akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> B[i];
    }

    priority_queue<ll> pq;
    ll need = 0;
    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        if (A[i] < B[i]) {
            need += B[i] - A[i];
            ans++;
        } else {
            pq.push(A[i] - B[i]);
        }
    }

    while (need > 0) {
        if (pq.size() == 0) {
            cout << -1 << endl;
            return 0;
        }

        need -= pq.top();
        pq.pop();
        ans++;
    }

    cout << ans << endl;
}

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

#define      ll     long long int

int powerTwo(int x)
{
    int c = 0;
    while (x % 2 == 0) {
        x /= 2;
        c++;
    }
    return c;
}

int main()
{
    int n, i, j, k, mn = 1e9;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        mn = min(mn, powerTwo(j));
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NAME "taskA"
#define scan 1
bool isFile;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void _();

void faster() {
    _();
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 27;
const int N = (int)1e5 + 5;
const int M = 1234;

namespace MATH_CAL {
    const int mod = MOD;
    inline ll add(ll a, ll b) { return a + b >= mod ? a + b - mod : a + b; }
    inline ll sub(ll a, ll b) { return a - b < 0 ? a - b + mod : a - b; }
    inline ll mul(ll a, ll b) { return (ll) a * b % mod; }
    inline void Add(ll &a, ll b) { (a += b) >= mod ? a -= mod : 0; }
    inline void Sub(ll &a, ll b) { (a -= b) < 0 ? a += mod : 0; }
    inline ll qpow(ll x, ll n) { ll r = 1; for ( ; n; n /= 2, x = mul(x, x)) if (n & 1) r = mul(r, x); return r; }
    inline ll mod_inv(ll x) { return qpow(x, mod - 2); }
    inline ll gcd(ll a, ll b) {while(b) {a %= b; swap(a, b);} return a;}
    inline ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
} using namespace MATH_CAL;

void solve() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK";
            return;
        }
    }
    cout << "NG";
}

