akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

struct Area {
    int tly, tlz, bry, brz;
    Area(): tly(100), tlz(100), bry(-1), brz(-1) {}
};

int w, h;
char C[50][50];
map<char, set<char>> rels;
bool visited[26];

bool dfs(char c) {
    if(visited[c-'A']) return false;
    visited[c-'A'] = true;
    bool ret = true;
    for(char u: rels[c]) ret = ret && dfs(u);
    visited[c-'A'] = false;
    return ret;
}

int main() {
	int n; cin >> n;
	rep(i, n) {
	    cin >> h >> w;
	    rep(i, h) scanf("%s", &C[i]);

	    map<char, Area> objs;
	    rep(i, h) {
	        rep(j, w) {
	            if(C[i][j] == '.') continue;
	            objs[C[i][j]].tly = min(i, objs[C[i][j]].tly);
	            objs[C[i][j]].tlz = min(j, objs[C[i][j]].tlz);
	            objs[C[i][j]].bry = max(i, objs[C[i][j]].bry);
	            objs[C[i][j]].brz = max(j, objs[C[i][j]].brz);
	        }
	    }
	    bool issafe = true;
	    for(auto o: objs) {
	        rels[o.first].clear();
	        REP(i, o.second.tly, o.second.bry+1) {
	            REP(j, o.second.tlz, o.second.brz+1) {
	                if(C[i][j] == '.') issafe = false;
	                else if(C[i][j] != o.first) {
                        rels[o.first].insert(C[i][j]);
	                }
	            }
	        }
	    }
	    memset(visited, false, 26);
	    for(auto o: objs) issafe = issafe && dfs(o.first);
	    cout << (issafe? "SAFE":"SUSPICIOUS") << endl;
	}
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    if(n<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
}

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

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

const long long MOD = 1000000007;

int main(){
  ll x,y;
  cin >> x >> y;
  int ans = 1;
  while(2*x<=y){
    x*=2;
    ans++;
  }
  cout <<ans <<endl;
}


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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  
  int ans = 1;
  int sum = Y+2 * Z;
  while (sum + Y+Z <= X) { 
    sum += Y + Z;
    ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 

const int MAX_N = 4010;
const int MAX_M = 4010;


class my_binary_serch{
private:
	vi v;
public:
	void push(int n){v.pb(n);}
	void maxHeapify(int i){
		int l = i * 2 + 1;
		int r = i * 2 + 2;
		int largest;
		if(l < v.size() && v[l] > v[i]) largest = l;
		else largest = i;
		
		if(r < v.size() && v[r] > v[largest]) largest = r;

		if(largest != i){
			swap(v[i], v[largest]);
			maxHeapify(largest);
		}
	}
	void buildMaxHeap(){
		for(int i = v.size() / 2; i >= 0; i--){
			maxHeapify(i);
		}
	}
	void print(){
		for(int i = 0; i < v.size(); i++){
			cout<<" "<<v[i];
		}
		cout<<endl;
	}
};


int main(){
	my_binary_serch q;
	int n, t;
	cin>>n;
	for(int i = 0; i < n; i++) {
		cin>>t;
		q.push(t);
	}
	q.buildMaxHeap();
	q.print();
}

Measured memory_bytes: 3112
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr= new int[n];
		for(int i=0; i<n; i++) {
			arr[i]=sc.nextInt();
		}
		Arrays.sort(arr);
		boolean flag=true;
		for(int i=0; i<n-1; i++) {
			if(arr[i]==arr[i+1] ) {
				flag=false;
				break;
			}
		}
		if(flag==true) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}
		

Measured memory_bytes: 64480
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 1000000000
using namespace std;

int main()
{
	vector<int> dp(MAX, INF), res(MAX, INF), four, odd;
	for (int i = 1; i * (i + 1) * (i + 2) / 6 < MAX; i++) {
		four.push_back(i * (i + 1) * (i + 2) / 6);
		dp[i * (i + 1) * (i + 2) / 6] = 1;
		if (i * (i + 1) * (i + 2) / 6 % 2) {
			odd.push_back(i * (i + 1) * (i + 2) / 6);
			res[i * (i + 1) * (i + 2) / 6] = 1;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = MAX - 1; j >= 0; j--) {
			if (dp[j] != INF) {
				for (int k = 0; k < four.size() && j + four[k] < MAX;k++) {
					dp[j + four[k]] = min(dp[j + four[k]], dp[j] + 1);
				}
			}
		}
	}
	int n;
	while (cin >> n, n) {
		cout << dp[n] << ' ';
		while (res[n] == INF) {
			for (int j = MAX - 1; j >= 0; j--) {
				if (res[j] != INF) {
					for (int k = 0; k < odd.size() && j + odd[k] < MAX; k++) {
						res[j + odd[k]] = min(res[j + odd[k]], res[j] + 1);
					}
				}
			}
		}
		cout << res[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 10552
#define IO std::ios::sync_with_stdio(false);
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b;
int main(){
	cin>>a>>b;
	if(b%a==0){
		cout<<a+b<<endl;
	}
	else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > V;
const int h = 4,w = 4;
int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
V mp(h,vector<int>(w));
bool onmp(int x,int y){return x>=0&&y>=0&&x<w&&y<h;}

struct dat{int x,y,dir,cost;};
void drop(int x,int y){
  int D[4][4];
  memset(D,-1,sizeof(D));
  queue<dat> Q;
  mp[y][x] = 0;
  for(int i=0;i<4;i++)Q.push((dat){x+dx[i],y+dy[i],i,1});
  
  while(!Q.empty()){
    dat t = Q.front();Q.pop();
    x = t.x, y = t.y;
    int I = t.dir, cost = t.cost;
    if(!onmp(x,y))continue;  
    if(!mp[y][x]||(mp[y][x]>=5&&cost!=D[y][x]))Q.push((dat){x+dx[I],y+dy[I],I,cost+1});
    else if(++mp[y][x]==5){
      D[y][x] = cost;
      for(int i=0;i<4;i++)Q.push((dat){x+dx[i],y+dy[i],i,cost+1});
    }
  }
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)if(mp[i][j]>=5) mp[i][j]=0;
}

bool check(){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)if(mp[i][j]) return 0;
  return 1;
}

map<V,int> mem;
int dfs(int cnt=0){
  if(check()) return 0;
  if(cnt>=5) return 1e9;
  if(mem.count(mp)) return mem[mp];
  
  int res=1e9;
  for(int y=0;y<h;y++)
    for(int x=0;x<w;x++){
      if(mp[y][x]==0)continue;
      V tmp = mp;
      if(++mp[y][x]==5)drop(x,y);
      res=min(res,1+dfs(cnt+1));
      mp = tmp;
    }
  return mem[mp] = res;
}

int main(){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)cin>>mp[i][j];
  
  if(dfs()>5) cout<<-1<<endl;
  else cout<<dfs()<<endl;
  return 0;
}

Measured memory_bytes: 4680
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
price, money, satis = map(int, input().split())
# 条件分岐っき
# 満足するだけ聞ける
if price * satis <= money:
	output = satis
# 満足するだけ聞けない
else:
	output = money // price
# 出力
print(output)

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

using namespace std;

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

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[25][21];
ll sum[1<<17];
ll dp[1<<17];

int main(){
  scanf("%d",&n);
  REP(i,n)REP(j,n)scanf("%d",&a[i][j]);
  REP(msk,1<<n){
    REP(i,n)if(msk>>i&1)REP(j,i)if(msk>>j&1)sum[msk] += a[i][j];
  }
  fill(dp,dp+(1<<n),-1ll<<60);
  dp[0] = 0;
  REP(msk,1<<n){
    int sub = msk;
    do{
      CHMAX(dp[msk], dp[sub] + sum[msk^sub]);
      sub = (sub-1) & msk;
    }while(sub != msk);
  }
  ll ans = dp[(1<<n)-1];
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc139/tasks/abc139_c
# 整数の入力
n = int(input())
b = list(map(int, input().split()))
a = [b[0], b[0]]
for i in range(1, n-1):
    if b[i] > b[i-1]:
        a.append(b[i])
    else:
        a.append(b[i])
        a[i] = b[i]
print("{}".format(sum(a)))


Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int n;
vint v;
vint tt;
vint used;
bool f=false;
int cnt=0;
int foo(int x);
int foo2(int c,int x,int y){
	if(c==0){
		return foo(x+1);
	}
	if(y>=n){
		return 0;
	}
	int ret=0;
	if(v[y]<=c&&used[y]==0){
		used[y]=1;
		cnt++;
		if(foo2(c-v[y],x,y+1)&&cnt==n){
			return 1;
		}
		used[y]=0;
		cnt--;
	}
	// reep(i,x+1,n){
		// if(used[i]==0&&c-v[i]>=0){
			// used[i]=1;
			// ret=max(ret,foo2(c-v[i],x));
			// if(ret) return ret;
			// used[i]=0;
		// }
	// }
	return foo2(c,x,y+1);
}
int foo(int x){
	// cout<<"x "<<x<<endl;
	// rep(i,n){
		// cout<<used[i]<<" ";
	// }
	// cout<<endl;
	if(x==n&&used[x-1]!=0){
		// cout<<"**************\n";
		// f=true;
		return 1;
	}
	if(used[x]==0) return 0;
	if(used[x]==2) return foo(x+1);
	int ret=0;
	used[x]=2;
	ret=max(ret,foo2(v[x],x,x+1));
	if(ret) return ret;
	used[x]=1;
	ret=max(ret,foo(x+1));
	return ret;
}
void mainmain(){
	while(cin>>n,n){
		v=vint(n);
		rep(i,n){
			cin>>v[i];
		}
		sort(ALL(v));
		reverse(ALL(v));
		tt=vint(n,0);
		used=vint(n,0);
		// rep(i,n) cout<<used[i]<<" ";
		// cout<<endl;
		used[0]=1;
		tt[0]=v[0];
		cnt=1;
		if(foo(0)) cout<<"YES\n";
		else cout<<"NO\n";
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    rep(i,s.length()) {
        if ( s[i] - '0' == 7 ) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
import java.math.*;
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int x = sc.nextInt();
		if (isPrime(x)) {
			System.out.println(x);
		} else  {
				while (!isPrime(x)) {
					x++;
				}
				System.out.println(x);
			}
		}

		public static boolean isPrime (int a) {
			BigInteger bi = BigInteger.valueOf(a);
			return bi.isProbablePrime(1);
		}
}


Measured memory_bytes: 36184
if __name__ == "__main__":
    h, w = map(int, input().split())
    s = list()
    s.append('.' * (w + 2))
    for i in range(h):
        s.append('.' + input() + '.')
    s.append('.' * (w + 2))

    for i in range(h):
        for j in range(w):
            tmp = s[i+1][j] + s[i][j+1] + s[i+1][j+2] + s[i+2][j+1]
            if tmp == '....' and s[i+1][j+1] == '#':
                print('No')
                exit()

    print('Yes')


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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto &x:a) cin >> x;
  long long ans=0ll;
  for(int i =0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
      for(int k=j+1;k<n;k++)
      {
        vector<int> temp(3);
        temp[0] = a[i]; temp[1] = a[j]; temp[2] = a[k];
        if(
          temp[0] == temp[1] ||
          temp[1] == temp[2] || 
          temp[2] == temp[0]
          ) continue;
        sort(temp.begin(),temp.end());
        if(temp[0]+0ll+temp[1]>0ll+temp[2])
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

void max_u(int&m, int v)
{
	if(m<v) m=v;
}

int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vector<vector<char> > s(n);
		map<vector<char>,int> m;
		int c_max=0;
		for(int i=0;i<n;i++)
		{
			s[i].resize(10+2);
			scanf("%s", &s[i][0]);
			m[s[i]]++;
			max_u(c_max, m[s[i]]);
		}

		for(auto&mm:m)
		{
			if(mm.second==c_max) printf("%s\n", &mm.first[0]);
		}
	}
	return 0;
}


Measured memory_bytes: 34816
#include <stdio.h>
#include <math.h>

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

typedef long long ll;

#define INF 1145141919
#define size 200000+5

int N;
int arr[size];

int Min(int a, int b) {
    return a > b ? b : a;
}

int Max(int a, int b) {
    return a > b ? a : b;
}

void solver() {

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

    int ans = arr[1]-arr[0];
    int min = arr[0];
    for (int i = 1; i < N; ++i) {
        ans = Max(ans, arr[i] - min);
        min = Min(min, arr[i]);
    }
    printf("%d\n", ans);
}


int main() {
    solver();
    return 0;
}


Measured memory_bytes: 2508
#include<bits/stdc++.h>
#define mod 1e9+7
#define ll long long
using namespace std;


int main()
{
	
	int n,k;
	cin>>n>>k;
	vector<ll>a;
	for(int i=0;i<n;i++)
	{
		ll x;
		cin>>x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	vector<ll>dp(k+1,0);
	vector<ll>p(k+1,1);
	dp[0]=1;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(j==0)
			{	
				p[j]=dp[j]=1;
				 // cout<<dp[j]<<" :
				continue;
			}
			p[j]=(dp[j]+p[j-1])%(ll)(1e9+7);

			if(j-(a[i]+1)>=0)
				dp[j]=(p[j]-p[j-a[i]-1]+(ll)(1e9+7))%(ll)(1e9+7);
			else
				dp[j]=p[j];


			// cout<<dp[j]<<" ::"<<p[j]<<":: ";

		}
		// cout<<endl;
	}
	cout<<dp[k];	
}

Measured memory_bytes: 4776
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<math.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define mod 10007
using  namespace std;
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
int main()
{
    char a[100005];
    scanf("%s",a);
    int num=strlen(a)/2;
    //if(strlen(a)%2==1)
    int p=0,g=0;
    for(int i=0;i<strlen(a);i++)
    {
        if(a[i]=='g') g++;
        else if(a[i]=='p') p++;
    }
    printf("%d\n",num-p);
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<v[k-1];
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[[int(j) for j in input().split()] for i in range(n)]
c=[[int(j) for j in input().split()] for i in range(m)]
for i in range(n):
    d=10e8
    b=0
    for j in range(m):
        if abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])<d:
            d=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
            b=j+1
    print(b)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
int n,i,a=0,w=0,t=0,r=0;
 char A[3]="AC";
 char W[3]="WA";
 char T[4]="TLE";
 char R[3]="RE";
 char s[4];
 scanf("%d",&n);
for(i=0;i<n;i++){
 scanf("%s",s);
   if(s[0]==A[0]){
     a++;
   }
   else  if(s[0]==W[0]){
     w++;
   }
   else  if(s[0]==T[0]){
     t++;
   }
   else  if(s[0]==R[0]){
     r++;
   }
}
printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,w,t,r);
}

