akhauriyash/Code-Regression huggingface dataset:
## coding: UTF-8
from collections import deque

S = input()
ls = deque()
for i in range(len(S)):
    ls.append(S[i])


Q = int(input())

lq = [list(map(str, input().split())) for _ in range(Q)]


#print(S, Q, lq, ls)

mode = 'jun'

for i in range(Q):
    query = lq[i]
    ti = query[0]
    if(ti == '1'):
        if(mode == 'jun'):
            mode = 'gyaku'
        else:
            mode = 'jun'
    else:
        fi = query[1]
        ci = query[2]
        if(fi == '1'):
            if(mode == 'jun'):
                ls.appendleft(ci)
            else:
                ls.append(ci)
        else:
            if(mode == 'jun'):
                ls.append(ci)
            else:
                ls.appendleft(ci)

a = []

if(mode == 'jun'):
    for i in range(len(ls)):
        a.append(ls[i])
else:
    for i in range(len(ls)):
        j = (-1) * (i+1)
        a.append(ls[j])


ans = ''.join(a)
print(ans)



Measured memory_bytes: 121808
def main():
    N = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    p_mul = 1
    dp[0][0] = 1
    for i in range(1, N + 1):
        p_mul *= (1-p[i-1])
        dp[i][0] = p_mul
    for i in range(1, N+1):
        for j in range(1, N+1):
            dp[i][j] = dp[i - 1][j] * \
                (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1]
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 396680
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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



