akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll read()
{
	register ll number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register ll x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll k=read(),a=read(),b=read(),c=0;
    if(a>=k)
    {
        write(1);
        putchar('\n');
        return 0;
    }
	else 
		if(b>=a)
		{
	        write(-1);
	        putchar('\n');
	        return 0;
	    }
		else 
			if((k-a)%(a-b)>=1)
	        	c=1;
    write(((k-a)/(a-b)+c)*2+1);
	putchar('\n');
	return 0;
}


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

using namespace std;

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

int main()
{
    vector<int> x(5);
    rep(i, 5)
    {
        cin >> x[i];
        if (x[i] == 0)
        {
            cout << i + 1 << endl;
            break;
        }
    }
}


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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct Qrys
{
	int a,t,id;
}Q[200010];
int n,X,q,a[200010],Ans[200010];
inline bool cmp(const Qrys a,const Qrys b)
{
	return a.t<b.t;
}
int main()
{
	X=read(); n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	q=read(); for(int i=1;i<=q;i++)
		Q[i].t=read(), Q[i].a=read(),Q[i].id=i;
	sort(Q+1,Q+1+q,cmp);a[0]=0;
	int lw=1,up=X,ll=1,uu=X; int j=1,ty=1;
	for(int i=1;i<=n;i++,ty^=1)
	{
		while(Q[j].t<=a[i]&&j<=q)
		{
			if(Q[j].a<=lw)
			{
				if(ty==1) Ans[Q[j].id]=max(ll-(Q[j].t-a[i-1]),0);
				if(ty==0) Ans[Q[j].id]=min(ll+(Q[j].t-a[i-1]),X);
			}
			else if(Q[j].a>=up)
			{
				if(ty==1) Ans[Q[j].id]=max(uu-(Q[j].t-a[i-1]),0);
				if(ty==0) Ans[Q[j].id]=min(uu+(Q[j].t-a[i-1]),X);
			}
			else 
			{
				if(ty==1) Ans[Q[j].id]=max(ll+(Q[j].a-lw)-(Q[j].t-a[i-1]),0);
				if(ty==0) Ans[Q[j].id]=min(ll+(Q[j].a-lw)+(Q[j].t-a[i-1]),X);
			}
			j++;
		}
		if(ty==1)
		{
			if(a[i]-a[i-1]>=ll)
			{
				lw+=a[i]-a[i-1]-ll;
				ll=0; uu=max(0,uu-a[i]+a[i-1]);
			}
			else 
			{
				ll-=a[i]-a[i-1];
				uu-=a[i]-a[i-1];
			}
		}
		else 
		{
			if(a[i]-a[i-1]>=X-uu)
			{
				up-=a[i]-a[i-1]-X+uu;
				uu=X; ll=min(X,ll+a[i]-a[i-1]);
			}
			else 
			{
				ll+=a[i]-a[i-1];
				uu+=a[i]-a[i-1];
			}
		}
	}
	while(j<=q)
		{
			if(Q[j].a<=lw)
			{
				if(ty==1) Ans[Q[j].id]=max(ll-(Q[j].t-a[n]),0);
				if(ty==0) Ans[Q[j].id]=min(ll+(Q[j].t-a[n]),X);
			}
			else if(Q[j].a>=up)
			{
				if(ty==1) Ans[Q[j].id]=max(uu-(Q[j].t-a[n]),0);
				if(ty==0) Ans[Q[j].id]=min(uu+(Q[j].t-a[n]),X);
			}
			else 
			{
				if(ty==1) Ans[Q[j].id]=max(ll+(Q[j].a-lw)-(Q[j].t-a[n]),0);
				if(ty==0) Ans[Q[j].id]=min(ll+(Q[j].a-lw)+(Q[j].t-a[n]),X);
			}
			j++;
		}
	for(int i=1;i<=q;i++) cout << Ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>

int main()
{
	int maxCap = 0, targetCap = 0, cubicCount = 0, cubicSize = 0, tetrahedralCount = 0, tetrahedralSize = 0, tmpCap = 0;
	for (; scanf("%d", &targetCap) && targetCap != 0; printf("%d\n", maxCap))
	{
		maxCap = 0, cubicCount = 0, cubicSize = 0, tetrahedralCount = 0, tetrahedralSize = 0, tmpCap = 0;
		for (;
			 cubicCount * cubicCount * cubicCount <= targetCap;
			 cubicCount++)
			maxCap = cubicCount * cubicCount * cubicCount;
		cubicCount--;
		if (maxCap == targetCap)
			continue;
		for (; cubicCount >= 0; cubicCount--)
		{
			for (cubicSize = cubicCount * cubicCount * cubicCount;
				 cubicSize + tetrahedralCount * (tetrahedralCount + 1) * (tetrahedralCount + 2) / 6 <= targetCap;
				 tetrahedralCount++)
				tetrahedralSize = tetrahedralCount * (tetrahedralCount + 1) * (tetrahedralCount + 2) / 6;
			tmpCap = cubicSize + tetrahedralSize;
			if (tmpCap > maxCap)
				maxCap = tmpCap;
			if (maxCap == targetCap)
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a, b, c;
  int i, j;
  for (i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  for (i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    b.push_back(tmp);
  }
  for (i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    c.push_back(tmp);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  vector<ll> bc(n + 1, 0);
  i = n - 1, j = n - 1;
  while(i >= 0 && j >= 0){
    if (b[i] >= c[j]) {
      bc[i] = bc[i + 1] + n - j - 1;
      i--;
    } else if (j == 0) {
      bc[i] = bc[i + 1] + n;
      i--;
    }else {
      j--;
    }
  }
  ll answer = 0;
  i = 0, j = 0;
  while(i < n && j < n){
    if (a[i] < b[j]) {
      answer += bc[j];
      i++;
    } else {
      j++;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 2424
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    n:usize,
    vec_a: [usize; n]
  }
  let mut mp = HashMap::new();
  for a in &vec_a {
    *mp.entry(a).or_insert(0) += 1;
    //mp[a]++;
  }

  let mut cnt = n;
  for i in 0..n {
    let s = vec_a[i];
    if let Some(&ss) = mp.get(&s) {
      if ss > 1 {
        cnt -= 1;
        continue;
      }
    }

    let mut d:Vec<usize> = Vec::new();
    divisor(s, &mut d);
    for x in d {
      if x==s {continue;}
      if let Some(&i) = mp.get(&x) {
        cnt -= 1;
        break;
      }
    }
  }

  println!("{}", cnt);
  //println!("Hello, AtCoder!");
}

fn divisor(n: usize, d: &mut Vec<usize>) -> usize {
  let mut cnt:usize = 0;
  let mut i:usize = 1;
  while i*i<=n {
    if n%i==0 {
      d.push(i);
      if i*i!=n {d.push(n/i);}

      cnt += 1;
    }
    i += 1;
  }

  return cnt;
}

Measured memory_bytes: 11544
na = lambda: list(map(int, input().split()))
h, w = na()
field = []
for i in range(h):
    field.append(list(map(int, input().split())))

ans = [] 
for i in range(h):
    for j in range(w-1):
        if field[i][j] % 2 == 1:
            ans.append([i+1, j+1, i+1, j+2])
            field[i][j] += 1
            field[i][j+1] -= 1
for i in range(h-1):
    if field[i][w-1] % 2 == 1:
        ans.append([i+1, w, i+2, w])
        field[i][-1] += 1
        field[i+1][-1] -= 1

print(len(ans))
for l in ans:
    print(" ".join(map(str, l)))

Measured memory_bytes: 29868
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

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

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	priority_queue<pair<int, int>>PQ;
	for (auto i : v) {
		PQ.push({ -i,1 });
	}
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		R *= -1;
		int sum = 0;
		while (L&&!PQ.empty()&&PQ.top().first > R) {
			auto box = PQ.top();
			PQ.pop();
			int num = min((int)L, box.second);
			L -= num;
			sum += num;
			box.second -= num;
			if (box.second)PQ.push({ box.first,box.second });
		}
		PQ.push({ R,sum });
	}
	long long int ans = 0;
	while (!PQ.empty()) {
		//cout << PQ.top().first << " " << PQ.top().second << endl;
		ans += 1LL * PQ.top().second*PQ.top().first;
		PQ.pop();
	}
	ans *= -1;
	cout << ans << endl;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

string s, t;
signed main() {
	cin >> s;
	t = s;
	reverse(t.begin(), t.end());
	rep(i, t.size()) {
		if (t[i] == 'b')t[i] = 'd';
		else if (t[i] == 'd')t[i] = 'b';
		if (t[i] == 'p')t[i] = 'q';
		else if (t[i] == 'q')t[i] = 'p';
	}
	if (s == t)puts("Yes");
	else puts("No");
	endre;
}

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {
	int n,v[20],c[20],tmp,sum=0;
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>v[i];
	}
	for (int i = 0; i < n; i++) {
		cin>>c[i];
		tmp=v[i]-c[i];
		if(tmp>0){
			sum+=tmp;
		}
	}


	cout<<sum<<"\n";



	return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

long long K,A,B,Ans=1;

int main(){
	scanf("%lld%lld%lld",&K,&A,&B);
	if(B<=2 || A+2>=B) printf("%lld",K+1);
	else{
		Ans=A;
		K=K-A+1;
		Ans+=(K&1)+(K>>1)*(B-A);
		printf("%lld",Ans);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int x = 1;
        int result = 0;
        while (x < b) {
            x += (a - 1);
            result++;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include<stdio.h>
int main(void)
{
    int n,i,flg = 0;
    int a,b,c;
    scanf("%d",&n);
    for(; n > 0; n--){
        a = b = c = 0;
        for(i = 0; i < 10; i++){
            scanf("%d",&a);
            if(b < a) b = a;
            else if(c < a) c = a;
            else flg = 1;
        }
        if(flg == 0) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 580
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846

int main(){
	FASTIO;
	ll n, m, x; cin >> n >> m >> x;
	ll mat[n][m + 1];
	for ( int k = 0; k < n; k++ ){
		cin >> mat[k][0];
		for ( int j = 1; j <= m; j++ )
			cin >> mat[k][j];
	}
	ll ans = 1000000000;
	for ( ll comb = 0; comb < (1 << n); comb++ ){
		ll temp = 0;
		ll v[m]; memset(v, 0, sizeof v);
		for ( int k = 0; k < n; k++ ){
			if (comb & (1 << k)) {
				for ( int j = 0; j < m; j++ ){
					v[j] += mat[k][j + 1];
				}
			temp += mat[k][0];
			}
		}
		bool flag = true;
		for ( int k = 0; k < m; k++ ){
			if (v[k] < x)
				flag = false;
		}
		if (flag)
			ans = min(ans, temp);
	}
	if (ans == 1000000000)
		ans = -1;
	cout << ans << endl;
	return 0;
}

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

int main(){
  int n, a, b;
  a = 0;
  cin >> n;
  vector<int> retu(n);
  for(int i = 0; i < n; i++){
    cin >> retu[i];
  }
  b = retu[0];
  for(int i = 0; i < n; i++){
    if(b >= retu[i]){
      a++;
      b = retu[i];
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

import static java.util.Comparator.naturalOrder;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int n = in.ni();
    List<Integer> list = new ArrayList<>();
    Map<Integer, Integer> count = new HashMap<>();
    for (int i = 0; i < n; i++) {
      int next = in.ni();
      list.add(next);
      count.put(next, count.getOrDefault(next, 0) + 1);
    }
    list.sort(naturalOrder());
    Set<Integer> has = new HashSet<>();
    int result = 0;
    for (int i = 0; i < n; i++) {
      int next = list.get(i);
      boolean divisible = false;
      for (int d = 1; d * d <= next; d++) {
        if (next % d == 0 && (has.contains(d) || has.contains(next / d))) {
          divisible = true;
          break;
        }
      }
      if (!divisible && count.get(next) == 1) {
        result++;
      }
      has.add(next);
    }
    out.println(result);
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 83640
'''input
3 5
1 2 1
2 3 0
'''
# connected components
from sys import stdin, setrecursionlimit
from bisect import bisect_left

# main starts
x = int(stdin.readline().strip())
mx = 10 ** 6 + 1
seive  = [0] * mx
prime = []
for i in range(2, mx):
    if seive[i] == 0:
        prime.append(i)
        for j in range(i* i, mx, i):
            seive[j] = 1
print(prime[bisect_left(prime, x)])


Measured memory_bytes: 51420
#include <stdio.h>
#define I 10000
int main(void)
{
    int i, j, u, x[I], y[I];
    i = 0;
    while(1) {
        scanf("%d %d", &x[i], &y[i]);
        if(x[i]==0 && y[i]==0)
            break;
        i++;
        u = i;
    }
         
         
         
         
    for(i = 0; i < u; i++) {
        if(x[i] > y[i]) {
            j = x[i];
        
            x[i] = y[i];
            y[i] = j;
        }
        printf("%d %d\n", x[i], y[i]);
    }
    
    return 0;
}
 

 

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="ABC")
    {
        cout<<"ARC";
    }
    else
    {
        cout<<"ABC";
    }
    return 0;
}   

Measured memory_bytes: 3636
#include<stdio.h>

int main()
{
    int N,i,x=0;
    scanf("%d",&N);
    char s[150];
    scanf("%s",s);
    if(N%2!=0)
        {
            x=1;

        }



    for(i=0; i<N/2; i++)
    {
        if(s[i]!=s[i+N/2])
        {
            x=1;

        }
     }
    if(x==1)
    {
         printf("No");
    }
    else
    {
         printf("Yes");
    }
    return 0;



}



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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }else if(a>=6 && a<=12){
    cout<<b/2<<endl;
  }else if(a<=5){
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
N=int(input())
x = [list(map(int, input().split())) for i in range(N)]
count=0
for i in range(N-2):
  if x[i][0]==x[i][1] and x[i+1][0]==x[i+1][1] and x[i+2][0]==x[i+2][1]:
     count=count+1
  else:
     count=count+0
else:
  if count>0 :
    print('Yes')
  else :
    print('No')

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

int main(){ 
int k,a,b;
cin>>k>>a>>b;
if(a%k==0||b%k==0){
  cout<<"OK"<<endl;
}
else if(b/k-a/k>=1){
  cout<<"OK"<<endl;
}
else{
  cout<<"NG"<<endl;
}
}


Measured memory_bytes: 3636
n,X = map(int,input().split())
x =list(map(int,input().split()))
x.append(X)
x.sort()
a = []
for i in range(n):
  a.append(x[i+1]-x[i])
  
h = min(a)
gcd = 1
for i in range(h,0,-1):
  if h%i == 0:
    if all(a[j]%i == 0 for j in range(n)):
      gcd = i
      break
      
print(gcd)
  
  




Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    int n, m;
    cin >> n >> m;
    int x[m];
    for (int i = 0; i < m; i++)
    {
        cin >> x[i];
    }
    sort(x, x + m);
    if (n >= m)
        cout << 0 << endl;
    else
    {
        int dif[m], sum = 0;
        for (int i = 1; i < m; i++)
        {
            dif[i - 1] = x[i] - x[i - 1];
        }
        sort(dif, dif + m - 1);
        for (int i = 0; i < (m - n); i++)
        {
            sum += dif[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
	while(true){
		string tmp;
		cin >> tmp;
		if(cin.eof()) break;
		map<int, int> table;
		for(int i = 0; i < tmp.size(); i++){
			if(table.count(tmp[i] - '0')) table[tmp[i] - '0']++;
			else table[tmp[i] - '0'] = 1;
		}

		vector<int> answer;
		for(int i = 1; i <= 9; i++){
			map<int, int> table2 = table;
			
			if(table2.count(i)){
				if(table2[i] < 4) table2[i]++;
				else continue;
			}
			else table2[i] = 1;
			
			for(int j = 1; j <= 9; j++){
				if(table2.count(j) && table2[j] > 1){
					map<int, int> table3 = table2;
					table3[j] -= 2;
					
					for(int k = 1; k < 8; k++){
						if(table3.count(k) && table3.count(k + 1) && table3.count(k + 2)){
							while(table3[k] && table3[k + 1] && table3[k + 2]){
								if(table3[k] % 3 == 0) break;
								table3[k]--;
								table3[k + 1]--;
								table3[k + 2]--;
							}
						}
					}
					bool OK = true;
					for(int k = 0; k <= 9; k++){
						if(table3.count(k) && (table3[k] && table3[k] != 3)) OK = false;
					}
					if(OK){
						bool flag = false;
						for(int k = 0; k < answer.size(); k++){
							if(i == answer[k]) flag = true;
						}
						if(!flag) answer.push_back(i);
					}
				}		
			}

			
		}

		if(!answer.size()) answer.push_back(0);
		for(int i = 0; i < answer.size(); i++){
			if(i) cout << " ";
			cout << answer[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

void updans(int tansh,int tansw,int &ansh,int &answ){
    int a=tansh*tansh+tansw*tansw,b=ansh*ansh+answ*answ;
    if(a<b){
        ansh=tansh;answ=tansw;
    }
    else if(a==b){
        if(tansh<ansh){
            ansh=tansh;answ=tansw;
        }
    }
}

int main(){
    while(true){
        int h,w;
        cin>>h>>w;
        if(h==0)break;
        int tai=h*h+w*w;
        int ansh=1000,answ=1000;
        for (int i = 1; i < 200; ++i) {//h
            for (int j = i+1; j < 200; ++j) {//w
                if(i*i+j*j<tai)continue;
                if(i*i+j*j==tai){
                    if(i<=h)continue;
                    updans(i,j,ansh,answ);
                }
                else{
                    updans(i,j,ansh,answ);
                }
            }
        }
        cout<<ansh<<" "<<answ<<endl;
    }
    return 0;
}


Measured memory_bytes: 3072
import qualified Data.ByteString.Char8 as BS
import qualified Data.List as L
import qualified Data.Set as S
import qualified Control.Monad as M
import Data.Maybe (fromJust)
import Data.Ord
import qualified Data.Vector.Unboxed as V

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

powerset :: [a] -> [[a]]
powerset [] = [[]]
powerset (x:xs) = [x:ps | ps <- powerset xs] ++ powerset xs

main = do
 [n,m,x] <- map (fst.fromJust.BS.readInt)<$>BS.words<$> BS.getLine
 arrays <- map ((map (fst.fromJust.BS.readInt)).BS.words)<$>M.replicateM n BS.getLine
 let allpat = init$powerset arrays
 let calc= map (foldl1 (zipWith (+))) allpat
 let filterpat = map head$filter (\(_:xs)-> and $ map ( >=x) xs ) calc
 print $ if null filterpat
  then -1
  else minimum filterpat


Measured memory_bytes: 4916
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	
	string str;
	int cnt = 0;
	cin >> str;
	for (int i = 0; i < 3; i++) {
		if (str[i] == 'o')cnt++;;
	}
	cout << 700+100*cnt <<endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [ [int(x) for x in input().split()] for _ in range(n) ]

ab.sort()

ans = 0

for (a, b) in ab:
    if m == 0:
        break
    for _ in range(b):
        if m == 0:
            break
        m -= 1
        ans += a

print(ans)

Measured memory_bytes: 21608
///created: 4/Jul/2019 17:53:50

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
const int modulo = 1e9 + 7;

#ifdef LOCAL_DEBUG_NTV1612
template<class __Ty>
string to_string(__Ty a) {
	string res = "[ ";
	bool f = true;
	for (auto &p : a) { res += (f ? string("") : string(", ")) + to_string(p); f = false;	}
	return res + " ]";
}
void _debug() { fprintf(stderr, "\n"); }
template<typename __Ty_head, typename... __Ty_tail>
void _debug(__Ty_head head, __Ty_tail... tail) { fprintf(stderr, "%s ", to_string(head).c_str()); _debug(tail...); }
#define debug(...) fprintf(stderr, "DEBUG [%s]: ", #__VA_ARGS__), _debug(__VA_ARGS__)
#else
#define debug(...) 0
#endif

template<class __Ty> bool mini(__Ty& a, __Ty b) { return a > b ? ((a = b) | 1) : (0); }
template<class __Ty> bool maxi(__Ty& a, __Ty b) { return a < b ? ((a = b) | 1) : (0); }
template<class __Ty> __Ty add(__Ty a, __Ty b) { return (a + b) % (__Ty(modulo)); }
template<class __Ty> __Ty sub(__Ty a, __Ty b) { __Ty m(modulo); return ((a - b) % m + m) % m; }

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int& f : a)
		cin >> f;
	a.push_back(x);
	sort(a.begin(), a.end());
	int g = 0;
	for (int i = 0; i < n; ++i)
		g = __gcd(g, a[i + 1] - a[i]);
	cout << g;
	return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        k: i64, a: i64, b: i64,
    }
    let d = a - b;
    if d <= 0 {
        if a >= k {
            puts!("1\n");
            return;
        } else {
            puts!("-1\n");
            return;
        }
    }
    puts!("{}\n", (max(0, k - a) + a - b - 1) / (a - b) * 2 + 1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

long long nxt[40][100001];
vector<long long> chd[100000];
long long depth[100000] = {0};
long long NUM;
long long Q;
long long sum[40][100000] = {0};


//各要素について深さを計算
void dfs(long long key, long long dep) {
  // if(chd[key].size() == 0) {
  //   depth[key] = dep;
  // }
  rep(i, chd[key].size()) {
    long long ni = chd[key][i];
    depth[ni] = dep + 1;
    dfs(ni, dep+1);
  }
  return;
}

//key分先の親を計算
long long calcPar(long long a, long long key) {
  long long temp = a;
  long long res = 0;
  for(long long i = NUM; i >= 0; i--) {
    if((key >> i) & 1) {
      res += sum[i][temp];
      temp = nxt[i][temp];
    }
  }
  return res;
}

bool isOk(long long a, long long b, long long key) {
  if(a == b) return true;
  if(calcPar(a, key) == calcPar(b, key)) {
    return true;
  }
  return false;
}

long long lower_search(long long a, long long b) {
  long long l = -1, r = depth[a];
  while(r - l > 1) {
    long long half = (r + l) / 2;
    if(isOk(a, b, half)) r = half;
    else l = half;
  }
  return r;
}

int main() {
  long long N, X, M;
  cin >> N >> X >> M;
  NUM = floor(log2(N));
  rep(i, M) {
    nxt[0][i] = (i * i) % M;
  }
  //ダブリングの表を作成
  rep(i, NUM) {
    rep(j, M) {
      if(nxt[i][j] == -1) {
        nxt[i+1][j] = -1;
      } else {
        nxt[i+1][j] = nxt[i][nxt[i][j]];
      }
    }
  }
  rep(i, M) {
    sum[0][i] = nxt[0][i];
  }
  rep(i, NUM) {
    rep(j, M) {
      if(sum[i][j] == -1) {
        sum[i+1][j] = -1;
      } else {
        sum[i+1][j] = sum[i][j] + sum[i][nxt[i][j]];
      }
    }
  }
  // rep(i, NUM+1) {
  //   rep(j, M) {
  //     cout << nxt[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << calcPar(X, N-1) + X << endl;
  // cout << sum[0][2] << endl;
  // cout << sum[1][2] << endl;
  // cout << sum[2][2] << endl;
  return 0;
}

Measured memory_bytes: 59200
#include <stdio.h>
int main(void){
    int n,k;
    int x[9<<14];
    int i=0;
    
    scanf("%d%d",&n,&k);
    for(;~scanf("%d",&x[i++]);){
        ;
    }
    int min=9<<25;
    for(int j=0;j<n-k+1;j++){
        min=fmin(x[j+k-1]-x[j]+fmin(abs(x[j]),abs(x[j+k-1])),min);
    }
    printf("%d",min);
}

Measured memory_bytes: 2552
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, a[5000];
    
    while (1) {
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int maxv = -100000;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < n - i; j++) {
                sum += a[i + j];
                maxv = max(maxv, sum);
            }
        }
        cout << maxv << endl;
    }

    return 0;
}

Measured memory_bytes: 1172
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    b -= a;
    if (b <= 0)
        printf("delicious\n");
    else if (b <= x)
        printf("safe\n");
    else
        printf("dangerous\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;

int main(){
   int n; cin>>n;
   vector<double> v(n);
   rep(i,n) cin>>v[i];
   sort(v.begin(),v.end());
   double ans=(v[0]+v[1])/pow(2,(n-1));
   for(int i=2;i<n;i++){
      ans+=v[i]/pow(2,(n-i));
   }
   printf("%.8f",ans);
   return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
if K%2==0:
    suma=0
    sumb=0
    for i in range(1,N+1):
        if i%K==0:
            suma+=1
        elif i%K==K//2:
            sumb+=1
    print(suma**3+sumb**3)
else:
    print((N//K)**3)


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int n; cin >> n;
  vector<int> d(n); rep(i,n) cin >> d[i];

  int ans = 0;
  rep(i,n){
    repm(j,i+1,n){
      ans += d[i]*d[j];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{

    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[][] adj = new int[n][];
            int[,] adjMatrix = new int[n, n];
            for (int i = 0; i < n; i++)
            {
                int[] temp = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                adj[temp[0] - 1] = new int[temp[1]];
                for (int k = 0; k < temp[1]; k++)
                {
                    adj[temp[0] - 1][k] = temp[k + 2] - 1;
                }
            }
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    adjMatrix[i, j] = 0;
            for (int i = 0; i < n; i++)
                foreach (var j in adj[i])
                    adjMatrix[i, j] = 1;

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n - 1; j++)
                    Console.Write(adjMatrix[i,j]+" ");
                Console.Write(adjMatrix[i, n - 1] + "\n");
            }
		}
    }
}




Measured memory_bytes: 15976
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const int INF=1000000007;
int memo[100][100];//y,x
int dp[100][100];//y,x,色
int r[1000];
int pos;

int n;
string t[3];
const int X=3,Y=5;

void add(int&a,int b){
	a+=b;
	a%=INF;
}

int main(){

cin>>n>>t[1]>>t[2];
string s="#";
rep(i,n+2)t[0].push_back('#');
t[1]=s+t[1]+s;
t[2]=s+t[2]+s;



for(int i=1;i<=n;i++){
	if(t[1][i]==t[2][i])r[pos++]=X;
	else{
		r[pos++]=Y;
		i++;
	}
}

int ans=0;
if(r[0]==X)ans=3;
else ans=6;

for(int i=1;i<pos;i++){
	if(r[i]==X&&r[i-1]==Y){}
	else if(r[i]==Y&&r[i-1]==Y){
	int tmp=ans;
	rep(k,2)add(ans,tmp);
	}

	else add(ans,ans);
}

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
template < typename T, typename U > auto cmn(T& a, U b){ if (a > b) { a = b; return true; } return false; }
template < typename T, typename U > auto cmx(T& a, U b){ if (a < b) { a = b; return true; } return false; }

template < template < typename ... > class Container, typename Value >
std::istream& operator>> (std::istream& is, Container< Value > const& v) {
  for (auto & x : v) is >> x;
  return is;
}

template < template < typename ... > class Container, typename Value >
std::ostream& operator<< (std::ostream& os, Container< Value > const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it == v.begin() ? "" : ",") << *it; }
  return os << "}";
}

void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::string s; std::cin >> n >> s;
  std::vector< int > a(n);
  std::transform(all(s), a.begin(), [](auto x){ return x - '0'; });
  a.insert(a.begin(), 0);
  a.insert(a.begin(), 0);
  std::vector< int > zs{0, 1};
  std::vector< int > dp(n + 3, 0);
  rep(i, 3, n + 3) {
    auto & crr = dp.at(i);
    cmx(crr, dp.at(i - 1));
    auto x = a.at(i - 1);
    if (x == 0) {
      zs.push_back(i - 1);
    } else {
      auto l = *(zs.end() - 2);
      auto r = *(zs.end() - 1);
      auto d0 = r - l - 1;
      auto d1 = i - r - 1;
      assert(d0 >= 0 && d1 >= 0);
      if (d0 >= 1 && d1 >= 1) {
        cmx(crr, dp.at(l) + d0);
        if (d0 >= 2)
          { cmx(crr, dp.at(l + 2) + d0 - 1); }
        cmx(crr, dp.at(r - 1) + d1);
      }
    }
  }
  // debug(a);
  // debug(dp);
  std::cout << dp.back() << std::endl;
  return 0;
}


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

int main() {
	int N;
	cin >> N;
	int ans = 0;
	vector<int>B(N);
	int a;
	cin >> a;
	B[0] = a;
	B[1] = a;
	
	for (int i = 1; i < N-1; i++) {
		cin >> B[i + 1];
	}
	for (int i = 1; i < N; i++) {
		ans += min(B[i - 1], B[i]);
	}
	ans += B[N - 1];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  ll y = x;
  y /= 500;
  ans += y*1000;
  x -= y*500;
  x /= 5;
  ans += x*5;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
static const int inf = 1 << 30;

int main(void) {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A, B) + min(C, D) << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	
	int N, M;
	cin >> N >> M;
	
	long long int x[2000], y[2000], z[2000];
	
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	
	int sig[8][3] = {{1, 1, 1}, {1, 1, -1}, {1, -1, 1}, {1, -1, -1}, 
			{-1, 1, 1}, {-1, 1, -1}, {-1, -1, 1}, {-1, -1, -1}};
	
	long long int ans = 0;
	
	for(int i = 0; i < 8; i++){
		vector<long long int> v;
		
		for(int j = 0; j < N; j++){
			long long int num = sig[i][0] * x[j] + sig[i][1] * y[j] + sig[i][2] * z[j];
			v.push_back(num);
		}
		
		sort(v.begin(), v.end());
		
		long long int S = 0;
		for(int j = 0; j < M; j++){
			S += v[N - j - 1];
		}
		ans = max(ans, S);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(void){
    ll n,d;
    cin >> n >> d;
    int cnt = 0;
    
    ll x[n],y[n];
    rep(i,n)cin >> x[i] >> y[i];
    
    rep(i,n){
        ll ans = (x[i]+y[i])*(x[i]+y[i])-2*x[i]*y[i];
        if(ans > d*d)continue;
        
        cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 6760
data = [int(x) for x in input().split()]
a = data[0]
b = data[1]
x = data[2]
v = a*a*b
import math
if x <= v/2:
  tan = 2*x/(a*b*b)
  w = math.atan(tan)
  t = 90 - math.degrees(w)
else:
  y = v - x
  tan = 2*y/(a*a*a)
  w = math.atan(tan)
  t = math.degrees(w)
print(t)
  
  



Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
int main(){
	int ans=0,n;
	cin>>n;
	vector<int> x;
	for(int i=0;i!=n;++i){
		int temp;
		cin>>temp;
		x.push_back(temp);
	}
	for(int i=0;i!=x.size();++i){
		for(int j=0;j!=x.size();++j){
			ans=max(ans,abs(x[i]-x[j]));
		}
	}
	cout<<ans;
}



Measured memory_bytes: 256
N = int(input())

array = []
cnt6 = 0
while 6**cnt6 <= N:
    array.append(6**cnt6)
    cnt6 += 1
    
cnt9 = 0
while 9**cnt9 <= N:
    array.append(9**cnt9)
    cnt9 += 1

a = sorted(list(set(array)))
# 最小
dp = [i for i in range(N+1)]
# print(a)
n = 6
for n in a:
    for i in range(N+1):
        if i+n <= N:
            dp[i+n] = min(dp[i]+1, dp[i+n])
print(dp[N])


Measured memory_bytes: 44912
#include <bits/stdc++.h>
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 MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int ans = 0;
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
k = int(input())
k_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(k_list[k-1])


Measured memory_bytes: 9160
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 998244353
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;}

vector<ll> ki[1000000];
ll c[1000000];
bool visited[1000000];
void dfs(ll p,ll x){
    if (p!=-1)c[x]+=c[p];
    for (ll i=0;i<ki[x].size();i++){
        if (ki[x][i]==p)continue;
        dfs(x,ki[x][i]);
    }
}

int main(){
    ll n,q;
    cin >> n >> q;
    fill(c,c+n,0);
    for (ll i=0;i<n-1;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    for (ll i=0;i<q;i++){
        ll p,x;
        cin >> p >> x;
        p--;
        c[p]+=x;
    }
    dfs(-1,0);
    for (ll i=0;i<n;i++){
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 44204
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

int x[103]={0,0,1,2,4,6,9,12,16,20,25,30,36,42,49,56,64,72,81,90,100,110,121,132,144,156,169,182,196,210,225,240,256,272,289,306,324,342,361,380,400,420,441,462,484,506,529,552,576,600,625,650,676,702,729,756,784,812,841,870,900,930,961,992,1024,1056,1089,1122,1156,1190,1225,1260,1296,1332,1369,1406,1444,1482,1521,1560,1600,1640,1681,1722,1764,1806,1849,1892,1936,1980,2025,2070,2116,2162,2209,2256,2304,2352,2401,2450,2500};

int main(){
  
  int k;
  cin >> k;
  cout << x[k] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;

  cin >> n;

  int min_sum = 1e9;
  rep(i, n + 1) {
    int a = i;
    int b = n - a;

    if(a < 1 || b < 1) {
      continue;
    }

    int sum = 0;
    while(a > 0) {
      sum += a % 10;
      a /= 10;
    }
    while(b > 0) {
      sum += b % 10;
      b /= 10;
    }

    min_sum = min(min_sum, sum);
  }

  cout << min_sum << endl;
}


Measured memory_bytes: 3636
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    number = int(input())
    numbers=[]
    numbers=list(map(int,input().split()))
    answer=0
    for i in numbers:
        answer+=i-1
    print(answer)

if __name__=="__main__":
    main()

Measured memory_bytes: 9196
import sys

target = input()
search_string = 'keyence'

if target.find(search_string) != -1:
    print('YES')
    sys.exit()

split_index = 7
while 0 < split_index:
    split_index -= 1
    head = search_string[0:split_index]
    tail = search_string[split_index:]
    find_index = target.find(head)
    rfind_index = target.rfind(tail)
    rfind_tail_index = rfind_index + len(tail)
    # print('head: ' + str(find_index)  + ' : ' + head)
    # print('tail: ' + str(rfind_index) + ' : ' + tail)
    if find_index == -1 or rfind_index == -1:
        continue
    if (find_index + len(head)) > rfind_index:
        continue
    if find_index == 0 and rfind_tail_index == len(target):
        print('YES')
        sys.exit()
print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll N, H; cin >> N >> H;
    vll a(N), b(N);
    ll sum = 0;
    ll amax = 0;
    rep(i, N) cin >> a[i] >> b[i], amax = max(amax, a[i]), sum += b[i];
    sort(all(b));
    reverse(all(b));
    ll count = 0;
    rep(i, N) {
        if (b[i] < amax) break;
        H -= b[i];
        count++;

        if (H <= 0) {
            cout << count << endl;
            return 0;
        }
    }

    count += (H + amax - 1) / amax;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 1){
            System.out.println("Hello World");
        }
        else if(n == 2){
            System.out.println(sc.nextInt() + sc.nextInt());
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[2][n];
    for(int i =0;i < 2;i++){
        for(int j =0;j <n;j++ ){
            cin>>arr[i][j];
        }
    }
    int sum=0;
    int ans = -1;

    for(int i =0;i<n;i++){
        sum=0;
        for(int j =0;j<=i;j++){
            sum+=arr[0][j];
        }
        for(int j = i;j<n;j++){
            sum+=arr[1][j];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;






}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int func(int x){
  if(x%100!=0) return 0;
  return func(x/100)+1;
}
 
int main(){
  int d,n;
  cin>>d>>n;
  int cnt=0;
  for(int x=1;;x++){
    if(func(x)==d){
      cnt++;
      if(cnt==n){
        cout<<x<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3524