akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  int N, K, ans;
  cin >> N;
  cin >> K;
  
  int x;
  for (int i = 0; i < N; i++){
    cin >> x;
    if (x <= (K/2)) ans += (x*2);
    else ans += abs((K-x)*2);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    ll fin = 1;
    REP(i,K){
        fin = 1;
        vector<ll> imos(N);
        REP(l,N){
            imos[max(ll(0),l - A[l])]++;
            if(l + A[l] + 1 < N)imos[l + A[l] + 1]--;
        }
        ll im = 0;
        REP(l,N){
            im += imos[l];
            A[l] = im;
            if(A[l] != N)fin = 0;
        }
        if(fin)break;
    }
    REP(i,N)cout << A[i] << "\n";
}

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

int main()
{
  int n, m, l;
  int i, j, k;
  cin >> n >> m >> l;

  long long a[n][m], b[m][l], c[n][l];

  //zero
    
  for(i = 0; i < n; i++)
  {
    for(j = 0; j < m; j++)
    {
      a[i][j] = 0;
    }
  }

  for(j = 0; j < m; j++)
  {
    for(k = 0; k < l; k++)
    {
      b[j][k] = 0;
    }
  }

  for(i = 0; i < n; i++)
  {
    for(j = 0; j < l; j++)
    {
      c[i][j] = 0;
    } 
  }

  //in

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

  //calculate

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < l; j++)
    {
      for(int k = 0; k < m; k++)
      {   
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  //out

  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < l; j++)
    {
      cout << c[i][j];
    
      if(j == l - 1)
      {
        cout << endl;
      }
      else
      {
        cout << " ";
      }
    }
  }

  return 0; 
}


Measured memory_bytes: 3316
/**Which of the favors of your Lord will you deny ?**/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define F first
#define S second
#define INF INT_MAX

#define ALL(x) (x).begin(), (x).end()
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl

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

template<class TIn>
using indexed_set = tree<
                    TIn, null_type, less<TIn>,
                    rb_tree_tag, tree_order_statistics_node_update>;

/*
PBDS
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // 0 based indexing
4) *find_by_order(position) // 0 based indexing

*/

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;
const LL LINF = 1e17;

string to_str(LL x)
{
    stringstream ss;
    ss<<x;
    return ss.str();
}

//bool cmp(const PII &A,const PII &B)
//{
//
//}

map<int,int>posa;
map<int,int>posb;

int main()
{
    optimizeIO();

    int n;
    cin>>n;

    vector<int>a(n);

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

    vector<int>b = a;

    sort(ALL(b));

    for(int i=0;i<n;i++)
    {
        posa[a[i]] = i;
        posb[b[i]] = i;
    }

    int cnt = 0;

    for(int i=0;i<n;i++)
    {
        int val = a[i];

        int pa = posa[val];
        int pb = posb[val];

        if(abs(pa-pb)%2==1)
            cnt++;
    }

    cout<<cnt/2<<endl;

    return 0;
}




Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
vector<ll> fruit;

