akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

char maze[1000][1000];
int H,W;

int score[1000][1000];
const int dh[] = {1,-1,0,0,1,1,-1,-1,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2};
const int dw[] = {0,0,1,-1,1,-1,1,-1,0,1,2,2,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1};
  
void bfs(int i, int j) {
  deque<pair<int,int>> Q;
  score[i][j]=0;
  Q.push_back(make_pair(i, j));
  while(!Q.empty()) {
    pair<int,int> q=Q.front();
    Q.pop_front();
    int h=q.first;
    int w=q.second;
    for (int k=0;k<24;k++) {
      int nh=h+dh[k];
      int nw=w+dw[k];
      if (nh<0 || nh>=H || nw<0 || nw>=W || maze[nh][nw]=='#') continue;
      if (k<4 && score[nh][nw]>score[h][w]){
        Q.push_front(make_pair(nh,nw));
        score[nh][nw] = score[h][w];
      }
      if(k>=4 && score[nh][nw]>score[h][w]+1){
        Q.push_back(make_pair(nh,nw));
        score[nh][nw] = score[h][w]+1;
      }
    }
  }
}
  
int main() {
  cin>>H>>W;
  
  ll ch,dh,cw,dw;
  cin>>ch>>dh>>cw>>dw;
  ch--,dh--,cw--,dw--;
  
  rep(i,1000){
    rep(j,1000) score[i][j]=1e9;
  }
  
  rep(i,H){
    rep(j,W) cin>>maze[i][j];
  }
  
  bfs(ch,dh);
  
  if(score[cw][dw]==1e9) cout<<-1<<endl;
  else cout<<score[cw][dw]<<endl;

  return 0;
}

Measured memory_bytes: 8592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// A1-A3を受け付ける
		int a[] = new int[3];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		// 3通りの絶対値を格納する配列Xを作成する

		int x[] = new int[3];
		x[0] = Math.abs(a[0] - a[1]);
		x[1] = Math.abs(a[1] - a[2]);
		x[2] = Math.abs(a[2] - a[0]);
		// 3通りの絶対値を合計する
		int sum = 0;
		for (int i = 0; i < x.length; i++) {
			sum += x[i];
		}
		// 3通りの中で最も大きいものを合計から引く
		int max1 = Math.max(x[0], x[1]);
		int trueMax = Math.max(max1, x[2]);
		int min_cost = sum - trueMax;
		// 最低コストmin_costを出力する
		System.out.println(min_cost);
	}
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int count = 1;
    int hen=0;
    for (int i = 0; i < n - 1; i++)
    {
        if (a.at(i) == a.at(i + 1))
        {
            hen++;
            if(hen%2==1){
                count--;
            }
            else{
                count++;
            }
        }
        else{
            count++;
            hen=0;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
N,M = map(int,input().split())

A=[]
B=[]

for i in range(N):
    A.append(list(input()))
    
for i in range(M):
    B.append(list(input()))

k=N-M+1
ans=False

for i in range(k):
    for j in range(k):
        flg=True
        
        for p in range(M):
            for q in range(M):
                if A[i+p][j+q] != B[p][q]:
                    flg=False
                    
        ans=flg
        if ans:
            break
    if ans:
        break

if ans:
    print("Yes")
else:
    print("No")

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

typedef long long ll;

typedef pair<ll, int> p;

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

    ll N, K;
    cin >> N >> K;

    vector<ll> c(pow(10, 5) + 10);

    for(int i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        c[a] += b;
    }

    for(int i = 0; i < pow(10, 5) + 10; i++) {
        if(K <= c[i]) {
            cout << i << endl;
            return 0;
        }
        K -= c[i];
    }
}

Measured memory_bytes: 1024
program Digit_Sum_Replace
  implicit none
  integer :: m, i
  integer(8) :: d, c, tot = 0_8, cnt = -1_8, rup = 0_8
  read(*,*) m
  do i = 1, m
    read(*,*) d, c
    tot = tot+d*c
    cnt = cnt+c
  end do
  do while (tot > 9_8)
    rup = rup+tot/10_8
    tot = tot/10_8+mod(tot,10_8)
  end do
  write(*,'(i0)') cnt+rup
end program Digit_Sum_Replace

Measured memory_bytes: 256
A, B = map(int, input().split())

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f * f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
   	a.append(n)
  return a
  
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) #再帰定義

