akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstring>

#define ll long long
const ll MOD = 1e9 + 7;

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

    bool dp[110000];
    memset(dp, false, sizeof(dp));

    int N, K;
    std::cin >> N >> K;
    std::vector<int> a(N);
    for (int i = 0; i < N; ++i)
        std::cin >> a[i];

    // 0個のとき先行は負け
    // dp[0] = false;
    for (int i = 1; i <= K; ++i)
    {
        // 取り方の数だけとる
        for (int j = 0; j < N; ++j)
        {
            // 先行は残り1個のとき1個とる -> 先行の価値
            // dp[1] |= !dp[1 - 1] : f -> t

            // 先行は残り2個のとき2個とる -> 先行の価値
            // dp[2] |= !dp[2 - 1] : t -> f
            // dp[2] |= !dp[2 - 2] : f -> t

            // 先行は残り3個のとき3個とる -> 先行の価値
            // dp[3] |= !dp[3 - 1] : t -> f
            // dp[3] |= !dp[3 - 2] : t -> f
            // dp[3] |= !dp[3 - 3] : f -> t

            // 先行が残り4個のとき1,2,3個とる -> 後攻の負け
            // dp[4] |= !dp[4 - 1] : t -> f
            // dp[4] |= !dp[4 - 2] : t -> f
            // dp[4] |= !dp[4 - 3] : t -> f

            // 先行が残り5個のとき1,2,3個とる ->
            // dp[5] |= !dp[5 - 1] : f -> t
            // dp[5] |= !dp[5 - 2] : t -> f
            // dp[5] |= !dp[5 - 3] : t -> f

            // 先行は i個のとき a[j] 個の石を取る
            if (0 <= i - a[j])
                dp[i] |= !dp[i - a[j]];
        }
    }

    if (dp[K])
        std::cout << "First" << std::endl;
    else
        std::cout << "Second" << std::endl;
}

Measured memory_bytes: 384
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int s;
    cin >> s;
    vector<int> A(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    vector<long long> dp(s + 1, 0);
    auto ndp = dp;
    dp[0] = 1;

    const long long MOD = 998244353;

    for (int i = 0; i < n; ++i) {
        fill(ndp.begin(), ndp.end(), 0);
        for (int j = 0; j <= s; ++j) {
            if (dp[j] == 0) {
                continue;
            }

            (ndp[j] += dp[j] * 2) %= MOD;
            {
                int nj = j + A[i];
                if (nj <= s) {
                    (ndp[nj] += dp[j]) %= MOD;
                }
            }
        }
        swap(ndp, dp);
    }

    cout << dp[s] << '\n';
    return 0;
}

Measured memory_bytes: 3708
import java.util.*;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] Items = new int[N];
		int kind=0;
		int maxA=0;
		for(int i=0;i<N;i++){
			Items[i] = sc.nextInt();
			if(maxA<Items[i]) maxA= Items[i];
		}
		int[] Corr = new int[maxA+1];
		for(int i: Items){
			if(Corr[i]==0){
				Corr[i]=1;
				kind++;
			}
		}	

			
		int MaxN=kind-1+kind%2;
		System.out.println(MaxN);
		sc.close();
	}
}

