akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

constexpr ll MOD = 1e9 + 7;

void add_mod(ll& a, ll b) { a = (a + b) % MOD; }

int main() {
    string s; cin >> s;
    vector<vll> dp(s.size()+1, vll(4, 0));
    dp[0][0] = 1;

    rep(i, s.size()) {
        rep(j, 4) {
            if(s[i] == '?') add_mod(dp[i+1][j], (dp[i][j] * 3) % MOD);
            else            add_mod(dp[i+1][j], dp[i][j]);
        }
        if(s[i] == 'A' || s[i] == '?') add_mod(dp[i+1][1], dp[i][0]);
        if(s[i] == 'B' || s[i] == '?') add_mod(dp[i+1][2], dp[i][1]);
        if(s[i] == 'C' || s[i] == '?') add_mod(dp[i+1][3], dp[i][2]);
    }

    cout << dp[s.size()][3] << endl;
    return 0;
}

/*

dp[i+1][0] := i個目まででなにも照合していない個数
dp[i+1][1] := i個目まででAまで照合した個数
dp[i+1][2] := i個目まででBまで照合した個数
dp[i+1][3] := i個目まででCまで照合した個数

*/


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

int main() {
  int N,L;
  cin >> N >> L;
  string word[N];
  for(int i=0; i<N; i++)cin >> word[i];
  
  sort(word,word+N);
  for (int i=0; i<N;i++)cout << word[i];
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const vi d8x = {1, 0, -1, 0, 1, -1, -1, 1};
const vi d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vi d4x = {1, 0, -1, 0};
const vi d4y = {0, 1, 0, -1};

//----------------ここからだよ-------------------

int main(){
    string S; cin>>S;
    if(S=="SUN")cout<<7<<endl;
    if(S=="MON")cout<<6<<endl;
    if(S=="TUE")cout<<5<<endl;
    if(S=="WED")cout<<4<<endl;
    if(S=="THU")cout<<3<<endl;
    if(S=="FRI")cout<<2<<endl;
    if(S=="SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int ll;

const ll INF = (ll)2e18;
const ll MOD = 1000000007LL;

ll S[100010];
ll dp[100010];
int main() {
    ll N, A, B; scanf("%lld%lld%lld", &N, &A, &B);
    if(A > B) swap(A, B);
    S[0] = S[1] = -INF;
    for(int i=0; i<N; i++) scanf("%lld", &S[i+2]);

    dp[1] = 1;
    int ptr = 1;
    for(int i=2; i<N+2; i++) {
        if(S[i] - S[i-2] < A) {
            printf("0\n");
            return 0;
        }
        // current: i
        // prev: i-1

        // 二つ目の山に入れる
        int lb = ptr - 1;
        int ub = upper_bound(S, S+N+2, S[i] - B) - S - 1;
        ll val = (lb >= ub ? 0 : dp[ub]);

        // 一つ目の山に入れる
        ll diff = S[i] - S[i-1];
        if(diff < A) {
            // dp[i-2] 以前の要素は全て 0 になる
            // 0 でない値が格納されているインデックスの下限は i-1 になり、
            // その値について、累積を解除
            ptr = i-1;
            dp[i-1] = (dp[i-1] - dp[i-2] + MOD) % MOD;
        }
        dp[i] = (dp[i-1] + val) % MOD;
    }

    printf("%lld\n", dp[N+1]);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,m,a[1005];
int main(){
	while(1){
		cin>>n>>m; if(n==0) return 0;
		rep(i,n) cin>>a[i];
		int ans = 0;
		rep(i,n) rep(j,n){
			if(i == j) continue;
			if(a[i]+a[j] <= m) ans = max(ans,a[i]+a[j]);
		}
		if(ans == 0) cout << "NONE" << endl;
		else cout << ans << endl;
	}
}



Measured memory_bytes: 3088
#15chess
H,W=(int(i) for i in input().split())
while H!=0 or W!=0:
    S="."
    for i in range(H-1):
        if S[0]== "#":
            S="."
        else:
            S="#"
        for i in range(W-1):
            if S[-1]== "#":
                S+="."
            else:
                S+="#"
        print(S)
    if S[0]== "#":
        S="."
    else:
        S="#"
    for i in range(W-1):
        if S[-1]== "#":
            S+="."
        else:
            S+="#"
    print(S,end="")    
    print("\n")
    H,W=(int(i) for i in input().split())

Measured memory_bytes: 7736
S = [1 if x=="W" else 0 for x in input()]

groups = []
tmp = 0
zeros = 0
for n in S:
    if n == 1:
        if zeros != 0:#直前まで０だったとき
            groups.append(zeros)
            zeros = 0#リセット
        tmp += 1
    elif n == 0:
        if tmp != 0:#直前まで１だったとき
            groups.append(tmp)
            tmp = 0#リセット
        zeros -= 1

#終端の処理
if tmp != 0:
    groups.append(tmp)
if zeros != 0:
    groups.append(zeros)
    
print(len(groups)-1)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){

    int A = 0;
    int B = 0;
    double H = 0;
    double M = 0;
    double angle = 0;
    double answer = 0.0;
    scanf("%d %d %lf %lf", &A, &B, &H, &M);

    angle = H * 30.0 + 30.0 * (M / 60.0) - M * 6.0;
    angle = fabs(angle);
    if (angle > 180){
        angle = 360 - angle;
    }
    if (angle == 90){
        answer = sqrt(A * A + B * B);
    } else {
        answer = A * A + B * B - 2 * A * B * cos(angle * 3.1415926535897932 / 180.0);
        answer = sqrt(answer);
        //printf("ang:%lf\n", angle);
        //printf("cos:%lf\n", cos(angle * 3.14 / 180.0));
    }
    printf("%0.10lf\n", answer);

    return 0;
}

Measured memory_bytes: 2520
def main():
    musics = int(input())
    title = []
    time = []
    for _ in range(musics):
        s, t = input().split()
        title.append(s)
        time.append(int(t))
    last_song = input()
    for i in range(musics):
        if title[i] == last_song:
            print(sum(time[i + 1:]))
            break


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include<stdio.h>

int main()
{

	int N, X, i, j, m[124];
	int min,sum;
	
	scanf("%d %d",&N,&X);

	sum = 0;
	min = 1000;
	for(i=0;i<N;i++) {
	scanf("%d",&m[i]);
	if(min > m[i]) min = m[i];
	sum += m[i];
	}
	
	j = N + (X-sum)/min;
	
		printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t m,j,l,q=0;
  cin>>m;
  for(j=1;j*j<=m;j++){
    if(m%j==0) l=m/j;
  }
  while(l>0){
    q++;
    l/=10;
  }
  cout<<q<<endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
  
int main(){
  
int a,b;
char hoge[256];

while(scanf("%d %d\n", &a, &b) != EOF){
    //scanf("%d %d\n",&a,&b);
printf("%d\n", sprintf(hoge, "%d", a+b));


}
  
    return 0;
}

Measured memory_bytes: 616
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,bf,x,H,W,d,xans=0,yans=0;
  cin>>H>>W;
  cin>>bf;
  rep1(i,H){
    cin>>x;
    d=(x-bf)%mod;
    xans=(xans+d*i%mod*(H-i)%mod)%mod;
    bf=x;
  }
  cin>>bf;
  rep1(i,W){
    cin>>x;
    d=(x-bf)%mod;
    yans=(yans+d*i%mod*(W-i)%mod)%mod;
    bf=x;
  }
  cout<<(xans*yans)%mod<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int M = 1000000007;
    long ao = 0;
    long aka = 0;
    for(int i=1; i<=K; i++){
      if(K-1<i-1 || N-K+1<i){
        System.out.println(0);
      } else {
        ao = nCk(K-1, i-1, M);
        aka = nCk(N-K+1, i, M);
        System.out.println((ao * aka) % M);
      }
    }
  }

  public static int nCk(int n,int k,int M) {
    long ret = 1;
    int min = Math.min(k, n-k);
    for(int i=1;i<=min;i++) {
      ret = (ret * pow(i,M-2,M)) % M;
    }
    for(int i=n-min+1;i<=n;i++) {
      ret = (ret * i) % M;
    }
    return (int)ret;
  }

  public static long pow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
      if((b&1)==1) ret = (ret * tmp) % M;
      tmp = (tmp * tmp) % M;
      b = b>>1;
    }
    return ret;
  }
}


