akhauriyash/Code-Regression huggingface dataset:
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  def get[T1, T2, T3, T4](
                           implicit in: BufferedReader,
                           converter1: String => T1,
                           converter2: String => T2,
                           converter3: String => T3,
                           converter4: String => T4
                         ): (T1, T2, T3, T4) = {
    getArray[String] match {
      case Array(v1, v2, v3, v4) => (converter1(v1), converter2(v2), converter3(v3), converter4(v4))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def primes(n: Long): ArrayBuffer[Long] = {
    val buf = ArrayBuffer.empty[Long]
    val s = Math.sqrt(n).toInt

    var v = n
    for (i <- 2 to s) {
      if (v == 1 || v == 0) {
        return buf
      } else {
        while (v % i == 0) {
          buf.append(i)
          v /= i
        }
      }
    }
    if (v > s) {
      buf.append(v)
    }
    buf
  }

  @tailrec
  def gcd(a: Long, b: Long): Long = {
    val reminder = a % b
    if (reminder == 0) {
      b
    } else {
      gcd(b, reminder)
    }
  }

  def lcm(a: Long, b: Long): Long = {
    a / gcd(a, b) * b
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (a, b, c, d) = get[Long, Long, Int, Int]

    @inline
    def dividable(k: Long): Long = {
      b / k - (a - 1) / k
    }

    out.println(
      dividable(1) - dividable(c) - dividable(d) + dividable(lcm(c, d))
    )

    out.flush()
  }
}

Measured memory_bytes: 27196
#include<stdio.h>
int main(void){
	int a[9] = {0};
	int n;
	int b = 0;
	for(int i=0; i<9; i++){
		scanf("%d", &a[i]);
	}
	scanf("%d", &n);
	for(int j=0; j<n; j++){
		scanf("%d", &b);
		for(int k=0; k<9; k++){
			if(a[k] == b){
				a[k] = 0;
			}
		}
	}
	if(a[0]+a[1]+a[2] == 0 || a[3]+a[4]+a[5] == 0 || a[6]+a[7]+a[8] == 0){
		printf("Yes\n");
	}
	else if(a[0]+a[4]+a[8] == 0 || a[2]+a[4]+a[6] == 0){
		printf("Yes\n");
	}
	else if(a[0]+a[3]+a[6] == 0 || a[1]+a[4]+a[7] == 0 || a[2]+a[5]+a[8] == 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n, k, q int
	fmt.Scanf("%d %d %d", &n, &k, &q)

	as := make([]int, q)

	for i := 0; i < q; i++ {
		fmt.Scanf("%d", &as[i])
	}

	for _, v := range *check(n, k, q ,&as) {
		fmt.Println(v)
	}
}

func check(n int, k int, q int, as *[]int) *[]string {
	p := make([]int, n)
	results := make([]string, n)
	point := k - q
	
	for i := 0; i < n; i++ {
		p[i] = point
	}
	for _, a := range *as {
		p[a-1] += 1
	}
	for k, v := range p {
		if v <= 0 {
			results[k] = "No"
		} else {
			results[k] = "Yes"
		}
	}
	return &results
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;

ll solver(vector<vector<ll>> &s, ll H, ll W, ll ch, ll cw, ll dh, ll dw)
{
    ll cost[H][W];
    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            cost[i][j] = -1;
        }
    }
    queue<pair<ll, ll>> p, q;
    q.push(make_pair(ch, cw));
    cost[ch][cw] = 0;
    ll costcnt = 0;
    ll flag = true;
    while (flag)
    {
        flag = false;
        while (!q.empty())
        {
            p.push(q.front());
            ll qh = q.front().first, qw = q.front().second;
            q.pop();
            rep(i, qh - 1, qh + 2)
            {
                rep(j, qw - 1, qw + 2)
                {
                    if (i >= 0 && j >= 0 && i < H && j < W && s[i][j] != -1 && cost[i][j] == -1 && abs(qh - i) + abs(qw - j) == 1)
                    {
                        q.push(make_pair(i, j));
                        cost[i][j] = costcnt;
                    }
                }
            }
        }
        while (!p.empty())
        {
            ll ph = p.front().first, pw = p.front().second;
            p.pop();
            rep(i, ph - 2, ph + 3)
            {
                rep(j, pw - 2, pw + 3)
                {
                    if (i >= 0 && j >= 0 && i < H && j < W && s[i][j] != -1 && cost[i][j] == -1)
                    {
                        flag = true;
                        cost[i][j] = costcnt + 1;
                        q.push(make_pair(i, j));
                    }
                }
            }
        }
        ++costcnt;
    }
    return cost[dh][dw];
}
int main()
{
    ll H, W;
    cin >> H >> W;
    ll ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    vector<vector<ll>> s(H, vector<ll>(W, 0));
    rep(i, 0, H)
    {
        string tmpstr;
        cin >> tmpstr;
        rep(j, 0, W)
        {
            s[i][j] = tmpstr[j] == '#' ? -1 : 1;
        }
    }
    --ch, --cw, --dh, --dw;
    cout << solver(s, H, W, ch, cw, dh, dw) << endl;
}


Measured memory_bytes: 19336
#include <bits/stdc++.h>
int N;
using namespace std;
int main() {
    cin >> N;

    vector<queue<int>> q(N);
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N-1; ++j) {
            int value;
            cin >> value;
            q.at(i).push(value-1);
        }
    }

    // 優先度が高い順にpushしてある
    // 1から順に試合をしていく。全部満たさないといけないので誰から試合を初めてもかまわない

    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
    int num = 0;
    int days = 0;
    int finish = N * (N-1) / 2;
    while(finish > num) {
        end = chrono::system_clock::now();
        double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(end-start).count() / 1000.0);
        // cout << setprecision(14) << time << endl;
        if(time > 1800.0) {
            cout << finish << endl;
            return 0;
        }
        days++;
        vector<int> match(N, 0);
        for(int i = 0; i < N; ++i) {
            if(q.at(i).empty()) {
                continue;
            }else {
                if(match.at(i) == 1) {
                    q.at(i).pop();
                }else {
                    int rival = q.at(i).front();
                    if(match.at(rival) == 0) {
                        if(q.at(rival).front() == i) {
                            match.at(i) = match.at(rival) = 1;
                            q.at(i).pop();
                            num++;
                        }
                    }
                }
            }
        }
        int flag = 0;
        for(int i = 0; i < N; ++i) {
            if(match.at(i) == 1) {
                flag = 1;
                break;
            }
        }
        int kazu = 0;
        for(int i = 0; i < N; ++i) {
            if(!q.at(i).empty()) kazu++;
        }
        if(kazu == 1) break;
        if(flag == 0) {
            break;
        }
    }

    if(finish == num) {
        cout << days << endl;
    }else {
        cout << "-1" << endl;
    }
}

