akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int A,B;
    int answer=0;
    scanf("%d %d",&A,&B);
    if(A<B)
    {
    answer+=B;
    B=B-1;
    }else{
    answer+=A;
    A=A-1;}
    if(A<B)
    {
    answer+=B;
    B=B-1;
    }else{
    answer+=A;
    A=A-1;}
    printf("%d",answer);
     
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;
 

ll poow(ll a, ll b, ll m)
{
 
    if (b % 2 == 0)
        return (((ll)pow(a, b / 2) % m) * ((ll)pow(a, b / 2) % m)) % m;
    else
        return (((ll)pow(a, (b - 1) / 2) % m) * ((ll)pow(a, (b + 1) / 2) % m)) % m;
}
 
bool subsum(ll ar[], ll s, ll n)
{
    if (n == 0 && s != 0)
        return false;
    else if (s <= 0)
        return true;
 
    else if (ar[n - 1] > s)
        return subsum(ar, s, n - 1);
    else
        return (subsum(ar, s - ar[n - 1], n - 1) || subsum(ar, s, n - 1));
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l)
    {
        int mid = l + (r - l) / 2;
 
        if (arr[mid] == x)
            return mid;
 
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
 
        return binarySearch(arr, mid + 1, r, x);
    }
 
    return -1;
}
int main()
{
    fio;
    int a,b;
    cin>>a>>b;
    cout<<(a*b);
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int main(){
	fio;
	int a[4]={0};
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[1]+a[2]; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,q;
  cin >>n>>q;
  string s;
  cin>>s;
  vector<int>l(q),r(q);
  rep(i,q){
    cin>>l[i]>>r[i];
  }
  int kazu_s[n+1],kazu_e[n+1];
  rep(i,q){
    l[i]--;
    r[i]--;
  }
  rep(i,n+1){
    kazu_e[i]=0;
  }          
  int sum=0;
  rep(i,n-1){
    if(s[i]=='A'&&s[i+1]=='C'){
      sum++;
    }
    kazu_e[i+1]=sum;
  }          
  rep(i,q){
    int kotae=kazu_e[r[i]]-kazu_e[l[i]];
    cout<<kotae<<endl;
  }
  return 0;
}

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

void solve(int n){
    string ans = "";
    while(n!=0){
        int r = n%26;
        if(r==0){
            r = 25;
            n/=26;
            n--;
        }
        else{
            r--;
            n/=26;
        }

        ans.append(1, 'a'+r);
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}

int32_t main(){
    int n;
    cin >> n;
    solve(n);
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    if (n%2== 0 && s.substr(0, n / 2) + s.substr(0, n / 2) == s)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
   
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b)
	{
		if(b<c)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else
	{
		printf("No\n");
	}

	
	 
     return 0;
}

Measured memory_bytes: 580
N = int(input())
H = [int(n) for n in input().split()]

dp = [1e8] * (N - 1) # i番目の板から始めた時のコスト最小値(0<=i<=N-1)
dp[-1] = abs(H[-1] - H[-2])
if N > 2:
    dp[-2] = min(abs(H[-1] - H[-3]), dp[1] + abs(H[-2] - H[-3]))

for i in range(N):
    j = N - i - 1
    if j < N-3:
        dp[j] = min(dp[j+1] + abs(H[j] - H[j+1]), dp[j+2] + abs(H[j] - H[j+2]))

print(dp[0])



Measured memory_bytes: 13772
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    bool flg = true;
    int C = 0, N = S.size();
    if(S[0] != 'A'){
        flg = false;
    }
    for(int i = 2;i < N-1; i++){
        if(S[i] == 'C'){
            C++;
        }
    }
    if(C != 1){
        flg = false;
    }
    for(int i = 1; i < N; i++){
        if('A' <= S[i] && S[i] <= 'Z' && !(S[i] == 'C'))flg = false;
    }
    if(flg == true){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);

    cout<<a[1]-a[0]+(a[2]-a[1])<<endl;
}


Measured memory_bytes: 256
from collections import deque
n,m = map(int, input().split(' '))
AB = [list(map(int, input().split(' '))) for i in range(m)]
ans = 0
for X in range(m):
    graph = [[] for i in range(n+1)]
    for i in range(m):
        if i != X:
            [a,b] = AB[i]
            graph[a].append(b)
            graph[b].append(a)
    x = deque([1])
    visited = [0]*(n+1)
    while x:
        q = x.popleft()
        visited[q] = 1
        for i in graph[q]:
            if visited[i] == 0:
                x.append(i)
    for i in range(1,n+1):
        if visited[i] != 1:
            ans += 1
            break
print(ans)

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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector <int>
#define vvi         vector <vi>
#define pii         pair <int,int>
#define vii         vector <pii>
#define nl          '\n'
#define yy          "YES\n"
#define nn          "NO\n"
#define pb          emplace_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007

signed main()
{
        IO;
        int n;
        double d;
        cin >> n >> d;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            double dist = sqrtl(x * x + y * y);
            if (dist <= d) {
                ans++;
            }
        }
        cout << ans;
}