Measured memory_bytes: 25044
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
int a[10];

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	for (int i = 0; i < 4; i++)
	{
		int b;
		cin >> b;
		a[b]++;
	}
	if (a[1] && a[9] && a[7] && a[4])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	int www;
	cin >> www;
}


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

int main() {
  int a, b; cin >> a >> b;
  int ans;
  if (a >= 13) ans = b;
  else if (a >= 6) ans = b/2;
  else ans = 0;
  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;
#define rep(i,n) ;for(int i=0;i<n;++i)
int main() {
  int n;
  cin>>n;
  vector <vector<int>> a(n,vector<int> (n-1));
  for(int i=0;i<n;++i){
    for(int j=0;j<n-1;++j){
    cin>>a[i][j];
    a[i][j]--;
  }
  reverse(a[i].begin(),a[i].end());
}
vector <P> q;


auto check = [&](int i){
  if (a[i].size()==0) return;
  int j=a[i].back();
  if (a[j].size()==0) return;
  if (a[j].back()==i){
    P p(i,j);
    if (p.first>p.second)swap(p.first, p.second);
    q.push_back(p);
  }
};

rep(i,n){
  check(i);
}
int day=0;
while(!q.size()==0){
  day++;
  sort(q.begin(),q.end());
  q.erase(unique(q.begin(),q.end()),q.end());
  vector <P> pq;
  swap(q,pq);
  for (P pnow:pq){
    int i=pnow.first;
    int j=pnow.second;
    a[i].pop_back();
    a[j].pop_back();
  }
  for (P pnow:pq){
    int i=pnow.first;
    int j=pnow.second;
    check(i);check(j);
  }
}
for(int i=0;i<n;++i){
  if (a[i].size()>0)
  day=-1;
}
cout<<day;

}


Measured memory_bytes: 4224
import sys
S = input()
cnt = 1
tmp = 0
if S[0] == 'A':
    for i in range(2, len(S)-1):
        if S[i] == 'C':
            tmp = i
            cnt -= 1
if cnt == 0:
    for i in range(len(S)):
        if S[i].isupper() is True and i != 0 and i != tmp:
            print('WA')
            sys.exit()
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
import math
N,K = map(int, input().split())
M = (N-1)*(N-2)//2
if K > M:
    print(-1)
    exit()

print(N-1+M-K)
for i in range(2,N+1):
    print(1,i)
s = 2
d = 3
for i in range(M-K):
    print(s,d)
    d+=1
    if d > N:
        s+=1
        d = s+1

Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
m = map(int,read().split())
LRC = zip(m,m,m)

R_to_L = [[] for _ in range(N+1)]
R_to_C = [[] for _ in range(N+1)]

for l,r,c in LRC:
    R_to_L[r].append(l)
    R_to_C[r].append(c)

INF = 10**18

class MinSegTree():
    def __init__(self,N):
        self.Nelem = N
        self.size = 1<<(N.bit_length()) # 葉の要素数
        
    def build(self,raw_data):
        # raw_data は 0-indexed
        INF = 10**18
        self.data = [INF] * (2*self.size)
        for i,x in enumerate(raw_data):
            self.data[self.size+i] = x
        for i in range(self.size-1,0,-1):
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x<y else y
    
    def update(self,i,x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i+i]; y = self.data[i+i+1]
            self.data[i] = x if x<y else y
            i >>= 1
    
    def get_value(self,L,R):
        # [L,R] に対する値を返す
        L += self.size
        R += self.size + 1
        # [L,R) に変更
        x = 10**18
        while L < R:
            if L&1:
                y = self.data[L]
                if x > y: x = y
                L += 1
                
            if R&1:
                R -= 1
                y = self.data[R]
                if x > y: x = y
            L >>= 1; R >>= 1
        return x

dp = MinSegTree(N+1)
dp.build([INF]  * (N+1))

dp.update(1,0)

for r in range(2,N+1):
    x = INF
    for l,c in zip(R_to_L[r], R_to_C[r]):
        y = dp.get_value(l,r-1) + c
        if x>y:
            x=y
    dp.update(r,x)
    if r == N:
        answer = x

if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 101088
n = list(map(int, reversed(input()))) + [0]
ans = 0
for i in range(len(n)-1):
    if n[i] < 5:
        ans += n[i]
    elif n[i] == 5:
        if i != len(n) - 1 and n[i + 1] >= 5:
            n[i+1] += 1
            ans += 10 - n[i]
        else:
            ans += n[i]
    else:
        n[i+1] += 1
        ans += 10 - n[i]
if n[-1] > 0:
    ans += n[-1]
print(ans)

Measured memory_bytes: 121832
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

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); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

