akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define re register
#define M 998244353
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,k,a[1000002],ans,b[10000002],dp[10000002],f[10000002];
char s[1000002];
signed main(){
	n=read(),m=read();f[1]=dp[1]=1;
	for(re int i=1;i<=m;++i)a[i]=read(),b[i]=read();
	for(re int i=2;i<=n;++i){
		for(re int j=1;j<=m;++j){
			if(i-a[j]<0)continue;
			
			re int l=max(i-b[j],0),r=max(i-a[j],0);
			if(l)
			dp[i]+=f[r]-f[l-1];else dp[i]+=f[r];
			dp[i]%=M;
			dp[i]+=M;
			dp[i]%=M;
		}
		f[i]=f[i-1]+dp[i];
		f[i]%=M;
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 5344
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint x;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x;
	llint ans = 0, sum = 100;
	while(sum < x){
		ans++;
		sum += sum/100;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    string s;
    cin>>s;
    if(s=="SUN")
    cout<<7;
    if(s=="MON")
    cout<<6;
    if(s=="TUE")
    cout<<5;if(s=="WED")
    cout<<4;if(s=="THU")
    cout<<3;if(s=="FRI")
    cout<<2;if(s=="SAT")
    cout<<1;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k,a,b,flag=0;
	cin>>k>>a>>b;
	if(a>=k){cout<<"1"<<endl;return 0;}
	if(b>=a){cout<<"-1"<<endl;return 0;}
	if((k-a)%(a-b)>=1) flag=1;
    cout<<((k-a)/(a-b)+flag)*2+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	Int count = 0;
	for (Int i = 0; i < N; i++) {
		while (a[i] % 2 == 0) {
			count++;
			a[i] /= 2;
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 384
def project(x,y):
    base=[x2-x1,y2-y1]
    hypo=[x-x1,y-y1]
    r=(base[0]*hypo[0]+base[1]*hypo[1])/(base[0]**2+base[1]**2)
    return x1+base[0]*r,y1+base[1]*r


def reflect(x,y):
    px,py=project(x,y)
    return x+(px-x)*2,y+(py-y)*2


x1,y1,x2,y2=map(int,input().split())
q=int(input())
for i in range(q):
    x,y=map(int,input().split())
    print(*reflect(x,y))


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> num(N, 0);
  for(int i=0; i<N-1; i++){
    int temp;
    cin >> temp;
    ++num[temp-1];
  }
  
  for(int i=0; i<N; i++){
    cout << num[i] << endl; 
  }
  
  return 0;
}

Measured memory_bytes: 4008
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 200001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}

int n;
int A[MaxN];


void solve()
{
    stack<int> S;
    int x = n; 
    while(x>1)
    {
        if(x!=n) printf(" ");
        printf("%d", A[x]);
        x-=1;
        if(x!=1) S.push(x);
        else break;
        x-=1;
    }
    if(n>1) printf(" ");
    printf("%d", A[1]);
    while(S.size()>0)
    {
        int loc = S.top();
        printf(" %d", A[loc]);
        S.pop();
    }
    puts("");
}

int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d", &n))
    {
        for(int i=1;i<=n;i++) scanf("%d", &A[i]);
        solve();
    }
    //system("pause");
}


Measured memory_bytes: 3276
#include <stdio.h>

int main (){

	int a,b,c,x,y,z;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	y=a+c;
	z=b+c;

	if(a>b && a>c || a==b && a==c && b==c){
		printf("%d\n",z);
	}
	else if(b>a && b>c)
	{
		printf("%d\n",y);
	}
	else if(c>a && c>b)
	{
		printf("%d\n",x);
	}
	return 0;
}

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

int main()
{
    long long n;
    cin>>n;
    long long temp=1;
    long long num=0;
    while(n>1)
    {
        num +=temp;
        temp *=2;
        n=n/2;
    }
    num +=temp;
    cout<<num;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a_max = max(a)
b_max = sorted(a)[-2]
for j in range(n):
  if a[j] == a_max:
    print(b_max)
  else:
    print(a_max)

Measured memory_bytes: 13404
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int c=0;
    string s;
    cin>>s;
    if(s.length()==2){
        if(s[0]==s[1]){
            cout<<1<<endl;
            return 0;
        }
    }
    for(int i=1;i<s.length();i++){
        if(s[i]==s[i-1]){
            int x=s[i]-'0';
            x=x^1;
            s[i]=x+'0';
            c++;
        }
    }
    cout<<c<<endl;
    
    return 0;
    
}



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

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  ll sum = 0;
  rep(i, m) cin >> a[i], sum+=a[i];
  if( n - sum < 0 ) {
    cout << -1 << endl;
  }else {
    cout << n - sum << endl;
  }
  return 0;
}


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

// よく愛用しています
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }

