akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int mod = 1000000007;
const int mod2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>> n >> m;
    UnionFind uf(n);
    for(int i = 0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
    };
    int ans = 0;
    for(int i =0;i<n;i++){
        int num = uf.size(i);
        ans = max(num,ans);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4000
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var max = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                max = Math.Max(max, Math.Abs(Math.Max(a[i], a[j]) - Math.Min(a[i], a[j])));
            }
        }

        Console.WriteLine(max);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;

const int INF = 1<<29;

int N;
vector<string> line(100);
map<string, int> label;
int to[101];
int d[101];
vector<int> from[101];

int main(){
    ios::sync_with_stdio(false);
    cin >> N;
    cin.ignore();
    for(int x = 0; x < N; x++){
        getline(cin, line[x]);
    }
    for(int x = 0; x < N; x++){
        to[x] = x+1;
        if(line[x].substr(0, 5) == "goto ") continue;
        label[line[x].substr(0, line[x].size()-1)] = x;
    }
    for(int x = 0; x < N; x++){
        if(line[x].substr(0, 5) != "goto ") continue;
        to[x] = label[line[x].substr(5, line[x].size()-6)];
    }
    for(int x = 0; x < N; x++){
        from[to[x]].push_back(x);
    }
    queue<P> que;
    que.push(P(N, 0));
    fill(d, d+N+1, INF);
    int ans = INF;
    while(!que.empty()){
        P p = que.front(); que.pop();
        int loc = p.first, cnt = p.second;
        if(d[loc] <= cnt) continue;
        d[loc] = cnt;
        if(cnt >= ans) continue;
        if(loc == 0){ ans = cnt; continue; }
        for(int x = 0; x < from[loc].size(); x++){
            que.push(P(from[loc][x], cnt));
        }
        if(to[loc-1] != loc){
            que.push(P(loc-1, cnt+1));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1268
#include <iostream>

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int N;
	int V[30];
	int val[30];
	int tmp;
	int tot = 0;
	cin >> N;
	
	for(int i=0;i<N;i++)
	{
		cin >> V[i];
	}
	for(int i=0;i<N;i++)
	{
		cin >> tmp;
		if(V[i] > tmp)
			tot = tot + (V[i] - tmp);
	}
	cout << tot;
	
	return 0;
}

Measured memory_bytes: 256
<?php
for ($i=1; ; $i++) { 
	$input = explode(' ', fgets(STDIN));
	$x = trim($input[0]);
	$y = trim($input[1]);

	if($x == 0 && $y == 0)
		break;
	if($x < $y)
		print($x.' '.$y."\n");
	else
		print($y.' '.$x."\n");
}

Measured memory_bytes: 6588
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	for(int i=b-a+1;i<b+a-1;i++)
	{
		printf("%d ",i);
	}
	printf("%d",b+a-1);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>a;
    Cout(n*n-a);
    return 0;
}


Measured memory_bytes: 256
def main():
    def f(n):
        return 3 * n + 1 if n % 2 else n // 2
    s = int(input())
    a = [s]
    for i in range(1, 11**6):
        x = f(a[i-1])
        if x in a:
            return len(a) + 1; exit()
        a.append(x)


print(main())

Measured memory_bytes: 9180
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    IN(ll, N);
    AIN(ll, A, N);
    ll M = *max_element(ALL(A));
    vi S(M + 1);
    ll g = 0;
    FOR(a, A)
    {
        ++S[a];
        g = gcd(g, a);
    }
    vector<bool> P(M + 1, true);
    P[0] = false;
    P[1] = false;
    bool pairwise_coprime = true;
    for (ll i = 2; i <= M; ++i)
    {
        if (P[i])
        {
            ll c = S[i];
            for (ll j = 2 * i; j <= M; j += i)
            {
                c += S[j];
                P[j] = false;
            }
            if (c >= 2)
            {
                pairwise_coprime = false;
            }
        }
    }
    if (pairwise_coprime)
    {
        OUT("pairwise coprime");
    }
    else if (g == 1)
    {
        OUT("setwise coprime");
    }
    else
    {
        OUT("not coprime");
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int out  = a + b;
	if (out <= a - b) out = a - b;
	if (out <= a * b) out = a * b;
	cout << out << endl;
	return 0;
}

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

int dp[100010];
class Jud
{
public:
    int calc(int n){
        int a;
        dp[0]=0;
        for(int i=1;i<=n;i++){
            dp[i]=dp[i-1]+1;
            for(int j=6;j<=i;j*=6){
                dp[i]=min(dp[i],dp[i-j]+1);
            }
            for(int j=9;j<=i;j*=9){
                dp[i]=min(dp[i],dp[i-j]+1);
            }
         }
        a=dp[n];
        return a;
     }
        
};
void solve(){
    Jud jud;
    int n,ans;
    cin>>n;
    ans=jud.calc(n);
    cout<<ans<<endl;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 640
from sys import setrecursionlimit
setrecursionlimit(10**8)


def dfs(i, d):
    # print(i, d)
    for j, w in node_array[i]:
        if color_array[j] == -1:
            color_array[j] = (d + w) % 2
            dfs(j, d + w)


N = int(input())
node_array = [[] for i in range(N)]
color_array = [-1] * N

for _ in range(N - 1):
    i, j, w = map(int, input().split())
    node_array[i - 1].append((j - 1, w))
    node_array[j - 1].append((i - 1, w))

color_array[0] = 0
dfs(0, 0)

for i in range(N):
    print(color_array[i])


Measured memory_bytes: 160160
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	m := getNextInt(scanner)
	d := getNextInt(scanner)

	fmt.Fprintln(writer, calc(m, d))
	writer.Flush()
}

func calc(m, d int) int {
	ans := 0
	for i := 1; i <= m; i++ {
		for ii := 22; ii <= d; ii++ {
			if ii%10 < 2 {
				continue
			}
			if i == (ii/10)*(ii%10) {
				ans++
			}
		}
	}
	return ans
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int n , k ;
double res ;

int main ()
{
	int i ;
	scanf("%d%d",&n,&k);
	for ( i=1 ; i<=n ; i++ )
		if ( i>=k ) res+=1.0/(double)(n);
		else 
		{
			int x=i ;
			double ans=1 ;
			while ( x<k ) x<<=1,ans*=0.5;
			res+=ans/(double)(n);
		}
	printf("%.12lf\n",res);
	return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	in(n);
	int ans = 0;
	ans += (n/500*1000);
	n-=(n/500)*500;
	ans += (n/5*5);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ary[][] = new int[N][4];
		for(int i = 0; i < N; i++){
			ary[i][0] = sc.nextInt();
			ary[i][1] = sc.nextInt();
			ary[i][2] = ary[i][0] + ary[i][1];
			ary[i][3] = i;
		}
		Arrays.sort(ary, Comparator.comparingInt(o -> o[2]));
		long a = 0;
		long b = 0;
		for(int i = 0; i < N; i++) {
			if(i % 2 == 0) {
				a += ary[N - 1 - i][0];
			} else {
				b += ary[N - 1 - i][1];
			}	
		}
		System.out.println(a - b);
	}
}


Measured memory_bytes: 94440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

// a -> 0, b -> 1, c -> 2
// dp[i][j] := i日目にjをしたときのmax
int N, a[1 << 17], b[1 << 17], c[1 << 17], dp[1 << 17][3];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i + 1] >> b[i + 1] >> c[i + 1];
    }

    dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];

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

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

