akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main() {

	int m, f, r,sum=0;

	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;

		sum = m + f;

		if (m == -1 || f == -1) printf("F\n");
		else if (sum >= 80) printf("A\n");
		else if (sum < 80 && sum >= 65) printf("B\n");
		else if (sum < 65 && sum >= 50) printf("C\n");
		else if (sum < 50 && sum >= 30) {
			if (r >= 50) printf("C\n");
			else printf("D\n");
		}
		else printf("F\n");
	}

	return 0;

}


Measured memory_bytes: 2088
#include <iostream>
#include <ios>
#include <vector>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
struct Data
{
	char c;
	long v;
	long i;
};
typedef vector<Data> vecD;

int Partition(vecD& vD, int p, int r)
{
	int x = vD[r].v;
	int i = p - 1;
	FOR(j, p, r){
		if (vD[j].v <= x){
			++i;
			swap(vD[i], vD[j]);
		}
	}
	swap(vD[i + 1], vD[r]);
	return i + 1;
}

void QuickSort(vecD& vD, int p, int r)
{
	if (p >= r) return;
	int q = Partition(vD, p, r);
	QuickSort(vD, p, q - 1);
	QuickSort(vD, q + 1, r);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, v;
	cin >> n;
	vecD vD(n);
	FOR(i, 0, n){
		cin >> vD[i].c >> vD[i].v;
		vD[i].i = i;
	}
	QuickSort(vD, 0, n - 1);
	bool isStable = true;
	FOR(i, 1, n){
		if (vD[i - 1].v != vD[i].v) continue;
		if (vD[i - 1].i > vD[i].i)
			isStable = false;
	}
	cout << (isStable ? "Stable\n" : "Not stable\n");
	FOR(i, 0, n)
		cout << vD[i].c << " " << vD[i].v << "\n";
	return 0;
}

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

using namespace std;
int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int count = 0;
    for(int i=l; i<r+1; i++){
        if(i%d==0)
          count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int n, m; cin >> n >> m;

	vector < vector <int> > a(n);

	map <int, int> cnt;

	for(int i = 0; i < n; i++){
		int k;
		cin >> k;

		a[i].resize(k);

		for(int j = 0; j < k; j++){
			cin >> a[i][j];
			cnt[a[i][j] - 1]++;
		}
	}


	int ans = 0;

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


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
x = gets
until x.nil?
 sum = []
 num = []
 a = x.to_f
 i = 1
 while i < 11
  if i == 1
   sum << a
   num << a
  elsif i % 2 == 1
    s = num[i-2] / 3
    sum << s
    num << s
  elsif i % 2 == 0
    k = num[i-2] * 2
    sum << k
    num << k
  end
  i += 1
 end

 puts sum.sum
 x = gets
end



Measured memory_bytes: 6864
// https://atcoder.jp/contests/m-solutions2020
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int X;
    cin >> X;
    for (int i = 0; i < 8; ++i)
    {
        if (X >= 400 + 200 * i && X < 600 + 200 * i)
        {
            cout << 8 - i << endl;
            return 0;
        }
    }
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n), b(n);
	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	
	auto c=a;
	sort(all(c));
	
	int f=-1,t=-1, z=0;
	do {
		if(a==c) f=z;
		if(b==c) t=z;
		z++;
	} while ( next_permutation(all(c)) );

	cout << abs(t-f) <<"\n";
	return 0;
}



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

using namespace std;

int main() {
  int L, R, d, ans = 0;
  
  cin >> L >> R >> d;
  
  L = ceil((double)L / d) * d;
  
  for (int i = L; i <= R; i++) {
    if (i % d == 0) {
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main() 
{
    io();
    string s;
    cin>>s;
    li n=s.length();
    F {if(s[i]=='?')
      s[i]='D';}
   cout<<s;
}


Measured memory_bytes: 3744
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)

c = collections.Counter(S)
cnt = 0
r = 2

for n in c.values():
    if n >= 2:
        cnt += factorial(n)/(factorial(r)*factorial(n - r))
print(int(cnt))


Measured memory_bytes: 67660
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")


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

	long long n, i, j, k, x, y, xx, yy, ans;
	cin >> n;
	set<long long> xv, yv;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		xv.insert(x + y);
		yv.insert(y - x);
	}

	ans = max((*xv.rbegin()) - (*xv.begin()), (*yv.rbegin()) - (*yv.begin()));
	cout << ans << "\n";


	return 0;
}