vector<int> G[200010];

signed main(){
	int n,m,x[200010],y[200010],acnt[200010] = {},bcnt[200010] = {};
	string s;
	bool ng[200010] = {};
	cin >> n >> m >> s;
	for(int i = 0;i < m;i++){
		cin >> x[i] >> y[i]; x[i]--;y[i]--;
		G[x[i]].pb(y[i]);
		G[y[i]].pb(x[i]);
	}
	queue<int> que;
	for(int i = 0;i < n;i++){
		for(int v : G[i]){
			if(s[v] == 'A') acnt[i]++;
			else bcnt[i]++;
		}
		if(!acnt[i] || !bcnt[i]){
			que.push(i);
			ng[i] = true;
		}
	}
	while(que.size()){
		int v = que.front();que.pop();
		ng[v] = true;
		for(int to : G[v]){
			if(!ng[to]){
				if(s[v] == 'A') acnt[to]--;
				else bcnt[to]--;
				if(!acnt[to] || !bcnt[to]){
					que.push(to);
					ng[to] = true;
				}
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(!ng[i]){
			Yes();
			return 0;
		}
	}
	No();
	return 0;
}

Measured memory_bytes: 19076
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<int> a(n), b(n);
  cin >> a >> b;
  vector<pair<int, int>> sa(n), sb(n);
  for (int i = 0; i < n; ++i) {
    sa[i] = make_pair(a[i], i);
    sb[i] = make_pair(b[i], i);
  }
  sort(sa.begin(), sa.end());
  sort(sb.begin(), sb.end());
  for (int i = 0; i < n; ++i)
    if (sa[i].first > sb[i].first) {
      puts("No");
      return 0;
    }
  for (int i = 1; i < n; ++i)
    if (sa[i].first <= sb[i - 1].first) {
      puts("Yes");
      return 0;
    }
  vector<int> p(n), q(n), r(n);
  for (int i = 0; i < n; ++i) {
    p[i] = sa[i].second;
    q[i] = sb[i].second;
  }
  for (int i = 0; i < n; ++i)
    r[p[i]] = q[i];
  int len = 0, x = 0;
  do {
    x = r[x];
    ++len;
  } while (x != 0);
  puts(len == n ? "No" : "Yes");

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 3840
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, K  = [int(x) for x in stdin.readline().rstrip().split()]
A = [0] + [int(x) for x in stdin.readline().rstrip().split()]

stack = [1]
nextt = A[1]
visited_dict = {1: True}

while True:
    if not visited_dict.get(nextt, False):
        stack.append(nextt)
        visited_dict[nextt] = True
    else:
        stack.append(nextt)
        break
    nextt = A[nextt]

    if len(stack) > K:
        print(stack[K])
        exit()

num1 = stack.pop()
length = len(stack)
tmp = []
while True:
    num2 = stack.pop()
    if num1 != num2:
        tmp.append(num2)
    else:
        tmp.append(num2)
        break

tmp = tmp[::-1]

index = (K - length) % len(tmp)

print(tmp[index])
    


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

typedef long long ll;

int main () {
    int a, b, c;
    cin >> a >> b >> c;
    int x = 100*a + 10*b + c;
    if (x%4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


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

#define all(c) (c).begin(),(c).end()

using namespace std;

vector<int>w;

bool fg[2000000];

void sieve(void){
  w.clear();
  w.push_back(-1);

  fill(fg,fg+2000000,false);
  for(int i=2;i*i<2000000;i++){
    if(!fg[i]){
      w.push_back(i);
      for(int j=i*2;j<2000000;j+=i){
        fg[j]=true;
      }
    }
  }
}

int dp[20][300][1130];

int main(void){

  sieve();

  fill(*dp[0],*dp[20],0);
  dp[0][0][0]=1;

  int sz=(int)(upper_bound(all(w),1120)-w.begin());
  for(int i=0;i<15;i++){
    for(int j=0;j<sz;j++){
      for(int k=0;k<=1120;k++){
        for(int l=j+1;l<sz;l++){
          if(k+w[l]<=1120){
            dp[i+1][l][k+w[l]]+=dp[i][j][k];
          }
        }
      }
    }
  }

  int n,K;
  while(cin >> n >> K,n|K){

    int ans=0;
    for(int i=0;i<sz;i++)ans+=dp[K][i][n];

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 29652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fr front
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
	ll ans = 0;
	int n; scanf("%d", &n);
	map <int, int> ct;
	map <int, int>::iterator it;
	
	int a[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		ct[a[i]]++;
	}
	for(it = ct.begin(); it != ct.end(); ++it){
		ans += 1LL * (it -> sc) * (it -> sc - 1) / 2;
	}
	for(int i = 0; i < n; i++){
		printf("%lld\n", ans - 1LL * ct[a[i]] + 1);
	}
}

Measured memory_bytes: 10432
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a, b , c ;
    cin >> a >> b >> c ;
    if(c - a + b < 0 || c == 0)cout << 0 ;
    else cout << c-a+b ;























return 0 ;
}


Measured memory_bytes: 3640
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int main()
{
    while (true) {
        int n = readln().chomp().to!int();
        if (n == 0) break;
        //writeln(dfs(0,0,0,n));
        int p = 9999999;
        for (int i = 0; i <= 25 && i * 200 <= n; i++) {
            for (int j = 0; j <= 17 && i * 200 + j * 300 <= n; j++) {
                for (int k = 0; k <= 10 && i * 200 + j * 300 + k * 500 <= n; k++) {
                    if (i * 200 + j * 300 + k * 500 == n) {
                        int t = i * 380 + j * 550 + k * 850;
                        t -= (i / 5) * 380;
                        t -= (j / 4) * 330;
                        t -= (k / 3) * 306;
                        p = min(p, t);
                    }
                }
            }
        }
        writeln(p);
    }

    return 0;
}

Measured memory_bytes: 1040
n,m,k=map(int,input().split())
def abyabya(a):
  global k,n,m
  if n*m-a==k:
    print("Yes")
    exit()
for i in range(n+1):
  for j in range(m+1):abyabya(i*j+(n-i)*(m-j))
print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y;
void solve()
{
    int i,tag=0;
    vector < int > a(n),b(m);
    for (i=0;i<n;i++)
        cin>>a[i];
    for (i=0;i<m;i++)
        cin>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for (i=x+1;i<=y;i++)
        if (i>a[n-1]&&i<=b[0]) {tag=1;break;}
    if (tag) cout<<"No War";
    else cout<<"War";
    cout<<endl;
}
int main()
{
    while(cin>>n>>m>>x>>y)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

const LL MOD = 1000000007;

int H, W, N;

bool same(vector<string> &bs, int y, int x, int dy, int dx) {
	char c = toupper(bs[y][x]);
	for (int i = 0; i < N; i++) {
		if (toupper(bs[y][x]) != c) {
			return false;
		}

		y += dy;
		x += dx;
	}

	return true;
}

void line_trans(vector<string> &bs, int y, int x, int dy, int dx) {
	char c = toupper(bs[y][x]);
	while (0 <= x && x < W && 0 <= y && y < H && c == toupper(bs[y][x])) {
		bs[y][x] = tolower(bs[y][x]);
		y += dy;
		x += dx;
	}
}

void down(vector<string> &bs) {
	for (int y = H - 2; y >= 0; y--) {
		for (int x = 0; x < W; x++) if (bs[y][x] != '.') {
			for (int i = y + 1; i < H; i++) {
				if (bs[i][x] == '.') {
					swap(bs[i - 1][x], bs[i][x]);
				}
			}
		}
	}
}

bool erase(vector<string> &bs) {
	bool done = false;

	// 横一直線
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W - N + 1; x++) if (bs[y][x] != '.' && same(bs, y, x, 0, 1)) {
			line_trans(bs, y, x, 0, 1);
		}
	}

	// 縦一直線
	for (int x = 0; x < W; x++) {
		for (int y = 0; y < H - N + 1; y++) if (bs[y][x] != '.' && same(bs, y, x, 1, 0)) {
			line_trans(bs, y, x, 1, 0);
		}
	}

	// 変換
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) if (islower(bs[y][x])) {
			bs[y][x] = '.';
			done |= true;
		}
	}

	return done;
}

bool all_empty(vector<string> bs) {
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			if (bs[y][x] != '.') {
				return false;
			}
		}
	}

	return true;
}