struct UnionFind{
    vector<int> Parent;
    vector<int> sizes;
    UnionFind(int n):Parent(n),sizes(n,1){ rep(i,n)Parent[i]=i; }
    //find the root of x
    int root(int x){
        if(x!=Parent[x]){
        Parent[x] = root(Parent[x]);
        }
        return Parent[x];
    }
    //merge x and y
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        Parent[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return root(x) == root(y); }
    int size(int x){ return sizes[root(x)]; }
};

int main() {
	ll N,M;
	cin>>N>>M;
	vector<P> v(M);
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		v[i] = {a,b};
	}
	vector<ll> ans(M);
	ans[M-1] = N*(N-1)/2;
	UnionFind uni(N);
	for (int i = M-1; i >= 1; --i){
		int x = v[i].first;
		int y = v[i].second;
		ll linked_N = 0;
		if(uni.same(x,y)){
			ans[i-1] = ans[i] - linked_N;
			continue;
		}else{
			linked_N = uni.size(x) * uni.size(y);
			uni.unite(x,y);
			ans[i-1] = ans[i] - linked_N;
		}
	}
	rep(i,M)cout<<ans[i]<<endl;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <string.h>
using namespace std;

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

		if(s.find(t)!= string::npos)cout << "Yes" << endl;
		else cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long N = scanner.nextLong();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < N * 3; i++) {
			list.add(scanner.nextInt());
		}
		Collections.sort(list);
		Collections.reverse(list);
