akhauriyash/Code-Regression huggingface dataset:
M=gets.to_i
d,c=M.times.map{gets.split.map(&:to_i)}.transpose
cnt=c.inject(&:+)-1
a=0
M.times do |i|
    a+=(d[i]*c[i])
end
while true
    cnt+=a/10
    a=a%10+a/10
    break if a<10
end
puts cnt


Measured memory_bytes: 19324
a = list(map(int,input().split(" ")))

b = [1,3,5,7,8,10,12]
c = [4,6,9,11]
d = 2

if a[0] in b:
    a0 = 1
elif a[0] in c:
    a0 = 2
else:
    a0 = 3

if a[1] in b:
    a1 = 1
elif a[1] in c:
    a1 = 2
else:
    a1 = 3

if a0 == a1:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time"<<1000*(ld)clock()(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ld xx = 6.28318530717958623200;
       ld r;
       cin>>r;
       r *= xx;
       cout<<setprecision(9);
       cout<<r<<endl;
}


Measured memory_bytes: 3788
n = int(input())
H = [int(i) for i in input().split()]

ans = 0
cnt = 0
for i in range(n-1):
  if H[i] >= H[i+1]:
    cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0

ans = max(ans, cnt)
print(ans)

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

using namespace std;

int main()
{
  int n, x, t;
  cin>>n;
  cin>>x;
  cin>>t;
  int output = 0;
  if( n%x > 0 ) output++;
  output = output+(n/x);
  output = output*t;
  cout<<output<<endl;
  return 0;
}

Measured memory_bytes: 3632
import copy

N, M, Q = map(int, input().split())
A = [[] for i in range(20)]
for i in range(N):
    if i == 0:
        for j in range(1, M+1):
            A[i].append([j])
    else:
        for j in range(len(A[i-1])):
            for k in range(A[i-1][j][i-1], M+1):
                temp = copy.copy(A[i-1][j])
                temp.append(k)
                A[i].append(temp)

X = []
Y = []
C = []
D = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    X.append(a-1)
    Y.append(b-1)
    C.append(c)
    D.append(d)

ans = 0
for i in range(len(A[N-1])):
    s = copy.copy(A[N-1][i])
    p = 0
    for q in range(Q):
        if s[Y[q]] - s[X[q]] == C[q]:
            p += D[q]
    ans = max([p, ans])
print(ans)