int main() {
  //
  int N, K;
  cin >> N >> K;
  rep(i, 0, N) {
    int a;
    cin >> a;
    fruit.push_back(a);
  }
  sort(fruit.begin(), fruit.end());

  ll ans = 0;
  rep(i, 0, K) { ans += fruit[i]; }

  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x=0,n,a[100];
  cin>>n;
  for(int i = 0 ; i < n; i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
      int tmp;
      if(a[j]<a[j-1]){
	tmp=a[j-1];
	a[j-1]=a[j];
	a[j]=tmp;
	x++;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl<<x<<endl;
  return 0;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  int count_1=0, count_2=0, count_3=0, count_4=0;
  
  string S; cin >> S;
  rep(i, S.size()) {
    if(S[i]=='N') count_1++;
    else if(S[i]=='S') count_2++;
    else if(S[i]=='E') count_3++;
    else count_4++;
  }
 
    
   if((count_1!=0 && count_2!=0 && count_3!=0 && count_4!=0) || (count_1!=0 && count_2!=0 && count_3==0 && count_4==0) || (count_1==0 && count_2==0 && count_3!=0 && count_4!=0))
     cout << "Yes" << endl;
   else cout << "No" << endl;
  }

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

using namespace std;

const int maxN = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[maxN + 1], b[maxN + 1], c[maxN + 1];
main() {
    int n = readInt();
    for(int i = 1; i <= n; i++)
        a[i] = readInt();
    for(int i = 1; i <= n; i++)
        b[i] = readInt();
    for(int i = 1; i <= n; i++)
        c[i] = readInt();
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    sort(c + 1, c + n + 1);
    int hi1, lo1, hi2, lo2;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        lo1 = 0, hi1 = n + 1;
        lo2 = 0, hi2 = n + 1;
        int x = b[i];
        while(hi1 - lo1 > 1) {
            int mid = (hi1 + lo1) >> 1;
            if(a[mid] < x)
                lo1 = mid;
            else
                hi1 = mid;
        }
        while(hi2 - lo2 > 1) {
            int mid = (hi2 + lo2) >> 1;
            if(c[mid] <= x)
                lo2 = mid;
            else
                hi2 = mid;
        }
        int p1 = lo1, p2 = lo2 + 1;
//        cout << p1 << " " << p2 << endl;
        if(p1 >= 1 && p1 <= n && p2 >= 1 && p2 <= n) {
            ans += p1 * (n - p2 + 1);
        }
    }
    cout << ans;
}


Measured memory_bytes: 2560
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
g = [[] for _ in range(n)]
for i in range(m):
    z,x = inpl()
    g[z-1].append(x-1)
    g[x-1].append(z-1)
res = 0
# print(g)
for i in range(n):
    ok = True
    for v in g[i]:
        if a[v] >= a[i]:
            ok = False
    if ok:
        # print(i)
        res += 1
print(res)

Measured memory_bytes: 100496
# N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp

if S == 'A'
  print "T\n"
elsif S == 'T'
  print "A\n"
elsif S == 'C'
  print "G\n"
else # S == 'G'
  print "C\n"
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

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

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String[] ary = new String[3];
    	for(int i = 0; i < 3; i++){
    		ary[i] = sc.next();
		}

    	System.out.println(ary[0].substring(0, 1) + ary[1].substring(1, 2) + ary[2].substring(2, 3));
    }

}


Measured memory_bytes: 22100
#include <iostream>
#include <cstring>
using namespace std;
char a[105][105];
int n,m;
int dx[8]={-1,0,1,1,1,0,-1,-1};
int dy[8]={-1,-1,-1,0,1,1,1,0};
int search(int x,int y)
{
	int ans=0;
	for(int i=0;i<8;i++)
	{
		if(x+dx[i]>=0&&x+dx[i]<n&&y+dy[i]>=0&&y+dy[i]<m&&a[x+dx[i]][y+dy[i]]=='#')
		{
			ans++;
		}
	}
	return ans+'0';
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		string b;
		cin>>b;
		for(int j=0;j<m;j++)
		{
			a[i][j]=b[j];
		}
	}
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	{	if(a[i][j]!='#')
		a[i][j]=search(i,j);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cout<<a[i][j];
			
		}
		cout<<endl;
	}
		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, m, x; cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> cost(n);
    for(int i = 0; i < n; i++) {
        cin >> cost[i];
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = mod;
    for(int msk = 0; msk < (1 << n); msk++) {
        vector<int> sum(m);
        int tot = 0;
        for(int i = 0; i < n; i++) {
            if((msk >> i) & 1) {
                tot += cost[i];
                for(int j = 0; j < m; j++) {
                    sum[j] += a[i][j];
                }
            }
        }
        bool can = 1;
        for(int j = 0; j < m; j++) {
            if(sum[j] < x) {
                can = 0;
                break;
            }
        }
        if(can) ans = min(ans, tot);
    }
    if(ans == mod) ans = -1;
    cout << ans << "\n";
    




    return 0;
    
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<bool>>;
const int MOD = 1e9 + 7;

bool isreachable(int s, int t, queue<int> &cnt) {
    unordered_set<int> st;
    st.insert(s);
    while (!cnt.empty()) {
        int i = cnt.front();
        cnt.pop();
        unordered_set<int> sttmp;
        for (auto j : st) {
            sttmp.insert(j + i);
            sttmp.insert(j - i);
        }
        swap(st, sttmp);
    }
    return st.find(t) != st.end();
}

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

    string s;
    int x, y;
    cin >> s >> x >> y;

    bool h = true;
    int cnt = 0;
    queue<int> hcnt, vcnt;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'T') {
            (h ? hcnt : vcnt).push(cnt);
            h ^= 1;
            cnt = 0;
            continue;
        }
        cnt++;
    }
    if (cnt > 0)
        (h ? hcnt : vcnt).push(cnt);

    int ix = hcnt.front(), iy = 0;
    hcnt.pop();

    bool isok = isreachable(ix, x, hcnt) & isreachable(iy, y, vcnt);
    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}


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

