akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Card[] a = new Card[n];
		Card[] b = new Card[n];
		for (int i = 0; i < n; i++) {
			String card = sc.next();
			char suit = card.charAt(0);
			int value = Character.getNumericValue(card.charAt(1));
			a[i] = new Card(suit, value);
			b[i] = new Card(suit, value);

		}

		Main main = new Main();
		main.bubbleSort(a, n);
		main.selectionSort(b, n);
		main.printCard(a, n);
		System.out.println("Stable");
		main.printCard(b, n);
		String ans = main.isStable(a, b, n) ? "Stable" : "Not stable";
		System.out.println(ans);

	}

	private boolean isStable(Card[] a, Card[] b, int n) {
		for (int i = 0; i < n; i++) {
			if (a[i].suit != b[i].suit) {
				return false;
			}
		}
		return true;
	}

	private void bubbleSort(Card[] a, int n) {
		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j >= i + 1; j--) {
				if (a[j].value < a[j - 1].value) {
					Card tmp = a[j];
					a[j] = a[j - 1];
					a[j - 1] = tmp;
				}
			}
		}

	}

	private void selectionSort(Card[] a, int n) {
		for (int i = 0; i < n - 1; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (a[j].value < a[minj].value) {
					minj = j;
				}
			}
			if (minj != i) {
				Card tmp = a[i];
				a[i] = a[minj];
				a[minj] = tmp;
			}
		}

	}

	private void printCard(Card[] a, int n) {
		for (int i = 0; i < n; i++) {
			String card = "" + a[i].suit + a[i].value;
			if (i != n - 1) {
				System.out.print(card + " ");
			} else {
				System.out.println(card);
			}
		}
	}

}

class Card {
	char suit;
	int value;

	public Card(char suit, int value) {
		this.suit = suit;
		this.value = value;
	}

}


Measured memory_bytes: 26208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n)
	ru := make([]int, n+1)
	m := map[int]int{}

	ru[0] = 0
	m[0]++
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		ru[i+1] = a[i] + ru[i]
		m[ru[i+1]]++
	}
	cnt := 0
	for _, v := range m {
		cnt += (v * (v - 1)) / 2
	}

	fmt.Println(cnt)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 16972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll n;
  cin >> n;
  vector<vector<ll>> vec(10,vector<ll>(10,0));
  ll t2;
  rep(i,n){
    ll t1 = i + 1;
    t2 = t1 % 10;
    ll t3 = 0;
    while(t1 != 0){
      t3 = t1;
      t1 /= 10;
    }
    vec[t2][t3]++;
  }
  ll ans = 0;
  rep(i,10){
    rep(j,10){
      ans += vec[i][j] * vec[j][i];
      //cout << vec[i][j] << " ";
    }
    //cout << endl;
  }
  cout << ans << endl;
}

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

using namespace std;
int n;

int getQuery(int bg, int en, int q){
    if(bg <= q && en >= q){
        int tmp = (bg + 2*n - 2) % (2*n);
        bg = (en + 2) % (2*n);
        en = tmp;
    }
    cout<<"? ";
    cout<<q+1<<" ";
    int i = bg;
    while(true){
        if(i == (en + 1)%(2*n)) break;
        cout<<i+1<<" ";
        i = (i + 1) % (2*n);
    }cout<<endl;
    string inp;
    cin>>inp;
    if(inp == "Red") return 1;
    return 0;
}

int getRow(int ind){
    int i = ind;
    cout<<"? ";
    while(i != (ind+n)%(2*n)){
        cout<<i+1<<" ";
        i = (i + 1) % (2*n);
    }
    cout<<endl;
    string inp; 
    cin >> inp;
    if(inp == "Red") return 1;
    return 0;
}

int main(){
    cin>>n;
    int initCol = getRow(0);
    int mxsofar = 0;
    int l=1, r=n-1;
    while(l <= r){
        int mid = (r+l)/2;
        //cerr<<l<<r<<mid<<endl;
        int chk = getRow(mid);
        if(chk != initCol){
            r = mid - 1;
        }
        else{
            mxsofar = max(mxsofar, mid);
            //cerr<<mxsofar<<"det"<<endl;
            l = mid + 1;
        }
    }
    mxsofar = (mxsofar + 1) % (2*n);
    int end = (mxsofar + n - 2) % (2*n);
    //cerr<<mxsofar<<end<<endl;
    string ans;
    for(int i=0; i<2*n; i++){
        int an = getQuery(mxsofar, end, i);
        if(an) ans += "R";
        else ans += "B";
    }
    cout<<"! ";
    cout<<ans<<endl;
}