max_kou = gcd(A, B)

print(len(set(prime_factorize(max_kou)))+1)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<list>
using namespace std;


int a[100005];
int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}
	int m = (N - 1) / (K - 1) + ((N - 1) % (K - 1)==0?0:1);
	printf("%d", m);
	return 0;
}

Measured memory_bytes: 640
A, B, K = map(int, input().split())

ans = set()
for i in range(A, min(B + 1, A + K)):
    ans.add(i)

for i in range(max(A, B - K + 1), B + 1):
    ans.add(i)
ans = sorted(list(ans))
for i in ans:
    print(i)


Measured memory_bytes: 62144
#!/usr/bin/python3

a, b, c, x, y = map(int, input().split())

min = float('inf')
for i in range(max(x, y) + 1):
    pa = (x - i) * a
    if pa < 0:
        pa = 0
    pb = (y - i) * b
    if pb < 0:
        pb = 0
    pc = c * 2 * i
    sum = pa + pb + pc
    if min > sum:
        min = sum

print(min)

Measured memory_bytes: 3064
package main

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

func main() {
	scan_init()
	n := scanInt()
	memo := map[string]int{}
	memo["AC"] = 0
	memo["WA"] = 0
	memo["TLE"] = 0
	memo["RE"] = 0
	for i:=0; i<n; i++ {
		s := scan()
		if _,ok := memo[s]; !ok {
			memo[s] = 0
		}
		memo[s] ++
	}
	fmt.Println("AC x", memo["AC"])
	fmt.Println("WA x", memo["WA"])
	fmt.Println("TLE x", memo["TLE"])
	fmt.Println("RE x", memo["RE"])
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2072
#include <iostream>

struct Point {
	double x;
	double y;
};

int main(void)
{
	struct Point p[4];
	int n;
	std::cin >> n;
	for(int j=0; j<n; j++){
	for(int i=0; i<4; i++)
		std::cin >> p[i].x >> p[i].y;
	double t1,t2;
	if( (p[1].y-p[0].y)/(p[1].x-p[0].x) == (p[3].y-p[2].y)/(p[3].x-p[2].x) )
		std::cout << "YES" << std::endl;
	else
		std::cout << "NO" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1224
N,M = list(map(int,input().split()))
A = set(int(input())-1 for i in range(M))

S = []
for i in range(N):
  if i not in A: 
    if i == 0 :
      S += [1]
    elif i == 1:
      S += [S[0] + 1]
    else:
      S += [(S[i-1] + S[i-2]) % int(1e9+7)]
  else:
    S += [0]

print(S[-1])
  

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

using namespace std;

#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n, ans=1;
	cin>>n;
	ll a [n];
	bool zero = false;
	forn(i,n){
		cin>>a[i];
		if(a[i]==0) zero = true;
	}
	if(zero) {cout<<"0\n"; return 0;}
	forn(i,n){
		if(a[i]<=1000000000000000000/ans) ans*=a[i];
		else {cout<<"-1\n"; return 0;}
	}
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 4320
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int r,d,x;
  cin>>r>>d>>x;
  for(int i = 0; i<10;i++){
      x = r*x-d;
      cout<<x<<endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 18) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 2010;

int n, k, q;
int a[MAXN], u[MAXN];

int main()
{
	
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	
	int ans = 1000000000;
	for (int c = 1; c <= n; ++ c)
	{
		for (int i = 1; i <= n; ++ i)
			u[i] = 0;
		vector<int> w;
		for (int i = 1; i <= n; ++ i)
		{
			if (u[i]) continue;
			if (a[i] < a[c]) continue;
			vector<int> v;
			int j = i;
			while (j <= n && a[j] >= a[c])
			{
				v.push_back(a[j]);
				u[j] = 1;
				j ++;
			}
			sort(v.begin(), v.end());
			int m = v.size();
			for (int j = 0; j < m-k+1; ++ j)
				w.push_back(v[j]);
		}
		if (w.size() >= q)
		{
			sort(w.begin(), w.end());
			/*
			for (auto x : w)
				printf("%d ", x); puts("");
			*/
			ans = min(ans, w[q-1]-w[0]);
		}
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int A[][] = new int[n][m];
        int b[] = new int[m];
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                A[i][j] = sc.nextInt();
            }
            sc.nextLine();
        }
        
        for(int i=0;i<m;i++){
            b[i] = sc.nextInt();
        }
        
        int c[] = productVector(A,b);
        
        for(int i=0;i<n;i++){
            System.out.println(c[i]);
        }
        
    
    }
    static int[] productVector(int a[][], int b[]){
        int c[] = new int[a.length];
        for(int i=0;i<a.length;i++){
            for(int j=0;j<a[0].length;j++){
                c[i] += (a[i][j]*b[j]);
            }
        }
        return c;
    }
}


Measured memory_bytes: 45988
import bisect
n=int(input())
a=[int(x) for x in input().split()]
a.sort()

ma=max(a)
mi=float('inf')
ans=0
for i in range(n-1):
  sa=ma-a[i]
  if abs(a[i]-sa)<=mi:
    mi=abs(a[i]-sa)
    ans=a[i]

print(ma,ans)


Measured memory_bytes: 19940
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  int a[n];
  for(int i; i < n; i++){
    cin >> a[i];
  }
  
  sort(a, a + n, greater<int>());
  int alice = 0;
  int bob = 0;
  for (int j = 0; j < n; j++){
    if (j % 2 == 0){
      alice += a[j];
    }else{
      bob += a[j];
    }
  }
  cout << (alice - bob) << endl;
  return 0;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    size = 60
    digits = [[0, 0] for _ in range(size)]
    for a in read_ints():
        for i in range(size-1, -1, -1):
            digits[i][a&1] += 1
            a >>= 1
    p = 1
    answer = 0
    modulo = 10**9+7
    for i in range(size-1, -1, -1):
        answer = (answer+p*digits[i][0]*digits[i][1])%modulo
        p *= 2
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 122944
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double n = sc.nextInt();
		double a = sc.nextInt();
		int b = sc.nextInt();
		double c = sc.nextInt();
		int d = sc.nextInt();
		
		int x = (int)Math.ceil(n / a);
		int y = (int)Math.ceil(n / c);
		
		System.out.println(Math.min(x * b, y * d));
	}
}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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 FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;