typedef long long ll;

const int Maxn = 200005;

char str[Maxn];
int slen;
ll res;

int main()
{
    scanf("%s", str); slen = strlen(str);
    int cnt = 0;
    int pnt = slen - 1;
    while (pnt >= 0)
        if (str[pnt] == 'A') { res += cnt; pnt--; }
        else if (pnt >= 1) {
            if (str[pnt - 1] == 'B' && str[pnt] == 'C') { cnt++; pnt -= 2; }
            else { cnt = 0; pnt--; }
        } else break;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double lxd;
typedef vector<ll> vll ;
 
#define INF (ll)1e11 + 7 
#define mem(dp,a) memset(dp,a,sizeof dp)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) ;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define fo(i,n,x) for (ll i=x;i<=n  ;i++)
#define mp(a,b) push_back(make_pair(a,b))
#define pb(x) push_back(x)
#define make_graph(a,b) adj[a].pb(b) ; adj[b].pb(a);
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t; cin>>t; label: while(t--)
#define fls fflush(stdout)
#define F first
#define S second

vll arr(100001);
vll dp(100001,-1) ;

ll fn(ll id){
    if(id == 0)return 0 ;
    
    if(dp[id] != -1)return dp[id] ;
    
    return dp[id] = min(abs(arr[id] - arr[max(0ll, id - 1)]) + fn(max(0ll, id - 1))
                    ,abs(arr[id] - arr[max(0ll, id - 2)]) + fn(max(0ll, id - 2))) ;
}

main(){
    ll n ; 
    cin>>n ; 
    f(i,n)cin>>arr[i] ;
    cout<<fn(n-1) ;
}

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

int main()
{
    cin.tie(0);

    int64_t n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    n--;

    a *= 2;
    b *= 2;
    c *= 2;
    d *= 2;

    int64_t x = abs(a - b);

    if (x > d * n) {
        cout << "NO" << endl;
        return 0;
    }

    int64_t e = (c + d) / 2;
    int64_t dist = -1;

    if (n % 2 == 0) {
        dist = x % (2 * e);
        dist = min(dist, 2 * e - dist);
    } else {
        dist = (x + e) % (2 * e);
        dist = min(dist, 2 * e - dist);
    }

    int64_t r = n * (d - c) / 2;

    // cerr << dist << ", " << e << ", " << r << endl;

    cout << (dist <= r ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
$N = (int)fgets(STDIN);
$As = array_map('intval', explode(' ', trim(fgets(STDIN))));

$odd = 1;
foreach ($As as $A) {
    if ($A % 2 == 0) {
        $odd *= 2;
    }
}

$ans = 3**$N - $odd;

echo "$ans\n";

Measured memory_bytes: 3956
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int H = sc.nextInt();
    int W = sc.nextInt();

    String[][] a = new String[H][W];

    for (int i = 0; i < H; i++) {
      String a_ = sc.next();
      a[i] = a_.split("");
    }

    sc.close();

    for (int i = 0; i < H; i++) {
      
      boolean isShow = false;

      for (int j = 0; j < W; j++) {

        boolean h = false;
        boolean w = false;

        for (int k = 0; k < H; k++) {
          if (a[k][j].equals("#")) {
            h = true;
          }
        }

        for (int k = 0; k < W; k++) {
          if (a[i][k].equals("#")) {
            w = true;
          }
        }

        if (h == true && w == true) {
          System.out.print(a[i][j]);
          isShow = true;
        }

      }

      if (isShow == true) {
        System.out.println("");
      }

    }

  }

}

Measured memory_bytes: 25916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
long long gcd(long long a, long long b){
    if(b==0) return a;
    return gcd(b, a%b);
}
long long K;
string s; 
int main() {
    cin >> s >> K;
    if(K==1) cout << s[0] << endl;
    else{
        for(int i=1; i<=s.size(); ++i){
            if(s[i-1]!='1') {
                cout << s[i-1] << endl;
                break;
            }
            if(i==K){
                cout << s[i-1] << endl;
                break;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long x,y,g=1,i,N=1000000000000000000;
	int flag=0;
	cin>>x>>y;
	if (x%y==0) flag=0;
	else for (i=2;g<N;i++) {
		g=i*x;
		if (g%y!=0) {
			flag=1;
			break;
		}
	} 
	if (flag)	cout<<g<<endl;
	else		cout<<"-1"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/ 7
// Problem:ABC 077 SnukeFestival c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N, tmp;
  cin >> N;
  vector< int > A(N);
  vector< int > B(N);
  vector< int > C(N);
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> B[i];
  }
  REP(i, N) {
    cin >> C[i];
  }

  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));

  ll ans = 0ll;
  // O(NlogN)
  REP(i, N) {
    ll tmp1 = lower_bound(ALL(A), B[i]) - A.begin();
    ll tmp2 = N - (upper_bound(ALL(C), B[i]) - C.begin());
    ans += tmp1 * tmp2;
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1536
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = (arg[1].split(" ")[0]);
    const T = (arg[1].split(" ")[1]);
    
    let answer = [];
    
    for(let i=0; i<N; i++) {
        answer.push(S[i]);
        answer.push(T[i]);
    }
    
    console.log(answer.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21956
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int A,B;
	cin >>A>>B;
	int an = -1;
	if (A<2*B) {
		A=0;
		B = 0;
	}
	cout << A-2*B<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<utility>
using namespace std;
 
typedef long long ll;
 
int main(){
	ll A,B,M;
    cin >> A >> B >> M;
    ll ans[2];
    ans[0]=100007;
    ans[1]=100007;

    ll a[A],b[B];
    for(int i=0; i<A; i++){
    	cin >> a[i];
        if(ans[0]> a[i]) ans[0] = a[i];
      
    }
    for(int i=0; i<B; i++){
    	cin >> b[i];
        if(ans[1]> b[i]) ans[1] = b[i];
    }
    ll answer= ans[0]+ans[1];
  	ll p,q,r;
    for(int i=0; i<M; i++){
    	cin >> p >> q >> r;
        if(a[p-1]+b[q-1]-r < answer){
        	answer = a[p-1]+b[q-1]-r;
        }
    }
    cout << answer << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
typedef long double ld;
#define pi 3.14159265358979

int  main()
{
	int w, h, n; cin >> w >> h >> n;
	int Xs = 0;
	int Xe = w;
	int Ys = 0;
	int Ye = h;
	rep(i, n)
	{
		int x,y,a;
		cin >> x >> y >> a;
		if (a == 1)
		{
			if (Xs < x)
			{
				// if (Xs < Xe)
					Xs = x;
				// else
				// 	Xs = Xe;
			}
		}
		if (a == 2)
		{
			if (Xe > x)
			{
				// if (Xe > Xs)
					Xe = x;
				// else
				// 	Xe = Xs;
			}
		}
		if (a == 3)
		{
			if (Ys < y)
			{
				// if (Ys < Ye)
					Ys = y;
				// else
				// 	Ys = Ye;
			}
		}
		if (a == 4)
		{
			if (Ye > y)
			{
				// if (Ye > Ys)
					Ye = y;
				// else
				// 	Ye = Ys;
			}
		}
	}
	int X = Xe - Xs;
	int Y = Ye - Ys;
	if (X < 0)
		X = 0;
	if (Y < 0)
		Y = 0;
	cout << X * Y << endl;
	return 0;
}


Measured memory_bytes: 256
# https://www.youtube.com/watch?v=-ZvzikEQkPY
# bit全探索
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
result = 0
"""
bit全探索
1<<HOGE=2^HOGE
根元事象が2のコインのようなものが得意
"""


for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        # bitが1になっているか2重ループで探索
        # 赤なら黒ではないからcontinue
        # それ意外ならblackカウンタインクリメント
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                if c[i][j] == "#":
                    black += 1
        if black == K: # ループのなかで条件に合う場合をカウントする
            result += 1

print(result)


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

using namespace std;

int a,b,c;

#define X abs(a-b)
#define Y abs(b-c)
#define Z abs(a-c)

int main(int argc,char ** argv)
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    cout<<min(X+Y,min(X+Z,Y+Z))<<endl;
    return 0;
}

Measured memory_bytes: 256
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



#include<bits/stdc++.h>
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<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


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

int main()
{
	optimize();

	int d = 7;
	int k;
	cin >> k;
	int n = 1e6;
	for ( int i = 1; i <= n; i++ ) {
		if (d % k == 0) {
			return cout << i << endl, 0;
		}

		d %= k;
		d *= 10;
		d += 7;
	}

	cout << "-1";

	return 0;
}


















Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const int LIM = 200050;
Int MO = 1000000007;
Int fact[200050], inv[200050], finv[200050];
vector<vector<int>> A;

Int comb(int n, int r) {
  return fact[n] * finv[r] % MO * finv[n - r] % MO;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < LIM; ++i) {
    inv[i] = MO - MO / i * inv[MO % i] % MO;
  }
  fact[0] = 1;
  finv[0] = 1;
  for (int i = 1; i < LIM; ++i) {
    fact[i] = fact[i - 1] * i % MO;
    finv[i] = finv[i - 1] * inv[i] % MO;
  }

  int N = in();
  Int X = in();
  Int Y = in();
  A.resize(N);
  for (int i = 0; i < N; ++i) {
    int c = in() - 1;
    int w = in();
    A[c].push_back(w);
  }

  int w = INF, windex = -1, w2 = INF;
  for (int i = 0; i < N; ++i) {
    if (!A[i].empty()) {
      int m = *min_element(A[i].begin(), A[i].end());
      if (w > m) {
        w2 = w;
        w = m;
        windex = i;
      } else if (w2 > m) {
        w2 = m;
      }
    }
  }

  int tot = 0;
  vector<int> num;
  for (int i = 0; i < N; ++i) {
    if (A[i].empty()) {
      continue;
    }
    int m = *min_element(A[i].begin(), A[i].end());
    int w0 = windex == i ? w2 : w;
    int c = 0;
    for (const int a : A[i]) {
      if (a + w0 <= Y || (m + a <= X && m + w0 <= Y)) {
        ++c;
      }
    }
    tot += c;
    num.push_back(c);
  }

  Int R = 1;
  for (const int k : num) {
    (R *= comb(tot, k)) %= MO;
    tot -= k;
  }

  printf("%lld\n", R);

  return 0;
}


Measured memory_bytes: 15100
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,m,x,y;
	int x1[105],y1[105];
	int max1=0,min1=0;
	cin >> n >> m >> x >> y;
	for(int i=0;i<n;i++){
		cin >> x1[i];
	}
	for(int i=0;i<m;i++){
		cin >> y1[i];
	}

	sort(x1,x1+n);
	sort(y1,y1+m);
	max1=x1[n-1];
	min1=y1[0];
	for(int i=x+1;i<y+1;i++){
		if(i>max1&&i<=min1){
			cout<<"No War"<<endl;
			return 0;
		}
	}

	cout<<"War"<<endl;

}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(void){
 
    int K, S;
    int ans = 0;
    int Z;
    cin >> K >> S;
    
    for(int X = 0; X <= K; X++){
        for(int Y = 0; Y <= K ;Y++){
            Z = S - (X + Y);
            if(Z <= K && Z >= 0 && X + Y + Z == S){
                //cout << "X = " << X << ", Y = " << Y << ", Z = " << Z << ", S = " << X + Y + Z << endl;
                ans++;
            }
        }
    }
    
    cout << ans << endl;
    
}


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


int main(){
    
    int W,H,N,x[110],y[110],a[110];
    cin>>W>>H>>N;
    rep(i,0,N){
        cin>>x[i]>>y[i]>>a[i];
    }
    int MINx=0,MAXx=W,MINy=0,MAXy=H;
    rep(i,0,N){
        if(a[i]==1)MINx=max(MINx,x[i]);
        else if(a[i]==2)MAXx=min(MAXx,x[i]);
        else if(a[i]==3)MINy=max(MINy,y[i]);
        else if(a[i]==4)MAXy=min(MAXy,y[i]);
    }
    if(MAXx>MINx&&MAXy>MINy)cout<<(MAXx-MINx)*(MAXy-MINy)<<endl;
    else cout<<0<<endl;
}






Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            if (a < c && c < b && a < b) {
                System.out.println("Yes");
            } else if (a > c && c > b && a > b) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
void solve () {
    string s;
    cin >> s;
    char r = s[0];
    int ans = 0;
    int n = (int) s.size();
    for (int i = 1; i < n; i++) {
        if (r != s[i]) {
            ans++;
            r = s[i];
        }
    }
    cout << ans;

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


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  set<PL> rabbit;
  rep(i,n){
    int a,b=i+1;
    cin>>a;
    if(a>b)swap(a,b);
    rabbit.insert({a,b});
  }
  out(n-SZ(rabbit));
  
  
  return 0;
}



Measured memory_bytes: 6528
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
bool AC[100000] ={};
int score = 0;
int pena[100000] ={};

signed main(){
	cin >> N >> M;
	rep(i, M){
		int p;
		string S;
		cin >> p >> S;
		p--;
		if(AC[p]) continue;
		if(S == "AC"){
			AC[p] = true;
			score++;
		}
		else pena[p]++;
	}
	cout << score << " ";
	int p = 0;
	rep(i, N)
		if(AC[i]) p += pena[i];
	cout << p << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B;
  cin >> A >> B;
  if (abs(A - B) >= 1)
    cout << 2 * max(A, B) - 1 << '\n';
  else
    cout << 2 * max(A, B) << '\n';
  return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/23.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int h,w,k;
    cin>>h>>w>>k;
    int str[305][305];
    memset(str,0,sizeof(str));
    int ans[305][305];
    int abc[305][305];
    memset(ans,0,sizeof(ans));
    memset(abc,0,sizeof(abc));
    int m=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='#'){
                str[i][j]=1;
                m++; ans[i][j]=m;
                abc[i][j]=2;
                if(m==k)
                    break;
            }
        }
        if(m==k)
        break;
    }
    for(int i=0;i<h;i++){
        for(int j=1;j<w;j++){
            if(ans[i][j-1]&&!ans[i][j])
                ans[i][j]=ans[i][j-1];
        }
        for(int j=w-2;j>=0;j--){
            if(ans[i][j+1]&&!ans[i][j])
                ans[i][j]=ans[i][j+1];
        }
    }
    for(int j=0;j<w;j++){
        for(int i=1;i<h;i++){
            if(ans[i-1][j]&&!ans[i][j])
                ans[i][j]=ans[i-1][j];
        }
        for(int i=h-2;i>=0;i--){
            if(ans[i+1][j]&&!ans[i][j])
                ans[i][j]=ans[i+1][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j];
            if(j!=w-1)
                cout<<" ";
        }
        cout<<endl;
    }
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