Measured memory_bytes: 724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >>k;
    string str;
    cin>>str;
    int n=str.length();
    if(n<=k)
    {
        cout<<str<<endl;
    }
    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<str[i];
        }
        cout<<"..."<<endl;
    }
    



    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m = 0;
  int k = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'C' || s[i] == 'A' || s[i] == 'T' || s[i] == 'G') k++;
    else k = 0;
    m = max(k, m);
  }
  cout << m << endl;
}

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


int main()
{
  //入力
  int a,b,c;
  int ans;
  cin>>a>>b>>c;

  if(a>b) swap(a,b);
  if(b>c) swap(b,c);
  if(a>b) swap(a,b);

  if((c-b)%2==0 && (c-a)%2==0) ans=(c-a)/2+(c-b)/2;
  else if((c-b)%2==1 && (c-a)%2==1) ans=(b-a)/2+(c-b);
  else if((c-b)%2==1 && (c-a)%2==0) ans=(3*(c+1)-(a+b+c))/2;
  else ans=(3*(c+1)-(a+b+c))/2;

  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
typedef unsigned long long ull;
using namespace std;
int deg[100005];
vector <int> vec[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	int n;
	cin>>n;
	int x,y;
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);
		vec[y].push_back(x);
		deg[x]++;
		deg[y]++; 
	}
	int mx=0;
	for(int i=0;i<n;i++)
	{
		mx=max(mx,deg[i]);
	}
	if(mx<=2)
	{
		cout<<1<<endl;
		return 0;
	}
//	for(int i=0;i<n;i++)
//	{
//		if(deg[i]==2) deg[i]=1;
//	}
	queue <int> que;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==1) que.push(i);
	}
	while(que.size())
	{
		int v=que.front();
		que.pop();
		int to=0;
		for(int i=0;i<vec[v].size();i++)
		{
			to=vec[v][i];
			if(deg[to]!=1) break;
		}
		if(deg[to]==2)
		{
			deg[to]=1;
			que.push(to);
		}
	}
	int res=0;
	for(int i=0;i<n;i++)
	{
		if(deg[i]==1) continue;
		int nm=0;
		for(int j=0;j<vec[i].size();j++)
		{
			int to=vec[i][j];
			if(deg[to]==1) nm++;
		}
		res+=max(0,nm-1);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  int sum = 1;
  rep(i,N)
  {
    sum *= 3;
  }
  int p = 1;
  rep(i,N)
  {
    if(A[i]%2==0)
    {
      p *= 2;
    }
    else
    {
      p *= 1;
    }
    
  }
  cout << sum - p << endl;
  return 0;
}


Measured memory_bytes: 3572
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
// #define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    int n;
    while(scanf("%d", &n) && n != 0){
        int days[31][n];
        fill(days[0], days[31], 0);
        rep(n){
            int m;
            scanf("%d", &m);
            repp(j, m){
                int day;
                scanf("%d", &day);
                days[day][i] = 1;
            }
        }

        int ans = -1;
        bitset<50> people[n];
        rep(n){
            bitset<50> bs(0uL);
            bs.set(i);
            people[i] = bs;
        }
        reppp(i, 1, 31){
            bitset<50> bs(0uL);
            repp(p, n){
                if(days[i][p]) bs |= people[p];
            }
            if(bs.count() == n){
                ans = i;
                break;
            }
            repp(p, n){
                if(days[i][p]) people[p] = bs;
            }
        }
        printf("%d\n", ans);
        
    }
    return 0;
}



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

int a[100010];
void print(int i, int n)
{
	for(int j = 1; j < i; j++) printf("%d ", a[j]);
	printf("[%d]", a[i]);
	for(int j = i + 1; j <= n; j++) printf(" %d", a[j]);
	printf("\n");
}
int partition(int p, int n){
	int x = a[n], i = p - 1;
	for(int j = 1; j < n; j++){
		if(a[j] <= x){
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i+1], a[n]);
	return i + 1;
}
int main()
{
	int n, t;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	t = partition(1, n);
	print(t, n);
	return 0;
} 