Measured memory_bytes: 1736
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,x;
    x=0;
    cin >> a >> b >> c;
    while (1<2)
    {
        if (c%a==0) x++;
        a++;
        if (a>b) break;}

cout << x << endl;
return 0;
}
    
    





Measured memory_bytes: 3088
#include <iostream>

#include <vector>

#include <algorithm>

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

using std::vector;

using std::sort;
using std::min;

static int cache[10000][1000];

struct magic
{
  int A;
  int B;
  double C;
};

bool
operator<(magic const &lhs, magic const &rhs)
{
  return rhs.C < lhs.C;
}

static int lowest(int H, int top, int bot, vector<magic> &m);

static int
lowest2(int H, int top, int bot, vector<magic> &m)
{
  int a = m[top].A;
  int b = m[top].B;
  if (top + 1 == bot)
  {
    return b * ((H + a - 1) / a);
  }
  if (H <= a)
  {
    return min(b, lowest(H, top + 1, bot, m));
  }
  return min(b + lowest(H - a, top, bot, m), lowest(H, top + 1, bot, m));
}

static int
lowest(int H, int top, int bot, vector<magic> &m)
{
  int ret = cache[H - 1][top - 1];
  if (ret == 0)
  {
    cache[H - 1][top - 1] = ret = lowest2(H, top, bot, m);
  }
  return ret;
}