bool simulation(vector<string> bs, int y, int x) {
	swap(bs[y][x], bs[y][x + 1]);

	do {
		down(bs);
	} while(erase(bs));

	return all_empty(bs);
}

int main(void) {
	cin >> H >> W >> N;
	vector<string> bs(H);
	for (auto &l : bs) cin >> l;
	
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W - 1; x++) {
			if (simulation(bs, y, x)) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc066_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            Console.WriteLine(a[0] + a[1]);
        }
    }
}


Measured memory_bytes: 11348
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();

		int count=0;

		for (int i=L; i<=R; i++){
			if (i%d == 0){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35620
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> listA = new ArrayList<Integer>();
		ArrayList<Integer> listB = new ArrayList<Integer>();
		ArrayList<String> listSY = new ArrayList<String>();

		try(Scanner scan = new Scanner(System.in)) {
			while(true) {
				int numA = scan.nextInt();
				String sym = scan.next();
				int numB = scan.nextInt();

				if(sym.equals("?")) {
					break;
				}
				listA.add(numA);
				listB.add(numB);
				listSY.add(sym);
			}
			for(int i = 0; i < listSY.size(); i++) {
				if(listSY.get(i).equals("+")) {
					System.out.println(listA.get(i) + listB.get(i));
				} else if(listSY.get(i).equals("-")) {
					System.out.println(listA.get(i) - listB.get(i));
				} else if(listSY.get(i).equals("*")) {
					System.out.println(listA.get(i) * listB.get(i));
				} else if(listSY.get(i).equals("/")) {
					System.out.println(listA.get(i) / listB.get(i));
				}
			}
		}
	}
}

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