Measured memory_bytes: 3568
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N, W = MI()
    mylist = [LI() for i in range(N)]
    d = [[0 for i in range(W+1)] for j in range(1+N)]
    for i in range(N):
        v, w = mylist[i]
        for j in range(W+1):
            if w > j:
                d[i+1][j] = max(d[i][j], d[i+1][j])
            else:
                d[i+1][j] = max(d[i][j], d[i+1][j], d[i][j-w]+v)
    print(d[N][W])
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 26616
import java.util.*;

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

        int num500 = X / 500;
        int num5 = (X - 500*num500) / 5;

        System.out.println( num500 * 1000 + num5 * 5);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define cerr cout
#define F first
#define S second
#define fori(i,a,b) for (i = a; i < b; ++i)
#define ford(i,a,b) for(i = a; i>=b;--i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) int(x.size())
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fill(a, x) memset(a, x, sizeof(a))
#define INF 1000000000
#define MOD 1000000007
#define SMOD 998244353
#define endl "\n"
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
const ll N = 100043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n - k], fact[k]));
}

void solve()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll a, b, n=x/d, ans = 1e17;
    if(n>=k)
    {
        ans = x-d*k;
        cout << abs(ans) << endl;
        return;
    }
    else
    {
        ll xn1 = x-d*n;
        ll xn2 = xn1-d;
        xn2 = abs(xn2);
        if(xn1>xn2)
        {
            if(!((k-n-1)%2))
                ans = xn2;
            else
                ans = min({ans, xn1, abs(xn2+d)});
        }
        else
        {
            if(!((k-n)%2))
                ans = xn1;
            else
                ans = min({ans, xn2, xn1+d});
        }
    }
    cout << abs(ans) << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin >> t;
    for(int i=1; i<=t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))


def dfs(i, j, c):
#    print('dfs:')
#    pri(c)
    if i<0 or j<0 or i>=len(c) or j>=len(c[0]) or c[i][j]==0:
        return
    c[i][j] = 0

    for di in [-1, 0, 1]:
        for dj in [-1, 0, 1]:
            dfs(i+di, j+dj, c)
    
    return

def solve(w, h, c):
    cnt = 0
    for i in range(h):
        for j in range(w):
            if c[i][j] == 1:
                cnt += 1
                dfs(i, j, c)
    print(cnt)
    return


while True:
    w, h = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(h)]
    if w == h == 0:
        break
    solve(w, h, c)




Measured memory_bytes: 8468
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;

    return 0;
}


Measured memory_bytes: 256
use std::collections::HashSet;
use std::io::Read;

fn main() {
    let mut line = String::new();
    std::io::stdin().read_to_string(&mut line);
    let mut tok = line.split_whitespace();
    let mut n: usize = tok.next().unwrap().parse().unwrap();
    let mut r = HashSet::new();
    for _ in 0..n {
        r.insert(tok.next().unwrap());
    }
    println!("{}", r.len());
}


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

using namespace std;

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

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

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

int main() {
    string s;
    string ans;

    cin>>s;

    int s1 = stoi(s.substr(0,2));
    int s2 = stoi(s.substr(2,2));

    if (s1 <= 12 && s1 >= 1)
    {
        if (s2 <= 12 && s2 >= 1)
            ans = "AMBIGUOUS";
        else
            ans = "MMYY";
    }
    else
    {
        if (s2 <= 12 && s2 >= 1)
            ans = "YYMM";
        else
            ans = "NA";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int N, arr[100];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) {
        cin >> arr[j];
    }

    int memo[10005];
    fill(memo, memo+10001, 0); memo[0] = 1;

    for (int j = 0; j < N; ++j) {
        for (int k = 10000; k >= arr[j]; --k) {
            if (memo[k-arr[j]] == 1) {
                memo[k] = 1;
            }
        }
    }
    bool ok = false;
    for (int j = 10000; j >= 0; --j) {
        if (j > 0 && j % 10 == 0) continue;
        if (memo[j] == 1) {
            cout << j << endl;
            ok = true;
            break;
        }
    }
    return 0;
}



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