Measured memory_bytes: 3796
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}

import           Control.Monad.State.Strict
import           Data.Bits
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.List
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
    [n, m] <- map read.words <$> getLine :: IO [Int]
    pys <- U.unfoldrN m parsePY <$> B.getContents
    putStr.unlines.map showAnswer.U.toList $ solve pys

solve :: U.Vector PY -> U.Vector IPJ
solve pys = radixSort64
    . U.postscanl' step 0
    . radixSort64
    $ U.imap (.|.) pys
  where
    step :: IPJ -> PYI -> IPJ
    step prev pyi
        | prevP == p = nextI .|. ((prev .&. 0x3ffffffff) + 1)
        | otherwise =  nextI .|. unsafeShiftL p 17 .|. 1
      where
        p = pyiToP pyi
        nextI = unsafeShiftL (pyiToI pyi) 34
        prevP = unsafeShiftR prev 17 .&. 0x1ffff

addLeadingZeros :: Int -> String
addLeadingZeros x = tail . show $ x + 1000000000000

showAnswer :: IPJ -> String
showAnswer ipj = addLeadingZeros $ (ipjToP ipj * 1000000) + ipjToJ ipj

type IPJ = Int -- I: 17, P: 17, J: 17
ipjToP :: IPJ -> Int
ipjToP ipj = unsafeShiftR ipj 17 .&. 0x1ffff

ipjToJ :: IPJ -> Int
ipjToJ ipj = ipj .&. 0x1ffff

type PY = Int
encodePY :: Int -> Int -> PY
encodePY p y = unsafeShiftL p 47 .|. unsafeShiftL y 17

type PYI = Int -- P: 17, Y: 30, I: 17
pyiToP :: PYI -> Int
pyiToP pyi = unsafeShiftR pyi 47 .&. 0x1ffff

pyiToI :: PYI -> Int
pyiToI pyi = pyi .&. 0x1ffff

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parsePY :: Parser PY
parsePY = runStateT $
    encodePY
        <$> StateT (B.readInt . B.dropWhile isSpace)
        <*> StateT (B.readInt . B.unsafeTail)

radixSort64 :: U.Vector Int -> U.Vector Int
radixSort64 v = foldl' step v [0, 16, 32, 48]
  where
    mask k x = fromIntegral $ unsafeShiftR x k .&. 0xffff
    step v k = U.create $ do
        pref <- U.unsafeThaw
            . U.prescanl' (+) 0
            . U.unsafeAccumulate (+) (U.replicate 0x10000 0)
            $ U.map (flip (,) 1. mask k) v
        res <- UM.unsafeNew $ U.length v
        U.forM_ v $ \x -> do
            let !masked = mask k x
            i <- UM.unsafeRead pref masked
            UM.unsafeWrite pref masked $ i + 1
            UM.unsafeWrite res i x
        return res