Measured memory_bytes: 7992
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int D =4*B-5*A;
    if((D>=5)||(D<=-4)){System.out.println(-1);}
    else{if(D>=0){System.out.println(10*B);}
    else{ int C=A%2;
         System.out.println((25*A+C)/2);}
        }
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main(int argc, char const *argv[]) {
  int n;
  string s;
  cin >> n >> s;
  string ans;
  rep(i, s.size()) {
    if (s[i] + n < 91) {
      ans.push_back(s[i] + n);
    } else {
      ans.push_back('A' + s[i] + n - 91);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int A, B, T, cnt = 0;

    cin >> A >> B >> T;
    int tmp = A;
    for (size_t i = 0; i < T + 1; i++)
    {
        if (i == A)
        {
            A += tmp;
            cnt += B;
        }
    }
    cout << cnt << endl;
    return 0;
}

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



int main()
{
	char ch[15];
	int flag = 0;
	char mid;
	
	scanf("%s",ch);
	mid = ch[strlen(ch)-1];
	
	for(int i=0 ; i<2 ; i++)
	{	
		scanf("%s",ch);
		if(mid == ch[0])flag++;
		mid = ch[strlen(ch)-1];
	}
	
	if(flag == 2)printf("YES");
	else printf("NO");
	
	return 0;
}

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

namespace ABC069D
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, W;
            int N;
            string[] vals;
            vals = Console.ReadLine().Split(' ');
            H = int.Parse(vals[0]);
            W = int.Parse(vals[1]);
            N = int.Parse(Console.ReadLine());
            int[] a = new int[N];
            vals = Console.ReadLine().Split(' ');

            for (int i=0; i < N; i++)
            {
                a[i] = int.Parse(vals[i]);
            }

            int[,] m = new int[H, W];

            int y=0, x=0;
            int c = 0;
            int dir = 0;
            while(y < H)
            {
                if(a[c] == 0)
                { 
                    c++;
                    if (c >= N)
                        break;
                }

                a[c]--;
                m[y, x] = c+1;

                if(dir == 0)
                {
                    if(x == W-1)
                    {
                        y++;
                        dir = 1;
                    }
                    else
                    {
                        x++;
                    }
                }
                else
                {
                    if(x == 0)
                    {
                        y++;
                        dir = 0;
                    }
                    else
                    {
                        x--;
                    }
                }

            }

            for(int j=0; j < H; j++)
            {
                for(int i=0; i < W; i++)
                {
                    Console.Write("{0} ", m[j, i]);
                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
#define INSIDE(i,j,H,W) ((i) >= 0 && (i) < (H) && (j) >= 0 && (j) < (W))
#define YesNo(b) (b ? "Yes" : "No")
#define YESNO(b) (b ? "YES" : "NO")
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

// all_of
// partial_sum, adjacent_difference

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#endif

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

template<class Pair>
struct CompBySecond {
	bool operator()(const Pair& left, const Pair& right) {
		return left.second < right.second || (left.second == right.second && left.first < right.first);
	}
};

int N,M,L;
string S;
int main() {
	cin >> N >> M>>L;
	if(N==M)cout << L << endl;
	else
		if (M == L)cout << N << endl;
		else cout << M << endl;
	return 0;
}



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

const int N = 10;

vector <int> vc[N];
bool vis[N];
int n, m;

int traverse (int u, int total) {

    vis[u] = true;

    if (total == n) {
        total --;
        return 1;
    }

    int way = 0;
    for (auto v : vc[u]) {
        if (not vis[v]) {
            total ++;
            way += traverse (v, total);
            vis[v] = false;
            total --;
        }
    }

    return way;
}

int main () {

    scanf ("%d %d", &n, &m);

    for (int i = 1; i <= m; i ++) {
        int u, v;
        scanf ("%d %d", &u, &v);
        vc[u].push_back(v); vc[v].push_back(u);
    }

    printf ("%d\n", traverse (1, 1));

    return 0;
}


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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n;
    int e[100009] = {}, o[100009] = {};
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if(i % 2)
            o[a]++;
        else
            e[a]++;
    }
    int omax = 0, onext = 0, emax = 0, enext = 0;
    FOR(i, 1, 100001) {
        if(o[omax] <= o[i]) {
            onext = omax;
            omax = i;
        } else if(o[onext] <= o[i])
            onext = i;
        if(e[emax] <= e[i]) {
            enext = emax;
            emax = i;
        } else if(e[enext] <= e[i])
            enext = i;
    }
    if(omax != emax) {
        cout << n - o[omax] - e[emax] << endl;
    } else {
        cout << n - max(o[omax] + e[enext], o[onext] + e[emax]);
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(int argc, char *args[])
{
	char string_a[2][201];
	int length;
	int m;
	int i,j;
	int h;
	int offset;


	while(1) {
		offset = 0;

		scanf("%s", string_a[0]);

		if( string_a[0][0] == '-' ) break;

		length=0;
		while( string_a[0][length] != 0 ) {
			length++;
		}

		scanf("%d", &m);

		for( i=0; i<m; i++ ) {
			scanf("%d", &h);

			for( j=0; j<length-h; j++ ) {
				string_a[offset^1][j] = string_a[offset][h+j];
			}

			for( j=0; j<h; j++ ) {
				string_a[offset^1][length-h+j] = string_a[offset][j];
			}
			string_a[offset^1][length] = 0;

			offset = offset ^ 1;
		}

		printf("%s\n", string_a[offset]);

	}

	return 0;

}

Measured memory_bytes: 1804
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[100000];
int d[100000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
	}
	for(int i=0;i<b;i++){
		int e;
		scanf("%d",&e);
		for(int j=0;j<a;j++){
			if(e>=c[j]){
				d[j]++;
				break;
			}
		}
	}
	int at=0;
	int v=0;
	for(int i=0;i<a;i++)if(v<d[i]){
		v=d[i];
		at=i;
	}
	printf("%d\n",at+1);
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MAX3(a, b, c) ((a) > (MAX(b, c)) ? (a) : (MAX(b, c)))
#define MIN3(a, b, c) ((a) < (MIN(b, c)) ? (a) : (MIN(b, c)))

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    string a;
    cin >> a;
    int nedan = 700;
    if (a[0] == 'o') nedan += 100;
    if (a[1] == 'o') nedan += 100;
    if (a[2] == 'o') nedan += 100;
    cout << nedan << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <boost/range/algorithm.hpp>
#include <algorithm>
using namespace std;


int main() {
    int s;
    cin >> s;
    vector<int> vec;
    vec.push_back(s);
    while (true) {
        int num = vec.at(vec.size()-1);
        if (num % 2 == 0) vec.push_back(num / 2);
        else vec.push_back(3 * num + 1);
        num = vec.at(vec.size()-1);

        if (count(vec.begin(), vec.end()-1, num) > 0) {
            cout << vec.size() << endl;
            return 0;
        }
        
    
    }
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    long long a[n+1];
    for (int i=1; i<=n; i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    if (n<=k){
        cout<<0;
        return 0;
    }
    n-=k;
    long long s=0;
    for (int i=1; i<=n; i++)
        s+=a[i];
    cout<<s;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[A];
    int[] b = new int[B];
    int ma = 1000000;
    int mb = 1000000;
    for(int i = 0; i < A; i++) {
      a[i] = sc.nextInt();
      ma = Math.min(ma, a[i]);
    }
    for(int i = 0; i < B; i++) {
      b[i] = sc.nextInt();
      mb = Math.min(mb, b[i]);
    }
    int ans = ma + mb;
    for(int i = 0; i < m; i++) {
      int x = sc.nextInt() - 1;
      int y = sc.nextInt() - 1;
      int c = sc.nextInt();
      ans = Math.min(ans, a[x] + b[y] - c);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 133468
from collections import defaultdict

N = int(input())

if N == 1:
    print(1)
else:
    result = defaultdict(int)
    nodes = [tuple(map(int, input().split(' '))) for i in range(N)]
    
    for x, y in nodes:
        for i, j in nodes:
            if x == i and y == j:
                continue
            p = x - i
            q = y - j
            result[(p, q)] += 1
    max_value = max(result.values())
    print(N - max_value)


Measured memory_bytes: 40560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            long x = in.nextLong();
            long a = x / 11;
            long b = x % 11;
            System.out.println(2 * a + (b == 0 ? 0 : b <= 6 ? 1 : 2));
        }
    }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int a,b;cin>>a>>b;
  cout<<a*b<<endl;

  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long 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;
}

int main(){
    int N;cin>>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll Yen=1000;
    ll Kab=0;
    bool flag=false;//前の回買ったか?
    rep(i,N-1){
        if(A[i]<A[i+1]){
            ll memo=Yen/A[i];
            Kab+=memo;
            Yen-=A[i]*memo;
            //買う
        }
        if(A[i]>A[i+1]){
            ll memo=Kab*A[i];
            Kab=0;
            Yen+=memo;
            //売る
        }
    }
    Yen+=Kab*A[N-1];
    cout<<Yen<<endl;
}

Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for(int i = 0;i < 3;i++){
            a[i] = sc.nextInt();
        }
        int max = 0;
        int count = 0;
        Arrays.sort(a);
        if((a[1] - a[0]) % 2 == 0){
            count += a[2] - a[1];
            count += (a[2] - a[0] - count) / 2;
        }
        else{
            count += a[2] - a[1];
            count += (a[2] - a[0] - count) / 2;
            count += 2;
        }
        System.out.println(count);
    }
}


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

namespace C
{
    class Program
    {
        static IEnumerable<int> func(int a, int b)
        {
            yield return a + b;
            yield return a - b;
        }

        static void Main(string[] args)
        {
            var A = Console.ReadLine().Select(x => int.Parse(x + "")).ToArray();

            if (A[0] + A[1] + A[2] + A[3] == 7)
            {
                Console.WriteLine($"{A[0]}+{A[1]}+{A[2]}+{A[3]}=7");
            }
            else if (A[0] + A[1] + A[2] - A[3] == 7)
            {
                Console.WriteLine($"{A[0]}+{A[1]}+{A[2]}-{A[3]}=7");
            }
            else if (A[0] + A[1] - A[2] + A[3] == 7)
            {
                Console.WriteLine($"{A[0]}+{A[1]}-{A[2]}+{A[3]}=7");
            }
            else if (A[0] + A[1] - A[2] - A[3] == 7)
            {
                Console.WriteLine($"{A[0]}+{A[1]}-{A[2]}-{A[3]}=7");
            }
            else if (A[0] - A[1] + A[2] + A[3] == 7)
            {
                Console.WriteLine($"{A[0]}-{A[1]}+{A[2]}+{A[3]}=7");
            }
            else if (A[0] - A[1] + A[2] - A[3] == 7)
            {
                Console.WriteLine($"{A[0]}-{A[1]}+{A[2]}-{A[3]}=7");
            }
            else if (A[0] - A[1] - A[2] + A[3] == 7)
            {
                Console.WriteLine($"{A[0]}-{A[1]}-{A[2]}+{A[3]}=7");
            }
            else if (A[0] - A[1] - A[2] - A[3] == 7)
            {
                Console.WriteLine($"{A[0]}-{A[1]}-{A[2]}-{A[3]}=7");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define int long long
#define mod 1000000007
#define N 200007
using namespace std;
inline int read(){
	int x=0,w=0;char ch=getchar();
	while (!isdigit(ch))w|=ch=='-',ch=getchar();
	while (isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return w?-x:x;
}
int ksm(int x,int k){
    int res=1;
    while(k){
        if(k&1)res=res*x%mod;
        x=x*x%mod;
        k>>=1;
    }
    return res;
}
int mn[N],c[N],w[N],cnt[N],jc[N],inv[N],n,A,B,ans;
signed main(){
//	freopen("keep.in", "r", stdin); freopen("keep.out", "w", stdout); 
	n=read(),A=read(),B=read();
    memset(mn,0x3f,sizeof(mn));
    jc[0]=1;
    for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%mod;
    inv[n]=ksm(jc[n],mod-2);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	for (int i=1;i<=n;++i){
		c[i]=read(),w[i]=read();
		mn[c[i]]=min(mn[c[i]],w[i]);//颜色集合最小值 
		++cnt[c[i]];//集合元素个数 
	}
	int Mn=1,mnn=inf;
	for (int i=1;i<=n;++i)
		if (mn[i]<mn[Mn])
			Mn=i;//找出全局最小值的颜色 
	for (int i=1;i<=n;++i)
		if (i!=Mn)
			mnn=min(mn[i],mnn);//找出除全局最小值的集合以外的所有数的最小值 
	for (int i=1;i<=n;++i){
		if (w[i]!=mn[c[i]]&&w[i]+mn[c[i]]<=A)continue;//如果这个值不是所在集合的最小值但它与所在集合的最小值的和小于A，那么它是有意义的 
		if (c[i]!=Mn&&w[i]+mn[Mn]<=B)continue;//如果这个值不在全局最小值所在的集合中 ，但它与全局最小值的和小于B，那么它是有意义的
		if (c[i]==Mn&&w[i]+mnn<=B)continue;//如果它在全局最小值所在的集合中，且它与除全局最小值的集合以外的所有数的最小值的和小于B，那么它是有意义的 
		--cnt[c[i]];//如果它不符合以上条件，那么它的存在是没有意义的
	}
	int num=cnt[Mn];
	for (int i=1;i<=n;++i)
		if (i!=Mn&&mn[Mn]+mn[i]<=B)//如果这种颜色存在且它不是全局最小值所在的集合 
			num+=cnt[i];
	ans=1;
	for (int i=1;i<=n;++i)
        if(mn[i]!=inf&&(i==Mn||mn[i]+mn[Mn]<=B))
            ans=ans*inv[cnt[i]]%mod;
	for (int i=1;i<=num;++i)
		ans=ans*i%mod;//这里是求有重复元素的排列种数 
	printf("%lld",ans);
}

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

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

Measured memory_bytes: 256
import numpy as np
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split(' ')))
A = np.array(A)

ans = 0
for i in range(60):
    c_1 = int((A&1).sum())
    ans += c_1*(N-c_1)*(2**i)
    A >>= 1

print(ans%MOD)

Measured memory_bytes: 48824
#include <iostream>
#define int long long
using namespace std;

int ans[50][50];

signed main() {
	int h, w, n, k;
	
	cin >> h >> w >> n >> k;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << "? " << i << " " << j << " " << i << " " << j << endl;
			cout.flush();
			cin >> ans[i][j];
		}
	}
	
	int mul = 1;
	int output = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			output += (ans[i][j] * mul) % k;
			output %= k;
			mul *= 2;
			mul %= k;
		}
	}
	cout << "! " << output << endl;
	return 0;
}

Measured memory_bytes: 724
n,w=map(int,input().split())
wv=[tuple(map(int,input().split())) for i in range(n)]
wv.sort(key=lambda x:-x[1])#reverse
wv.sort(key=lambda x:x[0])
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)]
                    ma=max(ma,ma_sub)
                else:
                    break
        else:
            break