int
main()
{
  int H, N;
  cin >> H >> N;
  vector<magic> m(N);
  for (int n = 0; n < N; n++)
  {
    cin >> m[n].A >> m[n].B;
    m[n].C = double(m[n].A) / m[n].B;
  }
  sort(m.begin(), m.end());
  int ret = lowest(H, 0, N, m);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 40320
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n,t,s,f,total=0;
	
	while(cin>>t){
		if(t==0)break;
		
		total=0;
		
		cin>>n;
		
		for(int i=0;i<n;i++){
			
			cin>>s>>f;
			total+=f-s;
			
		}
		
		if(total>=t){
			cout<<"OK"<<endl;
		}else{
			cout<<t-total<<endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e14;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

bool yes(int A, int B, int C){
    Rep(i,B){
        if ((A*i) % B==C){
            return true;
        }
    }
    return false;
}

using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;

    if (yes(A,B,C)) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
str = input().split()[0]
first = str[0]
strlist = str.split(first)
if len(strlist) != 3:
	print("No")
else:
	if len(strlist[1]) == 2:
		if strlist[1][0] == strlist[1][1]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[1]) == 1 and len(strlist[2]) == 1:
		if strlist[1][0] == strlist[2][0]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[2]) == 2:
		if strlist[2][0] == strlist[2][1]:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

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

const ll p=1e9+7;

int main(){
  ll N;
  cin >> N;
  vector<ll> S(N,0);
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin >> A[i];
  }
  S[0]=A[0];
  for(ll i=1;i<N;i++){
    S[i]=A[i]+S[i-1];
  }
  ll ans=0;
  for(ll i=0;i<N;i++){
    ans=(ans+A[i]*((S[N-1]-S[i])%p))%p;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6420
S = input()
s1 = int(S[:2])
s2 = int(S[2:])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s2 <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 2940
ERROR = 1e-5

require 'mathn'
include Math
class Line
	require 'matrix'
	#ax+by = c   (a > 0 or (a == 0 && b > 0))
	def self.through_two_points(x1, y1, x2, y2)
		a = y1 - y2
		b = x2 - x1
		c = a * x1 + b * y1
		new(a, b, c)
	end

	def self.through_one_point(x, y, rad)
		a = sin(rad)
		b = -cos(rad)
		c = a * x + b * y
		new(a, b, c)
	end

	def cross_point(l)
		m = Matrix[
			[@a, @b],
			[l.a, l.b],
		];
		v = Vector[@c, l.c]
		(m.inv * v).to_a
	end

	def vertical?
		b == 0
	end

	def y(x)
		(c - a * x) / b
	end

	def x(y)
		(c - b * y) / a
	end

	def parallel?(l)
		(@a * l.b - @b * l.a).abs < ERROR
	end

	def angle
		atan2(@a, -@b)
	end 

	def dist(x, y)
		(@a * x + @b * y - c).abs / sqrt(@a ** 2 + @b ** 2)
	end

	def through?(x, y)
		(@a * x + @b * y - c).abs < ERROR
	end


	private_class_method :new

	def initialize(*args)
		@a, @b, @c = args	
		if @a < 0
			@a *= -1
			@b *= -1
			@c *= -1
		elsif @a == 0 && @b < 0
			@b *= -1
			@c *= -1
		end
	end

	attr_reader :a, :b, :c
end

loop do
	n = gets.to_i
	break if n == 0

	para_num = {}
	lines = []
	n.times do
		l = Line.through_two_points(*gets.split.map(&:to_i))
		if rep = para_num.keys.find {|rep| l.parallel?(rep)}
			para_num[rep] += 1
		else
			para_num[l] = 1
		end
		lines << l
	end

	if para_num.size == 1
		if para_num.values[0] < 3
			puts 'Many'
		else
			puts 'None'
		end
	elsif para_num.values.max >= 3
		puts 'None'
	elsif para_num.size == 2
		if para_num.values.max == 1
			puts 'Many'
		elsif para_num.values.min == 1
			puts 'Many'
		else
			l1 = lines.shift
			l2 = lines.find {|l| l.parallel?(l1)}
			l3, l4 = lines - [l2]
			l5, l6 = nil, nil
			if l1.vertical?
				l5 = Line.through_two_points((l1.x(0) + l2.x(0)) / 2, 0, (l1.x(1) + l2.x(1)) / 2, 1)
			else
				l5 = Line.through_two_points(0, (l1.y(0) + l2.y(0)) / 2, 1, (l1.y(1) + l2.y(1)) / 2)
			end
			if l3.vertical?
				l6 = Line.through_two_points((l3.x(0) + l4.x(0)) / 2, 0, (l3.x(1) + l4.x(1)) / 2, 1)
			else
				l6 = Line.through_two_points(0, (l3.y(0) + l4.y(0)) / 2, 1, (l3.y(1) + l4.y(1)) / 2)
			end

			x, y = l5.cross_point(l6)
			if (l1.dist(x, y) - l3.dist(x, y)).abs < ERROR
				puts [x.to_f, y.to_f].join " "
			else
				puts 'Many'
			end
		end
	else
		candidates = []
		l1, l2, l3 = para_num.keys[0..2]
		x, y = l1.cross_point(l2)
		if l3.through?(x, y)
			candidates << [x, y]
		else
			bisec = []
			[l1, l2, l3].combination(2) do |la, lb|
				bisec << Line.through_one_point(*la.cross_point(lb), (la.angle + lb.angle) / 2)
				bisec << Line.through_one_point(*la.cross_point(lb), (la.angle + lb.angle + PI) / 2)
			end
			bisec.combination(3) do |la, lb, lc|
				next if la.parallel?(lb) or la.parallel?(lc)
				x, y = la.cross_point(lb)
				candidates << [x, y] if lc.through?(x, y)
			end
		end

		ans = []
		candidates.each do |x, y|
			ds = lines.map{|l| l.dist(x, y)}
			d0 = ds.shift
			if ds.all?{|d| (d - d0).abs < ERROR}
				ans << [x, y]
			end
		end

		if ans.size > 1
			puts 'Many'
		elsif ans.size == 1
			puts ans.flatten.join " "
		else 
			puts 'None'
		end
	end
end

Measured memory_bytes: 9932
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = new string[](3);
    foreach (i; 0 .. 3)
        S[i] = sread();
    long M = S.map!"a.length"().reduce!(max);

    auto match = new bool[][][](3, 3, M * 3);
    foreach (x; 0 .. 3)
        foreach (y; 0 .. 3)
            loop_i: foreach (i; 0 .. M * 3)
            {
                if (S[x].length <= i)
                {
                    match[x][y][i] = true;
                    continue;
                }
                foreach (j; 0 .. M * 2)
                    if (j + i < S[x].length && j < S[y].length)
                        if (S[x][j + i] != S[y][j] && S[x][j + i] != '?' && S[y][j] != '?')
                        {
                            continue loop_i;
                        }
                match[x][y][i] = true;
            }
    // writeln(match[0][1]);
    auto p = [0, 1, 2];

    bool check(long i, long j)
    {
        auto A = p[0], B = p[1], C = p[2];
        if (!match[A][B][i])
            return false;
        if (!match[A][C][j])
            return false;
        if (!match[B][C][j - i])
            return false;
        return true;

    }

    long ans = long.max;
    do
    {
        foreach (i; 0 .. S[p[0]].length + 1)
            foreach (j; i .. max(S[p[0]].length, i + S[p[1]].length) + 1)
            {
                long len = max(S[p[0]].length, i + S[p[1]].length, j + S[p[2]].length);
                if (check(i, j) && len < ans)
                {
                    // writeln(i, " ", j, " ", len);
                    ans = len;
                }
                // writeln(i, " ", j, " ", i + S[2].length);
            }
    }
    while (nextPermutation(p));
    writeln(ans);
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using  namespace std;
#define pb push_back
#define M 1000000007
typedef long long int ll;

void solve(){
	ll n, d = 0, a = 0;
	set<ll> mods;
	cin >> n;
	while(d < n){
		d = d*10 + 7;
		a++;
	}
	while(1){
		d = d%n;
		if(d == 0){
			cout << a << endl;
			exit(0);
		}
		if(mods.find(d) != mods.end()){
			cout << "-1\n";
			exit(0);
		}
		mods.insert(d);
		while(d < n){
			d = d*10 + 7;
			a++;
		}
	}
}		

int main(){

	int t;
	// cin >> t;
	t = 1;
	for(int q = 0; q < t; q++){
		solve();
	}

	return 0;
}

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

int arr[10];

bool cmp(const int &x, const int &y){return x < y;}

int main(){
	scanf("%d %d", &arr[1], &arr[2]);
	printf("%d\n", 6 - arr[1] - arr[2]);
	return 0;
}

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

int main() {
	int N; cin >> N;
	int A[100010];
	for(int i=0; i<N; ++i) cin >> A[i];
	sort(A, A+N, greater<int>());
	int num=0;
	long e[2];
	e[0]=0; e[1]=0;
	for(int i=0; i+1<N && num<2; ++i){
	    if(A[i]==A[i+1]){
	        e[num]=A[i];
	        ++num;
	        ++i;
	    }
	}
	long ans=e[0]*e[1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
// 2011/08/24 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt[7];
		for(int i=0; i<7; i++)
			cnt[i] = 0;		// 0ツづ渉可甘コツ可サ

		for(int i=0; i<n; i++){
			int age;
			cin >> age;
			if(age>=0&&age<10)
				cnt[0]++;
			else if(age<20)
				cnt[1]++;
			else if(age<30)
				cnt[2]++;
			else if(age<40)
				cnt[3]++;
			else if(age<50)
				cnt[4]++;
			else if(age<60)
				cnt[5]++;
			else if(age>=60)
				cnt[6]++;
		}

		for(int i=0; i<7; i++)
			cout << cnt[i] << endl;
	}

	return 0;
}

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

int main()
{
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	if(x>=r && y>=r && w-x>=r && h-y>=r)
    {
        cout << "Yes" << endl;
    } 
	else 
    {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

std::vector<int> tsort(const Graph &g) {
    int n = g.size();
    enum { YET, VISITED, DONE };
    std::vector<int> res, flg(n, YET);
    static const std::function<bool(int)> dfs = [&](int v) {
        flg[v] = VISITED;
        for (auto &e : g[v]) {
            int w = e.dst;
            if(flg[w] == DONE) continue;
            if(flg[w] == VISITED || !dfs(e.dst)) return false;
        }
        flg[v] = DONE;
        res.push_back(v);
        return true;
    };
    for (int i = 0; i < n; ++i)
        if (flg[i] == YET && !dfs(i)) return {};
    std::reverse(res.begin(), res.end());
    return res;
}

using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int s,t;
        cin >> s >> t;
        g[s].emplace_back(s,t,0);
    }
    vector<int> ord = tsort(g);
    for(int i = 0; i < n; ++i){
        cout << ord[i] << '\n';
    }
}

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

int main(){
  int n,k; cin>>n>>k;
  vector<int> a(n);
  
  int max_a=0;
  for (int i=0; i<n; i++){
    int ai; cin>>ai;
    a[i]=ai;
    max_a=max(max_a,ai);
  }
  int ok=max_a;
  int ng=0;
  
  while (abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    
    long long num=0;
    for (auto d : a){
      if (d%mid!=0) num+=d/mid;
      else num+=d/mid-1;
    }
    
    if (num<=k) ok=mid;
    else ng=mid;
  }
  
  cout<<ok<<endl;
}

Measured memory_bytes: 4028
import java.util.Scanner;
public class Main{
    int high;
    int low;
    int sa;
    int n;
    
    public void solve(){
        Scanner sc=new Scanner(System.in);
        n=0;
        while(n<7){
            high=sc.nextInt();
            low=sc.nextInt();
            sa=high-low;
            System.out.println(sa);
            n+=1;
        }
    }
    
    public static void main(String[] args){
        Main obj=new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17168
n,m = map(int,input().split(' '))
score = 0
penalty = 0
penalties = {}
acs = set()
for _ in range(m):
    num,result = input().split(' ')
    if num in acs:
        continue
    
    if result == "WA":
        if num in penalties:
            penalties[num] +=1
        else:
            penalties[num] =1
    else:
        score +=1
        if num in penalties:
            penalty += penalties[num]
        acs.add(num)

print(score,penalty)

Measured memory_bytes: 14052
if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    x_list = [a, b]
    y_list = [c, d]
    ans = 0

    if x_list[0] <= 0 and x_list[1] <= 0 and y_list[0] >= 0 and y_list[1] >= 0:
        ans = max(x_list) * min(y_list)
    elif x_list[0] >= 0 and x_list[1] >= 0 and y_list[0] <= 0 and y_list[1] <= 0:
        ans = max(y_list) * min(x_list)
    elif (x_list[0] <= 0 or x_list[1] <= 0) and (y_list[0] <= 0 or y_list[1] <= 0):
        ans = max(min(x_list) * min(y_list), max(x_list) * max(y_list))
    else:
        ans = max(x_list) * max(y_list)

    print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

long long a,b,c,d;
long long n,answ;

int main(){
    cin>>a>>b>>c>>d>>n;
    b = min(b , 2ll * a);
    c = min(c , 2ll * b);
    d = min(d , 2ll * c);
    answ += (n / 2ll) * d;
    answ += (n % 2ll) * c;
    cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;
#define INFF 1000000000000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    ll x,d;
    cin>>x>>k>>d;
    if(x<0){
        flag=-1;
        x=x*(-1ll);
    }
    ll p=x%d; ll q=d-x%d;
    ll full=x/d+1;
    if(k<full){
        cout<<x-k*d nn;
    }
    else{
        if((full-k)%2){
            cout<<p nn;
        }
        else{
            cout<<q nn;
        }
    }
    return 0;
}

Measured memory_bytes: 3776
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,t,temp,x,y;
string str;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	vll v;
	set<ll> s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
	    cin>>temp;
	    s.insert(temp);
	    v.pb(temp);
	}
	if(v.size()==s.size())
	cout<<"YES";
	else
	cout<<"NO";
	
	
	
	
	
}

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

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

    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans = i * ans;
        ans = ans % (1000000000 + 7);
    }
    cout << ans << endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }

    vector<int> L(N);
    L[0] = A[0];
    for (int i = 1; i < N; i++){
        L[i] = __gcd(L[i-1], A[i]);
    }

    vector<int> R(N);
    R[N-1] = A[N-1];
    for (int i = N-2; i >= 0; i--){
        R[i] = __gcd(R[i+1], A[i]);
    }

    int ans = 1;
    for (int i = 0; i < N; i++){
        if(i == 0){
            int x = R[1];
            ans = max(ans, x);
        } else if(i == N-1){
            int x = L[N-2];
            ans = max(ans, x);
        } else {
            int x = __gcd(L[i-1], R[i+1]);
            ans = max(ans, x);
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

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

  int answer[N];
  fill(answer, answer + N, 0);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;

    answer[a - 1] += 1;
    answer[b - 1] += 1;
  }

  for (int i = 0; i < N; i++) {
    cout << answer[i] << endl;
  }
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int n,m,ds[20+2][20+2],ans;
string s[N+2];
void bfs(int sr,int sc)
{
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)ds[i][j]=inf;
  }
  queue<pair<int,int> >q;q.push({sr,sc});
  ds[sr][sc]=0;

  while(q.size())
  {
    pair<int,int>p=q.front();q.pop();

    int u=p.first,v=p.second+1;
    if(u>=0&&v>=0&&u<n&&v<m&&s[u][v]=='.'&&ds[p.first][p.second]+1<ds[u][v])
    {
      ds[u][v]=ds[p.first][p.second]+1;q.push({u,v}); 
    }

    u=p.first,v=p.second-1;
    if(u>=0&&v>=0&&u<n&&v<m&&s[u][v]=='.'&&ds[p.first][p.second]+1<ds[u][v])
    {
      ds[u][v]=ds[p.first][p.second]+1;q.push({u,v}); 
    }

    u=p.first+1,v=p.second;
    if(u>=0&&v>=0&&u<n&&v<m&&s[u][v]=='.'&&ds[p.first][p.second]+1<ds[u][v])
    {
      ds[u][v]=ds[p.first][p.second]+1;q.push({u,v}); 
    }

    u=p.first-1,v=p.second;
    if(u>=0&&v>=0&&u<n&&v<m&&s[u][v]=='.'&&ds[p.first][p.second]+1<ds[u][v])
    {
      ds[u][v]=ds[p.first][p.second]+1;q.push({u,v}); 
    }
  }

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      if(ds[i][j]<inf)ans=max(ans,ds[i][j]);
  }
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>s[i];

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
    {
      if(s[i][j]=='.')
        bfs(i,j);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8064
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
place=[[-1,-1] for i in range(h*w+1)]
for i in range(h):
  for j in range(w):
    place[a[i][j]]=[i,j]

def calcdist(i,j):
  return abs(place[i][0]-place[j][0])+abs(place[i][1]-place[j][1])

dp=[[0] for i in range(d+1)]
for i in range(1,d+1):
  for j in range(i+d,h*w+1,d):
    dp[i].append(dp[i][-1]+calcdist(j-d,j))
    
q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  i=l%d
  if i==0:
    i=d
  l=(l-1)//d
  r=(r-1)//d
  print(dp[i][r]-dp[i][l])

Measured memory_bytes: 25716
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	s := make([][]byte, 3)
	for i := 0; i < 3; i++ {
		s[i] = []byte(readString())
	}
	i := 0
	for len(s[i]) > 0 {
		c := s[i][0]
		s[i] = s[i][1:]
		i = int(c - 'a')
	}
	printf("%c\n", rune('A'+byte(i)))
}


