akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll n, vector<string> S) {
  vector<int> cnt(26, 1e9);
  for (auto &s: S) {
    vector<int> v(26);
    for (char c: s) {
      ++v[c - 'a'];
    }
    REP(i,26) chmin(cnt[i], v[i]);
  }
  string res;
  REP(i,26) res += string(cnt[i], i + 'a');
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll n;
	scanf("%lld", &n);
	vector<string> S(n-1+1);
	for (int i = 0 ; i <= n-1 ; i++) {
	  cin >> S[i];
	}
	solve(n, S);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
  public class Main {
    public static void main(String[] args) {
     
        //sec--1 (definition)
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long cal = 1;
        long max = (long)Math.pow(10,18);
      
        //sec--2 (loop,0)
        for(int i=0; i<N; i++){
          A[i] = sc.nextLong();
          if(A[i]==0){
            System.out.println(0);
            return;
          }
        }
      
        //sec--3 (loop,-1.cal)
        //returnで初期に戻るので
        if(cal != 0) {
        for(int i=0; i<N; i++){
          if(max/cal < A[i]){
            System.out.println(-1);
            return;
          } else {
            cal *= A[i];
          }
        }
        }
            System.out.println(cal);
            return;
    }
  }

Measured memory_bytes: 62048
#include <bits/stdc++.h>
using namespace std;
int n,m,t,sum;
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) {
        scanf("%d",&t);
        sum+=t;
    }
    if(n<sum) printf("-1");
    else printf("%d",n-sum);
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, prev, it = 0, answer = 0;
    cin >> n >> prev;
    for(int i = 1; i < n; i++)
    {
        int in; cin >> in;
        if(prev >= in) it++; else it = 0;
        prev = in, answer = max(it, answer);
    }
    cout << answer;
}

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[] a = new int[n];
		for(int i=0;i<n;i++)
		  a[i] = sc.nextInt();
        //i番目
        
        int[] ans = new int[n];//正解順
        for(int i=0;i<n;i++)
           ans[a[i]-1]=i+1;
        for(int i=0;i<n;i++)
		  // 出力
		  System.out.print(ans[i]+" ");
	}
}

Measured memory_bytes: 64976
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<cmath>
#include<limits>

using namespace std;

int main() {
	int64_t A, B, C, D;
	cin >> A >> B >> C >> D;
	int64_t ans = B - A + 1;
	int64_t nC = B / C - (A - 1) / C;
	int64_t nD = B / D - (A - 1) / D;
	int64_t tmp;
	if (C <= D) {
		tmp = C;
		C = D;
		D = tmp;
	}
	int64_t C2 = C;
	int64_t D2 = D;
	int64_t r = C % D;
	while (r != 0) {
		C2 = D2;
		D2 = r;
		r = C2 % D2;
	}
	int64_t lcm = C * D / D2;
	int64_t nCD = B / lcm - (A - 1) / lcm;
	cout << ans - nC - nD + nCD << endl;
	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);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        System.out.println(distance(x1, y1, x2, y2));
    }

    public static double distance(double x1, double y1, double x2, double y2) {
        double d1 = x1 - x2;
        double d2 = y1 - y2;
        return Math.sqrt(d1 * d1 + d2 * d2);
    }
}