Measured memory_bytes: 22392
#include <stdio.h>

int a[100001];

void add(int b, int w, int n) {
	int i;
	for (i = b; i <= n; i += i & (-i))
		a[i] += w;
}

int sum2(int b) {
	int i, ans = 0;
	for (i = b; i > 0; i -= i & (-i))
		ans += a[i];
	return ans;
}

int sum(int b, int c) {
	return (sum2(c) - sum2(b - 1));
}

void init(int a[], int n) {
	int i;
	for (i = 0; i <= n; i++)
		a[i] = 0;
}

int main(void) {
	int n, q, com, x, y;

	scanf("%d %d", &n, &q);
	init(a, n);

	while (q--) {
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0)
			add(x, y, n);
		else
			printf("%d\n", sum(x, y));
	}

	return 0;
}

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

int n,cnt,ans;

int main()
{
	cin>>n;
	int las=0,a;
	for(int i=1;i<=n;++i) {
		scanf("%d",&a);
		if(a<=las) cnt++;
		else ans=max(ans,cnt),cnt=0;
		las=a;
	}
	ans=max(ans,cnt);
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i, N;
  float x, sam;
  char u[3];
  sam = 0;
  scanf("%d", &N);
  for(i = 0; i < N; i ++){
    scanf("%f %s", &x, &u);
    if (u[0] == 'J'){
      sam += x;
    }
    else{
      x = x*380000;
      sam = sam + x;
    }
  }
  printf("%f\n", sam);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+5;

int par[MAX];
int rk[MAX];
int gr[MAX];
//初期化
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i;
		rk[i]=0;
      	gr[i]=1;
	}
}
//根を求める
int find(int x){
	if(par[x]==x){
		return x;
	}
	else{
		return par[x]=find(par[x]);
	}
}
//xとyの属する集合を併合
ll unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y)return 0;
	
	ll a=(ll)gr[x]*gr[y];
	int b=gr[x]+gr[y];
	gr[x]=b;
	gr[y]=b;
	
	if(rk[x]<rk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rk[x]==rk[y])rk[x]++;
	}
	return a;
}
//xとyが同じ集合に属するか判定
bool same(int x,int y){
	return find(x)==find(y);
}

int main(){
	int N,M;
	cin>>N>>M;
	int A[MAX],B[MAX];
	rep(i,M){
		cin>>A[i]>>B[i];
	}
	
	init(N);
	
	ll ans[MAX];
	ans[M]=(ll)N*(N-1)/2;
	for(int i=M-1;i>=0;i--){
		ans[i]=ans[i+1]-unite(A[i]-1,B[i]-1);
	}
	rep1(i,M)cout<<ans[i]<<endl;
}

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

int main() {
	int n,count,b,countn;
	count =0;
	countn=0;
	cin >> n;
	for (int a=1; a<n+1; a=a+2){
		for(int c=1; c<=a; c=c+1){
			b=a%c;
			if (b==0){
				count += 1;
			}
			
		}
		if(count==8){
			countn+=1;
		}
		count=0;
	}
	cout<<countn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
 int K;
 std::cin>>K;
 int A,B;
 std::cin>>A>>B;

 int count=A;
 int ans=0;
 while(count<=B){
  if(count%K==0){
   ans=1;
   break;
  }
  count++;
 }

 if(ans==1){
  std::cout<<"OK";
 }else{
  std::cout<<"NG";
 }
}