Measured memory_bytes: 10620
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void pt(T s) { cout << s << "\n"; }
template <class T> inline void pt(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e2 + 10;
int n, k; char s[N]; int f[N][2], g[N][2]; 
// 0 origin
// 1 change
void run() {
	n = strlen(s + 1);
	if (n == 1) return pt(k / 2);
	f[1][0] = 0; f[1][1] = 1;
	for (int i = 2; i <= n; ++i) {
		f[i][0] = f[i - 1][1];
		if (s[i] != s[i - 1]) chmin(f[i][0], f[i - 1][0]);
		f[i][1] = min(f[i - 1][0], f[i - 1][1]) + 1;
	}
	if (s[1] != s[n]) pt(1ll * min(f[n][0], f[n][1]) * k);
	else {
		ll res = 1ll * f[n][1] * (k - 1) + min(f[n][0], f[n][1]);
		g[2][0] = 0, g[2][1] = 1; 
		for (int i = 3; i <= n; ++i) {
			g[i][0] = g[i - 1][1];
			if (s[i] != s[i - 1]) chmin(g[i][0], g[i - 1][0]);
			g[i][1] = min(g[i - 1][0], g[i - 1][1]) + 1;
		}
		chmin(res, min(f[n][0], f[n][1]) + 1ll * (min(g[n][0], g[n][1]) + 1) * (k - 1));	
	//	chmin(res, 1ll * (f[n][1] + min(f[n][0], f[n][1])) * (k / 2) + (k % 2 ? min(f[n][0], f[n][1]) : 0));
	//	chmin(res, 1ll * (min(g[n][0], g[n][1]) + 1 + min(f[n][0], f[n][1])) * (k / 2) + (k % 2 ? min(g[n][0], g[n][1]) + 1 : 0));
		chmin(res, 1ll * (g[n][1] + 1) * (k / 2) + 1ll * (k - k / 2) * min(f[n][0], f[n][1]));
		pt(res);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> (s + 1) >> k) run();
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int lines = Integer.parseInt(sc.nextLine());

		while (lines != 0) {
			int[] wait = new int[lines];
			for (int i = 0; i < lines; i++) {
				wait[i] = Integer.parseInt(sc.nextLine());
			}
			
			Arrays.sort(wait);
			
			long sum = 0;
			for (int i = 0; i < lines; i++) {
				sum = sum + (lines - i - 1) * wait[i];
			}
			System.out.println(sum);

			lines = Integer.parseInt(sc.nextLine());
		}
	}
}

Measured memory_bytes: 65332
#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 <complex>
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() {
    int n, x;
    cin >> n >> x;
    cout << n - x + 1 << endl;

    return 0;
}

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

