akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;

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

vector<int> a(5);
int k;
bool solve(void){
  for(int i = 0; i < 5; ++i){
    for(int j = i; j < 5; ++j){
      if(abs(a[i] - a[j]) > k)  return false;
    }
  }

  return true;

}

int main(){
  rep(i, 5){
    cin >> a[i];
  }

  cin >> k;

  bool ans;
  ans = solve();

  if(ans){
    cout << "Yay!" << endl;
  } else {
    cout << ":(" <<endl;
  }


}


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

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

    string t;   cin >> t;

    deque<char> deck;

    for(auto &c : t) {
        deck.push_back(c);
    }

    int q;  cin >> q;

    bool rev = false;

    auto addFront = [&](char c) {
        if(rev) {
            deck.push_back(c);
            return;
        }

        deck.push_front(c);
        //s = c + s;
    };

    auto addBack = [&](char c) {
        if(rev) {
            //s = c + s;
            deck.push_front(c);
            return;
        }

        deck.push_back(c);
    };

    while(q--) {
        int t;  cin >> t;
        if(t == 1) {
            rev = rev ^ 1;
        } else {
            int f;  char c; cin >> f >> c;

            if(f == 1) {
                addFront(c);
            } else {
                addBack(c);
            }
        }
    }

    if(rev) {
        reverse(deck.begin(), deck.end());
    }

    for(auto &c : deck) {
        cout << c;
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int dp[3240][3240];
Int n;
string str;
int main(){
  cin >> n;
  cin >> str;
  dp[0][0] = 1;
  for(int i = 0;i < n-1;i++){
    Int sum = 0;
    if(str[i] == '<'){
      for(int j = 0;j <= i+1;j++){
	dp[i+1][j] = sum;
	sum += dp[i][j];
	sum %= MOD;
      }
    }
    else{
      for(int j = i+1;j >= 0;j--){
	dp[i+1][j] = sum;
	if(j)sum += dp[i][j-1];
	sum %= MOD;
      }
    }
  }
  Int res = 0;
  for(int i = 0;i < n;i++){
    res += dp[n-1][i];res %= MOD;
  }
      cout << res << endl;
  return 0;
}

Measured memory_bytes: 76416
a = int(input())

for i in range(1,1000001):
    #print(a)
    if a == 4 or a == 2 or a == 1:
        print(str(i+3))
        exit()
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] a = sc.next().toCharArray();
		int cnt = 0;
		for(char b:a) {
			if(b == '1') cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 20948
//A-Colorful_Slimes_2
#include <bits/stdc++.h>
using namespace std;


int main(){
  int a,b,c,sum,N,purasu=0;
  cin>>N;

  a=0;
  b=10001;
  sum=0;

  for(int i=0;i<N;i++){
    cin>>c;
    /* cout<<a<<" "<<b<<" "<<c<<endl;*/
       
     if(c==b){
       
        if(a==c){
	  
	  if(purasu==1){
	    sum++;
	    purasu-=2;
	  }
	  purasu++;
	  a=b;
	  b=c;
            continue;
        }
      sum++;
     }
     a=b;
     b=c;
     purasu=0;
  }
  cout<<sum<<endl;
  
  return 0;
}

	


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int len = s.length;
        HashMap<Character, Character> sl = new HashMap<>();
        HashMap<Character, Character> tl = new HashMap<>();
        boolean check = true;
        for(int i = 0; i < len; i++){
            if(sl.containsKey(s[i]) && sl.get(s[i]) != t[i] || tl.containsKey(t[i]) && tl.get(t[i]) != s[i]){
                check = false;
                break;
            }
            sl.put(s[i],t[i]);
            tl.put(t[i],s[i]);
        }
        System.out.println(check ? "Yes" : "No");
    }
}


Measured memory_bytes: 28892
K, X = map(int, input().split())

start = -1000000
end = 1000000
if (X - K + 1 > start):
    start = X - K + 1 

if (X + K - 1 < end):
    end = X + K - 1

for i in range(start, end + 1):
    print(i, end=' ')


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

int f3(int N,int K){//
	if( N < K ){
		return 0;
	}
	if( N%K == 0 ){
		return N/K;
	}
	int D = N/K+1;
	if( (N%K)+1 > D ){
		N = (N/K)*K + ((N%K))%D;
		return f3(N,K);
	}

	return f3(N -( N/K + 1 ) ,K);
}

