akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int X, Y; cin >> X >> Y;
    ll ans = 0;
    if(X == 3) ans += 1e5;
    else if(X == 2) ans += 2e5;
    else if(X == 1) ans += 3e5;
    if(Y == 3) ans += 1e5;
    else if(Y == 2) ans += 2e5;
    else if(Y == 1) ans += 3e5;
    if(X == 1 && Y == 1) ans += 4e5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;

void test_case(){
	int L,R,d;
	cin >> L >> R >> d;
	int cnt=0;
	for(int i=d; i<=R ; i+=d){
		if(i>=L) cnt++;
	}
	cout << cnt << endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}


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

int main() {
	int n;
	string s1, s2;
	int a = 0, b = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		if (s1 > s2)a += 3;
		else if (s1 < s2)b += 3;
		else {
			a++; b++;
		}
	}

	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<string> v;
    while(n--){
        string s;
        cin>>s;
        v.pb(s);
    }
    sort(v.begin(),v.end());

    string k=v[0];
    ll ans=1;
    for(ll i=1;i<v.size();i++){
        
        if(v[i]!=k){
            k=v[i];
            ans+=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11600
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int N, K; cin >> N >> K;
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L[i];
  sort(L.begin(), L.end(), greater<int>());
  int res = 0;
  for(int i = 0; i < K; i++) res += L[i];
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;

const ll MA = 1000005;


int main() {

	vector<int> to(MA);

	int n;
	ll sum = 0;
	cin >> n;
	vector<int> d(n);

	rep(i, n) cin >> d[i];

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

	int a = d[(n - 1) / 2], b = d[((n - 1) / 2) + 1];

	bool f = false;

	if (a != b) {
		f = true;
	}
	if (f) {
		cout << b - a << endl;
	}
	else cout << "0" << endl;

	return 0;
}

Measured memory_bytes: 4608
/*input
211 5
31 41 59 26 53
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, n; cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
    	int a; cin >> a;
    	sum += a;
    }
    if(sum >= h) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int S=0,M=0,L;
  for(int i=0;i<n;i++){
    cin>>L;
    S+=L;
    M=max(M,L);
  }
  if(S>M*2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){

  int n, a[10], cnt=1, ans;

  cin >> n;
  ans = pow(3, n);

  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]%2!=0){
      cnt*=1;
    } else {
        cnt*=2;
      }
    }

    cout << ans-cnt << endl;

  return 0;
}

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

int main() {
    int a, b;
    std::cin >> a >> b;
    if (a * b % 2 == 0){
        std::cout << "Even" << std::endl;
    }
    else{
        std::cout << "Odd" << std::endl;
    }
}

Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  an = []
  a2n = a[n:2*n]
  a3n = []
  
  for i in range(n):
    heapq.heappush(an,a[i])
    heapq.heappush(a3n,-1*a[i+2*n])

  tmpsuman = sum(an)
  tmpsuma3n = -1*sum(a3n)
  
  suman = [tmpsuman]
  suma3n = [tmpsuma3n]
  
  for i in range(n):
    tmp = a2n[i]
    tmpsuman += tmp
    heapq.heappush(an,tmp)
    tmpsuman -= heapq.heappop(an)
    
    suman.append(tmpsuman)

    tmp = a2n[n-i-1]
    tmpsuma3n += tmp
    heapq.heappush(a3n,-1*tmp)
    tmpsuma3n -= -1*heapq.heappop(a3n)
    suma3n.append(tmpsuma3n)

  ans = -1*float("INF")
  for i in range(n+1):
    ans = max(ans,suman[i]-suma3n[n-i])
  print(ans)
solve()

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

using namespace std;

int main() {
    double height;
    vector<double> v;
    while(cin >> height){
        v.push_back(height);
    }
    
    sort(v.begin(),v.end());
    int len= v.size();
    double dif;
    dif = v[len-1]-v[0];
    cout << dif << endl;
}

Measured memory_bytes: 1304
n = int(input())
p = list(map(int,input().split()))
c = 0
p1 = sorted(p)

for i in range(n):
    if(p1[i]==p[i]):
        continue
    else:
        c=c+1

if c == 2 or c==0:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)


Measured memory_bytes: 3060
while True:
    n, q = map(int, input().split())
    if n == 0: break
    ls = []
    for i in range(n):
        ls.append(list(map(int, input().split())))

    max_q = 0
    date = 0
    for i in range(1, 101):
        count = 0
        for j in range(len(ls)):
            if i in ls[j][1:]:
                count += 1
                if count > max_q:
                    max_q = count
                    date = i
    if max_q < q:
        print(0)
    else:
        print(date)

Measured memory_bytes: 6720
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		int N = keyboard.nextInt();
		
		int[] X = new int[N];
			for(int i=0; i < N; i++) {
				X[i] = keyboard.nextInt();
			}
		int[] Y = new int[N];
			for(int j=0; j < N; j++) {
				Y[j] = keyboard.nextInt();
			}
			
		int[] sagaku = new int[N];
		for(int k=0; k < N; k++) {
			sagaku[k] = X[k] - Y[k];
		}
		
		int Max = 0;
		
		for(int l=0; l < N; l++) {	
			if(sagaku[l] + Max > Max) {
				Max += sagaku[l];
				}
		}

		System.out.print(Max);
		keyboard.close();	
	}
}


Measured memory_bytes: 23252
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	ArrayDeque<Integer> stack = new ArrayDeque<Integer>();
	int n;
	while (scan.hasNext()) {
	    n = Integer.parseInt(scan.nextLine());
	    if (n == 0) {
		System.out.println(stack.pop());
	    } else {
		stack.push(n);
	    }
	}
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
char a[52][52],b[52][52];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,n)scanf("%s",a+i);
  REP(i,m)scanf("%s",b+i);
  REP(i,n-m+1)REP(j,n-m+1){
    bool ok = true;
    REP(x,m)REP(y,m)if(a[i+x][j+y]!=b[x][y])ok=false;
    if(ok){
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a[2],b[2],c[2],d[2];
int i,kekka[2];
for(i=0;i<2;i++){
scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
kekka[i]=a[i]+b[i]+c[i]+d[i];
}
if(kekka[0]>kekka[1]){
printf("%d\n",kekka[0]);
}
else if(kekka[1]>=kekka[0]){
printf("%d\n",kekka[1]);
}
return 0;
}

Measured memory_bytes: 588
/* ex_3-2. nknm */

#include <stdio.h>

int main(void){

    //鉛筆の本数を入力
    int pencils;

    scanf("%d", &pencils);

    //条件により異なる出力
    if (pencils % 10 == 3){
        printf("bon\n");
    }else if(pencils % 10 == 0 || pencils % 10 == 1 || pencils % 10 == 6 || pencils % 10 == 8){
        printf("pon\n");
    }else{
        printf("hon\n");
    }
    
}

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

int main() {
  long m=-1;
  string s;
  bool p=true;
  vector<long> xy(2);
  vector<vector<long>> data(2,vector<long>(0));
  cin >> s >> xy[0] >> xy[1];

  for(long i=0;i<s.size();i++) {
    if(s[i]=='F') {
      if(m==-1) xy[0]--;
      else {
        data[m].back()++;
      }
    } else {
      if(m==-1) m=1;
      else m=(m+1)%2;
      data[m].push_back(0);
    }
  }

  for(long a=0;a<2&&p;a++) {
    long wa=0;
    for(long i=0;i<data[a].size();i++) wa+=data[a][i];
    if((wa-xy[a])%2==0&&(wa>=xy[a]&&-wa<=xy[a])) {
      long aaa=min((wa-xy[a])/2,(wa+xy[a])/2);
      vector<bool> k(aaa+1);
      k[0]=true;
      for(long i=0;i<data[a].size();i++) {
        if(data[a][i]!=0) {
          for(long j=aaa;j>=data[a][i];j--) {
            if(!(k[j])) k[j]=k[j-data[a][i]];
          }
        }
      }
      p=k[aaa];
    } else p=false;
  }
  if(p) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3708
#include <iostream>
using namespace std;
int main()
{
    long int   i, n,sum, min,max, input;
     
   
    cin >> n;
    cin >> input;
    max=input;
    min=input;
    sum=input;
    
    
    
    
    for(i=1; i<n; i++)
    {
        
       cin >> input; 
        
        sum = input +sum;
        
        if(input>max)
         max=input;
        
        if (input<min)
         min=input;
        
        
        
    }
    cout <<min<<" "<<max<< " " <<sum << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using Graph=vector<vector<ll>>;
int main(){
  ll n,c=0;cin>>n;
  vector<ll> x(100010);
  rep(i,n){
    ll a;cin>>a;a++;
    x[a-1]++;
    x[a]++;
    x[a+1]++;
  }
  rep(i,100010)c=max(c,x[i]);
  cout<<c;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod 1000000007

using namespace std;
int main()
{
    vector<ll> ve[4];

    int n,w;
    cin >> n >> w;
    int cost = 0;
    ve[0].push_back(0);
    ve[1].push_back(0);
    ve[2].push_back(0);
    ve[3].push_back(0);
    for(int i=0; i<n; i++)
    {
        int w,v;
        scanf("%d%d",&w,&v);
        if(cost == 0)
            cost = w;
        if(w == cost)
            ve[0].push_back(v);
        if(w == cost+1)
            ve[1].push_back(v);
        if(w == cost+2)
            ve[2].push_back(v);
        if(w == cost+3)
            ve[3].push_back(v);
    }
    for(int i=0; i<4; i++)
        {
            sort(ve[i].begin()+1,ve[i].end());
            reverse(ve[i].begin()+1,ve[i].end());
        }

    for(int i=0; i<4; i++)
    {
        for(int j=1; j<ve[i].size(); j++)
            ve[i][j] += ve[i][j-1];
    }
    ll mx = 0;

    ll x1 = cost,x2 = cost+1,x3 = cost+2,x4 = cost+3;
    for(int i=0; i<ve[0].size();i++)
    {
        for(int j=0; j<ve[1].size(); j++)
        {
            for(int k=0; k<ve[2].size(); k++)
            {
                for(int l=0; l<ve[3].size(); l++)
                {
                    if(i*x1 + j*x2 + k*x3 + l*x4 <= w)
                    {
                        ll can = ve[0][i] + ve[1][j] + ve[2][k] + ve[3][l];
                        mx = max(can,mx);
                    }
                }
            }
        }
    }
    cout << mx << endl;



    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;
typedef unsigned int i64;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c; cin >> a >> b >> c;
  swap(a,b);
  swap(a,c);
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}



Measured memory_bytes: 3652
//-----------------------
// author : xyqkoala
// time : 2020-06-23
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	int n;
	cin>>n;
	vector<int> nums(n);
	unordered_map<int,int> t;
	LL res = 0;
	for(int i=0;i<n;i++){
		cin>>nums[i];
		t[nums[i]]++;
		res+=nums[i];
	}
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int x,y;
		cin>>x>>y;
		int item = t[x];
		t[y]+=item;
		t[x]=0;
		res += 1ll * item*y;
		res -= 1ll*item*x;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 7468
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;


void solve() {
	string s; cin >> s;
	int n = s.length();
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl; return;
		}
	}
	cout << "Good" << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>

using namespace std;

void exchange(char a[], int left, int right) {
	int i = left, j = right;
	char temp;
	while (i < j) {
		temp = a[i];
		a[i] = a[j];
		a[j] = temp;
		i++;
		j--;
	}
}

void reserve(char a[], int n, int i) {
	exchange(a, 0, i - 1);
	exchange(a, i, n - 1);
	exchange(a, 0, n - 1);
	return;
}

int main() {
	char str[110], str1[110];
	int n, round = 0;
	scanf("%s", str);;
	scanf("%s", str1);
	if (strlen(str) != strlen(str1)) {
		printf("No");
		return 0;
	}
	n = strlen(str);
	while (round <= n) {
		reserve(str, n, 1);
		if (strcmp(str, str1) == 0) {
			printf("Yes");
			return 0;
		}
		round++;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 888
#include<stdio.h>

void maxheap(int);
void swap(int,int);
int num;
int array[2000001];

int main(){

   int i;
  scanf("%d",&num);
  for(i = 1;i <= num;i++){
    scanf("%d",&array[i]);
  }
  for(i = num / 2;i >= 1;i--){
    maxheap(i);
  }
  for(i = 1;i <= num;i++){
    printf(" %d",array[i]);
  }
  printf("\n");
  return 0;
}

void maxheap(int i){
  int left = 0;
  int right = 0;
  int largest = 0;
  int change;

  left = 2 * i;
  right = 2 * i + 1;

  if(left <= num && array[left] > array[i]){
    largest = left;
  }
  else{
    largest = i;
  }
  if(right <= num && array[right] > array[largest]){
    largest = right;
  }
  if(largest != i){
    change=array[i];
    array[i]=array[largest];
    array[largest]=change;
    maxheap(largest);
  }
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5,inf=1e9;
struct Edge{
	int next,to;
}edge[N<<2];
struct Node{
	int w,x;
	bool operator < (const Node &b)const{return w<b.w;}
}a[N];
int fi[N],se=1,c[N],d[N],ans[N<<1];
inline void add_edge(int u,int v){edge[++se].next=fi[u],edge[se].to=v,fi[u]=se;}
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
void dfs(int x){
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;
		if(c[v]){c[x]=c[v]^3,ans[i>>1]=d[x];return;}
		if(d[v]==d[x]){c[x]=1,c[v]=2,ans[i>>1]=d[x];return;}
	}
	puts("-1");exit(0);
}
int main(){
	int n,m,u,v;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",d+i+1),a[i].w=d[i+1],a[i].x=i+1;
	for(int i=0;i<m;i++)scanf("%d%d",&u,&v),add(u,v);
	sort(a,a+n);
	for(int i=0;i<n;i++)if(!c[a[i].x])dfs(a[i].x);
	for(int i=1;i<=n;i++)if(c[i]==1)putchar('B');else putchar('W');
	for(int i=1;i<=m;i++)printf("\n%d",ans[i]?ans[i]:inf);
	return 0;
} 

Measured memory_bytes: 8320
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e9;
const ll MAX = 200005;
//
//

                    vector<ll> vec;
                int check(ll mid, ll k){
                    ll cuts = 0;
                    for(ll z : vec){
                        cuts += ((z-1)/mid);
                    }
                    return cuts<=k;
                }
                void solve(){
                    ll n,k ;
                    cin>>n>>k;
                    vec.resize(n);
                    for(int i = 0; i < n; i++)
                        cin>>vec[i];
                    ll lo = 1, hi = INF;
                    while(lo < hi){
                        ll mid = (lo + hi)>>1;
                        if(check(mid, k))
                            hi = mid;
                        else
                            lo = mid+1;
                    }
                    // cout<<check(1, k);
                    cout<<lo;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 


Measured memory_bytes: 4736
import itertools

N=int(input())
first=""
for i in range(N):
    first+=str(i+1)
P=tuple(map(str,input().split()))
Q=tuple(map(str,input().split()))

A=list(itertools.permutations(first))

p=A.index(P)
q=A.index(Q)

print(abs(p-q))

Measured memory_bytes: 8052
a, b, m = map(int,input().split())

a_i = list(map(int,input().split()))
b_j = list(map(int,input().split()))

x = []
for i in range(m):
    x_x = list(map(int,input().split()))
    x.append(x_x)
    continue

ans = 1000000000000
for i in x:
    s = a_i[i[0]-1] + b_j[i[1]-1] - i[2]
    if ans > s:
        ans = s

a_b = min(a_i) + min(b_j)

if a_b < ans:
    print(a_b)
else:
    print(ans)



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

using namespace std;

int main(void){
  int N, M;
  cin >> N; cin >> M;
  int i, j;

  //index of person who likes food i
  vector<int> count(M, 0);

  //person i, he likes food j
  vector<vector<int> > a(N, vector<int>(M+1));

  //input
  for(i=0; i<N; i++){
    cin >> a[i][0];
    for(j=1; j<=a[i][0]; j++)
      cin >> a[i][j];
  }

  //count number of person who likes food i
  for(i=0; i<N; i++){
    for(j=1; j<=a[i][0]; j++)
      count[a[i][j]-1]++;
  }

  //count the number all person likes food i
  int count_n = 0;
  for(i=0; i<M; i++)
    if(count[i] == N)
      count_n++;

  cout << count_n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int N,K,X,ans;
  cin >> N;
  cin >> K;
  cin >> X;
  ans=1;
  if(N!=K)ans++;
  if(N!=X&&K!=X)ans++;
  cout << ans<<endl;
  
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
#include<tuple>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define fi first
#define se second
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vll v(3);
	rep(i, 3) cin >> v[i];
	ll a = v[0], b = v[1], c = v[2];
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(all(v));
	cout << v[0] * v[1] << endl;
	return 0;
}

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

int main()
{
    int h,w;
    cin >> h >> w;
    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    bool ans = false;
    int dx[4] = {0,0,1,-1};
    int dy[4] = {1,-1,0,0};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(c[i][j] == '#'){
                int find = 0;
                for(int k = 0; k < 4; k++){
                    if(i + dx[k] >= 0 && i + dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w && c[i+dx[k]][j+dy[k]] == '#'){
                        find = 1;
                    }
                }
                if(find == 0){
                    cout << "No";
                    return 0;
                }
            }
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// Unionfind
struct UF {
	vector<int> p;
	UF() = default;
	explicit UF(int n) : p(n + 1, -1) { p.back() = n; }
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return false;
		if (p[x] > p[y]) swap(x, y);
		p[x] += p[y];
		p[y] = x;
		p.back()--;
		return true;
	}
	int find(int x) { return (p[x] < 0 ? x : p[x] = find(p[x])); }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -p[find(x)]; }
	int count() { return p.back(); }
};

void _main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    REP (i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    UF uf(N);
    vector<int> ans;
    int sum = N * (N - 1) / 2;
    REP (i, M) {
        ans.push_back(sum);
        if (!uf.same(A[i], B[i])) sum -= uf.size(A[i]) * uf.size(B[i]);
        uf.unite(A[i], B[i]);
    }
    reverse(ans.begin(), ans.end());
    REP (i, M) cout << ans[i] << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 4596
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}
// -----------------------------------------------------------------------


// -----------------------------------------------------------------------



void q1(){
	int a;
	cin>>a;
	cout<<48-a;
	
}
// -----------------------------------------------------------------------


void q2(){
	int a,b;
	cin>>a>>b;
	string s;cin>>s;
	if(s[a]!='-'){
		cout<<"No\n";
		return ;
	}
	for(int i=0;i<=a+b;++i){
		if(i==a)
		continue;
		if(!(s[i]>='0' && s[i]<='9')){
			cout<<"No\n";
			return ;
		}
	}
	cout<<"Yes\n";
}

// -----------------------------------------------------------------------

void q3(){
	int n;
	cin>>n;
	int c[n-1],s[n-1],f[n-1];
	for(int i=0;i<n-1;++i)
	cin>>c[i]>>s[i]>>f[i];
	int res[n];
	res[n-1]=0;
	for(int i=n-2;i>=0;--i){
		int t=s[i]+c[i];
		for(int j=i+1;j<n-1;++j){
			if(t<=s[j]){
				t=s[j];
				t+=c[j];
			}else{
				int next = (t+f[j]-1)/f[j];
				next*=f[j];
				t=next+c[j];
			}
		}
		res[i]=t;
	}
	for(int i=0;i<n;++i)
	cout<<res[i]<<endl;
}


// -----------------------------------------------------------------------

void q4(){
	seive();
	int ans[100005];
	ans[0]=ans[1]=ans[2]=0;
	for(int i=3;i<100005;++i){
		if(Arr[i]==0){
			int n=(i+1)/2;
			if(Arr[n]==0)
			ans[i]=1;
		}
	}
	for(int i=1;i<100005;++i)
	ans[i]+=ans[i-1];
	int q;cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<ans[r]-ans[l-1]<<endl;
	}
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q2();
	return 0;
}


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

int main() {
  int N, result = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    result = result + (r - l) + 1;
  }
  cout << result << endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
//#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;//ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 vector<ll>deq;
 ll b;
 ll cnt=0;
 map<ll,bool>visited;
 map<ll,ll>num;
 rep(i,0,n){
  cin>>b;
  visited[b]=false;
  deq.push_back(b);
  num[b]++;
 }
  
 ll ans=0;
 rep(i,0,n){
  if(num[deq[i]]<=1||visited[deq[i]])continue;
  if(num[deq[i]]==2){
   cnt++;
   visited[deq[i]]=true;
  }
  else {
   ans+=cei(num[deq[i]],2)-1;
   if(num[deq[i]]%2==0)cnt++;
   visited[deq[i]]=true;
  }
  //cout<<i<<" deq[i]:"<<deq[i]<<" num:"<<num[deq[i]]<<" ans:"<<ans<<" cnt:"<<cnt<<endl;
 }
 ans+=cei(cnt,2);
 ans=n-2*ans;
 pr(ans);
 return 0;}

Measured memory_bytes: 16488
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100+5
#define white 0
#define black 1
#define INF 100000*100+5
int m[MAX][MAX],color[MAX],d[MAX],num;
void dijkstra(){
	d[0]=0;int now_node;
while(true){
	int minc=INF;
	for(int i=0;i<num;i++){
		if(!color[i]&&d[i]<minc){
			minc=d[i];now_node=i;
		}
	}
     	if(minc==INF) break;
		color[now_node]=black;
		for(int i=0;i<num;i++){
			if(color[i]==white&&m[now_node][i]+d[now_node]<d[i]){
				d[i]=d[now_node]+m[now_node][i];
			}
		}
	
}
return ;
}
int main(){
	cin>>num;
	for(int i=0;i<num;i++){
		for(int j=0;j<num;j++){
			m[i][j]=INF;
		}
	}
	int row,n,col,val;
	for(int i=0;i<num;i++){
		cin>>row;
		cin>>n;
		for(int j=0;j<n;j++){
			cin>>col>>val;
			m[row][col]=val;
		}
	}
	for(int i=0;i<num;i++){
		d[i]=INF;color[i]=0;
	}
	dijkstra();
	for(int i=0;i<num;i++){
		cout<<i<<" "<<d[i]<<endl;
	}
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(auto &e: v) cin >> e;

    ll dxy[] = {-1, 0, 1, 0, -1};
    for(ll i=0; i<h; i++)
        for(ll j=0; j<w; j++) {
            bool ok = v[i][j] != '#';
            for(ll di=0; di<4; di++) {
                ll ni = i + dxy[di], nj = j + dxy[di+1];
                if(!(0 <= ni && ni < h && 0 <= nj && nj <w )) continue;
                ok |= v[ni][nj] == '#';
            }
            if(!ok) {
                cout << "No" << endl;
                return 0;
            }
        }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
def reconstruction(l, r):
    global P, I, post
    if l >= r:
        return
    c = P.pop(0)
    m = I.index(c)
    reconstruction(l, m)
    reconstruction(m + 1, r)
    post.append(c)


if __name__ == "__main__":
    n = int(input())
    P = list(map(int, input().split()))
    I = list(map(int, input().split()))
    post = []

    reconstruction(0, n)
    print(*post)

Measured memory_bytes: 7712
s = input()
l = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = sorted(list(set(char)))
    ans = []
    for i in charset:
        if len(set(ans)) > 5:
            break
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[l-1])

Measured memory_bytes: 4444
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, t1, x1, my1, t2, x2, y2, t, x, y;
multiset < pair< int, pair<int, int> > > s;
multiset < pair< int, pair<int, int> > >::iterator it;
pair< int, pair<int, int> > pap;

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

    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &t2, &x2, &y2);
        s.insert(make_pair(t2, make_pair(x2, y2)));
    }

    for (it = s.begin(); it != s.end(); ++it) {
        pap = *it;
        t2 = pap.first; x2 = pap.second.first; y2 = pap.second.second;

        t = abs(t2 - t1); x = abs(x2 - x1); y = abs(y2 - my1);

        if (t < x + y || (x + y) % 2 != t % 2) {
            printf("No\n");
            return 0;
        }

        t1 = t2; x1 = x2; my1 = y2;
    }

    printf("Yes\n");
}


Measured memory_bytes: 6528
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
total = 0
for i in range(N):
    if A[i] >= B[i]:
        total += B[i]
    else:
        total += A[i] + min(B[i] - A[i], A[i + 1])
        A[i + 1] = max(A[i + 1] - (B[i] - A[i]), 0)
print(total)

Measured memory_bytes: 18624
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    if s[0] < s[1] {
        println!("<");
    } else if s[0] == s[1] {
        println!("=");
    } else {
        println!(">");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include <math.h>
using namespace std;
int main(){
    int  A,N;
    cin >> N >> A;
    vector<int> x(N);
    int X =0;
    for(int i=0;i<N;i++){
        cin >> x[i];
        x[i]-=A;
        X=max(abs(x[i]),X);
    }
     vector<vector<long int> > dp(N+1,vector<long int>(2*N*X+1,0));
    int XX=2*N*X;
    dp[0][N*X]=1;
    for(int j=1;j<=N;j++){
        for(int t=0;t<=XX;t++){
            if(t-x[j-1]<0||t-x[j-1]>XX)dp[j][t]=dp[j-1][t];
            else  dp[j][t]=dp[j-1][t]+dp[j-1][t-x[j-1]];
        }
    }
    cout << dp[N][N*X]-1 << endl;
    return 0 ;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
vector<vector<bool>> Grid(50, vector<bool>(50, false));
vector<vector<int>> Steps(50, vector<int>(50, -1));
queue<pair<int, int>> Que;
int H, W, wte = 0;

void addToQue(int x, int y, int step)
{
  if (x < 0 || y < 0 || x >= W || y >= H)
    return;
  if (Steps.at(y).at(x) == -1 && Grid.at(y).at(x))
  {
    Que.push(make_pair(x, y));
    Steps.at(y).at(x) = step;
  }
}

int main()
{
  cin >> H >> W;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      Grid.at(i).at(j) = (c == '.');
      if (c == '.')
        wte++;
    }
  }
  pair<int, int> cur;
  int x, y, step;
  Que.push(make_pair(0, 0));
  Steps.at(0).at(0) = 1;
  while (!Que.empty())
  {
    cur = Que.front();
    x = cur.first;
    y = cur.second;
    Que.pop();
    step = Steps.at(y).at(x);
    addToQue(x + 1, y, step + 1);
    addToQue(x - 1, y, step + 1);
    addToQue(x, y + 1, step + 1);
    addToQue(x, y - 1, step + 1);
  }

  if (Steps.at(H - 1).at(W - 1) == -1)
    cout << -1 << endl;
  else
    cout << wte - Steps.at(H - 1).at(W - 1) << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L, R = [0]*M, [0]*M
for i in range(M):
    L[i],R[i] = map(int, input().split())

a, b = max(L), min(R)
if a<=b:
    print(b-a+1)
else:
    print(0)

Measured memory_bytes: 10868
module Main where

import Control.Monad
import Control.Applicative
import Data.List

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)

solve :: [Int] -> Int -> Int
solve [] t = 0
solve (x:xs) t = if x >= t then solve xs x else solve xs t + t - x

main :: IO ()
main = do
    n <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    putStrLn $ show (solve a 0)


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

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

  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += L.at(i);
  }
  cout << ans << endl;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    int a=n;
    int b=0;
    while(n>0){
        b+=n%10;
        n/=10;
    }
    if(a%b == 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
a, b, h, m = map(int, input().split())

import math


rad_diff = min(abs(m/60-(h+m/60)/12), abs((h+m/60)/12-m/60))*2*math.pi
yogen = math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(rad_diff))
print(yogen)