Measured memory_bytes: 18384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);

	if(N%2==0){
		prin(N/2-1);
	}
	else{
		prin(N/2);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dp[50][4];

int main() {
	int n;
	while(cin >> n && n) {

		vector<int> p(n + 1), t(n + 1);
		rep(i, n) cin >> p[i + 1] >> t[i + 1];

		rep(i, 50) rep(j, 4) dp[i][j] = INF;

		int id = -1;
		dp[0][0] = 0;
		rep(i, n) {
			int d = abs(p[i+1] - p[i]);
			bool flag = true;

			rep(j, 4) {
				if(dp[i][j] == INF) continue;

				if(j < 3 && d * (j + 1) <= t[i+1] - t[i]) {
					flag = false;
					dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + d);
				}

				if(p[i] * (j + 1) + p[i+1] <= t[i+1] - t[i]) {
					flag = false;
					dp[i+1][1] = min(dp[i+1][1], dp[i][j] + p[i] + p[i+1]);
				}
			}

			if(flag) {
				id = i+1;
				break;
			}
		}

		if(id != -1) cout << "NG " << id << endl;
		else {
			int ans = INF;
			rep(j, 4) {
				ans = min(ans, dp[n][j] + p[n]);
			}
			cout << "OK " << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;





signed main() {
    ll n, m;
    cin >> n >> m;
    
    ll r = 0;
    ll cnt = 0;
    
    map <ll, ll> mp;
    
    ll a, b;
    rep(i, n) {
        cin >> a >> b;
        mp[a] += b;
    }
    
    for (auto i: mp) {
        rrep(j, i.second) {
            cnt++;
            r += i.first;
            if (cnt >= m) {
                mes(r);
                re0;
            }
        }
    }
    
    
    
    
}

Measured memory_bytes: 9836
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> hist;
	for (int i = 0; i <= N; i++) hist.push_back(0);
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		hist[tmp]++;
	}
	sort(hist.begin(), hist.end(), greater<int>());
	int num = N;
	for (int i = 0; i < K; i++) num -= hist[i];

	cout << num << endl;
	return 0;
}

Measured memory_bytes: 1400
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn z_algorithm(s: &str) -> Vec<usize> {
    let mut res = vec![0; s.len()];

    res[0] = s.len();

    let mut i = 1;
    let mut j = 0;

    while i < s.len() {
        while i + j < s.len() && s[i + j..i + j + 1] == s[j..j + 1] {
            j += 1;
        }
        res[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while k < j && k + res[k] < j {
            res[i + k] = res[k];
            k += 1;
        }
        i += k;
        j -= k;
    }

    res
}

fn main() {
    input! {
        n:usize,
        s:String,
    }
    let mut ans = 0_usize;
    for i in 0..n - 1 {
        ans = std::cmp::max(
            z_algorithm(&s[i..])
                .iter()
                .enumerate()
                .map(|(i, &x)| if x >= i + 1 { i } else { x })
                .max()
                .unwrap(),
            ans,
        );
    }
    println!("{}", ans);
}


Measured memory_bytes: 2236
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b,c,d; cin >> a >> b >> c >> d;
  cout << (a-c)*(b-d) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num[3];
	int temp, i, j;

	scanf("%d %d %d", &num[0], &num[1], &num[2]);
	for(i = 0;i < 2;i++)
		for(j = i + 1;j < 3;j++)
			if(num[i] > num[j])
			{
				temp = num[i];
				num[i] = num[j];
				num[j] = temp;
			}
	printf("%d %d %d\n", num[0], num[1], num[2]);

	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  int ans = 0;
  int first,second;
  while(n--){
    cin>>first>>second;
    if(first==second) ans++;
    
    else {
      if(ans<3) ans = 0;
    }
  }
  
  if(ans>=3) cout<<"Yes\n";
  else cout<<"No\n";
  
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,mod=1e9+7;
#define ll long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
    ll A, B, C;
    cin >> A >> B >> C;
    
    int ans = 0;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        if (A == B && B == C) {
            cout << -1 << endl;
            return;
        }
        ll nA = (B + C) / 2, nB = (A + C) / 2, nC = (A + B) / 2;
        A = nA;
        B = nB;
        C = nC;
        ans++;
    }
    cout << ans << endl;
    
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
/*
 _  __    _   _   _ ____ _____ 
| |/ /   / \ | | | / ___|_   _|
| ' /   / _ \| | | \___ \ | |  
| . \  / ___ \ |_| |___) || |  
|_|\_\/_/   \_\___/|____/ |_|  
*/
#include <bits/stdc++.h>
#include <fstream>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
vii v;
vii dp;
int n;
int happy(int prev,int now){
    if(now==n){
        return 0;
    }
    if(dp[prev][now]!=-1){
        return dp[prev][now];
    }
    int maxi = 0;
    rep(i,0,3){
        if(prev!=i){
            maxi = max(maxi,v[now][i] + happy(i,now+1));
        }
    }
    dp[prev][now] = maxi;
    return maxi;
}
int main()
{
    cin >> n;
    v.resize(n,vi(3));
    dp.resize(4,vi(n,-1));
    rep(i,0,n){
        rep(j,0,3){
            cin >> v[i][j];
        }
    }
    cout << happy(3,0);
}

Measured memory_bytes: 15096
#include<stdio.h>

#define SIZE 100001

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

  int c[SIZE], t[SIZE];
  int min=1001;
  int tle = 1;
  for(int i=0; i<n; i++){
    scanf("%d", &c[i]);
    scanf("%d", &t[i]);
    if(t[i]<=T){
      tle = 0;
      if(i==0 || min>c[i]){
	min = c[i];
      }
    }
  }

  if(tle){
    printf("TLE\n");
    return 0;
  }
  else{
    printf("%d\n", min);
    return 0;    
  }
  

  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define N 1299709
int main() {
	int i, j, *p,cnt=0,n;
	p = (int*)calloc(N + 1, sizeof(int));
	for (i = 2; i <= (int)sqrt((double)N); ++i) if (!*(p + i)) for (j = i*i; j <= N; j += i) *(p + j) = 1;
	for (; ~fscanf(stdin, "%d", &n),n!=0;fprintf(stdout, "%d\n", cnt)) {
		cnt = 0;
		if (!*(p + n)) continue;
		while (!*(p)) {
			if (!*(p + n))break;
			n--;
		}
		for (i = n+1,cnt=1;*(p + i); i++) cnt++;
	}
	free(p);
	return 0;
}

Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,k,q;
  cin>>n>>k>>q;

  vector<int> ps(n,k-q);
  for(int i=0;i<q;i++){
    int a;
    cin>>a;
    a--;
    ps[a]++;
  }

  for(int i=0;i<n;i++)
    cout<<(ps[i]>0?"Yes":"No")<<endl;
  return 0;
}


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

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,m,ans=0;
vector <pii> v;