int main(){
	string T_card,H_card;
	int n;
	int T_val=0,H_val=0;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>T_card>>H_card;
		if(T_card > H_card){
			T_val+=3;
		}
		else if(H_card > T_card){
			H_val+=3;
		}
		else if(T_card == H_card){
			T_val+=1;
			H_val+=1;
		}
	}
	cout<<T_val<<" "<<H_val<<endl;
	return 0;
}

Measured memory_bytes: 1208
summ=0
mapper=dict()
n=int(input())
arr=[int(i) for i in input().split()]
for i in range(0,n):
    temp=arr[i]
    if temp not in mapper:
        mapper[temp]=0
    mapper[temp]+=1
    summ+=temp
q=int(input())
for i in range(0,q):
    temp,temp1=[int(j) for j in input().split()]
    if((temp in mapper) and  temp1 not in mapper):
        summ-=temp*mapper[temp]
        summ+=temp1*mapper[temp]
        mapper[temp1]=0
        mapper[temp1]+=mapper[temp]
        mapper.pop(temp)
    elif((temp in mapper) and (temp1 in mapper)):
        summ-=temp*mapper[temp]
        summ+=temp1*mapper[temp]
        val=mapper[temp]
        mapper.pop(temp)
        mapper[temp1]=mapper[temp1]+val
    print(summ)



