akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;


int H, W;
string fi[110];
typedef pair<int,int> pint;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int dist[110][110];

int main() {
  while (cin >> H >> W) {
	int b = 0;
	for (int i = 0; i < H; ++i) {
	  cin >> fi[i];
	  for (int j = 0; j < W; ++j) {
		if (fi[i][j] == '#') ++b;
	  }
	}

	for (int i = 0; i < 110; ++i) for (int j = 0; j < 110; ++j) dist[i][j] = -1;
	dist[0][0] = 1;
	queue<pint> que;
	que.push(pint(0, 0));
	while (!que.empty()) {
	  pint cur = que.front();
	  que.pop();
	  int x = cur.first;
	  int y = cur.second;
	  for (int dir = 0; dir < 4; ++dir) {
		int nx = x + dx[dir];
		int ny = y + dy[dir];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
		if (fi[nx][ny] == '#') continue;
		if (dist[nx][ny] == -1) {
		  dist[nx][ny] = dist[x][y] + 1;
		  que.push(pint(nx, ny));
		}
	  }
	}
	if (dist[H-1][W-1] == -1) cout << -1 << endl;
	else {
	  cout << H * W - b - dist[H-1][W-1] << endl;
	}
  }
}

   


Measured memory_bytes: 256
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let mut iter = line.split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();
    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2);
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cerr << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n";

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;

ll n,a,b,c,d;
string s;

bool check(ll a, ll e){
    for(int i=a; i<e; i++){
        if(s[i]=='#' && s[i]==s[i+1]) return false;
    }
    return true;
}

int main(){
    fast
    
    cin>>n>>a>>b>>c>>d;
    cin>>s;
    a--;b--;c--;d--;
    if(c==d){
        cout<<"No\n";
        return 0;
    }
    if(c<=b || c<d){
        if(check(b,d)){
            s[d]='#';
            if(check(a,c)) cout<<"Yes\n";
            else{
                cout<<"No\n";
            }
        }else{
            cout<<"No\n";
        }
    }else if(d<c){
        if(check(b,d) && check(a,c)){
            for(int i=b-1; i<d; i++){
                if(s[i]=='.' && s[i]==s[i+1] && s[i]==s[i+2]){
                    cout<<"Yes\n";
                    return 0;
                }
            }
        }
        cout<<"No\n";
    }else{
        cout<<"No\n";
    }
}


/*



*/

Measured memory_bytes: 592
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;

int a[55];

int N;

int main()
{
	cin >> N;
	
	bool plus = true;
	bool minus = true;
	a[54] = 1000000;
	a[0] = -10000000;
	int mai = 0;
	int mii = 54;
	for(int i = 1;i <= N;i++)
	{
		cin >> a[i];
		if(a[i] > 0)
		{
			minus = false;
		}
		if(a[i] < 0)
		{
			plus = false;
		}

		if(a[mai] < a[i]) mai = i;
		if(a[mii] > a[i]) mii = i;
	}

	stringstream res;
	int cou = 0;
	if(plus == false && minus == false)
	{
		if(abs(a[mai]) >= abs(a[mii]))
		{
			for(int i = 1;i <= N;i++)
			{
				res << mai << " " << i << endl;
				cou++;
			}
			plus = true;
		}
		else
		{

			for(int i = 1;i <= N;i++)
			{
				res << mii << " " << i << endl;
				cou++;
			}
			minus = true;
		}
	}



	if(minus)
	{
		for(int i = N - 1;i >= 1;i--)
		{
			cou++;
			res << i + 1 << " " << i << endl;
		}

		cout << cou << endl;
		cout << res.str();
		return 0;
	}
		

	
	if(plus)
	{
		for(int i = 1;i < N;i++)
		{
			cou++;
			res << i << " " << i + 1 << endl;
		}
		cout << cou << endl;
		cout << res.str();
		return 0;
	}
}


Measured memory_bytes: 384
n,k = map(int,input().split())
s = input()
zo = []
if s[0:1] == "0":
    zo.append(0)
count = 0
zero_one = s[0:1]
for i in range(n):
    if zero_one == s[i:i+1]:
        count += 1
    else:
        zo.append(count)
        count = 1
        zero_one = s[i:i+1]