int main()
{
	cin>>n>>m;
	rep(i,n)
	{
		int x,y;
		cin>>x>>y;
		v.pb({x,y});
	}
	sort(v.begin(),v.end());
	rep(i,v.size())
	{
		if(v[i].se>=m)
		{
			ans+=v[i].fi*m;
			cout<<ans<<endl;
			rt0;
		}
		ans+=v[i].se*v[i].fi;
		m-=v[i].se;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 2420
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());

  int ans = 0;
  REP(i,n) FOR(j,i+1,n){
    int sum = a[i]+a[j];
    int r = lower_bound(a.begin(),a.end(),sum) - a.begin();
    int l = j+1;
    ans += max(0LL,r-l);
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;

struct Node{
	int x, y;
	bool operator<(const Node& o) const
	{
		return x * y < o.x * o.y;
	}
}a[4];

int main() 
{
	cin >> a[0].x; a[0].y = 8;
	cin >> a[1].x; a[1].y = 4;
	cin >> a[2].x; a[2].y = 2;
	cin >> a[3].x; a[3].y = 1;
	ll n; cin >> n; n *= 4;
	sort(a, a + 4);
	ll ans = 0;
	for (int i = 0; i < 4; i++)
	{
		ans += a[i].x * (n / (8 / a[i].y));
		n %= (8 / a[i].y);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int now=A[0], cnt=1, ans=0;
    for(int i=1; i<N; i++){
        if(A[i]==now) cnt++;
        else{
            if(cnt>=now) ans+=cnt-now;
            else ans+=cnt;

            now=A[i];
            cnt=1;
        }
    }
    if(cnt>=now) ans+=cnt-now;
    else ans+=cnt;

    cout << ans;


    return 0;
}

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

int dp[3010][3010]={0};
string s,t;

int main(){
  cin >> s;
  cin >> t;

  for(int i=0;i<s.size();++i){
    for(int j=0;j<t.size();++j){
      if(s[i]==t[j]) dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
    }
  }

  string ans="";
  int i=s.size();
  int j=t.size();
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j]){
      --i;
    }else if(dp[i][j]==dp[i][j-1]){
      --j;
    }else{
      ans=s[i-1]+ans;
      --i;
      --j;
    }
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 35584
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int hextoi(string S)
{
    int sum = 0;
    
    if(isdigit(S[0]))
    {
        sum += (S[0] - 48) * 16;
    }
    else
    {
        sum += (S[0] - 87) * 16;
    }
    if(isdigit(S[1]))
    {
        sum += S[1] - 48;
    }
    else
    {
        sum += S[1] - 97;
    }
    
    return sum;
}

const vector<string> color = { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

int main()
{
    string S;
    
    while(true)
    {
        cin >> S;
        
        if(S == "0") { break; }
        
        int R = hextoi(S.substr(1, 2));
        int G = hextoi(S.substr(3, 2));
        int B = hextoi(S.substr(5, 2));
        
        int near = 999999999, c = -1;
        
        for(int i = 0; i < 8; i++)
        {
            int R2 = ((i / 4) % 2 ? 255 : 0);
            int G2 = ((i / 2) % 2 ? 255 : 0);
            int B2 = ((i / 1) % 2 ? 255 : 0);
            
            int N2 = (R - R2) * (R - R2) + (B - B2) * (B - B2) + (G - G2) * (G - G2);
            
            if(N2 < near)
            {
                near = N2; c = i;
            }
        }
        
        cout << color[c] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3224
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sumA=[0]
for i in range(N):
  sumA.append(sumA[-1]+A[i])
sumB=[0]
for i in range(M):
  sumB.append(sumB[-1]+B[i])

ans=0
for i in range(N+1):
  k=K-sumA[i]
  if k<0:
    break
  left=0
  right=M
  while right>=left:
    mid=(right+left)//2
    if sumB[mid]>k:
      right=mid-1
    else:
      left=mid+1
  l=right
  ans=max(ans,i+l)
print(ans)

Measured memory_bytes: 47332
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i) 
#endif

#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int EPS = 1e-9;
const int MOD = 1e9+7;

 vector<bool> isprime(100005);

void eratos(int n){
  REP(i,n+1){
    isprime[i] = true;
  }
  isprime[0] = false;
  isprime[1] = false;
  int last = ((int)sqrt(n)) + 1;
  FOR(i,2,last){
    if(isprime[i]){
      int j = i+i;
      while(j <= n){
	isprime[j] = false;
	j += i;
      }
    }
  }
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  eratos(100004);
  vi Like(100006,0);//Like[i] => iまでの2017みたいな数の個数
  Like[0] = 0;
  Like[1] = 0;
  for(int i = 3; i <= 100005; i += 2){
    Like[i] = Like[i-2];
    if(isprime[i] && isprime[(i+1)/2]) Like[i]++;
  }
  int q;
  cin >> q;
  REP(i,q){
    int l,r;
    cin >> l >> r;
    int ans  =  Like[r] - Like[l-2];
    cout << ans << endl;
  } 
  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define fn(i,a,b) for(ll i=a;i>b;i--)
#define fne(i,a,b) for(ll i=a;i>=b;i--)
#define fm(it,m) for(it = m.begin();it != m.end();++it)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
double dp[3000];
int n=0;
double p=0;
 
int main()
{  
   IOS;
 
   cin>>n;
   
   dp[0]=1;
   
   fe(i,1,n)
   {
      cin>>p;
 
      fne(j,i,0)
       { 
         if(j==0)
            dp[j] = dp[j]*(1-p);
         
         else {
            dp[j] = dp[j-1]*p + dp[j]*(1-p);
         }
       }
    }
   
   double ans=0;
  
   fe(i,(n+1)/2,n)
    ans+=dp[i];
 
   cout<<setprecision(10)<<ans; 
       
 return 0;
}

Measured memory_bytes: 3804
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> text;
string buf;

int row, col;

void func_a(){
	col = 0;
}

void func_e(){
	col = text[row].size();
}

void func_p(){
	if (row > 0) row--;
	col = 0;
}

void func_n(){
	if (row < text.size() - 1) row++;
	col = 0;
}

void func_f(){
	if (col < text[row].size()) col++;
	else if (row < text.size() - 1){
		col = 0;
		row++;
	}
}

void func_b(){
	if (col > 0) col--;
	else if (row > 0){
		row--;
		col = text[row].size();
	}
}

void func_d(){
	if (col < text[row].size()) text[row].erase(col, 1);
	else if (row < text.size() - 1){
		text[row] += text[row + 1];
		text.erase(text.begin() + row + 1);
	}
}

void func_k(){
	if (col < text[row].size()){
		buf = text[row].substr(col, text[row].size() - col);
		text[row] = text[row].substr(0, col);
	}
	else if (row < text.size() - 1){
		func_d();
		buf = "\n";
	}
}

void func_y(){
	if (!buf.empty()){
		if (buf == "\n"){
			text.insert(text.begin() + row + 1, text[row].substr(col, text[row].size() - col));
			text[row].erase(col, text[row].size() - 1);
			row++;
			col = 0;
		}
		else {
			text[row].insert(col, buf);
			col += buf.size();
		}
	}
}

int main()
{
	string in;
	char cmd;

	while (getline(cin, in), in != "END_OF_TEXT"){
		text.push_back(in);
	}
	
	col = row = 0;
	buf.clear();

	while (cin >> cmd, cmd != '-'){
		switch (cmd){
		  case 'a': func_a(); break;
		  case 'e':	func_e(); break;
		  case 'p':	func_p(); break;
		  case 'n': func_n(); break;
		  case 'f': func_f(); break;
		  case 'b':	func_b(); break;
		  case 'd':	func_d(); break;
		  case 'k': func_k(); break;
		  case 'y': func_y(); break;
		}
#if 0
		printf("col:%d row:%d\n", col, row);
		puts("status:");
		for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
			cout << *it << endl;
		}
		puts("buffer:");
		cout << buf << endl;
#endif
	}

	
	for (vector<string>::iterator it = text.begin(); it != text.end(); it++){
		cout << *it << endl;
	}
	return (0);
}

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

int main(void){
    char a, b;
    cin >> a >> b;
    if (a=='H'){
        if (b=='H') cout << "H" << endl;
        else cout << "D" << endl;
    }
    else{
        if (b=='H') cout << "D" << endl;
        else cout << "H" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
    int n;
    scanf("%d",&n);
  int a[n+1];
  int b[n+1];
  int c[n+1];
  int d[n+1];
  
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    b[i]=a[i]%2;
    c[i]=a[i]%3;
    d[i]=a[i]%5;
    }

  for(int i=0;i<n;i++){
    if(b[i]==0){
      if(c[i]!=0 && d[i]!=0){
        printf("DENIED");
        return 0;
    }
  }
  }
    printf("APPROVED");
  return 0;
}

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

using namespace std;

int main () {
    string T, S;
    int count = 0, i;
    cin >> S;
    while(cin >> T, T != "END_OF_TEXT") {
        for (i=0;i < T.size(); i++) {
            if(T[i]>= 'A' && T[i] <= 'Z')
                T[i] += 32;
        }
        if(T == S)
            count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 1192
//AtCoder1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream> 
#include <algorithm>
#include <math.h> 
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) { cout << "No" << endl; }
    else if (c - a - b >= 0) {
        if (4 * a * b < (c - a - b) * (c - a - b)) { cout << "Yes" << endl; }
        else { cout << "No" << endl;}                                                                                             
    }
}


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

using namespace std;
typedef long long ll;


int main() {



	ll n;

	cin >> n;
	vector<ll> keys(n + 1);

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

	for (ll i = 1;i <= n;i++) {

		cout << "node " + to_string(i) + ": ";
		cout << "key = " + to_string(keys[i]) + ", ";

		if (i > 1) 	cout << "parent key = " + to_string(keys[i / 2]) + ", ";
		if (i * 2 <= n) cout << "left key = " + to_string(keys[i * 2]) + ", ";
		if (i * 2 + 1 <= n) cout << "right key = " + to_string(keys[i * 2 + 1]) + ", ";

		cout << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3256
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
        return 1
    if r == 1:
        return n % mod 
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
x,y = map(int,input().split())
if 2*x-y < 0 or 2*y-x<0 or (2*x-y) % 3 != 0:
    print(0)
    exit()
a = (2*x-y)//3
b = (2*y-x)//3
print(cmb(a+b,min(a,b),mod))


Measured memory_bytes: 3572
s=input()
if s=="keyence":
	print("YES")
	quit()
for i in range(len(s)):
	for p in range(i,len(s)):
		if i==0 and p==len(s)-1:
			continue
		if i==0:	
			t=s[p+1]
			if t=="keyence":
				print("YES")
				quit()
		if p==len(s)-1:
			t=s[:i]
			if t=="keyence":
				print("YES")
				quit()
		t=s[:i]+s[p+1:]
		if t=="keyence":
				print("YES")
				quit()
print("NO")

Measured memory_bytes: 3064
n=int(input())
s=list(input())
count_east=[0]*n
count_west=[0]*n
counts=[0]*n

for i in range(n-2,-1,-1):
    if s[i+1]=='E':
        count_east[i]=count_east[i+1]+1
    else:
        count_east[i]=count_east[i+1]
for i in range(1,n):
    if s[i-1]=='W':
        count_west[i]=count_west[i-1]+1
    else:
        count_west[i]=count_west[i-1]
for i in range(n):
    counts[i]=count_east[i]+count_west[i]

print(min(counts))

Measured memory_bytes: 31692
N = int(input())
W = list(map(int,input().split()))

min_deff = sum(W)
for i in range(1,len(W)):
    S1 = sum(W[:i])
    S2 = sum(W[i:])
    deff = abs(S1 - S2)
    if deff<min_deff:
        min_deff = deff

print(min_deff)

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


using namespace std;
double pi=3.14159265358979323846264338;


inline void ex(){cout<<"NO"<<endl;exit(0);}
long long a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	long long n=a*c;
	n=max(n,a*d);
	n=max(n,b*c);
	n=max(n,b*d);
	cout<<n<<endl;
	return 0;
			
}

Measured memory_bytes: 3632
from numba import njit
import numpy as np


@njit("i8(i8)")
def solve(n):
    ans = 1
    res = np.ones(n + 1, dtype=np.int64)
    for i in range(2, n + 1):
        for j in range(i, n + 1, i):
            res[j] += 1
        ans += i * res[i]
    return ans


N = int(input())
print(solve(N))


Measured memory_bytes: 188648
#include<bits/stdc++.h>
#define N 1000000
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin>>n;
  int arr[n];
  for(int i = 0;i <n; i++)
    cin>>arr[i];
 
  map<int,int> counts;
  
  /********sieve*************/
  vector<int> min_prime(N+1,0);
  for(int i = 2; i * i <= N;i++) {
    if(min_prime[i] == 0) {
      for(int j = i * i; j <= N; j+=i) {
        if(min_prime[j] == 0)
          min_prime[j] = i;
      }
    }
  }
  for(int i = 2; i <= N;i++) {
    if(min_prime[i] == 0) {
      min_prime[i] = i;
    }
  }
  /*****sieving ends*****/
  
  bool pairwise_coprime = true;
  bool setwise_coprime = true;
  for(int i =0;i < n;i++) {
    set<int> factors;
    while(arr[i] != 1) {
      factors.insert(min_prime[arr[i]]);
      arr[i] = arr[i] / min_prime[arr[i]];
    }
    for(auto it = factors.begin();it != factors.end();it++) {
      counts[*it]++;
    }
  }
  
  for(auto it = counts.begin(); it!= counts.end(); it++) {
    //cout<<it->first<<" "<<it->second<<endl;
   	if(it->second == n)
      setwise_coprime = false;
    if(it->second > 1)
      pairwise_coprime = false;
  }
  if(!pairwise_coprime) {
    if(setwise_coprime)
        cout<<"setwise coprime\n";
    else
    	cout<<"not coprime\n";
  } else {
    cout<<"pairwise coprime\n";
  }
  return 0;
}

Measured memory_bytes: 14692
import java.util.Scanner;

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

    	for(int i=1; i<=n; i++) {
    		String str2 = String.valueOf(i);
    		str += str2;
    	}
    	
    	permutation(str, "");
    }
    		
    public static void permutation(String q, String ans){
    	// Base Case
    	if(q.length() <= 1) {
  		    if(ans.length() != 0) ans += " ";
    		System.out.println(ans + q);
    	}
    	// General Case
    	else {
    		for (int i = 0; i < q.length(); i++) {
    			if(ans.length() == 0) permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
    			else permutation(q.substring(0, i) + q.substring(i + 1),ans + " " + q.charAt(i));
    		}
    	}
    }    	
} 


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

int main()
{
    int n,a[100002] = {0},i,j,cost = 0,pos = 0;

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

    for (i = 1; i < n + 2; i++)
    {
        cost += abs(a[i] - pos);
        pos = a[i];
    }

    for (i = 1; i <= n; i++)
    {
        printf("%d\n",cost - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]));
    }
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    const auto& modpow = [](unsigned long a, unsigned long n, unsigned long b = 1) -> unsigned long {
        unsigned long r{b % MOD};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    vector<unsigned long> v(K + 1);
    unsigned long ans{0};
    for(unsigned long i{K}; i > 0; --i){
        v[i] = modpow(K / i, N);
        for(unsigned long j{2 * i}; j <= K; j += i)v[i] += MOD - v[j];
        ans += i * (v[i] %= MOD) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
bool visited[100010];
long long int dp[100010];
vector<vector<long long int> > v(100010);
void dfs(long long int x)
{
	visited[x]=true;
	for(int i=0;i<v[x].size();i++)
	{
		if(!visited[v[x][i]])
		dfs(v[x][i]);
		dp[x]=max(dp[x],1+dp[v[x][i]]);
	}
}
int main()
{
	long long int n,m,i,x,y;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
	}
	memset(visited,false,sizeof(visited));
	memset(dp,0,sizeof(dp));
	for(i=1;i<=n;i++)
	{
		if(!visited[i])
		dfs(i);
	}
	long long int ans=0;
	for(i=1;i<=n;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 8576
module M = Map.Make (struct
  type t = int
  let compare = compare
end)
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let im = ref M.empty
let g a = im := M.add a (1 + try M.find a !im with _ -> 0) !im
let h a = im := match M.find a !im with 1 -> M.remove a !im | c -> M.add a (c - 1) !im
let rec f i = if i >= m then M.fold (fun a c s -> s + a * c) !im 0
  else let a, _ = M.max_binding !im in g @@ a / 2; h a; f @@ i + 1
let _ = Array.iter g a_s; Printf.printf "%d\n" @@ f 0

Measured memory_bytes: 12928
import collections
n = int(input())
a = list(map(int, input().split()))

c = dict(collections.Counter(a))

sum = 0
for v in c.values():
    sum += (v * (v - 1)) // 2

for i in a:
    temp = c[i] - 1
    ans = (temp * (temp - 1)) // 2
    ans += sum
    ans -= (c[i] * (c[i] - 1)) // 2
    print(ans)

Measured memory_bytes: 94028
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    int N, A, B;

    cin >> N >> A >> B;

    if ((B-A) % 2 == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
ll mx(ll a,ll b){if(a>=b) return a;return b;}
ll mn(ll a,ll b){if(a<b) return a;return b;}
#define pb push_back
#define mp make_pair
#define M (ll) (1e5+7)
#define INF (3e18)
typedef vector < vector<pll> > vvpll;
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0);
//    freopen("zotiland.gir","r",stdin);
//    freopen("zotiland.cik","w",stdout);
    string s;cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    else if(s=="Rainy")
        cout<<"Sunny"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  int p[N];
  for (int i = 0; i < N; i++) cin >> p[i];
  sort(p,p+N);
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import math

def dis(x1, y1, x2, y2):
    return ((x1 - x2)**2 + (y1 - y2)**2) ** (1/2)

def kaijo(n):
    return math.factorial(n)

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

sum = 0

for j in range(n):
    for i in range(n):
        if i != j:
            sum = sum + (dis(x[i], y[i], x[j], y[j])) * kaijo(n-1)

print(sum/kaijo(n))

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>

int main(void)
{
    int sq[20];
    int dp[301];
    int n;
    int i, j;
    
    for (i = 0; i < 17; i++){
        sq[i] = (i + 1) * (i + 1);
    }
    
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    
    for (i = 0; i < 17; i++){
        for (j = 0; j + sq[i] <= 300; j++){
            if (dp[j] != -1){
                dp[j + sq[i]] += dp[j];
            }
        }
    }
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        printf("%d\n", dp[n]);
    }
    
    return (0);
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) (1e9) * 2LL;

ll calc(ll X, ll s) {
    ll ret = 0, ng = INF;
    while (abs(ret - ng) > 1) {
        ll mid = (ret + ng) / 2;
        ll sum = mid * (s + mid - 1);
        if (sum > X)
            ng = mid;
        else
            ret = mid;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    ll x = abs(X - Y);
    if (x <= 1)
        cout << "Brown" << endl;
    else
        cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string n;
    cin >> n;
    

    int ans = 0;

    for(int i = 0;i<3;i++){
        if (n.at(i) == 'o'){
            ans++;
        }
    }
    int num = 100*ans;
    cout << 700+num << endl;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>

using namespace std;

typedef pair<int, int> P;

int main(){
    int H, W;
    char s[51][51];
    scanf("%d %d", &H, &W);
    for(int i = 0; i < H; i++){
        scanf("%s", s[i]);
    }
    int memo[50][50];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            memo[i][j] = -1;
        }
    }
    memo[0][0] = 1;

    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    queue<P> que;
    que.push(P(0,0));

    while(que.size()){
        P p = que.front();
        que.pop();
        if (p.first == H - 1 && p.second == W - 1) break;
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (0 <= nx && nx < H && 0 <= ny && ny < W && s[nx][ny] == '.' && memo[nx][ny] == -1){
                que.push(P(nx,ny));
                memo[nx][ny] = memo[p.first][p.second] + 1;
            }
        }
    }
    int ans = 0;
    int nb = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if (s[i][j] == '#') nb++;
        }
    }
    if(memo[H-1][W-1] == -1) puts("-1");
    else printf("%d\n", H * W - nb - memo[H-1][W-1]); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    int h,w;
    long long mod=1e9+7,dp[1001][1001]={0};
    cin>>h>>w;
    char a[1001][1001];
    rep(i,h)rep(j,w) cin>>a[i][j];
    dp[1][1]=1;
    rep(i,h)rep(j,w){
        if(a[i][j-1]=='.') dp[i+1][j+1]+=dp[i+1][j]%mod;
        if(a[i-1][j]=='.') dp[i+1][j+1]+=dp[i][j+1]%mod;
    }
    cout<<dp[h][w]%mod;
}

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;