Measured memory_bytes: 3632
(n,_),*t=[t.split()for t in open(0)]
n=int(n)
for i in range(10**(n-1)-(n<2),10**n):
  i=str(i)
  for s,c in t:
    if i[int(s)-1]!=c:
      break
  else:
    print(i)
    break
else:
  print(-1)

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

typedef long long ll;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

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

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

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M), ans(M, N * (N - 1) / 2), c(N, 1);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    init(N);
    for (int i = M - 2; i >= 0; i--) {
        if (same(A[i + 1], B[i + 1])) {
            ans[i] = ans[i + 1];
            continue;
        }
        ll c1 = c[find(A[i + 1])], c2 = c[find(B[i + 1])];
        ans[i] = ans[i + 1] - c1 * c2;
        unite(A[i + 1], B[i + 1]);
        c[find(A[i + 1])] = c1 + c2;
    }
    rep(i, M) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5248
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N, M;
    in2(N, M);

    vi P(M), Y(M);
    rep(i, M) in2(P[i], Y[i]);

    vvi X(N + 1);
    rep(i, M) X[P[i]].push_back(Y[i]);

    rep(i, N + 1) sort(all(X[i]));

    rep(i, M)
    {
        auto itr = lower_bound(all(X[P[i]]), Y[i]);
        int num = distance(X[P[i]].begin(), itr) + 1;

        cout << std::setw(6) << std::setfill('0') << P[i];
        cout << std::setw(6) << num;
        cout << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  int m = 0;
  rep(i,0,n) {
    int h;
    cin >> h;
    m = max(m,h);
    if (m-h >= 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	long double pi = acos(-1), R;
	
	cin>>R;
	
	R *= pi * 2;
	
	cout<<R<<endl;
	
	
	return 0;
}

//

Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long

void solve()
{
	int n,k;cin>>n>>k;
	vector < int > arr(n);
	for(int i=0;i<n;i++)
	cin>>arr[i];
	sort(arr.begin(),arr.end());
	if(n>k)
	{	ll sum=0;
		for(int i=0;i<n-k;i++)
		sum+=arr[i];
		cout<<sum<<endl;
	}
	else
	cout<<0;
}
int main()
{
//	int t;cin>>t;
//	while(t--)
	solve();
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            string[] strs = Console.ReadLine().Split(' ');

            List<long> nums = new List<long>();

            foreach(string s in strs)
            {
                nums.Add(long.Parse(s));
            }

            nums.Sort();
            nums.Reverse();

            long x = 0;
            long y = 0;
            bool isXfound = false;
            bool isYfound = false;

            int length = nums.Count;
            for (int i = 0; i < length - 1; i++)
            {
                if(nums[i] == nums[i + 1])
                {
                    if(!isXfound)
                    {
                        x = nums[i];
                        isXfound = true;
                        i++;
                    }
                    else{
                        y = nums[i];
                        isYfound = true;
                        break; 
                    }
                }
            }
            if(!isYfound)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                Console.WriteLine(x * y);
                return;
            }
            
        }
    }
}


Measured memory_bytes: 22112
#include <stdio.h>