zo.append(count)
if s[n-1:n] == "0":
    zo.append(0)

a = sum(zo[0:2*k+1])
ans = a
for i in range(int((n-(2*k+1))/2)):
    a += sum(zo[(2*k+1)+i*2:(2*k+1)+i*2+2])
    a -= sum(zo[i*2:i*2+2])
    if a > ans:
        ans = a
print(ans)

Measured memory_bytes: 45936
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int b[a*2];
    for(int i=0;i<a*2;i++){
        cin>>b[i];
    }
    
    for(int i=0;i<a*2;i++){
        if(b[i]==b[i+1]){
            if(b[i+2]==b[i+3]){
                if(b[i+4]==b[i+5]){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b;
    cin>>a>>b;
    long long int p=a*b;
    if((a!=1)&&(b!=1))
    {
    if(p%2==0)
    {  p=p/2;
        cout<<p;
        
    }
    else
    {  p=p/2;
       p=p+1;
        cout<<p;
    }
    return 0;
    }
   cout<<1; 
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = li_input()
    D = collections.defaultdict(lambda: 0)
    C = [0, 0]

    for a in A:
        D[a] += 1

    for k, v in D.items():
        if 2 <= v:
            C.append(k)
        if 4 <= v:
            C.append(k)

    C.sort(reverse=True)

    print(C[0] * C[1])


main()


Measured memory_bytes: 19784
#include<iostream>
#include<vector>
using namespace std;
int t[505][505];
vector<int> v1[4];
int main(){
	int h,w;
	int i,j,k;
	int a,b,c;
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>t[i][j];
		}
	}
	c=0;
	for(i=0;i<h;i++){
		for(k=0;k<w;k++){
			if(i%2==0)j=k;
			else j=w-k-1;
			if(c==1){
				v1[0].push_back(a+1);
				v1[1].push_back(b+1);
				v1[2].push_back(i+1);
				v1[3].push_back(j+1);
			}
			if(t[i][j]%2==1)c=1-c;
			a=i,b=j;
		}
	}
	cout<<v1[0].size()<<endl;
	for(i=0;i<v1[0].size();i++){
		cout<<v1[0][i]<<" "<<v1[1][i]<<" "<<v1[2][i]<<" "<<v1[3][i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 5220
#!/usr/bin/env python3
import sys


def solve(N: int):
    return sum(1 for i in range(1, N+1) if len(str(i)) % 2 == 1)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

if __name__ == '__main__':
    main()


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


#define ll long long
#define pll pair <ll,ll>
#define fi first
#define se second
#define endl "\n"
#define sqr(b) (b)*(b)


using namespace std;



int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    ll n;
    ll a[111111], f[111111];

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        f[i] = 2e9;
    }

    f[1] = 0;
    for (int i = 1; i <= n - 1; i++) {
        f[i + 1] = min(f[i + 1], f[i] + abs(a[i] - a[i + 1]));
        f[i + 2] = min(f[i + 2], f[i] + abs(a[i] - a[i + 2]));
    }

    cout << f[n] << endl;

    return 0;
}


Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<pair<int,int> >adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int> > PQ;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int,int>f=PQ.top();
    PQ.pop();
    int u=f.second;
    color[u]=BLACK;

    if(d[u]<f.first*(-1)) continue;

    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }
}

int main(){
  int k,c,u,v;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  
  dijkstra();

  return 0;
}



Measured memory_bytes: 8080
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
using namespace std;


int main() {
	int x,y,z,w;
	cin >> x ;
	if(x==1)cout<<0;
	else{
	cin>> y >> z;
	if(y>z)swap(y,z);
	for(int i=0;i<x-2;i++){
	cin >> w;
	y = min(y,w);
	z = max(z,w);
	}
	cout << z-y<<endl;
}
	}


Measured memory_bytes: 256
// C++ program to find the longest 
// path in the DAG 

#include <bits/stdc++.h> 
using namespace std; 

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{ 
	int n,e;
	cin>>n>>e;
	vector<int> adj[n + 1]; 

	for(int i=0;i<e;i++){
		int a,b;
		cin>>a>>b;
	addEdge(adj, a, b);} 


	cout << findLongestPath(adj, n); 
	return 0; 
} 


Measured memory_bytes: 9600
let () =
  let f x y = (x*60+y,x,y) and
      scanf = Scanf.scanf " %d %d" and
      comp (x1,_,_) (x2,_,_) = if x1 = x2 then 0 else if x1 < x2 then 1 else -1
  in
  let n1 = Scanf.scanf "%d" (fun x -> x) in
  let bus1 = Array.init n1 (fun x -> scanf f) in
  let n2 = Scanf.scanf " %d" (fun x -> x) in
  let bus2 = Array.init n2 (fun x -> scanf f) in
  let len1 = Array.length bus1 and
      len2 = Array.length bus2 in
  let rec merge h i j =
    if len1 > i || len2 > j then
      if len1 <= i then merge (bus2.(j)::h) i (j+1)
      else if len2 <= j then merge (bus1.(i)::h) (i+1) j
      else
        let (x1,_,_) = bus1.(i) and
            (x2,_,_) = bus2.(j) in
        if x1 > x2 then merge (bus1.(i)::h) (i+1) j
        else merge (bus2.(j)::h) i (j+1)
    else
      h
  in
  Array.sort comp bus1;
  Array.sort comp bus2;
  let list = merge [] 0 0 in
  let rec print prev = function
      [] -> ()
    | h::t ->
       let (h1,h2,h3) = h in
       if prev <> h1 then
           if prev = (-1) then
             Printf.printf "%d:%02d" h2 h3
           else
             Printf.printf " %d:%02d" h2 h3
       ;print h1 t
  in
  print (-1) list;print_newline ()
;;

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

namespace ExaWiz
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);
            if (A == B && B == C && C == A)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list_a = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            int din = sc.nextInt();
            list_a.add(din);
        }
        
        Collections.sort(list_a);
        int ans = 0;
        for(int i = 1; i < n; i++){
            //char c = (i == n - 1)? '\n' : ' ';
            //System.out.print(list_a.get(i));
            //System.out.print(c);
            ans += list_a.get(i) - list_a.get(i - 1);
        }
        System.out.println(ans);
    }    
}