using namespace std;
using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vvll s(8);

		for(int i=0;i<n;i++)
		{
			ll x, y, z;
			scanf("%lld%lld%lld", &x, &y, &z);
			s[0].push_back(+x+y+z);
			s[1].push_back(+x+y-z);
			s[2].push_back(+x-y+z);
			s[3].push_back(+x-y-z);
			s[4].push_back(-x+y+z);
			s[5].push_back(-x+y-z);
			s[6].push_back(-x-y+z);
			s[7].push_back(-x-y-z);
		}

		ll ans=0;
		for(auto&ms:s)
		{
			ll t=0;
			sort(ms.rbegin(), ms.rend());
			for(int i=0;i<m;i++)
			{
				t+=ms[i];
			}
			if(ans<t) ans=t;
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 256
import copy

def DFS(start, G):
    stack = []
    check = []
    check.append(start)
    stack.append(start)
    while stack:
        node = stack.pop()
        for child in G[node]:    
            if child not in check:
                check.append(child)
                stack.append(child)
    return set(check)

N, M = (int(i) for i in input().split())
G = []
S = []
for i in range(N + 1):
    G.append([])

for i in range(M):
    a,b = (int(j) for j in input().split())
    G[a].append(b)
    G[b].append(a)
    S.append( (a,b) )

res = 0
for side in S:
    a, b = side 
    dashG = copy.deepcopy(G)
    dashG[a].remove(b)
    dashG[b].remove(a)
    if DFS(a, dashG) != DFS(b, dashG):
        res += 1

print(res)

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	string s;
	while(getline(cin, s)){
		for(int j=0; j < 26; j++){
			for(int i=0; i< s.size(); i++){
				if('a' <= s[i] && s[i] < 'z')s[i]++;
				else if(s[i] == 'z') s[i] = 'a';
			}
			bool possible = false;
			if(s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos){
				cout << s << endl;
			}
		}
	}
}

Measured memory_bytes: 1176
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ae = [a, b, c, d, e]

time = 0

for i in ae:
    if i % 10 == 0:
        time += i

ae = [i for i in ae if i % 10 != 0]

if ae:
    idx = 0
    for i in ae:
        time += i
        time += 10 - (i % 10)

    one = []
    for i in ae:
        i = [j for j in str(i)]
        one.append(int(i[-1]))

    print(time-10+min(one))

else:
    print(time)

Measured memory_bytes: 3064
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);

    auto S = new long[](M);
    auto C = new long[](M);
    foreach (i; 0 .. M)
    {
        scan(S[i], C[i]);
        S[i]--;
    }

    x: foreach (x; 0 .. 1000)
    {
        auto s = x.to!string;
        if (s.length != N)
            continue x;
        foreach (i; 0 .. M)
        {
            if (s[S[i]] != C[i] + '0')
            {
                continue x;
            }
        }
        writeln(x);
        return;
    }
    writeln(-1);
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define out(s) cout << (s) << endl
#define ll long long