int main(){
    ll n;
    string s;
    cin >> n >> s;
    string ab = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    REP(i,s.size()){
        REP(j,26){
            if(s[i] == ab[j]){
                cout << ab[(j+n)%26];
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    L = input()
    ans = 1
    p = 1
    for i,b in enumerate(reversed(L)):
        if b == "1":
            ans = ((ans*2%Mod)+p)%Mod
        p = p*3 % Mod
    print(ans)
if __name__ == "__main__":
    main() 
    
#endline===============================================
    

Measured memory_bytes: 13652
A = int(input())
B = int(input())
C = int(input())
X = int(input())
a = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                a = a + 1

print(a)


Measured memory_bytes: 3060
#include <stdio.h>

#define MAX 100000

int A[MAX],n;

int partition(int p,int r)
{
  int x,i,j,y;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      y=A[i];
      A[i]=A[j];
      A[j]=y;
    }
  }
  y=A[i+1];
  A[i+1]=A[r];
  A[r]=y;
  return i+1;
}


int main()
{
  int i,q;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  q=partition(0,n-1);
  for(i=0;i<n;i++){
    if(i>=1) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  return 0;
}

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

typedef long long ll;
const int MOD = 2019;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    vector<int> cnt(300000);
    cnt[0] = 1; // remainder 0 already exists once
    ll ans = 0;
    // subtract suffixes
    ll num = 0;
    ll pot = 1;
    for (int i = s.length() - 1; i >= 0; --i) {
        ll cur = s[i] - '0';
        num += (cur * pot) % MOD;
        ans += cnt[num % MOD];
        cnt[num % MOD]++;
        pot = pot * 10 % MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int count = 0;
    count = (N * (N - 1) / 2 + M * (M - 1) / 2);
    cout << count << endl;
}

Measured memory_bytes: 256
n = int(input())
listA = []
ans = 0
for i in range(n):
    listA.append(list(input().split()))

for i in range(n):
    if listA[i][1] == "JPY":
        ans += float(listA[i][0])
    elif listA[i][1] == "BTC":
        ans += float(listA[i][0]) * 380000.0

print(ans)

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

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

  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int num[N];
  for (int i = 0; i < N; i++) num[i] = 0;

  for (int i = 0; i < N; i++) num[A[i] - 1]++;

  sort(num, num + N);

  int kinds_counter = 0;
  int zero_counter = 0;
  for (int i = 0; i < N; i++) {
    if (num[i]) kinds_counter++;
    else zero_counter++;
  }

  int answer = 0;
  for (int i = zero_counter; i < zero_counter + (kinds_counter - K); i++) {
    answer += num[i];
  }

  cout << answer << endl;
}

Measured memory_bytes: 1792
data Monotony = Dec | Inc | Nmn deriving (Eq, Show)

monotony :: [Int] -> Monotony
monotony [a,b,c] =
    if a<b  then if b<c then Inc
                        else Nmn
            else if b>=c then Dec
                        else Nmn

kanashimi b xs = aux b 0 1 xs
    where
        aux _ ac _ []     = ac
        aux b ac i (x:xs) = aux b (ac+abs(x-b-i)) (i+1) xs

range n xs = [kanashimi b xs | b <- [n-1..n+1]]

monoAt n xs = monotony $ range n xs

main = do
    n <- getLine
    xs <- ((fmap read . words) <$> getLine) :: IO [Int]
    let b = b_ini xs
    let l = b-50
    let u = b+50
    print $ solveR ((l, monoAt l xs),(u, monoAt u xs)) xs 10000000

b_ini :: [Int] -> Int
b_ini xs = ceiling (ave xs) - (div (length xs) 2)

solve :: Int -> [Int] -> Int
solve n xs = do
    let [a,b,c] = range n xs
    case monotony [a,b,c] of
        Inc -> solve (n-1) xs
        Dec -> solve (n+1) xs
        Nmn -> b

solveR :: ((Int,Monotony),(Int,Monotony)) -> [Int] -> Int -> Int
solveR ((l,Dec), (u,Dec)) xs p = do
    let nr = u+p
    solveR ((u,Dec),(nr,monoAt nr xs)) xs p
solveR ((l,Inc), (u,Inc)) xs p = do
    let nl = u-p
    solveR ((nl,monoAt nl xs),(l,Inc)) xs p
solveR ((l,Dec), (u,Inc)) xs p
    | u-l < 100 = solve (ceiling $ ave [u,l]) xs
    | otherwise = do
        let nr = u-div (u-l) 2+1
        solveR ((l,Dec),(nr,monoAt nr xs)) xs (div (u-l) 4)


ave :: [Int] -> Double
ave xs = fromIntegral (sum xs) / fromIntegral (length xs)


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

const int N = 2010, mod = 1e9 + 7;
int n, m, k;
int ans, f[N << 1][N][2], sum[N];

inline int read() {
	int s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

inline int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }
inline int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
inline void Add(int &a, int b) { a = add(a, b); }

int main() {
	n = read(), m = read(), k = read();
	f[0][0][0] = 1;
	for(int i = 1; i <= (max(n, m) << 1); ++i) {
		sum[0] = add(f[i - 1][0][0], f[i - 1][0][1]);
		for(int j = 1; j <= n; ++j)
			sum[j] = add(sum[j - 1], add(f[i - 1][j][0], f[i - 1][j][1]));
		for(int j = 0; j <= n; ++j) {
			f[i][j][0] = sub(sum[j], sum[j - 1]);
			if(j)	f[i][j][1] = sub(sum[j - 1], (j - k >= 0 ? sum[j - k] : 0));
		}
		for(int j = 0; j <= n; ++j)
			if(j % (k - 1) == n % (k - 1) && (i * (k - 1) - j + 1) % (k - 1) == m % (k - 1) && i * (k - 1) - j + 1 <= m)
				Add(ans, f[i][j][1]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 63232
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a-c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}











	return 0;
}

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

using namespace std;
using ll = long long;

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

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

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(a*a);
}

Measured memory_bytes: 256
import bisect

inf = 10 ** 18

def get_near(tera_num, tera_data, start_point):
    index_right = bisect.bisect_right(tera_data, start_point)
    tera_pre, tera_after = tera_data[index_right], tera_data[index_right - 1]
    return tera_pre, tera_after

def calc_data(start_point, point_a, point_b, min_point):
    a = abs(start_point - point_a) + abs(point_a - point_b)
    b = abs(start_point - point_b) + abs(point_b - point_a)
    min_point = min(a, b, min_point)
    return min_point

def calc_ans(start_point, tera_pre, tera_after, jinja_pre, jinja_after):
    min_point = float('inf')
    min_point = calc_data(start_point, tera_pre, jinja_pre, min_point)
    min_point = calc_data(start_point, tera_pre, jinja_after, min_point)
    min_point = calc_data(start_point, tera_after, jinja_pre, min_point)
    min_point = calc_data(start_point, tera_after, jinja_after, min_point)
    return min_point


def start(tera_num, jinja_num, q_num, tera_data, jinja_data, q_data):
    for start_point in q_data:
        tera_pre, tera_after = get_near(tera_num, tera_data, start_point)
        jinja_pre, jinja_after = get_near(jinja_num, jinja_data, start_point)
        ans = calc_ans(start_point, tera_pre, tera_after, jinja_pre, jinja_after)
        print(ans)

def main():
    tera_num, jinja_num, q_num = list(map(int, input().split()))
    tera_data = [-inf] + [int(input()) for i in range(tera_num)] + [inf]
    jinja_data = [-inf] + [int(input()) for i in range(jinja_num)] + [inf]
    q_data = [int(input()) for i in range(q_num)]

    start(tera_num, jinja_num, q_num, tera_data, jinja_data, q_data)

if __name__ == '__main__':
    main()

Measured memory_bytes: 16144
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int N;
vector<int> D;

int main(void) {
	cin >> N;
	D.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> D[i];

	int sum = accumulate(D.begin(), D.end(), 0);
	int ans = 0;
	for (int i = 0; i < N; ++i)
		ans += D[i] * (sum - D[i]);
	ans /= 2;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int q = sc.nextInt();
        long[] s = new long[a+2];
        long[] t = new long[b+2];
        s[0] = (long) -Math.pow(10, 12);
        t[0] = (long) -Math.pow(10, 12);
        s[a+1] = (long) Math.pow(10, 12);
        t[b+1] = (long) Math.pow(10, 12);
        for (int i = 1; i <= a; i++) s[i] = sc.nextLong();
        for (int i = 1; i <= b; i++) t[i] = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            long p = sc.nextLong();
            int sidx = bs(s, p);
            int tidx = bs(t,p);
            long d = Long.MAX_VALUE;
            d = Math.min(d, Math.abs(p - s[sidx]) + Math.abs(s[sidx] - t[tidx]));
            d = Math.min(d, Math.abs(p - s[sidx]) + Math.abs(s[sidx] - t[tidx+1]));
            d = Math.min(d, Math.abs(p - s[sidx+1]) + Math.abs(s[sidx+1] - t[tidx]));
            d = Math.min(d, Math.abs(p - s[sidx+1]) + Math.abs(s[sidx+1] - t[tidx+1]));
            d = Math.min(d, Math.abs(p - t[tidx]) + Math.abs(t[tidx] - s[sidx]));
            d = Math.min(d, Math.abs(p - t[tidx]) + Math.abs(t[tidx] - s[sidx+1]));
            d = Math.min(d, Math.abs(p - t[tidx+1]) + Math.abs(t[tidx+1] - s[sidx]));
            d = Math.min(d, Math.abs(p - t[tidx+1]) + Math.abs(t[tidx+1] - s[sidx+1]));
            sb.append(d).append("\n");
        }

        System.out.println(sb.toString());
        sc.close();
    }

    private static int bs(long[] t, long p) {
        int L = 0;
        int R = t.length;
        int m =0;
        while(R - L > 1){
            m = (L + R) /2;
            if(t[m] == p) break;
            else if(t[m] > p) R = m;
            else L = m;
        }
        return L;
    }

}


