akhauriyash/Code-Regression huggingface dataset:
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int compare(const void *a, const void *b)
{
    return *(int *) b - *(int *) a;
}

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);
    int dd[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", dd + i);
    }
    qsort(dd, n, sizeof(int), compare);
    int h = 0;
    int p = 101;
    for (int i = 0; i < n; i++) {
        if (p == dd[i]) continue;
        h++;
        p = dd[i];
    }
    printf("%d\n", h);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string num;
  char a;
  int sum = 0;
  cin >> num;
  for(int i = 0; i < num.size(); i++) sum += ((int)num[i] - (int)'0');
  if(stoi(num) % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> tower(N);
  for (int i=0;i<N;i++){
    cin >> tower.at(i);
  }
  int Total=0;
  for(int i=1;i<101;i++){
    int Reach = 1;
    for(int j=0;j<N;j++){
      if (i <= tower.at(j)){
        if(Reach){
        Total++;
        Reach = 0;
        }
      }
      else{
        Reach = 1;
      }
    }
  }
  cout << Total <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

	int	s;
	int	hh, mm, ss;

	scanf("%d", &s);
	hh = s / 3600;
	mm = (s % 3600) / 60;
	ss = s % 60;

	printf("%d:%d:%d\n",hh, mm, ss);

	return 0;
}

Measured memory_bytes: 1020
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header


signed main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N;
    vector<int> G[100010];

    cin >> N;
    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    const auto bfs = [&](int src) {
        vector<int> dist(N+1, INF);
        queue<int> que;

        dist[src] = 0;
        que.emplace(src);

        while(que.size()) {
            const int u = que.front(); que.pop();
            for (const int nxt : G[u]) {
                if (chmin(dist[nxt], dist[u] + 1)) {
                    que.emplace(nxt);
                }
            }
        }

        return dist;
    };

    const auto &dist_1 = bfs(1);
    const auto &dist_N = bfs(N);

    int fennec = 0;
    int snuke = 0;

    reps(u, 1, N) {
        if (dist_1[u] <= dist_N[u]) {
            ++fennec;
        } else {
            ++snuke;
        }
    }

    trace(fennec, snuke);

    cout << (fennec > snuke ? "Fennec" : "Snuke") << endl;


    return 0;
}


Measured memory_bytes: 6656
package main

import (
  "fmt"
  "sort"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }
  sort.Sort(sort.Reverse(sort.IntSlice(a)))
  alice, bob := 0, 0
  for i, v := range a {
    if i%2 == 0 {
      alice += v
    } else {
      bob += v
    }
  }
  fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  int n,k;cin >> n >> k;
  map<int, int> mp;
  for(int i = 0; i < n; ++i){
    int a;cin >> a;
    ++mp[a];
  }
  vector<int> a;
  for(auto it : mp){
    a.push_back(it.second);
  }
  sort(a.begin(), a.end(), greater<int>());
  int ans = 0;
  for(int i = 0; i < min(k, (int)a.size()); ++i){
    ans+=a[i];
  }
  cout << n-ans << endl;
}


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

int main(void){
    
    //入力
    long long N;
    cin >> N;
    
    //最小の乗員数を取得
    long long min_crew_num = 10000000000000000;
    for (int i = 0; i < 5; i++){
        long long crew_num;
        cin >> crew_num;
        min_crew_num = min(min_crew_num, crew_num);
    }
    
    //人数が最小の乗員数以下にばらけるまでの時間を求め、それに４を足す
    long long ans = (N + min_crew_num - 1) / min_crew_num + 4;
    
    //出力
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    N,P = map(int,input().split())
    A = list(map(int,input().split()))
    num1 = 0
    num0 = 0
    for i in range(N):
        tmp = A[i]%2
        if tmp == 0:
            num0 += 1
        else:
            num1 += 1
    #print(num1,num0)
    ans2 = 0
    for i in range(num0+1):
        ans2 += comb(num0,i)

    if P == 1:
        syo = num1//2
        amari = num1%2
        tmp = syo + amari
        i = 1
        ans = 0
        for j in range(tmp):
            ans += comb(num1,i)
            i += 2


        ans = ans*ans2
        return ans

    else:
        syo = num1//2
        tmp = syo+1
        i = 0
        ans = 0
        #print(tmp)
        for j in range(tmp):
            #print(i,num1)
            if i == 0:
                ans += 1
                i += 2
            else:
                ans += comb(num1,i)
                i += 2

        ans = ans*ans2
        return ans

#print(comb(3,2))
print(main())


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

using namespace std;

#define fo(i,CApiTaL_N) for(int i=0; i<CApiTaL_N; i++)
#define Fo(i,k,CApiTaL_N) for(int i=k; i<CApiTaL_N; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int t=1;
const int mxN=1e5;
int n;
vi a(mxN+1), b(mxN+1), c(mxN+1);
vvi dp(mxN+1,vi(3));

void test_case(){
    cin>>n;
    Fo(i,1,n+1){
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][0]=a[1];dp[1][1]=b[1];dp[1][2]=c[1];
    Fo(i,2,n+1){
        fo(j,3){
            dp[i][j]=max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3])+(j ? (j==1 ? b[i] : c[i]) : a[i]);
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
}

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

    // cin>>t;
    while(t--){
        test_case();
    }
    
    return 0;
}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int n;
    cin >> n;
    printf("%.10lf", 2*n*acos(-1));

    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int N,M;