void solve(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n){cin>>a[i];}
  ll sell = a[n-1];
  ll price = -1000000000;
  for(int i=n-2;i>=0;i--){
    ll buy = a[i];
    price = max(sell-buy, price);
    if(buy>sell){
      sell = buy;
    }
  }
  out(price);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = INF;
    for (int y : a) {
        vector<int> v;
        vector<int> now;
        rep(i, n) {
            if (a[i] >= y) {
                now.push_back(a[i]);
            } else {
                sort(all(now));
                rep(j, sz(now) - k + 1) v.push_back(now[j]);
                now.clear();
            }
        }
        sort(all(now));
        rep(j, sz(now) - k + 1) v.push_back(now[j]);
        now.clear();
        if (sz(v) < q) continue;
        sort(all(v));
        int x = v[q - 1];
        chmin(ans, x - y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
treats = [[False for i in range(110)] for j in range(110)]

res = 0

for i in range(1,K+1,1):
  d = int(input())
  A = [i for i in map(int,input().split())]
  for a in A:
    treats[i][a] = True
    
for j in range(1,N+1,1):
  flag = 1
  for i in range(1,K+1,1):
    if treats[i][j] == True:
      flag = 0
      
  if flag: res += 1
    
print(res)

Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	ll a[n + 1];
	a[0] = 0;
	rep(i, n) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	rep(i, n + 1) a[i] = (a[i] - i) % k;
	map<int, int> mp;
	int l = 0, r = 0;
	mp[0]++;
	ll ans = 0;
	while (r != n + 1) {
		if (r - l < k - 1) {
			if (mp[a[++r]]) ans += mp[a[r]];
			mp[a[r]]++;
		} else {
			mp[a[l++]]--;
			if (mp[a[++r]]) ans += mp[a[r]];
			mp[a[r]]++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll  = long long;
using ii  = pair<int, int>;
using vi  = vector<int>;
using vd  = vector<double>;
using vb  = vector<bool>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	ll H, W;
	cin >> H >> W;

	ll ans = H * W;
	ll s[3];

	for (int i = 0; i < 2; ++i) {
		for (int h = 1; h < H; ++h) {
			s[0] = h * W;
			s[1] = (H - h) * (W / 2);
			s[2] = H * W - (s[0] + s[1]);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);

			s[0] = h * W;
			s[1] = ((H - h) / 2) * W;
			s[2] = H * W - (s[0] + s[1]);
			sort(s, s + 3);
			ans = min(ans, s[2] - s[0]);
		}
		swap(H, W);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    int m,d,ans=0;
    cin>>m>>d;
    for(int i=1;i<=d;++i)
		if((i%10)*((i/10)%10)<=m&&(i%10>=2)&&((i/10)%10)>=2)++ans;
	cout<<ans<<endl;
	return 0;
}

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

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

  map<string, int> v;
  rep(i,n) {
    string t;
    cin >> t;
    v[t]++;
  }

  cin >> m;
  rep(i,m) {
    string t;
    cin >> t;
    v[t]--;
  }

  int ma = 0;
  for(auto i=v.begin(); i!=v.end(); i++){
    ma = max(ma,i->second);
  }
  ma = max(0,ma);

  cout << ma << endl;
}


Measured memory_bytes: 256
module A
  sub main()
    dim RD as string
    dim SD() as string
    dim CD as long
    dim SQ as double
    dim ans as string
    
    RD = console.readline()
    SD=split(RD," ")
    CD=clng(SD(0) & SD(1))
    SQ=System.Math.Sqrt(CD)
    SQ=int(SQ)
    
    if CD= (SQ*SQ)  then
      ans = "Yes"
    else
      ans = "No"
    end if
   
    console.writeline(ans)
    
  end sub
end module

Measured memory_bytes: 13536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static  List<List<Int64>>lst=new List<List<Int64>>();
        static void Main(string[] args)
        {
            //var length = c2i(RL());
            //var rl = spr(RL()).Select(x=>c2i(x)).ToList();
            var rl = RL();
            rl=rl.Replace('?', 'D');
            Console.WriteLine(rl);

        
        }
        
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 26992
T = []
W = input()

while True:
    t = input().split()
    if t[0] == "END_OF_TEXT":
        break
    for i in range(len(t)):
        T.append(t[i].lower())

k = 0
for i in range(len(T)):
    if T[i] == W:
        k += 1

print(k)



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

using namespace std;

typedef long long ll;

int flag[100005];

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> x(M), y(M);
    for(int i = 0; i < M; ++i){
        cin >> x[i] >> y[i];
        
        x[i]--;
        y[i]--;
    }
    
    vector<int> cnt(N, 1);
    flag[0] = true;
    int res = 0;
    for(int i = 0; i < M; ++i){
        cnt[x[i]]--;
        cnt[y[i]]++;
        if(flag[x[i]])      flag[y[i]] = true;
        
        if(cnt[x[i]] == 0){
            flag[x[i]] = false;
        }
    }
    
    for(int i = 0; i < N; ++i){
        if(flag[i])     res++;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1792
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

int dp[100005];
int ssum[100005];
int psum[1000005];
 
signed main()
{
    tezz
    
    int n, k;
    cin>>n>>k;

    vi v(n);
    for(int &x:v) cin>>x;
    	sort(all(v));

    for(int i=n-1;i>=0;i--) ssum[i] = ssum[i+1] + v[i];
    for(int i=0;i<n;i++) psum[i+1] = psum[i] + v[i];

    int hi = 200005, lo = 0, ans = -1;

	while(lo <= hi){ // binary search over the sum of pairs
		int mid = lo + (hi - lo)/2;
		// cout<<mid<<" _____ "<<endl;

		int count = 0;
		for(int i=0;i<n;i++){
			int curr = mid - v[i];
			if(curr > v[n-1]) continue;
			// if(curr < 0) {count += n; continue;}

			auto it = lower_bound(all(v), curr);

			// cout<<v[i]<<' '<<curr<<" ===> "<<endl;

			if(it != v.end()){
				// cout<<"lbound = "<<*(it)<<endl;

				// cout<<" count = ";
				if(it == v.begin()) count += n;//, cout<<n<<endl;
				else{
					// if(curr == *(it)) it++;

					// cout<<(v.end() - it)<<endl;

					count += (v.end() - it);
				}
			}
		}
		// cout<<" --> "<<count<<endl;

		if(count >= k){
			lo = mid + 1;
			ans = max(ans, mid);
		}
		else hi = mid - 1;
	}

	// cout<<ans<<' '<<lo<<endl;
	lo = ans;
	ans = 0;

	// for(int x:v) cout<<x<<' ';
	// 	cout<<endl;
	// for(int i=0;i<=n;i++) cout<<ssum[i]<<' ';
	// 	cout<<endl<<endl;

	for(int i=0;i<n;i++){
		int curr = lo + 1 - v[i];
		// if(curr < 0) continue;

		auto it = lower_bound(all(v), curr);
		int pos = it - v.begin();

		// cout<<curr<<" --> "<<pos<<endl;
		// cout<<" = "<<(n-pos)*v[i] + ssum[pos]<<endl;

		ans += (n-pos)*v[i] + ssum[pos];
		k-=(n-pos);
	}
	ans += k*lo;

	cout<<ans;
} 

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

const int MOD=1000000007;
vector<long long> power3(100000);

long long res = 1;
int counter = 0;

void powerInit(void){
    power3[0] = 1;
    for(int i=1; i<100000; i++){
        power3[i] = power3[i-1]*3%MOD;
    }
}

int main(void){
    string strL;
    cin >> strL;

    powerInit();

    for_each(strL.rbegin(), strL.rend(), [](const char chrL){
        if(chrL == '1'){
            res = (power3[counter] + 2*res)%MOD;
        }
        counter++;
    });

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1280
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1
  else:A[k]=R[j];j+=1
  c+=1
def s(A,l,r):
 if l+1<r:
  m=(l+r)//2
  s(A,l,m);s(A,m,r)
  g(A,l,m,r)
c=0
n=int(input())
A=list(map(int,input().split()))
s(A,0,n)
print(*A)
print(c)


Measured memory_bytes: 63708
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(a; usize);

    println!("{}", a + a*a + a*a*a);
}


Measured memory_bytes: 2136
#include <iostream>

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

using namespace std;

int main(void)
{
	int N;
	long M;
	while(cin >> N >> M, N > 0){
		long D[MAX_P + 1];
		long result = 0;
		//配列Dを初期化
		rep(i, MAX_P + 1){
			D[i] = 0;
		}
		//配列Dを構成
		rep(i, N){
			int d, p;
			cin >> d >> p;
			D[p] += d;
		}
		rep(i, MAX_P + 1){
			if (M >= D[MAX_P - i]){
				M -= D[MAX_P - i];
			}else if(M > 0){
				result += (D[MAX_P - i]-M) * (MAX_P - i);
				M = 0;
			}else{
				result += D[MAX_P - i] * (MAX_P - i);
			}
		}
		cout << result << endl;
	}
	return 0;
}


Measured memory_bytes: 3056
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
using namespace std;

vector<int> split(string s,char c){
	vector<int> v;string tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]==c){
			v.push_back(stoi(tmp));
			tmp ="";
		}
		else tmp += s[i];
	}
	if(tmp!="")v.push_back(stoi(tmp));
	return v;
}

