akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

bool is_ok(ll value, ll limit, vector<ll> &a) {
    ll count = 0;
    for (auto i: a) {
        if (i <= value) continue;
        count += floor((double)i / value);
        if (count > limit) return false;
    }
    return true;
}

ll binarySearch(ll left, ll right, ll limit, vector<ll> &a) {
    ll mid = (left + right) / 2;
    while (right - left > 1) {
        if (is_ok(mid, limit, a)) {
            right = mid;
        }
        else {
            left = mid;
        }
        mid = (left + right) / 2;
    }
    return right;
}

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    ll maxSize = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        maxSize = max(maxSize, a[i]);
    }
    cout << binarySearch(0, maxSize, k, a) << endl;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}


struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string str; scan(str);
      long n = str.size();
      long res = 0;
      for(long i = 0; i < n; i+=2) {
         bool t = true;
         for(long k = 0; k < i / 2; ++k) {
            if( str[k] != str[k+i/2] ) t = false;
         }
         if( t ) res = std::max(res, i);
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

int main() {
  int N;
  char S;

  cin >> N;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == 'Y') flag = true;
  }
  if (flag)
    puts("Four");
  else
    puts("Three");
}

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

using namespace std;

int main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    vector<char> s(n + 1);
    char p;
    int max_4;
    bool check = false;

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

    max_4 = max(c, d);

    /*
    for (int i = 1; i <= n; i++)
    {
        cout << s[i] << " ";
    }
    cout << endl;
    */

    for (int i = a; i < max_4; i++){
        if(s[i] == '#' and s[i + 1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    
    if(d < c){
        for (int i = b - 1; i < d; i++){
            if (s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.')
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

fn main() {
    let n: usize = read();
    let mut ok = true;
    for _ in 0..n {
        if read::<usize>() % 2 != 0 {
            ok = false;
        }
    }
    println!("{}", if !ok { "first" } else { "second" });
}

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


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

int main() {
  vector<int> a(3);
  rep(i, 0, 3) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;
  return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
ANS = [0]*N
for i in range(Q):
    ANS[A[i]-1] += 1
for i in range(N):
    if ANS[i] >= Q - K + 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8640
N,K=map(int,input().split())

i=0
a=[]
if K==10:
    print(len(str(N)))
else:
    while N>=K**i:
        i+=1
    i-=1
    for j in range(i+1):
        a.append(N//(K**(i-j)))
        N%=(K**(i-j))
        
    print(len(a))        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    int t=testcases;
    while(testcases--){  
        int n;
        cin>>n;
        int a[n];
        fori(0,n){
            cin>>a[i];
        }
        sort(a,a+n);
        int c=0;
        fori(0,n){
            forj(i+1,n){
                for(int k=j+1;k<n;k++){
                    if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k]) continue;
                    if(a[i]+a[j]>a[k]){
                        c++;
                    }
                }
            }
        }
        cout<<c<<endl;
    }               

    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

void tansaku(vector<vector<ll>>& path, vector<bool>& check, ll pos);

int main(){
  ll N, M;
  cin >> N >> M;
  
  vector<vector<ll>> path(N + 1, vector<ll>(0));
  for (ll i = 0; i < M; i++){
    ll a, b;
    cin >> a >> b;
    
    path.at(a).push_back(b);
    path.at(b).push_back(a);
  }
  
  vector<bool> check(N + 1, false);
  ll ans = -1;
  for (ll i = 1; i <= N; i++){
    if (check.at(i) == false){
      tansaku(path, check, i);
      ans++;
    }
  }
  
  cout << ans << endl;
  
}

void tansaku(vector<vector<ll>>& path, vector<bool>& check, ll pos){
  if (check.at(pos) == false){
    check.at(pos) = true;
    for (ll i : path.at(pos)){
      tansaku(path, check, i);
    }
  }
  
}

Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, K;
  cin >> N >> K;
  
  int sum = 1;
  
  for (int i =0; i < N; i++) {
    
    if (sum < K) {
      sum *= 2;
      if (i == (N-1)) {
        cout << sum << endl;
        break;
      }
    }
    
    else if (sum >= K) {
      sum += K;
      if (i == (N-1)) {
        cout << sum << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    V<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    for(int i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
            ans+=a[i]-a[i+1];
            a[i+1]=a[i];
        }
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 4764
n=int(input())
xy=[]
for _ in range(n):
	x,y=map(int, input().split())
	xy.append([x,y])

ans=0
for i in range(n):
	for j in range(n):
		ans += ((xy[j][0]-xy[i][0])**2 + (xy[j][1]-xy[i][1])**2)**0.5
		
print(ans/n)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};



int main(){
    string a,b;cin >> a >> b;
    int x,y;cin >> x >> y;
    string u;cin >> u;
    if(u==a) x--;
    else if(u==b) y--;
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 100000
using namespace std;
typedef long long llong;
llong T[MAX];
int n, k;

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong x = 0;
		while(x + T[i] <= P){
            x += T[i];
            i++;
            if(i == n)return n;
        }
	}
	return i;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> T[i];
    llong left = 0;
    llong right = 100000 * 100000;
    llong mid;
	while (right - left > 1) {
		llong mid = (right + left) / 2;
        int v =check(mid);
		if (v >= n)right = mid;
		else left = mid;
	}
	cout << right << endl;
	return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s, t;
	cin>>s>>t;
	int flag=1;
	for(int i=0; i<s.length(); i++)
	{
		if(s[i] != t[i])
		{
			flag = 0;
			break;
		}
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  cout << n*(n-1)/2 << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,i,m=0;
cin>>n;
long long a[n];
for(i=0;i<n;i++){
    cin>>a[i];
}sort(a,a+n);
for(i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
m=1;break;
    }
}if(m==1)
cout<<"NO";
else
cout<<"YES";
    return 0;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = min(a, k);
	k -= a;
	if (k > 0)
		k -= b;
	if (k > 0)
	{
		ans -= k;
	}

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

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

int main(void)
{
    bool judge = false;
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int a[110],b[110];
    for(int i = 0;i < n;i++){cin >> a[i];}
    for(int i = 0;i < m;i++){cin >> b[i];}
    sort(a,a+n);
    sort(b,b+m);
    for(int i = x + 1;i < y;i++)
    {
        if(a[n - 1] < i && b[0] >= i)
        {
            judge = true;
            break;
        }
    }
    if(judge){cout << "No War" << endl;}
    else{cout << "War" << endl;}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin >> s;
	int n = (int)s.size();
	REP(i, n){
		if (i == 5 || i == 13) cout << " ";
		else cout << s[i];
	}

	cout << endl;
}


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

using namespace std;

int main(){

	int N;
	string S;
	cin >> N >> S;
	bool flag = true;
	if (N % 2 == 0){
		for (int i = 0; i < N / 2; i++)
			if (S[i] != S[N / 2 + i])
				flag = false;
	}
	else
		flag = false;

	flag ? cout << "Yes" : cout << "No";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
///supercalifragilisticexpialidocious.
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
const int MAXN = 2e2 + 10;
int n , l[MAXN] , sum;
int main()
{
    cin >> n;
    for(int i = 0 ; i < 2 * n ; i ++)
        cin >> l[i];
    sort(l , l + 2 * n);
    for(int i = 0 ; i < 2 * n ; i += 2)
        sum += l[i];
    return cout << sum << endl , 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double w = sc.nextDouble();
		double h = sc.nextDouble();
		double x = sc.nextDouble();
		double y = sc.nextDouble();
		if(x==w/2 &&y==h/2) {
			System.out.println(w*h/2 +" " + 1);
		}else {
			System.out.println(w*h/2 +" " + 0);
		}
		
		
	}

}


Measured memory_bytes: 23124
using System;
using System.Collections;
using System.Collections.Generic;

namespace ABC124 {
  class ProblemB {
    static void Main(string[] args) {
      int n = Input.num;
      int[] h = Input.nums;
      
      bool view;
      int ans = 0;
      for (int i = 0; i < n; i++) {
        view = true;
        for (int j = 0; j < i; j++) {
          if (h[i] >= h[j]) {
            view = view && true;
          } else {
            view = view && false;
          }
        }
        if (view) {
          ans++;
        }
      }
      System.Console.WriteLine(ans);
    }
  }
  public class Input {
    public static string str => System.Console.ReadLine();
    public static string[] strs => str.Split(' ');
    public static char[] charArr => str.ToCharArray();
    public static int num => int.Parse(str);
    public static int[] nums => Array.ConvertAll(strs, int.Parse);
    public static long numL => long.Parse(str);
    public static long[] numLs => Array.ConvertAll(strs, long.Parse);
  }
}


Measured memory_bytes: 11092
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> a(n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
    }

    lint max = *std::max_element(a.begin(), a.end());

    lint half = max / 2;

    lint min = 1e9 + 1;
    lint best;

    for (auto a_e : a)
    {
        lint tmp = a_e;
        if (tmp > half)
            tmp = max - tmp;
        lint dif = half - tmp;
        if (min > dif && max != a_e)
        {
            min = dif;
            best = a_e;
        }
    }

    printf("%lld %lld", max, best);

    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int N;
int two[7] = {1,2,4,8,16,32,64};
int main(){
    cin >> N;
    int answear;
    for(int i=0;i<7;++i){
        if(two[i]>N){
            answear = two[i-1];
            break;
        }
        else{
            answear = 64;
        }
    }
    cout << answear<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<vector<int>,int> P;
int n,ans=9;
vector<int> v[2];
map<vector<int>,int> s[2];

void bfs(bool f){
  queue<P> Q;
  Q.push(P(v[f],0));
  while(!Q.empty()){
    P t=Q.front();Q.pop();
    vector<int> b=t.first;
    int d=t.second;
    if(f&&s[0].count(b))ans=min(ans,s[0][b]+d);
    if(s[f].count(b))continue;
    s[f][b]=d;
    if(d==4)continue;
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
	reverse(b.begin()+i,b.begin()+j+1);
	Q.push(P(b,d+1));
	reverse(b.begin()+i,b.begin()+j+1);
      }
  }
}

int main(){
  cin>>n;
  for(int i=1,a;i<=n;i++){
    cin>>a;
    v[0].push_back(a);
    v[1].push_back(i);
  }
  bfs(0),bfs(1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 126836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main(){
  int N;
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];
  sort(a,a+N);
  cout << a[N-1] - a[0] << endl;
}
  





Measured memory_bytes: 256
def readints():
    return list(map(int, input().split()))


D, N = readints()


def check(x):
    c = 0
    while x % 100 == 0:
        c += 1
        x /= 100
    return c == D


cnt = 0

for i in range(1, 10000000):
    if check(i):
        cnt += 1
        if cnt == N:
            print(i)
            exit()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int cnt=0;
  string s;
  cin>>s;
  char now=s[0];
  for(int i=1;i<s.size();i++){
    if(now!=s[i]){
      cnt++;
      now=s[i];
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

int taste(int L, int idx) {
    return L + idx - 1;
}
 
int main() {
    int N, L;
    cin >> N >> L;

    int applePi = 0;
    bool flag = false;
    for (int i = 1;  i < N+1; ++i) {
        if (taste(L, i) == 0) {
            flag = true;
        }
        applePi += taste(L, i);
    }
    if (flag) {
        cout << applePi << endl;
    } else if (applePi > 0) {
        cout << applePi - taste(L, 1) << endl;
    } else if (applePi < 0) {
        cout << applePi - taste(L, N) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
h,w,n = gets.split(" ").map(&:to_i)
h_data = Array.new(h+1, 0)
w_data = Array.new(w+1, 0)
data = Hash.new(false)
n.times do |i|
  h_1, w_1 = gets.strip.split.map(&:to_i)
  data[[h_1, w_1]] = true 
  h_data[h_1] += 1
  w_data[w_1] += 1
end

h_c = h_data.max
w_c = w_data.max

h_max = []
w_max = []

h_data.each_with_index do |i, index|
  if i == h_c
    h_max << index
  end
end
    
w_data.each_with_index do |j, index|
  if j == w_c
    w_max << index
  end
end


max = h_c + w_c 


h_max.each do |x|
  w_max.each do |y|
    if data[[x,y]]
    else
      puts max
      exit
    end
  end
end


max -= 1

puts max


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var s = Console.ReadLine();

			var charIndexDictionary = new Dictionary<char, int>();

			for(var i = 0; i < s.Length; i++)
			{
				if(!charIndexDictionary.ContainsKey(s[i]))
				{
					charIndexDictionary.Add(s[i], i);
				}
			}

			var hashset = new HashSet<string>();
			var count = 0;

			foreach(var keyValuePair1 in charIndexDictionary)
			{
				var str1 = s.Skip(keyValuePair1.Value + 1).ToList();

				foreach(var keyValuePair2 in charIndexDictionary)
				{
					var index = -1;

					for(var i = 0; i < str1.Count - 1; i++)
					{
						if(keyValuePair2.Key == str1[i])
						{
							index = i;
							break;
						}
					}

					if (index != -1)
					{
						var str2 = s.Skip(keyValuePair1.Value + index + 2).ToList();

						foreach (var keyValuePair3 in charIndexDictionary)
						{
							for (var i = 0; i < str2.Count; i++)
							{
								if (keyValuePair3.Key == str2[i])
								{
									count++;
									break;
								}
							}
						}
					}
				}
			}
			
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 28512
/*  CF_CC_
            4U7H0R:_C4551DY */

#include <bits/stdc++.h>
#include <fstream>

using namespace std;

typedef long long ll;

#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(a,b,c) for(ll a=b;a<c;a++)
#define lb lower_bound
#define pii pair<int,int>
#define vec vector<int>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
#define len length()
#define rev reverse
#define con continue

const int mxi=1e5+666;
const ll mod=1e9;
const ll inf=1e18;

ll n,x,t;

int main(){
    IC
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t;
}


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

int main() {
    long long int n, count = 0;
    cin >> n;
    int a[n+1], b[n];
    for(int i = 0; i < n+1; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        cin >> b[i];
    }

    for(int i = 0; i < n; ++i) {
        if(a[i] <= b[i]) {
            count += a[i];
            b[i] -= a[i];
            a[i] = 0;
        } else {
            count += b[i];
            a[i] -= b[i]; 
            b[i] = 0;
        }
        if(a[i+1] <= b[i]) {
            count += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
        } else {
            count += b[i];
            a[i+1] -= b[i]; 
            b[i] = 0;
        }
    }
    cout << count << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;


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

  int ans = 0;
  int z1, z2;
  int disc;
  for (int n = 1; n <= N; ++n){
    ans = 0;
    for (int x = 1; x <= 100; ++x){
      for (int y = 1; x * x + y * y + x * y <= n; ++y){
        for (int z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= n; ++z){
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, s, x;

main () {
	cin >> n >> m;
	while (m--) {
		cin >> x;
		s += x;
	}
	cout << max(-1ll, n - s) << endl;
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		2505

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

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

//
int main(){
	int N;cin>>N;
	V A(N);
	REP(i,N)cin>>A[i];

	double ans = 0.0;
	ll lcmn = 1;
	REP(i,N)lcmn *= A[i]/gcd(A[i],lcmn);
	ll sita = 0;
	REP(i,N)sita += lcmn/A[i];


	printf("%0.6lf\n",(double)lcmn/sita);


	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,h;
    cin >>a>>b>>h;
    cout<<((a+b)*h)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#-*-coding:utf-8-*-
from collections import Counter

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    counter = Counter(a_list)
    ans = 1

    if n % 2 == 0:
        if all(counter[i] == 2 for i in range(1, n, 2)):
            ans = 2 ** (n // 2)
        else:
            ans = 0
    else:
        if all(counter[i] == 2 for i in range(2, n, 2)) and counter[0] == 1:
            ans = 2 ** (n // 2)
        else:
            ans = 0
    print(ans % (10 ** 9 + 7))
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 14812
#include <iostream>
using namespace std;
static int N_MAX = 100;

void p(int A[], int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
}

int bubbleSort(int A[], int N) {
	int count = 0;
	int flag = 1;
	while (flag) {
		flag = 0;
		for (int j = 1; j < N; ++j) {
			if (A[j] < A[j - 1]) {
				int a = A[j];
				A[j] = A[j - 1];
				A[j - 1] = a;
				flag = 1;
				++count;
			}
		}
	}
	return count;
}

int main() {
	int N;
	int A[N_MAX];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	int count = bubbleSort(A, N);
	p(A, N);
	cout << count << endl;
}

Measured memory_bytes: 1160
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	ans = max(a, b);
	ans += max(ans - 1, min(a, b));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var x = double.Parse(Console.ReadLine());

        var i = (int)Math.Ceiling((Math.Sqrt(8 * x + 1) - 1) / 2);
        Console.WriteLine(i);
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef long long ll;
typedef pair<int,int> P;

mat mul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size()));
  for(int i=0;i<A.size();i++){
    for(int k=0;k<B.size();k++){
      for(int j=0;j<B[0].size();j++){
	C[i][j]=(C[i][j]+A[i][k]*B[k][j]);
      }
    }
  }
  return C;
} 

mat pow(mat A,ll n){
  mat B(A.size(),vec(A.size()));
  for(int i=0;i<A.size();i++)B[i][i]=1;
  while(n>0){
    if(n&1)B=mul(B,A);
    A=mul(A,A);
    n>>=1;
  }
  return B;
}

int main(void){

  int n,m,z,s,d;
  vector<P>G;

  while(cin >> n >> m >> z,n|m|z){
    G.clear();
    G.push_back(P(1,1));
    for(int i=0;i<m;i++){
      cin >> s >> d;
      G.push_back(P(s,d));
      G.push_back(P(d,s));
    }

    mat A(G.size(),vec(G.size()));
 
    for(int i=0;i<G.size();i++)
      for(int j=0;j<G.size();j++)
	if(i!=j && j && G[i].f!=G[j].s && G[i].s==G[j].f)A[i][j]=1;

    A=pow(A,z);

    bool fg=false;
    for(int i=0;i<A.size();i++)
      if(G[i].s==n && A[0][i])fg=true;

    cout << (fg?"yes":"no") << endl;
  }
  return 0;
}

Measured memory_bytes: 1380
#include <iostream>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++) //これを宣言
#include <set>


int main() {
  int num, happiness, something;
  cin >> num;
  something = num / 500;
   happiness = something*1000;
   happiness = ((num - something*500)/5)*5 + happiness;
   cout << happiness;
  return 0;
}


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

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] W = new int[10];
		int[] K = new int[10];
		
		for(int i = 0; i < 10; i++)
			W[i] = sc.nextInt();
		
		for(int i = 0; i < 10; i++)
			K[i] = sc.nextInt();
		
		Arrays.sort(W);
		Arrays.sort(K);
		
		int w = W[9] + W[8] + W[7];
		int k = K[9] + K[8] + K[7];
			
		System.out.println(w + " " + k);
		
		sc.close();
	}
}

Measured memory_bytes: 17172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var cs = new int[3][];
        for(var i = 0; i < 3; i++)
            cs[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        for(var i = 0; i < 100; i++)
        {
            if (i > cs[0][0]) { WriteLine("No");return; }
            var b1 = cs[0][0] - i;
            var a2 = cs[1][0] - cs[0][0] + i;
            var a3 = cs[2][0] - cs[0][0] + i;
            var b2 = cs[0][1] - cs[0][0] + b1;
            var b3 = cs[0][2] - cs[0][0] + b1;
            if(a2+b2==cs[1][1]&&
                a2+b3==cs[1][2]&&
                a3+b2==cs[2][1]&&
                a3 + b3 == cs[2][2]) { WriteLine("Yes");return; }
        }
    }
}


Measured memory_bytes: 13268
N,K=map(int,input().split())
p=[int(i) for i in input().split()]
a=[]
ans=0
for i in p:
    ans+=(i+1)/2
    a.append(ans)
k=0
for t in range(0,N-K):
    tt=a[t+K]-a[t]
    k=max(k,tt)
print(k if k!=0 else a[-1])

Measured memory_bytes: 25188
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var Q = int.Parse(inputs[1]);
        var S = Console.ReadLine();
        var l = new int[Q];
        var r = new int[Q];
        for (int i = 0; i < Q; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            l[i] = int.Parse(inputs[0]);
            r[i] = int.Parse(inputs[1]);
        }

        var counts = new int[N + 1];
        for (int i = N - 1; i >= 0; i--)
        {
            if (i < N - 1)
            {
                if (S.Substring(i, 2) == "AC")
                {
                    counts[i]++;
                }
            }
            counts[i] += counts[i + 1];
        }

        for (int i = 0; i < Q; i++)
        {
            var valueL = l[i];
            var valueR = r[i];
            var ans = counts[valueL - 1] - counts[valueR - 1];
            Console.WriteLine(ans);
        }

    }
}



Measured memory_bytes: 18756
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] e = new int[n+1];
    for(int i=1;i<=n;i++){
      int t=i;
      for(int j=2;j<=t;j++){
        while(t%j==0){
          e[j]++;
          t/=j;
        }
      }
    }
    int cnt2 = 0;
    int cnt4 = 0;
    int cnt14 = 0;
    int cnt24 = 0;
    int cnt74 = 0;
    int ans = 0;
    for(int i=2;i<=n;i++){
      if(e[i]>=2)cnt2++;
      if(e[i]>=4)cnt4++;
      if(e[i]>=14)cnt14++;
      if(e[i]>=24)cnt24++;
      if(e[i]>=74)cnt74++;
    }
    ans=cnt74+cnt24*(cnt2-1)+cnt14*(cnt4-1)+cnt4*(cnt4-1)*(cnt2-2)/2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;


int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  int count = 0;
  for(int i=0;i<n;i++){
    cin >> h[i];
    if(h[i] >= k){
      count += 1;
    }
  }
  cout << count <<endl;
  return 0;
}


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

bool is_prime(int n) {
  for (int i = n-1; i >= 2; i--) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  int X; cin >> X;
  int np = X;
  while (true) {
    if (is_prime(np)) break;
    np++;
  }
  printf("%d\n", np);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

ll N;

ll f(ll n, int k) {
  if (n / k == 0) return 0;
  return n / k + f(n / k, k);
}

int main() {
  cin >> N;

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  cout << min(f(N / 2, 2) + N / 2, f(N / 2, 5)) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static class Node {
        long x, y, val;
        Node() {}
        Node(long x, long y, long val) {
            this.x = x;
            this.y = y;
            this.val = val;
        }
    }
    private static long[][] dp;
    private static int n;
    private static Map<Integer, Long> M;
    private static int total;

    private static long process(Node[] arr, int s) {
        if (M.containsKey(s)) return M.get(s);
        List<Node> list = new ArrayList();
        long ans = Long.MAX_VALUE;
        long sum = 0L;
        for (int j = 0; j < n; j++) if ((s & (1 << j)) > 0) {
            list.add(arr[j]);
            sum += arr[j].val;
        }

        Collections.sort(list, (a, b) -> (int) (a.x - b.x));
        int pos = 0;
        long cnt = list.get(0).val;
        while (cnt < (sum + 1) / 2) {
            pos++;
            cnt += list.get(pos).val;
        }
        long x = list.get(pos).x;
        long cal = 0;
        for (int i = 0; i < list.size(); i++) cal += Math.abs(x - list.get(i).x) * list.get(i).val;
        ans = Math.min(ans, cal);

        Collections.sort(list, (a, b) -> (int) (a.y - b.y));
        pos = 0;
        cnt = list.get(0).val;
        while (cnt < (sum + 1) / 2) {
            pos++;
            cnt += list.get(pos).val;
        }
        long y = list.get(pos).y;
        cal = 0;
        for (int i = 0; i < list.size(); i++) cal += Math.abs(y - list.get(i).y) * list.get(i).val;
        ans = Math.min(ans, cal);

        M.put(s, ans);
        return ans;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        Node[] a = new Node[n];
        M = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long x = scan.nextLong();
            long y = scan.nextLong();
            long val = scan.nextLong();
            a[i] = new Node(x, y, val);
        }
        total = 1 << n;
        dp = new long[n + 1][total];
        for (int s = 1; s < total; s++) {
            long cnt = 0;
            for (int j = 0; j < n; j++) if ((s & (1 << j)) > 0) {
                cnt += Math.min(Math.abs(a[j].x), Math.abs(a[j].y)) * a[j].val;
            }
            dp[0][s] = cnt;
        }
        for (int i = 1; i <= n; i++) {
            for (int s = 1; s < total; s++) {
                if (dp[i - 1][s] == 0) {
                    dp[i][s] = 0;
                    continue;
                }
                long cnt = Long.MAX_VALUE;
                for (int s1 = s; s1 != 0; s1 = (s1 - 1) & s) {
                    int s2 = s ^ s1;
                    cnt = Math.min(cnt, dp[i - 1][s2] + process(a, s1));
                }
                dp[i][s] = cnt;
            }
            if (dp[i][total - 1] == 0) break;
        }
        for (int i = 0; i <= n; i++) System.out.println(dp[i][total - 1]);
    }
}


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

int main() {
    int n;
    set<int> s;
    
    for (int i=0; i<3; ++i) {
        cin >> n;
        s.insert(n);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  long long int suf[n+1];
  suf[n]=0;
  suf[n-1]=arr[n-1];
  for(int i=n-2;i>=0;i--)
  {
    suf[i]=arr[i]^suf[i+1];
  }
  int pre[n+1];
  pre[0]=arr[0];
  arr[0]=suf[1];
  for(int i=1;i<n;i++)
  {
    pre[i]=arr[i]^pre[i-1];
    arr[i]=pre[i-1]^suf[i+1];
  }
  for(int i=0;i<n;i++)
    cout<<arr[i]<<" ";
  cout<<endl;
}

Measured memory_bytes: 7472
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define LL long long
#define pr std::pair<int,int>
#define mk(a,b) std::make_pair(a,b)
#include<cmath>
LL S; 
int main(){
	scanf("%lld",&S);
	LL sqr=(LL)sqrt((long double)S);
	if(sqr*sqr!=S)sqr++;
	LL res=sqr*sqr-S;
	printf("%lld %lld %lld %lld %lld %lld\n",0ll,0ll,sqr,res?1ll:0ll,res,sqr);
//	printf("%lld\n",sqr*sqr-res*1);
	
}



Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7

D = [[0]*(K+1) for i in range(N+1)]
D[0][0] = 1

# nはn個のボールをいれるのを1から順番に考える
for n in range(1, N+1):
    D0 = D[n-1]
    # kはkこの箱にnこれいた場合の数
    for k in range(1, K+1):
        # 前回D[n-1][k-1]はk-1個の箱にn-1個入れてるので、それにn個めを新しい箱に入れるとD0[k-1]を足すことになる
        # 前回D[n-1][k-1]はk-1個の箱にn-1個入れてて、それぞれにn個めを1個足してくとそのパターンはk*D0[k]個ある
        # 頭ヨ
        D[n][k] = (D0[k-1] + k * D0[k]) % MOD
print(sum(D[N]) % MOD)


Measured memory_bytes: 29340
let toExponentials n =
    seq {
        yield 1
        for p in 2 .. n do
            yield!
                Seq.unfold (fun s ->
                    let a = pown p s
                    if a > n then None else Some(a, s + 1)) 2
    }

let readInt _ = stdin.ReadLine() |> int

()
|> readInt
|> toExponentials
|> Seq.max
|> printfn "%d"


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

void run() {
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >>x >> y;
        if (x * x + y * y <= d * d) ++ans;
    }
    cout <<ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    run();
    return 0;
}


Measured memory_bytes: 3496
N = int(input())
S = []
for _ in range(N):
    S.append(input())
ac=0
wa=0
tle=0
re=0
for i in S:
    if i =='AC':
        ac+=1
    elif i=='TLE':
        tle+=1
    elif i=='WA':
        wa+=1
    elif i=='RE':
        re+=1
print('AC x '+str(ac))
print('WA x '+str(wa))
print('TLE x '+str(tle))
print('RE x '+str(re))



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

int main(){
  int n;
  cin >> n;
  int a[n];
  int res[n];
  for (int i = 0; i < n; i++){
  	cin >> a[i];
  }
  
  int p = 1;
  long long tmp = 0;
  for (int j = 0; j < n; j++){
  	tmp = tmp + p*a[j];
    p *= -1;
  }
  res[0] = tmp;
  
  for (int k = 1; k < n; k++){
  	res[k] = 2*a[k-1] - res[k-1];
  }
  
  for (int l = 0; l < n; l++){
  	cout << res[l] << " ";
  }
  
  return 0;
}


Measured memory_bytes: 2048
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	map_delete
# CreatedDate:  2020-07-15 11:23:30 +0900
# LastModified: 2020-07-15 11:29:50 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    q = int(input())
    dictionary = {}
    for _ in range(q):
        command = list(input().split())
        if command[0] == '0':
            dictionary[command[1]] = int(command[2])
        elif command[0] == '1':
            if command[1] in dictionary.keys():
                print(dictionary[command[1]])
            else:
                print(0)
        else:
            if command[1] in dictionary.keys():
                del dictionary[command[1]]



if __name__ == "__main__":
    main()



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<int> check(k, 0);
  int d = 7%k;
  int ans = 1;

  while(1){
    if(d==0){cout<<ans; return 0;}
    else if(check.at(d)!=0){cout<<-1; return 0;}
    else {check.at(d)=1; ans++;}
    d = (d*10+7)%k;
  }
}

Measured memory_bytes: 7160
import heapq
from math import ceil
n, m = map(int, input().split())
nums = [-int(i) for i in input().split()]
heapq.heapify(nums)

for _ in range(m):
    m = ceil(heapq.heappop(nums) / 2)
    heapq.heappush(nums, m)

nums = [-n for n in nums]
print(sum(nums))


Measured memory_bytes: 14532
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    tmp = 1
    ans = 0
    for i in range(n - 1):
        if a[i + 1] == a[i]:
            tmp += 1
        else:
            ans += tmp // 2
            tmp = 1
    print(ans + tmp // 2)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  string S;
  cin >> N;
  
  //入力を並べた文字列を作成。
  for(int i = 0; i < N; i++)
  {
    string temp;
    cin >> temp;
    S += temp;
  }
  
  //Yがあるかどうかのみを確認
  if(0 < count(S.cbegin(), S.cend(), 'Y'))
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256