akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

// Lunlun数のリストを更新する.
// @param s:    (更新前)Lunlun数情報のリスト.
// @return ret: (更新後)Lunlun数情報のリスト.
set<LL> updateLunlun(set<LL> s){
    set<LL> ret;
    for(auto &o : s){
        LL r = o % 10; // 1の位を取得.
        for(LL d : {-1, 0, 1}){
            LL a = r + d; // 1の位に, -1, 0, 1 を 加算.
            if(a >= 0 && a <= 9) ret.insert(o), ret.insert(10 * o + a);
        }
    }
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int K;
    scanf("%d", &K);
    
    // 2. Lunlun数 を 保存.
    set<LL> s;
    rep(i, 9) s.insert(i + 1);
    rep(i, 10){
        set<LL> ls = updateLunlun(s);
        swap(s, ls);
    }
    
    // 3. K番目 を 取得.
    LL ans = 0;
    int count = 0;
    for(auto &p : s){
        if(++count == K){
            ans = p;
            break;
        }
    }
    
    // 4. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 46252
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, K = sc.nextInt()
    sc.nextLine()
    val S = sc.nextLine()

    var left = 0
    var right = 0
    while (right < N && S(right) == '1')
      right += 1

    var i = 0
    while (i < K) {
      while (right < N && S(right) == '0')
        right += 1
      while (right < N && S(right) == '1')
        right += 1
      i += 1
    }

    var max = right - left
    while (left < N && right < N) {
      while (left < N && S(left) == '1')
        left += 1
      while (left < N && S(left) == '0')
        left += 1
      while (right < N && S(right) == '0')
        right += 1
      while (right < N && S(right) == '1')
        right += 1
      max = Math.max(max, right - left)
    }

    println(max)
  }

}


Measured memory_bytes: 31424
object Main extends App {
  val n: Int = io.StdIn.readLine().toInt
  val arr: Array[Int] = io.StdIn.readLine().split(" ") map(_.toInt)
  val k: Int = 10000
  val count: Array[Int] = Array.fill(k+1)(0)
  val result: Array[Int] = Array.fill(n)(0)

  for (i <- arr) count(i) += 1
  for (i <- 1 to k) count(i) += count(i-1)
  for (i <- n-1 to 0 by -1) {
    result(count(arr(i))-1) = arr(i)
    count(arr(i)) -= 1
  }

  println(result.mkString(" "))
}