int sum(string s){
	int ret=0;
	for(int i=0;i<s.size();i++){
		ret += stoi(s.substr(i,1));
	}
	return ret;
}

int main(void){
	for(int i=0;;i++){
		string x;
		cin >> x;
		if(x=="0")return 0;
		cout << sum(x) << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
num = (0..9).to_a
while true do
  l = gets.chomp
  if l == "0 0" then
    exit
  end

  n, s = l.split(" ").map{|x| x.to_i}

  count = 0
  num.combination(n).each do |arr|
    if arr.inject(:+) == s then
      count += 1
    end
  end

  puts count
end

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

using namespace std;
const int MOD = 1000000007;
typedef long long ll;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
    int X, Y;
    cin >> X >> Y;

    ll x, a = 1, b = 1;
    ll ans = 1;

    bool flag = true;
    for(ll i=0;i<=X/2;++i){
        x = X - 2*i;
        if(2*x + i == Y){
            flag = false;
            for(ll j=i;j>0;j--){
                a = (a*j) % MOD;
            }
            for(ll j=x;j>0;j--){
                b = (b*j) % MOD;
            }
            for(ll j=2;j<=(i+x);++j){
                ans = (ans*j)%MOD;
            }
            ans = (ans * modinv(a, MOD)) % MOD;
            ans = (ans * modinv(b, MOD)) % MOD;
            break;
        }
    }
    if(flag) ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        final String SPACE = " ";
        final String EMPTY = "";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        String str = br.readLine();
        int a;
        int b;
        String[] temp = new String[2];
        for (int i = 0; i < 200; i++) {
            // 最終行であれば抜ける
            if (EMPTY.equals(str) || str == null) {
                break;
            }

            temp = str.split(SPACE);
            a = Integer.parseInt(temp[0]);
            b = Integer.parseInt(temp[1]);
            sb.append(String.valueOf(a + b).length() + "\r\n");

            str = br.readLine();
        }

        System.out.print(sb);
    }
}