print(ma)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define maxn 200005
#define angel 0x3f3f3f3f
#define eps 1e-9
#define my_angel main
#define ull unsigned long long
char str[30];
int my_angel()
{
    scanf("%s",str+1);
    int sum=0;
    for(int i=1;i<=4;i++)
    {
        if(str[i]=='+')
            sum++;
        else
            sum--;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
# include <iostream>

int main() {
	int m, f, r;

	char grade;
	while (true) {
		std::cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)
			break;
		if (m == -1 || f == -1) {
			grade = 'F';
		}
		else {
			if (m + f >= 80)
				grade = 'A';
			else if (m + f >= 65)
				grade = 'B';
			else if (m + f >= 50)
				grade = 'C';
			else if (m + f >= 30) {
				grade = 'D';
				if (r >= 50)
					grade = 'C';
			}
			else
				grade = 'F';
		}
		std::cout << grade << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll ones(int x){
    if (x == 1) return 1;
    return ones(x-1) * 10 + 1;
}

ll calc(ll d, int x, int fi = 0){
    if (x == 0){
        return d == 0;
    }
    if (x == 1){
        return (d == 0 ? 10 : 0);
    }
    ll ret = 0;
    ll p = (d % 10 + 10) % 10;
    ll a = ones(x - 1);
    ret += (10 - p - fi) * calc((d - p * a) / 10, x - 2);
    ret += (p - fi) * calc((d + (10 - p) * a) / 10, x - 2);
    return ret;
}

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

    if (d % 9){
        cout << 0 << endl;
        return 0;
    }

    d /= 9;

    ll ans = 0;

    FOR(i,2,18){
        ans += calc(d, i, 1);
    }

    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 256
h, w, m = map(int, input().split())
HW = set()
for _ in range(m):
    x, y = map(int, input().split())
    HW.add((x-1,y-1))

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]
for h,w in HW:
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

h_num_ix = {}
for num,ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)

w_num_ix = {}
for num,ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        if (h_ix, w_ix) in HW: continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)