//		for (int i = 0; i < N ; i++) {
//			list.add(i * 3 + 2, list.remove(list.size() - 1));
//		}

		long sum = 0;
		for (int i = 0; i < N; i++) {
			sum += list.get(i * 2 + 1);
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 96144
package main

import "fmt"

func main() {
  var N, K int
  fmt.Scan(&N, &K)
  
  h := make([]int,N)
  for i:=0; i < N; i++ {
    fmt.Scanf("%d",&h[i])
  }
  
  cnt := 0
  for i:=0; i < N; i++ {
    if h[i] >= K {
      cnt += 1
    }
  }
  fmt.Println(cnt)
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define llrep(i,a,b) for(ll i=a;i<b;i++)
#define llrepd(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
static const double pi = 3.141592653589793;

//---------------------------------------------------------------------------------------------------
void _main(){
    double A, B, H, M; cin >> A >> B >> H >> M;
    double deg = abs((M / 60.0) - ((H / 12.0) + (M / 720.0))) * 360;
    if (deg > 180) deg = 360 - deg;
    // cout << deg << " " << cos(pi * deg/180.0) << endl;
    cout << fixed << setprecision(20) << sqrt(A*A + B*B - 2.0 * A * B * cos(pi * deg/180.0)) << endl;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n, m;
  cin >> n >> m;

  VI v(n, -1);

  int s, c;

  REP(i, m) {
    cin >> s >> c;
    if (v[s - 1] == -1) {
      v[s - 1] = c;
    } else if (v[s - 1] == c) {
      // do nothing
    } else {
      ANS(-1);
      return 0;
    }
  }

  if(n ==1){
    if(v[0]==-1){
      ANS(0);
      return 0;
    }
    else{
      ANS(v[0]);
      return 0;
    }
  }
  int flag = 0;
  REP(i, n) {
    if (flag == 0) {
      if (v[i] == 0) {
        ANS(-1);
        return 0;
      } else {
        if (v[i] == -1) {
          v[i] = 1;
          flag = 1;
        } else {
          flag = 1;
        }
      }
    } else {
      if (v[i] == -1) {
        v[i] = 0;
      }
    }
  }

  int ans = 0;
  REP(i, n) {
    ans += pow(10, n - i - 1) * v[i];
  }

  ANS(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        int result = 1;
        int d = 0;
        for (int i = 0; i < n && d <= x; i++) {
            d += l[i];
            if (d <= x) {
                result++;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }



int collatz(int n){
    int a=n;
    if(a%2 == 0)a/=2;
    else a = a*3+1;
    return a;
}

int main(){
    int N;
    cin >> N;

    int ma = 0;
    int ans = 0;
    rep(i,N){
        int p;
        cin >> p;
        ans += p;
        ma = max(ma,p);
    }
    cout << ans-(ma/2) << endl;


}



Measured memory_bytes: 3644
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let t = buf.trim();
	let byte_s = s.as_bytes();
	let byte_t = t.as_bytes();
	let mut flag = true;
	for number in 0..s.len() {
		if byte_s[number] != byte_t[number] {
			println!("No");
			flag = false;
			break;
		}
	}
	if flag {
		println!("Yes");
	}
}

Measured memory_bytes: 2096
n=int(input())
t=list(map(int, input().split()))
m=int(input())
for i in range(m):
  p,x=map(int, input().split())
  time=0
  for j in range(n):
    if j==p-1:
      time+=x
    else:
      time+=t[j]
  print(time)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
	sort(a,a+n,comp);
	int ans=0;
	for(int i=k;i<n;i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}













Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int p[] = new int[m];
		int y[] = new int[m];

		String s[] = new String[m];

		HashMap<Integer, TreeMap<Integer, Integer>> map = new HashMap<>();

		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			y[i] = sc.nextInt();

			map.computeIfAbsent(p[i], e -> new TreeMap<>()).put(y[i], i);

		}

		for (Entry<Integer, TreeMap<Integer, Integer>> a : map.entrySet()) {
			int i = 0;
			for (Entry<Integer, Integer> b : a.getValue().entrySet()) {

				String s1 = String.format("%06d", a.getKey());
				String s2 = String.format("%06d", ++i);
				s[b.getValue()] = s1 + s2;

			}

		}

		Arrays.stream(s).forEach(System.out::println);

		sc.close();

	}

}

Measured memory_bytes: 183376
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ int i, p, q, r; P(int i = 0, int p = 0, int q = 0, int r = 0) {} };
int cal(P& p)
{	return p.p * 4 + p.q * 9 + p.r * 4;	}
void operator>>(istream& _cin, P& _p)
{	_cin >> _p.i >> _p.p >> _p.q >> _p.r; }