const int MAX_N = 110000;
int dp[MAX_N]; // dp[i] が i についての答え

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

	// 初期化
	for (int i = 0; i < MAX_N; ++i) dp[i] = N; // INF
	dp[0] = 0;
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
	que.push(make_pair(0, 0));

	// Dijkstra 法
	while (!que.empty()) {
		int cur = que.top().first; // 現在の距離
		int v = que.top().second; // 現在のノード
		que.pop();

		// Dijkstra 法でよくやる枝刈り
		if (cur > dp[v]) continue;

		for (int pow6 = 1; v + pow6 <= N; pow6 *= 6) {
			int nv = v + pow6; // 遷移先
			if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
		}
		for (int pow9 = 1; v + pow9 <= N; pow9 *= 9) {
			int nv = v + pow9; // 遷移先
			if (chmin(dp[nv], dp[v] + 1)) que.push(make_pair(dp[nv], nv));
		}
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
    int l,r,largest,temp;
    l=2*i;
    r=2*i+1;
    if(l <= H && A[l] > A[i])
        largest=l;
    else
        largest=i;
    if(r <= H && A[r] > A[largest])
        largest=r;

    if(largest != i){
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(largest);
    }
}

int main(void){
    int i;
    scanf("%d",&H);
    for(i=1;i<=H;i++)
        scanf("%d",&A[i]);
    for(i=H/2;i>=1;i--)
        maxHeapify(i);
    for(i=1;i<=H;i++)
        printf(" %d",A[i]);
    puts("");
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int a[12];
int n;
bool dfs(int b, int c, int ct) {
  if(ct == 10) return true;
  if(b < a[ct] && dfs(a[ct], c, ct + 1)) return true;
  if(c < a[ct] && dfs(b, a[ct], ct + 1)) return true;
  return false;
}

int main() {
  scanf("%d", &n);
  for(int j = 0; j < n; ++j) {
    for(int i = 0; i < 10; ++i) {
      scanf("%d", &a[i]);
    }
    printf("%s\n", dfs(0, 0, 0) ? "YES" : "NO");
  }
  return 0;
}

Measured memory_bytes: 3144
#include<iostream>

using namespace std;

bool check(bool *res,int *b,int N)
{
    for(int i=0;i<3;++i){
        if(res[i*3] && res[i*3+1] && res[i*3+2])
        {
            return true;
        }
        if(res[i] && res[i+3] && res[i+6])
        {
            return true;
        }
    }
    if(res[0] && res[4] && res[8])
    {
        return true;
    }
    if(res[2] && res[4] && res[6])
    {
        return true;
    }
    return false;
}

int main()
{
    int A[9];
    bool res[9];
    for(int i=0;i<9;++i)
    {
        res[i]=false;
    }
   for(int i=0;i<9;++i)
   {
       cin >> A[i];
   }

    int N;cin >> N;
    int b[N];
    for(int i=0;i<N;++i)
    {
        cin >> b[i];
    }
    
    for(int i=0;i<N;++i)
    {
        for(int j=0;j<9;++j)
        {
            if(b[i]==A[j]) res[j]=true;
        }
    }
    if(check(res,b,N))
    {
        cout << "Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

long long lcm(long long a, long long b)
{
    long long tmp, r;
    long long copied_a = a, copied_b = b;
    
    if(a < b){
        tmp = a;
        a = b;
        b = tmp;
    }
        
    /* ユークリッドの互除法 */
    r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    
    return copied_a * (copied_b / b);
}


int main(void){
    // Your code here!
    long long n, v = 1;
    
    cin >> n;
    for(int i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        v = lcm(v, temp);
    }
    
    cout << v << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    cout<< (a == b.substr(0, b.length() - 1) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3624
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;
    ll n, m, k, i, j, x=0,  s=1, f=0, p, y=1000000000000000000;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
        if(a[i]==0)x=1;
    }
    for(i=0; i<n; i++){

        if(s<=y/a[i]){
            s*=a[i];
        }
        else{
            f=1;
            break;
        }
    }
    if(x==1)cout<<0<<endl;
    else if(f==1)cout<<"-1"<<endl;
    else cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 4440
import sys
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b=set()
c=set()
for l in a:
  if l[0]==1:
    b.add(l[1])
  elif l[1]==n:
    c.add(l[0])
for x in b:
  if x in c:
    print("POSSIBLE")
    sys.exit()
print("IMPOSSIBLE")

Measured memory_bytes: 52504
import java.util.Scanner;

public class Main{
	public static long factorial(int n){
		if( n == 0 ){
			return 1;
		}
		return n*factorial(n-1);
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		System.out.println(factorial(n));
	}
}

Measured memory_bytes: 11000
fun main(args: Array<String>) {
    val S = readLine()!!
    var T = S

    var peek: String?
    val pat = listOf("dream", "dreamer", "erase", "eraser")
    while (pat.firstOrNull { T.endsWith(it) }.also { peek = it } != null) {
        T = T.substringBeforeLast(peek!!)
    }
    print(if (T == "") "YES" else "NO")
}


Measured memory_bytes: 56472
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
double PI = acos(-1);

int main() {
    double a, b, x, s, deg, rad, h, w;
    cin >> a >> b >> x;
    s = x/a;
    if(s>=a*b/2){
        h = 2*(a*b-s)/a;
        rad = atan2(h, a);
        deg = rad/PI*180;
        printf("%.10f", deg);
        
    }
    else{
        w = 2*s/b;
        rad = atan2(b, w);
        deg = rad/PI*180;
        printf("%.10f", deg);
    }
    return 0;
}

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

int main()
{
  string s,t;
  cin>>s>>t;
  int cnt=0;

  //if(s.size()==t.size())

      //cnt=0;
      for(int i=0;i<s.size();i++)
      {
          if(s[i]!=t[i])
          {
              cnt++;
          }
      }
      cout<<cnt<<endl;


}


Measured memory_bytes: 3856
N, M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for i in range(1,M+1):
  cnt = 0
  for a in A:
    if(i in a[1:]):
      cnt += 1
  if(cnt == N):
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <functional>
#include <iostream>

int main() {
    int n;
    while (std::cin >> n && n) {
        int tb[n];
        for (int i = 0; i < n; i++) tb[i] = 0;

        std::function<void(int, int)> f;
        f = [&](int depth, int sub) {
            if (sub == n) {
                int j = 0;
                while (tb[j] && j < n)
                    std::cout << (j == 0 ? "" : " ") << tb[j], j++;
                std::cout << std::endl;
            } else {
                for (int k = n - sub; k > 0; k--) {
                    if (depth == 0 || tb[depth - 1] >= k) {
                        tb[depth] = k;
                        f(depth + 1, sub + k);
                    }
                }
            }
            tb[depth] = 0;
        };

        f(0, 0);
    }
}

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

//Coding below.
int main (){

    string S;
    cin >> S;
    bool ans = true;
    for(int i=0;i<S.length();i++){
        if(i%2==0){//奇数
            if(S[i] == 'L'){
               ans = false;
            }
        }else{//偶数
            if(S[i] == 'R'){
                ans = false;
            }
        }
    }

    if(ans){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<ctime>

using namespace std;
const int Max = 1e6 + 5;

int main(){
	int n, m, i, j, t, k, flag = 0;
	string a, b;
	cin >> a >> b;
	int A[26] = {0}, B[26] = {0};
	for(i = 0; i < a.length(); i++)
		A[a[i] - 'a']++;
	for(i = 0; i < b.length(); i++)
		B[b[i] - 'a']++;
	sort(A, A + 26);
	sort(B, B + 26);
	for(i = 0; i < 26; i++)
		if(A[i] != B[i]) { flag++; break; }
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


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

dp = [1] * N
red = [False] * N
red[0] = True
for i in range(M):
    xi,yi = map(int, input().split())
    xi-=1
    yi-=1
    dp[yi] += 1
    red[yi] = red[yi] or red[xi]
    dp[xi] -= 1
    if dp[xi] == 0:
        red[xi] = False

ans = sum(red)
print(ans)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<int> > g;
vector<int> ord, low;
vector<bool> is_articulation;
vector<P> bridges;

void dfs(int u, int par, int &k){
    ord[u] = k;
    k++;
    low[u] = ord[u];
    int cnt = 0;
    for(auto v : g[u]){
        if(ord[v] == -1){
            cnt++;
            dfs(v, u, k);
            low[u] = min(low[u], low[v]);
            if(par!=-1 && ord[u] <= low[v]){
                is_articulation[u] = true;
            }
            if(ord[u] < low[v]){
                bridges.push_back(make_pair(min(u,v), max(u,v)));
            }
        }
        else if(v != par)low[u] = min(low[u], ord[v]);
    }
    if(par == -1){
        is_articulation[u] = cnt >= 2;
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    g.resize(n);
    ord.resize(n, -1);
    low.resize(n);
    is_articulation.resize(n, false);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int k = 0;
    dfs(0, -1, k);
    sort(bridges.begin(), bridges.end());
    for(auto e : bridges){
        cout << e.first << " " << e.second << endl;
    }
    return 0;
}



Measured memory_bytes: 4936
a, b, c, x = 4.times.map { gets.to_i }
count = 0
(0..a).each do |i|
  (0..b).each do |j|
     (0..c).each do |k|
        count += 1 if i * 500 + j * 100 + k * 50 == x
     end
  end
end

puts count

Measured memory_bytes: 1788
import fractions
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=abs(x-a[0])
a.sort()
if n==1:
    print(abs(x-a[0]))
else:
    cnt=abs(a[1]-a[0])
    for j in range(n-1):
        cnt=fractions.gcd(abs(a[j+1]-a[j]),cnt)
    for i in range(n):
        ans=fractions.gcd(abs(x-a[i]),ans)
    print(fractions.gcd(ans,cnt))
    

Measured memory_bytes: 16296
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Distance | diff Distance.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Distance.cpp && ./a.out

/*

 8/2/2020

 5:01-

 */

const int MAX_N=1e6+1;
LL X[MAX_N],Y[MAX_N];
int N,D;

void solve() {
  int res=0;
  REP(i,N) {
    LL d=X[i]*X[i]+Y[i]*Y[i];
    res+=d<=(LL)D*D;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N>>D;
  REP(i,N) cin>>X[i]>>Y[i];
  solve();

  return 0;
}


Measured memory_bytes: 6740
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
// input: 'A　B'
// const inputList = input.split(' '); // 空白文字に注意
// const inputNumberList = inputList.map(Number);


// const input = require('fs').readFileSync('/dev/stdin', 'utf8');
// const inputList = input.split('\n');
// const imputNumberList = inputList.map(Number);


if (input[0] === input[2]) {
  console.log('Yes');
} else {
  console.log('No');
}

Measured memory_bytes: 7372
import bisect

n = int(input())
s = list(input())
q = int(input())

alphabet = [chr(ord('a') + i) for i in range(26)]

d = {alphabet[i]: [] for i in range(26)}
for i, a in enumerate(s):
    d[a].append(i)

ans = []
for i in range(q):
    query = input().split()

    if query[0] == '1':
        idx, c = int(query[1]) - 1, query[2]
        if s[idx] == c:
            continue
        d[s[idx]].remove(idx)
        bisect.insort_left(d[c], idx)
        s[idx] = c
    else:
        l, r = int(query[1]) - 1, int(query[2]) - 1
        res = 0
        for c in alphabet:
            if bisect.bisect_right(d[c], r) > bisect.bisect_left(d[c], l):
                res += 1
        ans.append(res)

for i in ans:
    print(i)

Measured memory_bytes: 99456
#include <stdio.h>

typedef struct {
    int state[2][7];
    int assign[7];
    int p; // 次に代入すべきインデックス
} dice;

dice d1, d2;
int rot[6][7] = {
    {0,1,2,3,4,5,6},
    {0,2,6,3,4,1,5},
    {0,4,2,1,6,5,3},
    {0,3,2,6,1,5,4},
    {0,5,1,3,4,6,2},
    {0,1,3,5,2,4,6},
};
int tr['Z'];

void dice_init(dice *d, int *a) {
    int i;
    int t[6] = {0, 'N', 'E', 'W', 'S', 'L'};
    for (i = 1; i <= 6; i++) d->assign[i] = a[i];
    for (i = 1; i <= 5; i++) tr[t[i]] = i;
    for (i = 1; i <= 6; i++) d->state[0][i] = rot[0][i];
    d->p = 1;
}

int get_d_num(dice *d, int i) {
    return d->assign[d->state[!(d->p)][i]];
}

void dice_rotate(dice *d, char dir) {
    int i;
    for (i = 1; i <= 6; i++) {
        d->state[d->p][i] = d->state[!(d->p)][rot[tr[dir]][i]];
    }
    d->p = !(d->p);
}

void set_top(dice *d, int t) {
    char s[] = "NEEEN";
    char *ps = s;
    while (*ps) {
        if (get_d_num(d, 1) == t) return;
        dice_rotate(d, *ps);
        ps++;
    }
}

void set_front(dice *d, int f) {
    while (get_d_num(d, 2) != f) dice_rotate(d, 'L');
}

int equals(dice *d1, dice *d2) {
    int i;
    for (i = 1; i <= 6; i++) {
        if (get_d_num(d1, i) != get_d_num(d2, i)) return 0;
    }
    return 1;
}

char str[6] = "NEEEN";
int main(void) {
    int i, j;
    int a[7], b[7];
    char *p = str;
    for (i = 1; i <= 6; i++) scanf("%d", a + i);
    for (i = 1; i <= 6; i++) scanf("%d", b + i);
    dice_init(&d1, a);
    dice_init(&d2, b);
    for (i = 1; i<= 6; i++) {
        for (j = 1; j <= 4; j++) {
            if (equals(&d1, &d2)) {
                printf("Yes\n");
                return 0;
            }
            dice_rotate(&d2, 'L');
        }
        dice_rotate(&d2, *p);
        p++;
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
struct po{int x,y,a,b;};
int w,h;
int mp[55][55];
int tx,ty,kx,ky;
int dis[55][55][55][55];
 
po mkp(int a,int b,int c,int d){
  po res;
  res.x=a, res.y=b, res.a=c,res.b=d;
  return res;
}
 
int bfs(){
  int dx[]={0,0,-1,1};
  int dy[]={1,-1,0,0};
  memset(dis,0,sizeof(dis));
  queue <po> Q;
  Q.push(mkp(tx,ty,kx,ky));
 
  while(!Q.empty()){
    po t=Q.front();Q.pop();
 
    if(dis[t.y][t.x][t.b][t.a]>=100) return -1;
    if(t.x==t.a&&t.y==t.b) return dis[t.y][t.x][t.b][t.a];
     
 
    for(int i=0;i<4;i++){
      int nx=t.x+dx[i],ny=t.y+dy[i];
      int na=t.a-dx[i],nb=t.b-dy[i];
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx])nx=t.x,ny=t.y;
      if(na<0||nb<0||na>=w||nb>=h||mp[nb][na])na=t.a,nb=t.b;
      if(nx==t.x&&ny==t.y&&na==t.a&&nb==t.b)continue;
      if(dis[ny][nx][nb][na])continue;
      dis[ny][nx][nb][na]=dis[t.y][t.x][t.b][t.a]+1;
      Q.push(mkp(nx,ny,na,nb));
    }
  }
  return -1;
}
 
int main(){
 
  while(1){
  cin>>w>>h;
  if(!w&&!h)break;
  cin>>tx>>ty>>kx>>ky;
  tx--,ty--,kx--,ky--;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++) cin>>mp[i][j];
  int res=bfs();
  if(res==-1) cout << "NA"<<endl;
  else cout <<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 37264
#!/usr/bin/env python3
X, Y = map(int, input().split())
if (X + Y) % 3:
    exit(print(0))
m = (2*X - Y) // 3
n = X - 2*m
if n < 0 or m < 0:
    exit(print(0))

## class
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def power(a, b, c):
    try:
        return pow(a, b, c)
    except (ValueError, TypeError) as e:
        if b < 0:
            return pow(modinv(a, c), -b, c)
        else:
            print(e)

class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = power(self.f[n], -1, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

def nCr(n, r, mod = None, limit = None):
    if mod and limit:
        return Factorial(limit, mod).comb(n, r)
    elif mod:
        r = min(r, n - r)
        a = 1
        for i in range(r):
            a = a * (n - i) * power(i + 1, mod - 2, mod) % mod
        return a
    else:
        from math import factorial as f
        return f(n) // (f(n - r) * f(r))

MOD = 10**9+7
print(nCr(m + n, n, MOD, 2*10**6))

Measured memory_bytes: 70000
#d
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [0] * Q
C = [0] * Q
for i in range(Q):
    B[i], C[i] = map(int, input().split())
D = [0] * (10**5+1)
ans=sum(A)
for i in A:
    D[i]+=1
for x in range(Q):
    ans+=D[B[x]]*int(C[x]-B[x])
    print(ans)
    D[C[x]]+=D[B[x]]
    D[B[x]]=0

Measured memory_bytes: 84892
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n); sc2(m,k);
	c=n/(m+k);
	ans+=m*c;
	ans+=min(n-c*(m+k),m);
	pr(ans);
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
N = int(input())
S = input()
#N, M = map(int, input().split())
#A = list(map(lambda x: int(x)*(-1), input().split()))
#A = [int(input()) for i in range(N)]
#C = [list(map(int, input().split())) for i in range()]
R  =[]
G  =[]
B  =[]
for i, s in enumerate(S):
    if s == 'R':
        R.append(i)
    elif s == 'G':
        G.append(i)
    else:
        B.append(i)
answer = len(R)*len(G)*len(B)
hiku = 0

for i in range((N-1)//2):
    for j in range(N-i-i-2):
        if S[j] != S[j+i+1] and S[j+i+1] != S[j+i+i+2] and S[j] != S[j+i+i+2]:
            hiku += 1


answer -= hiku
print(answer)


Measured memory_bytes: 9280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int numValue = sc.nextInt();
        for(int i = 3; i <= numValue; i++){
            if(i % 3 == 0 || String.valueOf(i).contains("3")){
                System.out.print(" " + i);
            }
        }
        System.out.println();
    }
}




Measured memory_bytes: 29332
def SelectionSort(A, N):
    cnt = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            cnt += 1

    print(*A)
    print(cnt)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    SelectionSort(A, N)


if __name__ == '__main__':
    main()



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

using namespace std;

int n;
int temp;
int absolute(int a)
{
	if(a<0)return -a;
	return a;
}
int minimum(int a, int b)
{
	if(a<b)return a;
return b;

}
int Frog(vector<int>&h)
{
	//cout<<"heights : ";
	
	vector<int>cost(n,INT_MAX);
	cost[0]=0;
    
	cost[1] = absolute(h[0]-h[1]);
	

	for(int i=2;i<n;i++)
	{
		cost[i]=minimum( cost[i-1]+absolute(h[i]-h[i-1]), cost[i-2]+absolute(h[i]-h[i-2]));
		//cout<<cost[i]<<" ";
	}
	//cout<<endl;
	return cost[n-1];
}
int main()
{
	#ifdef patil
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
     
   cin>>n;
   vector<int>h;

   for(int i=0;i<n;i++)
   {
   	cin>>temp;
   	h.push_back(temp);
   }

   cout<<Frog(h);

	return 0;
}

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

using namespace std;

int main()
{
 string L,R,all,r,l;

 int m,h = 2,p,q;


 while (1){

 	cin >> all;

 	cin >> m ;

 	if (all == "-")break;

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

 		cin >> h ;
 		p = h ;
 		q = all.size();

 		 L = all.substr(0,h);
 		 R = all.substr(p,q - h + 1);
 		 l = L;
 		 r = R;
 		 all =  r + l;
 	}

 	cout << all << endl;

 }


 return 0;

}

Measured memory_bytes: 3164
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi l(n);
    rep(i,n)cin>>l[i];
    SORT(l);
    int s=0;
    rep(i,n-1)s+=l[i];
    Yes(s>l[n-1]);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
long long n, d, ans = 0, a[15][15];
int main(int argc, char const *argv[])
{
	scanf("%lld%lld", &n, &d);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= d; ++j)
			scanf("%lld", &a[i][j]);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j < i; ++j)
		{
			long long sum = 0;
			bool pd = false;
			for (int k = 1; k <= d; ++k) sum += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			for (int k = 1; k <= 1000; ++k)
			{
				if ((long long)k*k == sum)
				{
					pd = true;break;
				}
			}
			if (pd) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;

int a[N];


int main ()
{
	int n;
	cin >> n;
	set<int>st;
	for (int i = 0; i < n ; i ++) {
		cin >> a[i];
		st.insert(a[i]);
	}
	cout << st.size()-(st.size()%2?0:1) << endl;
	
	return 0;
}


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


int main()
{
	unsigned long long a;

	unsigned long long b = 1e18;
	cin >> a;
	for (int i = 1; i <= sqrt(a); ++i) {
		if (a % i == 0) {
			b = min(b, i + (a / i) - 2);
		}
	}
	cout << b;

}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val bList = readInputLine().split(" ").map { it.toInt() }.toMutableList()
    bList.reverse()
    
    val opReversed = mutableListOf<Int>()
    
    while (bList.isNotEmpty()) {
        var ok = false
        for ((i, b) in bList.withIndex()) {
            if (b == bList.size - i) {
                opReversed.add(b)
                bList.removeAt(i)
                ok = true
                break
            }
        }
        if (!ok) {
            println(-1)
            return
        }
    }
    
    for (op in opReversed.reversed()) {
        println(op)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        static final long MODULO = 998244353;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            Map<String, Long> cache = new HashMap<>();
            out.println(doit(s, cache));
        }

        private long doit(String s, Map<String, Long> cache) {
            if (s.length() == 0) return 1;
            Long cached = cache.get(s);
            if (cached != null) return cached;
            long woFirst = doit(s.substring(1), cache);
            long res = woFirst;
            if (s.charAt(0) == '1') res += woFirst;
            for (int len = 1; len * 2 <= s.length(); ++len) {
                char[] cand = new char[len];
                Arrays.fill(cand, '1');
                for (int rep = 0; len * (rep + 1) <= s.length(); ++rep) {
                    for (int i = 0; i < len; ++i) {
                        if (s.charAt(len * rep + i) == '0') cand[i] = '0';
                    }
                    if (rep >= 1) {
                        long cur = doit(new String(cand), cache);
                        cur *= doit(s.substring(len * (rep + 1)), cache);
                        cur %= MODULO;
                        res += cur;
                    }
                }
            }
            res %= MODULO;
            cache.put(s, res);
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 108924
#include <stdio.h>

int n, A[20];

int solve(int i, int m)
{
    if ( m == 0 ) {
        return 1;
    }
    if ( i >= n ) {
        return 0;
    }

    int res = ( solve(i + 1, m) || solve(i + 1, m - A[i]) );
    return res;
}

int main(void)
{
    int q;
    int m;
    int i;

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

    scanf("%d", &q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d", &m);
        if ( solve(0, m) ) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2036
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int path[51],N,M,a,b;
  REP(i,51)path[i] = 0;
  cin >> N >> M;
  REP(i,M){
    cin >> a >> b;
    path[a]++;
    path[b]++;
  }
  REP(i,N)
    cout << path[i+1] << endl;
  
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,k,mod;
int C[310][310],f[310][310],s[310][310];
int main()
{
	scanf("%d%d%d",&n,&k,&mod);
	C[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		C[0][i]=1;
		for (int j=1;j<=i;j++)
			C[j][i]=(C[j-1][i-1]+C[j][i-1])%mod;
	}
	for (int i=0;i<=k;i++) f[1][i]=1,s[1][i]=i;
	for (int i=2;i<=n+1;i++)
		for (int j=0;j<=k;j++)
		{
			int ans=0;
			for (int siz=1;siz<=i-1;siz++)
				ans=(1ll*C[siz-1][i-2]*f[i-siz][j]%mod*(s[siz][k]-s[siz][j]+mod)%mod+ans)%mod;
			f[i][j]=ans;
			s[i][j]=ans;
			if (j) s[i][j]=(ans+s[i][j-1])%mod;
		}
	printf("%d",f[n+1][0]);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll n = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int N;
void dfs(int id,string s,int ap)
{
	if(id==N)
	{
		cout<<s<<endl;
		return;
	}
	rep(i,0,ap+1)
	{
		string t=s;
		t+=(char)(i+'a');
		dfs(id+1,t,ap+(i==ap));
	}
}
main()
{
	cin>>N;
	dfs(0,"",0);
}


Measured memory_bytes: 1536
#include <stdio.h>

int main(void)
{
    char S[100], N=0, i=0, N_1, N_2, N_3, f=0, j;

    scanf("%s",S);

    while(S[i] != '\0'){
        N++;
        i++;
    }

    N_1 = N-1;
    //回文であるかの確かめ
    for(i=0; i<N_1/2; i++){
        if(S[i] != S[N_1 - i]) f=1;
    }

    N_2 = (N-1)/2;
    N_2--;
    //1文字目から(N-1)/2文字目までが回文か・0すたーとなので気を付ける
    for(i=0; i<N_2/2; i++){
        if(S[i] != S[N_2 - i]) f=1;
    }

    N_3 = (N+3)/2;
    N_3--;
    //(N+3)/2文字目からN文字目まで回文か・1こずれるの気を付ける
    j=1;
    for(i=N_3; i<(N_3 + N)/2; i++){
        //printf("%c %c\n",S[i], S[N-j]);
        if(S[i] != S[N - j]) {
            f=1;
        }
        j++;
    }

    //printf("%d %d",N, f);

    if(f == 1){
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}

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



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	VI dp(N+1);
	dp[0]=0;

	eFOR(i,1, N) {
		
		if (A[i - 2] == 1 && A[i-1]>0) {
			A[i - 1]++;
			A[i - 2] = 0;
		}

		if (A[i - 1] == 0) {
			dp[i] = dp[i-1];
		}
		else {
			dp[i] = dp[i - 1] + A[i-1]/2;
			A[i - 1] %= 2;
		}
		//REP(i, N)cout << A[i];
		//cout <<" "<< dp[i] << endl;
	}
	cout << dp[N] << endl;


	return 0;
}



Measured memory_bytes: 1792
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
#define pr(a,b) make_pair(a,b)
const int MAXN=20;
const long long INF=5e18;
int N;long long A[MAXN];
long long Solve(int L,int R,LL X,LL Y){
	if(L+1>=R)return 0;
	long long ret=INF;
	for(int i=L+1;i<=R-1;i++)
		ret=min(ret,Solve(L,i,X,X+Y)+Solve(i,R,X+Y,Y)+A[i]*(X+Y));
	return ret;
}
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%lld",&A[i]);
	printf("%lld\n",A[1]+A[N]+Solve(1,N,1,1));
}


Measured memory_bytes: 128
from bisect import bisect_right, bisect_left

N = int(input())
A = [int(input()) for _ in range(N)]

dp = [1]*N

for a in A:
    ia = bisect_right(dp, -a)
    if dp[ia] == 1:
        dp[ia] = -a
    else:
        ib = bisect_left(dp, -a+1)
        dp[ib] = -a
    #print(dp)

ans = 0
for i in range(N):
    if dp[i] != 1:
        ans += 1
print(ans)

Measured memory_bytes: 11140
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    int n,a,ans=0;
    cin>>n;
    priority_queue<int> pq;
    rep(i,n){
        cin>>a;
        pq.push(a);
        if(a==pq.top())
        ++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
let () =
  Scanf.scanf "%d %d\n" @@ fun x y ->
  Printf.printf "%d\n"
    (((if x<=3 then 4-x else 0) + 
      (if y<=3 then 4-y else 0) +
      (if x=1 && y=1 then 4 else 0)) * 100000)

Measured memory_bytes: 3820
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static long[] kaijo;
	 static long[] kaiinv;
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        int H = sc.nextInt();	
	        int W = sc.nextInt();
	        char[][] c = new char[H][W];
	        int[][] m = new int[H][W];
	        int cnt=0;
	        for(int i=0;i<H;i++) {
	        	String tmp = sc.next();
	        	c[i]=tmp.toCharArray();
	        	for(int j=0;j<W;j++) {
	        		if(c[i][j]=='#') {
	        			m[i][j]=-1;
	        			cnt++;
	        		}
	        	}
	        }
			LinkedList<Integer> queue = new LinkedList<Integer>();
			m[0][0]=1;
			queue.add(0);
			queue.add(0);
			queue.add(1);
			while(!queue.isEmpty()) {
				int h = queue.poll();
				int w = queue.poll();
				int d = queue.poll();
				if(h!=0&&m[h-1][w]==0) {
					m[h-1][w]=d+1;
					queue.add(h-1);
					queue.add(w);
					queue.add(d+1);
				}
				if(h!=H-1&&m[h+1][w]==0) {
					m[h+1][w]=d+1;
					queue.add(h+1);
					queue.add(w);
					queue.add(d+1);
				}
				if(w!=0&&m[h][w-1]==0) {
					m[h][w-1]=d+1;
					queue.add(h);
					queue.add(w-1);
					queue.add(d+1);
				}
				if(w!=W-1&&m[h][w+1]==0) {
					m[h][w+1]=d+1;
					queue.add(h);
					queue.add(w+1);
					queue.add(d+1);
				}
			}
	        if(m[H-1][W-1]==0){
	        	System.out.println(-1);
	        	return;
	        }
	        System.out.println(W*H-cnt-m[H-1][W-1]);
	        
	        
	 }

}

Measured memory_bytes: 21844
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	var ans []string
	fmt.Scan(&s)

	for _, v := range s {
		if v == '0' {
			ans = append(ans, "0")
		} else if v == '1' {
			ans = append(ans, "1")
		} else if v == 'B' && len(ans) != 0 {
			ans = ans[:len(ans)-1]
		}
	}
	fmt.Println(strings.Join(ans, ""))
}

Measured memory_bytes: 640