Measured memory_bytes: 130784
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n , S , mn = -1 , answ;
vector <int> g[N];
bool used[N];
int order[N];

void find_centroid(int v,int p){
    order[v] = 1;
    int mx = 0;
    for(int i=0;i<(int)g[v].size();i++){
        int to = g[v][i];
        if(to == p)continue;
        find_centroid(to , v);
        order[v] += order[to];
        mx = max(mx , order[to]);
    }
    mx = max(mx , n - order[v]);
    if(mn == -1 || mx < mn){
        mn = mx;
        S = v;
    }
}

void dfs(int v,int p){
    int childs = 0;
    used[v] = true;
    for(int i=0;i<(int)g[v].size();i++){
        int to = g[v][i];
        if(to == p)continue;
        dfs(to , v);
        used[v] &= used[to];
        childs++;
    }
    if(childs > 1){
        used[v] = false;
    }
}

void solve(int v,int p){
    int k = 0;
    for(int i=0;i<(int)g[v].size();i++){
        int to = g[v][i];
        if(to == p)continue;
        if(used[to]){
            k++;
            continue;
        }
        solve(to , v);
    }
    answ += max(0 , k - 1);
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int a , b;
        scanf("%d%d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    if(n == 2){
        cout<<1<<endl;
        return 0;
    }
    find_centroid(0 , -1);
    dfs(S , -1);
    solve(S , -1);
    cout<<answ<<endl;
	return 0;
}


