akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

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

   int n,m,x,y;
   cin>>n>>m>>x>>y;
   vector<int>v(n),vv(m);
   for(int i=0;i<n;i++) cin>>v[i];
   for(int i=0;i<m;i++) cin>>vv[i];

   int xn=max(x,*max_element(all(v)));
   int yn=min(y,*min_element(all(vv)));
   if(yn-xn>0) cout<<"No War"<<endl;
   else cout<<"War"<<endl;
   return 0;
}


Measured memory_bytes: 256
from queue import Queue
import copy

h, w = map(int, input().split())

f = [["#"] * (w + 2)] + \
    [list("#" + input() + "#") for i in range(h)] + \
    [["#"] * (w + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]

d = [[-1]*(w+2) for i in range(h+2)]
for iy in range(h+2):
    for ix in range(w+2):
        if f[iy][ix] == '#':
            d[iy][ix] = 1000

ans = 0
for sy in range(h+2):
    for sx in range(w+2):
        if f[sy][sx] == '#':
            continue
        dist = copy.deepcopy(d)
        cnt = 0
        cnt_max = 0
        q = Queue()
        q.put([sy, sx])
        dist[sy][sx] = 0
        while q.qsize():
            y, x = q.get()
            cnt = dist[y][x]
            
            # print(sx, sy, x, y)
            cnt_max = max(cnt_max, cnt)
            for dy, dx in dxy:
                ny, nx = y + dy, x + dx
                if dist[ny][nx] == 1000:
                    continue
                if dist[ny][nx] == -1:
                    q.put([ny, nx])
                    dist[ny][nx] = cnt + 1
        # print(sx, sy, x, y, cnt)
        ans = max(ans, cnt_max)
print(ans)

Measured memory_bytes: 9688
#include <stdio.h>

int main(int argc, char const *argv[])
{
int i, sum;
char x[1000];

for(;;) {
	scanf("%s", &x);
	if(x[0] == '0') break;

	sum = 0;
	for(i = 0; x[i] != '\0'; i++) {
		sum += x[i] - '0';
	}
	printf("%d\n", sum);

}


	return 0;
}



Measured memory_bytes: 2060
n,m = map(int,input().split())
d1 = {}
d2 = {}
for i in range(m):
    a,b = map(int,input().split())
    if a == 1: d1[b] = 1
    if b == n: d2[a] = 1

for k in d1:
    if k in d2: 
        ans = "POSSIBLE"
        break
else:
    ans = "IMPOSSIBLE"

print(ans)

Measured memory_bytes: 24176
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w,m] <- getIntList
    hw <- replicateM m $ do
        [x,y] <- getIntList
        return (x-1,y-1)
    
    hvec' <- VUM.replicate h (0 :: Int)
    wvec' <- VUM.replicate w (0 :: Int)
    forM_ hw $ \(x,y) -> do
        VUM.modify hvec' succ x
        VUM.modify wvec' succ y 
    hvec <- VU.freeze hvec'
    wvec <- VU.freeze wvec'

    let hmax = VU.maximum hvec
    let wmax = VU.maximum wvec
    let dhw = sum $ map check hw
          where check (x,y) | hvec VU.! x == hmax && wvec VU.! y == wmax = 1
                            | otherwise = 0
    let hidx = VU.length $ VU.filter (== hmax) hvec
    let widx = VU.length $ VU.filter (== wmax) wvec
    let lhw = hidx * widx
    let d = if dhw == lhw then 1 else 0

    print $ hmax + wmax - d

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

int main() {
    int number = 0;
    cin >> number;
    
    vector<int64_t> lucas(number + 1);
    
    lucas.at(0) = 2;
    lucas.at(1) = 1;
    for (int i = 2; i < lucas.size(); ++i) {
            lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
    }
    
    cout << lucas.at(number) << endl;
}

Measured memory_bytes: 256
from bisect import bisect_right

n = int(input())
a = sorted(map(int, input().split()))
r = 0
for i in range(2, n):
    j = i - 1
    while j and a[j - 1] + a[j] > a[i]:
        r += j - bisect_right(a, a[i] - a[j], 0, j)
        j -= 1
print(r)


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>