int main()
{
	int N, A, B, C, X, ans, cx, i;
	int Y[10001];
	while (scanf("%d%d%d%d%d", &N, &A, &B, &C, &X) && N) {
		ans = 0;
		for (int i = 0; i < N; i++)
			scanf("%d", &Y[i]);
		Y[N] = 10000;
		i = 0;
		while (N) {
			if (ans++ > 10000) {
				ans = 0;
				break;
			}
			if (X == Y[i])
				i++, N--;
			X = (A * X + B) % C;
		}
		printf("%d\n", ans - 1);
	}
	return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string s;
int main(){
    ll n;
    cin >> n;
    ll a[n][2],cnt=0;
    for( ll i = 0; i < n; i++){
	cin >> a[i][0];
	cin >> a[i][1];
    }
    bool ok=false;
    for( ll i = 0; i + 2 < n; i++){
	if( a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1] ){ok=true;}
    }
    puts(ok ? "Yes" : "No");



    return 0;
}


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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i)
#define deb(x) cout << #x << "= " << x << endl
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define tr(x) for(auto it = x.begin(); x != x.end(); it++)
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    fast;
    int t=1;
    while(t--){
        //begin code here
        int n; cin>>n;
        string s;
        cin>>s;
        string beginning, ending;
        int balance=0;
        for0(i,n){
            if(s[i]=='('){
                balance++;
            }
            else{
                balance--;
            }
            if(balance<0){
                beginning+='(';
                balance++;
            }
        }
        for0(i, balance){
            ending+=')';
        }
        cout << beginning + s + ending ;
    }
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,n,dp[31];
	dp[1]=1;
	dp[2]=2;
	dp[3]=4;
	for(int i=4;i<31;i++){
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	while(1){
		cin>>n;
		if(n==0)break;	
		a=dp[n]/10;
		b=dp[n]%10;
		if(b>0)a++;
		c=a/365;
		d=a%365;
		if(d>0)c++;
		cout<<c<<endl;
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s1,s2;
  cin>>s1;
  int n=s1.size();
  for(int i=n-1;i>=0;i--){
    s2.insert(0,s1.substr(i,1));
      if(s2=="dream"||s2=="dreamer"||s2=="erase"||s2=="eraser"){
        s2="";
      }
  }
  if(s2=="")printf("YES");
  else printf("NO");
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=5010;
int n,m,b[maxn][maxn],s[maxn],l[maxn][maxn],r[maxn][maxn],w[maxn];
ll a[maxn],A[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=2;i<=n;i++)scanf("%lld",&a[i]),a[i]+=a[i-1];
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)scanf("%d",&b[j][i]);
	/*for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++)printf("%d ",b[i][j]);
		puts("");
	}*/
	for(int i=1;i<=m;i++){
		int top=0;
		for(int j=1;j<=n;j++){
			while(top&&b[i][j]>s[top])top--;
			if(top)l[i][j]=w[top]+1;else l[i][j]=1;
			s[++top]=b[i][j];w[top]=j;
		}
		top=0;
		for(int j=n;j>=1;j--){
			while(top&&b[i][j]>s[top])top--;
			if(top)r[i][j]=w[top]-1;else r[i][j]=n;
			s[++top]=b[i][j];w[top]=j;
		}
		for(int j=1;j<=n;j++){
			//printf("(%d,%d)%d %d\n",i,j,l[i][j],r[i][j]);
			A[l[i][j]][j]+=b[i][j];
			A[l[i][j]][r[i][j]+1]-=b[i][j];
			A[j+1][j]-=b[i][j];
			A[j+1][r[i][j]+1]+=b[i][j];
		}
	}
	ll ans=-1ll<<60;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)A[i][j]+=A[i][j-1];
		for(int j=1;j<=n;j++)A[i][j]+=A[i-1][j];
		for(int j=i;j<=n;j++)ans=max(ans,A[i][j]-a[j]+a[i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 213120
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let x: u64 = read();

    if a == 0 {
        let ans = b / x + 1;
        println!("{}", ans);
    } else {
        let ans = b / x - (a - 1) / x;
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	vector<int> all = { a,b,c };
	sort(all.begin(), all.end());
	cout << all[2] * 10 + all[1] + all[0] << "\n";
	

}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			long a = sc.scanLong();
			long b = sc.scanLong();
			long count = 0;
			long g = gcd(a, b);
			boolean counted = false;
			while (g % 2 == 0) {
				if (!counted) {
					++count;
					counted = true;
				}
				g /= 2;
			}
			for (long i = 3, lim = (long) Math.sqrt(g); i <= lim; i += 2) {
				counted = false;
				while (g % i == 0) {
					if (!counted) {
						++count;
						counted = true;
					}
					g /= i;
				}
			}

			if (g > 2)
				++count;
			System.out.println(count+1);
		}

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

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,sum;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll dp[402][402] = {0};
    for(int i=1;i<n;i++){
        for(int j=0;j<n-i;j++){
            ll num=1e18;
            sum=0;
            for(int k=j;k<j+i;k++){
                num=min(num,dp[j][k]+dp[k+1][j+i]);
                sum+=a[k];
            }
            sum+=a[j+i];
            dp[j][j+i]=num+sum;
        }
    }
    cout << dp[0][n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Itv;
const ll INF = 1e9 + 5;
int main(void) {
  int n;
  cin >> n;
  vector<Itv> itvs(n);
  rep(i, n) {
    int x, l;
    cin >> x >> l;
    itvs[i] = make_pair(x + l, x - l);
  }
  sort(itvs.begin(), itvs.end());
  int ans = 0;
  ll t = -INF;
  rep(i, n) {
    if(t <= itvs[i].second) {
      ans++;
      t = itvs[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}

ll modpow(ll a,ll n,ll mod){
  ll ret=1;
  while(n>0){
    if(n&1) ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}

int main()
{
  int n;
  vector<vector<int>> a(3,vector<int>(3));
  REP(i,3){
    REP(j,3) cin>>a[i][j];
  }
  cin>>n;
  vector<int> b(n);
  REP(i,n) cin>>b[i];

  vector<vector<bool>> f(3,vector<bool>(3,0));
  REP(k,n){
    REP(i,3){
      REP(j,3){
        if(a[i][j]==b[k]){
          f[i][j]=1;
        }
      }
    }
  }

  if(f[0][0]==1 && f[0][1]==1 && f[0][2]==1) cout<<"Yes"<<endl;
  else if(f[1][0]==1 && f[1][1]==1 && f[1][2]==1) cout<<"Yes"<<endl;
  else if(f[2][0]==1 && f[2][1]==1 && f[2][2]==1) cout<<"Yes"<<endl;
  else if(f[0][0]==1 && f[1][0]==1 && f[2][0]==1) cout<<"Yes"<<endl;
  else if(f[0][1]==1 && f[1][1]==1 && f[2][1]==1) cout<<"Yes"<<endl;
  else if(f[0][2]==1 && f[1][2]==1 && f[2][2]==1) cout<<"Yes"<<endl;
  else if(f[0][0]==1 && f[1][1]==1 && f[2][2]==1) cout<<"Yes"<<endl;
  else if(f[0][2]==1 && f[1][1]==1 && f[2][0]==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  REP(i, n) cin >> a[i] >> b[i];

  auto dp = make_v<ll>(n,n);
  fill_v(dp, LLINF);
  REP(i, n) dp[i][i] = 0;
  FOR(w, 2, n+1) {
    REP(l, n) {
      ll r = l + w - 1;
      if(r >= n) break;
      FOR(i, l, r) {
        ll cost = a[l]*b[i]*a[i+1]*b[r];
        chmin(dp[l][r], dp[l][i] + dp[i+1][r] + cost);
      }
    }
  }
  cout << dp[0][n-1] << endl;

  return 0;
}



Measured memory_bytes: 3228
def calc_max_score(choices, R, S, P):
    score = {
        'r': P,  # player: paper, machine: rock
        's': R,  # player: rock, machine: scissors
        'p': S   # player: scissors, machine: paper
    }
    before_choice = None
    seq_cnt = 1
    sum_score = 0
    for c in choices:
        if before_choice == c:
            seq_cnt += 1
            continue
        if before_choice is not None:
            sum_score += score[before_choice] * ((seq_cnt + 1) // 2)
        before_choice = c
        seq_cnt = 1
    if before_choice is not None:
        sum_score += score[before_choice] * ((seq_cnt + 1) // 2)
    return sum_score


def main():
    N, K = list(map(int, input().split(' ')))
    R, S, P = list(map(int, input().split(' ')))
    T = input()
    choice_list = [list() for _ in range(K)]
    for i, c in enumerate(T):
        i %= K
        choice_list[i].append(c)
    answer = 0
    for choices in choice_list:
        answer += calc_max_score(choices, R, S, P)
    print(answer)


if __name__ == '__main__':
    main()


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

int main() {
  long long int N;
  cin >> N;
  vector<long long int> A(N);
  long long int S = 0;
  map<long long int, long long int> M;
  for (long long int i = 0; i < N; i++) {
    long long int a;
    cin >> a;
    A.at(i) = a;
    S += a;
    if (M.count(a)) M.at(a) += 1;
    else M[a] = 1;
  }
  long long int Q;
  cin >> Q;
  for (long long int i = 0; i < Q; i++) {
    long long int b, c;
    cin >> b >> c;
    if (M.count(b)) {
      long long int X = M.at(b);
      S -= X * b;
      S += X * c;
      M.at(b) = 0;
      if (M.count(c)) M.at(c) += X;
      else M[c] = X;
    }
    cout << S << endl;
  }
}

Measured memory_bytes: 9004
let s = Stack.create ()

let rec solve acc = function
  | [] | _::[] -> acc
  | x1::x2::xs ->
     match x1, x2 with
     | 0, 1 | 1, 0 -> 
        if not (Stack.is_empty s) then 
          let x' = Stack.pop s in solve (acc + 2) (x'::xs)
        else solve (acc + 2) xs
     | x1, x2 ->
        Stack.push x1 s;
        solve acc (x2::xs)

let input_bits () =
  let rec inner acc =
    try
      let acc' = (Scanf.scanf "%1d" (fun i -> i::acc)) in
      inner acc'
    with e -> acc
  in List.rev @@ inner []

let _ =
  let inputs = input_bits () in
  solve 0 inputs
  |> print_int

Measured memory_bytes: 12032
package main

import "fmt"

func main() {
	var N, T int
	fmt.Scan(&N, &T)
	t := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&t[i])
	}
	cnt := 0
	for i := 1; i < N; i++ {
		if d := t[i] - t[i-1]; d < T {
			cnt += d
		} else {
			cnt += T
		}
	}
	cnt += T
	fmt.Println(cnt)
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

//const int MAXN = 10000500;
//const int MAXN = 50;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;

unsigned int check(unsigned int x) {
	unsigned int y = x;
	for (int i = 3; i < x; i += 2) {
		if (x % i == 0) {
			y = i;
			break;
		}
	}
	return y;
}

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

	int n = 0;
	cin >> n;

	bool fl = false;

	for (int i = 10; i <= 1000; i += 10) {
		int ost = n % 10;
		n /= 10;
		if (ost == 7) {
			fl = true;
		}
	}

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

	

	//system("pause");
	return 0;
}
	
	


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int bra = 0, cket= 0;
    vector<int> d(N, 0);
    int x = (int)1e9;
    for(int i = 0; i < N; ++i) {
        if(S[i] == '(') bra++;
        else cket++;
        d[i] = bra - cket;
        x = min(x, d[i]);
    }
    string ans = "";
    for(int i = 0; i < -x; ++i) {
        ans.push_back('(');
    }
    for(int i = 0; i < N; ++i) {
        ans.push_back(S[i]);
    }
    for(int i = 0; i < d[N-1] - x; ++i) {
        ans.push_back(')');
    }
    if(x == 1 && S[0] == S[1] && S[0] == '(') ans.push_back(')');
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a>=10 || b>=10) {
			System.out.println(-1);
		}else {
			System.out.println(a*b);
		}
	}

}


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

using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(ALL(c)); c.erase(unique(ALL(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class K, class V> void cout_v(map<K, V>& m)
{ for(auto it=m.begin();it!=m.end();it++)cout<<it->first<<":"<<it->second<<endl;}
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
inline int powi(int x,int y) {int p=1; while(y--) p*=x; return p;}
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}
template<class T> inline bool is_overlap(const T& a, const T& b, const T& p, const T& q)
{ return p <=b && a <= q; }
#define MOD = 1000000007;
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, M; cin >> N >> M;
    
    int l_max = INT_MIN, r_min = INT_MAX;
    int l, r;
    rep(i, M) {
        cin >> l >> r;
        // cout << FMT2(l, r) << endl;
        chmax(l_max, l);
        chmin(r_min, r);
        // cout << FMT2(l_max, r_min) << endl;
        if (l_max > r_min)
            break;
    }
    
    cout << max(0, r_min - l_max + 1) << endl;
}



Measured memory_bytes: 256
def main():
	cookie = 0
	A,B,C = map(int,input().split())

	if C > B :
		C -= B
		cookie += (B*2)
		if C > A :
			cookie += (A+1)
		elif C <= A:
			cookie += C
		return cookie
	elif C <= B :
		return B+C

if __name__ == "__main__" :
	print(main())


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

int GCD(int a, int b, int c){
    int m;
    m=min(min(a,b), c);
    
    for(int i=m ; i>=1 ; i--)
    {
        if(a%i==0 && b%i==0 && c%i==0)
        return i;
    }
}

int main()
{int k, p, q, r;
 unsigned long long int sum=0;
 cin>>k;
 
 for(p=1 ; p<=k ; p++)
 {
     for(q=1 ; q<=k ; q++)
     {
         for(r=1 ; r<=k ; r++)
         sum+=GCD(p,q,r);
     }
 }
 
 cout<<sum;
 return 0;
}

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

void nuru(vector<int> &bw, vector<vector <pair <int, int>>> graph, int n){
  vector<int> dist(n + 1, -1);
  vector<int> prev(n + 1, 0);
  
  dist.at(0) = 0;
  dist.at(1) = 0;
  bw.at(0) = 0;
  
  queue<int> que;
  que.push(1);
  
  while(!que.empty()){
    int u = que.front();
    que.pop();
    
    if (dist.at(u) %2 == 0){
      bw.at(u) = bw.at(prev.at(u));
    } else {
      if (bw.at(prev.at(u)) == 0) {
        bw.at(u) = 1;
      } else {
        bw.at(u) = 0;
      }
    }
    
    for(int i = 0; i < graph.at(u).size(); i++){
      int v = graph.at(u).at(i).first;
      if(bw.at(v) != -1) continue;
      que.push(v);
      prev.at(v) = u;
      dist.at(v) = graph.at(u).at(i).second;
    }
  }
}

int main() {
  int n; cin >> n;
  
  vector<int> bw(n + 1, -1);
  
  vector<vector <pair <int, int>>> graph(n + 1);//, vector<pair <int, int>> (n));
  
  graph.at(0).push_back(make_pair(1, 0));
  
  for(int i = 1; i < n; i++){
    int u, v, w; cin >> u >> v >> w;
    
    graph.at(u).push_back(make_pair(v, w));
    graph.at(v).push_back(make_pair(u, w));
  }
  
  nuru(bw, graph, n);
  
  for (int i = 0; i < n; i++){
    cout << bw.at(i + 1) << endl;
  }
}

Measured memory_bytes: 13056
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline long gl(void){
    long x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

long gcd(long a, long b){
    if(a==0) return b;
    if(b==0) return a;
    do{
        long t=a%b;
        a=b;
        b=t;
    }while(b!=0);
    return a;
}

int main(void){
    long n=gl(), s=gl();
    long g=0;
    for(long i=0; i<n; i++){
        long t = gl();
        g=gcd(labs(t-s), g);
    }
    printf("%ld\n", g);
    return 0;
}


Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = (0 until m).map { Road016b(sc.next().toInt(), sc.next().toInt()) }
    println(problem061b(n, m, a))
}

fun problem061b(n: Int, m: Int, a: List<Road016b>): String {
    val list = (0 until n).map { 0 }.toMutableList()
    for (i in 0 until m) {
        list[a[i].a - 1] += 1
        list[a[i].b - 1] += 1
    }
    return list.joinToString("\n")
}

data class Road016b(var a: Int, var b: Int)

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

ll N;
ll A[400][400];
bool deleted[400][400];

signed main() {
    ll cost = 0;
    cin>>N;
    rep(i,0,N){
        rep(j,0,N){
            cin>>A[i][j];
            cost += A[i][j];
        }
    }
    cost /= 2;

    rep(i,0,N)
        rep(j,0,N)
            rep(k,0,N){
                if (i==j || i==k || j==k)
                    continue;

                if (A[i][j] + A[j][k] < A[i][k]){
                    // 三角不等式をみたさない
                    cout<<-1<<endl;
                    return 0;
                } else if (A[i][j] + A[j][k] == A[i][k] && !deleted[i][k]){
                    // jで迂回すればよいので、A[i][j]は不要
                    cost -= A[i][k];
                    deleted[i][k] = deleted[k][i] = true;
                }
            }

    cout<<cost<<endl;
    return 0;
}


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

#define MAX 100010

int dp[MAX][3];
int a[MAX][3];

int main(){
	int n;	cin>>n;
	for(int i=0;i<MAX;i++){
		for(int j=0;j<3;j++)dp[i][j]=0;
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++) cin>>a[i][j];
	}

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

		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				dp[i+1][k]=max(dp[i+1][k], dp[i][j] + a[i][k]);
			}
		}

	}

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

	//for(int i=1;i<=n;i++){
	//	for(int j=0;j<3;j++)cout<<dp[i][j]<<" ";
	//	cout<<endl;
	//}


	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    char c[105] = {0};
    int nl = 0, nr = 0;
    scanf("%d%*c", &n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%c", &c[i]);
        if(c[i] == ')')
        {
            ++nr;
            if(nl)
            {
                --nr;
                --nl;
            }
        }
        else if(c[i] == '(')
        {
            ++nl;
        }
    }
    getchar();
    for(int i = 0; i < nr; ++i)
    {
        cout << '(';
    }
    cout << c;
//    for(int i = 0; i < n; ++i)
//    {
//        cout << c[i];
//    }
    for(int i = 0; i < nl; ++i)
    {
        cout << ')';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    CoutYn(a <= c*b);
}


Measured memory_bytes: 3636
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    /////////////////////
    // Write code below /
    /////////////////////
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = 'second'
for _ in range(n):
    a = int(input())
    if a%2 != 0:
        ans = 'first'
print(ans)

# 状態としてありえるのは、E:全て偶数 or O:いずれか1つ以上が奇数
# 最終的にEを押し付けられたら負けと考える（すべて0）
# 現状態がOであるなら、奇数のものだけを食べて、状態Eを相手に返すことができる
# 現状態がEであるなら、1つ以上食べる必要があるので、Oが相手に返る
# ここから、初期状態がOならばfirst, Eならばsecondが答えとなる

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

//-------------------ここから回答する-----------------------

void solve(void)
{
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    rep(i, h) cin >> c[i];
    rep(i, 2 * h) cout << c[i / 2] << endl;
}
int main(void)
{
    solve();
}


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

int main(){
    int a,b;
    cin>>a>>b;
    
    if(a<b)cout<<"a < b"<<endl;
    else if(a>b)cout<<"a > b"<<endl;
    else if(a==b)cout<<"a == b"<<endl;
    return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n, y;
		int[] h;
		
		while(true){
			n = scan.nextInt();
			if(n == 0)break;
			
			h = new int[7];
			for(int i = 0; i < n; i++){
				y = scan.nextInt();
				
				if(y < 10)h[0]++;
				else if(y < 20)h[1]++;
				else if(y < 30)h[2]++;
				else if(y < 40)h[3]++;
				else if(y < 50)h[4]++;
				else if(y < 60)h[5]++;
				else h[6]++;
			}
			for(int i = 0; i < 7; i++){
				System.out.println(h[i]);
			}
		}
	}
}

Measured memory_bytes: 247696