void i_to_array(int x,int a[]){
    for(int i=0;i<N;i++){
        a[i]=x/(int)pow(10,N-1-i);
        x-=a[i]*(int)pow(10,N-1-i);
    }
    return;
}

int main(){    
    cin >>N>>M;
    int s[6],c[6];
    for(int i=0;i<M;i++)cin >> s[i] >>c[i];
    
    int a[3]={-1,-1,-1};
    int max_N=1,min_N;
    for(int i=0;i<N;i++)max_N *= 10;
    if(N==1)min_N=0;
    else {min_N=max_N/10;}

    int ans=-1;
    bool check=true;
    for(int i=min_N;i<max_N;i++,check=true){ 
        i_to_array(i,a);
        for(int j=0;j<M;j++){
            if(a[s[j]-1]!=c[j])check=false; 
        }
        if(check){
            ans=i;
            break;
        }    
    }

    //出力
    cout<< ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int search(string, char);

int main()
{
	string w;
	unsigned int i;
	cin >> w;
	int can=1;
	for (i = 0; i<w.size(); i++) {
		if (search(w, w[i]) % 2 == 0) {
			can = can*1;
		}
		else
		{
			can = 0;
		}

	}
	if (can==1) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
    return 0;
}

int search(string str, char one_char) {
	unsigned int i;
	int num = 0;

	for (i = 0; i<str.size(); i++) {
		if (str[i] == one_char) {
			num++;
		}
	}
	return num;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	rep(i, 0, n) {
		sll(num);
		if((num % 2 == 0) && (num % 3 != 0 && num % 5 != 0)) {
			puts("DENIED");
			return 0;
		}
	}
	puts("APPROVED");
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = sorted(map(int, input().split()))
ans = 0
for i in range(N):
    if x >= a[i]:
        ans += 1
        x -= a[i]
    else:
        break
    if i == N - 1:
        if x != 0:
            ans -= 1
print(ans)

Measured memory_bytes: 38288
a = [0]
n = 0

def main():
    global n
    for s in input():
        if s == "<":
            nproc()
            a.append(a[-1]+1)
        else:
            n += 1
    nproc()
    print(sum(a))

def nproc():
    global n, a
    if n > 0 and n > a[-1]:
        a[-1] = n
    for i in list(range(n))[::-1]:
        a.append(i)
    n = 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 34544
#include <stdio.h>
using namespace std;

int main(){
    int a,b,c,min,max;
    scanf("%d %d %d", &a,&b,&c);
    min=a;
    max=a;
    if(min>b){
        min=b;
    }
    if(min>c){
        min=c;
    }
    if(max<b){
        max=b;
    }
    if(max<c){
        max=c;
    }
    printf("%d %d\n",min,max);
    return 0;
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //memset(brr,-1,sizeof(brr));
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>k;
         rep(i,0,49)arr[i]=49+k/50;
         rep(i,0,k%50-1)arr[i]++;
         rep(i,k%50,49) arr[i]-=k%50;
         cout<<50<<"\n";
         rep(i,0,49)cout<<arr[i]<<" ";
     }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                                                      
                                                                                                         
int main(void) {                                                                                         
  int a[3];                                                                                              
  std::cin >> a[0] >> a[1] >> a[2];                                                                      
  int A[3];                                                                                              
                                                                                                         
  for(int i = 0; i < 3; i++) {                                                                           
    if(i+1 < 3) {                                                                                        
      A[i] = a[i] - a[i + 1];                                                                            
    }                                                                                                    
    else {                                                                                               
      A[i] = a[i] - a[i - 2];                                                                            
    }                                                                                                    
  }                                                                                                      
  for(int i = 0; i < 3; i++) {                                                                           
    if(A[i] < 0) {                                                                                       
      A[i] = A[i] * -1;                                                                                  
    }                                                                                                    
  }                                                                                                      
  int max = 0;                                                                                           
  for(int i = 0; i < 3; i++) {                                                                           
    if(A[i] > max) {                                                                                     
      max = A[i];                                                                                        
    }                                                                                                    
  }                                                                                                      
  std::cout << max << std::endl;                                                                         
  return 0;                                                                                              
}                   

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

using namespace std;

int main() {
	string s; cin >> s;
	if (s == "SUN") cout << 7;
	else if (s == "MON") cout << 6;
	else if (s == "TUE") cout << 5;
	else if (s == "WED") cout << 4;
	else if (s == "THU") cout << 3;
	else if (s == "FRI") cout << 2;
	else cout << 1;
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		PRIN;
	}
	else if (a == b || b == c || c == a) {
		PRIY;
	}
	else PRIN;
	return 0;
}

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

int main()
{
    ll a, b, k;

    cin >> a >> b >> k;

    if(a >= k)
    {
        cout << a - k << " " << b << endl;
    }
    else if (a + b >= k)
    {
        cout << 0 << " " << b - (k - a) << endl;
    }
    else
    {
        cout << 0 << " " << 0 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


int main() {
  int N, M; cin >> N >> M;

  int n[N];

  rep(i, N) n[i] = -1;
  rep(i, M) {
    int s, c;
    cin >> s >> c;
    --s;
    if (n[s] == -1)
      n[s] = c;
    else if (n[s] != c) {
      cout << "-1\n";
      return 0;
    }
  }
  if (n[0] == 0 && N > 1) {
    cout << "-1\n";
    return 0;
  }
  if (n[0] == -1)
    n[0] = (N == 1 ? 0 : 1);
  rep(i, N) {
    if (n[i] == -1)
      n[i] = 0;
    cout << n[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= putStrLn . which "ABD" "ABC" . ( 1000 <= )

Measured memory_bytes: 508
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
ll n,a,b;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n>>a>>b;
	if ((a+b)%2==0) cout<<abs(a-b)/2;
	else
	{
		cout<<min(a+b,(n-a+1)+(n-b+1))/2;
	}
}





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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 a,b;
	cin >> a >> b;
	i64 sum = 0;
	FOR(i, 1, b-a)
	{
		sum += i;
	}
	cout << (sum - a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// #include <boost\version.hpp>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 1145141919
#define MINF -1145141919

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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



int main() {
	int n;
	bool yattaze = false;
	cin >> n;
	string a;
	a = to_string(n);
	FOR(i, 0, a.length()) {
		if (a[i] == '9') {
			yattaze = true;
		}
	}
	if (yattaze) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return	0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

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

int main()
{
    map<string, int> worm;
    queue<string> que;
    string chars = "rgb";
    REP(i, 2, 11){
        for (char c : chars) {
            worm[string(i,c)] = 0;
            que.push(string(i,c));
            while (!que.empty()) {
                string s = que.front(); que.pop();
                rep(j, s.length()-1){
                    if (s[j] != s[j+1])
                        continue;
                    rep(k, 3){
                        if (s[j] == chars[k]) {
                            REP(l, k+1, k+3){
                                REP(m, k+1, k+3){
                                    if (l != m) {
                                        string p = s;
                                        p[j] = chars[l%3];
                                        p[j+1] = chars[m%3];
                                        if(!EXIST(worm, p) || worm[p] > worm[s]+1){
                                            que.push(p);
                                            worm[p] = worm[s] + 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    string input;
    while (cin >> input, input != "0") {
        if (EXIST(worm, input))
            cout << worm[input] << endl;
        else
            cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 9484
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	ll fac[N],facinv[N];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD; }
	void main()
	{
		fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
		facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;
		int l1=qread(),l2=qread(),r1=qread(),r2=qread();ll ans=0;
		//fo(i,l1,r1) fo(j,l2,r2) add(ans, C(i+j,j) );
		fo(i,l1,r1) add(ans, C(i+r2+1,i+1) ),add(ans, MOD-C(i+l2,i+1) );
		write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 31488
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

const int INF = 20000000;

void dfs(int v, int p, vector<int> &dist, vector<int> G[]) {
  if (dist[v] != INF) return;
  if (p != -1) dist[v] = dist[p] + 1;
  else dist[v] = 0;
  for (auto&u: G[v]) {
    if (u == p) continue;
    dfs(u, v, dist, G);
  }
}

void solve(int n, int s, int t, vector<int> &fromS, vector<int> fromT, vector<int> G[]) {
  vector<bool> done(n, false);
  priority_queue<pair<int, int> > Qs, Qt;
  Qs.push({ fromT[s], s });
  Qt.push({ fromS[t], t });
  while (Qs.size() and Qt.size()) {
    auto qs = Qs.top(); Qs.pop();
    while (done[qs.second] and Qs.size()) {
      qs = Qs.top(); Qs.pop();
    }
    if (done[qs.second]) {
      print("Snuke");
      return;
    }
    done[qs.second] = true;
    
    auto qt = Qt.top(); Qt.pop();
    while (done[qt.second] and Qt.size()) {
      qt = Qt.top(); Qt.pop();
    }
    if (done[qt.second]) {
      print("Fennec");
      return;
    }
    done[qt.second] = true;
    
    // print("Fennec", " ");
    // print(qs.second+1);
    // print("Snuke", " ");
    // print(qt.second+1);
    {
      for (auto &&u: G[qs.second]) {
        if (done[u]) continue;
        Qs.push({ -fromT[u], u }); // Tに近い方から取る.
      }
    }
    {
      for (auto &&u: G[qt.second]) {
        if (done[u]) continue;
        Qt.push({ -fromS[u], u }); // Sに近い方から取る.
      }
    }
  }
  
  if (Qs.size()) print("Fennec");
  else print("Snuke");
}

int main() {
  int n;in(n);
  vector<int> G[n];
  loop(i,0,n-1) {
    int a, b; in(a),in(b);
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int s = 0, t = n-1;
  vector<int> fromS(n, INF), fromT(n, INF);
  dfs(s, -1, fromS, G);
  dfs(t, -1, fromT, G);
  
  solve(n, s, t, fromS, fromT, G);
  return 0;
  
  int cnt = 0;
  loop(i,0,n) {
    // TよりもSに近いところはFが取れる.
    cnt += fromS[i] <= fromT[i];
  }
  if (cnt >= (n + 2) / 2) print("Fennec");
  else print("Snuke");
  return 0;
}


Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector<ll> v;

    rep(i, n) {
        ll vi;
        cin >> vi;
        v.push_back(vi);
    }
    ll Max = -LINF;
    for (int k = 0; k <= K; ++k) {

        for (int re = 0; re <= k / 2; ++re) {

            if (k - re >= n) {
                vector<ll> negative;
                ll sum = 0;

                rep(i, n) {
                    sum += v[i];
                    if (v[i] < 0) negative.push_back(abs(v[i]));
                }
                sort(all(negative));
                reverse(all(negative));
                rep(i, min(re, (int) negative.size())) sum += negative[i];
                Max = max(Max, sum);
                continue;
            }

            for (int l = 0; l <= k - re; ++l) { //左からとる数
                vector<ll> negative;
                ll sum = 0;

                rep(i, min(l, n)) { //左
                    sum += v[i];
                    if (v[i] < 0) negative.push_back(abs(v[i]));
                }
                for (int i = n - 1, c = 0; c < min((k - re) - l, n); --i, ++c) {
                    sum += v[i];
                    if (v[i] < 0) negative.push_back(abs(v[i]));
                }
                sort(all(negative));
                reverse(all(negative));
                rep(i, min(re, (int) negative.size())) sum += negative[i];
                Max = max(Max, sum);
            }
        }


    }



    cout << Max << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
 
using namespace std;
 
int main() {
	// 入力
    int a, b;
    cin >> a >> b;
    int m[13];
    for (int i = 1; i <= 13; ++i) m[i] = 31;
    m[2] = 28;
    m[4] = 30;
    m[6] = 30;
    m[9] = 30;
    m[11] = 30;
    
    //cout << m[1] << endl;
    int count = 0;
    for (int i = 1; i <= a; ++i) { // i 月
        if(i != a) {
            for (int j = 1; j <= m[i]; ++j) { // j 日
            	if (j==i){
            	    ++count;
            	    //cout << i << "m " << j << "d" << endl;      
            	}
            }
        }
        else {
            for (int j = 1; j <= b; ++j) {
            	if (j==i){
            	    ++count;
            	    //cout << i << "m " << j << "d" << endl;      
            	}
            }
        }
    }
 
	//出力
    cout << count << endl;
}

Measured memory_bytes: 256
s = input()
s8=[]

def cal(p,n):
	if n==0:
		s8.append(p)
	else:
		cal(p[:n] + '+' + p[n:],n-1)
		cal(p[:n] + '-' + p[n:],n-1)

cal(s,len(s)-1)
for ss in s8:
	if eval(ss)==7:
		print(ss+'=7')
		exit()

Measured memory_bytes: 3060
import collections 
n,k = map(int, raw_input().split(' '))

left = n % k
cc = [0] * k
for ii in range(k):
	cc[ii] += n / k
	if 0<ii <= left:
		cc[ii] += 1


r = 0
for ii in range(len(cc)):
	if (- 2*ii) % k == 0:
		r += cc[ii] * ((cc[(k - ii) % k ]) ** 2) 

print r

Measured memory_bytes: 70428
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s, t, u;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  cin >> u;
  if(s==u){
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define dbg(x) cerr << #x << ":" << x << " "
#define dbgl(x) cerr << #x << ":" << x << "\n"
#define dbgv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vi P(N); rep(i, N) cin >> P.at(i);
	vi Q(N); rep(i, N) cin >> Q.at(i);
	vi A(N); rep(i, N) A.at(i) = i + 1;
	int i = 1, a = 0, b = 0;
	do {
		// dbgv(A); dbgl(i);
		if (P == A) a = i;
		if (Q == A) b = i;
		// dbg(a); dbgl(b);
		i++;
	} while (next_permutation(all(A)));
	cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
def cmb(n,r):#r==2固定
    return n*(n-1)//2

def main():
    import sys
    from collections import defaultdict

    N=int(sys.stdin.readline())
    AL=list(map(int,sys.stdin.readline().split()))
    dic=defaultdict(int)
    for a in AL:
        dic[a]+=1


    K=[cmb(v,2) for k,v in dic.items()]
    total=sum(K)

    for i in range(N):
        a=dic[AL[i]]
        print(total-cmb(a,2)+cmb(a-1,2))

main()


Measured memory_bytes: 25908
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
lli gcd(lli num1, lli num2){
  return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  string S,OP1,OP2,OP3;
  cin >> S;
  A=stoll(S.substr(0,1));
  B=stoll(S.substr(1,1));
  C=stoll(S.substr(2,1));
  D=stoll(S.substr(3,1));
  N=7-A;
  if(B+C+D==N)cout<< A << '+' << B <<'+' << C << '+' << D << "=7" << endl;
  else if(B+C-D==N)cout<< A << '+' << B <<'+' << C << '-' << D << "=7" << endl;
  else if(B-C-D==N)cout<< A << '+' << B <<'-' << C << '-' << D << "=7" << endl;
  else if(-B-C-D==N)cout<< A << '-' << B <<'-' << C << '-' << D << "=7" << endl;
  else if(B-C+D==N)cout<< A << '+' << B <<'-' << C << '+' << D << "=7" << endl;
  else if(-B-C+D==N)cout<< A << '-' << B <<'-' << C << '+' << D << "=7" << endl;
  else if(-B+C+D==N)cout<< A << '-' << B <<'+' << C << '+' << D << "=7" << endl;
  else if(-B+C-D==N)cout<< A << '-' << B <<'+' << C << '-' << D << "=7" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;


int main(){


    string S; cin >> S;
    vector<vector<ull>> dp(S.size() + 1, vector<ull>(13));
    dp[0][0] = 1;

    rep(i, S.size()){
        int c;
        if(S[i] == '?')c = -1;
        else c = S[i] - '0';
        rep(j, 10){
            if(c != -1 && c != j)continue;
            rep(ki, 13){
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }
        rep(j, 13)dp[i + 1][j] %= mod;
    }


    cout << dp[S.size()][5];


    return 0;
}

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

int main() {
  int A, B, C, x ;
  x = 0;
  cin >> A >> B >> C;
  for(int i=0; i<C+1; i++){
    if(A<=B && x<C){
      B -= A ;
      x++ ;
    }
    else{
      cout << x << endl;
      break;
    }
  }
}

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

long long n;
vector<long long> v;

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i];

  for(int i = 0; i < n; ++i) {
    if(i != 0) cout << " ";
    cout << v[n - 1 - i];
  }
  cout << endl;

  return 0;
}


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

int main(void)
{
  int N, M;
  cin >> N >> M;
  int c[100] = {};
  int a, b;
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    c[a]++;
    c[b]++;
  }
  for (int i = 1; i <= N; i++)
  {
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void) {
  
	string s;
	cin >> s;
	sort(s.begin(), s.end());
  
	if (s.at(0) == 'a' && s.at(1) == 'b' && s.at(2) == 'c') cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<cstring>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

int main(){
	int n;
	LL a,b,c,d;
	scanf("%d%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	bool ans=0;
	n--;
	fo(i,0,n)
	if (b>=a+1ll*i*c-1ll*(n-i)*d&&b<=a+1ll*i*d-1ll*(n-i)*c){
		ans=1;
		break;
	}
	if (ans)printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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

        List<Integer> list = new ArrayList<>(N);

        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }

        int standard = calculationStandard(list);

        System.out.println(calsulationResult(list, standard));
    }

    private static int calculationStandard(List<Integer> list) {
        int SUM = 0;
        for (int number : list) {
            SUM += number;
        }

        int quotient = SUM / list.size();
        int surplus = SUM % list.size();

        if (surplus >= list.size() / 2.0) {
            quotient++;
        }

        return quotient;
    }

    private static int calsulationResult(List<Integer> list, int standard) {
        int result = 0;
        for (int i : list) {
            result += (i - standard) * (i - standard);
        }

        return result;
    }
}

Measured memory_bytes: 9812
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, long long A, long long B, long long C, long long D, string S){
  A--; B--; C--; D--;
  if (D > C) {
    for (int i = A; i < C; i++) {
      if (S[i] == '#' && S[i+1] == '#') {
        std::cout << "No" << std::endl;
        return;
      }
    }
    for (int i = B; i < D; i++) {
      if (S[i] == '#' && S[i+1] == '#') {
        std::cout << "No" << std::endl;
        return;
      }
    }
    std::cout << "Yes" << std::endl;
    return;
  } else {
    bool flag = false;
    for (int i = A; i < C; i++) {
      if (S[i] == '#' && S[i+1] == '#') {
        std::cout << "No" << std::endl;
        return;
      }
    }
    for (int i = B; i < D; i++) {
      if (S[i] == '#' && S[i+1] == '#') {
        std::cout << "No" << std::endl;
        return;
      }
    }
    for (int i = B-1; i < D; i++) {
      if (S[i] == '.' && S[i+1] == '.' && S[i+2] == '.') {
        flag = true;
      }
    }
    if (flag) {
      std::cout << "Yes" << std::endl;
      return;
    } else {
      std::cout << "No" << std::endl;
      return;
    }
  }
}

int main(){
  long long B;
  string S;
  long long C;
  long long D;
  long long A;
  long long N;
  scanf("%lld",&N);
  scanf("%lld",&A);
  scanf("%lld",&B);
  scanf("%lld",&C);
  scanf("%lld",&D);
  cin >> S;
  solve(N, A, B, C, D, S);
  return 0;
}


Measured memory_bytes: 888
n, m = map(int, input().split())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ab.sort()
money = 0
i = 0
while m > 0:
    money += ab[i][0] * min(ab[i][1], m)
    m -= ab[i][1]
    i += 1
print(money)

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

int main() {
  int n,sum = 0;
  cin >> n;
  vector<int> w(n);
  rep(i,n) {
    cin >> w[i];
    sum += w[i];
  }
  int ans = sum;
  rep(i,n) {
    sum -= 2*w[i];
    if(sum < 0) ans = min(ans,-sum);
    else ans = min(ans,sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {

		Scanner scanner = new Scanner(System.in);// ??\?????????????????????
		
		int num01 = scanner.nextInt();
		int num02 = scanner.nextInt();
		int min = Math.min(num01, num02);
		int max = Math.max(num01, num02);
		int gcd = 1;// ?????§??¬?´???°???????´????????????°
		int surplus = 1;
		
		while(true){
			surplus = max % min;
			max = min;
			min = surplus;
			if(surplus == 0){
				break;
			}
		}
		System.out.println(max);// ?????§??¬?´???°?????????
	}
}

Measured memory_bytes: 26332
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < q; i++) {
		    arr[sc.nextInt() - 1]++;
		}
		StringBuilder sb = new StringBuilder();
		for (int x : arr) {
		    if (x + k - q > 0) {
		        sb.append("Yes");
		    } else {
		        sb.append("No");
		    }
		    sb.append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 50568