int main(){
	int ba[101][2],n,m,i,j,c;
	
	while(0<=scanf("%d%d",&n,&m)){
		if(n==0 && m==0)break;
		
		//ÚInÔÆlú»
		memset(ba,0,sizeof(ba));
		
		
		//ÚInÔãüÆlvZ
		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++){
				scanf("%d",&c);
				if(c==1)++ba[j][1];
				ba[j][0]=j;
			}
		}
		
		//lÅ\[g
		for(i=1;i<=m;i++){
			for(j=1;j<m;j++){
				if(ba[j][1]<ba[j+1][1]){
					c=ba[j][1];
					ba[j][1]=ba[j+1][1];
					ba[j+1][1]=c;
					
					c=ba[j][0];
					ba[j][0]=ba[j+1][0];
					ba[j+1][0]=c;
				}
			}
		}
		
		//oÍ
		for(i=1;i<=m;i++){
			printf("%d",ba[i][0]);
			if(i!=m)printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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

    vector<int> v;
    for (int i = 0; i < N; i++) {
        int value;
        cin >> value;
        v.push_back(value);
    }

    sort(v.begin(), v.end());

    double ave = v[0];
    for (int i = 0; i < N-1; i++) {
        ave = (ave + v[i+1]) / 2.0;
    }

    cout << ave << endl;
}

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

int main(){
	int x,y; cin>>x>>y;
	if(x%y==0) {cout<<-1<<endl; return 0;}
	for(int i=2; i<10; i++){
		if((x*i)%y!=0) {cout<<x*i<<endl;return 0;}
	}
}

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

int main()
{
  int n;
  cin >> n;
  
  //バケット
  vector<int> b_0(110000, 0), b_1(110000, 0);
  for (int i = 0; i < n / 2; i++)
  {
    int a_0, a_1;
    cin >> a_0 >> a_1;
    b_0.at(a_0)++;
    b_1.at(a_1)++;
  }
  
  //最頻値と2番目に頻度が大きいもの(最頻値の場所が被ったとき用)
  //2番目が最頻値と同じこともあるがそれでよい
  int max_0 = 0, max_1 = 0, max2nd_0 = 0, max2nd_1 = 0;
  int maxP_0 = -1, maxP_1 = -1;
  for (int i = 0; i < b_0.size(); i++)
  {
    if (max_0 < b_0.at(i))
    {
      max2nd_0 = max_0;
      max_0 = b_0.at(i);
      maxP_0 = i;
    } else if (max2nd_0 < b_0.at(i)) max2nd_0 = b_0.at(i);
    if (max_1 < b_1.at(i))
    {
      max2nd_1 = max_1;
      max_1 = b_1.at(i);
      maxP_1 = i;
    } else if (max2nd_1 < b_1.at(i)) max2nd_1 = b_1.at(i);
  }
  
  int ans;
  if (maxP_0 != maxP_1) ans = n - (max_0 + max_1);
  else ans = n - max(max_0 + max2nd_1, max_1 + max2nd_0);
  //cout << max_0 << " " << max_1 << " " << max2nd_0 << " " << max2nd_1 << " " << endl;
  //cout << maxP_0 << " " << maxP_1 << endl;
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  int a[110];
  for (int i = 0; i < N; ++i){ cin >> a[i];}
  
  sort(a, a + N, greater<int>());
  
  
  int Alice = 0;
  int Bob   = 0;
  for (int i = 0; i < N; ++i){
    if (i % 2 == 0){Alice += a[i];}
    else           {Bob   += a[i];}
  }
  
  cout << Alice - Bob << endl;
}
  
    

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

using namespace std;