int main()
{
  int K, A, B;
  cin >> K;
  cin >> A >> B;
  for (int i = A; i <= B; i++)
  {
    if (i % K == 0) {
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}


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

using namespace std;


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

    int n;
    cin >> n;
    vector<int>a(n, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    int m_cost = 10e5;
    for (int i = -100; i <= 100; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        m_cost = min(m_cost, tmp);
    }
    cout << m_cost;


    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<int> num(n); for (auto& a : num) std::cin >> a;
	std::sort(num.begin(), num.end());
	std::vector<bool> is_divideable(1000001, false);
	for (auto i = 1; i < n; ++i) {
		if (num[i] == num[i - 1]) {
			is_divideable[num[i]] = true;
		}
	}
	auto unique = num;
	unique.erase(std::unique(unique.begin(), unique.end()), unique.end());
	for (const auto a : unique) {
		for (auto i = a << 1; i < is_divideable.size(); i += a) is_divideable[i] = true;
	}
	std::cout << std::count_if(num.begin(), num.end(), [&is_divideable](const int i) {return !is_divideable[i]; }) << '\n';
}


Measured memory_bytes: 5044
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	// your code goes here
	int N, M, C;
  	int B[20];
    int A[20][20];
  
    int clear = 0;
    long long temp_sum = 0;
    
    unsigned int temp = 0;
    
	temp = scanf("%d %d %d",&N, &M, &C);
    for(int i = 0; i < M; i++){
        temp = scanf("%d",&B[i]);
    }
    for(int i = 0; i < N; i++){
      for(int j = 0; j < M; j++){
        temp = scanf("%d",&A[i][j]);
      }
    }
	
    for(int i = 0; i < N; i++){
      temp_sum = 0;
      
      for(int j = 0; j < M; j++){
        temp_sum += A[i][j] * B[j];
      }
      
      temp_sum += C;
      
      if(temp_sum > 0){
        clear++;
      }
    }
    
    printf("%d", clear);

	return 0;
}


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

int main(){
  int h,n;
  cin >> h >> n;
  int a[n];
  int sum = 0;
  for(int i=0;i<n;i++){
     int k;
     cin >> k;
     sum +=k;
     if(sum >= h){
        cout << "Yes" << endl;
        return 0;
     }
  }

  cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int n, k, a = 1;
	scanf("%d %d", &n, &k);
	
	for (int i = 1; i <= n; i++) {
		if ( a * 2 < a + k) {
			a *= 2;
		}
		else {
			a += k;
		}
	}
	printf("%d", a);
}

Measured memory_bytes: 1736
points = $<.map{|s| s.split(",").map(&:to_f)}
points << points[0]
area = 0
points.each_cons(2){|u, v|
    x1, y1 = u
    x2, y2 = v
    area += x1 * y2 - y1 * x2
}
printf("%.7f\n", area.abs / 2)

Measured memory_bytes: 6132
K, N = map(int, raw_input().split())
A = map(int, raw_input().split())

cmax = 0
for i in range(N-1):
    if A[i+1]-A[i] > cmax:
        cmax = A[i+1]-A[i]
if A[0]+K-A[N-1] > cmax:
    cmax = A[0]+K-A[N-1]
print K-cmax


Measured memory_bytes: 20032
#include <stdio.h>

void reset(int w[1024][1024],int l[]){
	int i,j;
	for(i = 0;i < 1024;i++){l[i] = 0;}
	for(i = 0;i < 1024;i++){
		for(j = 0;j < 1024;j++){w[i][j] = 0;}
	}
}

int main(void) {
	int n,m,w[1024][1024],l[1024],i,j,a,b,res;
	while(scanf("%d",&n) , n != 0){
		scanf("%d",&m);
		res = 0;
		reset(w,l);
		for(i = 1;i <= m;i++){
			scanf("%d%d",&a,&b);
			w[a][b]++;
			w[b][a]++;
		}
		for(i = 1;i <= n;i++){
			if(w[1][i] == 0){continue;}
			l[i] = 1;
			for(j = 1;j <= n;j++){
				if(w[i][j] != 0){l[j] = 1;}
			}
		}
		for(i = 2;i <= n;i++){if(l[i]){res++;}}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
using namespace std;

int main(){
  int N;
  cin >> N;
  int max_int4 = N / 4;
  int max_int7 = N / 7;
  bool flag = false;
  
  for(int i = 0; i <= max_int4; ++i){
    for(int j = 0; j <= max_int7; ++j){
      if(i * 4 + j * 7 == N){
	flag = true;
	break;
      }
    }
    if(flag == true){
      break;
    }
  }

  if(flag == true){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> b[i][j];
  int offset = 13000;
  vector<vector<bitset<26000>>> can(h, vector<bitset<26000>>(w));
  can[0][0][offset + (a[0][0] - b[0][0])] = true;
  can[0][0][offset + (b[0][0] - a[0][0])] = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i == j && i == 0) continue;
      if (i > 0) {
        if (a[i][j] - b[i][j] >= 0) {
          can[i][j] |= can[i - 1][j] << (a[i][j] - b[i][j]);
          can[i][j] |= can[i - 1][j] >> (a[i][j] - b[i][j]);
        } else {
          can[i][j] |= can[i - 1][j] << (b[i][j] - a[i][j]);
          can[i][j] |= can[i - 1][j] >> (b[i][j] - a[i][j]);
        }
      }
      if (j > 0) {
        if (a[i][j] - b[i][j] >= 0) {
          can[i][j] |= can[i][j - 1] << (a[i][j] - b[i][j]);
          can[i][j] |= can[i][j - 1] >> (a[i][j] - b[i][j]);
        } else {
          can[i][j] |= can[i][j - 1] << (b[i][j] - a[i][j]);
          can[i][j] |= can[i][j - 1] >> (b[i][j] - a[i][j]);
        }
      }
    }
  }
  int ans = 1000000000;
  for (int i = 0; i < 12900; i++) {
    if (can[h - 1][w - 1][offset + i] || can[h - 1][w - 1][offset - i]) {
      ans = min(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 21120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int N,K;
string s,t;
void change(int i){
	t[i]='0'+'1'-t[i];
	K--;
	if(K==0){
		cout<<t<<endl;
		exit(0);
	}
}
int main(){
	cin>>N>>s>>K;
	t=s;
	if(K==0){
		cout<<t<<endl;
		return 0;
	}
	rep(i,N) if(s[i]=='0') change(i);
	for(int i=N-1;i>=0;i--) if(s[i]=='1') change(i);
}

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

using ll = long long;

// 0-indexed
struct dsu {
	int n; // number of connected components
	vector<int> par;
	vector<int> sz;

	dsu(int _n) : n(_n), par(n, -1), sz(n, 1) { }

	int getpar(int a) {
		return par[a] == -1 ? a : (par[a] = getpar(par[a]));
	}

	bool merge(int a, int b) {
		a = getpar(a);
		b = getpar(b);
		if (a == b) return false;
		n--;
		if (sz[a] < sz[b]) swap(a, b);
		par[b] = a;
		sz[a] += sz[b];
		return true;
	}
};

// edge_t is something like pair<weight, pair<a, b>>
template <typename edge_t> ll mst(int n, vector<edge_t> edges) {
	sort(edges.begin(), edges.end());
	dsu conn(n);
	ll res = 0;
	for (const auto& e : edges) {
		int a, b; tie(a, b) = e.second;
		if (conn.merge(a, b)) {
			res += e.first;
		}
	}
	return res;
}

const int MAXN = 2e5;
int N;
int P[MAXN][2];

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

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i][0] >> P[i][1];
	}

	vector<pair<int, pair<int, int>>> edges;
	for (int z = 0; z < 2; z++) {
		vector<int> ord(N);
		iota(ord.begin(), ord.end(), 0);
		sort(ord.begin(), ord.end(), [&](int i, int j) {
			return P[i][z] < P[j][z];
		});
		for (int i = 0; i+1 < N; i++) {
			edges.push_back({P[ord[i+1]][z] - P[ord[i]][z], {ord[i], ord[i+1]}});
		}
	}

	cout << mst(N, edges) << '\n';

	return 0;
}


Measured memory_bytes: 7272
def run():
    n,m,l=tuple(map(int,input().split()))
    
    A=[]
    
    for i in range(n):
        row_ls=list(map(int,input().split()))
        
        A.append(row_ls)
        
    B=[]
    
    for i in range(m):
        row_ls=list(map(int,input().split()))
        
        B.append(row_ls)
        
    C=[[0 for j in range(l)] for i in range(n)]
    
    for i in range(n):
        for j in range(l):
            for k in range(m):
                C[i][j]+=A[i][k]*B[k][j]
                
    
    for i in range(n):
        for j in range(l):
            if j!=l-1:
                print(f"{C[i][j]} ",end="")
            else:
                print(f"{C[i][j]}")

run()


Measured memory_bytes: 7088
n,m=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]

a=[]
for i in range(n+1):
	a.append([0])

for i in range(m):
	x,y=[int(x) for x in input().split()]
	if a[x][0]!=-1 and h[x-1]>h[y-1]:
		a[x].append(y)
	else:
		a[x]=[-1]

	if a[y][0]!=-1 and h[y-1]>h[x-1]:
		a[y].append(x)
	else:
		a[y]=[-1]

ans=0
for i in range(1,n+1):
	if a[i][0]!=-1:
		ans+=1
print(ans)

Measured memory_bytes: 26572
import heapq as hq

X, Y, A, B, C = map(int,input().split())
p = list(map(int,input().split())); p.sort(); p.reverse()
q = list(map(int,input().split())); q.sort(); q.reverse()
r = list(map(int,input().split())); r.sort(); r.reverse()

pq1 = []; hq.heapify(pq1) # 昇順
for i in range(X):
    hq.heappush(pq1, p[i])
for i in range(Y):
    hq.heappush(pq1, q[i])
pq2 = []; hq.heapify(pq2) # 降順で用いる
for i in range(C):
    hq.heappush(pq2, -r[i])
while (len(pq2) and pq1[0] < -pq2[0]):
    hq.heappush(pq1, -hq.heappop(pq2))
    hq.heappop(pq1) # 順序を変えてみた
print(sum(pq1))

Measured memory_bytes: 23216
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
using namespace std;

int main()
{
    int a, b, c; cin >> a >> b >> c;
    string ans = "No";
    if (a + b >= c) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int main()
{
	int H, N;
	int A[100010];
	cin >> H >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		H -= A[i];
	}
	if (H <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a[n + 1];
    long long b[n];
    for (int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    long long kill_num = 0;
    for (int i = 0; i < n; i++)
    {
        kill_num += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        kill_num += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }

    cout << kill_num << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

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

    long ans = 0;

    if(N%2 == 0){
        long t =5;
        while(N/t > 0){
            ans += N/t/2;
            t = t*5;
        }
    }else{
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=a+b+c;
    if(a==max(a,max(b,c)))
    {
        ans-=a;
        ans+=a*pow(2,k);
    }
    else if(b==max(a,max(b,c)))
    {
        ans-=b;
        ans+=b*pow(2,k);
    }
    else
    {
        ans-=c;
        ans+=c*pow(2,k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long s = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        sb.append("0 0 1000000000 1 ");
        int v = 1_000_000_000;
        long x = (v - s % v) % v;
        long y = (s + x) / v;
        sb.append(x);
        sb.append(" ");
        sb.append(y);
        System.out.println(sb);
    }

}


Measured memory_bytes: 35652
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	ll wat = 0;
	ll sug = 0;
	for (ll a = 0; 100*A*a <= F; a++) {
		for (ll b = 0; 100*A*a+100*B*b <= F; b++) {
			ll w = 100*A*a+100*B*b;
			if (w == 0) {
				continue;
			}
			for (ll c = 0; w+C*c <= F; c++) {
				if (E*w-100*C*c < 0) {
					continue;
				}
				ll d = min((F-w-C*c)/D, (E*w-100*C*c)/(100*D));
				ll s = C*c+D*d;
				if ((wat == 0 && sug == 0) || sug * (w + s) < s * (wat + sug)) {
					wat = w;
					sug = s;
				}
			}
		}
	}
	cout << wat+sug << " " << sug << endl;
}


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

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a+w<b){
        cout << b - a - w << endl;
        return 0;
    }
    if(a > b + w){
        cout << a - b - w << endl;
        return 0;
    }
    if(b<=a+w&&b>=a||a <= b+w &&a >= b){
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int res = 0;
		
		for(int i = 1; i <= n; i++) {
			if(i <= k) {
				res+=x;
			}else{
				res+=y;
			}
		}
		
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String [] input = sc.next().split(",");
			int [] data = new int[5];
			for(int i = 0 ; i < 5; i++){
				data[i] = Integer.parseInt(input[i]);
			}
			Arrays.sort(data);
			//System.out.println(Arrays.toString(data));
			if(isfour(data)){
				System.out.println("four card");
			}
			else if(isfull(data)){
				System.out.println("full house");
			}
			else if(isstraight(data)){
				System.out.println("straight");
			}
			else if(isthree(data)){
				System.out.println("three card");
			}
			else if(istwo(data)){
				System.out.println("two pair");
			}
			else if(one(data)){
				System.out.println("one pair");
			}
			else{
				System.out.println("null");
			}
		}
	}

	private boolean one(int[] data) {
		for(int i = 0; i < 4; i++){
			if(data[i] == data[i+1]){
				return true;
			}
		}
		return false;
	}

	private boolean istwo(int[] data) {
		int count = 0;
		for(int i = 0; i < 4; i++){
			if(data[i] == data[i + 1]){
				count++;
			}
		}
		if(count == 2) return true;
		return false;
	}

	private boolean isthree(int[] data) {
		int count = 0;
		int max = 0;
		for(int i = 0; i < 4; i++){
			if(data[i] == data[i + 1]){
				count++;
				max = Math.max(max, count);
			}
			else{
				count = 0;
			}
		}
		if(max == 2){
			return true;
		}
		return false;
	}

	private boolean isstraight(int[] data) {
		for(int i = 0; i < 4; i++){
			if(data[i] + 1 != data[i+1]){
				if(i == 0 &&  data[0] == 1 && data[4] == 13){
					
				}
				else{
					return false;
				}
			}
		}
		return true;
	}
	
	private boolean isfull(int[] data) {
		if(data[0] == data[1] && data[1] == data[2] && data[3] == data[4]){
			return true;
		}
		if(data[0] == data[1] && data[2] == data[3] && data[3] == data[4]){
			return true;
		}
		return false;
	}

	private boolean isfour(int[] data) {
		int count = 0;
		int max = 0;
		for(int i = 0; i < 4; i++){
			if(data[i] == data[i + 1]){
				count++;
				max = Math.max(max, count);
			}
			else{
				count = 0;
			}
		}
		if(max == 3){
			return true;
		}
		return false;
	}

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

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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      mut s: chars,
    }

    use std::collections::VecDeque;
    let n = s.len();

    if n < 3 {
        println!("{}", 0);
        return;
    }


    let mut acnt = 0u64;
    let mut i = 0;
    let mut ans = 0u64;
    while i < n-2 {
        if s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C' {
            s[i+2] = 'A';
            ans += 1 + acnt;
            i = i+2;
        } else {
            if s[i] == 'A' {
                acnt += 1;
            } else {
                acnt = 0;
            }
            i += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                vll graph[MAX+5];
                void dfs(ll cur,ll c,vll &vis,vll &vec){
                        vis[cur]=1;
                        vec[cur]=c;
                        for(auto g:graph[cur])
                                if(!vis[g])
                                        dfs(g,c+1,vis,vec);
                }
                void solve(){
                        ll n,a,b;
                        cin>>n>>a>>b;
                        rep(i,0,n-1){
                                ll m,k;
                                cin>>m>>k;
                                graph[m].pb(k);
                                graph[k].pb(m);
                        }
                        vll vis(n+1,0);
                        vll store1(n+1,0);
                        dfs(a,0,vis,store1);
                        fill(all(vis),0);
                        vll store2(n+1,0);
                        dfs(b,0,vis,store2);

                        ll ans=0;
                        rep(i,1,n+1)
                                if(store2[i]>store1[i])
                                        ans=max(ans,store2[i]-1);

                        cout<<ans;
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //printf("Case #%d: ", i);
                                solve();
                         }
        return 0; 
}         
 

Measured memory_bytes: 12032
def main():
    n = int(input())
    a = list(map(int, input().split()))

    t = [0,0,0]

    total = 1
    for i in range(n):
        count = 0
        for j in range(3):
            if t[j] == a[i]:
                count +=1
        for j in range(3):
            if t[j] == a[i]:
                t[j] += 1
                break
        if count == 0:
            return 0
        total *= count
    return total%1000000007

if __name__ == "__main__":
    print(main())

Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin>>n;
    unordered_map<string, int> m;
    while(n--){
        string s;
        cin>>s;
        m[s]++;

    }
    cout<<"AC x "<<m["AC"]<<endl<<"WA x "<<m["WA"]<<endl<<
"TLE x "<<m["TLE"]<<endl<<
"RE x "<<m["RE"]<<endl;

}


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

