akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    
    double max_conc = 0.0;
    lint max_sugar = 0;
    lint max_water = 0;
    
    auto search = [&](lint i, lint j) {
        double conc;
        lint sugar = 0;
        lint soluble = (a * i + b * j) * e;
        soluble = min(soluble, f - (100 * a * i + 100 * b * j));
        if (soluble == 0) return tuple<double, lint> {0.0, 0};
        
        repeat_to(x, soluble / c) {
            sugar = max(sugar, c * x + d * ((soluble - c * x) / d));
        }
        lint water = 100 * a * i + 100 * b * j;
        conc = (double)(sugar) / (water + sugar);
        return tuple<double, lint> {conc, sugar};
    };
    
    repeat_to(i, 30) {
        repeat_to(j, 30) {
            double conc;
            lint sugar;
            lint water = i * a * 100 + j * b * 100;
            if (water > f) continue;
            
            tie(conc, sugar) = search(i, j);
            if (water + sugar > f) continue;
            
            if (conc > max_conc) {
                max_conc = conc;
                max_sugar = sugar;
                max_water = water;
            }
        }
    }
    if (max_water == 0) max_water = a * 100;
    cout << max_sugar + max_water << " " << max_sugar << endl;
}

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype>  // isupper, islower, isdigit, toupper, tolower
#include <cmath>   // abs, sin, cos, tan
#include <ctime>   // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n, r; cin >> n >> r;
  if(n >= 10) fin(r);
  else fin(r + 100 * (10 - n));
  return;
}

//前処理
int main()
{
  int ti = clock();
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
  return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


void solve(int testCase){

    int n , k;
    scanf("%d %d" , &n , &k);

    vi a(n) , win(k+1);

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

    for(int i = 0 ; i <= k ; i ++){
            for(int j = 0 ; j < n ; j ++){
                    if(i - a[j] >= 0){
                            win[i] |= (!win[i - a[j]]);
                    }
            }
    }

    printf("%s\n" , win[k] ? "First" : "Second");

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> buka(N,0);
    int a;
    for(int i=1; i<N; i++){
        cin >> a;
        buka.at(a-1)++;
    }
    for(int i=0; i<N; i++){
        cout << buka.at(i) << endl;
    }
}

Measured memory_bytes: 4056
from collections import Counter
from math import gcd

class Prime:
    def __init__(self, N):
        smallestPrime = [1] * (N + 1)
        primes = []

        for i in range(2, N + 1):
            if smallestPrime[i] != 1:
                continue
            primes.append(i)
            for p in range(i * 2, N + 1, i):
                if smallestPrime[p] == 1:
                    smallestPrime[p] = i

        self.smallestPrime = smallestPrime
        self.primes = primes

    def isPrime(self, n):
        return n > 1 and self.smallestPrime[n] == 1

    def factorization(self, n):
        ret = Counter()
        while True:
            p = self.smallestPrime[n]
            if p == 1:
                break
            ret[p] += 1
            n //= p
        if n > 1:
            ret[n] += 1
        return ret

N = int(input())
A = list(map(int, input().split()))
prime = Prime(max(A) + 100)

def isSetwise(A):
    ret = A[0]
    for a in A:
        ret = gcd(ret, a)
    return ret == 1

def isPairwise(A):
    cnt = Counter()
    for a in A:
        for p in prime.factorization(a):
            if cnt[p] >= 1:
                return False
            cnt[p] += 1
    return True

if not isSetwise(A):
    print('not coprime')
elif isPairwise(A):
    print('pairwise coprime')
else:
    print('setwise coprime')


Measured memory_bytes: 187208
#include <iostream>
using namespace std;
#define ll long long
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}

ll sep(int a, int b){
    ll pre=1<<30,a1,a2;
    for(ll i=1;i<a;i++){
        a1=max(llabs(b*i-b*((a-i)/2)),llabs(b*i-b*(a-i-(a-i)/2)));
        a2=max(llabs(b*i-(a-i)*(b/2)),llabs(b*i-(a-i)*(b-b/2)));
        a1=min(a1,a2);
        if(pre>a1){
            pre=a1;
        }
    }
    return pre;
}