void _() {
//    isFile = 1;
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
         solve();
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    int temp_1=1, temp_2=1, temp_3=1, ans;

    if(S == 1 || S == 2) cout << 0 << endl;
    else if(S == 3 || S == 4 || S == 5) cout << 1 << endl;
    else{
        for(int i = 0; i < S-5; i++){
            ans = (temp_1 + temp_3) % MOD;
            temp_1 = temp_2;
            temp_2 = temp_3;
            temp_3 = ans;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
long long n,d;
void solve()
{
    long long i,ans=0;
    for (i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        if (x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<endl;
    
}
int main()
{
    while(cin>>n>>d)
        solve();
}

Measured memory_bytes: 3184
#include <iostream>
#include <cstring>

using namespace std;

int main(void) {
  while (true) {
    int field[21][21]; // ?????£???????????????????¨??????§?¨?
    int N; // ??????????????°
    int M; // ??????????????°
    int positionX = 10; // ????????????????????????x??§?¨?
    int positionY = 10; // ????????????????????????y??§?¨?
    memset(field, 0, sizeof(field));

    cin >> N;
    if (N == 0) {
      break;
    }
    for (int i=0; i<N; i++) {
      int x, y;
      cin >> x >> y;
      field[y][x] = 1;
    }

    cin >> M;
    for (int i=0; i<M; i++) {
      char direction;
      int distance;
      cin >> direction >> distance;
      switch (direction) {
      case 'N':
        for (int j=0; j<=distance; j++) {
          field[positionY+j][positionX] = 0;
        }
        positionY += distance;
        break;
      case 'E':
        for (int j = 0; j <= distance; j++) {
          field[positionY][positionX+j] = 0;
        }
        positionX += distance;
        break;
      case 'S':
        for (int j = 0; j <= distance; j++) {
          field[positionY-j][positionX] = 0;
        }
        positionY -= distance;
        break;
      case 'W':
        for (int j = 0; j <= distance; j++) {
          field[positionY][positionX-j] = 0;
        }
        positionX -= distance;
        break;
      }
    }

    bool ans = true;
    for (int i = 0; i < 21; i++) {
      for (int j = 0; j < 21; j++) {
        if (field[i][j] == 1) {
          ans = false;
        }
      }
    }
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;
int uf[MAX];
int FIND( int x ) { return uf[x] == x ? x : uf[x] = FIND( uf[x] ); }
void UNION( int x, int y ) { uf[FIND( x )] = FIND( y ); }

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int n, m; cin >> n >> m;
	for(int i = 1; i <=n; i++)uf[i] = i;
	vector<int> ans(n + 1);
	vector<vector<int>> g(n + 1);
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> que;
	que.push_back(1);
	vector<bool> vis(n + 1);
	vis[1] = true;
	int f = 0;
	vector<int> par(n + 1);
	while(f < (int)que.size()){
		int v = que[f++];
		for(auto nv: g[v]){
			if(!vis[nv]){
				par[nv] = v;
				vis[nv] = true;
				que.push_back(nv);
			}
		}
	}
	if(que.size() == n){
		cout << "Yes "<< endl;
		for(int v = 2; v <= n; v++)
		cout << par[v] << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 11320
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector<long long> x,y;
	long long temp,temp2;
	for(int i=0;i!=n;++i){
		cin>>temp>>temp2;
		x.push_back(temp);
		y.push_back(temp2);
	}
	long long ans=0;
	for(int i=n-1;i>=0;--i){
		x[i]+=ans;
		if(x[i]%y[i]){
			long long add=(x[i]/y[i]+1)*y[i]-x[i];
			ans+=add;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 2036
#include <iostream>
#include <string>
using namespace std;

struct Dice{
    int s[6];
    void roll(char ope){
        int b;
        if(ope == 'E'){
            swap(s[0],s[2]);
            swap(s[0],s[5]);
            swap(s[0],s[3]);
        }
        if(ope == 'W'){
            swap(s[0],s[3]);
            swap(s[0],s[5]);
            swap(s[0],s[2]);
        }
        if(ope == 'S'){
            swap(s[0],s[1]);
            swap(s[0],s[5]);
            swap(s[0],s[4]);
        }
        if(ope == 'N'){
            swap(s[0],s[4]);
            swap(s[0],s[5]);
            swap(s[0],s[1]);
        }
    }
    int top(){
        return s[0];
    }
};

int main(){
    struct Dice Dice;
    for(int i = 0;i < 6;i++)
        cin >> Dice.s[i];
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++)
        Dice.roll(s[i]);
    cout << Dice.top() << endl;

    return 0;
}


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

using namespace std;
//for triangle a+b>c

void test()
{
    int n;
    cin>>n;

    vector<long long>a(n);

    for(auto &it:a)
        cin>>it;

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

    int res=0;

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]==a[j])
                continue;
            for(int k=j+1;k<n;k++)
            {
                if(a[j]==a[k])
                    continue;

                if(a[i]+a[j]>a[k])
                    res++;
            }
        }
    }

    cout<<res<<endl;
}

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

    test();

    return 0;
}


Measured memory_bytes: 3648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var a, b int
	input := scanIntNum()
	inputs := scanIntNums()
	inputs2 := scanIntNums()
	patterns := order(input)
	for i, p := range patterns {
		if reflect.DeepEqual(p, inputs) {
			a = i + 1
		}
		if reflect.DeepEqual(p, inputs2) {
			b = i + 1
		}
	}
	//fmt.Println(a, ",", b)
	if a-b > 0 {
		fmt.Println(a - b)
	} else {
		fmt.Println(b - a)
	}
}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}

func order(size int) [][]int {
	rest := make([]int, size)
	var head []int
	for i := 0; i < size; i++ {
		rest[i] = i + 1
	}
	return perm(head, rest)
}

func perm(head, rest []int) [][]int {
	var res [][]int
	if len(rest) == 0 {
		res = append(res, head)
		return res
	}
	for i := 0; i < len(rest); i++ {
		restx := make([]int, len(rest))
		headx := make([]int, len(head)) //
		copy(restx, rest)
		copy(headx, head) //
		headx = append(headx, restx[i])
		restx = append(restx[:i], restx[i+1:]...)
		res = append(res, perm(headx, restx)...)
	}
	return res
}

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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int x = inputLongArray[0];
            int y = inputLongArray[1];

            var groupA = new[] { 1, 3, 5, 7, 8, 10, 12 };
            var groupB = new[] { 4, 6, 9, 11 };
            var groupC = new[] { 2 };

            if (groupA.Contains(x) && groupA.Contains(y)) {
                Console.WriteLine("Yes");
                return;
            } else if (groupB.Contains(x) && groupB.Contains(y)) {
                Console.WriteLine("Yes");
                return;
            } else if (x == 2 && y == 2) {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
            return;
        }
    }
}


Measured memory_bytes: 11348
import collections

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

N = int(input())

PrimeFactors = collections.Counter(prime_factorize(N))
countPrime = PrimeFactors.values()
cnt = 0
for i in countPrime:
    counter = 0
    for j in range(1,20):
        i = i - j
        if i >= 0:
            cnt += 1
        else:
            break