Measured memory_bytes: 107600
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vector<bool> flag(n);
  rep(i, n) {
    ll p;
    cin >> p;
    if (i + 1 != p) {
      flag[i] = true;
    } else {
      flag[i] = false;
    }
  }

  ll cnt = 0;
  rep(i, n) {
    if (!flag[i]) {
      if (i < n - 1 && !flag[i + 1]) {
        cnt++;
        flag[i] = true;
        flag[i + 1] = true;
      } else {
        cnt++;
        flag[i] = true;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
'''input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
 
import sys, time, threading


	
# main starts
arr = list(map(int, stdin.readline().split()))
if sum(arr) >= 22:
	print('bust')
else:
	print('win')

Measured memory_bytes: 3940
#include<iostream>
#include<vector>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    std::size_t n = S.size();
    int cnt = 0;
    for(int i = 0; i < n / 2; i++){
        if(S[i] != S[n - 1 - i]){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc046/tasks/abc046_b

#include<iostream>
using namespace std;
int main()
{
	int N, K;
	cin >> N >> K;

    int sum = K;
    for(int i=0; i<N-1;i++){
        sum = sum * (K-1);
    }

    cout << sum << endl;
	return 0;
}

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

using namespace std;

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

  int sum = 0;
  int mx = 0;
  for (int n = 0; n < N; ++n) {
    int P;
    cin >> P;
    sum += P;
    mx = max(mx, P);
  }
  sum -= mx / 2;
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>

int main(void) {
	// your code goes here
	int S,m,s,base;
	scanf("%d",&base);
	S=base/3600;
	base%=3600;
	m=base/60;
	base%=60;
	s=base;
	printf("%d:%d:%d\n",S,m,s);
	
	return 0;
}


Measured memory_bytes: 2100
import numpy as np
from numba import njit, i8, b1
import heapq

@njit(i8(b1[:,:],i8,i8,i8,i8),cache=True)
def solve(road_map,ch,cw,dh,dw):

    h,w = road_map.shape
    queue = [(0,ch*w+cw)]
    max_l = 2<<30
    used_map = np.full(h*w,max_l,dtype=np.int64)
    goal = dh*w+dw
    used_map[ch*w+cw] = 0

    #move walk
            
    while len(queue) != 0:
        tl,n = heapq.heappop(queue)
        th,tw = divmod(n,w)
        if n == goal:
            break

        for x in range(-2,3,1):
            for y in range(-2,3,1):
                if x == y == 0:
                    continue
                if abs(x)+abs(y) <= 1:
                    loop = tl
                else:
                    loop = tl+1
                tx = th + x
                ty = tw + y
                next_n  = tx*w+ty
                if tx < 0 or ty < 0 or tx >= h or ty >= w or road_map[tx][ty] == True:
                    continue
                check = used_map[next_n]
                if check > loop:
                    used_map[next_n] = loop
                    heapq.heappush(queue,(loop,next_n))

    ans = used_map[goal]
    if ans == max_l:
        return -1
    else:
        return ans

h,w = map(int,input().split())
ch,cw = map(int,input().split())
ch,cw = ch-1,cw-1
dh,dw = map(int,input().split())
dh,dw = dh-1,dw-1
road_map = np.array([[c=="#" for c in input()] for _ in range(h)])

print(solve(road_map,ch,cw,dh,dw))



Measured memory_bytes: 117108
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	p := scanInt()
	s := scanString()

	if 10%p == 0 {
		cnt := 0
		for i := 0; i < n; i++ {
			num,_ := strconv.Atoi(string(s[n-1-i]))
			if num%p == 0 {
				cnt += n-i
			}
		}
		fmt.Fprintln(wr, cnt)
		return
	}

	a := make([]int, n+1)
	now := 0
	a[0] = 0

	for i := 0; i < n; i++ {
		num,_ := strconv.Atoi(string(s[n-1-i]))
		now = (now+num*mpow(10,i,p)%p)%p
		a[i+1] = now
	}

	debug(a)

	c := map[int]int{}
	ans := 0

	for i := 0; i < n+1; i++ {
		ans += c[a[i]]
		c[a[i]]++
	}

	debug(c)

	fmt.Fprintln(wr, ans)


}

func mpow(a,n,mod int) int {
	res := 1
	for n>0 {
		if n&1 == 1 { res = res*a%mod }
		a = a*a%mod
		n >>= 1
	}
	return res
}


Measured memory_bytes: 7936
#A
S = input()
T = input()
ans = 0
if S[0:1] == T[0:1]:
    ans += 1
    
if S[1:2] == T[1:2]:
    ans += 1
    
if S[2:3] == T[2:3]:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }
  else if(a<6){
    cout<<0<<endl;
  }
  else{
   	cout<<b/2<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, ans, l[2005];
int main() {
	scanf("%d", &n);
	rep(i,n) scanf("%d", l+i);
	sort(l, l+n);
	rep(i,n) rep(j,i){
		ans += (int)(lower_bound(l, l+n, l[i]+l[j]) - l) - i - 1;
	}
	printf("%d\n", ans);
}

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

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

    vector<vector<bool>> dp(N + 1, vector<bool>(1 << 25, false));
    dp[0][0] = true;

    int D;
    vector<int> duplicate(25, 0);
    duplicate[0]++;
    for (int i = 1; i <= N; i++)
    {
        cin >> D;
        duplicate[min(D, 24 - D)]++;
        if (duplicate[min(D, 24 - D)] > 2)
        {
            cout << 0 << endl;
            return 0;
        }

        for (int j = 0; j < (1 << 24); j++)
        {
            if (dp[i - 1][j])
            {
                if ((j >> D) ^ 1)
                {
                    dp[i][(j | (1 << D))] = true;
                }
                if (D != 0 && (j >> (24 - D)) ^ 1)
                {
                    dp[i][(j | (1 << (24 - D)))] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << 24); i++)
    {
        if (dp[N][i])
        {
            int s = INT_MAX;
            bitset<24> b(i + 1);
            int count = 0;
            for (int j = 0; j < 24; j++)
            {
                if (b[j])
                {
                    count++;
                }
                for (int k = 0; k < j; k++)
                {
                    if (b[j] && b[k])
                    {
                        s = min(s, min((j - k), 24 - (j - k)));
                    }
                }
            }
            // cout << N + 1 << " " << count << " " << i << endl;
            // assert(count == N + 1);
            if (s != INT_MAX && count == N + 1)
            {
                ans = max(ans, s);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 213504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      int num = Integer.valueOf(input.readLine());
      if (num == 0)
      {
        break;
      }
      printSquare(makeMagicSquare(num));
    }
  }

  private static void printSquare(int[][] square)
  {
    for (int[] each : square)
    {
      StringBuilder line = new StringBuilder();
      for (int i : each)
      {
        line.append(leftPad(String.valueOf(i), ' ', 4));
      }
      System.out.println(line.toString());
    }
  }

  private static int[][] makeMagicSquare(int size)
  {
    int[][] ret = new int[size][size];

    int x = size / 2 + size % 2 - 1;
    int y = size / 2 + size % 2;
    ret[y][x] = 1;

    for (int i = 2; i <= size * size; i++)
    {
      int[] position = getNextPosition(ret, x, y);
      x = position[1];
      y = position[0];
      ret[y][x] = i;
    }
    return ret;
  }

  private static int[] getNextPosition(int[][] square, int x, int y)
  {
    int ret_x = x + 1;
    int ret_y = y + 1;

    while (true)
    {

      if (ret_x == square[0].length)
      {
        ret_x = 0;
      }
      else if (ret_x < 0)
      {
        ret_x = square[0].length - 1;
      }
      if (ret_y == square.length)
      {
        ret_y = 0;
      }
      else if (ret_y < 0)
      {
        ret_y = square.length - 1;
      }

      if (square[ret_y][ret_x] == 0)
      {
        int[] ret =
        { ret_y, ret_x };
        return ret;
      }

      ret_x--;
      ret_y++;
    }
  }

  private static String leftPad(String str, char padChar, int length)
  {
    for (int i = str.length(); i < length; i++)
    {
      str = String.valueOf(padChar) + str;
    }
    return str;
  }

}

Measured memory_bytes: 24432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            Dictionary<int, int> players = new Dictionary<int, int>();
            bool[] points = new bool[31];

            while (true)
            {
                string[] input1 = Console.ReadLine().Split(',');
                int p = int.Parse(input1[0]);
                int s = int.Parse(input1[1]);

                if (p == 0 && s == 0) break;

                players.Add(p, s);
                points[s] = true;
            }

            int[] ranks = new int[31];
            int rank = 0;

            for (int i = 30; i >= 0; i--)
            {
                if (points[i]) rank++;
                ranks[i] = rank;
            }

            string input2;

            while (!string.IsNullOrEmpty(input2 = Console.ReadLine()))
            {
                int q = int.Parse(input2);

                sb.AppendLine(ranks[players[q]].ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9616
#include <iostream>
using namespace std;
int y[2],m[2],d[2];
int d31[7] = {1,3,5,7,8,10,12};
int d30[4] = {4,6,9,11};
bool flg,uru,eq;


void check() {
  uru = 0;
  if(y[0] % 4 == 0)
    if(y[0]%100 !=0) uru = 1;
  
  if(y[0]%400 == 0) uru = 1;
}


int main() {


  while(1) {
    
    for(int i=0;i<2;i++) cin >> y[i] >> m[i] >> d[i];
    if(y[0] == -1 && d[0] == -1) break;
    check();
    int count = 0;
    while(1) {
      //      cout << y[0] <<" " <<  m[0] <<" " << d[0] << endl; 
      if(y[0] == y[1] && m[0] == m[1] && d[0] == d[1]) break;
    
      flg = 0;
      for(int i=0;i<4;i++)
	if(d30[i] == m[0])flg = 1;
      
      if(m[0] == 2 && d[0] == 28 && uru == 0) {
	m[0]++;
	d[0] = 0;
      } else if(m[0] == 2 && d[0] == 29){
	m[0]++;
	d[0] = 0;
      } else if(d[0] == 30 && flg == 1) {
	m[0]++;
	d[0]=0;
      } else if(d[0] == 31) {
	m[0]++;
	d[0]=0;
      
	if(m[0] == 13) {
	  m[0] = 1;
	  y[0]++;
	  check();
	}
      }
      count++;
      d[0]++;
    }
     
    cout << count << endl;
    
  }
  
  
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <unordered_map>
#define M ((ll)1e9+7)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
void solve()
{
    ll n;
    cin>>n;
    if(n&(ll)1)
    cout<<0<<endl;
    else
    {
        n/=2;
        ll v=5,s=0;
        while(n/v>0)
        {
            s+=n/v;
            v*=5;
        }
        cout<<s<<endl;
    }
}
int main()
{
   solve();
   return 0;
}

Measured memory_bytes: 256
// #define DEBUG

#include <iostream>
#include <string>
typedef long long int ll;

using namespace std;
ll sum = 0;

void debug(ll print)
{
    cout << print << endl;
}

void dfs(ll n, string s) noexcept(false)
{
    if (s.size() == 0)
    {
        sum += n;
        return;
    }

    for (size_t i = 1; i <= s.size(); ++i)
    {
        // 125 の場合 m = 1, 12, 125
        ll m = stoll(s.substr(0, i));

        // 残りの文字列を探索
        dfs(n + m, s.substr(i, s.size() - 1));
    }
}

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

#ifdef DEBUG
    debug();
#endif

    dfs(0, S);
    cout << sum << endl;
}

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

int main()
{
  // 入力                                                                                                              
  int A, P;
  cin >> A >> P;

  int Frag_Apple = 0;

  //かけらの数                                                                                                         
  Frag_Apple = A * 3 + P;

  //整数に切り捨てて出力                                                                                   
  cout << (int)floor((double)Frag_Apple/2) << endl;

  return 0;
}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q):
	l[i],r[i] = map(int,input().split())
c = [0]*(len(s)+1)
for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		c[i+1] += c[i] + 1
	else:
		c[i+1] = c[i]
for i in range(q):
	print(c[r[i]-1]-c[l[i]-1])

Measured memory_bytes: 14212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b,c; cin>>a>>b>>c;
    ll k; cin>>k;
    ll res;
    if(k%2==0) res=a-b;
    else res=b-a;
    if(abs(res)>1e18) cout<<"Unfair"<<endl;
    else cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  
  int x1, x2, y_1, y2;
  scanf("%d %d %d %d", &x1, &y_1, &x2, &y2);
  
  int x = x2-x1;
  int y = y2-y_1;
  
  int vx = -y;
  int vy = x;
  int x3 = x2+vx;
  int x4 = x1+vx;
  int y3 = y2+vy;
  int y4 = y_1+vy;
  
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int H,A;
  cin>>H>>A;
  cout<<(H+A-1)/A<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll max_val = 1e5;
void dfs(ll a, vector<ll> v[], vector<bool> &visit, stack<ll> &st){
    visit[a]=true;
    for(auto x : v[a]){
        if(visit[x]==false)
            dfs(x,v,visit,st);
    }
    st.push(a);
}
int main(){
	ios::sync_with_stdio();
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,a,b;
	cin>>n>>m;
	vector<ll> v[max_val+1];
	vector<ll> inorder(n+1,0);
	for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        v[a].pb(b);
        inorder[b]++;
	}
	vector<ll> dist(n+1,-1e9);
	for(int i=0;i<n;i++){
        if(inorder[i]==0)
            dist[i]=0;
	}
	stack<ll> st;
	vector<bool> visit(n+1,false);
	for(ll i=0;i<n;i++){
        if(visit[i]==false){
            dfs(i,v,visit,st);
        }
	}
	while(!st.empty()){
        ll a = st.top();
        st.pop();
        for(auto x : v[a]){
            if(dist[a]+1>dist[x]){
                dist[x]=dist[a]+1;
            }
        }
	}
	ll maxi = 0;
	for(int i=0;i<n;i++){
        maxi=max(maxi,dist[i]);
	}
	cout<<maxi<<endl;
  	return 0;
}


Measured memory_bytes: 13588
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        final int M = Integer.parseInt(sc.next());
        final int X = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 0; i < M; i++) {
            int a = Integer.parseInt(sc.next());
            if (a < X) {
                ans++;
            } else {
                ans = Math.min(ans, M - ans);
                break;
            }
        }
        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int i = sc.nextInt();

		System.out.println(N - i + 1);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,cnt=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if((i+1)%2==1 && a[i]%2==1) ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define rep(i,a,b) for (rg int i=(a);i<=(b);i++)
#define per(i,a,b) for (rg int i=(b);i>=(a);i--)
#define pb push_back
#define lowbit(x) (x&(-x))
#define replow(i,a,b) for(rg int i = (a);i<=(b);i+=lowbit(i))
#define perlow(i,a,b) for(rg int i = (b);i>=(a);i-=lowbit(i))
#define mk make_pair
#define VI vector<int>
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define fi first
#define se second
#define il inline
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define inf 0x3f3f3f3f
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<15],*p1 = buf,*p2 = buf;
inline ll read(){
    #define num ch-'0'
    char ch;bool flag=0;ll res;
    while(!isdigit(ch=getc()))
    (ch=='-')&&(flag=true);
    for(res=num;isdigit(ch=getc());res=res*10ll+num);
    (flag)&&(res=-res);
    #undef num
    return res;
}
inline void write(ll x){
	if (x < 0) x = ~x + 1ll, putchar('-');
	if (x > 9) write(x / 10ll);
	putchar(x % 10ll + '0');
}
#define mid ((l + r)>>1)
#define ls (x<<1)
#define rs ((x<<1)|1)
#undef mid
#undef ls
#undef rs
void solve()
{
	ll n = read();
	ll lim = (ll)sqrt(n * 1.0);
	per(i,1,lim)
	{
		if(n % i == 0)
		{
			cout<<(i+n/i-2);
			break;
		}
	}
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("data.txt","r",stdin);
	#endif
//	int T = read();
//	while(T--)
	solve();
}

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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);

    bool ok[4] = {false};

    int a, b; cin >> a >> b;
    ok[a] = true;
    ok[b] = true;

    for(int i = 1; i <= 3; i++) {
        if(!ok[i]) {
            cout << i << '\n';
            exit(0);
        }
    }


    return 0;
}


Measured memory_bytes: 256
implicit none
integer(8):: n, i, ans
integer(8),allocatable,dimension(:):: a
 
ans=0
 
read (5,*) n
allocate(a(n))
read(5,*) (a(i),i=1,n)
 
call heapsort(n,a)
 
do i=n,1,-1
    if(mod(n-i,2)==0)then
        ans=ans+a(i)
    else
        ans=ans-a(i)
    endif
enddo
 
 
write(6,"(i0)") ans
 
end
 
!---http://slpr.sakura.ne.jp/qp/sortf90/---
subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    double precision,intent(inout) :: array(1:n)
   
    integer ::i,k,j,l
    double precision :: t
   
    if(n.le.0)then
        write(6,*)"Error, at heapsort"; stop
    endif
    if(n.eq.1)return
 
    l=n/2+1
    k=n
    do while(k.ne.1)
        if(l.gt.1)then
            l=l-1
            t=array(L)
        else
            t=array(k)
            array(k)=array(1)
            k=k-1
            if(k.eq.1) then
                array(1)=t
                exit
            endif
        endif
        i=l
        j=l+l
        do while(j.le.k)
            if(j.lt.k)then
                if(array(j).lt.array(j+1))j=j+1
            endif
            if (t.lt.array(j))then
                array(i)=array(j)
                i=j
                j=j+j
            else
                j=k+1
            endif
        enddo
        array(i)=t
    enddo
 
    return
end subroutine heapsort

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt=0;
    rep(i,n){
        int q,w;
        q = a[i];
        if(a[q-1]-1 == i) cnt++;
    }
    cout << cnt/2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long d[101][100001],i,j,n,k,a[101],mod=1e9+7;
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++) cin>>a[i];
    d[0][0]=1;
    for(i=1;i<=n;i++){
        d[i][0]=d[i-1][0];
        for(j=1;j<=k;j++) d[i-1][j]+=d[i-1][j-1];
        for(j=1;j<=k;j++){
            if(j-a[i]-1>=0) d[i][j]-=d[i-1][j-a[i]-1];
            d[i][j]+=d[i-1][j]+mod+mod;
            d[i][j]%=mod;
        }

    }
    cout<<d[n][k];
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define MAX 1000
using namespace std;


struct edge {
    int to, cost;
};

typedef pair<int, int> pii;
typedef pair<double, pair<int, int> > P;
double dist[MAX][1 << 10];

int main(){
    int n, m, p, a, b;
    while(1){
        cin >> n >> m >> p >> a >> b;
        if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0) break;
        a--;
        b--;
        vector<edge> g[MAX];
        int t[n];
        for(int i = 0; i < n; i++) cin >> t[i];
        sort(t, t + n);
        for(int i = 0; i < p; i++){
            int x, y, z;
            cin >> x >> y >> z;
            x--;
            y--;
            g[x].push_back((edge){y, z});
            g[y].push_back((edge){x, z});
        }
        priority_queue<P, vector<P>, greater<P> > que;
        for (int i = 0; i < MAX; i++){
            for(int j = 0; j < 1 << n; j++){
                dist[i][j] = INF;
            }
        }
        dist[a][0] = 0;
        que.push(P(0, pii(a, 0)));
        while (!que.empty()) {
            P f = que.top();
            que.pop();
            int v = f.second.first;
            double d = f.first;
            int uma = f.second.second;
            if (dist[v][uma] < d) continue;
            for(int i = 0; i < n; i++){
                if(uma >> i & 1) continue;
                int numa = (uma | (1 << i));
                for(int j = 0; j < (int)g[v].size(); j++){
                    edge e = g[v][j];
                    double cost = d + 1.0 * e.cost / (double)t[i];
                    if(cost < dist[e.to][numa]){
                        dist[e.to][numa] = cost;
                        que.push(P(cost, pii(e.to, numa)));
                    }
                }
            }
        }
        double ans = INF;
        for(int i = 0; i < 1 << n; i++){
            ans = min(ans, dist[b][i]);
        }
        if(ans == INF){
            cout << "Impossible" << endl;
        }else{
            cout << ans << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 8520
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
int main() {
	int a,b,c,d;
	cin>>a>>b>>c;
	d=max({a,b,c});
	print(a+b+c-d);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int cnt[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,maxV = 0;
	int c[3][3],x[3], y[3];
	REP(i, 3) {
		REP(j, 3) {
			cin >> c[i][j];
		}
	}
	x[0] = 0;
	REP (i, 3)y[i] = c[0][i] - x[0];
	REP(i, 3)x[i] = c[i][0] - y[0];
	bool good = true;
	REP(i, 3) {
		REP(j, 3) {
			if (x[i] + y[j] != c[i][j]) {
				good = false;
			}
		}
	}

	if(good)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let mut n = stdin.lock().gets().parse::<usize>().unwrap();
    let mut sieve = vec![true; 555556];
    for i in (3..sieve.len()).filter(|x| x % 2 != 0) {
        if sieve[i] {
            if i % 10 == 1 {
                println!("{}", i);
                n -= 1;
                if n == 0 {
                    break;
                }
            }
            let mut j = i * 2;
            while j < sieve.len() {
                sieve[j] = false;
                j += i;
            }
        }
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
n, y = [int(x) for x in input().split()]
a = b = c = -1
for i in range(n + 1):
    for j in range(n + 1):
        k = n - i - j
        if k < 0:
            continue
        else:
            if 10000 * i + 5000 * j + 1000 * k == y:
                a = i
                b = j
                c = k
print(a, b, c)


Measured memory_bytes: 41068
import sys


input = sys.stdin.buffer.readline

n, k = map(int, input().split())
max_n = 300000
num = 2 ** ((max_n - 1).bit_length())
SEG = [0] * (2 * num)
func = max
ele = 0


def update(idx, val):
    idx += num
    SEG[idx] = val
    while idx > 0:
        idx //= 2
        SEG[idx] = func(SEG[2 * idx], SEG[2 * idx + 1])


def query(left, right):
    res_left = ele
    res_right = ele
    left += num
    right += num
    while right - left > 0:
        if left & 1:
            res_left = func(res_left, SEG[left])
            left += 1
        if right & 1:
            right -= 1
            res_right = func(SEG[right], res_right)
        left //= 2
        right //= 2
    return func(res_left, res_right)


for _ in range(n):
    val = int(input())
    temp = query(max(0, val - k), min(max_n + 1, val + k + 1))
    temp += 1
    update(val, temp)


print(SEG[1])



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

int selectionSort(int a[], int n) {
    int sw{};
    for(int i = 0; i < n; i++) {
        int minj = i;
        for(int j = i; j < n; j++) {
            if(a[j] < a[minj])
                minj = j;
        }
        swap(a[i], a[minj]);
        if(i != minj)
            sw++;
    }
    return sw;
}

int main() {
    int n, a[100], sw;
    
    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sw = selectionSort(a, n);
    
    for(int i = 0; i < n; i++) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << "\n" << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

signed main(){
	ll n;
	cin >> n;
	
	ll a,b,c;
	ll dp[n][3] = {};
	
	cin >> a >> b >> c;
	dp[0][0] = a;
	dp[0][1] = b;
	dp[0][2] = c;
	
	rep(i,1,n){
		cin >> a >> b >> c;
		
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c;
	}
	
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
	
	return 0;
}


Measured memory_bytes: 2560
import itertools

N = int(input())
P = [int(s) for s in input().split()]
Q = [int(s) for s in input().split()]


p_turn, q_turn = 0, 0
for i, V in enumerate(list(itertools.permutations(range(1, N+1)))):
    if p_turn == 0 and all([p == v for p, v in zip(P, V)]):
        p_turn = i + 1
    if q_turn == 0 and all([q == v for q, v in zip(Q, V)]):
        q_turn = i + 1

print(abs(p_turn-q_turn))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    ll th = n / k;
    cout << min(abs(n-k*th), abs(n-k*(th+1))) << "\n";
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test IOS long long t;cin >> t;while(t--)
#define ses   "\n"
#define whp   " "
#define mxi 200003
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
#define INF 0x3f3f3f3f
#define CLR(a,b) memset(a,b,sizeof(a));
#define PI acos(-1)
#define what_is(x) cout<<x<<ses;
//set <int, greater <int> > ::iterator it;
//vector<pair<int,int> >a;
//memset(arr,0,sizeof(hg));
//priority_queue <int, vector<int>, greater<int> > pq;
///  string single character erase-
///             s.erase(s.begin()+x); where s is st ring name
///               ans x is index;
///    transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
///    transform(su.begin(), su.end(), su.begin(), ::toupper);
typedef long long v99;
typedef unsigned long long ull;
using namespace std;
v99 fx[4]= {1,-1,0,0};
v99 fy[4]= {0,0,1,-1};
v99 ox8[] = {0, 0, 1, 1, 1, -1, -1, -1};
v99 oy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
bool sort2val(const pair<int,int> &a,const pair<int,int> &b)
{
    if(a.second==b.second)return a.first<b.first;
    return a.second<b.second;
}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
/**
bool prime[1000020];vector<v99>prm;
void SieveOfEratosthenes(v99 n)
{
	memset(prime, true, sizeof(prime));
	for(v99 i=4;i<=n;i+=2)prime[i]=false;
	for (v99 p=3; p*p<=n; p++)
	{
		if (prime[p] == true)
		{
			/// Update all multiples of p
			for (v99 i=p*p; i<=n; i += 2*p)
				prime[i] = false;
		}
	}
	rep1(i,2,n)if(prime[i])prm.push_back(i);

}*/
v99 pw(v99 a, v99 b)
{
	v99 ans = 1;
	for(v99 i = 1; i <= b; ++i)
		ans = (ans * a);
	return ans;
}

template <class T> inline T bigmod(T n,T p,T m)
{
    if(p==0)return 1;
    else if(p%2==0)
    {
        v99 val=bigmod(n,p/2,m);
        return (T)((val*val)%m);
    }
    else return (T)(((v99)n*(v99)bigmod(n,p-1,m))%m);
}


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



int main()
{

    //freopen("data.out","w",stdout);
    //test
    //while(1)
    {
        v99 l,r,n;cin>>l>>r>>n;
        v99 ans=(l-1)/n,ans1=(r/n);
        cout<<ans1-ans<<ses;
    }
    return 0;
}





Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  if(s[0]==t[0])ans++;
  if(s[1]==t[1])ans++;
  if(s[2]==t[2])ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int N,a[1000],i,mina,maxa;
scanf("%d",&N);
for(i=0;i<N;i++){
scanf("%d",&a[i]);
}
mina=a[0];
maxa=a[0];
for(i=1;i<N;i++){
if(mina>a[i])mina=a[i];
if(maxa<a[i])maxa=a[i];
}
printf("%d",maxa-mina);
return 0;
}

Measured memory_bytes: 128
N = int(input())
a = [[int(i) for i in input().split()] for _ in range(N)]
dp = a[0]

for i in range(1,N) :
    a[i][0] += max(dp[1],dp[2])
    a[i][1] += max(dp[2],dp[0])
    a[i][2] += max(dp[0],dp[1])
    dp = a[i]
print(max(dp))

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

int a[3][3];
bool check[3][3];

int main()
{
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	int n;
	cin>>n;
	int b;
	for(int i=0;i<n;i++)
	{
		cin>>b;
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(b==a[j][k]) check[j][k]=true;
	}
	   
	int cnt;
	for(int i=0;i<3;i++)
	{
		cnt=0;
		for(int j=0;j<3;j++)
			if(check[i][j]) cnt++;
		if(cnt==3)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	for(int j=0;j<3;j++)
	{
		cnt=0;
		for(int i=0;i<3;i++)
			if(check[i][j]) cnt++;
		if(cnt==3)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	if(check[0][0]==true && check[1][1]==true && check[2][2]==true)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	
	if(check[0][2]==true && check[1][1]==true && check[2][0]==true)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0, a - (n - b)) << '\n';
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	vector<ll>s(3);
	rep(i, 3)cin >> s[i];
	sort(all(s));
	cout << (s[0] == s[1] && s[1] != s[2] || s[0] != s[1] && s[1] == s[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//

#include <stdio.h>

int main(void){
    int n,m,i,j,c,d;
    int a[50];
    scanf("%d %d",&n,&m);
    for(i=0;i<=n;i++)a[i]=0;
    for(i=0;i<m;i++){
        scanf("%d %d",&c,&d);
        a[c]++;
        a[d]++;
    }
    for(i=1;i<=n;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}

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

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

ll n,m,x,k,d,i,j,index,flag=0,mini,count=0,result,odd,even,sum=0,temp;
string str;
cin>>str;
n=str.size();
for(i=0;i<n;i++)
{
    sum+=str[i]-'0';
}
if(sum%9==0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    return 0;
}


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

using std::cout;    using std::cin;
using std::endl;	using std::max;

int main() {
	
	int N;
	cin >> N;
	
	int m = 0, sum = 0;
	
	for (int i = 0; i != N; ++i) {
		
		int x;
		cin >> x;
		
		sum += x;
		m = max(m, x);
	}
	
	if (sum > 2 * m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
		
	return 0;
}

Measured memory_bytes: 3616
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let nm = read_vec::<usize>();
    let n = nm[0];
    let m = nm[1];
    let mut digits = vec![HashSet::new(); n];

    if m == 0 {
        if n == 1 {
            println!("0");
            return;
        }
        print!("1");
        for _ in 1..n {
            print!("0");
        }
        println!("");
        return;
    }

    for _ in 0..m {
        let sc = read_vec::<usize>();
        let s = sc[0];
        let c = sc[1];
        digits[s-1].insert(c);
    }
    let digits = digits.iter().collect::<Vec<_>>();

    if digits[0].contains(&0) && n != 1 {
        println!("-1");
        return;
    }
    for i in 0..n {
        if digits[i].len() > 1 {
            println!("-1");
            return;
        }
    }

    if digits.iter().filter(|x| x.is_empty() == false).count() == 0 {
        println!("0");
        return;
    }

    for (i, d) in digits.iter().enumerate() {
        match d.iter().collect::<Vec<_>>().first() {
            Some(num) => { print!("{}", num); },
            None => { if i == 0 { print!("1"); } else {print!("0"); } },
        }
    }
    println!("");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define mem0(x) memset(x, 0, sizeof(x))
#define mem1(x) memset(x, -1, sizeof(x))
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define de(x) cout << #x << " = " << x << endl;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i > b; i--)
#define setI freopen("input.txt", "r", stdin);
#define setIO freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout);
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
//---------------------------------------------------------//
const int N = 1e5 + 5;

int n, a[N], cnt[N];

int main()
{
	#ifdef M1saki
//		setI;
	#endif
//	ios::sync_with_stdio(false);
	scanf("%d", &n);
	rep(i, 1, n + 1)
	{
		scanf("%d", &a[i]);
		cnt[a[i]]++;
	}
	int ans = 0;
	rep(i, 0, 100002)
	{
		int tmp = 0;
		if (i - 1 >= 0)  tmp += cnt[i - 1];
		tmp += cnt[i];
		tmp += cnt[i + 1];
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll L, R;
    cin >> L >> R;
    if (R - L >= 5000) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = LINF;
    FOR(i, L, R + 1) {
        FOR(j, i + 1, R + 1) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{ int m,n;
cin>>m>>n;
int i;
int a[n];
for(i=0;i<n;i++)
{
    a[i]=0;
}
for(i=0;i<m;i++)  //number of person
{ int x;

    int j,k;
    cin>>k;      //items liked by man
    for(j=0;j<k;j++)   //number of food item
    {
      cin>>x;
      a[x-1]++;
    }
    
}
int count=0;
for(i=0;i<n;i++)
{
    if(a[i]==m)
    {count++;}
    
    
}
cout<<count;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

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

int main(){
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int gcd_sum = A[0];
  for(int i=1; i<N; i++){
    gcd_sum = gcd(gcd_sum,A[i]);
  }
  sort(A.begin(),A.end(),greater<int>());
  if(A[0] < K){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  if(K%gcd_sum != 0){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << "POSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 640