signed main(){
	vector<int>a(3);
	REP(i,3)cin>>a[i];
	int t=accumulate(ALL(a),0);
	if(t>21)cout<<"bust"<<endl;
	else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
#define PB push_back
const int MAX = 505;
using namespace std;

int main()
{
	int N;
	cin >> N;
	int r = 0 , b = 0;
	while(N--)
	{
		char c;
		cin >> c;
		r += c == 'R';
		b += c != 'R';
	}
	cout <<( (r > b) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  int m;
  cin >> m;
  int t[m];
  for(int i=0;i<m;i++){
    cin >> t[i];
  }

  sort(d,d+n);
  sort(t,t+m);

  int a;
  a=0;
  for(int i=0;i<m;i++){
    if(a>=n){
      cout << "NO" <<endl;
      return 0;
    }
    while(d[a]!=t[i]){
      if(a<n-1){
        a++;
      }else{
        cout << "NO" <<endl;
        return 0;
      }
    }
    a++;
  }
  cout << "YES" <<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 100000

int A[MAX];

int partition(int p, int r)
{
    int x = A[r];
    int i = p - 1;

    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            int tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }

    i++;
    int tmp = A[i];
    A[i] = A[r];
    A[r] = tmp;
    return i;
}

int main()
{
    int n;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    int q = partition(0, n - 1);

    for (int i = 0; i < n; i++) {
        if (i > 0)
            printf(" ");
        if (i == q) {
            printf("[%d]", A[i]);
        } else {
            printf("%d", A[i]);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}


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

	ll m=n%1000;
	ll ans = 0;
	if (m != 0) {
		ans=1000-m;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(5);
    ll j = -1;
    FORO(i, 5) {
        cin >> a[i];
        if(j == -1 || a[j] > a[i]) {
            j = i;
        }
    }

    ll ans = 0;
    ans += j;
    ans += n / a[j] + (n % a[j] ? 1LL : 0LL);
    ans += 4 - j;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#配列のすべての要素に-1を代入
S = [-1] * 13
H = [-1] * 13
C = [-1] * 13
D = [-1] * 13

#照合
n = int(input())
for i in range(n):
    x = input().split()
    mark = x[0]
    num = int(x[1])
    if mark == 'S':
        S[(num-1)] = 1
    elif mark == 'H':
        H[(num-1)] = 1
    elif mark == 'C':
        C[(num-1)] = 1
    else:
        D[(num-1)] = 1

#表示
for i in range(13):
    if S[i] == -1:
        print('S', (i+1))
for i in range(13):
    if H[i] == -1:
        print('H', (i+1))
for i in range(13):      
    if C[i] == -1:
        print('C', (i+1))
for i in range(13):
    if D[i] == -1:
        print('D', (i+1))


Measured memory_bytes: 5616
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int k = scanner.nextInt();
			scanner.nextLine();
			Map<Integer, Integer> numberCountMap = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int number = scanner.nextInt();
				int integer = numberCountMap.getOrDefault(number, 0);
				numberCountMap.put(number, integer + 1);
			});
			int size = numberCountMap.size();
			if (size <= k) {
				System.out.println(0);
			} else {
				System.out.println(
						numberCountMap.entrySet().stream().mapToInt(x -> x.getValue()).sorted().limit(size - k).sum());
			}
		}
	}
}