Measured memory_bytes: 97540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	vector<ii> vec;
	ll MAX=0;
	for(int i=0;i<n;i++)
	{
		ll l,r; cin>>l>>r;
		vec.pb({r,l}); MAX=max(MAX,l);
	}
	sort(vec.begin(),vec.end());
	ll maxL = vec[0].se;
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		ll R1 = vec[0].fi;
		ll R2 = vec[i].fi;
		//case 1
		{
			ll L1=MAX;
			ll L2=vec[i].se;
			ans=max(ans,max(R1-L1+1,0LL)+max(R2-L2+1,0LL));
		}
		//case 2
		{
			ll L1=maxL;
			ll L2=MAX;
			ans=max(ans,max(R1-L1+1,0LL)+max(R2-L2+1,0LL));
		}
		
		maxL=max(maxL,vec[i].se);
	}
	cout<<ans<<'\n';
}	


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

int main()
{
    int A, B;

    cin >> A >> B;

    int coin;

    if (A > B)
    {
        coin = A * 2 - 1;
    }
    else if (A < B)
    {
        coin = B * 2 - 1;
    }
    else
    {
        coin = A * 2;
    }

    cout << coin << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<cstdio>

int n, m;

int inline Log(int a)
{
	int l = 0, r = 31;
	while (l < r)
	{
		int mid = (l + r) >> 1;
		if ((1 << mid) >= a)
		{
			r = mid;
		}
		else
		{
			l = mid + 1;
		}
	}
	return l;
}

int main() 
{
	scanf("%d", &n);
	m = Log(n);
	if ((1 << m) == n)
	{
		puts("No");
	}
	else
	{
		puts("Yes");
		printf("%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n", 1, 2, 2, 3, 3, n + 1, n + 1, n + 2, n + 2, n + 3);
		for (int i = 2; (i << 1 | 1) <= n; i++)
		{
			printf("%d %d\n", 1, i << 1);
			printf("%d %d\n", 1, i << 1 | 1);
			printf("%d %d\n", i << 1, (i << 1 | 1) + n);
			printf("%d %d\n", i << 1 | 1, (i << 1) + n);
		}
		if (!(n & 1))
		{
			for (int i = 2; i < n; i++)
			{
				if (i != 3)
				{
					int j = (i ^ 1 ^ n);
					if (j != 3 && j < n)
					{
						printf("%d %d\n", n, i);
						printf("%d %d\n", n << 1, j);
						break;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 2020000;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)

int a[maxn];
int vis[maxn] = {0};

int dfs(int x, int rt) {
	if(x&(1<<rt)) {
		if(vis[rt]) return 0;
		else {
			vis[rt] = 1;
			if(dfs(x, rt + 1)) return 1;
			vis[rt] = 0;
			return 0;
		}
	}
	else return dfs(x, rt + 1);
}


void solve() {
	int n;
	LL ans = 0;
	LL temp = 0;
	cin >> n;
	for(int i = 1;i <= n;i++) scanf("%d", &a[i]);
	for(int l = 1, r = 0;l <= n;l++) {
		ans += (LL)(r - l + 1);
		for(int j = r + 1;j <= n;j++) {
			if((temp^a[j]) == temp + a[j]) {
				temp ^= a[j];
				ans++;
				r++;
			}
			else break;
		}
		temp ^= a[l];
	}
	cout << ans << endl;
}

int main() {
	int t = 1;
	while(t--) {
		solve();
	}
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	int h, w;
	cin >> h >> w;
	if (w == 1 || h == 1)cout << 1 << endl;
	else if (h * w % 2 == 0)cout << h * w / 2 << endl;
	else cout << h * (w - 1) / 2 + h / 2 + 1 << endl;
}


Measured memory_bytes: 256
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    input = readline
    mod = 10 ** 9 + 7
    H, W, M = map(int, input().split())
    Hlist = collections.defaultdict(int)
    Wlist = collections.defaultdict(int)
    hw = []

    for _ in range(M):
        h, w = map(int, input().split())
        Hlist[h-1] += 1
        Wlist[w-1] += 1
        hw.append([h, w])

    #hmax = [i for i, x in enumerate(Hlist) if x == max(Hlist)]
    #wmax = [i for i, x in enumerate(Wlist) if x == max(Wlist)]

    Hlist = sorted(Hlist.items(), key=lambda x: x[1], reverse=True)
    Wlist = sorted(Wlist.items(), key=lambda x: x[1], reverse=True)

    hmaxset = set()
    wmaxset = set()

    maxH = Hlist[0][1]
    for k, v in Hlist:
        if v != maxH:
            break
        else:
            hmaxset.add(k)

    maxW = Wlist[0][1]
    for k, v in Wlist:
        if v != maxW:
            break
        else:
            wmaxset.add(k)


    flag = False
    count = 0
    for hh in hw:
        h = hh[0] - 1
        w = hh[1] - 1
        if h in hmaxset and w in wmaxset:
            count += 1

    lenhmax = len(hmaxset)
    lenwmax = len(wmaxset)

    if count != lenhmax * lenwmax:
        flag = True

    if flag:
        print(maxH + maxW)
    else:
        print(maxH + maxW - 1)





if __name__ == '__main__':
    solve()

Measured memory_bytes: 234796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

//turn, mass, money -> e;
double dp[51][5010];
int x, y, z;

int main(void)
{
	while(cin >> x >> y >> z && x)
	{
		memset(dp, 0, sizeof(dp));
		vector<P> events(y + 1);
		vector<int> roulette(x);
		readAll(roulette);

		int maxmoney = 0;
		for (int i = 0; i < z; i++)
		{
			int n, e, a;
			cin >> n >> e >> a;
			events[n] = P(e, a);
			if(e == 2)
				maxmoney += a;
		}

		dp[0][0] = 1.;

		double mag = 1.0 / (double)x;

		for (int j = 0; j < y; j++)
		{
			for (int k = 0; k <= maxmoney; k++)
			{
				double exp = dp[j][k] * mag;
				for (int l = 0; l < x; l++)
				{
					int next = min(j + roulette[l], y);
					int money = k;
					int ev = events[next].first;
					int value = events[next].second;
					if(ev != 0)
					{
						if(ev == 1)
						{
							next = min(next + value, y);
						}
						if(ev == 2)
						{
							money += value;
						}
						if(ev == 3)
						{
							money = max(0, money - value);
						}
					}
					dp[next][money] += exp;
					dp[j][k] = 0;
				}
			}
		}

		double result = 0;
		for (int k = 0; k <= 5000; k++)
		{
			result += dp[y][k] * k;
		}

		cout << (int)result << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []

for i in range(m):
	l = list(map(int,input().split()))
	p.append(l[0])
	x.append(l[1])

for (a,b) in zip(p,x):
	nums = 0
	for i in t:
		nums += i
	nums -= t[a-1]-b
	print(nums)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const ll MOD = 1000000007;
const ll INF = 10000000;


int main(void){

    int n, a[100005];

    cin >> n;

    ll ans = 0;
    for (int i = 0; i < n; i++){
        int s;
        cin >> s;
        ans += s-1;
    }


    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	/** 行数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(IntStream.range(0, N).mapToObj(i -> scanner.next().substring(i, i + 1))
					.collect(Collectors.joining()));
		}
	}
}


Measured memory_bytes: 27348
z=60,t;p(){printf("0%d:%02d:%02d\n",t/z/z,t/z%z,t%z);}main(h,m,s){for(;scanf("%d%d%d",&h,&m,&s),~h;p(),p(t*=3))t=7200-h*z*z-m*z-s;exit(0);}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();//6/5
		System.out.println(2*(x/11)+(x%11 == 0 ? 0 : x%11 <= 6 ? 1 : 2));
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int Search(int);

int S[1000000],n;
int main(){
  int i,q,key,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
   
      scanf("%d",&S[i]);
    }

  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      if(Search(key)==1)
	{
	  count++;
	}
    }
  printf("%d\n",count);
  return 0;
}
int Search(int k)
{
  int left =0,right = n;
  int mid;
  while(left<right){
      mid=(left+right)/2;
      if(k==S[mid])return 1;
      if(k > S[mid])left = mid+1;
      else if(k < S[mid])right = mid;
    }
  return 0;
}

Measured memory_bytes: 988
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(char,a);
  if(a>=97){
      p("a");
  }
  else{
      p("A");
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



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

    int T=1;
    //cin >> T;
    while(T--){
        ll n;
        cin>>n;
        ll a[n];
        rep(i,n) cin>>a[i];
        ll mx=0;
        ll ans=0;
        rep(i,n){
            ans+=max(0ll, mx-a[i]);
            mx=max(mx, a[i]);
        }
        cout<<ans<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 5364
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	int N;
	cin >> N;
	int H[N];
	for(int i = 0; i < N; i++){
		cin >> H[i];
	}
	int cnt = 0;
	for(int i = 0; i < N; i++){
		bool flag = true;
		for(int j = 0; j < i; j++){
			if(H[j] > H[i]){
				flag = false;
				break;
			}
		}
		if(flag){
			cnt++;
		}
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    string s, t; cin >> s >> t;
    int len = s.size();
    
    vector<int> num(26, -1);//出現順、未出現なら-1
    string s_, t_;  vector<char> alp;
    for(char c='a'; c<='z'; c++)alp.push_back(c);

    int index = 0;
    for(char c: s){
        int i = c - 'a';
        if(num[i]==-1){
            s_.push_back(alp[index]);
            num[i] = index;
            index++;
        }else{
            s_.push_back(alp[num[i]]);
        }
    }
    index = 0; rep(i, 26)num[i] = -1;
    for(char c: t){
        int i = c - 'a';
        if(num[i]==-1){
            t_.push_back(alp[index]);
            num[i] = index;
            index++;
        }else{
            t_.push_back(alp[num[i]]);
        }
    } 
    //cout << s_ << " " << t_ << ln;
    cout << (s_==t_? "Yes":"No") << ln;  
}

Measured memory_bytes: 1168
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
	int n;
	List<List<Integer>> list;

	public void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			list=new ArrayList<List<Integer>>();
			for(int i=0;i<n;i++){
				List<Integer> tmp=new ArrayList<Integer>();
				int m=sc.nextInt();
				for(int j=0;j<m;j++){
					tmp.add(sc.nextInt());
				}
				list.add(tmp);
			}
			List<Integer> s=new ArrayList<Integer>();
			int m=sc.nextInt();
			for(int i=0;i<m;i++){
				s.add(sc.nextInt());
			}

			int i=1;

			int val=-1;
			for(List<Integer> l:list){
				if(l.containsAll(s)){
					if(val!=-1){
						val=-1;
						break;
					}
					val=i;
				}
				i++;
			}
			pr(val);
		}
	}

	public static void pr(Object o){
		System.out.println(o);
	}
	public static void main(String[] _) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	vector<char>AL(26);
	AL = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
	string A, B, C;
	cin >> A >> B >> C;
	int cnt = 0;
	rep(i, 26) {
		if (A[0] == al[i]) {
			cout << AL[i];
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << A[0];
	}
	cnt = 0;

	rep(i, 26) {
		if (B[0] == al[i]) {
			cout << AL[i];
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << B[0];
	}
	cnt = 0;

	rep(i, 26) {
		if (C[0] == al[i]) {
			cout << AL[i];
			cnt++;
		}
	}
	if (cnt == 0) {
		cout << C[0];
	}
	cnt = 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TEST ll t;cin>>t;while(t--)
ll sizes[100001];
ll arr[100001];

bool ok=true;
ll A[100001];
pll B[100001];

ll root(ll i){
    while(i!=arr[i]) i=arr[i];
    return(i);
}
void Union(ll i,ll j){
    ll root_i=root(i),root_j=root(j);
    if(root_i==root_j) return;
    if(sizes[root_i]>sizes[root_j]) swap(root_i,root_j);
    sizes[root_j]+=sizes[root_i];
    arr[root_i]=arr[root_j];
    return;
}
bool prime[10000000];
vector<ll> v;
void era(){
    memset(prime,true,sizeof prime);
    for(int p=2;p*p<=10000000;p++){
        if(prime[p]){
            if(p%5==1) v.push_back(p);
            for(int q=p*p;q<=10000000;q+=p){
                prime[q]=false;
            }
        }
    }
    return;
}
ll power[11];

int main(){
    IO
    ll N;
    cin>>N;
    era();
    
    for(ll i=0;i<N;i++) cout<<v[i]<<" ";
    return(0);
}


Measured memory_bytes: 10496
#include<iostream>

using namespace std;

int main(){
    
    int n,t,e,x,al;
    
    al = -1;
    cin >> n >> t >> e;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x > t+e) continue;
        if(t%x <= e || x-t%x <= e) al = i+1;
    }
    
    cout << al << endl;
    
    return(0);
}


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

using   namespace       std;

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


int     main() {
        long A, B, C, D;
        cin >> A >> B >> C >> D;
        long S;
        S=B/C - (A-1)/C;
        S += B/D - (A-1)/D;
        long SS=C/gcd(C, D);
        SS *= D;
        S -= B/SS - (A-1)/SS;
        S = B-A+1-S;
        cout << S << endl;
        return 0;
}

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

int main() {
    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        cout << "vowel" << endl;
    }
    else cout << "consonant" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;



int main()
{
    idfc;

    int k;
    cin>>k;
    int n=0;
    set<int> ss;
    int c=1;
    while(true)
    {
        n=((n*10)+7)%k;
        if(n==0)
        {
            cout<<c;
            break;
        }
        if(ss.count(n))
        {
            cout<<-1;break;
        }
        ss.insert(n);
        c++;
    }


    return 0;
}

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

int main()
{
    int n, count = 0;
    float m, sum = 0;
    vector<int> a(300);

    cin >> n >> m;
    rep(i, n)
    {
        cin >> a.at(i);
        sum += a.at(i);
    }
    rep(i, n)
    {
        if (a.at(i) >= sum / (4 * m))
            count++;
    }

    if (count >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    // cout << sum / (4 * m) << endl;

    return 0;
}

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

using namespace std;

string s , t;

int LCS(int l , int m)
{
    int i , j ;
    vector<vector<int>>dp(l+1,vector<int>(m+1,0));
    for( i = 0 ; i <=l ; i++)
    {
        for( j = 0 ; j <=m ; j++)
        {
            if(i==0 || j==0) dp[i][j]=0;

            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    i = l;
    j = m;
    string ans;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
int main()
{
    cin>>s>>t;
    LCS(s.length(),t.length());
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char );
long long getkey(char []);
int h1(int);
int h2(int);
int find(char []);
int insert(char []);

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}

int getChar(char ch){
  if(ch=='A') return 1;
  else  if(ch=='C') return 2;
  else  if(ch=='G') return 3;
  else  if(ch=='T') return 4;
  else return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int find(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if (strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getkey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if (strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 16052
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int res = b + (c - (a + b) <= 1 ? c : c - (c - b - a) + 1);
        
        System.out.println(res);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int ans[100001],dist[100001];
int n,m;
vi v[100001];
bool used[100001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	rep(i,n)
	dist[i]=1000000;
	dist[0]=0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int p=q.front();
		q.pop();
		used[p]=true;
		rep(i,v[p].size()){
			if(dist[v[p][i]]>dist[p]+1){
				dist[v[p][i]]=dist[p]+1;
				ans[v[p][i]]=p;
				q.push(v[p][i]);
			}
		}
	}
	rep(i,n){
		if(!used[i]){
			cout<<"No";
			re 0;
		}
	}
	cout<<"Yes\n";
	forn(i,1,n)
	cout<<ans[i]+1<<"\n";
	re 0;
}

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/

/******** User-defined Function *******/




/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x,y; cin >> x >> y;

  int tmp = y - x*2;

  if(tmp<0){
      cout << "No" << endl;
      return 0;
  }

  if(tmp%2!=0){
      cout << "No" << endl;
      return 0;
  }else if(tmp/2>x){
      cout << "No" << endl;
  }else{
      cout << "Yes" << endl;
  }


  return 0;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3652
n,m,x=map(int,input().split())
a=[]
a+=list(map(int,input().split()))
countr=0
countl=0
for i in range (0,m):
  if a[i]<x:
    countr=countr+1
  elif a[i]>x:
    countl=countl+1
print(min(countr,countl))

Measured memory_bytes: 3064
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                      
 
 
const int inf = 1e9, maxn = 1e3 + 108, mod = 1e9 + 7, N = 1e4 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, m, a, b, c[N][N];

main () {
	cin >> n >> m >> a >> b;
	forn (i, 1, n) {
		forn (j, 1, m) 
			if ((i <= b && j <= a) || (i > b && j > a))
				printf("1");
			else
				printf("0");
		printf("\n");

	}
}

    

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

int main()
{
  vector<int> vc{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin>>n;
  cout<<vc[n-1]<<endl;

    return 0;
}


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

int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int ab = min(x,y);
  ll sum = 0;
  if(a+b>2*c){
      sum += 2*ab*c;
  }else{
      sum += a*ab+b*ab;
  }
  if(a<2*c){
    if(x-ab>0){
        sum += a*(x-ab);
    }
  }else{
     if(x-ab>0){
        sum += 2*c*(x-ab);
    } 
  }
  if(b<2*c){
    if(y-ab>0){
        sum += b*(y-ab);
    }
  }else{
      if(y-ab>0){
        sum += 2*c*(y-ab);
    }
  }
  
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <tuple>
#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define MAXN (100005)
#define MAXX (100005)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

int C[MAXX];
int N, Ans;

int main() {
	scanf("%d", &N);
	for(int i = 1, c; i <= N; i++) { scanf("%d", &c); C[c]++; }
	for(int i = 1; i < MAXX; i++) Ans += 1 < C[i] ? C[i]-1 : 0;
	printf("%d\n", N - (Ans+1)/2*2);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n;
int A[50000010];
char s[500010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  scanf("%s",s+1);
  n=strlen(s+1);
  for(int i=1;i<=n;++i) A[n-i+1]=s[i]-'0';
  int cnt=n,t=0,tot=0;
  for(int i=1;i<=n;++i) {
    int g=(A[i]*9+t)/10;
    A[i]=(A[i]*9+t)%10;
    t=g;
    tot+=A[i];
  }
  if(t) A[++cnt]=t,tot+=t;
  for(int i=1;i<=n*9;++i) {
    t=9;
    for(int j=1;j<=cnt;++j) {
      int g=(A[j]+t)/10;
      tot-=A[j];
      A[j]=(A[j]+t)%10;
      tot+=A[j];
      t=g;
      if(!t) break;
    }
    if(t) A[++cnt]=t,tot+=t;
    if(tot<=i*9) return printf("%d\n",i),0;
  }
  return 0;
}


Measured memory_bytes: 4352