int main(void){
    ll h,w,a1,a2;
    cin>>h>>w;
    a1=sep(h,w);
    a2=sep(w,h);
    cout<<(a1<a2?a1:a2);
}


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

const ll mod = 1e9 + 7;

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

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

string s, key = "keyence";

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

    cin >> s;
    int x = 0, y = 0;
    while(x < 7 && key[x] == s[x])
        x++;
    while(y < 7 && key[6 - y] == s[s.size() - 1 - y])
        y++;
    cout << (x + y >= 7 ? "YES\n" : "NO\n");
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();
        int M = in.nextInt();
        int[] values = new int[M];
        if (N >= M) {
            System.out.println("0");
            return;
        }
        for (int i = 0; i < M; i++) {
            values[i] = in.nextInt();
        }
        Arrays.sort(values);

        int[] diffs = new int[M - 1];
        for (int i = 0; i < M - 1; i++) {
            diffs[i] = values[i + 1] - values[i];
        }
        Arrays.sort(diffs);

        int ans = 0;
        for (int i = 0; i < M - N; i++) {
            ans += diffs[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 48060
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

ans=0
for i in range(1,n+1):
  A[i]+=A[i-1]


for j in range(1,m+1):
  B[j]+=B[j-1]


b_cnt=m
for a_cnt in range(n+1):
  if A[a_cnt]>k:
    continue
  while A[a_cnt]+B[b_cnt]>k:
    b_cnt-=1 

  ans=max(ans,a_cnt+b_cnt)
print(ans)

Measured memory_bytes: 39868
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n, x = il()
m = ils(n)
ans = n
x -= sum(m)
while x >= min(m):
    x -= min(m)
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

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

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

int main(){

  char s[101] = {'\0'};
  scanf("%s",s);

  int len = strlen(s);

  long long k;
  scanf("%lld",&k);

  int i = 0;
  for(i = 0; i < min(k,len) ; ++i){
    if(s[i] != '1'){
      printf("%c\n",s[i]);
      return 0;
    }
  }
  printf("1");
  return 0;

}


Measured memory_bytes: 128
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [0] * n
for i in range(n):
    b[i] = int(input())

for i in range(n):
    for j in range(3):
        for z in range(3):
            if a[j][z] == b[i]:
                a[j][z] = -1

for i in range(3):
    f = True
    for j in range(3):
        if a[i][j] != -1:
            f = False
    if f:
        print('Yes')
        exit()

for i in range(3):
    f = True
    for j in range(3):
        if a[j][i] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for i in range(3):
    if a[i][i] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for i in range(3):
    if a[i][2-i] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

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

using ll = long long;
using P = pair<int, ll>; // to, cost
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)

const ll INF = 1LL << 60;
vector<vector<P>> G;

ll d[100010];
void dfs(int v, int p, ll c) {
    d[v] = c;
    for (P& to : G[v]) if (to.first != p) {
        dfs(to.first, v, c + to.second);
    }
}

int main() {
    int n;
    cin >> n;
    G.resize(n);
    rep(i, n - 1) {
        int a, b, c; scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        G[a].push_back(P(b, c));
        G[b].push_back(P(a, c));
    }

    int q, k; cin >> q >> k;
    k--;
    dfs(k, -1, 0);

    rep(j, q) {
        int x, y; scanf("%d%d", &x, &y);
        cout << d[x - 1] + d[y - 1] << "\n";
    }

    return 0;
}

Measured memory_bytes: 14336
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Maybe
import Data.STRef
import Data.Vector.Unboxed ((!))
import qualified Data.Vector.Unboxed as U

main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.pack . show

sol v = if e then -1 else f
  where
  n = v!0
  a = U.drop 1 v
  e = isJust $ find (uncurry (>)) [(a!(i*n+j),a!(i*n+k)+a!(k*n+j)) |
    i <- [0..n-2], j <- [i+1..n-1], k <- [0..n-1], k/=i, k/=j]
  f = runST $ do
    d <- newSTRef 0
    forM_ [0..n-2] $ \i ->
      forM_ [i+1..n-1] $ \j -> do
        let e' = isNothing $ find (uncurry (==))
              [(a!(i*n+j), a!(i*n+k) + a!(k*n+j)) | k <- [0..n-1], k/=i, k/=j]
        when (e') $ modifySTRef' d (+ a!(i*n+j))
    readSTRef d

Measured memory_bytes: 8264
local r = 99999999
local n = tonumber(io.read("*l"))
for _ in io.read("*l"):gmatch("%d+") do
  local r0 = 0
  local k = tonumber(_)
  while k % 2 < 1 do
    r0 = r0 + 1
    k = k // 2
  end
  if r > r0 then
    r = r0
  end
end
return print(r)


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  for(int i(0);i<5;i++){
    int a;
    cin>>a;
    if(a == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 4e18;

using namespace std;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  vector<int> y(N);
  vector<vector<int>> vec(N, vector<int>(2));
  REP(i, N){
    cin >> x[i] >> y[i];
    vec[i][0] = x[i];
    vec[i][1] = y[i];
  }

  sort(ALL(x));
  sort(ALL(y));

  int ans = (x[N-1]-x[0])*(y[N-1]-y[0]);
  REP(xi, N) FOR(xj, xi+1, N) REP(yi, N) FOR(yj, yi+1, N){
    int cnt = 0;
    REP(i, N){
      if(IN(x[xi], vec[i][0], x[xj]+1) && IN(y[yi], vec[i][1], y[yj]+1)) cnt++;
      if(K <= cnt) chmin(ans, (x[xj]-x[xi])*(y[yj]-y[yi]));
    }
  }

  cout << ans << endl;

  return 0;
}

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

int my_gcd(int a,int b,int c){
    return (gcd(gcd(a,b),c));
}

int main()
{
    int n;
    cin >> n;
    long sum=0;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                sum+=my_gcd(i,j,k);
            }
        }
    }
    printf("%ld", sum);
    return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		int N=sc.nextInt();
	
		int[] cheat = new int[200];
		
		cheat[0]=105;
		cheat[1]=135;
		cheat[2]=165;
		cheat[3]=189;
		cheat[4]=195;
		
		if(N>194){
			System.out.println(5);
		}else if(N>188){
			System.out.println(4);
		}else if(N>164){
			System.out.println(3);
		}else if(N>134){
			System.out.println(2);
		}else if(N>104){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
}

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

#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 llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

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

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


int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    llong n,m;
    cin>>n>>m;
    llong ans=0;
    if(n>m) swap(n,m);
    if(n==1&&m==1) ans=1;
    else if(n==1&&m!=1) ans=m-2;
    else ans=(n-2)*(m-2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b;
  cin>>a>>b;
  if((a+b)%2)
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  else
  {
    cout<<(a+b)/2<<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++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), plus(0), minus(0);

  REP(i, N) {
    cin >> A[i];
    if (A[i] < 0) {
      minus.push_back(A[i]);
    } else {
      plus.push_back(A[i]);
    }
  }
  sort(minus.begin(), minus.end());
  sort(plus.begin(), plus.end(), greater<int>());
  if (minus.empty()) minus.push_back(plus.back()), plus.pop_back();
  if (plus.empty()) plus.push_back(minus.back()), minus.pop_back();
  ll cur = minus[0];
  vector<P> Ans(0);
  for (int i = 0; i < plus.size() - 1; i++) {
    Ans.push_back(P(cur, plus[i]));
    cur -= plus[i];
  }
  Ans.push_back(P(plus.back(), cur));
  cur = plus.back()-cur;
  for (int i = 1; i < minus.size(); i++) {
    Ans.push_back(P(cur, minus[i]));
    cur -= minus[i];
  }
  cout << cur << endl;
  for (auto s : Ans) {
    cout << s.first << " " << s.second << endl;
  }
}

Measured memory_bytes: 5520
#include<bits/stdc++.h>
using namespace std;
const int SIZE=55;
const int dr[]={-1,-1,-1,0,0,1,1,1};
const int dc[]={-1,0,1,-1,1,-1,0,1};
int H,W;
char M[SIZE][SIZE];
int count(int x,int y){
	int sum=0,r,c;
	for(int i=0;i<8;i++){
		r=x+dr[i];
		c=y+dc[i];
		if(r>=0&&r<H&&c>=0&&c<W&&M[r][c]=='#')sum++;
	}
	return sum;
}
int main(){
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>M[i];
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(M[i][j]=='.')M[i][j]='0'+count(i,j);
	for(int i=0;i<H;i++)cout<<M[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int piece[50]={};
  int N;
  int i;
  
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&piece[i]);
  
  int j;
  int power=0;
  
  for(i=0;i<N;i++)
    for(j=i+1;j<N;j++)
    {
      power+=piece[i]*piece[j];
    }
  printf("%d",power);
  return 0;
}

Measured memory_bytes: 128
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
a1 = [aa for aa in a if aa > x]
a2 = [aa for aa in a if aa < x]
if len(a1) > len(a2):
    print(len(a2))
else:
    print(len(a1))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,s=0;cin>>n;
  lvector A(n);rep(i,n) {cin>>A[i];s^=A[i];}
  rep(i,n) A[i]^=s;
  rep(i,n-1) cout<<A[i]<<' ';cout<<A[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 4688
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s;
bool check(char c){
for(int i=0;i<9;i+=3){
if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&s[i]==c){
return true;
}
}
for(int i=0;i<3;i++){
if(s[i]==c&&s[i+3]==c&&s[i+6]==c){
return true;
}
}
if(s[0]==s[4]&&s[4]==s[8]&&s[0]==c){
return true;
}
if(s[2]==s[4]&&s[4]==s[6]&&s[2]==c){
return true;
}
return false;
}
int main(){
while(cin>>s){
bool o = check('o');
bool x = check('x');
if(o){
cout<<"o"<<endl;
}
if(x){
cout<<"x"<<endl;
}
if(!o&&!x){
cout<<"d"<<endl;
}
}
}

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

const int inf = 1000000000;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;

    int ans[n];
    for (int i = 0; i < n; i++) {
        ans[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        int d[n];
        for (int i = 0; i < n; i++) {
            d[i] = inf;
        }
        d[i] = 0;
        queue<int> que;
        que.push(i);
        while (que.size() > 0) {
            int p = que.front();
            que.pop();
            if (p - 1 >= 0 && d[p - 1] > d[p] + 1) {
                d[p - 1] = d[p] + 1;
                que.push(p - 1);
            }
            if (p + 1 < n && d[p + 1] > d[p] + 1) {
                d[p + 1] = d[p] + 1;
                que.push(p + 1);
            }
            if (p == x && d[y] > d[p] + 1) {
                d[y] = d[p] + 1;
                que.push(y);
            }
            if (p == y && d[x] > d[p] + 1) {
                d[x] = d[p] + 1;
                que.push(x);
            }
        }
        for (int j = 0; j < n; j++) {
            ans[d[j]]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << ans[i] / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N, W = map(int, input().rstrip().split())
    item_list = []
    for _ in range(N):
        w, v = map(int, input().rstrip().split())
        item_list.append((w, v))

    # dp[i][w] = i番目まで見て重さwで持ち帰れる最大の価値
    dp = [[0] * (W + 1) for _ in range(N+1)]

    for i, item in enumerate(item_list, 1):
        for w in range(W+1):
            # もし品物iが入れられる
            if w + item[0] <= W:
                dp[i][w+item[0]] = max(dp[i][w+item[0]], dp[i-1][w]+item[1])
            # 入れないパターン
            dp[i][w] = max(dp[i][w], dp[i-1][w])
    print(dp[N][W])

if __name__ == '__main__':
    main()

Measured memory_bytes: 118768
def main():
    N, M, X = map(int, input().split())
    C = []
    A = []
    for _ in range(N):
        C_A = list(map(int, input().split()))
        C.append(C_A[0])
        A.append(C_A[1:])

    prices = []
    for bit in range(1 << N):
        price = 0
        understandings = [0] * M
        for i in range(N):
            if bit & (1 << i):
                price += C[i]
                for idx, a in enumerate(A[i], start=0):
                    understandings[idx] += a
        if min(understandings) >= X:
            prices.append(price)

    if len(prices) == 0:
        print(-1)
    else:
        print(min(prices))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74184
#include <bits/stdc++.h>
using namespace std;
long long n,ans,p=10;
int main()
{
scanf("%lld",&n);
if(n%2 == 0)
{
    while(p<=n)
	{
        ans+=n/p;
        p*=5;
    }
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
import copy

N = int(input())

seq = []

for i in range(N):
    seq.append(int(input()))

seq2 = copy.deepcopy(seq)
seq2.sort(reverse=True)

n1 = seq2[0]
n2 = seq2[1]

for a in seq:
    if a == n1:
        print(n2)
    else:
        print(n1)


Measured memory_bytes: 14584
from heapq import heappush, heappop

X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

ans = sum(P[:X]) + sum(Q[:Y])
apples = []
for p in P[:X]:
    heappush(apples, p)

for q in Q[:Y]:
    heappush(apples, q)

for r in R:
    amin = heappop(apples)
    if r >= amin:
        heappush(apples, r)
        ans += (r - amin)
    else:
        break

print(ans)

Measured memory_bytes: 23216
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve(); int main() { solve(); return 0; }

int dp[5005][5005];

void solve() {
  int n;
  string s;
  cin >> n >> s;
  for (int i=n-1; i>=0; i--) {
    for (int j=n-1; j>=0; j--) {
      if (s[i]!=s[j]) { dp[i][j] = 0; continue; }
      dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  
  int max_ = 0;
  for (int i=n-1; i>=0; i--) {
    for (int j=n-1; j>=0; j--) {
      if (i>=j) continue;
      max_ = max(max_, min(dp[i][j], j-i));
    }
  }
  cout << max_ << endl;
}


Measured memory_bytes: 101376
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+4;
vector<bool> prime(N,1);
vector<int> spec(N,0);
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	prime[1]=prime[0]=0;
	for(int i=2;i<N;i++)
	{
		if(!prime[i])continue;
		for(int j=i*i;j<N;j+=i)
		{
			prime[j]=0;
		}
	}

	for(int i=1;i<N;i++)
	{
		if(prime[i] and prime[(i+1)/2])spec[i]=1;
	}

	for(int i=1;i<N;i++)spec[i]+=spec[i-1];

	int q;cin>>q;int l,r;
	while(q--)
	{
		cin>>l>>r;
		cout<<spec[r]-spec[l-1]<<"\n";
	}


	




	
}

Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a = Long.parseLong(scan.next());
        long b = Long.parseLong(scan.next());
        long n = Long.parseLong(scan.next());
        scan.close();

        long ans = 0;
        if (n < b) {
            ans = a * n;
            ans /= b;
        } else {
            ans = a * (b - 1);
            ans /= b;
        }

        System.out.println(ans);
    }
}


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

using namespace std;

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

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

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

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll ans;
vl res;

ll f(ll c, int d, ll x, ll y){
  while(c>0 && c/x){
    ans+=c/x*y;
    c-=c/x*(x-1);
  }
  REP(_, c){
    res.push_back(d);
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int m, d[252521];
  ll c[252521];
  cin>>m;
  REP(i, m){
    cin>>d[i]>>c[i];
  }
  REP(i, m){
    if(d[i]==0){
      ans+=c[i];
    }
    if(d[i]==1){
      f(c[i], d[i], 10, 10);
    }
    if(d[i]==2){
      f(c[i], d[i], 10, 11);
    }
    if(d[i]==3){
      f(c[i], d[i], 4, 4);
    }
    if(d[i]==4){
      f(c[i], d[i], 10, 13);
    }
    if(d[i]==5){
      f(c[i], d[i], 10, 14);
    }
    if(d[i]==6){
      f(c[i], d[i], 4, 5);
    }
    if(d[i]==7){
      f(c[i], d[i], 10, 16);
    }
    if(d[i]==8){
      f(c[i], d[i], 10, 17);
    }
    if(d[i]==9){
      f(c[i], d[i], 2, 2);
    }
  }
  int n=res.size();
  REP(i, n-1){
    ++ans;
    res[i+1]+=res[i];
    if(res[i+1]>=10){
      ++ans;
      res[i+1]=res[i+1]%10+1;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 13164
import java.util.Scanner;

public class Main {

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

        System.out.println( solve(S) );
    }

    private static int solve(String S) {
        char first = S.charAt(0);
        boolean black = first == 'B';
        int ans = 0;
        for (int i = 1; i < S.length(); i++) {
            char c = S.charAt(i);

            if( black && c == 'W' ) {
                ans++;
                black = false;
            } else if( !black && c == 'B' ){
                ans++;
                black = true;
            }
        }
        return ans;
    }
}

Measured memory_bytes: 26348
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, x: "List[int]"):
    ans = 0
    for i in range(N):
        ans += min(x[i], K-x[i])
    print(ans*2)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))

# print(a[1]^a[2]^a[3])
ans=0
for i in range(n):
    ans^=a[i]
# print(ans)

lst=[]
for i in range(n):
    lst.append(ans^a[i])
print(*lst)

Measured memory_bytes: 106696
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //System.setIn(Main.class.getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[][] tab = new int[n][2];
        for (int i = 0; i < n; i++) {
            tab[i][0] = sc.nextInt();
            tab[i][1] = sc.nextInt();
        }
        int[] dp = new int[h+10000];
        dp[0] = 0;
        for (int i = 1; i < dp.length; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 0; j < n; j++) {
                if(i >= tab[j][0] && dp[i - tab[j][0]] < Integer.MAX_VALUE) {
                    dp[i] = Math.min(dp[i], dp[i - tab[j][0]] + tab[j][1]);
                }
            }
        }
        int min = Arrays.stream(dp)
                .skip(h)
                .min()
                .getAsInt();
        System.out.println(min);
    }

    private static int compare(int[] a, int[] b, int remaining) {
        double a0 = Math.min(a[0], remaining);
        double b0 = Math.min(b[0], remaining);
        return (int) Math.signum(a0 / ((double) a[1]) - b0 / ((double) b[1]));
    }

    private static int nextInt(Scanner sc) {
        return Integer.valueOf(sc.nextLine());
    }

    private static int[] toArray(String text) {
        return Arrays.stream(text.split("\\s")).mapToInt(Integer::valueOf).toArray();
    }

}

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

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

    LL len = 1;
    LL total = 26;
    while (n > total) {
        n -= total;
        total *= 26;
        len++;
    }

    n--;

    string s(len, 'a');
    for (LL i = len-1; i >= 0; i--) {
        s[i] += n%26;
        n /= 26;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    int K;
    char S[100];
    cin>>K;
    cin>>S;
    if(K>=strlen(S))
    {
        cout<<S;
    }
    else
    {
        for(int i=0;i<K;i++)
        {
            cout<<S[i];
        }
        cout<<"...";
    }
    return 0;
}

Measured memory_bytes: 3628
n=int(input())
lst_hi=list(map(int,input().split()))

#hi=lst_hi[i-1](i=1~n)
i=1
count=0
countmax=0
while i<n:
    if lst_hi[i-1]>=lst_hi[i]:
        count+=1
    else:
        if countmax<count:
            countmax=count
            count=0
        else:
            count=0
    i+=1
    if i==n:
        if countmax<count:
            countmax=count
print(countmax)


Measured memory_bytes: 14252
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

s = int(input())
r = set([s])
m = 1

while True:
    m += 1
    s = f(s)
    if s in r:
        break
    else:
        r.add(s)

print(m)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int x;

	cin >> x;
	// vector<int> a(n);

	if (x >= 30){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
#define M 200005

using namespace std;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    string s;
    cin >> s;
    int res = 0;
    for(int i=0;i<s.size();i++)
    {
        res %= 9;
        res += (s[i]-'0');
    }
    res%=9;
    if(res==0) cout <<"Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3740
public class Main {

	public static void main(String[] args) {

		StringBuilder sb = new StringBuilder();
		
		for(int i = 1; i <= 9; i++) {
			for(int j = 1; j <= 9; j++) {
				sb.append(i + "x" + j + "=" + (i * j) + "\n");
			}
		}
		
		System.out.print(sb.toString());
	}
}



Measured memory_bytes: 24124
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
 string s;
 ll cnt[2020];
int main(){
 
  cin>>s;
  int n=s.length();
  ll ans=0;
  cnt[0]=1;
  int tot=0;
  int p=1;
  for(int i=n-1;i>=0;i--){
    tot=(tot+(s[i]-'0')*p)%2019;
    ans+=cnt[tot];
    p=(p*10)%2019;
    cnt[tot]++;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

bool check357(ll num)
{
  bool ret3 = false;
  bool ret5 = false;
  bool ret7 = false;
  while(num > 0)
  {
    int res = num % 10;
    ret3 |= (res == 3);
    ret5 |= (res == 5);
    ret7 |= (res == 7);
    num /= 10;
  }
  return (ret3 & ret5 & ret7);
}

ll n;
ll ans = 0;

void dfs(ll num, ll digit)
{
  if (num > n) return;
  if (num > 100) ans += check357(num);

  dfs(num + digit * 3, digit * 10);
  dfs(num + digit * 5, digit * 10);
  dfs(num + digit * 7, digit * 10);
}

void solve()
{
  cin >> n;

  dfs(0, 1);
  cout << ans;

}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3604
import math
N = int(input())

divisors = []
i = 1
while i <= math.sqrt(N):
    if N % i == 0:
        divisors.append([i, int(N/i)])
    i += 1
ans = N
for i in divisors:
    if max(i) < ans:
        ans = max(i)

print(len(str(ans)))

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

int board[10][10];

bool valid(int x, int y){
	if(x > 0 && x < 9 && y > 0 && y < 9){
		return true;
	}else{
		return false;
	}
}

void removeBomb(int x, int y){
	//cout << "removeBomb: " << x << "," << y << endl;
	if (board[y][x] != 1) {
		return;
	}
	board[y][x] = 0;
	for (int i = 1; i <= 3; i++) {
		if(valid(x, y+i)) removeBomb(x,y+i);
		if(valid(x, y-i)) removeBomb(x,y-i);
		if(valid(x-i, y)) removeBomb(x-i,y);
		if(valid(x+i, y)) removeBomb(x+i,y);
	}
}

void printBoard(){
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cout << board[i+1][j+1];
		}
		cout << endl;
	}
}

int main(){
	int n, x, y;
	string s;
	while (getline(cin, s)) {
		n = atoi(s.c_str());
		for (int i = 0; i < n; i++) {
			getline(cin, s);
			for (int j = 0; j < 8; j++) {
				getline(cin, s);
				for (int k = 0; k < 8; k++) {
					board[j+1][k+1] = s[k] - '0';
				}
			}
			for (int j = 0; j < 10; j++) {
				board[j][9] = 0;
				board[j][0] = 0;
				board[0][j] = 0;
				board[9][j] = 0;
			}
			getline(cin, s);
			x = atoi(s.c_str());
			getline(cin, s);
			y = atoi(s.c_str());
			//cout << x << "," << y << endl;
			board[y][x] = 1;
			removeBomb(x, y);
			cout << "Data " << i+1 << ":" << endl;
			printBoard();
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

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


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

t = 1
while (A > 0) and (C > 0):
    if t > 0:
        C -= B
    else:
        A -= D
    t = (t + 1) % 2

if C <= 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9148
// package Lesson_ITP1;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		if(a<b && b<c) System.out.println("Yes");
		else System.out.println("No");
	}
}



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

struct RU {
	using t1 = int;
	using t2 = int;
	static t2 id2() { return -1; }
	static t1 op2(const t1& l, const t2& r) { return r == id2() ? l : r; }
	static t2 op3(const t2& l, const t2& r) { return r == id2() ? l : r; }
};

template <typename M>
class lazy_segment_tree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T1> data;
	vector<T2> lazy;
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		lazy[node << 1] = M::op3(lazy[node << 1], lazy[node]);
		lazy[(node << 1) | 1] = M::op3(lazy[(node << 1) | 1], lazy[node]);
		lazy[node] = M::id2();
	}
public:
	lazy_segment_tree(int n_, T1 v1)
		: h(ceil(log2(n_))), n(1 << h), data(n_, v1), lazy(n << 1, M::id2()) {}
	lazy_segment_tree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(data_), lazy(n << 1, M::id2()) {}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l >>= 1; r >>= 1;
		}
	}
	T1 find(int p) {
		T1 res = data[p]; p += n;
		while (p) res = M::op2(res, lazy[p]), p >>= 1;
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	lazy_segment_tree<RU> lst(n, INT_MAX);
	while (q--) {
		int com;
		cin >> com;
		if (com == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			lst.update(s, t, x);
		}
		else {
			int p;
			cin >> p;
			printf("%d\n", lst.find(p));
		}
	}
	return 0;
}



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

int main()
{
  int n,m;
  cin >> n >> m;
  
  int a[m],b[m];
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
  }
  
  int num[n+1];
  for(int i = 0; i < n; i++){
    num[i] = 0;
  }
  for(int i = 0; i < m; i++){
    num[a[i]-1]++;
    num[b[i]-1]++;
  }
  for(int i = 0; i < n; i++){
    cout << num[i] << endl;
  }
  
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int k,n;
int arr[200005];

void input(){
	cin>>k>>n;
	rep(i,0,n)
		cin>>arr[i];
}

void solve(){
	int dist[200005];
	dist[0]=arr[0];
	rep(i,1,n)
		dist[i]=arr[i]-arr[i-1];
	dist[0]+=(k-arr[n-1]);
	int ans=1e15;
	rep(i,0,n)
		ans=min(ans,k-dist[i]);
	cout<<ans<<endl;
}

main(){
	fastio;
	int t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 3328
import std.stdio, std.string, std.conv;

void main() {
	int _n = stdin.readln.chomp.to!int;
	auto input = stdin.readln.chomp.split(" ").to!(int[]);

	// insert sort
	for (auto j = 0; j < input.length; j++) {
		for (auto i = j - 1; i >= 0; i--) {
			if (input[i] > input[i+1]) {
				auto tmp = input[i];
				input[i] = input[i+1];
				input[i+1] = tmp;
			}
		}
		input.to!(string[]).join(" ").writeln;
	}
}

Measured memory_bytes: 2576
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a > b) swap(a, b);
		while (b != 0) {
			int c = a%b;
			a = b;
			b = c;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 2952
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

template <class T> void print(T a, int n, int br = 1, const string& deli = ", ") { cout << "{ "; for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } cout << " }"; while (br--) cout << endl; }
template <class T> void print(const vector<T>& v, int br = 1, const string& deli = ", ") { print(v, v.size(), br, deli); }


int main()
{
	int a[10];
	for (int i = 0; i < 10; ++i)
		scanf("%d", a + i);
	sort(a, a + 10, greater<int>());
	for (int i = 0; i < 3; ++i)
		printf("%d\n", a[i]);
}

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

int main() {
	char c; cin >> c;
	if ('a' <= c && c <= 'z') cout << "a\n";
	else cout << "A\n";

	return 0;
}


Measured memory_bytes: 3544
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int a,b;
    scanf("%d%d", &a, &b);
    const double eps=1e-10;
    int i;
    for (i = 1; i <= 10000; i++) {
        double tmp=(double)i*0.08+eps;
        if(a!=(int)tmp) continue;
        tmp=(double)i*0.1+eps;
        if(b!=(int)tmp) continue;
        printf("%d\n", i);
        return;
    }
    printf("-1\n");

    return;
}

int main(int argc, char* argv[])
{
    solve();

	return 0;
}


Measured memory_bytes: 128