Measured memory_bytes: 85448
require "prime"

n = gets.to_s.to_i

ans = 0
1.step(n,2) do |k|
  # p k.prime_division.to_h
  ans += 1 if 8 == k.prime_division.to_h.values.reduce(1){|cnt, t| cnt * (t+1) } 
  # p k if 8 == k.prime_division.to_h.values.reduce(1){|cnt, t| cnt * (t+1) } 
end

puts ans

Measured memory_bytes: 2684
from collections import defaultdict
import bisect
s = list(input())
t = list(input())
ds = defaultdict(int)  # ｓに含まれる文字のそれぞれの数
dsl = defaultdict(list)  # ｓの文字のindex
for i in range(len(s)):
    ds[s[i]] += 1
    dsl[s[i]].append(i)


ans = 0
now = -1  # ここが-1じゃないと、最初の遷移でsの最初の文字を使えない
for i in range(len(t)):
    if ds[t[i]] == 0:  # ｓにｔを構成する文字がない場合
        print("-1")
        exit()
    # elif ds[t[i]] == 1:
    #     if dsl[t[i]][0] > now:  # ｔの次の文字が現在地より右にある場合
    #         ans += (dsl[t[i]][0] - now)
    #     else:  # ｔの次の文字が現在地より左にある場合
    #         ans += dsl[t[i]][0] + (len(s) - now)
    #     now = dsl[t[i]][0]
    else:
        index = bisect.bisect_right(dsl[t[i]], now)
        if index == len(dsl[t[i]]):
            index = -1
        if dsl[t[i]][index] > now:  # ｔの次の文字が現在地より右にある場合
            ans += (dsl[t[i]][index] - now)
            now = dsl[t[i]][index]
        else:  # ｔの次の文字が現在地より左にある場合
            ans += dsl[t[i]][0] + (len(s) - now)
            now = dsl[t[i]][0]

print(ans)


Measured memory_bytes: 9308
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    str s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
import itertools

n,m,x=map(int,input().split())
ca=[0]*n
num=[]
ls=[]
last=[]
test=0
ng=0
money=0
for i in range(n):
  ca[i]=input().split()
  num.append(i)
  
for j in range(1,n+1):
  ls=list(itertools.combinations(num,j))
  
  for k in range(len(ls)):
    test=0
    money=0
    ng=0
    for l in range(m):
      test=0
      for p in range(j):
        test+=int(ca[ls[k][p]][l+1])
      if test<x:
        ng+=1
    if ng==0:
      for q in range(j):
        money+=int(ca[ls[k][q]][0])
      last.append(money)

if len(last)>0:
  print(str(min(last)))
else:
  print("-1")

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

using namespace std;