Measured memory_bytes: 480416
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> minus;
    vector<int> plus;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if(x<0) minus.push_back((-1)*x);
        else plus.push_back(x);
    }
    int m = minus.size(), p = plus.size();
    while(minus.size()<K) minus.push_back(1000000000);
    while(plus.size()<K) plus.push_back(1000000000);
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());
    
    int ans = 1000000000;
    ans = min(ans, plus.at(K-1));
    ans = min(ans, minus.at(K-1));
    for(int i = 0; i < K-2; i++) {
        ans = min(ans, minus.at(i) + 2*plus.at(K-i-2));
        ans = min(ans, 2*minus.at(i) + plus.at(K-i-2));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main() {
    int H[100], W[100];
    int count = 0, i, j, k;

    while (1)
    {
        scanf("%d %d", &H[count], &W[count]);
        if (H[count] == 0 && W[count] == 0) {
            break;
        }
        count++;
    }

    for (i = 0; i < count; i++) {
        for (j = 0; j < H[i]; j++) {
            if (j == 0 || j == H[i] - 1) {
                for (k = 0; k < W[i]; k++)
                {
                    printf("#");
                }
                printf("\n");
            }
            else
            {
                printf("#");
                for (k = 1; k < W[i] - 1; k++)
                {
                    printf(".");
                }
                printf("#\n");
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2032
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] x = new int[N];
        int sum = 0;

        for(int i=0; i<N; i++){
            x[i] = sc.nextInt();
            if(Math.abs(K-x[i])<=Math.abs(x[i])){
                sum += Math.abs(K - x[i]);
            }
            else{
                sum += Math.abs(x[i]);
            }
        }
        System.out.println(2 * sum);

    }
}

Measured memory_bytes: 23124
#!/usr/bin/env pypy3


import collections
 
 
class UnitDict(dict):
 
    def __init__(self, iterable=None, wrapper=lambda x: x):
        super().__init__(self)
        self.wrapper = wrapper
        if iterable is not None:
            self.update(iterable)
 
    def __missing__(self, key):
        self[key] = self.wrapper(key)
        return self[key]
 
 
class DisjointSetDataStructure(object):
 
    def __init__(self, nodes=None):
        self.par = UnitDict(wrapper=lambda x: x)
        self.rank = collections.defaultdict(int)
        self.groups = UnitDict(wrapper=lambda x: {x})
        if nodes is not None:
            for node in nodes:
                _, _, _ = self.par[node], self.rank[node], self.groups[node]
         
    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r
     
    def in_the_same_set(self, node1, node2):
        return self.root(node1) == self.root(node2)
     
    def elements_of_group(self, node):
        return self.groups[self.root(node)]
  
    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            self.groups[x].update(self.groups[y])
            self.groups[y].clear()
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def solve(n, m, edges):
    dds = DisjointSetDataStructure(range(n))
    inconvs = [n * (n - 1) // 2]
    for a, b in reversed(edges):
        if dds.in_the_same_set(a, b):
            inconvs.append(inconvs[-1])
        else:
            n_a = len(dds.elements_of_group(a))
            n_b = len(dds.elements_of_group(b))
            inconvs.append(inconvs[-1] - n_a * n_b)
        dds.unite(a, b)
    return inconvs[::-1][1:]


def main():
    n, m = (int(z) for z in input().split())
    edges = [tuple((int(z) - 1 for z in input().split())) for _ in range(m)]
    res = solve(n, m, edges)
    print(*res, sep="\n")
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 162680
import java.util.*;
import java.io.*;

public class Main {	
	static int H;
	static int W;
	static char[][] grid;
	static int[][] minblack;
	private static void solve(){
		//Implement solution here.
		H = ni();
		W = ni();
		grid = new char[H][W];
		minblack = new int[H][W];
		for(int i = 0; i < H; i++) 	grid[i] = next().toCharArray();
		for(int i = 0; i < H; i++) 	Arrays.fill(minblack[i], -1);
		steps(0,0,0,false);
//		for(int i = 0; i < H; i++) {
//			for(int j = 0; j < W; j++) {
//				System.out.print(minblack[i][j]);
//			}
//			System.out.println();
//		}
		System.out.println(minblack[H - 1][W - 1]);
	}

	private static void steps(int y, int x,int cnt,boolean bbefore) {
//		System.out.println(y + " " + x + " " + cnt + " " + minblack[y][x]);
		if(grid[y][x] == '#' && !bbefore)cnt++;
		if(grid[y][x] == '#') {
			bbefore = true;
		} else {
			bbefore = false;
		}
		if(minblack[y][x] >= 0) {
			if(cnt >= minblack[y][x]) {
				return;
			}
		} 
		minblack[y][x] = cnt;
//		System.out.println(minblack[y][x]);
		//go right
		if(x < W - 1)steps(y,x + 1,cnt,bbefore);
		//go down
		if(y < H - 1)steps(y + 1,x,cnt,bbefore);		
	}



	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include<bits/stdc++.h>
#define lli long long
using namespace std;

int main()
{
   string a,b;
   cin>>a>>b;

   if(a.size()+1!=b.size())cout <<"No\n";
   else
   {
       if(a==b.substr(0,a.size()))cout <<"Yes\n";
       else cout<<"No\n";

   }


}


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

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

    ll n,a,b;
    cin >> n >> a >> b;
    
    if (a <= b){
        if (n == 1){
            if (a == b){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
        else if (n == 2){
            cout << 1 << endl;
        }
        else{
            ll l = a + b*(n-1);
            ll s = a*(n-1) + b;
            cout << l-s+1 << endl;
        }
    }
    else{
        cout << 0 << endl;
    }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int n,m;
vector<P> subways;
vector<vector<P>> g;
ll dist[500010]; int s,t;
void dijkstra(){
    Fill(dist,INF); dist[s]=0;
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push({0,s});
    while(pq.size()){
        P p=pq.top(); pq.pop();
        int d=p.first,v=p.second;
        if(dist[v]<d)continue;
        for(P to:g[v]){
            int nxtv=to.first;
            if(chmin(dist[nxtv],dist[v]+to.second))pq.push({dist[nxtv],nxtv});
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    rep(i,0,n)subways.push_back({i,-1});
    vector<int> u(m),v(m),w(m);
    rep(i,0,m){
        scanf("%d%d%d",&u[i],&v[i],&w[i]);
        u[i]--; v[i]--;
        subways.push_back({u[i],w[i]});
        subways.push_back({v[i],w[i]});
    }
    sort(ALL(subways));
    subways.erase(unique(ALL(subways)),subways.end());
    int sz=subways.size();
    map<P,int> enco;
    rep(i,0,sz)enco[subways[i]]=i;
    g.resize(sz);
    rep(i,0,sz){
        if(subways[i].second==-1)continue;
        int sta=subways[i].first;
        int reach=enco[{sta,-1}];
        g[i].push_back({reach,0});
        g[reach].push_back({i,1});
    }
    rep(i,0,m){
        int sta=enco[{u[i],w[i]}],reach=enco[{v[i],w[i]}];
        g[sta].push_back({reach,0});
        g[reach].push_back({sta,0});
    }
    s=enco[{0,-1}],t=enco[{n-1,-1}];
    dijkstra();
    printf(dist[t]==INF?"-1\n":"%lld\n",dist[t]);
    return 0;
}

Measured memory_bytes: 96104
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std; //
int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	else if(a>b){
		cout<<"a > b"<<endl;
	}
	else{
		cout<<"a == b"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
const int NAX = 2e3 +1;
long long dp[NAX][NAX];

long long fabs(int x, int y, int z) {
  	return x * 1LL * abs(y - z);
}

int main() {
	int N;
	cin >> N;
  	vector<pair<int, int>> arr(N);
	for (int i = 0; i < N; ++i) {
    	cin >> arr[i].first;
     	arr[i].second = i;
    }
 	sort(arr.begin(), arr.end());
	for (int i = 0; i < N; ++i) {
    	dp[i][i] = fabs(arr[0].first, arr[0].second, i);
    }
	for (int i = 2; i <= N; ++i) {
    	for (int x = 0; x + i - 1 < N; ++x) {
			int y = x + i - 1;
	        dp[x][y] = max(dp[x + 1][y] + fabs(arr[i - 1].first, arr[i - 1].second, x), 
                          dp[x][y - 1] + fabs(arr[i - 1].first, arr[i - 1].second, y));
        }
    }
  	cout << dp[0][N - 1] << endl;
  	return 0; 
}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  double c = n - n/2;
  printf("%.6f", c/n);
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int f[100001][2];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        f[x][i % 2]++;
    }
    int v = 0, w = 0, pv = 0, pw = 0;
    for (int i = 1; i < 100001; ++i)
    {
        if (f[i][0] > f[v][0])
            v = i;
        if (f[i][1] > f[w][1])
            w = i;
    }
    for (int i = 1; i < 100001; ++i)
    {
        if (i != v && f[i][0] > f[pv][0])
            pv = i;
        if (i != w && f[i][1] > f[pw][1])
            pw = i;
    }
    if (v == w)
        cout << n - max(f[v][0] + f[pw][1], f[pv][0] + f[w][0]);
    else
        cout << n - f[v][0] - f[w][1];
}


Measured memory_bytes: 1152
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,a,b,ans=0;
  cin >> n >> a >> b;
  ll x[n];
  for(int i=0;i<n;i++){
    cin >> x[i];
  }
  for(int i=1;i<n;i++){
    ans += min(b,(x[i]-x[i-1])*a);
  }
  cout << ans << endl;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a < c && c < b){
        cout << "Yes" << endl;
    }
    else if (b < c && c< a){
        cout << "Yes" << endl;
}
    else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, a, top int
	fmt.Scan(&N)
	color := make([]bool, 8)
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		switch {
		case 1 <= a && a < 400:
			color[0] = true
		case 400 <= a && a < 800:
			color[1] = true
		case 800 <= a && a < 1200:
			color[2] = true
		case 1200 <= a && a < 1600:
			color[3] = true
		case 1600 <= a && a < 2000:
			color[4] = true
		case 2000 <= a && a < 2400:
			color[5] = true
		case 2400 <= a && a < 2800:
			color[6] = true
		case 2800 <= a && a < 3200:
			color[7] = true
		case 3200 <= a:
			top += 1
		}
	}
	count := 0
	for _, v := range color {
		if v {
			count += 1
		}
	}
	min := count
	if count == 0 {
		min = 1
	}
	max := count + top
	fmt.Println(min, max)
}


Measured memory_bytes: 512
n = gets.to_i
a = Array.new()
n.times do
  a << gets.chomp
end

b = a.group_by{|i| i}.
  map{|j| [j[0], j[1].length]}.
  sort{|x, y| y[1] <=> x[1]}
max = b.first[1]
ans = b.select{|k| k[1] == max}.
  sort{|x, y| x[0] <=> y[0]}.
  map{|z| z[0]}.join("\n")

print "#{ans}\n"

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s;

	f(i,0,2){
        if(s[i]=='o') count+=100;
	}
	cout<<700+count<<endl;

}


Measured memory_bytes: 256
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	char c[3][3];
	string ans;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
			if (i == j)ans += c[i][j];
		}
	}
	cout << ans << endl;
	
	return(0);
}

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