Measured memory_bytes: 17004
#include<stdio.h>
int max(int a,int b)
{
    if(a>=b)
    {
        return a;
    }
    if(b>a)
    {
        return b;
    }
}
int main()
{
int a,b,c,d,a1,a2;
scanf("%d %d %d %d",&a,&b,&c,&d);
a1=a*b;
a2=c*d;
printf("%d",max(a1,a2));
}

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

int main(){
    char word;
    cin >> word;
    char alph[26];
    alph[0]='a';
    alph[1]='b';
    alph[2]='c';
    alph[3]='d';
    alph[4]='e';
    alph[5]='f';
    alph[6]='g';
    alph[7]='h';
    alph[8]='i';
    alph[9]='j';
    alph[10]='k';
    alph[11]='l';
    alph[12]='m';
    alph[13]='n';
    alph[14]='o';
    alph[15]='p';
    alph[16]='q';
    alph[17]='r';
    alph[18]='s';
    alph[19]='t';
    alph[20]='u';
    alph[21]='v';
    alph[22]='w';
    alph[23]='x';
    alph[24]='y';
    alph[25]='z';

    for (int i = 0; i < 25; i++){
        if(alph[i]==word){
            cout << alph[i+1];
        }
    }
    


    return 0;
}


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

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




Measured memory_bytes: 256
# N問出題, M回提出
N, M = map(int, input().split())

p_S_list = []

WA = 'WA'
AC = 'AC'

question_list = [False] * N
WA_count_list = [0] * N

count_AC = 0
count_WA = 0

for i in range(M):
    p, S = input().split()
    int_p = int(p)
    
    if S == WA and question_list[int_p - 1] == False:
        WA_count_list[int_p - 1] += 1

    if S == AC and question_list[int_p - 1] == False:
        count_AC += 1
        count_WA += WA_count_list[int_p - 1]
        question_list[int_p - 1] = True

print(str(count_AC) + ' ' + str(count_WA))








'''
first_AC_index_list = []
AC_set = set([])

for j in range(M):
    p, S = input().split()
    int_p = int(p)
    p_S_list.append([int_p, S])

    if S == AC and (int_p not in AC_set):
        first_AC_index_list.append([j, int_p])
        AC_set.add(int_p)

count_AC = len(first_AC_index_list)
count_WA = 0
# for i in range(1, N + 1):
#     # i問目の問題について考える
#     if [i, AC] in p_S_list:
#         count_AC += 1

#         first_AC_index = p_S_list.index([i, AC])

#         count_WA += p_S_list[:first_AC_index].count([i, WA])

for i_list in first_AC_index_list:
    count_WA += p_S_list[:i_list[0]].count([i_list[1], WA])

ans = str(count_AC) + ' ' + str(count_WA)

print(ans)

'''




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