void solve(){
	int N;
	cin >> N;
	vector<int> A(N),K(N);
	vector<int> gra(N);
	for(int i=0;i<N;++i){
		cin >> A[i] >> K[i];
		gra[i] = f3(A[i],K[i]);
	}
	int res = 0;
	for(int i=0;i<N;++i){
		res = res^gra[i];
	}
	
	if( res == 0 ){
		cout << "Aoki" << endl;
	}else{
		cout << "Takahashi" << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

std::vector<int> a[6], A;
int n, k;

std::vector<int> operator * (const std::vector<int> &a, const std::vector<int> &b) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[i] = a[b[i]];
	return res;
}

std::vector<int> inv(const std::vector<int> &a) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[a[i]] = i;
	return res;
}

std::vector<int> ksm(std::vector<int> x, int y) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[i] = i;
	for (; y; y >>= 1, x = x * x) if (y & 1) res = res * x;
	return res;
}

int main() {
	// freopen("a.in", "r", stdin);
	n = read(), k = read() - 1; a[1].resize(n); a[0].resize(n);
	for (int i = 0; i < n; ++ i) a[0][i] = read() - 1;
	for (int i = 0; i < n; ++ i) a[1][i] = read() - 1;
	for (int i = 2; i < 6; ++ i) a[i] = a[i - 1] * inv(a[i - 2]);
	if (k < 6) { for (int i = 0; i < n; ++ i) printf("%d ", a[k][i] + 1); puts(""); return 0; }
	A = ksm((a[1] * inv(a[0])) * (inv(a[1]) * a[0]), k / 6);
	A = A * a[k % 6] * inv(A);;
	for (int i = 0; i < n; ++ i) printf("%d ", A[i] + 1); puts("");
	return 0;
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
int n,a[20000010];
bool s(int i,int j,int k)
{
    return a[i]<=k&&a[j]<=k;
}
bool b(int i,int j,int k)
{
    return a[i]>k&&a[j]>k;
}
bool check(int k)
{
    for(int i=0;i<n-1;i++)
	{
        if(b(n+i,n+i+1,k)||b(n-i,n-i-1,k))
			return 0;
        if(s(n+i,n+i+1,k)||s(n-i,n-i-1,k))
			return 1;
    }
    return s(1,1,k);
}
int main()
{
    scanf("%d",&n);
    int nn=2*n-1,l=1,r=nn;
    for(int i=1;i<=nn;i++)
        scanf("%d",&a[i]);
    while(l<r)
	{
        int mid=l+(r-l)/2;
        if(check(mid))
            r=mid;
        else
			l=mid+1;
    }
    printf("%d\n",r);
    return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

bool gone[10005];
ll now = 0;
vector<ll> v[10005];
vector<ll> c(10005);
vector<ll> ans(10005);
void dfs(ll pos){
    ans[pos] = c[now];
    now++;
    gone[pos] = true;
    rep(i,v[pos].size()){
        ll to = v[pos][i];
        if(gone[to])continue;
        dfs(to);
    }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  rep(i,n-1){
      ll a,b; cin >> a >> b;
      a--; b--;
      v[a].push_back(b);
      v[b].push_back(a);
  }
  ll M = 0;
  rep(i,n){
      cin >> c[i];
      M += c[i];
  }
  sort(c.begin(),c.begin()+n);
  reverse(c.begin(),c.begin()+n);
  M -= c[0];
  rep(i,n){
      gone[i] = false;
  }
  dfs(0);
  cout << M << endl;
  rep(i,n){
      cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt();
        int b = fs.nextInt();
        int min = Math.min(a,b);
        int max = Math.max(a,b);
        System.out.println(String.valueOf(min).repeat(Math.max(0, max)));
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 32432
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
line = []
for _ in range(M):
    a, b = map(int, input().split())
    line.append([a-1, b-1])
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


ans = 0
for l in line:
    a, b = l
    qs = [a]
    checked = [False for _ in range(N)]
    checked[b] = True
    ok = False
    #print(a, b)
    first = True
    while qs:
        #print(qs)
        qqs = []
        for q in qs:
            checked[q] = True
            for k in graph[q]:
                #print(k)
                if k == b and first:
                    first = False
                elif k == b:
                    ok = True
                    break
                if not checked[k]:
                    qqs.append(k)
        qs = qqs
    if not ok:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#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];
	}
	int x=*max_element(a,a+n);
	int y=*min_element(a,a+n);
	cout<<x-y;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

tmp = a[:]
max1_val = max(tmp)
max1_idx = tmp.index(max1_val)
del tmp[max1_idx]
max2_val = max(tmp)

for i in range(n):
    if i != max1_idx:
        print(max1_val)
    else:
        print(max2_val)

Measured memory_bytes: 14068
import numpy as np
 
def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort()
    return a
 
N,M = map(int,input().split())
 
f = factorization(M)
f = np.array(f)
print(np.max(f[f<=M/N]))

Measured memory_bytes: 22136
N , M = gets.split.map{|i| i.to_i}
input = Array.new(N).map{Array.new(2)}

N.times do |i|
    input[i] = gets.split.map{|i| i.to_i}
end

input.sort!{|a , b| a[0] <=>b[0]}

i = 0
k = 0
min = 0
while k != M
    if input[i][1] == 0
        i += 1
    end

    k += 1
    min += input[i][0]
    input[i][1] -= 1
end

puts min

Measured memory_bytes: 16752
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 1000000;

struct node
{
	int num;
	int place;  
};

int partition(node *A,int p,int r)
{
	int j,temp;
	node x;

	x = A[r];
	j = p-1;

	for(int i = p; i < r; i++)
	{
		if (A[i].num <= x.num)
		{
			j++;
			temp = A[i].num;
			A[i].num = A[j].num;
			A[j].num = temp;
		}
	}

	temp = A[j+1].num;
	A[j+1].num = A[r].num;
	A[r].num = temp;

	return j+1;
}

void quicksort(node *A,int p,int r)
{
	int q;

	if (p < r)
	{
		q = partition(A,p,r);
		quicksort(A,p,q-1);
		quicksort(A,q+1,r);
	}
}


int main()
{
	int n,sum,minall,mini,sol,cnt,j;
	node a[1000] = {0},b[1000] = {0};

	sol = 0;
	minall = INF;

	scanf("%d", &n);

	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i].num);
		a[i].place = i;
		b[i] = a[i];
		b[i].place = i;
	}

	quicksort(b,0,n-1);

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

		if (a[i].num >= 0)
		{
			sum += a[i].num;
			mini = a[i].num;
			cnt = 1;
			j = i;

			while(b[a[j].place].num != a[i].num)
			{
				for(int k = 0; k < n; k++)
				{
					if (a[k].num == b[a[j].place].num)
					{
						j = k;
						sum += a[k].num;
						cnt++;

						if (mini > a[k].num)
						{
							mini = a[k].num;
						}

						a[k].num = -1;
						break;
					}
				}
			}

			a[i].num = -1;

			sol += min(sum + mini * (cnt -2), sum + mini + (cnt + 1) * b[0].num);
		}
	}

	printf("%d\n", sol);


	return 0;
}
	

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