print(cnt)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  string S; cin >> S;
  string ls = S.substr(0,N);
  string rs = S.substr(N,N); reverse(rs.begin(),rs.end());

  map<char, ll> cl, cr;
  rep(i,N) { cl[ls[i]]++; cr[rs[i]]++; }
  bool ok = true;
  for (auto x: cl) {
    if (x.second!=cr[x.first]) ok = false;
  }
  if (!ok) { cout << 0 << endl; return 0; }

  map<string, map<string,ll>> left, right;
  rep(i,(1<<N)) {
    string sl = "", tl = "";
    string sr = "", tr = "";
    rep(j,N) {
      if (i&(1<<j)) { sl += ls[j]; sr += rs[j]; }
      else { tl += ls[j]; tr += rs[j]; }
    }
    left[sl][tl]++; right[sr][tr]++;
  }

  ll result = 0;
  for (auto x: left) for (auto y: x.second) {
    result += y.second * right[x.first][y.first];
  }
  cout << result << endl;
  return 0;
}

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

int main(){
  int a,h,c=0,d,e;
  cin>>a;
  vector<vector<int>> b(a,vector<int>(3));
  for(int i=0;i<a;i++){
    for(int j=0;j<3;j++)
      cin>>b.at(i).at(j);
  }
  sort(b.begin(),b.end(),[](vector<int> i, vector<int> j){
    return i.at(2)>j.at(2);
  	/*if(i.at(0)==j.at(0)){
      if(i.at(1)==j.at(1)){
        return i.at(1)<
      }
    }else{
      return i.at(0)<j.at(0);
    }*/
  });
  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      h=b.at(0).at(2)+abs(b.at(0).at(0)-i)+abs(b.at(0).at(1)-j);
      for(int k=0;k<a;k++){
        if(b.at(k).at(2)==0){
          if(h-abs(b.at(k).at(0)-i)-abs(b.at(k).at(1)-j)>0)
            break;
        }
        else{
          if(h!=b.at(k).at(2)+abs(b.at(k).at(0)-i)+abs(b.at(k).at(1)-j))
            break;
        }
        if(k==a-1){
          c=1;
          d=i;
          e=j;
        }
      }
      if(c==1)
        break;
    }
    if(c==1)
      break;
  }
  cout<<d<<' '<<e<<' '<<h<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  double w;
  while (scanf("%lf", &w) != EOF) {
    if (w <= 48.00) printf("light fly\n");
    else {
      if (w <= 51.00) printf("fly\n");
      else {
	if (w <= 54.00) printf("bantam\n");
	else {
	  if (w <= 57.00) printf("feather\n");
	  else {
	    if (w <= 60.00) printf("light\n");
	    else {
	      if (w <= 64.00) printf("light welter\n");
	      else {
		if (w <= 69.00) printf("welter\n");
		else {
		  if (w <= 75.00) printf("light middle\n");
		  else {
		    if (w <= 81.00) printf("middle\n");
		    else {
		      if (w <= 91.00) printf("light heavy\n");
		      else printf("heavy\n");
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 608
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define MAX_N 100000
int dp[3][MAX_N];
int abc[3][MAX_N];

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		cin>>abc[0][i]>>abc[1][i]>>abc[2][i];
	}
	dp[0][0] = abc[0][0];
	dp[1][0] = abc[1][0];
	dp[2][0] = abc[2][0];
	for(int i = 1; i < n; i++){
		dp[0][i] = abc[0][i] + max(dp[1][i-1],dp[2][i-1]);
		dp[1][i] = abc[1][i] + max(dp[0][i-1],dp[2][i-1]);
		dp[2][i] = abc[2][i] + max(dp[0][i-1],dp[1][i-1]);
	}
	cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1])<<endl;
	return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[53] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
int main(){
	int n; scanf("%d", &n);
	printf("%d\n", a[n-1]);
}


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

int main() { 	
 int A,B,N,ans;
 cin >>N;
 vector<int> AA(N);
  vector<int> BB(N);
  ans=0;
 for(int i=0;i<N;i++){
cin >>A;
AA.at(i)=A;
BB.at(i)=A;
 }
sort(AA.begin(),AA.end());

for(int i=0;i<N;i++){
	
if(AA.at(i)!=BB.at(i)){
ans++;
}
 }

 if(ans>=3){
	 cout << "NO"<<endl;
 }else{
	 cout << "YES"<<endl;
 }
}

Measured memory_bytes: 256
import java.util.*;

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

        int count = 0;
        for(int i = 0; i < word.length()/2; i++){
          //System.out.println(word.substring(i, i+1) + " " + word.substring(word.length()-1, word.length()));
          if(!word.substring(i, i+1).equals(word.substring(word.length()-1-i, word.length()-i)))
            count++;
        }

        System.out.println(count);
    }
}

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

struct Range{
  int L,R;

  bool operator<(const Range &another) const{
    if(L == another.L) return R < another.R;
    return L < another.L;
  }

};

//範囲を昇順に並べ境界をずらしていく
//コーナーケースとして最大の範囲一つとそれ以外
int main(void){
  int N;
  cin >> N;
  vector<Range> ranges(N);
  int joy = 0;
  for(int i = 0; i < N; ++i){
    int L,R;
    cin >> L >> R;
    ++R;
    joy = max(joy,R-L);
    ranges[i] = {L,R};
  }
  sort(ranges.begin(),ranges.end());

  //前方累積重複範囲と後方累積重複範囲
  vector<Range> fwd(N+1);
  vector<Range> bak(N+1);
  fwd[0] = {1, (int)1e9+1};
  bak[N] = {1, (int)1e9+1};
  for(int i = 0; i < N; ++i){
    fwd[i+1] = {
      max( ranges[i].L, fwd[i].L),
      max( ranges[i].L, min( ranges[i].R, fwd[i].R ) )
    };
  }
  for(int i = N-1; i >= 0; --i){
    bak[i] = {
      max( ranges[i].L, bak[i+1].L),
      max( ranges[i].L, min( ranges[i].R, bak[i+1].R ) )
    };
  }

  joy += fwd[N].R-fwd[N].L;
  for(int i = 1; i < N; ++i){
    joy = max(joy, 
        fwd[i].R-fwd[i].L + bak[i].R-bak[i].L);
  }
  cout << joy << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int W[10];
	int K[10];
	int wtotal;
	int ktotal;
	
	for (int i = 0; i < 10 ; i++){
		cin >> W[i];
	}
	for (int i = 0; i < 10 ; i++){
		cin >> K[i];
	}
	
	sort(W,W+10);
	reverse(W,W+10);
	
	sort(K,K+10);
	reverse(K,K+10);
	
	wtotal = W[0] + W[1] + W[2];
	ktotal = K[0] + K[1] + K[2];
	
	cout << wtotal <<" "<< ktotal << endl;
	
	return (0);
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;

    int N;
    cin >> N;
    vi A(N);
    vi B(N);
    vi C(N - 1);

    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    int score = 0;
    int pre = -2;
    rep(i, N)
    {
        score += B[A[i] - 1];
        if(pre + 1 == A[i] - 1)
            score += C[pre];
        pre = A[i] - 1;
    }
    cout << score << endl;
}

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

int main()
{
	int min, max;
	long sum = 0;
	int n, num;

	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> num;
		if(i == 0) {
			min = num;
			max = num;
		} else {
			if(num < min)
				min = num;
			if(num > max)
				max = num;
		}
		sum += num;
	}
	cout << min << " " << max << " " << sum << endl;

	return 0;

}

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

X = list(map(int,input().split()))

X.sort()
Y=[]
for i in range(M-1):
    Y.append([X[i+1]-X[i],i])

Y=sorted(Y,key=lambda y: y[0])
ans=0
for i in range(M-N):
    ans+=Y[i][0]
    
print(ans)

Measured memory_bytes: 22316
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	in >> N >> K;

	if (K > (N - 1) * (N - 2) / 2)
	{
		out << -1 << std::endl;
		return 0;
	}

	std::vector<std::pair<LL, LL>>ans;
	std::vector<LL>cnt(N + 1, N - 1);
	for (LL i = 1; i <= N; ++i) for (LL j = i + 1; j <= N; ++j) ans.push_back(std::make_pair(i, j));
	rep(i, K)
	{
		rep(j, ans.size())
		{
			if (cnt[ans[j].first] > 1 && cnt[ans[j].second] > 1)
			{
				--cnt[ans[j].first];
				--cnt[ans[j].second];
				ans.erase(ans.begin() + j);
				break;
			}
		}
	}

	out << ans.size() << std::endl;
	rep(i, ans.size()) out << ans[i].first << " " << ans[i].second << std::endl;
}


Measured memory_bytes: 512
#include <stdio.h>


int main(){


  int i, j;
  int H, W;


  while(1){
    scanf("%d %d", &H, &W);


    if(H == 0 && W == 0){
      break;
    }

    else{
      for(i=0;i<H;i++){
        for(j=0;j<W;j++){
          printf("#");
        }

        printf("\n");
      }
    }

    printf("\n");
  }


  return 0;
}

Measured memory_bytes: 572
#include<stdio.h>
int main()
{
 int N,L[100],sum=0;
 scanf("%d",&N);
 for(int i=0;i<N;i++)
 {
 	scanf("%d",&L[i]);
 }
 int max=L[0];
 for(int i=0;i<N;i++)
 {
 	if(max<L[i])
 	{
 		max = L[i];
 	} 
 }
 for(int i=0;i<N;i++)
 {
 	sum = sum + L[i];
 }
 if(sum-max>max)
{
	printf("Yes\n");
}
else
{
	printf("No\n");
}
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, a;
  cin >> n >> a;
  cout << n*n - a << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, X;
	cin >> N >> X;
	VI L(N);
	int sum = 0,ans=0;
	REP(i, N) {
		cin >> L[i];
		sum += L[i];
		if (sum <= X)ans++;
	}

	cout << ans+1 << endl;
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, A, B;
    ll passed = 0;
    ll rank = 0;
    string S;
    cin >> N >> A >> B >> S;
    for(ll i = 0;i < N;i++) {
        char c = S[i];
        if(c != 'c') {
            if(A + B > passed) {
                if(c == 'a' || (c == 'b' && rank++ < B)) {
                    passed++;
                    cout << "Yes" << endl;
                    continue;
                }
            }
        }
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 896
MOD = 10**9 + 7

class ModInt:
    def __init__(self, x):
        if isinstance(x, ModInt):
            self.value = x.value
        else:
            self.value = x % MOD
            if self.value < 0:
                self.value += MOD
    
    def get_mod(self):
        return MOD
    
    # str関数を使用したとき
    def __str__(self):
        return str(self.value)
    
    def __int__(self):
        return self.value
    
    __index__ = __int__
    
    # print関数を使用したとき
    __repr__ = __str__

    ## 四則演算
    def __add__(self, other):
        return ModInt(self.value + ModInt(other).value)
    
    def __sub__(self, other):
        return ModInt(self.value - ModInt(other).value)

    def __mul__(self, other):
        return ModInt(self.value * ModInt(other).value)
    
    def __truediv__(self, other):
        # a * a^(p - 2) ≡ 1 (mod p) 逆元から求める
        return ModInt(self.value * pow(ModInt(other).value, MOD - 2, MOD))

    # 累乗
    def __pow__(self, other):
        return ModInt(pow(self.value, ModInt(other).value, MOD))

    ## 四則演算の順序
    __radd__ = __add__

    def __rsub__(self, other):
        return ModInt(other - self.value)
    
    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.value, MOD - 2, MOD))

    def __rfloordiv__(self, other):
        return ModInt(other // self.value)
    
    # 累乗の順序
    def __rpow__(self, other):
        return ModInt(pow(other, self.value, MOD))
    
    ## 不等号
    def __lt__(self, other):
        return self.value < ModInt(other).value
    
    def __gt__(self, other):
        return self.value > ModInt(other).value

    def __le__(self, other):
        return self.value <= ModInt(other).value
    
    def __ge__(self, other):
        return self.value >= ModInt(other).value
    
    def __eq__(self, other):
        return self.value == ModInt(other).value
    
    def __ne__(self, other):
        return self.value != ModInt(other).value
    
    ## in-place 演算子(+=, -=, *=, /=)
    def __iadd__(self, other):
        self.value += ModInt(other).value
        if self.value >= MOD:
            self.value -= MOD
        return self.value
    
    def __isub__(self, other):
        self.value -= ModInt(other).value
        if self.value < 0:
            self.value += MOD
        return self.value
    
    def __imul__(self, other):
        self.value = ModInt(self.value * ModInt(other).value)
        return self.value

    def __itruediv__(self, other):
        self.value = ModInt(self.value * pow(ModInt(other).value, MOD - 2, MOD))
        return self.value
    
    # 逆元
    def modinv(self):
        return ModInt(pow(self.value, MOD - 2, MOD))
    
N, K = map(ModInt, map(int, input().split()))

ans = ModInt(0)
for i in range(K, N + 2):
    res_min = ModInt( int(i * (i - 1) / 2) )
    res_max = ModInt( int(i * (N + (N - i + 1)) / 2) )
    
    ans += res_max - res_min + 1

print(ans)

Measured memory_bytes: 69852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,m; cin>>n>>m;
  vector<vector<ll>> t(100010);
  rep(i, n) {
    ll a,b; cin>>a>>b;
    t[a].push_back(b);
  }
  ll ans = 0;
  priority_queue<ll> q;
  for (int i=1; i<=m; i++) {
    for (auto v:t[i]) q.push(v);
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    char a[2];
    cin >> a[0] >> a[1];
    for(int i=0; i<2; i++){
        if(a[i]=='H') a[i]=1;
        else a[i]=-1;
    }
    if(a[0]*a[1] == 1){
        cout << "H" << endl;
    }else{
        cout << "D" << endl;
    }
    return 0;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      EzDeque<String> edq = new EzDeque<>(q, "");

      String[] query;
      int op,accessWay,index;
      for ( int i=0; i<q; i++ ){
        query = br.readLine().split(" ");
        op  = Integer.parseInt(query[0]);

        switch( op ) {
          case 0 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              edq.addFirst(query[2]);
            else
              edq.addLast(query[2]);
            break;
          case 1 :
            System.out.println( edq.get(Integer.parseInt(query[1])) );
            break;
          case 2 :
            accessWay = Integer.parseInt(query[1]);
            if ( accessWay == 0 )
              edq.removeFist();
            else
              edq.removeLast();
            break;
          default:
        }
      }
    }
  }
}

class EzDeque<E> {

  private Object[] array;
  private int iHead;
  private int iTail;

  public EzDeque(int size, E init) {
    array = new Object[size*2];
    Arrays.fill(array, init);
    iHead = iTail = size;
  }

  public void addFirst(E val) {
    array[iHead--] = val;
  }
  public void addLast(E val) {
    array[++iTail] = val;
  }
  public void removeFist() {
    iHead++;
  }
  public void removeLast() {
    iTail--;
  }
  @SuppressWarnings("unchecked")
  public E get(int index) {
    index += (iHead+1);
    return ( E ) array[index];
  }
}


Measured memory_bytes: 124096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll modpow(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=modpow(a,b/2,p);
		return t*t%p;
	}
	return a*(modpow(a,b-1,p))%p;
} 
//cout << fixed << setprecision(桁数);
//__builtin_popcount()
signed main(){
	ll n,c,k; cin>>n>>c>>k;
	vl vec(n);
	rep(i,0,n) cin>>vec[i];
	sort(all(vec));
	vec.push_back(MOD*10);
	ll ans=0;
	ll memo=0;
	rep(i,0,n+1){
		if(vec[memo]+k<vec[i]){
			memo=i;
			++ans;
		}
		if(i-memo>=c)memo+=c,++ans;
	}
	cout<<ans<<endl;
		
	return 0;
}


Measured memory_bytes: 4792
#include<stdio.h>

int main(){
  int N,i,j=0,k=0;
  
  scanf("%d",&N);
  
  int V[N];
  int C[N];
  
  for(i=0;i<N;i++)
    scanf("%d ",&V[i]);
  for(i=0;i<N;i++)
    scanf("%d ",&C[i]);
  
  for(i=0;i<N;i++){
    if(V[i] > C[i]){
      j+=V[i];
      k+=C[i];
    }
  }
  printf("%d\n",j-k);
  return 0;
}
  

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	//A
	/*
	public static void main(String[] args){
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(Math.min(N*A,B));
	}
	**/

	//B
	public static void main(String[] args){
		int N = sc.nextInt();
		String N2 = String.valueOf(N);
		int range = N2.length();
		int f = 0;
		for(int i = 0; i < range ;i++){
			f += Integer.parseInt(""+N2.charAt(i));
		}
		if(N%f == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21460
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let p: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<usize> = it.next().unwrap().chars().map(|c| c.to_digit(10).unwrap() as usize).collect();
    if p <= 10 {
        let mut ans = 0;
        let mut dp = vec![0usize; p];
        for &d in s.iter() {
            let mut next = vec![0usize; p];
            for k in 0..p {
                next[(k * 10 + d) % p] += dp[k];
            }
            next[d % p] += 1;
            dp = next;
            ans += dp[0];
        }
        println!("{}", ans);
    } else {
        let mut ans = 0usize;
        let mut now = 0;
        let mut map = std::collections::BTreeMap::new();
        *map.entry(now).or_insert(0) += 1;
        let mut mul = 1;
        for &d in s.iter().rev() {
            now = (now + mul * d) % p;
            mul = 10 * mul % p;
            let po = map.entry(now).or_insert(0);
            ans += *po;
            *po += 1;
        }
        println!("{}", ans);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 6396
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		int size = list.size();

		BigInteger base = BigInteger.ZERO;

		BigInteger loop = BigInteger.ZERO;

		for (int i = 0; i < size; i++) {
			int ki = list.get(i);
			for (int j = 0; j < i + 1; j++) {
				if (ki > list.get(j)) {
					loop = loop.add(BigInteger.ONE);
				}
			}

			for (int j = i + 1; j < size; j++) {
				if (ki > list.get(j)) {
					base = base.add(BigInteger.ONE);
					loop = loop.add(BigInteger.ONE);
				}
			}
		}

		BigInteger kk = BigInteger.valueOf(k-1l).multiply(BigInteger.valueOf(k)).divide(BigInteger.valueOf(2l));

		System.out.println(
				loop.multiply(kk).add(base.multiply(BigInteger.valueOf(k)))
						.remainder(BigInteger.valueOf(1000000007l)));
	}
}


Measured memory_bytes: 91124
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
#define min(a,b) (((a)<(b))?(a):(b))
LL num[1000000];
LL solve(LL a)
{
	LL k;
	k=0;
	while (a>0) {k+=a%10;a=a/10;}
	return k;
}
int main()
{
	LL i,j,k,a,b,c,ans;
	for (i=1;i<=200000;i++)
	{
		num[i]=solve(i);
	}
	scanf("%lld",&a);
	ans=(LL)0xFFFFFFFF;
	for (i=1;i<a;i++)
	{
		b=num[i]+num[a-i];
		ans=min(ans,b);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg int n = read();
    for (reg int i = 1; i <= 9; i++) {
        for (reg int j = 1; j <= 9; j++) {
            if (i * j == n) { puts("Yes"); return 0;}
        }
    }
    puts("No");
    return 0;
}


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

using namespace std;
const int maxn = 1010;

int n, m;
vector<int> graph[maxn];
vector< pair<int, int> > ac;
int dis[maxn], kol[maxn];
bool sel[maxn];

vector< pair<int, int> > v;
int deg[maxn];
bool check() {
    memset(deg, 0, sizeof deg);
    for (int i = 0; i < m; i++) {
        int x = ac[i].first;
        int y = ac[i].second;
        if (sel[x] && sel[y]) {
            deg[x]++, deg[y]++;
            if (max(deg[x], deg[y]) > 2) return false;
        }
    }
    return true;
}

int dfs(int x, int ds) {
    dis[x] = 2;
    kol[x] = ds;

    v.push_back(make_pair(x, ds));
    for (int i = 0; i < graph[x].size(); i++) {
        int tren = graph[x][i];
        if (dis[tren] == 0) dfs(tren, ds + 1);
        else if (dis[tren] == 2) {
            int ss = kol[tren];
            memset(sel, false, sizeof sel);
            for (int i = v.size() - 1; i >= 0; i--) {
                if (v[i].second >= ss) sel[v[i].first] = true;
                else break;
            }
            if (check()) {
                printf("%d\n", ds - ss + 1);
                for (int i = 1; i <= n; i++)
                    if (sel[i]) printf("%d\n", i);
                exit(0);
            }
        }
    }
    dis[x] = 1;
    v.pop_back();
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        graph[a].push_back(b);
        ac.push_back(make_pair(a, b));
        //graph[b].push_back(a);
    }

    for (int i = 1; i <= n; i++) {
        if (dis[i] == 0) dfs(i, 0);
    }
    printf("-1");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 1000005
#define PI 3.14159265358979323846264338327950
#define ll signed long long int
using namespace std;
ll t , n, ans = 0, k= 0;
long double a, b, c, d;


int main()
{
    FAST;
    cin >> a >> b >> c>> d;
    c += 12;
    if(d == 0){
    	d = 60;
    	c--;
	}
	
	if(c > 12){
		c -= 12;
	}
    c*= 30, c+= d/2;
    d /= 5; d*= 30;
    c = abs(c-d);
    //if(c > 180){
    //	c -= 180;
	//}
    long double ans1 = sqrt(a*a +b*b - (long double)(2*a*b*cos(c*(PI)/180)));
    cout << fixed<< setprecision(20) << ans1;
    return 0;
    
}

Measured memory_bytes: 4152
#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];

ll k[2*100000+20];
ll Acount[2*100000+20];
ll A[2*100000+20];

int main()
{

    ll N; cin >> N;

    rep(i, N){
        cin >> A[i];
        Acount[A[i]] += 1;
    }

    ll sum = 0;
    rep(i,N+1){
        ll count = Acount[i];
        if(count > 0){
            count = (count) * (count-1) / 2;
        }
        sum += count;
    }

        PRINT(sum)
    rep(i,N){
        ll count = Acount[A[i]];
        if(count == 1){
            k[i] = sum;
        }
        else{
            k[i] = sum - (count) * (count-1) / 2 + (count-1) * (count-2) / 2;
        }
        PRINT(count)
        cout << k[i] << endl;
    }

    return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<pair<int,int>>A(N);
  rep(i,N){
    int k;
    cin>>A[i].second>>A[i].first;
  }
  sort(A.begin(),A.end());
  int sum=0;
  rep(i,N){
    sum+=A[i].second;
    if(sum>A[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1792
// abc136_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((a - b) > c) {
    cout << "0" << endl;
  } else {
    cout << c - (a - b) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int M = 1e5 + 10;
int a[M];
int main() {
    int n , c , k;
    cin >> n >> c >> k;
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i];
    }
    sort(a , a + n);
    int ans = 1 , count = 0 , tim = a[0] + k;
    for(int i = 0 ; i < n ; i++) {
        if(a[i] <= tim) count++;
        if(count > c || a[i] > tim) {
            count = 1;
            tim = a[i] + k;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

  int ans = 0;
  for(int i = 1;i <= n;i+=2){
    int cnt = 0;
    for(int j = 1;j <= i;j++){
      if(i % j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,c,hako[100005],aka[100005],x,y,ans;

int main(){
    cin >> n >> m;
    for(int i=0;i<=n;i++)hako[i]=1;
    aka[1]=1;
    for(int i=0;i<m;i++){
        cin >> x >> y;
        if(aka[x]==1&&hako[x]==1){
            aka[x]--;
            hako[x]--;
            if(aka[y]==0)aka[y]++;
            hako[y]++;
        }else if(aka[x]==1&&hako[x]>1){
            aka[y]=1;
            hako[x]--;
            hako[y]++;
        }else{
            hako[x]--;
            hako[y]++;
        }

    }

    for(int i=1;i<=n;i++)if(aka[i]==1)ans++;
    cout << ans << endl;

return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
int main(){
	int n;	cin>>n;
	int s[n];
	rep(i,n)	cin>>s[i];
	int q;	cin>>q;
	int count=0,t;
	rep(i,q){
		cin>>t;
		if(binary_search(s,s+n,t))	count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1548
#include<stdio.h>
int main(void){
   int w, n, a[1000], b[1000], key[1000], p, i;
   scanf("%d %d", &w, &n);
   for(i = 0; i < w; i++){
      key[i] = i + 1;
   }
   for(i = 0; i < n; i++){
      scanf("%d,%d", &a[i], &b[i]);
      p = key[a[i]-1];
      key[a[i]-1] = key[b[i]-1];
      key[b[i]-1] = p;
   }
   for(i = 0; i < w; i++){
      printf("%d\n", key[i]);
   }
   return 0;
}

Measured memory_bytes: 1800
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	for (int i = 0; i < 9; ++i) {
		string st; cin >> st;
		int a, b; cin >> a >> b;
		cout << st << " "<<a + b <<" "<< a * 200 + b * 300 << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include <stdio.h>
int main(void){
  int N;
  int i;
  int s=0;
  
  scanf("%d",&N);
  int n=N;
  for(i=0;i<8;i++){
    int a;
    a=n%10;
    n=n/10;
    s=s+a;
  }
  
  if(N%s==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1704
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    from collections import Counter

    n = int(readline())
    a = list(map(int, readline().split()))
    ans = sum(a)
    counter = Counter(a)
    q = int(readline())
    for _ in range(q):
        b, c = map(int, readline().split())
        ans += (c - b) * counter[b]
        counter[c] += counter[b]
        counter[b] = 0
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89156
#define D 1000000007
#define M 100002
char s[M],t[M];
int  N,i,c[128];
int main()
{
	scanf("%d%s%s",&N,s,t);
	for(c[s[0]]=1,N--,i=1;i<N;i++){
		c[s[i]]+=c[t[i]];
		c[s[i]]-=c[s[i]]>=D?D:0;
	}
	printf("%d\n", c[t[N]]);
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=1e3+10,M=1e9+7;
int h,w;
int mod(int a,int M){int ret=a%M;if(ret<0)ret+=M;return ret;}
int dp[mxN][mxN];
char matriz[mxN][mxN];
int solve(int a,int b){
    if(matriz[a][b]=='#')return 0;
   if(dp[a][b]>=0)return dp[a][b];
   if(a==0 && b==0)return dp[a][b]=1;
   if(a==0)return dp[a][b]=mod(solve(a,b-1),M);
   if(b==0)return dp[a][b]=mod(solve(a-1,b),M);
   return dp[a][b]=mod(solve(a-1,b)+solve(a,b-1),M);

}
// LONG LONG CASE
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>matriz[i][j];
        }
    }
    
    solve(h-1,w-1);
    cout<<dp[h-1][w-1];
    
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int A = scanner.nextInt();
        int r = N % 500;
        if (r > A) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int x=0;
  int a=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    else x--;
    a=max(a,x);
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256