Measured memory_bytes: 62500
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,all=0;
	cin >> n;
	vector<int> v(n+2, 0);
	for (int i = 1; i < n+1; i++) {
		cin >> v[i];
	}
	for (int i = 1; i < n+2; i++) {
		all += abs(v[i] - v[i - 1]);
	}
	for (int i = 1; i < n + 1; i++) {
		cout << all - (abs(v[i] - v[i - 1]) + abs(v[i + 1] - v[i]) - abs(v[i - 1] - v[i + 1]))<<endl;
	}
	//cout << all;
}


Measured memory_bytes: 1664
// -_-
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long , long long> pll;
 
int main() 
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

    int h, w, d;
    cin >> h >> w >> d;
    map <int, pii> mp;
    int a[h+1][w+1], flag[10000000] = {}, vis[10000000] = {}, ans[10000000] = {};
    vi vec;

    fori(i, 1, h)
    {
    	fori(j, 1, w) 
    	{
    		cin >> a[i][j];
    		vec.pb(a[i][j]);
    		mp[a[i][j]] = {i, j};
    		flag[a[i][j]] = 1;
    	}
    }
    sort(vec.begin(), vec.end());

    fori(i, 0, vec.size()-1)
    {
    	if(vis[vec[i]] == 0)
    	{
    		vis[vec[i]] = 1;
    		int j = vec[i] + d;
    		int s = 0;
    		while(flag[j] == 1)
    		{
    			vis[j] = 1;
    			s = s + abs(mp[j-d].fi - mp[j].fi) + abs(mp[j-d].se - mp[j].se);
    			ans[j] = s;
    			j += d;
    			if(j > h*w) break;
    		}
     	}
    }

    int q, l, r;
    cin >> q;
    fori(i, 1, q)
    {
    	cin >> l >> r;
    	cout << ans[r] - ans[l] << endl;
    }

	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int counter = 0;
  for (int i=0; i<3; i++) {
    if (S.at(i)==T.at(i)) {
      counter++;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    ll A,B,C,X,Y;
    cin >> X >> Y >> A >> B >> C;
    Vll p(A),q(B),r(C);
    priority_queue<ll> p_que,q_que,r_que,ans_que;
    rep(i,0,A){
        cin >> p[i];
        p_que.push(p[i]);
    }
    rep(i,0,B){
        cin >> q[i];
        q_que.push(q[i]);
    }
    rep(i,0,C){
        cin >> r[i];
        r_que.push(r[i]);
    }
    rep(i,0,X){
        ll temp = p_que.top();p_que.pop();
        ans_que.push(-temp);
    }
    rep(i,0,Y){
        ll temp = q_que.top();q_que.pop();
        ans_que.push(-temp);
    }
    ll ans = 0;
    rep(i,0,X+Y){
        ll temp = -ans_que.top();ans_que.pop();
        if(temp < r_que.top() && !r_que.empty()){
            temp = r_que.top();r_que.pop();
        }
        ans+=temp;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll,ll>;
const int INF = 1e9;

int main()
{
    int n;
    cin >> n;
    vector<int> dp(n + 10, INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        int beki = 6;
        for(; beki + i<= n; beki *= 6)dp[i + beki] = min(dp[i + beki], dp[i] + 1);
        beki = 9;
        for(; beki + i<= n; beki *= 9)dp[i + beki] = min(dp[i + beki], dp[i] + 1);
    }
    cerr << "__yay__" << endl;
    
    cout << dp[n] << endl;

}

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

#define int             long long
#define	ll				long long

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";
long long prime[1000000];

void sieve()
{
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<1000000;i++)
		prime[i]=1;

	for(int i=2;i*i<1000000;i++)
		if(prime[i]==1)
			for(int j=i*i;j<1000000;j+=i)
				prime[j]=0;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i <= floor(sqrt(n)); i++)
        if (n % i == 0)
            return false;

    return true;
}

int factorial(int n)
{
    int f=1;
    for(int i = 1;i<=n ; i++)
        f = (f*i)%mod;
    return f;
}

int gcd(int a, int b)
{
	return !b ? a : gcd(b, a % b);
}

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

int fastExponentiation(int n, int x, int modulo)
{
	int res = 1;
	while(x > 0)
       {
          if(x & 1)
          res = (res*n) % modulo;
          x = x >> 1;
          n = (n * n) % modulo;
       }
       return res;
}

int power(int n , int p )
{
	if(p==0)
	   return 1;

	 int res = power((n*n)%mod,p/2);
	 if(p%2==1)
	   res = (n*res)%mod;

	   	 return res;
}

bool isPowerOfTwo(int n)
{
   	return n && (!(n&(n-1)));
}

bool isSet(int n,int i)
{
	// To check if ith bit is set or not in binary representation of n
   	return n & (1 << i);
}

bool valid_coordinate(ll x,ll y,ll n,ll m)
{
    if(x<0 || y<0)
       return false;

   	else if(x>=n || y>=m)
       return false;

   	else
   		return true;
}

int sod(int n)
{
	int sum=0;
	while(n)
	{
		sum+=(n%10);
		n/=10;
	}
	return sum;
}



void solve()
{
	int a,b,count=0;
	cin>>a>>b;
	for(int i=1;i<a;i++){
		for(int j=i+1;j<=a;j++)
		count++;
	}
	for(int i=1;i<b;i++){
		for(int j=i+1;j<=b;j++)
		count++;
	}
	cout<<count<<endl;
}

int32_t main()
{

	//int t; cin>>t; while(t--)
	solve();

	return 0;
}


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

int main(void) {
  int N, A;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    string s, t; cin >> s >> t;
    if(s.length() != s.length()){
        cout << "No" << endl;
    }else{
        int a = 1;
        rep(i, s.length()){
            if(s[i] != t[i]) a = 0;
        }
        if(a) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)
 
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  int N,K,l,count=0,base=0;
  string S;
  char edge;

  cin >> N >>K;

  cin >> S;


  edge = S[0];
  l=0;
  rep(i,N){
    if(i < N-1 and S[i]==S[i+1])base++;
    if(S[i]==edge){
      if(i >= l+2){
	count++;
      }
      l=i;
    }
  }
  
  if(S[0]==S[N-1]){
    if(count >= K)
      cout << base+2*K << endl;
    else
      cout << base+2*count << endl;
  }else{
    if(count >= K)
      cout << base+2*K << endl;
    else
      cout << base+(2*count)+1 << endl;
  }
 

  
  return 0;
}


Measured memory_bytes: 512