int main()
{
   int n;
   cin>>n;
   int c[n],v[n];
   for(int i=0;i<n;i++)
      cin>>v[i];
   for(int i=0;i<n;i++)
      cin>>c[i];
   double div[n];
   for(int i=0;i<n;i++)
      div[i] = (double)v[i]/c[i];
   int sum{};
   for(int i=0;i<n;i++)
   {
      if(div[i]>=1)
         sum += v[i] - c[i];
   }
   cout<<sum;
   return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  cout << (n-1)*(m-1) << "\n";
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int count = 0;

	for(int i = 0; i < s.length(); i++){
		if(s[i] == t[i])count++;
	}
	

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = []
a = N//100
b = N//10-a*10
c = N - a*100 - b*10
A.append(a)
A.append(b)
A.append(c)
for i in range(3):
    if A[i]==1:
        A[i]=9
    elif A[i]==9:
        A[i]=1
print(A[0]*100+A[1]*10+A[2])

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

int main(){
	int z;
	int a=0;
	int b=0;
	while(1){
		std::cin>>z;
		if(z==0)break;
		std::vector<int> vec1(z);
		std::vector<int> vec2(z);
		for(int i=0;i<z;i++){
			std::cin>>vec1[i];
			std::cin>>vec2[i];
		}
		for(int i=0;i<z;i++){
			if(vec1[i]>vec2[i])a=a+vec1[i]+vec2[i];
			if(vec2[i]>vec1[i])b=b+vec1[i]+vec2[i];
			if(vec1[i]==vec2[i]){
				a=a+vec1[i];
				b=b+vec2[i];
			}
		}
		std::cout<<a<<" "<<b<<std::endl;
		a=0;
		b=0;
	}
	
	return 0;
}

Measured memory_bytes: 1272
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

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

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

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

int inside(point p, vector<point> ps){
  point a,b;
  a=b=p;

  b.x=1000000;

  int n=ps.size();
  ps.push_back(ps[0]);

  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<n;i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;
  
  for(int i=0;i<n;i++){
    if(is_point_on_line(ps[i],ps[i+1],p))return 0;
  }
  
  int cnt1=0;
  for(int i=0;i<n;i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;
  
  int cnt=0;
  for(int i=0;i<n;i++)
    if(is_intersected_ls(ps[i],ps[i+1],a,b))cnt++;
  
  return (cnt-cnt1)%2;
}

int main(void){
 
  point in[4],p;
  vector<point>ps;

  while(cin>>in[1].x>>in[1].y>>in[2].x>>in[2].y>>in[3].x>>in[3].y>>p.x>>p.y){

    ps.clear();

    for(int i=1;i<4;i++)
    ps.push_back(in[i]);

    if(inside(p,ps))cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import numpy as np
from collections import Counter

# 最頻値
def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n = int(input())
a_list = list(map(int, input().split()))
bit = 0
a_list.sort()
for i in range(n - 1):
  if a_list[i] == a_list[i + 1]:
    bit = 1
    print("NO")
    break
if bit == 0:
  print("YES")

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

const int N = 200001;
vector<vector<int> > G(N);
vector<vector<int> > dist(2, vector<int>(N, -1));

void bfs(int s){
  int c = (s == 1 ? 0 : 1);

  queue<int> q;
  q.push(s);
  dist[c][s] = 0;
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(int i = 0; i < G[p].size(); i++){
      int v = G[p][i];
      if(dist[c][v] == -1){
        dist[c][v] = dist[c][p] + 1;
        q.push(v);
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  bfs(1);
  bfs(n);

  int f = 0, s = 0;
  for (int i = 1; i <= n; i++) {
    if (dist[0][i] <= dist[1][i]) {
      f++;
    } else {
      s++;
    }
  }
  if (f > s) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}

Measured memory_bytes: 9840
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
typedef vector<string> Vs;

set<int> S;
int res;

int main(){
	for (int n=IN();n--;) S.insert(IN());
	res=S.size();
	if (res%2==0) res--;
	printf("%d\n",res);
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	int a = 1;
	REP(i, n) {
		if (v[i] == 0)a = 0;
	}
	if (a) {
		cout << 0 << endl;
		return 0;
	}
	FOR(i, 1, INF) {
		int flag = 0;
		REP(j, n) {
			int sum = 0;
			REP(k, log10(i)+EPS) {
				if (j + k < n) {
					sum = sum * 10 + v[j + k];
				}
			}
			if (sum == i) {
				flag = 1;
				break;
			}
		}
		if (!flag) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		vector<int> v;
		for(int i = 1; i <= n; i++)
			v.push_back(i);
		int cp=0;
		m--;
		while(1){
			if(v.size()==1)
				break;
			else{
				int nidx=(cp+m)%(v.size());
				cp=nidx;
				vector<int> nv;
				for(int i = 0; i < v.size(); i++){
					if(i!=nidx){
						nv.push_back(v[i]);
					}
				}
				if(nidx==v.size()-1)
					nidx=1;

				v=nv;
			}
		}
		cout<<v[0]<<endl;
	}

	return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  sort(as.begin(), as.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x < as[i]) {
      break;
    }
    x -= as[i];
    ans++;
  }
  if (x && ans == n) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}

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

double dp[301][301][301];

void solve() {
    int N; cin >> N;
    map<int, int> cnt;
    rep(i, N) {
        int s; cin >> s;
        cnt[s]++;
    }
    auto f = [&](auto &&f, int a, int b, int c) -> double {
        if(a + b + c == 0) return 0;
        if(dp[a][b][c]) return dp[a][b][c];
        double p = 1.0 - double(N - a - b - c) / N;
        double ret = 1.0 / p;
        if(a) ret += f(f, a - 1, b, c) * a / N / p;
        if(b) ret += f(f, a + 1, b - 1, c) * b / N / p;
        if(c) ret += f(f, a, b + 1, c - 1) * c / N / p;
        return dp[a][b][c] = ret;
    };
    cout << fixed << setprecision(15) << f(f, cnt[1], cnt[2], cnt[3]) << '\n';
}

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


Measured memory_bytes: 111212