int main(void) {
	string s;
	cin >> s;
	
	int c(0);
	//blk
	for (int i = 0; i < s.size(); i++) {
		if (s[i] - '0' == i % 2) {
			c++;
		}
	}

	int d(0);
	for (int i = 0; i < s.size(); i++) {
		if (s[i] - '0' == (i+1)%2) {
			d++;
			
		}
	}
	cout << min(c, d);
	
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    static  boolean[] visited;
    static boolean[][] adjMatrix;
    static int res;

    static {
        res = 0;
    }

    static boolean visited_all() {
        for (boolean b : visited)
            if (!b)
                return false;
        return true;
    }

    static void dfsSolve(int vertex) {
        visited[vertex] = true;
        for (int nextVertex = 1; nextVertex < adjMatrix[vertex].length; ++nextVertex) {
            if (adjMatrix[vertex][nextVertex] && !visited[nextVertex]) {
                dfsSolve(nextVertex);
            }
        }
        if (visited_all())
            res += 1;
        visited[vertex] = false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        visited = new boolean[n + 1];
        visited[0] = true; // indexing from 1
        adjMatrix = new boolean[n + 1][n + 1];
        for (int i = 0; i < m; ++i) {
            int a = in.nextInt();
            int b = in.nextInt();
            adjMatrix[a][b] = true;
            adjMatrix[b][a] = true;
        }
        dfsSolve(1);
        System.out.println(res);
    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <vector>

using namespace std;

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

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

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

	int ans = a[0];
	for (auto x: a) {
		ans = gcd(ans, x);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import itertools
n,m,q = map(int,input().split())
ab = [0]*q
for i in range(q):
    ab[i] = list(map(int,input().split()))
data = list(range(1,m+1))
ans = 0
a = list(itertools.combinations_with_replacement(data, n))
for s in a:
    score = 0
    for i in range(q):
        if s[ab[i][1]-1] != s[ab[i][0]-1] + ab[i][2]:
            pass
        else:
            score += ab[i][3]
    ans = max(ans,score)
print(ans)

Measured memory_bytes: 21612
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    vector<int> ans(n, 0);
    for(int i=0; i<2*m; ++i){
        int a;
        cin >> a;
        ++ ans[a-1];
    }

    for(int i=0; i<n; ++i)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
s=[]
for i in range(n):
    s.append(input())
t=[0]*5
#print(s)

for i in range(n):
    c=list(s[i])
    if c[0]=='M':
        t[0]+=1
    if c[0]=='A':
        t[1]+=1
    if c[0]=='R':
        t[2]+=1
    if c[0]=='C':
        t[3]+=1
    if c[0]=='H':
        t[4]+=1
    #print(c)
ans=0
cnt=1
#print(t)
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
                cnt=t[k]*t[j]*t[i]
                ans+=cnt
print(ans)

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

using namespace std;

int main() {
    int N;
    cin >> N;
    while(N--) {
        string s1, s2;
        cin >> s1 >> s2;

        if(s1.size() > 80 || s2.size() > 80) {
            cout << "overflow" << endl;
            continue;
        }
        char buf[81] = {0};
        int p1 = s1.size()-1, p2 = s2.size()-1, pb = 79;
        int carry = 0;
        while(p2 >= 0) buf[pb--] = s2[p2--];
        pb = 79;
        while(pb >= 0 && (p1 >= 0 || carry > 0)) {
            int bd = buf[pb];
            if(bd > 0) bd -= '0';
            int bp = 0;
            if(p1 >= 0) bp = s1[p1--]-'0';
            int d = bp + bd + carry;
            carry = d / 10;
            d %= 10;
            buf[pb--] = d+'0';
        }
        while(pb >= 0 && buf[pb]) pb--;
        if(pb == -1 && carry > 0) cout << "overflow" << endl;
        else cout << (char*)(buf+(pb+1)) << endl;
    }
    return 0;
}

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

int main() {
    string a;
    cin >> a;
    map<char, int> count;
    long long result = 1;
    for (int i = 0; i < a.size(); i++) {
        auto current = count[a[i]]++;
        result += i - current;
    }
    cout << result;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int x = (int) ceil(a / 0.08), y = (int) ceil(b / 0.1);

    for (int i = min(x, y), n = max(x, y); i <= n; i++)
        if (floor(0.08 * i) == a && floor(0.1 * i) == b) {
            cout << i << endl;
            return 0;
        }

    cout << -1 << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int A[301],K[301];
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>A[i]>>K[i];
		int a=A[i],k=K[i];
		while(true){
			a=a/k*k+a%k%(a/k+1);
			if(a%k){
				a=a-(a/k+1);
			}
			else{
				ans^=(a/k);
				break;
			}
		}
	}
	if(ans)
		cout<<"Takahashi"<<endl;
	else
		cout<<"Aoki"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int a[4],s1,s2;
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+3+1);
	s1=a[3]-a[1];
	s2=a[3]-a[1]+a[2]-a[1];
	cout<<min(s1,s2);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,c[51],a,b,i;
	scanf("%d %d",&n,&m);
	for(i=0;i<=50;i++)	c[i]=0;
	for(i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		c[a]++;
		c[b]++;
	}
	for(i=1;i<=n;i++)	printf("%d\n",c[i]);
	return 0;
}


Measured memory_bytes: 128
<?php
$array = [];
for ($i = 0; $i < 5; $i++) {
	$array[] = trim(fgets(STDIN));
}
  
$k = trim(fgets(STDIN));

for ($i = 0; $i < 5; $i++) {
	for ($j = $i + 1; $j < 5; $j++) {
		if ($array[$i] === $array[$j]){
        	continue;
        } else if ($array[$j] - $array[$i] > $k) {
        	echo ':(', PHP_EOL;
            exit();
        }
    }
}

echo 'Yay!', PHP_EOL;

Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
using namespace std;
int ans = 1e9;
int n;
int a[3];
int l[10];
void dfs(int depth, string str){
    if(depth == n){
        int cnt[5] = {};
        int p = 0;
        int sum[5] = {};
        for(int i = 0; i < n; i++){
            int index = (int)(str[i] - '0');
            sum[index] += l[i];
            cnt[index] += 1;
        }
        for(int i = 0; i < 3; i++){
            if(cnt[i] == 0)return;
            p += (abs(sum[i] - a[i]) + (cnt[i]- 1)*10);   
        }
        ans = min(p, ans);
        return;
    }
    for(int i = 0; i < 4;i++){
        dfs(depth+1, str + (char)('0' + i));
    }
    return;
}
int main(){
    cin >> n >> a[0] >> a[1] >> a[2];
    for(int i = 0; i < n; i++)cin >> l[i];
    dfs(0,"");
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll 	long long
#define pb push_back
using namespace std;
#define pi acos(-1.0)
   
int main ()  
{

ll n;
cin>>n;

ll a[n+9];
ll cnt=0;

for(ll i=0;i<n;i++) cin>>a[i];

for(ll i=0;i<n;i+=2)
{
	if(a[i]%2)
	cnt++;
}
cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll X, Y, A, B, C;
ll p[101010], q[101010], r[101010];

typedef pair<ll, int> P;

int main()
{
    cin >> X >> Y >> A >> B >> C;
    priority_queue<P> que;
    rep(i, 0, A)
    {
        cin >> p[i];
        que.push(make_pair(p[i], 0));
    }
    rep(i, 0, B)
    {
        cin >> q[i];
        que.push(make_pair(q[i], 1));
    }
    rep(i, 0, C)
    {
        cin >> r[i];
        que.push(make_pair(r[i], 2));
    }

    ll total = X + Y;
    ll xcnt = 0;
    ll ycnt = 0;
    ll totalcnt = 0;

    ll ans = 0;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();

        int color = p.second;

        if (color == 0)
        {
            if (xcnt < X && totalcnt < total)
            {
                ans += p.first;
                xcnt++;
                totalcnt++;
            }
        }
        else if (color == 1)
        {
            if (ycnt < Y && totalcnt < total)
            {
                ans += p.first;
                ycnt++;
                totalcnt++;
            }
        }
        else
        {
            if (totalcnt < total)
            {
                ans += p.first;
                totalcnt++;
            }
        }
    }
    cout << ans << endl;
}


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

const int MX = 100001;

int main(){
  int n,q;
  cin >> n;
  vector<ll> cnt(MX);
  rep(i,n){
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll tot = 0;
  rep(i,MX) tot += i*cnt[i];

  cin >> q;
  rep(i,q){
    int b,c;
    cin >> b >> c;
    tot -= b*cnt[b];
    tot -= c*cnt[c];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    tot += b*cnt[b];
    tot += c*cnt[c];
    cout << tot << endl;
  }

  return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,m,K;
  cin>>n>>m>>K;
  vector<int> A(n),B(m);
  for(int i=0;i<n;++i)cin>>A[i];
  for(int i=0;i<m;++i)cin>>B[i];
  int posA=0,posB=0;
  for(;posA<n;++posA){if(K-A[posA]>=0)K-=A[posA];else break;}
  for(;posB<m;++posB){if(K-B[posB]>=0)K-=B[posB];else break;}
  int ans=posA+posB;
  while(posA-1>=0){
    K+=A[posA-1];posA--;
    for(;posB<m;++posB){
      if(K-B[posB]>=0)K-=B[posB];
      else break;
    }
    ans=max(ans,posA+posB);
  }
  cout<<ans<<'\n';
  
  return 0;
}
//2020.06.27 20:03:43


Measured memory_bytes: 4780
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]
		|| s[0] == s[2] && s[1] == s[3] && s[0] != s[1]
		|| s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
		puts("Yes");
	}
	else puts("No");
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  char s[100001];
  scanf("%s", s);
  
  u64 ra = 0;
  u64 raaa = 1;
  u64 rb = 0;
  u64 rc = 0;
  for (char*p=s;*p;p++) {
      if (*p == 'A') ra+=raaa, ra%=MOD;
      if (*p == 'B') rb+=ra, rb %= MOD;
      if (*p == 'C') rc+=rb, rc %= MOD;
      if (*p == '?') {
          u64 raa = (((u64)ra)*3+raaa)%MOD;
          u64 rbb = ((u64)ra+rb*3)%MOD;
          u64 rcc = ((u64)rb+rc*3)%MOD;
          ra = raa;
          rb = rbb;
          rc = rcc;
          raaa=(raaa*3)%MOD;
          // printf("%d %d %d\n", ra, rb ,rc);
      }
  }
  wu64(rc);
  
  return 0;
}


Measured memory_bytes: 384