int main()
{
  string n;
  cin >> n;
  int sn = 0;
  for (int i = 0; i < n.size(); ++i) sn += n[i] - '0';
  cout << (stoi (n) % sn == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner=new Scanner(System.in);
        Double x1=scanner.nextDouble();
        Double y1=scanner.nextDouble();
        Double x2=scanner.nextDouble();
        Double y2=scanner.nextDouble();
        System.out.println(Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2)));
    }

}



Measured memory_bytes: 27992
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()

    val res = mutableMapOf<Pair<Char, Char>, Int>()
    for (i in 1..n) {
        val x = i.toString()
        val first = x.first()
        val last = x.last()
        if (last == '0') continue
        val key = first to last

        if (res.containsKey(key)) res.put(key, res.get(key)!! + 1)
        else res.put(key, 1)
    }

    var ans = 0
    for (key in res.keys) {
        val other = key.second to key.first
        if (!res.containsKey(other)) continue

        ans += res[key]!! * res[other]!!
    }
    println(ans)

}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 38736
#include <iostream>
#include <cstdio>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int a[maxn];
int cnt[maxn];
typedef long long ll;

void quickpow(int b)
{
    ll res = 1,k = 2;
    while(b)
    {
        if(b & 1) res = (res % mod * k % mod ) % mod;
        b >>= 1;
        k = k * k % mod;
    }
    cout << res << endl;
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++) {
        scanf("%d",&a[i]);
        cnt[a[i]] ++;
    }
    bool fg = true;
    if (n % 2) {
        if(cnt[0] != 1) fg = false;
    }
    for (int i = n % 2 + 1; i < n; i += 2) {
        if(cnt[i] != 2) {fg = false;break;}
    }
   if(fg)
   {
       if(n % 2) quickpow((n - 1) / 2);
       else quickpow(n / 2);
   }
   else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(998244353)