int main (){

 long long n,i,d,c=0,k;

  cin>>n>>k;

  for(i=1; i<=n; i++){

    cin>>d;

    if(d>=k)c++;

  }

  if(c>0) cout<<c<<endl;
  else cout<<0<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  ll cnt=0;
  bool flag[n+10]={};
  for(int i=0;i<n;i++){
    int t;cin>>t;
    if(t==i+1)
      flag[i]=false;
    else
      flag[i]=true;
  }
  for(int i=0;i<n;i++){
    if(i==n-1){
      if(!flag[i]){
	flag[i]=true;
	flag[i-1]=true;
	cnt++;
      }
    }else if(!flag[i]){
      flag[i]=true;
      flag[i+1]=true;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 384
s = input()
se = s[::2]
so = s[1::2]
ans = "-1 -1"
for i in range(len(s)-1) :
    if s[i] == s[i+1] :
        ans = str(i+1)+" "+str(i+2)
for i in range(len(se)-1) :
    if se[i] == se[i+1] :
        ans = str(2*i+1)+" "+str(2*i+3)
for i in range(len(so)-1) :
    if so[i] == so[i+1] :
        ans = str(2*i+2)+" "+str(2*i+4)
print(ans)

Measured memory_bytes: 3188
A,B,C,X,Y = map(int, input().split())

#print( A,B,C,X,Y )

min_val = 0

if A+B < 2*C:
    min_val = A*X + B*Y
else:
    if X > Y:
        min_val = Y*2*C + min(abs(X-Y)*A, abs(X-Y)*2*C)
    else:
        min_val = X*2*C + min(abs(X-Y)*B, abs(X-Y)*2*C)

print(min_val)


Measured memory_bytes: 3060
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[200005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ma = a[0];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ma = max(ma, a[i]);
		ans += ma - a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    int MAX = 0, MIN = INF;
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
        chmax(MAX, a);
        chmin(MIN, a);
    }
    bool ok = 1;
    ok &= sz(cnt) == MAX - MIN + 1;
    ok &= cnt[MAX] >= 2;
    ok &= cnt[MIN] == 2 - (MAX + 1) % 2;
    cout << (ok ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Msi = M<string, int>;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int bad = 0;
    char now = s[0];
    REP2(i, 1, n) {
        if (now != s[i] && now == 'R') {
            bad++;
        }
        now = s[i];
    }
    if (s[0] == 'R' && s.back() == 'L') {
        if (k < bad) {
            std::cout << n - (bad-k)*2 << '\n';
        } else {
            std::cout << n - 1 << '\n';
        }
    } else if (s[0] == 'L' && s.back() == 'R') {
        if (k <= bad) {
            std::cout << n-2-(bad-k)*2 << '\n';
        } else {
            std::cout << n-1 << '\n';
        }
    } else {
        if (k <= bad) {
            std::cout << n-1-(bad-k)*2 << '\n';
        } else {
            std::cout << n-1 << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong k;
llong d[128];
llong a[128][128];
llong cnt[128];

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

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3696
def f():
    import sys
    input=sys.stdin.buffer.readline
    sys.setrecursionlimit(10**9)
    n=int(input())
    l=sorted([list(map(int,input().split())) for i in range(n)],key=sum,reverse=1)
    ans=0
    for i in range(n):
        if i%2:ans-=l[i][1]
        else:ans+=l[i][0]
    print(ans)
if __name__ == "__main__":
    f()

Measured memory_bytes: 32992
D,G=map(int,input().split())
p=[]
c=[]
for i in range(D):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)

ans=100000

for i in range(2**D):
    ten=0
    mondaisu=0
    for j in range(D):
        if ((i>>j)&1):
            ten+=(j+1)*100*p[j]+c[j]
            mondaisu+=p[j]
        else:
            k=j
    if ten>G:
        if ans>mondaisu:
            ans=mondaisu
    else:
        if G-ten<=(k+1)*100*p[k]:
            mondaisu+=(G-ten-1)//((k+1)*100)+1
            if ans>mondaisu:
                ans=mondaisu
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

ll abss(ll x){return x >= 0? x : 0 - x;}

void solve_B(){
    ll a, v;
    ll b, w;
    ll t;
    cin >> a >> v >> b >> w >> t;

    bool flag = false;
    
    if(v > w){
        if((abss(a-b) + (v-w) -1 ) / (v-w) <= t) flag = true;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main(void){
    solve_B();
    
    return 0;
}

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

using namespace std;

const int MX = 100, md = 998244353;

map<string, int> f;

int gg(string s);

int ff(string s) {
	if (s.empty()) return 1;
	if (f.count(s) == 0) {
		string t(s.begin(), s.end() - 1);
		int ans = ff(t);
		if (s.back() == '1') ans = (ans * 2) % md;
		
		for (int x = 0; x + 1 < s.size(); x++) {
			string tt(s.begin(), s.begin() + x);
			string ts(s.begin() + x, s.end());
			
			ans = (ans + ff(tt) * 1ll * gg(ts)) % md;
		}
		
		f[s] = ans;
	}
	
	return f[s];
}

map<string, int> g;

int gg(string s) {
	if (s.empty()) return 0;
	if (g.count(s) == 0) {
		int ans = 0;
		for (int p = 1; p < s.size(); p++)
			if (s.size() % p == 0) {
				string t(s.begin(), s.begin() + p);
				
				int cnt = 0;
				for (int i = 0; i < p; i++) {
					bool ok = true;
					for (int j = i; j < s.size() && ok; j += p)
						ok = ok && s[j] == '1';
					
					if (ok == false)
						t[i] = '0';
				}
				
				ans = (ans + ff(t)) % md;
			}
		
		g[s] = ans;
	}
	
	return g[s];
}

char s[MX + 1];

int main() {
	ignore = scanf("%s", s);
	
	printf("%d\n", ff(s));
	
	return 0;
}


Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		//????????£????????????
		Scanner sc = new Scanner(System.in);
		//??????????????£?¨?
		boolean [][] cards = new boolean[4][13];
		//???????????????????????? ???????????????????????????
		//String mark = new String();
		//????????????????????°
		int num =sc.nextInt();
		//??\????????????????????????????????°????????????
		for(int i=0; i < num; i++){
			//????????????????????????
			String mark = sc.next();
			//??????????????????????????°????????\?????????????????????true
			if(mark.equals("S")){
				cards[0][sc.nextInt()-1] = true;
			}else if(mark.equals("H")){
				cards[1][sc.nextInt()-1] = true;
			}else if(mark.equals("C")){
				cards[2][sc.nextInt()-1 ]= true; 
			}else if(mark.equals("D")){
				cards[3][sc.nextInt()-1] = true;
			}
		}
		//?????????????????????????????¨???
		for(int i = 0; i< cards.length;i++){
			for(int j=0; j< cards[0].length;j++){
				//true??§????????????????????¨???
				if(!cards[i][j]){
					if(i == 0){
						System.out.println("S " + (j+1));
					}else if(i == 1 ){
						System.out.println("H " + (j+1));
					}else if(i == 2){
						System.out.println("C " + (j+1));
					}else if(i == 3){
						System.out.println("D " + (j+1));
					}
				}
			}
		}
		
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int N,Q;
string s[100];
int a[100];

int main(){
  cin>>N>>Q;
  rep(i,N)cin>>a[i]>>s[i];
  a[N]=1;
  s[N]="kogakubu10gokan";
  N++;
  string res;
  int mx=-1;
  rep(i,N){
    if(a[i]<=Q&&mx<a[i]){
      mx=a[i]; res=s[i];
    }
  }
  cout<<res<<endl;
  return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	if (b - a <= 8) {
		for (ll i = a; i <= b; i++) {
			ans = ans xor i;
		}
	}
	else {
		while (a % 4 != 0) {
			ans = ans xor a;
			a++;
			//cout << ans << endl;
		}
		while (b % 4 != 3) {
			ans = ans xor b;
			b--;
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
}


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

int n,a,b,c,d;
char s[200010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();a=rd();b=rd();c=rd();d=rd();
	scanf("%s",s+1);
	bool flag=true;
	for (int i=a;i<c;i++) if (s[i]=='#'&&s[i+1]=='#') flag=false;
	for (int i=b;i<d;i++) if (s[i]=='#'&&s[i+1]=='#') flag=false;
	if (!flag) { puts("No");return 0; }
	if (c<d) { puts("Yes");return 0; }
	flag=false;
	for (int i=b-1;i<=d-1;i++) if (s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') flag=true;
	if (flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) 
    { 
        if (y & 1) 
        res = res*x; 
        y = y>>1; 
        x = x*x;  
    } 
    return res; 
}

signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,i,j;
		cin>>n;
		if(n==0)
		cout<<1<<u;
		else
		cout<<0<<u;
	}
	return 0;
} 

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

int main() {
  int N, sum = 0, A = 100000000;
  cin >> N;
  int n = N;
  
  for (int i = 0; i < 8; i++) {
    if (i != 7) {
      sum += n / A;
    }
    else if (i == 7) {
      sum = sum + n / 10 + n % 10;
    }
    n = n % A;
    A = A / 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }  
}

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

int N[] = {105, 135, 165, 189, 195, 201};

int main(){
    int n;
    cin >> n;
    int *pos = upper_bound(N, N + 6, n);
    int idx = distance(N, pos);
    cout << idx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	
	cin >> a >> b;
	
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    K, X = map(int, input().split())

    if 500 * K >= X:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    sc.close();

    Deque<Long> v = divisor(N);

    int l = v.size();
    if (l % 2 == 0) {
      System.out.println(v.pollLast() + v.pollLast() - 2);
    } else {
      System.out.println(v.pollLast() * 2 - 2);
    }

  }

  static Deque<Long> divisor (long N) {
    Deque<Long> res = new ArrayDeque<>();
    for (long i = 1; i * i <= N; i++) {
      if (N % i == 0) {
        res.add(i);
        if (i != N / i) {
          res.add(N / i);
        }
      }
    }
    return res;
  }

}

Measured memory_bytes: 23764
#include <stdio.h>

int main (){
    int i, j, t, n=0; 
    int R[10000000]={0};
    int maxv, minv;

    scanf("%d",&n);
    for(t=0; t<n; t++){
        scanf("%d",&R[t]);
    }
    
    maxv = (R[1] - R[0]);
    minv = R[0];
    for(j=1; j<n; j++){
        if(maxv < R[j]-minv) maxv = R[j]-minv;      //maxv = (maxv と R[j]-minv のうち大きい方)
        if(minv > R[j])      minv = R[j];           //minv = (minv と R[j] のうち小さい方)
        
        //printf("%d %d\n", maxv, minv);
    }

    printf("%d\n", maxv); 
    
return 0;
}



Measured memory_bytes: 41820
#include<bits/stdc++.h>
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(j=a;j>=b;j--)
#define vi vector<int>
#define pi 3.14159265358979323846
using namespace std;

void koch(int n, pair<double,double> a, pair<double,double> b);
int main(){
	int n,i,j;
	cin>>n;
	pair<double,double> a(0,0),b(100,0);
	printf("%.8lf %.8lf\n",a.first,a.second);
	koch(n,a,b);
	printf("%.8lf %.8lf\n",b.first,b.second);
}

void koch(int n, pair<double,double> a, pair<double,double> b){
	if(n==0){
		return;
	}
	double th=pi/3.0;
	pair<double,double> s((2*a.first+b.first)/3.0,(2*a.second+b.second)/3.0);
	pair<double,double> t((a.first+2*b.first)/3.0,(a.second+2*b.second)/3.0);
	pair<double,double> u((t.first-s.first)*cos(th)-(t.second-s.second)*sin(th)+s.first,(t.first-s.first)*sin(th)+(t.second-s.second)*cos(th)+s.second);
	koch(n-1,a,s);
	printf("%.8lf %.8lf\n",s.first,s.second);
	koch(n-1,s,u);
	printf("%.8lf %.8lf\n",u.first,u.second);
	koch(n-1,u,t);
	printf("%.8lf %.8lf\n",t.first,t.second);
	koch(n-1,t,b);
}

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

int main() {

    int N;
    cin >> N;
    vector<int> A(N), B(N + 1);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i + 1];

    int ans = 0, now = 0;

    for (int i = 0; i < N + 1; i++)
        now += B[i];

    rep(i, N) {
        now += A[i] - B[i];
        ans = max(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << x << endl;
#define input(x) cin >> x;
#define rep(i, n) for (int i = 0; i < n; ++i)

int main()
{
    long long int l, r;
    cin >> l >> r;

    long long int ans = 2018;

    if (r - l >= 2019)
    {
        print(0);
        return 0;
    }
    else
    {
        for (long long int i = l; i < r; ++i)
        {
            for (long long int j = i + 1; j <= r; ++j)
            {
                ans = min(ans, (i * j) % 2019);
            }
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[205], B[205], Count[205];
vector <int> Graph[205];

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    scanf("%d%d", A + i, B + i);
  }

  for (int i = 100; i < N + 100; i++){
    scanf("%d%d", A + i, B + i);
    for (int j = 0; j < N; j++){
      if (A[j] < A[i] && B[j] < B[i]){
        Graph[i].push_back(j);
        Graph[j].push_back(i);
        Count[i]++; Count[j]++;
      }
    }
  }

  int ans = 0, cnt = 0;
  while (cnt < N){
    cnt++;

    priority_queue <Pii, vector<Pii>, greater<Pii> > que;
    for (int i = 0; i < N; i++){
      if (Count[i] == 0) continue;
      que.push({Count[i], i});
    }
    for (int i = 100; i < N + 100; i++){
      if (Count[i] == 0) continue;
      que.push({Count[i], i});
    }

    if (que.empty()) break;

    int edge = que.top().se, next = -1, num = 1e9;
    Count[edge] = 0;

    for (int i = 0; i < Graph[edge].size(); i++){
      if (Count[Graph[edge][i]] == 0) continue;

      if (Count[Graph[edge][i]] < num){
        num = Count[Graph[edge][i]];
        next = Graph[edge][i];
      }
      Count[Graph[edge][i]]--;
    }
    if (next == -1) continue;
    ans++;
    Count[next] = 0;

    for (int i = 0; i < Graph[next].size(); i++){
      if (Count[Graph[next][i]] == 0) continue;
      Count[Graph[next][i]]--;
    }
  }
  cout << ans << endl;


  return 0;
}


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

int main() {
	int a;
	vector<int> A;
	for (int i = 0; i < 10; i++) {
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), greater<int>());
	cout << A[0] << endl;
	cout << A[1] << endl;
	cout << A[2] << endl;
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll pot[12],d;
ll dfs(ll k,ll x,ll i,bool fi){
    if(k/2<=i){
	ll res=(x==d);
	if(k%2==1)res*=10;
	return res;
    }
    ll kei=pot[k-i-1]-pot[i];
    ll res=0;
    for(ll r=-9;r<=9;r++){
	ll kei2=(10-abs(r));
	if(fi&&r>=0)kei2--;
	if(abs(d-(x+kei*r))<=kei){
	    res+=kei2*dfs(k,x+kei*r,i+1,0);
	}
    }
    return res;
}
ll solve(ll k){
    return dfs(k,0,0,1);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    pot[0]=1;
    for(int i=1;i<18;i++)pot[i]=pot[i-1]*10;
    ll ans=0;
    cin>>d;
    for(int k=2;k<=18;k++){
	//cout<<"#"<<k<<" "<<solve(k,d)<<endl;
	ans+=solve(k);
    }
    cout<<ans<<endl;
}




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

using namespace std;

int main(void) {
	int num, i = 0, sum = 0, ans = 0;
	cin >> num;
	vector<int> top(num), flo(num), a(num);
	for (; i < num; i++)
		scanf("%d", &top[i]);
	for (i = 0; i < num; i++)
		scanf("%d", &flo[i]);
	for (i = 0; i < num; i++) {
		sum += top[i];
		a[i] = sum;
	}
	for (i = num - 1, sum = 0; i >= 0; i--) {
		sum += flo[i];
		a[i] += sum;
	}
	for (i = 0; i < num; i++)
		ans = max(ans, a[i]);
	cout << ans << "\n";
	return 0;
}

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

D = True

pos = []
pos1 = []

for i in range(n):
	x, h = map(int, input().split())
	pos.append((x, h))

pos.sort(key=lambda x: x[0])

bombs = 0
damage = 0
y, z = 0, 0


while y < n:
	x0 = pos[y][0]
	try:
		x1 = pos1[z][0]
	except IndexError:
		x1 = 1e16
	if x0 <= x1:
		health = pos[y][1]
		health -= damage
		number = max(0, (health-1) // a + 1)
		bombs += number
		damage += number*a
		pos1.append((x0+2*d, number*a))
		y+=1
	else:
		damage -= pos1[z][1]
		z += 1
	

print(bombs)



Measured memory_bytes: 57316
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

int main(){

    while(true){
	int h,w;
	cin >> w >> h;
	if(w == 0 && h == 0) break;
	vector< vector<char> > board(h+2,vector<char>(w+2,'#'));
	int sx,sy;
	int ans = 0;
	REP(i,h)REP(j,w){
	    cin >> board[i+1][j+1];
	    if(board[i+1][j+1] == '@'){
		sx = j+1;
		sy = i+1;
		board[sy][sx] = '#';
		ans++;
	    }
	}
	queue<int> qx;
	queue<int> qy;
	qx.push(sx);
	qy.push(sy);
	while(!qx.empty()){
	    int x = qx.front();
	    int y = qy.front();
	    qx.pop();
	    qy.pop();
	    REP(i,4){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(board[ny][nx] == '.'){
		    board[ny][nx] = '#';
		    qx.push(nx);
		    qy.push(ny);
		    ans++;
		}
	    }
	}
	cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
params = STDIN.read
l1 = params.split(/\n/)[0].strip
l2 = params.split(/\n/)[1]
l3 = params.split(/\n/)[2]

n = l1.to_i
v_arr = l2.split(" ").map(&:to_i)
c_arr = l3.split(" ").map(&:to_i)

v_with_c = v_arr.zip c_arr

ans = 0
v_with_c.each do |jew|
  dif = jew[0] - jew[1]
  ans += dif if jew[0] - jew[1] > 0
end


puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll tre[2*4*MAX], va[2*MAX];
int hi[2*MAX];

ll query(int node, int l, int r, int a, int b){
    //cerr<<"l, r == "<<l<<' '<<r<<'\n';
    if(a<=l && r<=b){
        return tre[node];
    }

    ll ans = -1;

    int mid = (l+r)/2;
    if(a<=mid){
        ans = max(ans, query(2*node+1, l, mid, a, b));
    }

    if(b>mid){
        ans = max(ans, query(2*node+2, mid+1, r, a, b));
    }

    return ans;
}


void update(int node, int l, int r, int ind, ll val){
    //cerr<<"l, r == "<<l<<' '<<r<<'\n';
    //cerr<<"upd val == "<<val<<'\n';
    if(l==r){
        //cerr<<"upd l == "<<ind<<'\n';
        tre[node] = val;
        return;
    }

    int mid = (l+r)/2;
    if(ind<=mid){
        update(2*node+1, l, mid, ind, val);
    } else {
        update(2*node+2, mid+1, r, ind, val);
    }
    tre[node] = max(tre[2*node+1], tre[2*node+2]);
}

int main(){
    /*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>hi[i];
        hi[i]--;
    }

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

    for(int i=0;i<n;i++){
        ll qr = 0;
        qr = query(0, 0, n-1, 0, hi[i]);
        //cerr<<"qr == "<<qr<<'\n';
        update(0, 0, n-1, hi[i], qr+va[i]);
    }

    /*for(int i=0;i<=4*n;i++){
        cerr<<tre[i]<<' ';
    }*/
    ll ans = 0;
    ans = query(0, 0, n-1, 0, n-1);
    cout<<ans<<'\n';
    
    return 0;   
}

Measured memory_bytes: 8448
#include <stdio.h>

#define N_MAX (200000)

int main(void)
{
    long long x[N_MAX];
    long long y[N_MAX];
    long long N, D;
    int i;
    long long DD, xx, yy; 
    int cnt = 0;
 
    scanf("%ld %ld", &N, &D);
    for (i = 0; i < N; i++) {
        scanf("%ld %ld", &x[i], &y[i]);
    }

    DD = D * D;

    for (i = 0; i < N; i++) {
        xx = x[i] * x[i];
        yy = y[i] * y[i];
        if (DD >= xx + yy) {
            cnt++;
        }
    }

    printf("%d", cnt);

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int>a(n);
	rep(i, n)cin >> a[i];

	map<int, int>mp;
	rep(i, n) {
		mp[a[i]]++;
	}

	int q = 0;

	for(pair<int , int> p: mp ) {
		q++;
	}
	
	vector<int>cut(q);
	int h = 0;
	for (pair<int, int> p : mp) {
		cut[h]= p.second;
		h++;
	}
	sort(cut.begin(), cut.end());
	int count = 0;
	for (int i = 0; i < q - k; i++) {
		count += cut[i];
	}
	cout << count << endl;
}

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5 + 5;

int a[4][N], dp[4][N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=3; j++) {
            cin >> a[j][i];
            dp[j][i] = 0;
        }
    }
    for (int i=1; i<=3; i++) dp[i][1] = a[i][1];
    for (int i=2; i<=n; i++) {
        for (int j=1; j<=3; j++) {
            for (int k=1; k<=3; k++) {
                if (k != j) {
                    dp[j][i] = max(dp[j][i], dp[k][i-1] + a[j][i]);
                }
            }
        }
    }
    int ans = 0;
    for (int i=1; i<=3; i++) ans = max(ans, dp[i][n]);
    cout << ans << "\n";
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M; //N個の都市、M個の道
    vector<int> a(M);
    vector<int> b(M);
    vector<int> city(N, 0);
    for(int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);
    }
    for(int i = 0; i < M; i++){
        city.at(a.at(i)-1)++;
        city.at(b.at(i)-1)++;
    }
    for(int i = 0; i< N; i++){
        cout << city.at(i) << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  string s;
  cin >> s;
  if (s.length() <= 3) {
    printf("No\n");
    return 0;
  }
  if (s.substr(0, 4) == "YAKI") {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll sum=0;
  rep(i,n-1){
    if(a[i]>a[i+1]){
      sum += a[i]-a[i+1];
      a[i+1]=a[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 4040
#include<iostream>

using namespace std;

void maxHeapify(int arr[], int i, int n)    
{
	int largest = i;  
	int l = 2*i + 1;  
	int r = 2*i + 2;  

	if (l < n && arr[l] > arr[i]) largest = l;

	if (r < n && arr[r] > arr[largest]) largest = r;

	if (largest != i)
	{
		swap(arr[i], arr[largest]);

		maxHeapify(arr, largest, n);
	}
}

void buildMaxHeap(int arr[], int n){
	for(int i = (n-2)/2; i >= 0; i--)
	{
		maxHeapify(arr,i,n);
	}
}

void print(int arr[], int n){
	for(int i = 0; i < n; i++) cout << " " << arr[i];
	cout << endl;
}


int main(){
	int n, arr[500001];
	cin >> n;

	for(int i = 0; i < n; i++) cin >> arr[i];

	buildMaxHeap(arr, n);
	print(arr, n);
	
	return 0;
}


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


int main(){
  int n,q,cnt=0;
  int mid=0;
  int left=0;
  cin >> n;
  int right=n;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  cin >> q;
  vector<int> t(q);
  for(int i=0;i<q;i++){
    cin >> t.at(i);
  }
  
  for(int i=0;i<q;i++){
    left = 0;
    right = n;
    while(left<right){
      mid = (left+right)/2;
      if(s[mid]==t[i]){
        cnt++;
        break;
      }
      else if(t[i]<s[mid])		//あくまでも添え字を変化させる
        right = mid;
      else
        left = mid+1;
    }
  }
   
  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <numeric>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) cout << "debug (" #a "):" << endl << (a) << endl;

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;

template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);

//uint64_t a, b, c, d;
//uint64_t i, j;
lint n, l;

int main(){
//////////////////////////////////////////////////////

    cin >> n >> l;

    lint sum = 0;
    rep(i,n)
    {
        sum += l+i;
    }

    if(l<0 && l+n>0)
    {
        cout << sum << endl;

    }
    else if(l<0)
    {
        cout << sum -( l + n - 1) << endl;
    }
    else if(l>=0)
    {
        cout << sum - l << endl;
    }
    
//cout << sum << endl;
   


// Ctrl + Opt + N to make
    return 0;
}


//最小化用関数
template<class T> inline bool chmin(T& a, T b)
{
    if (a > b) 
    {
        a = b;
        return true;
    }
    return false;
}

//最大化関数
template<class T> inline bool chmax(T& a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}


// vectorprint用
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}

// //合計
// template<class T> lint sum(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0);
// }


// //平均
// template<class T> double ave(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0.0) / a.size();
// }


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

#define equals(a,b) (fabs((a) - (b)) < EPS)

class Point {
public:
	double x, y;

	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator*(double a) { return Point(a * x, a * y); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double norm() { return x * x + y * y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point & p) const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator==(const Point & p) const {
		return fabs(x - p.x) < EPS and fabs(y - p.y) < EPS;
	}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
	return a.x* b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x* b.y - a.y * b.x;
}

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};

//直交判定
bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
	return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//平行判定
bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
	return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

//線分sに対する点pの射影
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base * r;
}

Point refrect(Segment s, Point p) {
	return p + (project(s, p) - p) * 2.0;
}
signed main() {
	//ios::sync_with_stdio(false);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int q;
	cin >> q;
	Segment seg = Segment(Point(x1, y1), Point(x2, y2));
	rep(i, q) {
		int x, y;
		cin >> x >> y;
		Point p = refrect(seg, Point(x, y));
		printf("%.9f %.9f\n", p.x, p.y);
	}
	return 0;
}




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

int main() {
	int n,m;
	int a[100][100],b[100];
	int c[100] = {0};
	cin >> n >> m;
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			cin >> a[i][j];
		}
	}
	for ( int i = 0; i < m; i++ ) cin >> b[i];
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < m; j++ ) {
			c[i] += a[i][j] * b[j];
		}
	}
	for ( int i = 0; i < n; i++ ) {
		cout << c[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
li = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-li.index(s))






Measured memory_bytes: 2940