Measured memory_bytes: 16256
#include <stdio.h>
int main(void){
    int n,t,e,i;
    int x[100],ans=-1;
    scanf("%d %d %d",&n,&t,&e);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        if(t%x[i]<=e||x[i]-(t%x[i])<=e){
            ans=i+1;
        }
    }
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

const int mx=200010;
//const ll mod=1e9+7;

int n;
int x,y,a,b;
ll ans = 1;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  cin >> x >> y;
  bool flag = false;
  for(int i=0; i<=x; i++){
    int j = (x-i)/2;
    if(j<0 || (x-i)%2!=0){continue;}
    if(y != (2*i + j)){continue;}
    a = i; b = j; flag = true;
    break;
  }
  if(!flag){cout << "0" << endl; return 0; }
  int c = a+b;
  
  COMinit();
  ans = COM(c,a);
  cout << ans << endl; 
  return 0;
  

}

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

long long mod = 1000000007;
long long fact[1 << 18], factinv[1 << 18], ans = 1;
int N, M, A[1 << 18], B[1 << 18];
vector<int> X[1 << 18];
bool used[1 << 18];

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= 100000; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	for (int i = 0; i <= 100000; i++) factinv[i] = Div(1, fact[i], mod);
}

long long ncr(long long n, long long r) {
	if (r < 0 || n < r) return 0;
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

long long npr(long long n, long long r) {
	return fact[n] * factinv[n - r] % mod;
}

void dfs(int pos) {
	if (used[pos] == true) return;

	long long v1 = M - 1; if (pos != 1) v1 = M - 2;
	long long v2 = X[pos].size(); if (pos != 1) v2 = X[pos].size() - 1;
	long long v3 = npr(v1, v2);
	ans *= v3; ans %= mod;

	used[pos] = true;
	for (int i = 0; i < X[pos].size(); i++) dfs(X[pos][i]);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	init();
	dfs(1);
	cout << (ans * M) % mod << endl;
	return 0;
}

Measured memory_bytes: 17792
import sys
input = sys.stdin.readline
#n = int(input())
#l = list(map(int, input().split()))
'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def bfs(h, w, m, start):

    import queue
    d = [[0 for i in range(w)]for i in range(h)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    flg = False

    a = queue.Queue()
    a.put(start)
    #print(start)
    while not a.empty():
        hh, ww = map(int, a.get())
        for i in range(4):
            nx, ny = ww+dx[i], hh+dy[i]
            if 0 <= ny < h and 0 <= nx < w and m[ny][nx] != "#" and d[ny][nx] == 0 and [ny,nx]!=start:
                a.put([ny, nx])
                d[ny][nx] = d[hh][ww]+1
    #print(d)
    return d[hh][ww]



h, w = map(int, input().split())
m = [[]for i in range(h)]
for i in range(h):
    m[i] = list(input().rstrip())

ans=[]
for i in range(h):
    for j in range(w):
        if m[i][j]!="#":
            start=[i,j]
            ans.append(bfs(h,w,m,start))
            #print(ans)

print(max(ans))


Measured memory_bytes: 3952
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

typedef long long LL ;
const int N=1e5+100;

int a[N] , b[N];
int f[N];
int siz[N];

inline int find ( int x ) { return f[x]==x?x:f[x]=find(f[x]); }
inline void merge ( int x , int y )
{
	int fx=find(x),fy=find(y);
	if ( fx==fy ) return;
	if ( siz[fx]<siz[fy] ) siz[fy]+=siz[fx],f[fx]=fy;
	else siz[fx]+=siz[fy],f[fy]=fx;
}

LL ans[N];
int n , m ;

int main ()
{
	int i ;
	scanf("%d%d",&n,&m);
	for ( i=1 ; i<=n ; i++ ) f[i]=i,siz[i]=1;
	for ( i=1 ; i<=m ; i++ ) scanf("%d%d",a+i,b+i);
	ans[m]=1ll*n*(n-1ll)/2ll;
	for ( i=m ; i>=1 ; i-- ) 
	{
		LL fa=find(a[i]) , fb=find(b[i]);
		ans[i-1]=ans[i];
		if ( fa==fb ) continue;
		ans[i-1]-=1ll*siz[fa]*siz[fb],merge(a[i],b[i]);
	}
	for ( i=1 ; i<=m ; i++ ) printf("%lld\n",ans[i]);
	return 0 ;
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    static bool CountDivisor(int n){
        int count = 0;
        for(var i = 1;i <= n;i++){
            if(n % i == 0){
                count++;
            }
        }
        return (count == 8) ? true : false;
    }
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        
        var i = 1;
        var ans = 0;
        while(i <= N){
            if(CountDivisor(i)){
                ans++;
            }
            i += 2;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
 char a[100000000],b[100000000];
int main(void)
{
  int i=0,n=0;
  scanf("%s%s",a,b);
  while(1){
    if(a[i]=='\0'){
      break;
    }
    if(a[i]!=b[i]){
      n++;
    }
    i++;
  }
  printf("%d\n",n);
  return 0;
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int>arr[1000000+100]; 
bool has[1000000+100]={false};
int indegree[1000000+100];
int diss[1000000+100];
int zh(int a,int b)
{
	return a*1000+b;
}
bool flag=false;
int my_max(int a,int b)
{
	return a>b?a:b;
}
void  dfs(int star,int now,int fa)
{
	has[now]=true;
	if(now==star)
	{
		flag=true;
		return ;
	}
//	printf("%d--\n",now);
	for(int i=0;i<arr[now].size();i++)
	{
		int v=arr[now][i];
	//	printf("%d\n",v); 
		if(v!=fa && !has[v])
			dfs(star,v,now);
		if(flag)
			return ;
	}
}
int dfs2(int now)
{
	int an=1;
	int u=0;
	has[now]=true;
	for(int i=0;i<arr[now].size();i++)
	{
		int v=arr[now][i];
		if(!has[v])
			u=my_max(u,dfs2(v));
		else
			u=my_max(u,diss[v]);
	}
	return diss[now]=u+1;
}
int low[1000000+100];
int dfn[1000000+100];
int ins[1000000+100];
int tot=0;
stack<int>s;
void tarjan(int x)
{
    low[x]=dfn[x]=++tot;//
    s.push(x);ins[x]=1;
    for(int i=0;i<arr[x].size();i++){
        int p=arr[x][i];
        if(!dfn[p]){//判断点是否被访问过
            tarjan(p);
            low[x]=min(low[x],low[p]);
        }
        else if(ins[p]) low[x]=min(low[x],dfn[p]);//判断点是否在栈中
    }
 
    if(low[x]==dfn[x]){//dfs到叶子节点，开始判断，如果==就到达了某个强联通分量的根节点,dfs回溯到了这个点
        int cnt=0;
        while(1){//得出相关的强联通分量
            int now=s.top();
            s.pop();
            ins[x]=0;//出栈visit置0
            cnt++;
            if(now==x) break;//通过栈找到那个点
        }
        if(cnt>1) flag=true;
    	
    }
}
int main()
{
	int n;
	scanf("%d",&n);
	int p=n;
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		a--;
		int b=i;
		if(a>b)
		{
			int c=a;
			a=b;
			b=c;
		}
		int last=zh(a,b);
		for(int k=0;k<n-2;k++)
		{
			scanf("%d",&a);
			a--;
			b=i;
			if(a>b)
			{
				int c=a;
				a=b;
				b=c;
			}
			int node=zh(a,b);
			arr[node].push_back(last);
			indegree[last]++;
			last=node;
		}
	}
	memset(has,false,sizeof(has));
	for(int i=0;i<=1000000+5;i++)
	{
		if(!dfn[i])
		{
			tarjan(i);
			if(flag)
				break;
		}
	}
//	printf("%d",flag);
	if(flag==true)
		printf("%d\n",-1);
	else
	{
	//	printf("asd");
		memset(has,false,sizeof(has));
		for(int i=0;i<=1000000+5;i++)
			diss[i]=0;
		int ans=1;
		for(int i=0;i<n;i++)
			for(int k=0;k<i;k++)
			{
				if(indegree[zh(k,i)]==0)
				{
				//	has[zh(k,i)]=true;
					diss[zh(k,i)]=1;
					ans=my_max(ans,dfs2(zh(k,i)));
				//	printf("%d\n",zh(k,i));
				}
			}
	//	printf("asd");
		
		printf("%d\n",ans);
	}
	return 0;
 } 

Measured memory_bytes: 59904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc;
        String line;
        int p;
        int b;
        char a;
        sc = new Scanner(System.in);
        outer:
        while (true) {

        line = sc.next();
        p = line.length();
        b=0;

            for (int i = 0; i < p; i++) {
                a = line.charAt(i);
                if (p == 1 && a == 48) {
                    break outer;
                }
                b = b + (a - 48);
            }
            System.out.println(b);
        }
    }

}


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

using namespace std;

int main () {

    int N, K;
    cin >> N >> K;

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

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

    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += l[N - 1 - i];
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 3) cout << 3 << endl;
  if(a + b == 4) cout << 2 << endl;
  if(a + b == 5) cout << 1 << endl;
  return 0;
}

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

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

  int a,b,c; cin >> a >> b >> c;
  int ans = b / a;
  if(ans > c) ans = c;
  cout << ans << endl;

  return 0;
}


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