#define INF (2e9)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	string a,b; cin>>a>>b;
	int ans=0;
	For(i,0,sz(a)-1) if(a[i]!=b[i]) ans++;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3784
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int n, x;
  cin >> n >> x;
  std::vector<int> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  int result = 1;
  int pos    = 0;
  for (int i = 0; i < n; i++) {
    pos += l[i];
    if (pos <= x) {
      result++;
    } else {
      break;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <locale>
#include <string>
#include <algorithm>
#include <sstream> 
#include <vector>

using namespace std;

int main() {
	string text,pattern;
	vector<string> words;
   	string word;

	getline(cin,pattern);
	int counter=0;
	while(getline(cin,text)){
		if (text == "END_OF_TEXT") break;
    	transform(text.begin(), text.end(), text.begin(), ::tolower);
    	replace(text.begin(), text.end(), '.', ' ');
    	replace(text.begin(), text.end(), ',', ' ');
    	replace(text.begin(), text.end(), '"', ' ');
    	
    	istringstream iss(text);
    	while( getline(iss, word, ' ') ){
        	words.push_back(word);
    	}
    }
   	counter = count(words.begin(), words.end(), pattern);
	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 3180
N = int(input())
h = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(h[1] - h[0])
for i in range(1,N-1):
    dp[i+1] = min(dp[i-1]+abs(h[i+1]-h[i-1]),dp[i]+abs(h[i+1]-h[i]))

print(dp[N-1])

Measured memory_bytes: 13980
#include<stdio.h>
     
int print_leap_year(int x);
         
int main(void)
{
    int start_year, end_year, counter, dataset_number;
    dataset_number =0;
    while(1){
        scanf("%d %d", &start_year, &end_year);
        if(start_year == 0 && end_year == 0){
            break;
        }else{
            if(dataset_number != 0){
            printf("\n");
            }
            counter = 0;
            for(int i = start_year; i <= end_year; i++){
                counter += print_leap_year(i); 
            }
            if( counter == 0){
                printf("NA\n");
            } 
        }
    ++dataset_number; 
    }
    return 0;
}
     
     
int print_leap_year(int x)
{
    if((x % 4 == 0 && !(x % 100 == 0)) || x % 400 == 0){
        printf("%d\n", x);
        return 1;
    }
    return 0;
} 

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int n,a;
    scanf("%d%d",&n,&a);
    if(a>=n){
        printf("unsafe");
    }else{
        printf("safe");
    }
}

Measured memory_bytes: 3824
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	var res int
	for i := 0; i < 2; i++ {
		if a > b {
			res += a
			a--
		} else {
			res += b
			b--
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    sort(ALL(s));
    cout << (s == "abc" ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
//SPFA
#include <cstdio>
#include <cstring>
#include<queue>
#include<algorithm>
using namespace std;
#define INF (10*900*4)
#define rep(i,n) for(i=0;i<(n);i++)
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

struct Node{
	int y,x,dir;
};

void _a(Node *a){a->y+=dy[a->dir];a->x+=dx[a->dir];}
void _b(Node *a){a->dir=(a->dir+1)%4;_a(a);}
void _c(Node *a){a->dir=(a->dir+2)%4;_a(a);}
void _d(Node *a){a->dir=(a->dir-1+4)%4;_a(a);}
void _e(Node *a){}
void (*action[5])(struct Node *)={_a,_b,_c,_d,_e};

bool in(int y,int x,int h,int w){
	return 0<=y&&y<h&&0<=x&&x<w;
}

int main(){
	queue<Node> que;
	bool inQ[30][30][4];
	int dst[30][30][4];
	Node a,b;
	
	int w,h,s[30][30],c[4];
	int i,j,k,ans;
	while(scanf("%d%d",&w,&h)==2&&(w||h)){
		rep(i,h)
			rep(j,w)scanf("%d",&s[i][j]);
		rep(i,4)scanf("%d",c+i);
		memset(inQ,false,sizeof(inQ));
		rep(i,h)rep(j,w)rep(k,4)dst[i][j][k]=INF;
		a.y=a.x=a.dir=0;
		while(!que.empty())que.pop();
		dst[a.y][a.x][a.dir]=0;
		que.push(a);
		while(!que.empty()){
			a=que.front();
			que.pop();
			inQ[a.y][a.x][a.dir]=false;
			b=a;
			action[s[b.y][b.x]](&b);
			if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir] < dst[b.y][b.x][b.dir]){
				dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir];
				if(!inQ[b.y][b.x][b.dir]){
					que.push(b);
					inQ[b.y][b.x][b.dir]=true;
				}
			}
			rep(i,4){
				b=a;
				action[i](&b);
				if(in(b.y,b.x,h,w) && dst[a.y][a.x][a.dir]+c[i] < dst[b.y][b.x][b.dir]){
					dst[b.y][b.x][b.dir] = dst[a.y][a.x][a.dir]+c[i];
					if(!inQ[b.y][b.x][b.dir]){
						que.push(b);
						inQ[b.y][b.x][b.dir]=true;
					}
				}
			}
		}
		printf("%d\n",*min_element(dst[h-1][w-1],dst[h-1][w-1]+4));
	}
}

Measured memory_bytes: 856
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

int dist(int ax,int ay,int bx,int by){
    return abs(ax-bx)+abs(ay-by);
}
vector<vector<int>> aki;
vector<vector<int>> d;

int dx[] ={0,1,0,-1};
int dy[] ={1,0,-1,0};
int n;
void propagate(int x,int y){
    if(aki[x][y]){
        for(int i=0;i<4;i++){
            int tox = x+dx[i];
            int toy = y+dy[i];
            if(0<=tox && tox<n && 0<=toy && toy<n){
                if(d[tox][toy]>d[x][y]){
                    d[tox][toy] = d[x][y];
                    propagate(tox,toy);
                }
            }
        }
    }
    else{
        for(int i=0;i<4;i++){
            int tox = x+dx[i];
            int toy = y+dy[i];
            if(0<=tox && tox<n && 0<=toy && toy<n){
                if(d[tox][toy]>d[x][y]+1){
                    d[tox][toy] = d[x][y]+1;
                    propagate(tox,toy);
                }
            }
        }
    }
}
int main(){
    cin>>n;
    vector<int> p(n*n);
    for(int i=0;i<n*n;i++) cin>>p[i],p[i]--;

    vector<int> x(n*n),y(n*n);
    aki.resize(n,vector<int>(n));
    d.resize(n,vector<int>(n));
    for(int i=0;i<n*n;i++){
        x[i] = p[i]/n;
        y[i] = p[i]%n;
        int xd = min(x[i],n-1-x[i]);
        int yd = min(y[i],n-1-y[i]);
        d[x[i]][y[i]]=min(xd,yd);
    }

    vector<int> res(n*n);
    
    for(int i=0;i<n*n;i++){
        res[i] = d[x[i]][y[i]];
        aki[x[i]][y[i]]=true;
        propagate(x[i],y[i]);
        // cerr<<"#"<<i<<endl;
        // for(int i=0;i<n;i++){
        //     for(int j=0;j<n;j++){
        //         cerr<<d[i][j];
        //     }
        //     cerr<<endl;
        // }
    }

    cout<<accumulate(res.begin(),res.end(),0)<<endl;
    
    return 0;
}


Measured memory_bytes: 24616
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
int main(){
    int a,b,a1,a3,a2;
    cin>>a>>b;
    a1=a+b;
    a2=a-b;
    a3=a*b;
    cout<<max(a1,max(a2,a3))<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    final double EPS = 1.0e-5;

    void run() {
        Scanner sc = new Scanner(System.in);
        String[] hands = new String[15];
        hands[0] = "Rock";
        hands[1] = "Fire";
        hands[2] = "Scissors";
        hands[3] = "Snake";
        hands[4] = "Human";
        hands[5] = "Tree";
        hands[6] = "Wolf";
        hands[7] = "Sponge";
        hands[8] = "Paper";
        hands[9] = "Air";
        hands[10] = "Water";
        hands[11] = "Dragon";
        hands[12] = "Devil";
        hands[13] = "Lightning";
        hands[14] = "Gun";
        Map<String, Set<String>> win = new HashMap<String, Set<String>>();
        Map<String, Set<String>> lose = new HashMap<String, Set<String>>();
        for (int i = 0; i < 15; i++) {
            Set<String> w = new HashSet<String>();
            Set<String> l = new HashSet<String>();
            for (int j = 1; j < 15; j++) {
                if (j < 8)
                    w.add(hands[(i + j) % 15]);
                else
                    l.add(hands[(i + j) % 15]);
            }
            win.put(hands[i], w);
            lose.put(hands[i], l);
        }
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            String[] hs = new String[n];
            for (int i = 0; i < n; i++) {
                hs[i] = sc.next();
            }
            String ans = "";
            for (int i = 0; i < n; i++) {
                boolean w_flag = false;
                boolean l_flag = false;
                for (int j = 0; j < n; j++) {
                    if (i == j)
                        continue;
                    if (win.get(hs[i]).contains(hs[j])) {
                        w_flag = true;
                    } else if (lose.get(hs[i]).contains(hs[j])) {
                        l_flag = true;
                    }
                }
                if (w_flag && !l_flag) {
                    ans = hs[i];
                    break;
                }
            }
            System.out.println(ans == "" ? "Draw" : ans);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 13000
#include "bits/stdc++.h"
using namespace std;
char a[50][51];
char b[50][51];

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) cin>>a[i][j];
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++) cin>>b[i][j];
	}

	bool exist = false;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i+m-1>=n || j+m-1>=n) continue;

			bool match = true;
			for(int y=0;y<m;y++){
				for(int x=0;x<m;x++){
					if(a[i+y][j+x] != b[y][x]) match = false;
				}
			}
			if(match) exist = true;
		}
	}

	if(exist) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