int main() {
  int n;
  cin >> n;
  vector<int> RC(n+1);
  for(int i = 0;i < n;i++){
      cin >> RC.at(i) >> RC.at(i+1);
  }

  vector<vector<int>> cost(n+1,vector<int>(n+1));
  int min_cost;
  for (int l = 2;l <= n;l++){
      for (int i = 1;i <= n-l+1;i++){
          int j = i+l-1;
          for (int k = i;k < j;k++){
              if (k == i){
                  min_cost = cost.at(i).at(k)+cost.at(k+1).at(j)+RC.at(i-1)*RC.at(k)*RC.at(j);
              }else{
                  min_cost = min(min_cost,cost.at(i).at(k)+cost.at(k+1).at(j)+RC.at(i-1)*RC.at(k)*RC.at(j));
              }
          }
          cost.at(i).at(j) = min_cost;
      }
  }

  cout << cost.at(1).at(n) << endl;
  
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define ll long long
const ll base = 31;
const ll MOD = 1e9+9;
const ll  maxN = 1e6+9;

using namespace std ;
int main()
{ unsigned long long int  a , n , b , res=0;
  cin >> n >> a >>b;
  if (a ==0) {
    cout<<0 ;
    return 0 ;
  }
  if (n < a) {
    cout<< n;
    return 0 ;
  }
  ll temp = a+b;
   res=n/temp * a;
   temp = n % temp ;
   if ( temp < a) res+=temp ;
   else if ( temp > a) res+=a;
   cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define MAX_N 1000
#define MAX_M 1000

int now = 0, e[MAX_N], r[MAX_M], i, n, m;

int main(){
  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) break;
    now = 0;
    for(i = 0; i < n; i++) scanf("%d", &e[i]);
    for(i = 0; i < m; i++) scanf("%d", &r[i]);
    for(i = 0; i < m; i++){
      now += r[i];
      now += e[now];
      if(now >= n - 1) break;
    }
    printf("%d\n", i + 1);
  }
  return 0;
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll x;
    cin >> x;
    ll sum =0 ;
    sum += (x/500) * 1000;
    x %= 500;
    sum += (x/5) * 5;
    cout << sum << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<int, pii>
#define puu pair<ULL, ULL>
#define pdd pair<long double, long double>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

const int N = 2e5 + 5;
pii a[N];
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d %d", &a[i].se, &a[i].fi);
    int now = 0;
    sort(a+1, a+1+n);
    for (int i = 1; i <= n; ++i) {
        if(now+a[i].se > a[i].fi) return 0*puts("No\n");
        now += a[i].se;
    }
    printf("Yes\n");
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S;
	int K;
	cin >> S >> K;
	K = min(K, 300);
	
	int cnt = 0;
	vint A;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') {
			cnt++;
		} else {
			A.push_back(cnt);
			cnt = 0;
		}
	}
	A.push_back(cnt);
	
	reverse(begin(A), end(A));
	//cout << A << endl;

	int N = A.size();
	auto dp = makeVector(N+1, 305, K+1, 2, 0ll);
	
	dp[0][0][K][0] = 1;

	for (int i = 0; i < N; i++) {
		for (int j = 300; j >= 0; j--) {
			for (int k = K; k >= 0; k--) {
				if (j > 0) {
					(dp[i][j-1][k][1] += dp[i][j][k][0] + dp[i][j][k][1]) %= mod2;
				}
				for (int l = 0; l <= A[i]; l++) {
					if (j+l <= 300 && k-l >= 0) (dp[i+1][j+l][k-l][0] += dp[i][j][k][0]) %= mod2;
				}
				(dp[i+1][j][k][0] += dp[i][j][k][1]) %= mod2;
			}
		}
	}

	ll sum = 0;
	for (int i = 0; i <= K; i++) {
		(sum += dp[N][0][i][0] + dp[N][0][i][1]) %= mod2;
	}
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 773052