using namespace std;

int n, ans;

int main()
{
	int i, t, a, prev = -1;
	
	scanf("%d", &n);
	
	for(i=t=1;i<=n;i++){
		scanf("%d", &a);
		if(a == prev) t ++;
		else{
			if(t > 1) ans += t / 2;
			t = 1;
		}
		prev = a;
	}
	
	if(t > 1) ans += t / 2;
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int N = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    int[] L = new int[N+1];
    L[0] = 0;
    for (int i=1; i<N+1; i++) {
      L[i] = Integer.parseInt(sc.next());
      L[i] += L[i-1];
    }
    
    int cnt = 0;
    for (int i=0; i<N+1; i++) {
      if (L[i] <= X) cnt++;
      else break;
    }
    
    System.out.print(cnt);
  }
}


Measured memory_bytes: 22612
#include<iostream>
#include<vector>
#include<numeric>

using namespace std;

int main() {
	int w, h, n, x, y, a;
	cin >> w >> h >> n;
	vector<vector<bool>> v(h, vector<bool>(w,false));
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;

		if (a == 1) {
			for (int j = 0; j < x; j++) {
				for (int k = 0; k < h; k++) v[k][j] = true;
			}
		}
		if (a == 2) {
			for (int j = x; j < w; j++) {
				for (int k = 0; k < h; k++) v[k][j] = true;
			}
		}
		if (a == 3) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < y; k++)v[k][j] = true;
			}
		}
		if (a == 4) {
			for (int j = 0; j < w; j++) {
				for (int k = y; k < h; k++)v[k][j] = true;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < v.size(); i++)sum += accumulate(v[i].begin(), v[i].end(), 0);
	cout << w*h - sum << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

vector<int> divisor(int n) {
  vector<int> d;
  for(int i = 1; i <= n; i++) {
    if(n % i == 0) d.push_back(i);
  }
  return d;
}

signed main() {
  int n, cnt = 0;
  cin >> n;
  for(int i = 1; i <= n; i += 2) {
    vector<int> d = divisor(i);
    if(d.size() == 8) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int judge(int,int); /*素数を判定*/
int main()
{
  int n,cnt=0,result;
  scanf("%d",&n);
  int s[n],i;
  for(i=0;i<n;i++)
    scanf("%d",&s[i]);
  for(i=0;i<n;i++)
    {
      result=judge(s[i],n);
     if(result==1)cnt++;
    }
  printf("%d\n",cnt);
  return 0;
}
int judge(int x,int n) /*素数を判定*/
{
  int j;
  
      if(x<0)return 0;
      else if(x==2)return 1;
      if(x%2 == 0)return 0;
      for(j=3 ; j*j <= x; j+=2)
	{
	  if(x%j == 0)return 0;
	}
      return 1;
	
}



Measured memory_bytes: 2104
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if(u == s) cout << a-1 << " " << b << endl;
    else if(u == t) cout << a << " " << b-1 << endl;

return 0;
}

Measured memory_bytes: 3608
import heapq
n,m = map(int, input().split())
al = list(map(int, input().split()))
al = [(-1)*a for a in al]
al.sort()

for _ in range(m):
    poped = heapq.heappop(al)
    heapq.heappush(al, (poped*(-1)//2)*(-1))

print(sum(al)*(-1))

Measured memory_bytes: 91952
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  long long Acnt=0,ans=0;
  for(int i=0; i<s.length(); i++){
    if(s[i]=='A'){
      Acnt++;
    }else if(s[i]=='B' && s[i+1]=='C'){
      if(Acnt>0){
        ans+=Acnt;
      }
      i++;
    }else{
      Acnt=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
using namespace std;
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int is_palin(string s){
    int n=s.length();
    for (int i = 0; i < n/2; ++i)
    {
        if(s[i]!=s[n-i-1]) return 0;
    }
    return 1;
}
int32_t main(){
    IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout); 
    int t=1;
    // cin>>t;
    while(t--){
        string s;
        cin>>s;
        int n=s.length();
        if(is_palin(s)&&is_palin(s.substr(0,(n-1)/2))&&is_palin(s.substr(((n+3)/2-1),(n-1)/2)))
            cout<<"Yes";
        else cout<<"No";
        cout<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, k, a[200007], res;
map<ll, ll> mp;

int main () {
    fastIO;
    cin >> n >> k >> a[0], a[0] --;
    a[0] = a[0] % k;
    for(li i = 1; i < n; i ++) cin >> a[i], a[i] = (a[i] + a[i - 1] - 1) % k;

    for(li i = 0; i < n; i ++) {
        if(i >= k) mp[a[i - k]] --;
        res += mp[a[i]];
        if(a[i] == 0 && i < k - 1) res ++;
        mp[a[i]] ++;
    }

    cout << res;
}


Measured memory_bytes: 14336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int k = sc.nextInt();
      	//配列
        int num[] = new int[n];
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < n; i++){
        	if(num[i]>=k){
            	count++;
            }
        }
        System.out.println(count);
     }
}

Measured memory_bytes: 59416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  string X;
  cin>>X;
  stack<char> Y;
  rep(i,X.size()){
    if(X[i]=='S') Y.push('S');
    else if(Y.size()==0||Y.top()=='T') Y.push('T');
    else Y.pop();
  }
  cout<<Y.size()<<endl;
}

Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
main ()
{
	char s[100005];
	int p=0, g=0, ans=0;
	cin >> s;
	int n = strlen (s);
	for (int i=0; i<n; i++)
	{
		if (s[i] == 'g')
		{
			if (g>p)
			{
				ans++;
				p++;
			}
			else g++; 
		}
		else
		{
			if (g>p) p++;
			else
			{
				g++;
				ans--;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e9;
ll mod=998244353 ;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define SIZE 5000 + 1

long long expo(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M)%M;
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

void solve()
{
 ll n,m;
 cin>>n>>m;
 cout<<(n*(n-1)+m*(m-1))/2;
}

int main(){
    boost;
  solve();
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
L = [list(map(int,input().split())) for i in range(n)]

ans = 0
for i in range(n):
      acm = 0
      for j in range(m):
            acm += L[i][j] * B[j]
      if acm + c > 0:
            ans += 1      

print(ans)

Measured memory_bytes: 38256
#include<stdio.h>

int main(void) {
	int i, number[30] = {0},a;
	for (i = 0; i < 28; i++) {
		scanf("%d",&a);
		number[a - 1] = 1;
	}
	for (i = 0; i < 30; i++) {
		if (!number[i])printf("%d\n",i+1);
	}
	return 0;
}

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

using namespace std;

string str;
int calc(int a, int b){
  int acc = 0, depth = 0;
  for(int i=a;i<=b;++i){
    switch(str[i]){
    case '\\':
      acc += depth*2 + 1;
      ++depth;
      break;
    case '/':
      if(depth > 0){
	--depth;
	acc += depth * 2 + 1;
      }
      break;
    case '_':
      acc += depth * 2;
      break;
    }
  }
  return acc;
}

int main(){
  cin >> str;

  int A = 0;
  vector<int> L;
  int st[40000], ed[40000], depth = 20000;
  fill(st, st+40000, -1);
  fill(ed, ed+40000, -1);
  for(int i=0;i<str.length();++i){
    switch(str[i]){
    case '\\':
      st[depth++] = i;
      break;
    case '/':{
      int s = st[--depth];
      if(s >= 0)
	ed[s] = i;
      break;
    }
    case '_':
      break;
    }
  }

  for(int i=0;i<str.length();++i){
    int nxt = ed[i];
    if(nxt < 0) continue;
    int res = calc(i,nxt);
    A += res;
    L.push_back(res);
    i = nxt;
  }

  cout << A / 2 << endl;
  cout << L.size();
  for(int i=0;i<L.size();++i)
    cout << " " << L[i] / 2;
  cout << endl;

  return 0;
}

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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define int long long int
#define ll long long
#define ld long double

bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}

ll lcm(ll x,ll y){
    return (x*y)/(__gcd(x,y));
}

ll nod(ll n){
    while(n%10==0){
        n/=10;
    }
    return n;
}


signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n,x,a;
        cin>>n>>x>>a;
        int p;
        ld max=10e5,ans=0;
        for(int i=0;i<n;i++){
            cin>>p;
            if(max>abs(a-x+p*0.006)){
                max=abs(a-x+p*0.006);
                ans=i+1;
            }
        }
        cout<<ans<<endl;
        
    }
    return 0;
}



Measured memory_bytes: 3812
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<a; i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
 
using namespace std;
 
const int mod=1e9+7;
const int maxn=100005;
 
int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	loop(s.size()){
		s[i]+=n;
		if(s[i]>90) s[i]-=26;
	}
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 256
s = int(input())
S = [str(s)]
i = 1
while True:
    if s % 2 == 0:
        i += 1
        s = s//2
        S.append(str(s))
        if S.count(str(s)) == 2:
            print(i)
            exit()
    else:
        i += 1
        s = int(3 * s + 1)
        S.append(str(s))
        if S.count(str(s)) == 2:
            print(i)
            exit()
pass


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

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

  vector<int64_t> a(n);
  map<int64_t, int64_t> bc;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (bc.count(a[i]) == 0) bc[a[i]] = 0;
    bc[a[i]]++;
  }

  map<int64_t, int64_t> sums;
  int64_t all_sum = 0;
  for (auto count : bc) {
    sums[count.first] = count.second * (count.second - 1) / 2;
    all_sum += sums[count.first];
  }

  for (int k = 0; k < n; k++) {
    int64_t ans = all_sum;
    ans -= sums[a[k]];

    ans += (bc[a[k]] - 1) * (bc[a[k]] - 2) / 2;
    cout << ans << endl;
  }
}


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

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.next();
    let xs = sc.vec::<f64>(n);
    let ys = sc.vec::<f64>(n);
    let ds: Vec<f64> = xs
        .iter()
        .zip(ys.iter())
        .map(|(x, y)| (y - x).abs())
        .collect();

    for i in 1..4 {
        let p = i as f64;
        let s: f64 = ds.iter().map(|d| d.powf(p)).sum();
        println!("{:.6}", s.powf(1. / p));
    }

    let s: f64 = ds.iter().cloned().fold(0., f64::max);
    println!("{:.6}", s);
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



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

int main()
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  string p = "";
	
  for(int i = 0; i < abs(tx - sx); i++)
    p += "R";
    
  for(int i = 0; i < abs(ty - sy); i++)
    p += "U";
  
  for(int i = 0; i < abs(tx - sx); i++)
    p += "L";
    
  for(int i = 0; i < abs(ty - sy); i++)
    p += "D";
    
   p += "D";
  
  for(int i = 0; i <= abs(tx - sx); i++)
    p += "R";
  for(int i = 0; i <= abs(ty - sy); i++)
    p += "U";
  
  p += "LU";

  for(int i = 0; i <= abs(tx - sx); i++)
    p += "L";
  for(int i = 0; i <= abs(ty - sy); i++)
    p += "D";
   
  p += "R";
  
  cout << p;
  return 0;
}
  
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int min = 99999;
  int res = 0;
  int x = 0;
  for(int i = 0; i < S.length() - 2; i++) {
    x = 100 * (S[i] - '0') + 10 * (S[i + 1] - '0') + (S[i + 2] - '0');
    if(min > abs(x - 753)) {
      min = abs(x - 753);
      res = x;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

#define M 1046527
#define L 13

char H[M][L];

int getChar(char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            return 0;
        }
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) {
            return 1;
        } else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

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

    char cmd[7], str[L];
    for (int i = 0; i < n; i++) {
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 15872
//
// Created by Myabu on 2020/01/26.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;
bool pair_compare_by_first(pair<string, int> left, pair<string, int> right) {
    if(left.first != right.first){
        return left.first < right.first;
    }else{
        return left.second > right.second;
    }
}

int main(void){
    int N;
    cin>>N;
    vector<pair<string, int> >X;

    map<string, int> dic;

    for (int i = 0; i < N; ++i) {
        string s;
        int p;
        cin>>s>>p;

        X.push_back(make_pair(s,p));
        dic[s+to_string(p)] = i+1;
    }

    sort(X.begin(), X.end(), pair_compare_by_first);


    for (int i = 0; i < N; ++i) {
        cout<<dic[X[i].first+to_string(X[i].second)]<<endl;
    }



    return 0;
}

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

int main()
{
    vector <int> a(3);
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(a[0]+a[1]==a[2])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

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

using namespace std;

int main() {
	int i;
	int N;

	cin >> N;

	int sum = 0;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		sum += L[i];
	}

	for (i = 0; i < N; i++) {
		if (sum <= 2 * L[i])
			break;
	}
	if (i == N) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ 
	char s;
	scanf("%c",&s);
	if(s=='a' || s=='e' || s=='i' || s=='o' || s=='u' ){
		printf("vowel\n");
	}
	else {
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        LCSAizu solver = new LCSAizu();
        solver.solve(1, in, out);
        out.close();
    }

    static class LCSAizu {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int tt = in.nextInt();

            while (tt-- != 0) {
                char[] a = in.next().toCharArray();
                char[] b = in.next().toCharArray();
                int n = a.length;
                int m = b.length;

                int[][] dp = new int[n + 1][m + 1];
                for (int i = 1; i < n + 1; i++) {
                    for (int j = 1; j < m + 1; j++) {
                        if (a[i - 1] == b[j - 1]) {
                            dp[i][j] = 1 + dp[i - 1][j - 1];
                        } else {
                            dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                        }
                    }
                }

                out.println(dp[n][m]);
            }
        }

    }
}




Measured memory_bytes: 64176
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> l(n);
  rep(i,n){
    cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int64_t t = 0;
  rep(i,k){
    t += l.at(i);
  }
  cout << t << endl;
    
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    m, d = map(int, input().split())
    ans = 0

    for mi in range(1, m + 1):
        for di in range(1, d + 1):
            d10 = di // 10
            d1 = di - d10 * 10

            if mi == d1 * d10 and d1 >= 2 and d10 >= 2:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP(i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);


int main() {
	vector<int>findx, findy, starx, stary;
	int n, m;
	while (cin >> n&&n) {
		findx.clear();
		findy.clear();
		starx.clear();
		stary.clear();
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			findx.emplace_back(a);
			findy.emplace_back(b);
		}
		cin >> m;
		for (int i = 0; i < m; i++) {
			int a, b;
			cin >> a >> b;
			starx.emplace_back(a);
			stary.emplace_back(b);
		}
		for (int i = 0; i < m; i++) {
			int sx = starx[i] - findx[0];
			int sy = stary[i] - findy[0];
			int count = 0;
			for (int j = 0; j < m; j++) {
				for (int k = 0; k < n; k++) {
					if (starx[j] - sx == findx[k] && stary[j] - sy == findy[k])count++;
				}
			}
			if (count == n) {
				cout << sx << " " << sy << endl;
				break;
			}
		}
		//system("pause");
	}
}

Measured memory_bytes: 3156
import sys
N = int(sys.stdin.readline())
a = []
b = []
c = []
for i in range(N):
    tmpa, tmpb, tmpc = map(int, sys.stdin.readline().split())
    a.append(tmpa)
    b.append(tmpb)
    c.append(tmpc)

dpa = [0 for i in range(N)]
dpb = [0 for i in range(N)]
dpc = [0 for i in range(N)]
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]
for i in range(1, N):
    dpa[i] = max(dpb[i-1]+a[i], dpc[i-1]+a[i])
    dpb[i] = max(dpa[i-1]+b[i], dpc[i-1]+b[i])
    dpc[i] = max(dpa[i-1]+c[i], dpb[i-1]+c[i])

print(max(dpa[N-1], dpb[N-1], dpc[N-1]))


Measured memory_bytes: 26836
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=1e9+7;

int p[MX+5], a[MX], b[MX];

vector<int>pm;

void sieve()
{
    for(int i=2; i*i<=1e6; i++)
    {
        if(!p[i])
        {
            for(int j=i+i; j<=1e6; j+=i) p[j]=1;
        }
    }
    for(int i=2; i<=1e6; i++) if(!p[i]) pm.push_back(i);
}

ll bigmod(ll a, ll b)
{
    if(!b) return 1;
    if(b&1) return (a*bigmod(a, b-1))%mod;
    else
    {
        ll r=bigmod(a, b/2); return (r*r)%mod;
    }
}
map<ll, ll>mp;
map<ll, ll>::iterator it;

void fact(int x)
{
    for(int i=0; pm[i]*pm[i]<=x; i++)
    {
        if(x%pm[i]==0)
        {
            int cn=0;
            while(x%pm[i]==0)
            {
                x/=pm[i];
                cn++;
            }
            if(mp[pm[i]]<cn) mp[pm[i]]=cn;
        }
    }
    if(x>1)
    {
        if(!mp[x]) mp[x]=1;
    }
}

ll call(ll lcm, ll x)
{
    for(int i=0; pm[i]*pm[i]<=x; i++)
    {
        if(x%pm[i]==0)
        {
            int cn=0;
            while(x%pm[i]==0)
            {
                x/=pm[i]; cn++;
            }
            lcm=(lcm*bigmod(bigmod(pm[i], cn), mod-2))%mod;
        }
    }
    if(x>1)
    {
        lcm=(lcm*bigmod(x, mod-2))%mod;
    }
    return lcm;
}

int main()
{
    FasterIO;

    sieve();

    int n;

    cin>>n;

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

    ll lcm=1;
    for(it=mp.begin(); it!=mp.end(); it++)
    {
        lcm=(lcm*bigmod(it->ff, it->ss))%mod;
    }

    ll sm=0;
    for(int i=1; i<=n; i++)
    {
        sm=(sm+call(lcm, a[i]))%mod;
    }
    cout<<sm<<endl;
    return 0;
}


Measured memory_bytes: 8824