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

int BS(int *,int,int);

int main(){
  int i,j,n,q,C=0;
  int *S,*T;
  scanf("%d",&n);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  T=(int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    C+=BS(S,n,T[i]);
  }
  printf("%d\n",C);
  return 0;
}

int BS(int *P,int n,int k){
  int r=n,l=0,t;
  while(l<r){
    t=(r+l)/2;
    if(k==P[t]){
      return 1;
    }
    if(k>P[t]){
      l=t+1;
    }
    else if(k<P[t]){
      r=t;
    }
  }
  return 0;
}



Measured memory_bytes: 2272
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;
use std::collections::VecDeque;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let h:usize = scan.next();
    let w:usize = scan.next();

    let mut a:Vec<Vec<char>> = (0..h).map(|_| scan.next::<String>().chars().collect()).collect::<Vec<Vec<char>>>();

    let mut queue = VecDeque::new();

    for y in 0..h {
        for x in 0..w {
            if a[y][x] == '#' {
                queue.push_back((x,y));
            }
        }
    }

    let mut white_count = h * w - queue.len();
    let mut count = 0;

    'outer: while queue.len() > 0 {
        let mut current = queue.drain(0..).collect::<VecDeque<_>>();

        if white_count == 0 {
            break 'outer;
        }

        while let Some((x,y)) = current.pop_front() {
            let x = x as i64;
            let y = y as i64;

            for &(dx,dy) in &[(-1,0),(1,0),(0,-1),(0,1)] {
                let x = x + dx;
                let y = y + dy;

                if x >= 0 && x < w as i64 && y >= 0 && y < h as i64 {
                    let x = x as usize;
                    let y = y as usize;

                    if a[y][x] == '.' {
                        white_count -= 1;
                        a[y][x] = '#';
                        queue.push_back((x,y));
                    }
                }
            }
        }
        
        count += 1;
    }

    println!("{}",count);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 40184
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e5+5;
int f[maxn];
int a[maxn];
void Input()
{
    int n,k;
    cin >> n >>k;
    FOR(i,1,n) cin >> a[i];
    f[0]=0;
    FOR(i,1,k)
        FOR(j,1,n) if (i>=a[j]&&f[i-a[j]]==0) f[i]=1;
    if (f[k]) cout << "First"; else cout << "Second";
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	
	vector<int> tmp = x;
	sort(tmp.begin(), tmp.end());
	for(int i = 0; i < n; i++)
	{
		if(x[i] <= tmp[(n / 2) - 1])
		{
			cout << tmp[n / 2]<< endl;
		}
		else
		{
			cout << tmp[(n / 2) - 1] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3712
def z_algorithm(s):
    n = len(s)
    z = [0] * n
    z[0] = n

    i = 1
    lcp = 0
    while i < n:
        while i+lcp < n and s[i+lcp] == s[lcp]:
            lcp += 1
        z[i] = lcp

        if lcp == 0:
            i += 1
            continue

        k = 1
        while i+k < n and k+z[k] < lcp:
            z[i+k] = z[k]
            k += 1
        i += k
        lcp -= k

    return z

from collections import deque
def topological_sort(graph: list, n_v: int) -> list:
    # graph[node] = [(cost, to)]
    indegree = [0] * n_v # 各頂点の入次数
    for i in range(n_v):
        for v in graph[i]:
            indegree[v] += 1

    cand = deque([i for i in range(n_v) if indegree[i] == 0])
    res = []
    while cand:
        v1 = cand.popleft()
        res.append(v1)
        for v2 in graph[v1]:
            indegree[v2] -= 1
            if indegree[v2] == 0:
                cand.append(v2)

    return res

import sys

def main():
    input = sys.stdin.readline
    s = input().rstrip()
    t = input().rstrip()

    n0 = len(s)
    m = len(t)

    s = s * (m // n0 + 2)


    z = z_algorithm(t + '*' + s)
    z = z[m+1:]
    # print(z)

    graph = [[] for _ in range(n0)]
    for i in range(n0):
        if z[i] >= m:
            graph[i].append( (i + m) % n0 )

    ts = topological_sort(graph, n0)
    if len(ts) != n0:
        ans = -1
    else:
        # print(ts)
        ans = 0
        path = [0] * n0
        for i in range(n0):
            ans = max(ans, path[ts[i]])
            for j in graph[ts[i]]:
                path[j] = path[ts[i]] + 1

    print(ans)

main()


Measured memory_bytes: 146720
/*
 Sarthak Jain
*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
  return (a<b)?a:b;
}
int max(int a,int b){
  return (a>b)?a:b;
}
int fp(int a,int b){
  if(b==0) return 1;
  int x=fp(a,b/2);
  x=(x*x)%mod;
  if(b&1) x=(x*a)%mod;
  return x;
}
const int N=2e5+5;
vector<vector<int>> v(N);
vector<int> ans(N);

int sum(int n)
{
  int x=(n*(n+1)/2)%mod;
  return x;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n,k;
 cin>>n>>k;
 n++;
 int ans=0;
 for(int i=k;i<=n;i++)
 {
 int x=sum(n)-sum(n-i)-sum(i)+1;
 ans=(ans+x+mod)%mod;
 //cout<<i<<" "<<x<<endl;
 }
 cout<<ans;

}

Measured memory_bytes: 9408
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int64_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

template <typename T>
ostream& operator << (ostream& out, const vector <T> &a) 
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

template <typename T>
ostream& operator << (ostream& out, const set <T> &a) 
{out << "{ "; for(const auto &i: a) out << i << ", "; return out << "}" << endl;}

template <typename T, typename G>
ostream& operator << (ostream& out, const map <T, G> &a) 
{out << "< "; for(const auto &i: a) out << i << ", "; return out << ">" << endl;}

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vector <pair <int,int> > a;
	for (int i = 0, u; i < n; ++i) {
		cin >>u;
		if (i == 0) {
			a.push_back({u, u});
		} else if (a.back().y > u) {
			a.push_back({u, u});
		} else {
			a.back().y = u;
		}
	}
	int val = 1000;
	for (int i = 0; i < a.size(); ++i) {
		int stocks = val / a[i].x;
		val %= a[i].x;
		val += stocks * a[i].y;
	}
	cout << val << '\n';
	return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#define no {puts("Impossible");return 0;}
using namespace std;
int n,m,a[1005];
inline int read(){
	int ret=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=getchar();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=getchar();
	return f?-ret:ret;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++){
		int x=read();
		if(x>m) m=x;
		a[x]++;
	}
	for (int i=m+3>>1;i<=m;i++) if(a[i]<2) no
	a[(m+1>>1)]-=(m&1)+1;
	for (int i=m+1>>1;i;i--) if(a[i]) no
	puts("Possible");return 0;
}

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

typedef long long ll; 

int main(){
	int n; cin>>n; 
	int N=n; 
	string s,t; cin>>s; 
	n--; 
	set<string> ss; 
	ss.insert(s); 
	while(n--){
		cin>>t; 
		ss.insert(t); 
		if(t[0]!=s.back()){
			cout<<"No"; 
			return 0; 
		}
		s=t; 
	}
	if(ss.size()==N)
	cout<<"Yes"; 
	else cout<<"No"; 

}

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

using namespace std;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        queue<int> q;
        int ans = -100000;
        int sump = 0, sumn = 0;
        while(N--) {
            int n;
            cin >> n;
            q.push(n);
            if(n >= 0) sump += n;
            else sumn += -n;
            while(q.size() > 1 && (sump <= sumn || q.front() < 0)) {
                int np = q.front();
                if(np >= 0) sump -= np;
                else sumn -= -np;
                q.pop();
            }
            ans = max(ans, sump-sumn);
        }
        cout << ans << endl;
    }
    return 0;
}

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



int main(){
    ll n;cin>>n;
    ll a[100010],pl=0;
    rep(i,0,n){
        cin>>a[i];
        if(a[i]>=0)pl++;
    }
    sort(a,a+n);
    ll mi=n-pl,an=0;
    an-=a[0];
    rep(i,1,n-1){
        if(a[i]<0)an-=a[i];
        else an+=a[i];
    }
    an+=a[n-1];
    cout<<an<<endl;
    if(mi*pl!=0){
    rep(i,0,pl-1){
        cout<<a[mi-1]<<" "<<a[n-1-i]<<endl;
        a[mi-1]-=a[n-i-1];
    }
    cout<<a[mi]<<" "<<a[mi-1]<<endl;
    a[mi]-=a[mi-1];
    a[mi-1]=a[mi];
    rep(i,0,mi-1){
        cout<<a[mi-1]<<" "<<a[mi-2-i]<<endl;
        a[mi-1]-=a[mi-2-i];
    }
    }
    else if(mi==0){
        rep(i,0,n-2){
            cout<<a[0]<<" "<<a[n-1-i]<<endl;
            a[0]-=a[n-1-i];
        }
        cout<<a[1]<<" "<<a[0];
    }
    else if(pl==0){
        rep(i,0,n-1){
            cout<<a[n-1]<<" "<<a[n-2-i]<<endl;
            a[n-1]-=a[n-2-i];
        }
    }
    
}







Measured memory_bytes: 2688
import java.io.IOException;
import java.util.Scanner;

//????????¢?????¢???????±???????????????°??????
public class Main{

	public static void main(String[] args) throws IOException{

		Scanner in = new Scanner(System.in);
		int x=in.nextInt();
		int y=in.nextInt();

		System.out.println(x*y +" "+ (2*x+2*y));//??¢???

		in.close();
	}

}

Measured memory_bytes: 25988
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
static const int MAX = 100005;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty()) {
        int u = S.top(); S.pop();
        for(int i=0; i<G[u].size(); i++) {
            int v = G[u][i];
            if(color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for(int i=0; i<n; i++) color [i] = NIL;
    for(int u=0; u<n; u++) {
        if(color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    
    cin >> n >> m;
    
    for(int i=0; i<m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    
    assignColor();
    
    cin >> q;
    
    for(int i=0; i<q; i++) {
        cin >> s >> t;
        if( color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 8900
N = 2019


def main():
    S = input()
    mod = [0] * N
    ans = 0
    for c in S:
        nxt = [0] * N
        x = int(c)
        for i in range(N):
            nxt[(i*10+x) % N] += mod[i]
        nxt[x] += 1
        ans += nxt[0]
        mod = nxt
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 76344
import java.lang.reflect.Array;
import java.util.*;
public class Main {




    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in) ;
        int A = Integer.parseInt(scan.next());
        int B = Integer.parseInt(scan.next());

        System.out.println(((A * B) % 2 == 0) ? "No":"Yes");
    }
}

Measured memory_bytes: 21716
H,W = list(map(int,input().split()))
N = int(input())
a = list(map(int,input().split()))

ans = []

current_a=a[0]
current_id = 1
for i in range(H):
    w_ans = []
    for j in range(W):
        if current_a == 0:
            current_a = a[current_id]
            current_id += 1
        
        current_a -= 1
        w_ans.append(str(current_id))
    if i%2==1:
        w_ans = w_ans[::-1]
    ans.append(w_ans)

for i in range(H):
    print(" ".join(ans[i]))


Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#define int long long
using namespace std;
int n, k, ai;
vector<int> data, rmq;
vector<vector<int> > sums;
map<int, int> mm;
void change(int i, int l, int r, int ind){
    if (r - l == 1){
        rmq[i] = 1;
    }
    else{
        int m = (l + r) / 2;
        if (ind < m) change(2*i+1, l, m, ind);
        else change(2*i+2, m, r, ind);
        rmq[i] = rmq[2*i+1] + rmq[2*i+2];
    }
}
int get(int i, int l, int r, int l1, int r1){
    if (l1 >= r1) return 0;
    if (l == l1 && r == r1){
        return rmq[i];
    }
    int m = (l + r) / 2;
    return get(2*i+1, l, m, l1, min(r1, m)) + get(2*i+2, m, r, max(l1, m), r1);
}
int bs(int number){
    int left = -1;
    int right = n;
    while (right - left > 1){
        int m = (left + right) / 2;
        if (sums[m][0] >= number) left = m;
        else right = m;
    }
    return left;
}
int32_t main(){
    cin >> n >> k;
    for (int i=0;i<n;i++){
        cin >> ai;
        data.push_back(ai - k);
    }
    int summ = 0;
    for (int i=0;i<n;i++){
        summ += data[i];
        vector<int> help;
        help.push_back(summ);
        help.push_back(i);
        sums.push_back(help);
    }
    sort(sums.begin(), sums.end(), greater<vector<int> > ());
    for (int i=0;i<n;i++){
        int si = sums[i][1];
        mm[si] = i;
    }
    for (int i=0;i<4*n;i++){
        rmq.push_back(0);
    }
    int now = 0;
    int ans = 0;
    for (int i=0;i<n;i++){
        int ind = bs(now) + 1;
        ans += ind - get(0, 0, n, 0, ind);
        ind = mm[i];
        now += data[i];
        change(0, 0, n, ind);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 40936
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



typedef long long ll;
#define INF 1LL<<60
int X, Y, Z, N;
ll A[101010], B[101010], C[101010];
ll AA[101010], BB[101010];
//---------------------------------------------------------------------------------------------------
ll dp1[101010];
void dodp1() {
    priority_queue<ll> que;
    rep(i, 0, N) dp1[i] = -INF;
    ll sm = 0;

    rep(i, 0, N) {
        que.push(-BB[i]);
        sm += BB[i];
        if (Y < que.size()) {
            ll q = -que.top();
            sm -= q;
            que.pop();
        }
        if (que.size() == Y) dp1[i] = sm;
    }
}
//---------------------------------------------------------------------------------------------------
ll dp2[101010];
void dodp2() {
    priority_queue<ll> que;
    rep(i, 0, N) dp2[i] = -INF;
    ll sm = 0;

    rrep(i, N - 1, 0) {
        que.push(-AA[i]);
        sm += AA[i];
        if (X < que.size()) {
            ll q = -que.top();
            sm -= q;
            que.pop();
        }
        if (que.size() == X) dp2[i] = sm;
    }
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> X >> Y >> Z;
    N = X + Y + Z;
    rep(i, 0, N) cin >> A[i] >> B[i] >> C[i];

    ll ans = 0;
    rep(i, 0, N) {
        ans += C[i];
        A[i] -= C[i];
        B[i] -= C[i];
    }

    vector<int> v;
    rep(i, 0, N) v.push_back(i);
    sort(v.begin(), v.end(), [&](int a, int b) { return A[a] - B[a] < A[b] - B[b]; });
    rep(i, 0, N) {
        int j = v[i];
        AA[i] = A[j];
        BB[i] = B[j];
    }

    dodp1(); dodp2();

    ll ma = -INF;
    rep(k, 0, N - 1) ma = max(ma, dp1[k] + dp2[k + 1]);

    ans += ma;
    printf("%lld\n", ans);
}

Measured memory_bytes: 7288
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,sumw,sume,numw,nume,mix=2e9;
char s[300005];
int main(void){
	register int i,len;
	scanf("%d%s",&n,s+1),len=strlen(s+1);
	for(i=1;i<=len;++i)
		if(s[i]=='W')++sumw;
		else ++sume;
	for(i=1;i<=len;++i){
		if(s[i]=='W')++numw;
		else ++nume;
		mix=min(numw-(s[i]=='W')+sume-nume,mix);
	}
	printf("%d\n",mix);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int M; 
  cin >> M;
 int O; 
  cin >> O;
 if (N+M+O >= 22) {
   cout << "bust" << endl;
 }
  else {
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main() {
  int n, cnt=0;
  char str[51];
  scanf("%d%s", &n, &str);
  for(int i=0;i<n;) {
    if(str[i]=='A' & str[i+1]=='B' & str[i+2]=='C') {
      cnt++;
      i+=2;
    }
    i++;
  }
  
  printf("%d", cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}


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

  int N; cin >> N;
  vector<int> h(N); cin >> h;

  vector<LLI> dp(N, 1e9);
  dp[0] = 0;

  REP(i,N){
    if(i+1<N) dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
    if(i+2<N) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
  }

  cout << dp[N-1] << endl;

  
  return 0;
}


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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

int n;
set<string> s;

void solve(){

    cin >> n;

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

        s.insert(tmp);
    }
    
    cout << s.size()<< endl;

}





int main(){

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

    solve();

}

Measured memory_bytes: 19092
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var t, a float64
	var h []float64
	var pnum int
	var pdiff float64
	fmt.Scan(&n, &t, &a)
	for i:=0; i<n; i++ {
		var ih float64
		fmt.Scan(&ih)
		h = append(h, ih)
	}

	for i:=0; i<n; i++ {
		x := h[i]
		temp := t - x * 0.006
		if i==0 || math.Abs(a - temp) < pdiff {
			pnum = i + 1
			pdiff = math.Abs(a - temp)
		}
	}

	fmt.Println(pnum)
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define N 8

struct Pos {
  int x, y;
};

class Queens {
private:
  vector<Pos> st;
  vector<int> index;
  bool row[N] = {};
  bool col[N] = {};
  bool slantr[2 * N - 1] = {};
  bool slantl[2 * N - 1] = {};

  void set_val(int x, int y, bool val) {
    row[x] = val;
    col[y] = val;
    slantr[x + y] = val;
    slantl[x - y + N - 1] = val;
  }
  bool solve_main(int idx) {
    int x = index[idx];
    if (st.size() == N)
      return true;
    for (int y = 0; y < N; y++) {
      if (check(x, y)) {
        set(x, y);
        if (solve_main(idx + 1))
          return true;
        pop();
      }
    }
    return false;
  }

public:
  Queens() {}
  void pop() {
    auto p = st.back();
    set_val(p.x, p.y, false);
    st.pop_back();
  }
  void set(int x, int y) {
    st.push_back(Pos{x, y});
    set_val(x, y, true);
  }
  bool check(int x, int y) {
    return !(row[x] || col[y] || slantr[x + y] || slantl[x - y + N - 1]);
  }
  void print() {
    bool data[N][N] = {};
    for (auto q : st)
      data[q.x][q.y] = true;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++)
        cout << (data[i][j] ? "Q" : ".");
      printf("\n");
    }
  }
  bool solve() {
    bool tmp[N] = {};
    for (auto q : st)
      tmp[q.x] = true;
    for (int i = 0; i < N; i++)
      if (!tmp[i])
        index.push_back(i);
    return solve_main(0);
  }
};

int main() {
  int n;
  cin >> n;
  auto queens = Queens();
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    queens.set(x, y);
  }

  queens.solve();
  queens.print();
}

Measured memory_bytes: 3136
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int a;
  rep1(i, 5){
    cin >> a;
    if(a == 0){
      cout << (i+1);
    }
  }

}

Measured memory_bytes: 3552
def main():
    s = list(input())
    t = []
    q = int(input())

    for _ in range(q):
        query = list(input().split())

        if query[0] == "1":
            s, t = t, s
        elif query[0] == "2":
            if query[1] == "1":
                t.append(query[2])
            elif query[1] == "2":
                s.append(query[2])

    print(*(t[::-1] + s), sep="")


if __name__ == "__main__":
    main()


Measured memory_bytes: 121032
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	mx := A[N-1]
	A = A[:N-1]
	key := mx / 2
	var ans int
	r, l := search(A, key)
	//fmt.Fprintln(wtr, A)
	//fmt.Fprintln(wtr, r, l)
	if l != -1 && r != len(A) {
		if abs(key-A[l]) < abs(key-A[r]) {
			ans = A[l]
		} else {
			ans = A[r]
		}
	} else if l == -1 {
		ans = A[r]
	} else {
		ans = A[l]
	}

	fmt.Fprintln(wtr, mx, ans)
}

func search(A []int, key int) (int, int) {
	l := -1
	r := len(A)
	for abs(r-l) > 1 {
		mid := (r + l) / 2
		if A[mid] >= key {
			r = mid
		} else {
			l = mid
		}
	}
	return r, l
}


Measured memory_bytes: 3072
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      hs: [i64; n],
    }

    const INF: i64 = 1 << 50;
    let mut dp = vec![INF; n];
    dp[0] = 0;
    for i in 0..n {
        for k in 1..k+1 {
            if i+k < n {
                dp[i+k] = min(dp[i+k], dp[i] + (hs[i+k] - hs[i]).abs());
            }
        }
    }
    puts!("{}\n", dp[n-1]);
}


Measured memory_bytes: 6396
import sys
input = sys.stdin.readline
from collections import *

N, A, B, C, D = map(int, input().split())
d = max(A, B)-min(A, B)

for i in range(N):
    if C*i-D*(N-1-i)<=d<=D*i-C*(N-1-i):
        print('YES')
        exit()

print('NO')

Measured memory_bytes: 38768
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      int n,m;cin >> n >> m;
      char arrn[n + 5][n + 5];
      char arrm[m + 5][m + 5];
      for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                  cin >> arrn[i][j];
            }
      }
      for(int i = 0;i < m;i++){
            for(int j = 0;j < m;j++){
                  cin >> arrm[i][j];
            }
      }
      for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                  if(arrn[i][j] == arrm[0][0]){
                        int c = 0;
                        for(int k = i;k < i + m;k++){
                              if(k < n){
                                    for(int l = j;l < j + m;l++){
                                          if(l < n){
                                                if(arrn[k][l] == arrm[k - i][l - j])c++;
                                          }
                                    }
                              }
                        }
                        if(c == m * m)return cout << "Yes", 0;
                  }
            }
      }
      cout << "No";
}

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

const int mx = 1024;
const int mod = 1e9 + 7;
char raw[mx][mx];
int dp[mx][mx];
int H, W;

bool IsWall(int xx, int yy) {
    return xx == -1 || xx == H \
        || yy == -1 || yy == W \
        || raw[xx][yy] == '#';
}

int ModAdd(int xx, int yy){
    if(xx + yy >= mod)
        return (xx + yy)%mod;
    return xx + yy;
}

int main() {
    scanf("%d%d", &H,&W);
    for(int i = 0 ;i < H ; ++i){
        scanf("%s", raw[i]);
    }

    dp[H-1][W-1] = 1;
    for(int i = H-1; i >= 0; --i) {
        for(int j = W -1 ; j >= 0; --j){
            if(!IsWall(i-1,j)){
                dp[i-1][j] = ModAdd(dp[i-1][j], dp[i][j]);
            }
            if(!IsWall(i, j-1)) {
                dp[i][j-1] = ModAdd(dp[i][j-1], dp[i][j]);
            }
        }
    }
    printf("%d\n",dp[0][0]);
    return 0;
}

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

int main() {
	char c1,c2,c3,c4;
	cin >> c1 >> c2 >> c3 >> c4;
	if (c1 == 'Y' && c2 == 'A') {
		if (c3 == 'K' && c4 == 'I') {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
	else {
		cout << "No\n";
	}
	return 0;

}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n-1);
    rep(i, n-1) {
        cin >> a[i];
        a[i]--;
    }
    vi cnt(n);
    rep(i, n-1) cnt[a[i]]++;
    rep(i, n) cout << cnt[i] << endl;
    return 0;
}


Measured memory_bytes: 4824
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
h = LIST()
ans = 0
tmp = 0
for i in range(n):
    for j in range(n):
        if tmp < h[i]:
            ans += h[i] - tmp
        tmp = h [i]
print(ans)


Measured memory_bytes: 10104
import bisect
import sys

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_accumulated = [0] * (n + 1)
b_accumulated = [0] * (m + 1)

for idx, a in enumerate(A):
    a_accumulated[idx + 1] = a_accumulated[idx] + a

for idx, b in enumerate(B):
    b_accumulated[idx + 1] = b_accumulated[idx] + b

a_limit = bisect.bisect(a_accumulated, k)
if a_limit == 0:
    position = bisect.bisect(b_accumulated, k)
    print(position - 1)
    sys.exit(0)

best_num = 0
for i in reversed(range(0, a_limit)):
    position = bisect.bisect_right(b_accumulated, k - a_accumulated[i])
    best_num = max(best_num, i + position - 1)
print(best_num)



Measured memory_bytes: 118412
#include <iostream>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for (size_t i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (size_t i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define INF 1e7

int main()
{
  int N, T, c, t, ans = INF;
  cin>>N>>T;

  REP(i,N) {
    cin>>c>>t;
    if (T >= t) {
      ans = min(ans, c);
    }
  }

  if (ans == INF) cout<<"TLE"<<endl;
  else cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  int a[n];
  int b[n];
  rep(i,n)cin >> a[i];
  rep(i,n)b[i]=a[i];
  sort(a,a+n);
  rep(i,n){
    if(b[i]==a[n-1])cout << a[n-2] << endl;
    else cout << a[n-1] << endl;
  }
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


inline pair<bool, string> calc(li pos, string s, string t) {
    rep(i, sz(t)) {
        if (s[pos + i] != t[i]) {
            if (s[pos + i] != '?') {
                return {false, ""};
            }
            s[pos + i] = t[i];
        }
    }
    rep(i, sz(s)) {
        if (s[i] == '?') {
            s[i] = 'a';
        }
    }
    return {true, s};
}

int main() {
    string s, t;
    cin >> s >> t;
    string res = "";
    if (sz(t) > sz(s)) {
        puts("UNRESTORABLE");
        return 0;
    }
    rep(i, sz(s) - sz(t) + 1) {
        auto r = calc(i, s, t);
        if (r.F) {
            if (res == "" || r.S < res) {
                res = r.S;
            }
        }
    }
    cout << (res == "" ? "UNRESTORABLE" : res) << endl;

    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int n, k;
vector<ll> vs;

vector<ll> memo;

ll dfs(int index, ll height, int color) {
	if (index == n) {
		if (color < k) return INF;
		return 0;
	}
	ll a = INF;
	if (height < vs[index]) {
		a = min(a, dfs(index + 1, vs[index], color + 1));
	}
	else {
		a = min(a, dfs(index + 1, height, color));		
		ll add = height + 1 - vs[index];
		a = min(a, dfs(index + 1, height+1, color+1) + add);
	}
	memo[index] = a;
	return a;
}

int main() {
	cin >> n >> k;
	vs.resize(n);
	memo.resize(n);
	rep(i, n) cin >> vs[i];
	ll lower = dfs(0, 0, 0);
	cout << lower << endl;
	return 0;
}


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


int main(){
	int n, m;
	cin >> n >> m;
    vector<int> counter(n, 0);
	rep(i,m){
	    int a, b;
	    cin >> a >> b;
	    a--;
	    b--;
	    counter[a]++;
	    counter[b]++;
	}
	for(int t : counter){
        cout << t << endl;
	}
}


Measured memory_bytes: 256
/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cout.sync_with_stdio(false);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, ans1, ans2;
	
	cin>>a>>b;
	
	int i=1;
	
	while(1)
	{
		if(floor(i*0.08)==a && floor(i*0.1)==b)
		{
			cout<<i<<endl;
			
			return 0;
		}
		
		if(i>100/0.08)
		{
			cout<<"-1"<<endl;
			
			return 0;
		}
		
		i++;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define txt                        \
    freopen("ip.txt", "r", stdin); \
    freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define quickie                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define div2(a) (!(a & 1))
#define deb(x) cout << (#x) << " " << (x) << "\n";
#define newl cout << "\n"
#define all(s) s.begin(), s.end()
#define pi 3.14159265358979323846
#define mod 1000000007
#define fp(x) fixed << setprecision(x) <<
template <class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template <class T>
int sumAllInts(T n)
{
    int a = 1;
    int su = 0;
    while (n)
    {
        su += n % 10;
        n /= 10;
    }
    return su;
}
template <class T>
void split(char c, T s)
{
    int n = s.size();
    int i = 0;
    while ((cout << s[i], i += 1) && (i < n) && (cout << c << ' '))
        ;
}
void solve()
{
    int n; cin>>n;
    map<int,int> mp;
    for (int i = 0; i < n; i++)
    {
        int temp; cin>>temp;
        mp[temp]++;
    }
    int freqE = 0;
    int freqO = 0;
    for(auto c: mp){
        if(c.second%2==0){
            freqE++;
        }else
        {
            freqO++;
        }
    }
    int ans = mp.size();
    if(freqE%2==0){
        cout<<ans;
    }else
    {
        cout<<ans - 1;
    }
    

}
int main()
{
    quickie;
    //txt;
    int t = 1;
    while (t--)
    {
        solve();
        newl;
    }
    return 0;
}

Measured memory_bytes: 8304
from decimal import Decimal
N, K = map(int, input().split())
A = list(map(int, input().split()))
#N,K=5 ,3
#A=[96, 98, 95, 100, 20]
ten=[0]*(N-K+1)
a=100000*(10**20)+0.1
#for i in range(K):
 #   a*=A[i]
#print(a)
#a=1
ten[0]=Decimal(a)
for i in range(1,(N-K+1)):
    ten[i]=Decimal(ten[i-1]*A[K+i-1]/A[i-1])
#print(ten)
for i in range(1,N-K+1):
    #print(ten[i])
    if ten[i]>ten[i-1]:
        print('Yes')
    else:
        print('No')

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> H(n);
    rep(i, n) cin >> H[i];

    vector<ll> dp(10101010, 10101010101010);
    dp[0] = 0;
    rep(i, n)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
        }
    }

    cout << dp[n - 1] << endl;
}
//配るDPのが楽


Measured memory_bytes: 82988
n, a, b = map(int,input().split())
M = 10**9+7
Answer = pow(2,n,M)-1
factorial=1
for i in range(1,a+1):
    factorial = (factorial*(n+1-i)*pow(i,M-2,M))%M
Answer -= factorial%M
factorial =1
for j in range(1,b+1):
    factorial = (factorial*(n+1-j)*pow(j,M-2,M))%M
Answer -= factorial%M
Answer = Answer%M
print(Answer)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <sstream>
using namespace std;

int ar[11], ag[11], ab[11];
bool checked[59049];
int p3[11];
map<int,int> change = {
    {0,0}, {1,8}, {2,4}, {3,8}, {4,4}, {5,0}, {6,4}, {7,0}, {8,8}
};

int conv(string s) {
    int ret = 0;
    for (int i=0; i<(int)s.size(); ++i) {
        ret *= 3;
        if (s[i] == 'g') ret += 1;
        if (s[i] == 'b') ret += 2;
    }
    return ret;
}

int rotate(int x, int n) {
    int ret = 0;
    for (int i=0; i<n; ++i) {
        ret = ret * 3 + (x % 3 + 1) % 3;
        x /= 3;
    }
    return ret;
}

int main() {
    p3[0] = 1;
    for (int i=1; i<=10; ++i) {
        p3[i] = p3[i-1] * 3;
    }
    ar[0] = ag[0] = ab[0] = 0;
    for (int i=1; i<=10; ++i) {
        ar[i] = ar[i-1];
        ag[i] = ag[i-1] * 3 + 1;
        ab[i] = ab[i-1] * 3 + 2;
    }
    string s;
    while (cin >> s, s != "0") {
        memset(checked, false, sizeof checked);
        int n = s.size();
        int first = conv(s);
        queue<pair<int,int> > q;
        q.push(make_pair(first, 0));
        checked[first] = true;
        int res = -1;
        while ( ! q.empty()) {
            int col = q.front().first;
            int t = q.front().second;
            q.pop();
            if (col == ar[n] || col == ag[n] || col == ab[n]) {
                res = t;
                break;
            }
            for (int i=0; i<n-1; ++i) {
                int replace = change[(col / p3[i]) % 9];
                int nx = (col / p3[i+2]) * p3[i+2] + replace * p3[i] + (col % p3[i]);
                if ( ! checked[nx]) {
                    q.push(make_pair(nx, t+1));
                    checked[nx] = true; nx = rotate(nx, n);
                    checked[nx] = true; nx = rotate(nx, n);
                    checked[nx] = true;
                }
            }
        }
        if (res < 0) {
            cout << "NA" << endl;
        } else {
            cout << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1304
/*..........mango is luv..........*/
#include<bits/stdc++.h>
using namespace std;
#define fk(i,start,end) for(ll i=start;i<ll(end);i++)
typedef long long int ll;
string A="YES";
string B="NO";
ll m=1000000007;
int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 
     ll n,sum=0;
     cin>>n;
     vector<ll>a(n)  ;
     fk(i,0,n)
     {
        cin>>a[i];
        sum+=a[i];
        sum=sum%m;
     }
     ll s=0;
     fk(i,0,n)
     {
     	sum-=a[i];
     	if(sum<0)
     	{
     		sum+=m;
     	}
     	s+=sum*a[i];
     	s=s%m;
     }
     cout<<s<<endl;
  return 0;

}

Measured memory_bytes: 4756
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;


ll A, B;

ll ans = 0;

queue<ll> que;


vector<pair<ll, ll>> prime_factorize(ll n)
{
	vector<pair<ll, ll>> res;
	for (ll p = 2; p * p <= n; p++)
	{
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

//最大公約数を求める
ll GCD(ll x, ll y)
{
	return y ? GCD(y, x % y) : x;
}


int main()
{
	cin >> A >> B;
	ll G = GCD(A, B);
	auto pf = prime_factorize(G);
	cout << pf.size() + 1 << endl;
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());
  int alice = 0, 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