using namespace std;
typedef long long int lli;
vector <vector <lli> > v(100004);
lli dp[100004];
lli solve(lli i);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	lli n,m,x,y;
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>x>>y;
		v[x].push_back(y);
	}
	for (int i=1;i<=n;i++) dp[i]=-1;
	for (int i=1;i<=n;i++){
		if (dp[i]==-1) solve(i);
	}
	sort(dp,dp+n+1,greater <lli> ());
	cout<<dp[0]<<endl;
	
	return 0;
}

lli solve(lli i){
	if (v[i].size()==0) return 0;
	if (dp[i]!=-1) return dp[i];
	for (int j=0;j<v[i].size();j++){
		dp[i]=max(dp[i],solve(v[i][j])+1);
	}
	return dp[i];
}



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

map<long long, int> factorize(long long n) {
    map<long long, int> ret;
    for(long long i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {
    long long n; cin >> n;
    auto fac = factorize(n);
    cout << n << ':';
    for_each(begin(fac), end(fac),
    [](const pair<long long, int> &a) {
        for(int i=0; i<a.second; ++i) cout << ' ' << a.first;
    });
    cout << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N;
    cin >> N;
    ll i, j;
    
    pt(N*(N-1)/2-N/2);
    
    for(i=1; i<=N; i++) {
        for(j=i+1; j<=N; j++) {
            if(N%2==0 && i+j==N+1) continue;
            if(N%2==1 && i+j==N) continue;
            
            pt(i << " " << j);
        }
    }
    
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
#define pb push_back
#define rep(i,a,b) for (int i = a; i < b; i++)

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int res = 0;
	while (a && k){
		a--;
		k--;
		res++;
	}
	while (b && k){
		b--;
		k--;
	}
	while (c && k){
		c--;
		k--;
		res--;
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<vector>
#include<string>
#include<cstdio>
#define LL long long
#define pb push_back
using namespace std;
int a[111];
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  bool f=false;
  for(int i=0;i<n;i++)
    if(a[i]%10!=0){
      f=true;
      break;
    }
  if(f==false){
    cout<<0;
    return 0;
  }
  int ans=0;
  for(int i=0;i<n;i++)
    ans+=a[i];
  if(ans%10==0)
    for(int i=0;i<n;i++)
      if(a[i]%10!=0){
        ans-=a[i];
        break;
      }
  cout<<ans;  return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;
    int p[n+1];
    for (int i = 1; i <= n; i++) {
        scanf( "%d", &p[i]);
    }
    for (int i = 1; i <= n; i++) {
        if (p[i] == i) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

struct Node{
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

typedef struct Node Node;

Node *NIL;
Node *root;

Node *find(Node *u,int k);
void insert(int k);
void inorder(Node *u);
void preorder(Node *u);



int main(void)
{
  int n,x;
  int i;
  char com[20];

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      scanf("%s",com);

      if(com[0]=='f')
	{
	  scanf("%d",&x);
      
	  Node *t=find(root,x);
      
	  if(t!=NIL)
	    {
	      puts("yes");
	    }

	  else
	    {
	      puts("no");
	    }
      
	}
    
      else if(strcmp(com,"insert") == 0)
	{
	  scanf("%d",&x);
      
	  insert(x);    
	}
    
      else if(strcmp(com,"print") == 0)
	{
	  inorder(root);
      
	  putchar('\n');
      
	  preorder(root);
      
	  putchar('\n');
	}
    
    }
  
  return 0;
}

Node * find(Node *u,int k)
{
  while(u!=NIL&&k!=u->key)
    {
      u=(u->key<k)?u->right:u->left;
    }

  return u;
}

void insert(int k)
{
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL)
    {
      y=x;

      if(z->key<x->key)
	{
	  x=x->left;
	}
      
      else
	{
	  x=x->right;
	}
    }

  z->parent=y;

  if(y==NIL)
    {
      root=z;
    }

  else
    {
      if(z->key<y->key)
	{
	  y->left=z;
	}

      else
	{
	  y->right=z;
	}
    }
}

void inorder(Node *u)
{
  if(u==NIL)
    {
      return;
    }
  
  inorder(u->left);
  
  printf(" %d",u->key);
  
  inorder(u->right);  
}

void preorder(Node *u)
{
  if(u==NIL)
    {
      return;
    }
  
  printf(" %d",u->key);
  
  preorder(u->left);
  
  preorder(u->right);
}



Measured memory_bytes: 20452
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int cnt[114514];
int amari[114514];
int msp[114514];
signed main(){
	int n,m;
	cin>>n>>m;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
		cnt[x]++;
	}
	for(int i=1;i<=100000;i++){
		amari[i%m] += cnt[i];
	}
	for(int i=1;i<=100000;i++){
		msp[i%m] += cnt[i]/2;
	}
	int ans = 0;
	for(int i=0;i<m;i++){
		if( i == 0 || m == 2 * i){
			ans += amari[i]/2;
			amari[i] %= 2;
		}
		else{
			int cp = min( amari[i], amari[m-i] );
			ans += cp;
			amari[i] -= cp;
			amari[m-i] -= cp;
		}
	}
	for(int i=0;i<m;i++){
		ans += min( msp[i], amari[i]/2 );
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3572