int main()
{
    for(int n; cin >> n && n;)
	{
		vector<P> vec(n);
		
		rep(i, n) cin >> vec[i];
		
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;
		
		bool flag = true;
		rep(i, n) if(vec[i].p <= P && vec[i].q <= Q && vec[i].r <= R && cal(vec[i]) <= C)
		{
			flag = false;
			cout << vec[i].i << endl;
		}
		
		if(flag) cout << "NA" << endl;
	}
}

Measured memory_bytes: 920
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
int main()
{
    int ans = 0;
    int n;
    cin >> n;

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

    for (int i = 1; i < n - 1; i++)
    {
        if (a[i] == a[i + 1] && a[i] == a[i - 1])
        {
            if (a[i] != 1)
                a[i] = 1;
            else
                a[i] = 2;
            //cout << "change a[" << i << "] ";
            ans++;
        }
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (a[i] == a[i + 1])
        {
            if (i == 0)
            {
                a[i] = a[i + 1] + 1;
            }
            else
            {
                if (a[i - 1] != a[i + 1])
                    a[i] = a[i + 1] + 1;
                else
                    a[i] = a[i + 1] + 2;
            }
            //cout << "change" << a[i] << " ";
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
INF = 10**12
A, B, Q = map(int, input().split())
shrines = [-INF] + [int(input()) for _ in range(A)] + [INF]
temples = [-INF] + [int(input()) for _ in range(B)] + [INF]
for _ in range(Q):
  query = int(input())
  sh_pos = bisect_left(shrines, query)
  te_pos = bisect_left(temples, query)
  ans = INF
  for s in shrines[sh_pos-1:sh_pos+1]:
    for t in temples[te_pos-1:te_pos+1]:
      dis = min(abs(s-query)+abs(s-t),abs(t-query)+abs(t-s))
      ans = min(ans, dis)
  print(ans)


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    VVL dp(n + 1, VL(2, -1e17));
    dp[0][0] = 0;
    REP(i, n) {
        dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
        dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
    }
    cout << dp[n][0] << ln;
    return 0;
}


Measured memory_bytes: 6144
#include<stdio.h>
#include<math.h>

#define N 200000

void main(){
  long int a[N], n, cnt[N];
  scanf("%ld",&n);
  for(int i=1; i<n; i++)
    scanf("%ld ",&a[i]);
  
  for(int i=0; i<n; i++)
    cnt[i] = 0; 
    
  for(int i=1; i<n; i++)
    cnt[a[i]-1]++; 
  
  for(int i=0; i<n; i++)
    printf("%ld\n",cnt[i]);
}

Measured memory_bytes: 4860
c = int(input())

a = int (c / 100)
b = c % 100
if 0 < a < 13:
    if 0 < b < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < b < 13:
        print('YYMM')
    else:
        print('NA')






Measured memory_bytes: 2940
## subroutines

def dist2(p0, p1)
  (p1[0] - p0[0]) ** 2 + (p1[1] - p0[1]) ** 2
end

def pdist_rec(i, j)
  ij = j - i
  return 0 if ij <= 1
  return dist2($pts[i], $pts[i + 1]) if ij == 2

  if ij == 3
    return [dist2($pts[i], $pts[i + 1]),
            dist2($pts[i + 1], $pts[i + 2]),
            dist2($pts[i + 2], $pts[i])].min
  end

  k = (i + j) / 2
  d2 = [pdist_rec(i, k), pdist_rec(k, j)].min
  d = Math.sqrt(d2 + 0.5).to_i

  midx = $pts[k][0]
  spts = []

  (k - 1).downto(i) do |i0|
    break if midx - $pts[i0][0] >= d
    spts << $pts[i0]
  end

  for j0 in (k...j)
    break if $pts[j0][0] - midx >= d
    spts << $pts[j0]
  end

  spts.sort!{|a, b| a[1] <=> b[1]}
  nspts = spts.length

  for i0 in (0...nspts)
    for j0 in ((i0 + 1)...nspts)
      break if spts[j0][1] - spts[i0][1] >= d
      sd2 = dist2(spts[i0], spts[j0])
      if d2 > sd2
        d2 = sd2
        d = Math.sqrt(d2 + 0.5).to_i
      end
    end
  end

  d2
end

### main

n = gets.strip.to_i

$pts = n.times.map{gets.strip.split(' ').map{|s| s.to_i}}.sort
#p $pts

d2 = pdist_rec(0, n)
puts d2

Measured memory_bytes: 99236
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  q = [True] * 102
  for i in range(n):
    q[p[i]] = False
  d_min = 10**3
  for j in range(102):
    if q[j]:
      d = abs(x - j)
      if d_min > d:
        d_min = d
        ans = j
  print(ans)


Measured memory_bytes: 9068
n,m = map(int,input().split())
factor = [1,m]
for i in range(2,int(m**0.5)+2):
	if m%i == 0:
		factor.append(i)
		factor.append(m//i)	
factor.sort(reverse=True)
for f in factor:
	if f <= m//n:
		print(f)
		exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        int temp1,temp2;
        temp1 = i;
        temp2 = x - i;
        if(2 * temp1 + 4 * temp2 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#01:17
n = int(input())
for i in range(n):
  a = int(input())
  if i == 0:
    ans = a - 1
    now = 2
    continue
  if a == now:
    now += 1
    #print(a,now,ans)
    continue
  ans += (a-1) // now
  #print(a,now,ans)
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

#define N 10000

int search(int *,int,int);


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

  
  scanf("%d", &n2);
  
  for ( i = 0 ; i < n2 ; i++ ){
    scanf("%d", &key);
    if ( search(A, n, key) ){
      count++;
    }
  }
  
  printf("%d\n", count);


  return 0;
}



int search(int A[], int n, int key){
  
  int i;
  
  for ( i = 0; i < n; i++ ){
    
    if ( A[i] == key ) {
      return 1;
    }
    
  }
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>

#define MAX_N 55

int N, A[MAX_N];
int P;

long long dp[MAX_N][2];

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

	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		if (A[i] & 1) {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = dp[i - 1][1] + dp[i - 1][0];
		}
		else {
			dp[i][0] = dp[i - 1][0] + dp[i - 1][0];
			dp[i][1] = dp[i - 1][1] + dp[i - 1][1];
		}
	}
	printf("%lld\n", dp[N][P & 1]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX=100000;
static const int NIL=-1;

int n;
int color[MAX];
vector<int> G[MAX];

void dfs(int r,int c){
  stack<int> S;
  S.push(r);
  color[r]=c;

  while(!S.empty()){
    int u=S.top();
    S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
        color[v]=c;
        S.push(v);
      }
    }
  }
}

int main(){
    int m,s,t,q;

    cin>>n>>m;

    for(int i=0;i<m;i++){
      cin>>s>>t;
      G[s].push_back(t);
      G[t].push_back(s);
    }

    for(int i=0;i<n;i++){
      color[i]=NIL;
    }

    int id=1;

    for(int u=0;u<n;u++){
       if(color[u]==NIL){
         dfs(u,id++);
       }
    }


    cin>>q;
    for(int i=0;i<q;i++){
      cin>>s>>t;
      if(color[s]==color[t]){
        cout<<"yes"<<endl;
      }
      else{
        cout<<"no"<<endl;
      }
    }

  return 0;
}

Measured memory_bytes: 8928
#include <stdio.h>
int main(void){
  int n,i;
  char c;
  bool ans=false;
  scanf("%d\n",&n);
  for (i=0;i<n;i++){
    scanf("%c",&c);
    if (c=='Y'){
      ans=true;
      break;
    }
    scanf("%c",&c);
  }
  printf("%s\n",(ans)? "Four":"Three");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          int mn=1e9,mx=0,s=0;
	          for(i=1;i<=6;i++){
	        	  int x;
	        	  cin >> x;
	        	  if(i<=4){
	        		  s+=x;
	        		  mn=min(mn,x);
	        	  }else{
	        		  mx=max(mx,x);
	        	  }
	          }

	          cout << s-mn+mx << endl;

	          return 0;
}

Measured memory_bytes: 3008
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] p = new int[n];
			int sum = 0;
			for(int i=0;i<n;i++){
				p[i] = sc.nextInt();
				sum += p[i];
			}
			Arrays.sort(p);
			sum = (sum-p[0]-p[n-1])/(n-2);
			System.out.println(sum);
		}
	}	
}