Measured memory_bytes: 31512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = 3;
		String[] ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
		
		Arrays.sort(ii0);

		System.out.println(ii0[0] + ii0[1]);
		
		

	return;
	}
	//-----------------------------------------------------------------
	// Debug.Print
	static void dp(String s) {
		System.out.println(s);
	}
	static void dp(StringBuilder s) { dp(s.toString()); }
	static void dp(int i) { dp(String.valueOf(i)); }
	static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	static void checkInput(long[] i1) {
		StringBuilder sb = new StringBuilder();
		for(long i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}


Measured memory_bytes: 22484
#include <iostream>

using namespace std;

int main(){
  int N, X;
  cin >> N >> X;
  int M[N];
  int ans,mindnt, cntM;
  mindnt =10000;
  for(int i=0;i<N;i++)cin >> M[i];
  for(int i=0;i<N;i++)
    if(mindnt > M[i])mindnt = M[i];
  for(int i=0;i<N;i++)X -= M[i];
  cout << N + X/mindnt << endl;

}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
 
    def root(self, i):
        if self.parent[i] == i:
            return i
        else:
            self.parent[i] = self.root(self.parent[i])
            return self.parent[i]
    
    def find(self, x, y):
        return self.root(x) == self.root(y)
 
    def union(self, i, j):
        i = self.root(i)
        j = self.root(j)
        self.parent[j] = i
N, M = map(int, input().split())
ps = list(map(int, input().split()))
ps = [i-1 for i in ps]
swap =[list(map(int, input().split())) for i in range(M)]
u = UnionFind(N)
for x, y in swap:
    u.union(x-1, y-1)
ans = 0
for i, p in enumerate(ps):
    if u.find(i, p):
        ans += 1
print(ans)

Measured memory_bytes: 35344
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll a, b;
//ld ;
//string s;

ll gcd(ll p, ll q){
    return q ? gcd(q, p%q) : p;
}

int main() {
    cin >> a >> b;
    //ll hou[n];
    ll gcd1 = gcd(a,b);
    ll lcm = a*b/gcd1;
    cout << lcm << endl;
    return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        char c;
        cin>>c;
        if(c>='a')cout<<"a";
        else cout<<"A";
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int f[100][10],c[100];
int p[100][11];

int main(){
    int n;
    cin>>n;
    rep(i,n){
        rep(j,10) cin>>f[i][j];
    }
    rep(i,n){
        rep(j,11) cin>>p[i][j];
    } 
    int ans=-1000000000,ans2=-1000000000;
    FOR(i,1,1024){
        memset(c,0,sizeof(c));
        rep(j,10){
            if(1<<j&i){
                rep(k,n){
                c[k]+=f[k][j];
                }
            }
        }
        int sum=0;
        rep(j,n){
            sum+=p[j][c[j]];
        }
        if(ans<=sum) ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}


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


int main(){
    int range;
    cin >> range;
    long long int ans = 0;
    for(int i = 0; i < range+1; i++){
        if(i%3==0||i%5==0){
        }else{
          ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
import math

INF = 10**9+7

def k(i):
    if(i == 1):
        return 1
    else:
        return(i * k(i-1))

def comb(n, r):
    if(n == r or r == 1):
        return 1
    else:
        return k(n) / (k(n-r) * k(r))

stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()
def nsl(): return list(stdin.readline().strip())
def ni(): return int(stdin.readline())
def nil(): return list(map(int, stdin.readline().split()))

s = input().split(" ")

a = s[0][0].upper()
b = s[1][0].upper()
c = s[2][0].upper()

print(a+b+c)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

int dp[2019] = {};
int ndp[2019]={};
int32_t main()
{
	FIO;
	string s; cin >> s;
	int n = s.length();

	dp[s[0] - '0'] = 1;
	int ans = dp[0];

	for (int i = 1; i < n; ++i)
	{
		int d = s[i] - '0';
		for (int j = 0; j < 2019; ++j)
		{
			ndp[(j * 10 + d) % 2019] += dp[j];
		}

        ndp[d]++;

        for(int j=0;j<2019;++j)
            dp[j]=ndp[j],ndp[j]=0;

		

		//cout << i << ' ' << dp[i][0] << '\n';

		ans += dp[0];
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main(){
  cin>>N;  
  multiset<ll> goal; 
  rep(j,(1LL<<N)){ 
    cin>>A; 
    goal.insert(A); 
  } 
  queue<ll> now;
  auto big = goal.end(); 
  --big;
  now.push(*big); 
  goal.erase(big);
  rep(i,N){ 
    rep(j,(1LL<<i)){ 
      ll sli = now.front(); 
      now.pop(); 
      now.push(sli); 
      auto son = goal.lower_bound(sli);
      /*cout<<i<<j<<endl;
      for(ll c : goal) cout<<c; 
      cout<<endl; */
      if(son == goal.begin()) {
        cout<<"No"<<endl; 
        return 0;
      } 
      --son; 
      now.push(*son);
      goal.erase(son); 
    } 
  } 
  cout<<"Yes"<<endl; 
}


Measured memory_bytes: 13696
ALPHA = "abcdefghijklmnopqrstuvwxyz"
import math


def solve(x):
    b = 1
    for n in range(2, x):
        for k in range(2,12):
            if n ** k > x:
                break
            else:
                u = n**k
                b = max(b, u)
    return b


def main():
    # a, b, c, d = [int(a) for a in input().split()]
    res = solve(int(input()))
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = int(input())
table = [0] * (n + 1)
divider = 2
cnt = 0
able3 = 0
able5 = 0
able15 = 0
able25 = 0
able75 = 0

for i in range(1, n + 1):
    while True:
        if i == 1:
            divider = 2
            break
        elif i % divider == 0:
            table[divider] += 1
            i //= divider
        else:
            divider += 1

for i in table:
    if 2 <= i:
        able3 += 1
    if 4 <= i:
        able5 += 1
    if 14 <= i:
        able15 += 1
    if 24 <= i:
        able25 += 1
    if 74 <= i:
        able75 += 1

cnt += (able5 - 1) * able15  # 5 * 25
cnt += (able3 - 2) * (able5 - 1) * able5 // 2  # 3 * 5 * 5
cnt += (able3 - 1) * able25  # 25 * 3
cnt += able75  # 75
print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n+1),cum(n+1,0);
    rep(i,n+1) cin>>a[i];
    cum[n]=a[n];
    for(ll i=n-1;i>=0;i--) cum[i]+=cum[i+1]+a[i];
    ll nv=1,ans=0;
    rep(i,n+1){
        ans+=nv;
        if(i==n){
            if(nv!=a[i]){
                cout<<-1<<endl;
                return 0;
            }
        }else{
            nv-=a[i];
            if(nv<=0){
                cout<<-1<<endl;
                return 0;
            }
            nv=min(nv*2,cum[i+1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4808
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
#define INF (1 << 30)
#define all ((1 << 12) - 1)

int xs[] = {0, -1, 0, 1}, ys[] = {-1, 0, 1, 0};
int h, w, k;
int dp[52][52][4][1 << 12];
string port[52];

bool back(int last){
    int p = 0, q = 0;
    for(int i = 0;i < 6;i++){
	p += xs[last % 4];
	q += ys[last % 4];
	if(p == 0 && q == 0)return true;
	last >>= 2;
    }
    return false;
}

int solve(int x, int y, int d, int last){
    if(x == 0 && y == 0 && d == 0)return 0;
    if(x < 0 || x >= h || y < 0 || y >= w || d < 0)return -INF;
    if(dp[x][y][d][last] != -INF)return dp[x][y][d][last];
    if(port[x][y] == '#')return -INF;
    int add = 0, res = -INF;
    if(port[x][y] != '.' && !back(last))add = port[x][y] - '0';
    for(int i = 0;i < 4;i++){
	x += xs[i];y += ys[i];
	if(i == 2)d--;
	res = max(res, solve(x, y, d, all & ((last << 2) + i)));
	x -= xs[i];y -= ys[i];	   
    }
       d++;
    return dp[x][y][d][last] = res + add;
}

int main(){
    cin >> h >> w >> k;
    for(int i = 0;i < h;i++){
	cin >> port[i];
	for(int j = 0;j < w;j++){
	    for(int k = 0;k <= 3;k++){
		fill(dp[i][j][k], dp[i][j][k] + (1 << 12), -INF);
	    }
	}
    }
    int res = -INF;
    for(int i = 0;i <= k;i++){
	res = max(res, solve(h - 1, w - 1, i, 0));
    }
    cout << res << endl;
    return 0;
}

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

ID = list()
for i in range(M):
    ID.append(list(map(int, input().split())))

nega = 0
posi = N

check = 1
for (L, R) in ID:
    if L > nega:
        nega = L
    if R < posi:
        posi = R
    if R < nega or posi < L:
        check = 0

if check == 1:
    print(posi-nega+1)
else:
    print(0)

Measured memory_bytes: 27348
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;
 
void solve(){
	string s;
    cin>>s;
    map<char,int>mp;
    rep(i,s.size()){
        mp[s[i]]++;
    }
    //ある文字(文字数が一番多いならその文字)について一番区間が大きいものを求めその最小値が答え
    //自分より前のものしか変えられないが、後ろのは1回ごとに消滅していくから
    int n=s.size();
    int ans=n/2;
    if(mp.size()==1)
    {cout<<0<<"\n";
    return;
    }
    for(auto x:mp){
        if(x.second>1){
            int memo,maxv=0;
            rep(i,n){
                if(s[i]==x.first){
                    memo=i;
                    break;
                }
            }
            maxv=max(maxv,memo);
            int cnt=1;
            int cur=memo,nxt=memo+1;
            while(x.second>cnt){
                ++cnt;
                while(s[cur]!=s[nxt])++nxt;
                maxv=max(maxv,nxt-cur-1);
                cur=nxt;
                nxt=cur+1;
            }
            maxv=max(maxv,n-cur-1);
            ans=min(ans,maxv);
        }

    }
    cout<<ans<<"\n";
}
 
signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
typedef unsigned long long ull;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "

int gcd(int x, int y)
{
  return x?gcd(y%x, x):y;
}

int main()
{
  int n; scanf("%d", &n);
  vector<int> v(n);
  for (auto & e : v) scanf("%d", &e);
  int cur = 0;
  for (;; cur ^= 1)
    {
      vector<int> cnt(2, 0);
      vector<int> last(2, -1);
      for (int i = 0; i < v.size(); ++i)
	{
	  int parity = v[i]%2;
	  ++cnt[parity];
	  last[parity] = i;
	}
      if (cnt[0]%2 == 1) 
	{
	  break;
	}
      else if (cnt[1] == 1 && v[last[1]] != 1)
	{
	  --v[last[1]];
	  int g = 0;
	  for (auto e : v) g = gcd(g, e);
	  for (auto &e : v) e /= g;
	}
      else 
	{
	  cur ^= 1;
	  break;
	}
    }
  puts(cur?"Second":"First");
}


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

using namespace std;
int main(){
	string s;
	cin>>s;
	int a=0;
	for(int i=0;i<s.length();i++){
		a+=int(s[i])-int('0');
	}
	if(a%9==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  cin>>s1>>s2;
  int cnt=0;
  for(int i=0;i<s1.size();i++)
  {
    if(s1[i]!=s2[i])
    {
      cnt++;
    }
  }
  cout<<cnt;
  return 0;
}

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

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


int main()
{
    int64_t n;
    string s = "";

    cin >> n;

    while(n!=0)
    {
        n--;
        s += 'a' + n % 26;
        n /= 26;
    }

    reverse(s.begin(), s.end());

    cout << s << endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const int N=11e5+10,mod=924844033;
int qp(int x,int k)
{
	int res=1;
	for(;k;k>>=1,x=1ll*x*x%mod)
		if(k&1)
			res=1ll*x*res%mod;
	return res;
}
int n,rev[N],lim,tmp,len;
int head[N],tot;
struct edge
{
	int to,next;
}e[N<<1];
void adde(int a,int b)
{
	e[++tot].to=b; e[tot].next=head[a]; head[a]=tot;
}
int cnt[N],ans[N];
int dfs(int k,int fa)
{
	int sz=1;
	for (int i=head[k];i;i=e[i].next)
		if(e[i].to!=fa)
			sz+=dfs(e[i].to,k);
	if(fa)cnt[sz]++,cnt[n-sz]++;
	return sz;
}
int fac[N],inv[N],num[N];
void init()
{
	lim=N-10;
	fac[0]=inv[0]=1;
	for(int i=1;i<=lim;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[lim]=qp(fac[lim],mod-2);
	for(int i=lim-1;i;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
void ntt(int f[],int opt)
{
	for(int i=0;i<lim;i++)
		if(i<rev[i])
			swap(f[i],f[rev[i]]);
	for(int i=1;i<lim;i<<=1)
	{
		int tmp=i<<1;
		int w=qp(5,opt?(mod-1)/tmp:mod-1-(mod-1)/tmp);
		for(int j=0;j<lim;j+=tmp)
		{
			int wn=1;
			for(int k=0;k<i;k++,wn=1ll*w*wn%mod)
			{
				int x=1ll*wn*f[i+j+k]%mod;
				f[i+j+k]=(f[j+k]-x+mod)%mod;
				f[j+k]=(f[j+k]+x)%mod;
			}
		}
	}
	if(!opt)
	{
		int inv=qp(lim,mod-2);
		for(int i=0;i<lim;i++)
			f[i]=1ll*f[i]*inv%mod;
	}
}
int main()
{
	scanf("%d",&n);
	int u,v;
	for(int i=1;i<n;i++)
		scanf("%d%d",&u,&v),adde(v,u),adde(u,v);
	init();
	dfs(1,0);
	for(int i=1;i<=n;i++)
		cnt[i]=1ll*cnt[i]*fac[i]%mod;
	for(int i=0;i<=n;i++)
		num[n-i]=inv[i];
	for(len=n+n+1,lim=1;lim<=len;lim<<=1,tmp++);
	for(int i=0;i<lim;i++)
		rev[i]=(rev[i>>1]>>1)|((i&1)<<tmp-1);
	ntt(cnt,1); ntt(num,1);
	for(int i=0;i<lim;i++)
		ans[i]=1ll*cnt[i]*num[i]%mod;
	ntt(ans,0);
	for(int i=1;i<=n;i++)
		printf("%lld\n",(1ll*fac[n]*inv[i]%mod*inv[n-i]%mod*n%mod-1ll*ans[i+n]*inv[i]%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 44928
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, k = list(map(int, input().strip().split()))
    d = input().strip().split()
    ans = n
    while True:
        sans = str(ans)
        flag = False
        for c in sans:
            # print(c)
            # print('d ', d)
            if c in d:
                ans += 1
                flag = True
                break
        if flag:
            continue
        print(sans)
        return

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  long long n, m;
  cin >> n >> m;
  if(n==1 && m==1)cout << 1 << endl;
  else if(n==1 || m==1)cout << n*m-2 << endl;
  else cout << (n-2)*(m-2) << endl;
  return 0;
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<llint> make_divisors(llint x){
	vector<llint> div;
	for(llint i=1;i*i<=x;i++){
		if(x%i==0){
			div.push_back(i);
			if(x/i!=i)div.push_back(x/i);
		}
	}
	return div;
}

void solve(){
	llint n,m;
	cin >> n >> m;
	vector<llint>div=make_divisors(m);
	llint ans=0;
	for(auto d:div){
		if(d*n<=m)ans=max(ans,d);
	}
	cout << ans << endl;
}

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


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n, h, w;
    cin >> n >> h >> w;

    int ans = ((n - h) + 1) * ((n - w) + 1);

    cout << ans << '\n';
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();

        long answer = k;
        for (long i = 2; i <= n; i++)
        {
            answer = answer *= (k - 1);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> es(n);
    vector<int> dp(n, 0);
    rep(i, m) {
        int a,b; cin >> a >> b;
        --a; --b;
        es[a].push_back(b);
        es[b].push_back(a);
        dp[a]++; dp[b]++;
    }  
    queue<int> st;
    rep(i, n) if (dp[i] == 1) st.push(i);
    int cnt = 0; 
    while (!st.empty()) {
        int a = st.front(); st.pop();
        if (dp[a] > 0) {
            dp[a]--;
            ++cnt;
        }
        for (int b : es[a]) {
            if (dp[b] > 0) dp[b]--;
            if (dp[b] == 1) st.push(b);
        }
    } 
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

b = 0
s = 0
ans = 1
for i in range(n-1):
    if a[i] < a[i+1]:
        b = 1
    elif a[i] > a[i+1]:
        s = 1
    if b and s:
        ans += 1
        b = 0
        s = 0
print(ans)

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

using namespace std;

long long inf=1000000007;

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	vector<int> col(n);
	for(int i=0;i<n;i++) cin>>col.at(i);

	vector<vector<int>> grid(h,vector<int>(w));

	for(int i=0;i<h;i++){
		int j=0;
		if(i%2==1) j=w-1;

		while(0<=j && j<w){
			int C=distance(col.begin(),upper_bound(col.begin(),col.end(),0))+1;
			grid.at(i).at(j)=C;
			col.at(C-1)--;

			if(i%2==0) j++;
			else j--;
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<grid.at(i).at(j);
			if(j<w-1) cout<<" ";
			else cout<<endl;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int n; sc(n);
    vector<int> a(n+1), b(n);
    rep(i, 0, n+1) sc(a[i]);
    rep(i, 0, n) sc(b[i]);
    ll ans = 0;
    rep(i, 0, n){
        if (b[i] < a[i]) ans += b[i], b[i] = 0;
        else ans += a[i], b[i] -= a[i];
        if (b[i] < a[i+1]) ans += b[i], a[i+1] -= b[i];
        else ans += a[i+1], a[i+1] = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(readline()) for _ in range(n)]


acc1 = [0]*(n+1)
acc2 = [0]*(n+1)

for i in range(n):
    acc1[i+1] = max(acc1[i],a[i])
    acc2[-i-2] = max(acc2[-i-1],a[-i-1])

for i in range(n):
    print(max(acc1[i], acc2[i+1]))

#print(a)
#print(acc1)
#print(acc2)

Measured memory_bytes: 15680
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
Int MOD=1e9+9; //<- alert!!!
typedef vector<Int> arr;
typedef vector<arr> mat;
inline arr mul(mat a,arr& b,Int mod){
  arr res(b.size(),0);
  for(int i=0;i<(int)b.size();i++)
    for(int j=0;j<(int)a[i].size();j++)
      (res[i]+=a[i][j]*b[j])%=mod;
  return res;
}
inline mat mul(mat& a,mat& b,Int mod){
  mat res(a.size(),arr(b[0].size(),0));
  for(int i=0;i<(int)a.size();i++)
    for(int j=0;j<(int)b[0].size();j++)
      for(int k=0;k<(int)b.size();k++)
	(res[i][j]+=a[i][k]*b[k][j])%=mod;
  return res;
}
inline mat mat_pow(mat a,Int n,Int mod){
  mat res(a);
  for(int i=0;i<(int)a.size();i++)
    for(int j=0;j<(int)a[i].size();j++)
      res[i][j]=(i==j);
  while(n){
    if(n&1) res=mul(a,res,mod);
    a=mul(a,a,mod);
    n>>=1;
  }
  return res;
}
//END CUT HERE
mat base;
mat memo[100];
void init(mat a,Int mod){
  base=mat(a);
  for(int i=0;i<(int)base.size();i++)
    for(int j=0;j<(int)base.size();j++)
      base[i][j]=i==j;
  memo[0]=a;
  for(int k=1;k<70;k++)
    memo[k]=mul(memo[k-1],memo[k-1],mod);
}
inline mat mat_pow2(Int n,Int mod){
  mat res(base);
  int k=0;
  while(n){
    if(n&1) res=mul(memo[k],res,mod);
    n>>=1;
    k++;
  }
  return res;
}

typedef pair<Int,Int> P;
signed main(){
  Int w,h,n,cnt=0;
  while(cin>>w>>h>>n,w||h||n){
    Int x[n],y[n];
    for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
    P p[n];
    for(Int i=0;i<n;i++) p[i]=P(y[i],x[i]);
    sort(p,p+n);
    for(Int i=0;i<n;i++) x[i]=p[i].second,y[i]=p[i].first;
    arr a(w,0);
    a[0]=1;
    mat b(w,arr(w,0));
    for(Int i=0;i<w;i++){
      for(Int j=0;j<w;j++) b[i][j]=0;
      b[i][i]=1;
      if(i-1>=0) b[i][i-1]=1;
      if(i+1<w)  b[i][i+1]=1;
    }
    init(b,MOD);
    Int d=1;
    for(Int k=0;k<n;k++){
      if(y[k]==d) continue;
      a=mul(mat_pow2(y[k]-d-1,MOD),a,MOD);
      Int j=k;
      mat c=b;
      while(j<n&&y[k]==y[j]){
	for(Int i=0;i<w;i++) c[x[j]-1][i]=0;
	j++;
      }
      a=mul(c,a,MOD);
      d=y[k];
    }
    a=mul(mat_pow2(h-d,MOD),a,MOD);
    cout<<"Case "<<++cnt<<": "<<a[w-1]<<endl;
  }
  return 0;
}

/*
  verified on 2017/10/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2397
*/



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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

struct edge {
  ll to, cost;
};

vector<ll> dijkstra(vector<vector<edge>> &g, ll s) {
  vector<ll> dist(g.size(), INF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    ll cost, idx;
    tie(cost, idx) = que.top();
    que.pop();
    if (dist[idx] < cost) continue;
    for (auto &e : g[idx]) {
      if (dist[e.to] > cost + e.cost) {
        dist[e.to] = cost + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }

  return dist;
}

int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  vector<vector<edge>> g1(n), g2(n);
  REP(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    --u, --v;
    edge e1, e2, e3, e4;
    e1.cost = a, e1.to = v;
    e2.cost = a, e2.to = u;
    e3.cost = b, e3.to = v;
    e4.cost = b, e4.to = u;
    g1[u].push_back(e1);
    g1[v].push_back(e2);
    g2[u].push_back(e3);
    g2[v].push_back(e4);
  }

  auto d1 = dijkstra(g1, s);
  auto d2 = dijkstra(g2, t);

  vector<ll> ans;
  ll mn = INF;
  REPR(i, n - 1) {
    mn = min(mn, d1[i] + d2[i]);
    ans.push_back(mn);
  }

  reverse(ALL(ans));
  REP(i, n) { cout << INF - ans[i] << endl; }

  return 0;
}

Measured memory_bytes: 19964
#平均値に近づけるという考え方が間違い-->中央値に近づける

N = int(input())
A = list(map(int, input().split()))

A = [A[i]-(i+1) for i in range(N)]

A.sort()

center1 = A[N//2]
if N == 1:
    center2 = 10 ** 9
else:
    center2 = A[(N+2)//2]

ans1 = 0
for i in range(N):
    ans1 +=abs(A[i]-center1)
    
ans2 = 0
for j in range(N):
    ans2 += abs(A[j]-center2)
    
print (min(ans1, ans2))

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

using namespace std;

int main() {
	bool isOver = false;
	while (!isOver) {
		string s;
		cin >> s;
		if (s[0] == '0') {
			isOver = true;
			break;
		}
		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			char temp = s[i];
			int x = temp - 48;
			sum += x;
		}

		cout << sum << endl;
	}

	
	return 0;
}

Measured memory_bytes: 3176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

long long a[100005],b[100005],c[100005];

int main(){
	long long n,sum1 = 0LL,sum2 = 0LL;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = 1;i <= n;i++) cin >> b[i];
	for(int i = 1;i <= n;i++){
		c[i] = a[i] - b[i];
		if(c[i] > 0LL) sum1 += c[i];
		else if(c[i] < 0LL) sum2 += c[i];
	}
	long long ans = sum1 * 2LL;
	for(int i = 1;i <= n;i++){
		if(c[i] < 0){
			ans -= ((b[i] - a[i]) / 2LL) * 2;
		}
	}
	if(ans > 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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


char s[1000005];
int dp[1000005][2];
int n;

int dfs(int level,int c)//位置、进位
{
	if(level==n) return c;
	if(dp[level][c]>=0) return dp[level][c];
	return dp[level][c]=std::min(s[level]+c+dfs(level+1,0),10-s[level]-c+dfs(level+1,1));
}

int main()
{
	// freopen("test.in","r",stdin);
	scanf("%s",s);
	n=strlen(s);
	for(int i=0,j=n-1;j>=i;i++,j--)
	{
		s[i]-='0';
		if(i!=j)
			s[j] -= '0', std::swap(s[i], s[j]);
	}
	memset(dp,-1,sizeof(dp));
	printf("%d\n",dfs(0,0));
	return 0;
}

Measured memory_bytes: 55936
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	int non = 0;
	long long mnum;
	long long res = 0;
	for (int i = 0; i < N; ++i) {
		long long num;
		cin >> num;
		if (num < 0) {
			++non;
			num = -num;
		}
		if (i == 0) {
			mnum = num;
		}
		else {
			mnum = min(num,mnum);
		}
		res += abs(num);
	}
	if (non%2 == 1) {
		res -= 2*mnum;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,ll>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
int b[maxx];
int main(){
    int n; cin>>n;
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i==1) sum+=b[i];
        else if(i==n) sum+=b[n-1];
        else{
            sum+=min(b[i],b[i-1]);
        }
    }
    cout<<sum<<endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];
    SORT(a);
    cout << (a[2] - a[1]) + (a[1] - a[0]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int N;
string s;
int main(){
    cin>>N>>s;
    int x=0;
    int ans=0;
    for(int i=0;i<N;i++){
        if(s[i]=='I')x++;
	else x--;
	ans=max(ans,x);
    }
    cout<<ans<<endl;
}

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

int n, s, x[101000];
long long p[101000];

int main(void) {
  scanf("%d%d", &n, &s);
  for(int i = 1; i <= n; i++) {
    scanf("%d%lld", &x[i], &p[i]);
  }
  int l = 1, r = n, flg1 = 1, flg2 = 1;
  long long ans = 0;
  while(l <= r) {
    if(s <= x[l]) {
      ans += x[r] - s;
      break;
    }
    if(s >= x[r]) {
      ans += s - x[l];
      break;
    }
    if(p[l] >= p[r]) {
      p[l] += p[r];
      if(flg1) ans += x[r] - x[l];
      r--;
      flg1 = 0;
      flg2 = 1;
    } else {
      p[r] += p[l];
      if(flg2) ans += x[r] - x[l];
      l++;
      flg2 = 0;
      flg1 = 1;
    }
    //hcerr << l << " " << r << " " << ans << endl;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int x1,x2,x3;
  int c=0,h=0;

  while(scanf("%d,%d,%d",&x1,&x2,&x3)!=EOF){
    if(x1*x1+x2*x2==x3*x3)
      c++;
    if(x1==x2)
      h++;
  }
  printf("%d\n%d\n",c,h);
  return 0;
}

Measured memory_bytes: 0
#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))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

llint n;
llint a[100005][2];
bool used[100005][2];
vector<E> vec;
vector<P> mvec, Mvec;

int main(void)
{
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cin >> a[i][0] >> a[i][1];
		vec.push_back(E(a[i][0], P(i, 0)));
		vec.push_back(E(a[i][1], P(i, 1)));
	}
	sort(vec.begin(), vec.end());
	
	llint sum = 0;
	for(int i = 0; i < n; i++) sum += vec[i].first;
	if(vec[n-1].first == vec[n].first){
		cout << sum << endl;
		return 0;
	}
	
	for(int i = 0; i < n; i++){
		used[vec[i].second.first][vec[i].second.second] = true;
	}
	for(int i = 1; i <= n; i++){
		if(used[i][0] && used[i][1]){
			cout << sum << endl;
			return 0;
		}
	}
	
	bool flag[2] = {};
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 2; j++){
			if(used[i][j]) Mvec.push_back(P(a[i][j], i)), flag[j] = true;
			else mvec.push_back(P(a[i][j], i));
		}
	}
	sort(Mvec.rbegin(), Mvec.rend());
	sort(mvec.begin(), mvec.end());
	
	if(!flag[0] || !flag[1]){
		cout << sum << endl;
		return 0;
	}
	
	llint ans = inf; 
	if(Mvec[0].second != mvec[0].second) ans = mvec[0].first - Mvec[0].first;
	else{
		ans = min(mvec[0].first - Mvec[1].first, mvec[1].first - Mvec[0].first);
	}
	ans += sum;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 13804
process.stdin.on("data",function(c){
	(c+"").trim().split("\n").slice(1).some(function(a){
		a=a.split(" ");
		var b=0,c=0;
		console.log(a.some(function(n){
			return b<(n=+n)?(b=n,0):c<n?(c=n,0):1;
		})?"NO":"YES");
	});
}).resume();

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	rep(i,m) cin >> a[i] >> b[i];
	map<int,int> cnt;
	rep(i,m){
		cnt[a[i]]++;
	}		
	rep(i,m){
		cnt[b[i]]++;
	}	
	for(int i = 1; i <= n; i++){
		cout << cnt[i] << endl;
	}
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(void)
{
	int a,b,c,max;

	scanf("%d %d %d",&a,&b,&c);


	if(a>b){
		max=a;
		a=b;
		b=max;
	}
	if(b>c){
		max=b;
		b=c;
		c=max;
	}

	if(a>b){
		max=a;
		a=b;
		b=max;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2052
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'Yes' if 'A' in S and 'B' in S else 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38256
import sys
K=int(input())

if K%2==0 or K%5==0:
  print(-1)
  sys.exit(0)

k_mod=0
seven_k=0
for i in range(1,K+1):
  k_mod=10*k_mod+7
  k_mod%=K
  if k_mod==0:
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 63196
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int count = 0;
    for (int i = 0; i < N; i++) {
      long a = sc.nextLong();
      while (a > 0) {
        if (a % 2 != 0) {
          break;
        }
        count++;
        a /= 2;
      }
    }
    System.out.println(count);
  }
}

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

int n;
ll a[200005];

bool check(int x,ll key){
  ll* p=&a[x];
  ll* ed=&a[x+n+1];
  
  for(int i=0;i<3;i++){
    ll target=*p;
    p=lower_bound(p,ed,target+key);
    if(p==ed)return false;
  }  
  return true;
}

ll solve(int x,ll sum){
  ll L=2,R=sum/3,M;
  while(L<R){
    M=(L+R)/2;
    if(check(x,M))L=M+1;
    else R=M;
  }
  return L-1;
}

int main(){
  cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++){cin>>a[i];sum+=a[i];}
  for(int i=n+1;i<=n+n;i++)a[i]=a[i-n];

  for(int i=1;i<=n+n;i++)a[i]+=a[i-1];
  
  ll ans=0;
  for(int i=0;i<n;i++)ans=max(ans,solve(i,sum));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, R> a) {cerr << "(" << a.ST << ", " << a.ND << ")";}
template<class T> void db(V<T> v) 
{ cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__); 
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

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

	int n, k;
	cin >> n >> k;

	VI a(n);
	REP(i, n)
		cin >> a[i];

	V<bool> first_win(k + 1);
	first_win[0] = false;
	FOR(i, 1, k)
	{
		for(int x : a)
		{
			if(i >= x && first_win[i - x] == false)
			{
				first_win[i] = true;
				break;
			}
		}
	}

	cout << (first_win[k] ? "First\n" : "Second\n");
}


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

int main() {
	long long n,m,r,g,b,i,j,k,cur,ans=0,res;

	cin >> n;
	for(i=1; i*(i+1)+i<=n; i++){
		if((n-i)%i==0){
			ans+=(n-i)/i;
		}
	}
	cout << ans;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back


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

    mat C(2001, vec(2001, 0));
    C[0][0] = 1;
    REP(i,1,2001) {
        C[i][0] = 1;
        REP(j,1,2001) {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
        }
    }

    ll sum = 0;
    REP(i,1,S/3+1) {
        if(S >= i*2+1) sum = (sum + C[S-2*i-1][i-1]) % MOD;
    }
    PR(sum);

    return 0;
}

/*



*/

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

using ll = long long; 

const int MOD = 1e9+7;

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

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

int my_pow(int x, int e) {
    if (e == 0) {
        return 1;
    }
    
    if (e % 2 == 0) {
        int temp = my_pow(x, e/2);
        return mul(temp, temp);
    }
    else {
        return mul(x, my_pow(x, e-1));
    }
}

int my_inv(int x) {
    return my_pow(x, MOD-2);
}

int nCk(int n, int k) {
    // n! / (n-k)!*k!
    // return mul(fac[n], my_inv(mul(fac[n-k], fac[k])));
    int ans = 1;
    
    for (int i = 1; i <= k; i++) {
        ans = mul( mul(ans, n-i+1), my_inv(i) );
    }
    
    return ans;
}

int main() {
    int n, a, b;
    int n_fac, a_fac, b_fac;
    
    scanf("%d%d%d", &n, &a, &b);
    
    //vector<int> fac(n+1);
    
    //fac[0] = 1;
 
    
    int ans = my_pow(2, n);
    
    ans = sub(ans, nCk(n, a));
    
    ans = sub(ans, nCk(n, b));
    
    ans = sub(ans, 1); // empty set
    
    //int ans = sub(my_pow(2, n), add(nCk(n, a, fac), nCk(n, b, fac)));
    
    printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 3764
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string s;
cin>>s;
for(int i=0;i<s.size();i++)cout<<'x';
cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,p[200][3],r[200],m;
	scanf("%d",&n);
	rep(i,n){
		rep(j,3)scanf("%d",p[i]+j);
		r[i]=0;
	}
	
	rep(i,3){
		rep(j,n){
			r[j]+=p[j][i];
			rep(k,n){
				if(p[j][i]==p[k][i] && k!=j){
					r[j]-=p[j][i];
					break;
				}
			}
		}
	}
	rep(i,n)printf("%d\n",r[i]);
	return 0;
}

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

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, c, k, t[100000], ans = 0, now, ride = 0;
  cin >> n >> c >> k;
  for(int i = 0; i < n; i++){
    cin >> t[i];
  }
  sort(t, t + n);
  for(int i = 0; i < n; i++){
    if(!ride){
      ride++;
      now = t[i] + k;
      ans++;
      if(ride == c){
        ride = 0;
      }
      continue;
    }
    if(t[i] <= now){
      ride++;
      if(ride == c){
        ride = 0;
      }
    }
    else{
      ride = 1;
      now = t[i] + k;
      ans++;
      if(ride == c){
        ride = 0;
      }
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

char s;

int main(){

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

cin >> s;
if (isupper(s))
   {
       cout <<'A'<< endl;
   }
   else
   {
       cout << 'a' << endl;
   }

   return 0;

}
    


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx;
	int dy = ty - sy;
	for (int i = 0; i < dy; i++) {
		printf("U");
	}
	for (int i = 0; i < dx; i++) {
		printf("R");
	}
	for (int i = 0; i < dy; i++) {
		printf("D");
	}
	for (int i = 0; i <= dx; i++) {
		printf("L");
	}
	for (int i = 0; i <= dy; i++) {
		printf("U");
	}
	for (int i = 0; i <= dx; i++) {
		printf("R");
	}
	printf("D");
	printf("R");
	for (int i = 0; i <= dy; i++) {
		printf("D");
	}
	for (int i = 0; i <= dx; i++) {
		printf("L");
	}
	printf("U");
}

Measured memory_bytes: 256