C = Counter(A)
C = sorted(C.items())

cc = []
for a, b in C:
    cc.append([a, b])
C = cc

M = len(C)

left = 0
right = M - 1

while True:
    if C[left][1] < 2:
        p_left = left
        for left in range(p_left, M):
            if C[left][1] > 1:
                break

    if C[right][1] < 2:
        p_right = M - right - 1
        for right in range(M):
            if C[M - right - 1][1] > 1:
                break

        right = M - right - 1

    if C[left][1] <= 1 and C[right][1] <= 1:
        break

    if left == right:
        if C[left][1] >= 3:
            C[left][1] -= 2
        else:
            f = 0
            C[left][1] -= 1
            for i in range(left + 1, M):
                if C[i][1] > 0:
                    C[i][1] -= 1
                    f = 1
                    break

            if f == 0:
                for i in range(0, left):
                    if C[i][1] > 0:
                        C[i][1] -= 1

    else:
        C[left][1] -= 1
        C[right][1] -= 1


ans = 0
for a, b in C:
    ans += b

print(ans)


Measured memory_bytes: 103108
package main

import "fmt"

func maxint(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m)
	var points [][]int

	dp := make([]int, n+1)
	for i := 0; i <= n; i++ {
		points = append(points, make([]int, 0))
	}
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y)
		points[x] = append(points[x], y)
	}
	max := 0
	for i := 1; i <= n; i++ {
		max = maxint(max, steps(i, dp, points))
	}
	fmt.Println(max)
}