int m, d;
int dh;

int enum_div(int n) {
	int ret = 0;
	for (int i = 2; i * i <= n && i < 10; ++i) {
		if (n % i == 0 && n / i < 10) {
			if (i * 10 + n / i <= d) {
				ret++;
				//printf("%d月%d%d日\n", n, i, n / i);
			}
			if (i * i != n && n / i * 10 + i <= d) {
				ret++;
				//printf("%d月%d%d日\n", n, n / i, i);
			}
		}
	}
	return ret;
}

int main(void) {
	cin >> m >> d;
	dh = d / 2;
	int ret = 0;
	for (int i = 4; i <= m; i++) {
		ret += enum_div(i);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
s = deque(input())
q = int(input())
a = 0
c = ""
for i in range(q):
    b = list(input().split())
    if b[0] == "1":
        if a == 0:
            a = 1
        else:
            a = 0
    else:
        if (a, b[1]) == (0, "1") or (a, b[1]) == (1, "2"):
            s.appendleft(b[2])
        else:
            s.append(b[2])
if a == 0:
    for i in range(len(s)):
        c += s.popleft()
else:
    for i in range(len(s)):
        c += s.pop()
print(c)

Measured memory_bytes: 6400
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String s = Console.ReadLine();
            String[] strInputList = s.Split();

            int a = int.Parse(strInputList[0]);
            int b = int.Parse(strInputList[1]);

            int dividedaAswer = a / b;        

            int remainderAnswer = a % b;

            Double dividedaAswerDouble = 1.0 * a / b;
            
            Console.WriteLine(dividedaAswer + " " + remainderAnswer + " " + dividedaAswerDouble.ToString("f5"));
        }
    }
}



Measured memory_bytes: 17944
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
ll X;
ll a[MAX_N];
ll p[MAX_N];

void init()
{
  a[0] = 1, p[0] = 1;
  for (int i = 0; i < N; i++) {
    a[i + 1] = a[i] * 2 + 3;
    p[i + 1] = p[i] * 2 + 1;
  }
}

ll f(ll N, ll X)
{
  if (N == 0) {
    return X <= 0 ? 0 : 1;
  }
  else if (X <= 1 + a[N - 1]) {
    return f(N - 1, X - 1);
  }
  else {
    return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1]);
  }
}

void solve()
{
  init();
  cout << f(N, X) << endl;
}

int main(void)
{
  cin >> N >> X;
  solve();
  return 0;
}


Measured memory_bytes: 256