const int MAX = 3005;
ll dp[MAX][MAX];

void solve(){
    mod =  998244353;
    ll n,s;
    cin>>n>>s;
    ll ans=0;
    ll a[n+1];
    dp[0][0] = 1;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        memcpy(dp[i],dp[i-1] ,sizeof dp[0]);
        (dp[i][a[i]] += i)%=mod;
        for(ll j=1;j+a[i] <= s ; j++){
            (dp[i][j+a[i]] += dp[i-1][j])%= mod;
        }
        ans += dp[i][s];
        ans %= mod;
    }
    cout << ans << endl;
}

int main(){
    
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 70784
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    e = sum(v % 2 == 0 for v in c.values())
    ans = len(c.keys()) - (e % 2)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88528
#include <iostream>
#include <bitset>

using namespace std;

const int MAX = 2e3+10;
int N;
bitset<MAX*MAX> bs;

int main() {
    bs = 1;
    cin >> N;
    int s = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        bs |= (bs<<a);
        s += a;
    }
    
    for (int i = (s+1)/2; i <= s; i++) {
        if (bs[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    ll ans=0;
    vl X(N),Y(M);
    ll resx=0,resy=0;
    rep(i,N){
        cin >> X[i];
        resx+=X[i]*(N-1-2*i);
        resx%=MOD;
    }
    rep(i,M){
        cin >> Y[i];
        resy+=Y[i]*(M-1-2*i);
        resy%=MOD;
    }
    ans=(resx*resy+MOD)%MOD;
    cout << ans << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 4752
N=int(input())
A=list(map(int,input().split()))
count_4=0
count_2=0
count_1=0
for i in A:
    if i%4==0:
        count_4+=1
    elif i%2==0:
        count_2+=1
    else:
        count_1+=1
if count_2<2:
    if count_1+count_2-1<=count_4:
        print("Yes")
    else:
        print("No")
else:
    if count_1<=count_4:
        print("Yes")
    else:
        print("No")

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

int N;

int main() {
    cin >> N;
    long long target_num = floor(pow(N, 0.5));
    // cout << target_num << endl;
    // printf("%d\n", pow(target_num, 2.0));
    cout << target_num * target_num << endl;
}

Measured memory_bytes: 384
def nexts(X,Xs,Y,Ys):
    Z = (X+Y)//2
    print('{}\n'.format(Z))
    Zs = input()
    if Zs == 'Vacant':
        sys.exit()
    if (Xs == Zs and (Z-X)%2 == 1)\
    or (Xs != Zs and (Z-X)%2 == 0):
        Y, Ys = Z, Zs
    else:
        X, Xs = Z, Zs
    return X,Xs,Y,Ys

import sys

N = int(input())
print('0\n')
xs = input()
if xs == 'Vacant':
    sys.exit()
print('{}\n'.format(N-1))
ys = input()
if ys == 'Vacant':
    sys.exit()
x, y = 0, N-1
while True:
    x,xs,y,ys = nexts(x,xs,y,ys)

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

int main() {
int a,b,c;
  cin >> a>>b>>c;
  if(a!=b && a!=c &&b==c)cout <<"Yes"<<endl;
  else if(b!=a && b!=c &&a==c)cout <<"Yes"<<endl;
  else if(c!=a && c!=b &&a==b)cout <<"Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin


def generate_adj_table(v_table):
    for each in v_table:
        start, end, weight = map(int, each)
        init_adj_table[start][end] = weight

    return init_adj_table


def floyd():
    for k in _range:
        for i in _range:
            for j in _range:
                adj_table[i][j] = min(adj_table[i].get(j, float("INF")),
                                      adj_table[i].get(k, float("INF")) + adj_table[k].get(j, float("INF")))
    return adj_table


def solve():
    ans = floyd()
    negative = False
    for m in range(vertices):
        if ans[m][m] < 0:
            negative = True

    if negative:
        print('NEGATIVE CYCLE')
    else:
        for a in _range:
            print(*(str(each[-1]).upper() for each in sorted(ans[a].items())))

    return None


if __name__ == '__main__':
    _input = stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    info_list = map(lambda x: x.split(), _input[1:])
    _range = range(vertices)

    init_adj_table = tuple({i: 0} for i in range(vertices))
    adj_table = generate_adj_table(info_list)
    solve()

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  string S;
  cin>>S;
  int A[26]={0};
  if(S=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
  else if(S.size()==26){
    rep(i,25){
      if(S[24-i]<S[25-i]){
        rep(j,25){
          if(S[24-i]<S[25-j]){
            S+=S[25-j];
            break;
          }
        }
        S.erase(24-i,i+2);
        cout<<S<<endl;
        break;
      }
    }
  }else{
    rep(i,S.size()) A[S[i]-'a']++;
    rep(i,26){
      if(!A[i]){
        cout<<S<<char('a'+i)<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	long long int n;
	cin>>n;
	long long int temp1=0, temp2=0;
	while(n)
	{
		if(n%10==1)
			temp1+=9;
		else
			temp1+=1;
		n/=10;
		temp1*=10;
	}
	temp1/=10;
	while(temp1)
	{
		temp2+=(temp1%10);
		temp1/=10;
		temp2*=10;
	}
	temp2/=10;
	cout<<temp2<<endl;
return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int used = 0;
    for(int i = 0, j = 1; i < n; i++) {
        if(a[i] == j) {
            used++;
            j++;
        }
    }
    if(used == 0) {
        cout << -1 << endl;
    } else {
        cout << n - used << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
// Problem : C - Traveling Salesman around Lake
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " | ";
	err(++it, args...);
}

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll ans = inf;
		ll n,k;
		cin>>k>>n;
		
		ll a[n];
		forn(i,0,n)
		{
			cin>>a[i];
		}
		
		vector<ll>d;
		ll cnt = 0;
		ll sum = 0;
		forn(i,1,n)
		{
			d.pb(a[i]-a[i-1]);
			sum += a[i]-a[i-1];
		}
		
		d.pb(k-(a[n-1]-a[0]));
		sum += k-(a[n-1]-a[0]);
		
		forn(i,1,n)
		{
			ans = min(ans,sum-(a[i]-a[i-1]));
			
		}
		
		ans = min(ans,sum - (k-(a[n-1]-a[0])));
		
		forn(i,0,n-1)
		{
			ans = min(ans,sum - (a[i+1]-a[i]));
		}
		
		cout<<ans;
	}

	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin >> s >> k;
    rep (i, s.size()) {
        if (i != s.size() - 1) {
            if (k < 26 - (s[i] - 'a') % 26) continue;
            k -= (26 - (s[i] - 'a')) % 26;
            s[i] = 'a';
        } else {
            s[i] = 'a' + (s[i] - 'a' + k) % 26;
        }
    }
    cout << s << endl;
    
    return 0;
}



Measured memory_bytes: 592