Measured memory_bytes: 640
N,D = [int(i) for i in input().split()]
X = []
for n in range(N):
    X.append([int(i) for i in input().split()])
import numpy as np
X = np.array(X)
cnt = 0
for n in range(N):
    for nn in range(n+1,N):
        tmp = np.linalg.norm(X[n] - X[nn])
        if tmp == int(tmp):
            cnt+=1
print(cnt)

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

int main(){
	long long X;
	cin >> X;
	
	vector<long long> p;
	for(long long i=1;i*i<=X;i++)if(X%i==0)p.push_back(i);
	
	for(auto k:p){
		long long A=k/2;
		long long B=A-k;
		while(A*A*A*A*A-B*B*B*B*B<=X){
			if(A*A*A*A*A-B*B*B*B*B==X){
				cout << A << " " << B << endl;
				return 0;
			}
			A++;
			B++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n,c;
vi a,b;

int main(){
	cin>>n>>c;
	a=b=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	const int S=405;
	vvl s(S,vl(S,1));
	for(int i=1;i<S;i++) for(int j=0;j<S;j++) s[i][j]=s[i-1][j]*j%mod;
	for(int i=0;i<S;i++) for(int j=1;j<S;j++) (s[i][j]+=s[i][j-1])%=mod;
	vvl dp(n+1,vl(c+1));
	dp[0][0]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<=c;j++){
		for(int k=0;k<=j;k++) (dp[i][j]+=dp[i-1][k]*(s[j-k][b[i-1]]-s[j-k][a[i-1]-1]+mod))%=mod;
	}
	cout<<dp[n][c]<<endl;
}

Measured memory_bytes: 2944