Measured memory_bytes: 21844
import math
N = int(input())
A = list(map(int,input().split()))
b = [[0]*60 for i in range(2)]
#max_a = math.ceil(math.log(max(A),2))
max_a = 60
for i in range(N):
    x = A[i]
    j = 0
    for j in range(max_a):
        b[x % 2][j] += 1
        x //= 2

x = 0
for i in range(max_a):
    x += b[0][i] * b[1][i] * 2**i
    x %= 10 ** 9 + 7

print (x)

Measured memory_bytes: 122936
def calc_median(X):
    #中央値計算
    Xl = len(X)
    if Xl % 2:
        ret = X[(Xl + 1) // 2 - 1]
    else:
        ret = (X[Xl // 2 - 1] + X[Xl // 2]) / 2

    return ret


N, *AB = map(int, open(0).read().split())

A = sorted(AB[::2])
B = sorted(AB[1::2])

AM = calc_median(A)
BM = calc_median(B)

if N % 2:
    ans = BM - AM + 1
else:
    ans = int((BM - AM) * 2 + 1)

print(ans)


Measured memory_bytes: 55244
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct WeightedUnionFind {
    vector<int> data;
    vector<int> diff_weight;

    WeightedUnionFind(int sz) : data(sz, -1), diff_weight(sz, 0) {}

    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) {
                swap(x, y);
                w = -w;
            }
            data[x] += data[y];
            data[y] = x;
            diff_weight[y] = w;
        } else {
            if (diff(x, y) == w) return true;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { 
            return x;
        } else {
            int par = data[x];
            data[x] = find(data[x]); 
            diff_weight[x] += diff_weight[par];
            return data[x];
        }
    }

    int weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int diff(int x, int y) {
        return weight(y) - weight(x);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    WeightedUnionFind wuf(n);
    rep(i,m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if(!wuf.unite(l, r, d)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100;

int qw[N],cnt,q[N],n;
vector<int>in[500];

int main(){
	int i=1,j;
	cin>>n;
	for(i=1;;++i){
		qw[i]=qw[i-1]+i;
		if(qw[i]>=n) break;
	}
	if(qw[i]!=n){
		puts("No");
		return 0;
	}
	cnt=i;
	puts("Yes");
	cout<<cnt+1<<endl;
	int cot=0;
	for(i=1;i<=cnt;++i)
	 for(j=i+1;j<=cnt+1;++j){
	 	++cot;
	    in[i].push_back(cot);
	    in[j].push_back(cot);
	 }
	for(i=1;i<=cnt+1;++i){
		printf("%d",cnt);
		for(j=0;j<cnt;++j)
		 printf(" %d",in[i][j]);
		 puts("");
	}
	return 0;
}

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


int main(void) {
	char input[30];
	double r;
	double a, b;
	double pi = 3.14159265358979323846264338327950288;
	
	r = atof(fgets(input, sizeof(input), stdin));
	
	a = r * r * pi;
	b = 2 * r * pi;
	
	printf("%f %f\n", a, b);
	
	return 0;
}

Measured memory_bytes: 584
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

N, W = input_li()
# dp[n][w] ... 荷物nまでの容量wの価値の最大値を格納する
dp = [[0] * (W + 1) for _ in range(N + 1)]
wv_li = [input_li() for _ in range(N)]
now_w = 0
for i in range(N):
    for sum_w in range(W + 1):
        w, v = wv_li[i]
        if w > sum_w:
            # 容量オーバー
            dp[i + 1][sum_w] = dp[i][sum_w]
        else:
            dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - w] + v)
print(dp[N][W])


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int solve(string& str) {
    int n = str.size();
    if (n % 2)
        return 0;
    string tmp = str.substr(0, n / 2);
    tmp = tmp + tmp;
    return tmp == str;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    string str;
    cin >> n >> str;
    int ans = solve(str);
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
 
    public  static void main(String[] args)   throws Exception, IOException{
     
        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
     
        // int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // for (int i=0; i<n; i++) {a[i]=sc.nextInct();}
        int a=sc.nextInt();
        int b=sc.nextInt(),x=0;

        char c[] = sc.nextString().toCharArray();
        for (int i=0;i<c.length ;i++ ) {
            if(c[i]=='-')x++;
        }

        out.println((x==1 && c[a]=='-')?"Yes":"No" );
        out.flush();
    }

    static void db(Object... os){
     
        System.err.println(Arrays.deepToString(os));
     
    }
     
    static boolean validpos(int x,int y,int r, int c){
        
        return x<r && 0<=x && y<c && 0<=y;
        
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
string s; long long k, ans[101][2], sol;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s >> k; int n=s.size();
ans[0][1]=1; 
bool kk=1; for(int i=0; i<n-1; i++) if (s[i]!=s[i+1]) kk=0;
if (kk){cout << (n*k)/2; return 0;}
for (int i=1; i<n; i++){
	if (s[i]==s[i-1]){
		ans[i][0]=ans[i-1][1];
		ans[i][1]=min(ans[i-1][0], ans[i-1][1])+1;
	}
	else{
		ans[i][0]=min(ans[i-1][1], ans[i-1][0]);
		ans[i][1]=min(ans[i-1][0], ans[i-1][1])+1;
	} 
}
sol=min(ans[n-1][0], ans[n-1][1]);
sol*=k;
if (s[n-1]==s[0]){
	int kk1=1, kk2=1;
	for (int i=n-1; i>0; i--){
		if (s[i]!=s[i-1]) break;
		kk1++;
	}
	for (int i=0; i<n; i++){
		if (s[i]!=s[i+1]) break;
		kk2++;
	}
	if (kk2%2 and kk1%2) sol+=k-1;
}
cout << sol;
return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();

    let mut iter = input.split_whitespace().map(|w| w.parse::<i32>().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let c = iter.next().unwrap();

    let num = (a..b+1).filter(|n| c % n == 0).count();
    println!("{}", num);
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);
string S;
  int N,K;
  cin >> N>>K;
  cin >>S;
  if(S.at(K-1)=='A') S.at(K-1)='a';
  else if (S.at(K-1)=='B') S.at(K-1)='b';
  else S.at(K-1)='c';
  
  cout <<S<<endl;

	
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextLong();
		int[] X = new int[N];
		int[] Y = new int[N];
		int c=0;
		double dista = 0;
		for(int i=0;i<N;++i){
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
		}
		sc.close();
		for(int i=0;i<N;++i){
			dista = Math.pow(X[i], 2) + Math.pow(Y[i], 2);
			if (D * D >= dista) {
				c++;
			}
		}
		System.out.println(c);
	}
}



Measured memory_bytes: 60952
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <functional>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
using namespace std;
static const int Nil = -1;
static const int Inf = 1 << 30;
static const int MAX = 100;

int main()
{
    int N;
    int Alice = 0, Bob = 0;
    int a[MAX];
    cin >> N;
    REP(i, N)
    {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());
    REP(i, N)
    {
        if (i % 2 == 0)
        {
            Alice += a[i];
        }
        else
        {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else if(s[0] == '/') {
      b = pop();
      a = pop();
      push(a / b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}




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

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

	sort(a, a + 3);

	cout << a[0] + a[1] << endl;

	return 0;

	
}


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

int main() {
	string S;
	cin >> S ;
	if (S == "SUN") {
		cout << 7 << endl;
	}
	if (S == "MON") {
		cout << 6 << endl;
	}
	if (S == "TUE") {
		cout << 5 << endl;
	}
	if (S == "WED") {
		cout << 4 << endl;
	}
	if (S == "THU") {
		cout << 3 << endl;
	}
	if (S == "FRI") {
		cout << 2 << endl;
	}
	if (S == "SAT") {
		cout << 1 << endl;
	}

		


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

ll d[111][111];
void warshall_floyd(int n) {
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            for(int k=0;k<n;k++)
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
}
signed main() {
    REP(i,111) REP(j,111) d[i][j]=(i==j?0:INF);
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m),c(m);
    REP(i,m) {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--,b[i]--;
        d[a[i]][b[i]]=c[i];
        d[b[i]][a[i]]=c[i];
    }
    warshall_floyd(n);

    int ans=0;
    REP(i,m) {
        bool used=false;
        REP(k,n) {
            REP(l,n) {
                if(d[k][a[i]]+c[i]+d[b[i]][l]==d[k][l]) {
                    used=true;
                }
            }
        }
        if(!used) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll R;
	while(cin>>R) {
		cout<<R*R<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import defaultdict


def main():
    X, Y, Z, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    B = list(map(int, input().split(' ')))
    C = list(map(int, input().split(' ')))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    que = [(- A[0] - B[0] - C[0], 0, 0, 0)]  # multiply -1 to change min to max
    already_inserted = defaultdict(int)
    answer = list()
    for _ in range(K):
        q, i, j, k = heappop(que)
        answer.append(-q)
        if i + 1 < X:
            item_a = (- A[i + 1] - B[j] - C[k], i + 1, j, k)
            if already_inserted[item_a] == 0:
                heappush(que, item_a)
                already_inserted[item_a] = 1
        if j + 1 < Y:
            item_b = (- A[i] - B[j + 1] - C[k], i, j + 1, k)
            if already_inserted[item_b] == 0:
                heappush(que, item_b)
                already_inserted[item_b] = 1
        if k + 1 < Z:
            item_c = (- A[i] - B[j] - C[k + 1], i, j, k + 1)
            if already_inserted[item_c] == 0:
                heappush(que, item_c)
                already_inserted[item_c] = 1
    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	string s;
	string ans = "";

	cin >> s;

	REP(i, s.size()) {
		ans += s[i];
		i++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int mod = 1000000000 + 7;
struct mint
{
    ll x; //
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
    string S;
    cin >> S;
    vector<vector<mint>> digit_rest(S.size(), vector<mint>(13, 0)), dp(S.size(), vector<mint>(13, 0));

    int digit = 1;
    reverse(S.begin(), S.end());
    rep(i, S.size())
    {
        if (S[i] == '?')
        {
            rep(n, 10)
            {
                int rest = n * digit;
                rest %= 13;
                digit_rest[i][rest] += 1;
            }
        }
        else
        {
            int n = S[i] - '0';
            int rest = n * digit;
            rest %= 13;
            digit_rest[i][rest] += 1;
        }
        digit *= 10;
        digit %= 13;
    }

    reverse(digit_rest.begin(), digit_rest.end());

    rep(i, 13)
    {
        dp[0][i] = digit_rest[0][i];
    }

    rep(i, S.size() - 1) rep(j, 13)
    {
        rep(nj, 13)
        {
            if (digit_rest[i + 1][nj].x == 0)
                continue;

            dp[i + 1][(j + nj) % 13] += dp[i][j];
        }
    }
    cout << dp[S.size() - 1][5] << endl;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<string> s(2);
  rep(i, 2) cin >> s[i];

  int n = s[1].size();
  rep(i, n) cout << s[0][i] << s[1][i];
  if (s[0].size() > n) cout << s[0][n];
  cout << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int i,c;
    scanf("%d", &i);
    
    while(i != 0){
        c = 0;
        i = 1000 - i;
        
            if(i >= 500) {
                i -= 500;
                c ++;
            }
            if(i >= 100){
                c += (i / 100);
                i %= 100;
            }
            if(i >= 50){
                i -= 50;
                c ++;
            }
            if(i >= 10){
                c += (i / 10);
                i %= 10;
            }
            if(i >= 5){
                i -= 5;
                c++;
            }
            
            c += i;
        
        printf("%d\n", c);
        
        scanf("%d", &i);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int n,r;
    cin >> n >> r;
    if(n>=10) cout << r << endl;
    else cout <<100*(10-n)+r << 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++)
typedef long long INT;
double PI = 3.14159265;

const long long INF = 1LL << 60;


int main() {
    int N, a[101] = {},sum=0;

    cin >> N;

    rep(i, N)cin >> a[i];

    sort(a,a+N,greater<int>());

    rep(i, N) {
        if (i % 2 == 0)sum += a[i];
        else sum -= a[i];
    }

    cout << sum << endl;

  return 0;
}

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

using namespace std;

int main()
{
	int n, x, t;
	cin >> n >> x >> t;

	int count = (n % x == 0) ? n / x : n / x + 1;

	cout << count * t << endl;

	return 0;
}

Measured memory_bytes: 3620
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [0]*N
for i in range(1, N):
    v = 10**18
    for k in range(min(K, i)):
        v = min(v, dp[i-k-1] + abs(A[i] - A[i-k-1]))
    dp[i] = v
print(dp[N-1])

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

ll dp[105][100005];

int main() {
    int N, W;
    cin >> N >> W;
    int w[N], v[N];
    rep(i, N) cin >> w[i] >> v[i];

    rep(i, N) {
        rep(sum_w, W + 1) {
            if (sum_w - w[i] >= 0) {
                dp[i + 1][sum_w] =
                    max(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            dp[i + 1][sum_w] = max(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 81672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int a=0;
  rep(i, 3){
  int s;
    cin >>s;
    a+=s;
  }
  if(a>21)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,k){
        ans+=a[i];
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char> > data(H, vector<char>(W));
	vector<string> vec(H);

	for (int i = 0; i < H; i++) {
		cin >> vec.at(i);
  	}

  	for (int i = 0; i < H; i++) {
    	for (int j = 0; j < W; j++) {
      		data.at(i).at(j) = vec.at(i).at(j);
    	}
  	}

  	for (int i = 0; i < H; i++) {
    	for (int j = 0; j < W; j++) {
    		int answer = 0;
    		if(data.at(i).at(j)=='.'){
	    		if(j > 0){
	    			if(data.at(i).at(j-1)=='#'){
	    				answer++;
	    			}
	    			if(i > 0){
	    				if(data.at(i-1).at(j-1)=='#'){
	    					answer++;
	    				}
	    			}
	    			if(i < H-1){
	    				if(data.at(i+1).at(j-1)=='#'){
	    					answer++;
	    				}
	    			}
				}

				if(j < W-1){
	    			if(data.at(i).at(j+1)=='#'){
	    				answer++;
	    			}
	    			if(i > 0){
	    				if(data.at(i-1).at(j+1)=='#'){
	    					answer++;
	    				}
	    			}
	    			if(i < H-1){
	    				if(data.at(i+1).at(j+1)=='#'){
	    					answer++;
	    				}
	    			}				
				}	
	    		if(i > 0){
	    			if(data.at(i-1).at(j)=='#'){
	    				answer++;
	    			}
	    			
	    		}
	    		
	    		if(i < H-1){
	    			if(data.at(i+1).at(j)=='#'){
	    				answer++;
	    			}
	    		}	
	      		cout << answer;
	    	}
	    	else{
	    		cout << '#';
	  		}

	    }
	    cout << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);
        int A, B;
        A = sc.nextInt();
        B = sc.nextInt();
        if(A*B%2 == 0)
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> ans(n, 0);
  rep(i, n-1){
    int in;
    cin >> in;
    in--;
    ans.at(in)++;
  }
  rep(i, n){
    cout << ans.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
n, m = map(int, input().split())
c = list(map(int, input().split()))

dp = [[float('inf')]*50010 for _ in range(25)]
dp[0][0] = 0
for i in range(m):
    for j in range(n+1):
        if j >= c[i]:
            dp[i+1][j] = min(dp[i][j-c[i]] + 1, dp[i][j], dp[i+1][j-c[i]]+ 1)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[m][n])


Measured memory_bytes: 45352
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  vint a(3);
  for (ll i=0;i<3;i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  cout << a.at(2)-a.at(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define ll long long
using namespace std;
const int N=2e5+5;
int n,cnt,x[N];ll k,daoyin;
int lower_bound(ll Mid)
{
	int l=0,r=n-1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(x[mid]*daoyin>Mid)
			l=mid+1;
		else
			r=mid-1;
	}
}
int upper_bound(ll Mid)
{
	int l=0,r=n-1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(x[mid]*daoyin>=Mid)
			l=mid+1;
		else
			r=mid-1;
	}
}
bool check(ll mid)
{
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		daoyin=x[i];
		if(x[i]==0)
		{
			if(mid>=0)
				sum+=n-1;
		}
		else
		if(x[i]<0)
		{
			ll lc=mid/x[i];
			if(mid/x[i]*x[i]>mid)lc++;
			ll num=lower_bound(x,x+n,lc)-x;
			//-x*a<=mid,x>=mid/a
			if(num<=i)sum--;
			sum+=n-num;
		}
		else
		{
			ll lc=mid/x[i];
			if(mid/x[i]*x[i]>mid)lc--;
			ll num=upper_bound(x,x+n,lc)-x-1;
			if(num<0)continue;
			if(num>=i)sum--;
			sum+=num+1;
		}
	}
	return sum/2>=k;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
	}
	sort(x,x+n);
	ll l=-1e18,r=1e18;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(check(mid))
			r=mid-1;
		else
			l=mid+1;
	}
	cout<<r+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

import random


def f(x, A, B):
    return (A * x) // B - A * (x // B)

def main():
    A, B, N = MI()
    ans = 0
    s = set()

    x = B - 1
    # print(f(x, A, B))

    if x >= N:
        # print(x, N)
        x = N

    # print('x', x)
    print(f(x, A, B))
    # print(3, f(3, A, B))
    # print(4, f(4, A, B))

    # for x in range(min(N+1, 10**6)):
    #     d = f(x, A, B)
    #     ans = max(ans, d)
    #     s.add(d)
    #     print(x, d)

    # print(s)
    # print(ans)


if __name__ == '__main__':
    main()


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

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+5;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int a[MAX];
pair<int,int>p[MAX];
in main()
{
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
for(int i=0;i<m;i++)
{
	cin>>p[i].s>>p[i].f;
	p[i].f*=-1;
}
sort(a,a+n);
sort(p,p+m);
int idx=0;
for(int i=0;i<m;i++)
{
 	p[i].f*=-1;
	int cur=p[i].s;
	while(idx<n&&p[i].f>a[idx]&&cur--)
	{
		a[idx++]=p[i].f;
	}
}
int ans=0;
for(int i=0;i<n;i++)
{
ans+=a[i];	
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840