Measured memory_bytes: 103732
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int res = 0;
    rep(i, m) {
        int a;
        cin >> a;
        res += a;
    }

    if (res > n) cout << -1 << endl;
    else cout << n - res << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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 a[10010][10010], b[1000];
// int dp[10010][3];

int S[10][1000];

int main() {

    string S;
    cin >> S;
    ll Q; cin >> Q;

    bool flip = false;
    string S_top, S_bot;
    int T;
    rep(i,Q){
        cin >> T;
        if(T == 1){
            flip = flip?false:true;
        }
        else{            
            int n; cin >> n;
            char c; cin >> c;
            if((flip&&n==1) || (!flip&&n==2)){
                S_bot.push_back(c);
            }
            else{
                S_top.push_back(c);
            }
        }
    }
    string res;
    if(flip){
        reverse(S_bot.begin(), S_bot.end());
        reverse(S.begin(), S.end());
        res = S_bot;
        res += S;
        res += S_top;
    }
    else{
        reverse(S_top.begin(), S_top.end());
        res = S_top;
        res += S;
        res += S_bot;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
// F - LCS

#define fi first
#define se second

using namespace std;

int dp[3003][3003];
pair<int,int> par[3003][3003];

int main() {
    string s,t,ans;
    int i,j;
    pair<int,int> p;

    cin >> s;
    cin >> t;

    s = " " + s;
    t = "." + t;
    for (i = 1;i < s.size();i++) {
        for (j = 1;j < t.size();j++) {
            if (dp[i - 1][j] > dp[i][j - 1]) {
                dp[i][j] = dp[i - 1][j];
                par[i][j] = {i - 1,j};
            }
            else {
                dp[i][j] = dp[i][j - 1];
                par[i][j] = {i,j - 1};
            }

            if (s[i] == t[j] && dp[i - 1][j - 1] + 1 > dp[i][j]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                par[i][j] = {i - 1,j - 1};
            }
        }
    }

    i = s.size() - 1;
    j = t.size() - 1;

    while (i > 0 && j > 0) {
        p = par[i][j];
        if (p.fi < i && p.se < j)
            ans += s[i];

        i = p.fi;
        j = p.se;
    }

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

    printf("%s\n",ans.c_str());

    return 0;
}


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

int a,b;

int getCoin() {
  int ret = 0;
  if (a > b) {
    ret = a;
    a--;
  } else {
    ret = b;
    b--;
  }
  return ret;
}

int main() {
  cin >> a >> b;
  int ret = 0;
  for (int i = 0; i < 2; i++) {
    ret += getCoin();
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(M, D):
    ans = 0

    for m in range(1, M+1):
        for d in range(1, D+1):
            d = str(d)
            if len(d) > 1:
                d10 = int(d[1])
            else:
                d10 = 0
            d1 = int(d[0])
            if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
                ans += 1
    return ans


def main():
    M, D = read_int_n()
    print(slv(M, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int answer = 0;
        while (true) {
            if (checkSosuOrNot(x)) {
                answer = x;
                break;
            }
            x++;
        }
        System.out.println(answer);
        sc.close();
    }

    // 引数が素数か判定
    private static boolean checkSosuOrNot(int n) {
        // 1以下の整数は素数にならない
        if (n <= 1) {
            return false;
        }
        // 1と自身を除くどの整数でも割り切れない値が素数となる
        // 引数を2～(引数-1)までの値で順番に割っていく
        for (int i = 2; i < n; i++) {
            // 余りが0ならば素数ではない
            if ((n % i) == 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 35520
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
ll min(ll a, ll b){
     return a > b ? b : a;
}
     
ll max(ll a, ll b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );
     
     int n,m;
     cin>>n>>m;
     
     priority_queue <ll, vector <ll>, greater<ll> > q;
     map <ll, ll> rep;
     vector <pair<ll ,ll> > arr(m);
     
     for (int i=0;i<n;i++){
         ll qq;
         cin>>qq;
         
         q.push(qq);
         rep[qq]++;
     }
     
     for (int i=0;i<m;i++){
         //ll a,b;
         //cin>>a>>b;
         cin>>arr[i].second>>arr[i].first;
         
         //arr.push_back({b, a});
     }
     
     sort(arr.begin(), arr.end());
     reverse(arr.begin(), arr.end());
     
     for (int i=0;i<m;i++){
         ll a = arr[i].second;
         ll b = arr[i].first;
         while ( a > 0 ){
             ll qq = q.top();
             //q.pop();
             if ( qq >= b ){
                 break;
             }else{
                 ll smanji = min(rep[qq], a);
                 rep[qq]-=smanji;
                 rep[b]+=smanji;
                 a-=smanji;
                 q.push(b);
                 
                 if ( rep[qq] == 0 ){
                     q.pop();
                     rep.erase(qq);
                 }
             }
         }
     }
     
     ll res = 0;
     for (auto i:rep){
         res+=i.first*i.second;
     }
     
     cout<<res<<endl;
}

Measured memory_bytes: 11980
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	int n, s;
	
	while(cin >> n >> s, n){
		int ans = 0;
		rep(i, 1<<10){
			int tmp = i;
			int j = 0;
			int cnt = 0;
			int sum = 0;
			while(tmp != 0){
				
				if(tmp % 2 != 0){
					sum += j;
					cnt++;
				}
				tmp = tmp >> 1;
				j++;
			}
			if(cnt != n) continue;
			if(sum == s) ans++;
		}
		cout << ans << endl;
	}

	
	return 0;
}

Measured memory_bytes: 3084
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        k: i64,
        a: [i64; n],
    }
    const B: usize = 40;
    let mut ch = vec![[0, 0]; B];
    for i in 0..B {
        let mut cnt = 0;
        for j in 0..n {
            if (a[j] & 1 << i) != 0 { cnt += 1; }
        }
        ch[i] = [cnt as i64, (n - cnt) as i64];
    }
    let mut ma = 0;
    let mut k = k;
    loop {
        let lsb = k & (-k);
        let mut tot = 0;
        for i in 0..B {
            tot += ch[i][(k >> i & 1) as usize] << i;
        }
        ma = max(ma, tot);
        if k == 0 { break; }
        let mut u = 1;
        let mut pos = 0;
        while u < lsb {
            if ch[pos][0] < ch[pos][1] {
                tot += (ch[pos][1] - ch[pos][0]) << pos;
            }
            u *= 2;
            pos += 1;
        }
        tot += (ch[pos][0] - ch[pos][1]) << pos;
        ma = max(ma, tot);
        k &= k - 1;
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	max_n, max_cnt := 1, 0
	for i := n; i > 0; i-- {
		num := i
		cnt := 0
		for {
			if num % 2 == 0 {
				cnt++
				num /= 2
			} else {
				break
			}
		}
		if cnt > max_cnt {
			max_cnt = cnt
			max_n = i
		}
	}

	fmt.Println(max_n)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> a(n, std::vector<int>(m));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			std::cin >> a[i][j];
			a[i][j]--;
		}
	}
	std::vector<bool> present(m, true);
	auto getBest = [&]() {
		std::vector<int> freq(m, 0);
		for(int i = 0; i < n; i++) {
			for(auto j : a[i]) {
				if(present[j]) {
					freq[j]++;
					break;
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < m; i++) {
			if(freq[i] > freq[ans]) ans = i;
		}
		return std::pair<int, int>(ans, freq[ans]);
	};
	int ans = n;
	for(int i = 0; i < m; i++) {
		auto curPair = getBest();
		ans = std::min(ans, curPair.second);
		present[curPair.first] = false;
	}
	std::cout << ans << '\n';
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

struct Node {
  vector<int> children;
  ll cost;
  bool used;
};

Node nodes[200010];
ll results[200010];

int main(int argc, char* argv[]) {
  ll N, Q;
  cin >> N >> Q;

  REP(i, 0, N - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    nodes[a].children.push_back(b);
    nodes[b].children.push_back(a);
  }

  REP(i, 0, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    nodes[p].cost += x;
  }

  stack<int> s;
  s.push(0);

  ll cost = 0;
  while (!s.empty()) {
    int index = s.top();
    s.pop();

    if (nodes[index].used) {
      cost -= nodes[index].cost;
      continue;
    }

    cost += nodes[index].cost;
    results[index] = cost;
    nodes[index].used = true;

    s.push(index);
    for (int next : nodes[index].children) {
      if (nodes[next].used) continue;
      s.push(next);
    }
  }

  string result;
  REP(i, 0, N) { result += to_string(results[i]) + " "; }
  result.pop_back();
  cout << result << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 21876
/* ex 5_4
   yy8332 */

#include <stdio.h>
#include <string.h>

int main(void){
  char str1[11], *str2;
  int len1, len2, ans, i;

  //入力読み取り
  scanf("%s", str1);

  len1 = strlen(str1);

  //最長部分文字列の取得
  ans = 0;

  for(i = 0; i < len1; i++){
    if(str1[i] == 'A' || str1[i] == 'C' || str1[i] == 'G' || str1[i] == 'T'){
      len2 = 0;
      str2 = &str1[i];
      while(*str2 == 'A' || *str2 ==  'C' || *str2 == 'G' || *str2 == 'T'){
        len2++;
        str2++;
      }
      i += len2 - 1;
    }
    if(len2 > ans){
      ans = len2;
    }
  }

  //出力
  printf("%d\n", ans);
}


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

int main(void){
    // Your code here!
   int n;
   scanf("%d",&n);
   int a[n];
   long long sum=0;
   
   for(int i=0;i<n;i++){
       scanf("%d",&a[i]);
   }
   
   for(int i=1;i<n;i++){
       while(1){
           if(a[i-1]>a[i]){
               a[i]++;
               sum++;
           }else{
               break;
           }
       }
   }
   
   printf("%lld\n",sum);
   
   return 0;
 }


Measured memory_bytes: 2476
#include<stdio.h>
#include<string.h>
int judge(char a[],int n);
int main()
{
	char a[50];
	while(scanf("%s",a)!=EOF)
	{
		
		int len=strlen(a);
		if(judge(a,len))
			printf("no\n");
		else 
			printf("yes\n");
	}
	return 0;
}
int judge(char a[],int n)
{
	int i,j;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(a[i]==a[j])
				return 1;
		}
	}
	return 0;
}

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

int main(){
    int64_t N,x,sum=0,kids =0;
    cin >> N >> x;
    int a[N];
    for(int i=0;i<N;i++) {
        cin>>a[i];
        sum+= a[i];
    }
    if(x>sum) cout << N-1 << endl;

    else{
        sort(a,a+N);
        int A =0;

        for(int i=0;i<N;i++){
            if(x>=(A+a[i])){
                A += a[i];
                kids++;
            }
            else break;       
        }
        cout << kids << endl;
    }


}

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

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    string s[50];
    for (int i=0;i<H;i++) cin >> s[i];

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

    for (int i=0;i<H;i++){
	for (int j=0;j<W;j++){
	    if (s[i][j] == '#') continue;

	    int num=0;
	    for (int d=0;d<8;d++){
		int ni=i+dy[d];
		int nj=j+dx[d];

		if ((ni < 0) || (H <= ni)) continue;
		if ((nj < 0) || (W <= nj)) continue;
		if (s[ni][nj] == '#') num++;
	    }
	    s[i][j]=char(num+'0');
	}
    }

    for (int i=0;i<H;i++) cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

//////検証する数,超えられない数////

long long cine(long long a, long long b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
};
//vector型の初期化

void vec_initialize(vector<ll>& a, const ll N) {
	ll c;

	for (int i = 0; i < N; i++) {

		cin >> c;
		a.push_back(c);

	}

};
void vec_pair_initialize(vector<pair<ll, ll>>& a, const ll N) {
	ll c, d;
	for (int i = 0; i < N; i++) {
		cin >> c >> d;
		a.push_back(make_pair(c, d));
	}
};
/*
	ll N, C;
	vector<ll>s, t, c;
	cin >> N >> C;
	ll x,y,z;
	map<ll, ll>chanel;
	for (ll i = 0; i < N; i++) {
		cin >> x>>y>>z;
		s.push_back(2*x-1);
		t.push_back(2*y);
		c.push_back(z);
	}
	
	map<ll,ll>tmpc;
	
	for (ll i = 1; i <=C; i++) {
		vector<ll> tmps;
		vector<ll> tmpt;
		
		for (ll j = 0; j < N; j++) {
			if (c[j] == i) {
				tmps.push_back(s[j]);
				tmpt.push_back(t[j]);
				
				tmpc[i-1]++;
			}
		}
		sort(tmps.begin(), tmps.end());
		sort(tmpt.begin(), tmpt.end());
		for (ll j = 0; j < tmpc[i - 1]; j++) {
			if (j+1!=tmpc[i-1]&&tmps[j+1] < tmpt[j]) {
				tmps[j + 1] += 2;
			}
		}
		for (ll j = 0; j < tmpc[i - 1]; j++) {
			for (ll k = tmps[j]; k <= tmpt[j]; k++) {

				chanel[k]++;

			}
		}


	}
	ll big=0;
	for (auto i : chanel) {
		if (i.second > big) {

			big = i.second;
		}

	}

	cout <<big;


}
*/
int main(){
	ll N, M;
	cin >> N>>M;
	vector<ll>X;
	vector<ll>far;
	vec_initialize(X, M);
	sort(X.begin(), X.end());
	ll tmp ;
	for (int i = 1; i < M; i++) {
		tmp = labs(X[i] - X[i-1]);
		far.push_back(tmp);
	}
	sort(far.begin(), far.end());
	ll cnt = 0;
	for (int i = 0; i < M - N; i++) {
		cnt += far[i];
	}
	cout << cnt;
}

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

int main() {
    int n;
    cin >> n;
    long long int ans = 0;
    int d[n];
    for(int k = 0; k < n; ++k) {
        cin >> d[k];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll k;
    cin >> k;
    vector<string> ans;
    vector<ll> mass;
    ll lim = 0;
    for(ll i = 1; i <= 9; i++){
        string c = to_string(i);
        ans.push_back(c);
        mass.push_back(i);
        lim++;
    }
    ll count = 1;
    ll start = 0;
    //cout << "aaa" << endl;
    while(count < 10){
        ll finish = ans.size();
        for(ll i = start; i < finish; i++){
            string c = ans[i];
            for(ll j = -1; j <= 1; j++){
                char d = c[c.length()-1];
                if(d=='0' && j==-1) continue;
                if(d=='9' && j==1) continue;
                d+=j;
                string e = c+d;
                ans.push_back(e);
                ll pp = stoll(e);
                mass.push_back(pp);
               //cout << ans[i] << " " << pp << endl;
               lim++;
               if(lim >= 102000) break;
            }
        }
        count++;
        start = finish;
        finish = ans.size();
        //cout << start << " " << finish << endl;
    }
    //cout << mass.size() << endl;
    sort(mass.begin(), mass.end());
    cout << mass[k-1] << endl;
    return 0;
}


Measured memory_bytes: 11112
# https://atcoder.jp/contests/abc088/tasks/abc088_d


import sys
input = sys.stdin.readline
from collections import deque

move = [(1, 0), (-1, 0), (0, 1), (0, -1)]     # 動ける場所の候補

def debug(p, t):
    player = p
    debug_grid = list(list(grid[h]) for h in range(H))
    debug_grid[start[0]][start[1]] = "S"
    debug_grid[goal[0]][goal[1]] = "G"
    debug_grid[player[0]][player[1]] = "P"
    print("~~~~~~~~~ t = " + str(t+1) + "  ~~~~~~~~")
    for debug_h in range(H):
        print("".join(debug_grid[debug_h][debug_w] for debug_w in range(W)))

def bfs(grid, visit, start, goal=(None,None)):
    visit[start[0]][start[1]] = 1               # スタート地点はすでに訪れている
    next_set = deque([(start, 0)])              # 次に進む候補を列挙する。スタック（右から取り出す = pop）だと深さ優先になり、キュー（左から取り出す = popleft）だと幅優先になる
                                                # 第一成分はスタート地点、第二成分は時刻を表す。
    while next_set:                             # p = [] になったら止める
        p, t = next_set.popleft()               # 要素を消去して、消去した要素を出力
        h, w = p
        for dh, dw in move:                     # 頂点 p から進める経路の候補から一つ選ぶ
            q = (h + dh, w + dw)
            if q[0] < 0 or q[0] >= H or q[1] < 0 or q[1] >= W:
                continue
            if grid[q[0]][q[1]] == wall:         # 壁があったら進まない
                continue
            if visit[q[0]][q[1]] == 1:           # 一度訪れていた場合は進まない
                continue
            #### (debug code) ######
            # debug(start, goal, q, t)
            ########################
            if q == goal:                       # ゴールがあるならば、ここで判定
                return t + 1                    # 経路の長さは t + 1 で与えられる
            visit[q[0]][q[1]] = 1               # 頂点 q に一度訪れた事をメモ (for の前に書くと、ここで選ばれた q が最短であるはずなのに、違う経路でvisit = Trueを踏んでしまう可能性がある)
            next_set.append((q, t + 1))         # p から q へと移動。時刻を 1 進める
    return -1


road, wall = ".", "#"                         # (進行可能を意味する記号, 進行不可を意味する記号)

H,W = map(int,input().split())                # 左上は(h,w)=(0,0)、右下は(h,w)=(H-1,W-1)

grid = []
cnt = 0
for h in range(H):
    grid.append(input().rstrip())                # 文字列を読み込むと改行が入るため、rstrip()で消す
    cnt += grid[-1].count(".")
start = (0,0)
goal = (H-1, W-1)

visit = [[0]*W for _ in range(H)]
res = bfs(grid, visit, start, goal)           #  visitを初期化せずに何度も呼び出すと、visit が変わって返り値も変わるので注意
if res == -1:
    print(-1)
else:
    print(cnt - res - 1)

Measured memory_bytes: 74076
#include <bits/stdc++.h>
using namespace std;
const long long MAX=1e6;
vector<long long> isprime(MAX+1, 1), uoc(MAX+1);
void sieve(){
	for(long long i=1; i<=MAX; i++) uoc[i]=i;
	isprime[0]=0; isprime[1]=0;
	for(long long i=2; i*i<=MAX; i++){
		if(isprime[i])
		for(long long j=i*i; j<=MAX; j+=i){
			isprime[j]=0;
			if(uoc[j]==j) uoc[j]=i;
		}
	}
}
main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	long long n;
	cin >> n;
	sieve();
	vector<long long> mark(MAX+1, 0);
	long long mama=0;
	for(long long i=1; i<=n; i++){
		long long x;
		cin >> x;
		mama=max(mama, x);
		long long pre=0;
		while(uoc[x]!=1){
			if(uoc[x]!=pre) mark[uoc[x]]++, pre=uoc[x];
			x/=uoc[x];
		}
	}
	if(mama==1) return cout << "pairwise coprime", 0;
	long long ma=*max_element(mark.begin(), mark.end());
	if(ma==1) cout << "pairwise coprime";
	else if(ma!=n) cout << "setwise coprime";
	else cout << "not coprime";
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1000000007;
const int INF = 1<<18;
const lint INFLINT = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

int n, x, y, z;
string s;

int main() {
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf=1e9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};	

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

	map<int,int> memo;
	bool ok=false;
	for (int i = 0; i < n; i++){
		int a;
		cin>>a;
		if(memo[a]){
			ok=true;
		}else{
			memo[a]++;
		}
	}

	if(ok){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}

	return 0;
}



Measured memory_bytes: 9600