func steps(start int, dp []int, p [][]int) int {
	if dp[start] > 0 {
		return dp[start]
	}
	result := 0
	for i := 0; i < len(p[start]); i++ {
		result = maxint(result, steps(p[start][i], dp, p)+1)
	}
	dp[start] = result
	return result
}


Measured memory_bytes: 24576
x,n = map(int,input().split())
if n == 0:print(x);exit(0)
*p, = sorted(map(int,input().split()))
pp = set(p)
ans = 9e9
for i in range(0,102):
    if i in pp: continue
    if abs(i-x) < ans:
        xx = i
        ans = abs(i-x)
    else:
        break
print(xx)


Measured memory_bytes: 62048
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e9;
const ll MOD = 1e9;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vector(vector<int> & a) {
	forn(i, (int)a.size()) {
		cout << a[i] << " ";
	}
	cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
	ll h;
	forn(i, n) {
		cin >> h;
		a.pb(h);
	}
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
//#define DEBUG
int main(){
	FastIO;
	#ifdef DEBUG
		freopen("input.txt", "r", stdin);
	#endif // DEBUG
	int n;
	cin >> n;
	vector<int> gg(n);
	forn(i, n){
		cin >> gg[i];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i){
		sum = gg[i] - sum;
	}
	int a = sum;
	for (int i = 0; i < n; ++i){
		cout << a << " ";
		a = 2 * gg[i] - a;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[12];
bool b[12];
string s;
ll ans;
void cal(){
	ll sum=0;
	for(int i=0;i<s.size();i++){
		ll now=a[i];
		if(b[i]){
			sum*=10;
			sum+=a[i];
		}
		else{
			ans+=sum;
			sum=0;
		}
	}
	ans+=sum;
}
void dep(ll now){
	if(now==s.size()){
		cal();
		return ;
	}
	b[now]=true;dep(now+1);
	b[now]=false;dep(now+1);
}
int main() {
	cin>>s;
	for(int i=0;i<12;i++){
		a[i]=-1;
	}
	for(int i=0;i<s.size();i++){
		ll now=s[i]-'0';
		a[i]=now;
	}
	dep(0);
	cout << ans;
	// your code goes here
	return 0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;



int main() {
  int a,b;
  cin>>a>>b;
  cout << max(0,a-b) << endl;
  
}

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

#define sum vec[i] + vec[j]

int main() {
	int n, m, near; vector<int> vec;
	while (1) {
		cin >> n >> m; if (n == 0 && m == 0) break;
		near = 0; vec.resize(n);
		for (int i = 0; i < n; i++) cin >> vec[i];
		sort(vec.begin(), vec.end(), greater<int>());
		for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
			if (i == j) continue;
			if (sum <= m && sum >= near) near = sum;
			if (near == m) break;
		}
		if (near == 0) cout << "NONE" << endl;
		else cout << near << endl;
		for (int i = 0; i < n; i++) vec.pop_back();
	}
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 1;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

vector<pll> primeFactorization(ll n) {
	vector<pll> res;
	
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0) res.push_back(pll(i, 0));
		while (n % i == 0) {
			n /= i;
			res[res.size() - 1].second++;
		}
	}
	if (n > 1) res.push_back(pll(n, 1));
	
	return res;
}

int main() {
	int N, M;
	cin >> N >> M;
	
	fact_inv(112345, MOD);
	
	vector<pll> dat = primeFactorization(M);
	int datc = 0;
	REP(i, dat.size()) datc += dat[i].se;
	
	ll ans = 1;
	REP(i, dat.size()) {
		ll cur = fact[dat[i].se + N - 1];
		cur *= inv[dat[i].se] * inv[N - 1] % MOD;
		cur %= MOD;
		
		ans = ans * cur % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<array>

using namespace std;
using ll=long long;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int n;
  cin>>n;
  array<ll,86> s={};
  s[0]=2;
  s[1]=1;
  rep(i,2,n+1){
      s[i]=s[i-2]+s[i-1];
  }
  cout<<s[n]<<endl;
}

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

int main(){
  int X;
  cin >>X;
  
  for (int i=X;i<200000;i++){
    int count=0;
    for (int j=0;j<i;j++){
      if (i%(j+1)==0){
        count++;
      }
    }
    if(count==2){
      cout <<i<<endl;
      break;
    }
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(){

	int n;
	std::cin >> n;

	int digit[4];
	for(int i = 0; i < 4; i++){
		digit[3-i] = n / (int)std::pow(10, i) % 10;
	}

	bool flag = false;
	for(int i = 0; i < 2; i++){

		if( digit[i] == digit[i+1] &&
			digit[i+1] == digit[i+2]){

			flag = true;
		}
	}

	std::cout << (flag ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = sc.nextInt();
    sc.close();

    long sum = 0;
    for (int i = 0; i < N; i++) sum += A[i];

    long cnt = 0;
    for (int i = 0; i < N; i++)
      if (sum <= A[i] * 4 * M ) cnt++;

    String ans = M <= cnt ? "Yes" : "No";
    System.out.println(ans);
  }
}

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

#define MAX_N 100001
int par[MAX_N], rnk[MAX_N];

/* 初期化 */
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rnk[i]=0;
  }
}

/* 根ノード探索 */
int find(int x){
  if(par[x] == x) return x;
  else{
    /* path compression */
    par[x] = find(par[x]);
    return par[x];
  }
}

/* 併合 */
void unite(int x, int y){
  int px = find(x), py = find(y);
  if(px == py) return;
  /* union by rnk */
  if(rnk[px] > rnk[py]) par[px] = py;
  else par[py] = px;
  if(rnk[px] == rnk[py]) rnk[x]++;
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    init(n);
    int a , b;
    vector<int> fri(n);
    for(int i = 0; i< m; i++){
        cin >> a >> b;
        fri[--a]++;
        fri[--b]++;
        unite(a,b);
    }
    map<int,int> g;
    for(int i = 0; i< n; i++){
        g[find(i)] ++;
    }
    vector<int> ans(n);
    for(int i = 0; i< n; i++){
        ans[i] = g[find(i)] - (1+fri[i]); // 自分と友達は抜く
    }
    int c, d;
    for(int i=0;i<k;i++){
        cin >> c >> d;
        if(find(--c) == find(--d)){
            ans[c]--;
            ans[d]--;
        }
    }
    for(auto v: ans){
        cout << v << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6656
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  int h;
  for(int i = 0; i < N; i++) {
    cin >> h;
    if(h >= K) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if((A==7&&(B==7&&C==5))||(A==7&&(B==5&&C==7))||((A==5&&B==7)&&C==7)){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}

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

string a,b;
string ans;


int main(){
	
  	cin >> a >> b;
  	
  	if( a== "H" && b == "H")ans = "H";
    else if( a=="H" && b == "D")ans = "D";
    else if( a=="D" && b == "D")ans = "H";
    else if( a=="D" && b == "H")ans = "D";
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

// @idea: digit dp
//      n: total number of children
//      s   : current number of candies
//      dp(i, s) : all the ways s candies can be distributed from [1...i]

using namespace std;

const int NMAX = 1e2 + 11;
const int KMAX = 1e5 + 11;
const int MOD  = 1e9 + 7;

int n, k, a[NMAX], acc[KMAX], dp[NMAX][KMAX];

int solve(void)
{
    dp[0][0] = 1;

    for (int s = 1; s <= k; ++s)
        dp[0][s] = 0;

    for (int i = 1; i <= n; ++i)
    {
        // 1. If the prefix sum exceeds MOD, it will not be strictly increasing
        acc[0] = dp[i - 1][0];
        for (int s = 1; s <= k; ++s)
            acc[s] = (acc[s - 1] + dp[i - 1][s]) % MOD;
        // 2. reachable =  [s - a[i], s]
        for (int s = 0; s <= k; ++s)
            dp[i][s] =
                (acc[s] - (s - a[i] - 1 >= 0 ? acc[s - a[i] - 1] : 0) + MOD) %
                MOD; // take care of possible negative results. See 1.
    }

    return dp[n][k];
}

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

    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 41600
N,M = map(int,input().split())
H = list(map(int, input().split()))
AB = [list(map(int,input().split()))for i in range(M)]
good = [True]*N
for i in range(M):
        a,b = AB[i]
        if H[a-1] > H[b-1]:
            good[b-1] = False
        elif H[a - 1] < H[b - 1]:
            good[a - 1] = False
        else:
            good[a - 1] = False
            good[b - 1] = False
#print(good)
print(good.count(True))

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

int main()
{
  int n, m, ans = -1, pena = 0, correct = 0;
  cin >> n >> m;
  vector<int> ac(n + 1, 0), tpena(n + 1, 0);
  for (int i = 0; i < m; ++i)
  {
    int p;
    string s;
    cin >> p >> s;
    if (ac[p])
      continue;
    if (s == "AC")
    {
      ac[p] = 1;
      ++correct;
      pena += tpena[p];
    }
    else if (s == "WA")
    {
      ++tpena[p];
    }
  }
  printf("%d %d\n", correct, pena);
}

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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; ++i) cin >> S[i];

    sort(S.begin(),S.end());
    int most = 1, num = 1; string P = S[0];
    vector<pair<string, int>> res;
    for(int i = 1; i <= N; ++i) {
        if(i >= N) { res.push_back(pair<string,int>(P,num)); most = max(most, num);break;}
        if(S[i] == P) { ++num; }
        else {
            res.push_back(pair<string, int>(P,num));
            most = max(most, num);
            num = 1; P = S[i];
        }
    }
    for(int i = 0, i_len = res.size(); i < i_len; ++i) {
        if(res[i].second == most) cout << res[i].first << endl;
    }
    return 0;
}

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

typedef long long ll;

int main(){
	ll n,a,b;
	ll h[100010];
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++)scanf("%lld",&h[i]);
	
	ll l=1,r=1000000000;
	while(l<r){
		ll m=(l+r)/2;
		ll cnt=0;
		for(int i=0;i<n;i++){
			if(h[i]-m*b>0){
				cnt+=(h[i]-m*b+(a-b)-1)/(a-b);
			}
		}
		if(cnt<=m)r=m;
		else l=m+1;
	}
	cout<<l<<endl;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m, l;
	while (cin >> n >> m >> l, n) {
		vector<vector<pair<pair<int, int>,int>>> vvpii(n);
		REP(i, m) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			a--;
			b--;
			vvpii[a].push_back({ {c,d},b });
			vvpii[b].push_back({ { c,d },a });
		}
		priority_queue<pair<pair<int, int>, int>> Q;
		Q.push({ {0,l},0 });
		vvi G(n,vi(l+1,1e9));
		G[0][l] = 0;
		int ans = 0;
		while (!Q.empty()) {
			pair<pair<int, int>, int> q = Q.top();Q.pop();
			q.first.first*=-1;
			if (q.second == n - 1) {
				ans = q.first.first;
				break;
			}
			REP(i, vvpii[q.second].size()) {
				//used money
				if (q.first.second >= vvpii[q.second][i].first.first) {
					if (G[vvpii[q.second][i].second][q.first.second - vvpii[q.second][i].first.first]>q.first.first) {
						G[vvpii[q.second][i].second][q.first.second - vvpii[q.second][i].first.first] = q.first.first;
						Q.push({ {-q.first.first,q.first.second - vvpii[q.second][i].first.first },vvpii[q.second][i].second });
					}
				}
				if (G[vvpii[q.second][i].second][q.first.second]>q.first.first+ vvpii[q.second][i].first.second) {
					G[vvpii[q.second][i].second][q.first.second] = q.first.first + vvpii[q.second][i].first.second;
					Q.push({ { -q.first.first - vvpii[q.second][i].first.second,q.first.second},vvpii[q.second][i].second });
				}
				//secoi
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3252