Measured memory_bytes: 21076
n = int(input())
s = input()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha_c = [""]*26
for i in range(26):
    a = (i + n) % 26
    alpha_c[i] = alpha[a]
word = ""
for i in range(len(s)):
    for j in range(26):
        if alpha[j]==s[i]:
            word += alpha_c[j]
print(word)

Measured memory_bytes: 3060
n,m=map(int,input().split())
s=input()
res=[]
now=n
while now!=0:
    j=False
    for i in range(max(0,now-m),now):
        if s[i]=="0":
            j=True
            res.append(now-i)
            now=i
            
            break
    if not j:
        print(-1)
        exit()
for i in range(len(res)-1,-1,-1):
    print(res[i],end=" ")

Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define rep(a,b) for(ll int a=0;a<b;a++)
#define Tcase int t;cin>>t;while(t--)   
int main(){
  long int k,x;
  cin>>k>>x;
  long long int total=k*500;
  if(total>=x)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;

const int inf = 1000000000;//10^9

int main (){

  int N,L;
  cin >>N>>L;
  vector<string> S(N);
  rep(i,N){
    cin>>S[i];
  }

  sort(S.begin(),S.end());

  rep(i,N){
    cout<<S[i];
  }
  cout<<endl;


   return 0;

}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

cnt1 = 0
cnt2 = 0
cnt4 = 0
for a in A:
    if a%4 == 0:
        cnt4 += 1
    elif a%2 == 0:
        cnt2 += 1
    else:
        cnt1 += 1

if cnt1 <= cnt4:
    print("Yes")
elif cnt1 == cnt4 + 1 and cnt2 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 23096
n = gets.to_i
a = gets.split.map(&:to_i)
m1 = 0
m2 = 0
m4 = 0
a.each{|x|
  case x % 4
  when 0
    m4 += 1
  when 2
    m2 += 1
  else
    m1 += 1
  end
}
puts (m1 <= m4 or (m2 == 0 and m1 <= m4 + 1))  ? "Yes" : "No"

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll N, M; cin >>N>>M;

    vector<ll> A(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    sort(all(A));

    vector<int> B(M);
    vector<int> C(M);
    rep(i, M) cin >> B[i] >> C[i];

    vector<int> idx(M);
    iota(all(idx), 0);
    sort(all(idx), [&](int x, int y) {return C[x]>C[y];});

    int ia = 0;
    bool fbreak = false;
    for (int i = 0; i < M && ia < N && !fbreak; i++) {
        for (int j = 0; j < B[idx[i]] && ia < N; j++) {
            if (C[idx[i]] > A[ia]) {
                sum += C[idx[i]] - A[ia];
            } else {
                fbreak = true; break;
            }
            ia++;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 2176
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e12 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
    
    ll n;
    cin >> n;
    vector <pll> v;
    bool f = 0;
    for(ll i = 2; i * i <= n; i++) {
    	if(n % i == 0) {
    		v.pb({i, n / i});
    		f = 1;
		}
	}
    
    if(!f) {
    	cout << n - 1;
	}
	else {
		ll ans = INF;
		for(int i = 0; i < sz(v); i++) {
			cmin(ans, (v[i].F-1+v[i].S-1));
		}
		cout << ans;
	}
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll a[100000] = {};
ll b[100001] = {};
int main() {
	ll N; cin >> N;

	ll maxA = 0;
	rep(i, 0, N) {
		cin >> a[i];
		b[a[i]]++;
		maxA = max(maxA, a[i]);
	}
	ll maxV = 0;
	repe(i, 0, maxA + 1) {
		ll sum = 0;
		if (i != 0) {
			sum += b[i - 1];
		}
		sum += b[i];
		if (i != maxA + 1) {
			sum += b[i + 1];
		}
		maxV = max(maxV, sum);
	}
	cout << maxV << endl;

	return 0;
}

Measured memory_bytes: 1792
main(i,j,r){
  p[0]=p[1]=1;
  for(i=2;i<10001;i++)
    if(!p[i])
      for(j=i*2;j<10001;j+=i)p[j]=1;
  for(;~scanf("%d",&j);printf("%d\n",r))
    for(r=0,i=2;i<=j;i++)
      if(!p[i]&&!p[j-i+1])r++;
  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Binary Indexed Tree(1-indexed)
const int MAX_N = 220000;

struct BIT {
    int bit[MAX_N + 1] = {}, n;

    void init(int n_) {
        n = n_;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int N, K;
int a[220000];
pint ip[220000];
BIT bit;

signed main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) cin >> a[i];
    for (int i = 0; i <= N; i++)ip[i] = pint(a[i] - K, i);
    for (int i = 1; i <= N; i++)ip[i].first += ip[i - 1].first;
    sort(ip, ip + N + 1);
    bit.init(N + 1);

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        ans += bit.sum(ip[i].second + 1);
        bit.add(ip[i].second + 1, 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6912
import math
N = int(input())
n = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        a = i
        b = j
        c = math.gcd(a,b)
        for k in range(1, N+1):
            d = k
            e = math.gcd(c,d)
            n += e
print(n)

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

using namespace std;

typedef long long int ll;
 
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; }
 
typedef pair<int,int> pair;

int main(){
  int s,w; cin >> s >> w;
  if(s<=w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  
}

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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	vector<long long int>v(N);
	for(auto &i:v)cin>>i;
	map<int,int>mp;
	long long int ans=0;
	vector<int>er(N,-1);
	if(M-1<N)er[M-1]=0;
	mp[0]++;
	for(int i=0;i<N;i++){
		if(er[i]!=-1)mp[er[i]]--;
		v[i]--;
		if(i)v[i]+=v[i-1];
		v[i]%=M;
		ans+=mp[v[i]];
		mp[v[i]]++;
		if(i+M<N)er[i+M]=v[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 12032
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b==c || a+c==b || b+c==a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main(){
	let (n, d) = get!(usize, usize);
	let mut ans;
	if n % (2*d+1) == 0 {
		ans = n / (2*d+1);
	} else {
		ans = n / (2*d+1) + 1;
	}
	println!("{}", ans);
}

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

#define print(x) cout << (x) << '\n'
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(__null);
    
    int x; cin >> x;
    if (x == 3 || x == 5 || x == 7) print("YES");
    else print("NO");
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int countBits(int in){
  int res=0;
  rep(i,10){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

int main() {
  int n,k;cin>>n>>k;
  double ans=0.0;
  rep(i,n){
    ll val=i+1;
    int cnt=0;
    while(val<k){
      val*=2;
      cnt++;
    }
    ans+=1.0/n*pow(0.5,cnt);
    
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll h, a;
  cin >> h >> a;
  cout << (h + a - 1)/a;
  return 0;
} //good night.

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

using namespace std;

typedef long long ll;

#define INF 1e10
const int MOD = 1e9+7;

bool dp[111111];

int main(){
	dp[0]=1;
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 1; i <= k; i++){
		bool cur = 1;
		for(int j = 0; j < n; j++) if(i-a[j]>=0 && dp[i-a[j]]) cur=0;
		dp[i]=cur;
	}
	string s[]={"First","Second"};
	cout<<s[dp[k]];
}


Measured memory_bytes: 384