akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}
/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
int a=0, b=0, c = 0;

int main(void) {
	Rapid;

	string s;
	cin >> s;
	int cnt1 = 0, cnt2 = 0;
	rep(i, s.size()) {
		if (s[i] == '0')cnt1++;
		else cnt2++;
	}
	cout << 2 * min(cnt1, cnt2) << rt;

	please AC;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  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];
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += max(0, V[i] - C[i]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 2;


int main(){
  int N, M;
  cin>>N>>M;
  vector<vector<int>> v(M, vector<int>(N+1));
  vector<int> k(M);
  vector<int> p(M);
  rep(i, M) {
    cin>>k[i];
    rep(j, k[i]) {
      cin>>v[i][j];
    }
  }
  rep(i, M) cin>>p[i];

  int ans = 0;
  for(int i=0; i<(1<<N); i++) {
    bool f = true;
    for(int j=0; j<M; j++) {
      int num = 0;
      for(int l=0; l<k[j]; l++) {
	if(i>>(v[j][l]-1) & 1) {
	  num++;
	}
      }
      f = f and (num % 2 == p[j]);
    }
    if(f) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int ans = 0;

            for (int i = 1; i <= n; i++) {
                if (Integer.toString(i).length() % 2 != 0) ++ans;
            }
            // 出力
            out.println(ans);
        }

    }
}



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

const int N = 200005;
const long long MOD = 1000000007;
long long sum[N], a[N];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	for (int i = n; i; --i)
		sum[i] = (sum[i + 1] + a[i]) % MOD;
	long long ans = 0;
	for (int i = n - 1; i; --i)
		ans = (ans + (a[i] * sum[i + 1])) % MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 6744
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <sstream>

using namespace std;

int N;

int main(){
    
    cin >> N;
    
    int t = N, k = 0;
    
    while(t > 0) k += t % 10, t /= 10;
    
    if(N % k == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
NK=input()
ListNK=NK.split() #ListNK[0]=N,[1]=K
N=int(ListNK[0])
K=int(ListNK[1])
Listh=[]
ListQ=[]
for i in range(0,N,1):
  hi=int(input())
  Listh.append(hi)

Listh.sort() #Listhの要素を小さい順に並べる
for i in range(0,N-K+1,1):
  Q=int(Listh[K+i-1]-Listh[i]) #hmax-hminの候補.Qminを求めればよい
  ListQ.append(Q)
ListQ.sort()
print(ListQ[0])


Measured memory_bytes: 11224
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

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

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

//----------------------------------------------------------------

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


Measured memory_bytes: 256
def is_ok(H):
    if len(H) <= 1:
        return True

    H[0] = H[0] - 1
    if H[0] > H[1]:
        return False
    for i in range(1, len(H)-1):
        if not((H[i]-1 > H[i+1]) or (H[i-1] > H[i]-1)):
            H[i] = H[i] - 1
        if H[i] > H[i+1] or H[i-1] > H[i]:
            return False
    return True

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

if is_ok(H):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14400
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  char d;
  int n=0,co=0;
  string out="";
  string tmp="";
  while(cin>>d){
    string in="";
    in+=d;
    if(d=='e')rep(i,2){
	cin>>d;
	in+=d;
      }
    else rep(i,6){
	cin>>d;
	in+=d;
      }
    if(tmp==in){
      if(n<co){
	out=in;
	n=co;
	co=1;
      }else
	co=1;
    }else if(tmp!=in){
      co++;
    }
    tmp=in;
  }
  if(n<co)out=tmp;
  cout<<out<<endl;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N;
  cin >> N;
  int res =0 ;
  int ans =0 ;
  for(int i=1;i<N+1;i+= 2){
    ans = 0 ;
    for(int j=1;j<i+1;j+= 2){
      if(i % j == 0){
       ans ++ ;
      }
    }
    if(ans == 8)
      res ++;
  }
  cout << res << endl;
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n,m,k;
  cin >> n >> m >> k;
  int a[n+1],b[m+1];
  a[0]=0,b[0]=0;
  fp(i,1,n)
    cin >> a[i],a[i]+=a[i-1];
  fp(i,1,m)
    cin >> b[i],b[i]+=b[i-1];
  int posb=m;
  int cnt=0;
  f(i,n+1)
  {
      if(a[i]>k)
        break;
      while(b[posb]>(k-a[i]))
        posb--;
      cnt=max(cnt,posb+i);
  }
  cout << cnt << '\n';
  return;
} 

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


Measured memory_bytes: 6764
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
bool  a[50001];
int b[25000];
int main() {
	int c = 0;
	fill(a, a + 50001, true);
	a[0] = false; a[1] = false;
	for (int i = 2; i <= 50000;) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 50000) {
				a[i*j] = false;
				j++;
			}
			b[c] = i;
			c++;
		}
		if (i == 2) i++;
		else i += 2;
	}
	int n;
	while (cin >> n&&n != 0) {
		int i = 0;
		map<int, int> d;
		while (b[i] <= n&&i != c) {
			if (a[n - b[i]]) {
				d.insert(map<int, int>::value_type(min(b[i], n - b[i]), max(b[i], n - b[i])));
			}
			i++;
		}
		cout << d.size() << endl;
	}
}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


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

	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}

	sort(vec.begin(), vec.end());
	cout << vec.at(N - 1) - vec.at(0) << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

type Rect = (Int, Int)

rarea :: Rect -> Int
rarea (h, w) = h * w

rsplit :: Rect -> [(Rect, Rect)]
rsplit (h, w) = [((y, w), (h-y, w)) | y <- [0..h`div`2]] ++ [((h, x), (h, w-x)) | x <- [0..w`div`2]]

eqsplit :: Rect -> [(Rect, Rect)]
eqsplit (h, w) = let (y, x) = (div h 2, div w 2) in [((y, w), (h-y, w)), ((h, x), (h, w-x))]

f :: Rect -> Rect -> Rect -> Int
f p q r = let l = map rarea [p, q, r] in maximum l - minimum l

solve :: [Int] -> Int
solve [h, w] = minimum $ concatMap (\(p, q) -> map (uncurry $ f p) (eqsplit q)) $ rsplit (h, w)

main = solve <$> (map read . words <$> getLine) >>= print

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define pb                push_back
#define int                long long
#define forn(i, n)        for (int i = 0; i < n; i++)
#define Forn(j, a, b)     for (int j = a; j < b; j++)
#define sp                " "
#define br                "\n"
#define mii               map<int ,int>
#define setbits(x)        _builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define ps(x,y)           fixed<<setprecision(y)<<x
#define w(x)              int x; cin>>x; while(x--)
#define MAXN              10000000
void c_p_c()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("ou.txt", "w", stdout);
#endif
}
//map--------------------------
// auto it=map.begin();
// for(it;it!=map.end();++it)
// {

// }
// int dp[100002][6];
// int fun(int arr[],int i,int k,int z,int n)
// {
//   if(i>=n||k==0||i<0)
//   return 0;
//   if(dp[i][z]!=-1)return dp[i][z];
//   int value=0;
//   if(i<n)
//   value=max(value,arr[i]+fun(arr,i+1,k-1,z,n));
//   if(i>0 and z>0)
//   value=max(value,arr[i]+fun(arr,i-1,k-1,z-1,n));
//   return dp[i][z]=value;
// }


//char num[][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};


void solve()
{
  int x;cin>>x;
  if(x>=30)cout<<"Yes";
  else cout<<"No";
}
int32_t main()
{
  c_p_c();
  solve();
}   


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<pair<ll,ll>> vec(0);
  for(ll i=2;i<=sqrt(N);i++) {
if(N%i==0) {
ll count=0;
  while(N%i==0) {
N/=i;
    count++;
  }
  vec.push_back(make_pair(i,count));
}
  }
  
  if(N>1) {
vec.push_back(make_pair(N,1));
  }
  
  ll ans=0;
   for(auto x:vec) {
     ll n=1;
     while(n*(n+1)/2<=x.second) {
n++;
     }
     ans+=n-1;
   }
  
  cout<<ans<<endl;
}

     
     
     
     
     
     
     
     
     
     
     
 

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];

  sort(L.begin(), L.end());

  int sum = 0;
  rep(i, N-1) sum += L[i];

  if(sum>L[N-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
ll MOD=1000000007;

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

  vector<bitset<21>> a(N,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int t;
      cin >> t;
      if(t==1) a[i].set(j);
    }
  } 

  vector<vector<ll>> r(N+1,vector<ll>((1<<N)));

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

  for(int i=1;i<=N;i++){
    for(int j=1;j<(1<<N);j++){
      if(__builtin_popcount(j)!=i) continue;
      for(int k=0;k<N;k++){
        if(a[i-1].test(k) && ((j>>k)&1)){
          r[i][j]+=r[i-1][j^(1<<k)];
          r[i][j]%=MOD;
        }
      }
      //cout << r[i][j] << " ";
    }
    //cout << endl;
  }

  cout << (r[N][(1<<N)-1]+MOD)%MOD << endl;
  return 0;
}


Measured memory_bytes: 377216
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#define MOD 998244353

int inv(LLI n) {
    int e = MOD-2;
    LLI r = 1;
    while (e > 0) {
        if (e & 1) r *= n,r %= MOD;
        e >>= 1;
        n *= n,n %= MOD;
    }
    return r;
}
int fact[3000000];
int invfact[3000000];
int choose(int n,int k) {
    return ((((LLI) fact[n]*invfact[k]) % MOD)*invfact[n-k]) % MOD;
}
int main() {
    int i;
    int N,M;
    cin >> N >> M;

    fact[0] = 1;
    for (i = 1; i < 3000000; i++) fact[i] = ((LLI) fact[i-1]*i) % MOD;
    invfact[2999999] = inv(fact[2999999]);
    for (i = 2999998; i >= 0; i--) invfact[i] = ((LLI) invfact[i+1]*(i+1)) % MOD;
    LLI ans = choose(3*M+N-1,N-1);
    for (i = 2*M+1; i <= 3*M; i++) ans -= ((LLI) N*choose(3*M-i+N-2,N-2)) % MOD;
    for (i = M+1; i <= min(N,3*M); i++) {
        if (!((3*M-i) & 1)) ans -= ((LLI) choose(N,i)*choose((3*M-i)/2+N-1,N-1)) % MOD;
    }
    ans %= MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 23680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i;
        while (j < n && a[i] == a[j]) {
            j++;
        }
        if (j-i < a[i]) {
            ans += j-i;
        } else if (j-i > a[i]) {
            ans += (j-i) - a[i];
        } 
        i = j;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int  x;
  cin>>x;
  long long int d = 100;
 long long  int cnt = 0;

  while(d<x)
  {
     d =  d+d*0.01;
     cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  
  int A;
  int B;
  
  scanf("%d %d",&A,&B);
  
  if(A + B >= A - B && A + B >= A * B){
    printf("%d",A + B);
  }
  else if(A - B >= A + B && A - B >= A * B){
    printf("%d",A - B);
  }
  else{
    printf("%d",A * B);
  }
  
  return 0;
}
  

Measured memory_bytes: 128
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n := input.NextInt()
  t := make([][]int,n)
  for i:=0;i<n-1;i++ {
    x,y := input.NextInts()
    t[x-1] = append(t[x-1],y-1)
    t[y-1] = append(t[y-1],x-1)
  }
  var dfs func(int,int) int
  dfs = func(u,p int) int {
    ret := 0
    for _,v := range t[u] {
      if v == p { continue }
      ret ^= (dfs(v,u)+1)
    }
    return ret
  }
  if dfs(0,-1) != 0 {
    fmt.Println("Alice")
  } else {
    fmt.Println("Bob")
  }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInt() int {
  n,_ := strconv.Atoi(i.NextLine())
  return n
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

Measured memory_bytes: 36480
n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    p = [j for j in map(int, input().split())]
    c.append(p[0])
    a.append(p[1:])
# print(n, m, x)
# for i in range(n):
#     print(c[i], a[i])
ans = 10**10

for i in range(1 << n):
    money = 0
    understand = [0]*m

    for j in range(n):
        if (i >> j) & 1 == 0:
            continue
        money += c[j]
        for k in range(m):
            understand[k] += a[j][k]
    for l in range(m):
        if understand[l] < x:
            break
    else:
        ans = min(ans, money)


if ans == 10**10:
    print(-1)
else:
    print(ans)


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

using namespace std;

int n;

void solve(){
    int i,j;
    string a,b,c;
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    long long ans = 0;
    for(i = 0;i < n;i++){
        if(a[i] == b[i] && b[i] == c[i]){
            ans += 0;
        }
        else if(a[i] == b[i] || b[i] == c[i] || a[i] == c[i]){
            ans += 1;
        }
        else{
            ans += 2;
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,k;
    int ans[500],rifuru[500],kat[500];
    int i,j,l,o;

    scanf("%d%d",&n,&m);
    for(i = 1; i <= n * 2; i++) ans[i] = rifuru[i] = i;
    for(i = 1; i <= m; i++){
        scanf("%d",&k);

        if(k == 0){
            j = 1,o = n + 1;
            for(l = 1; l <= n * 2; l++){
                if(l % 2 == 1){
                    ans[l] = rifuru[j];
                    j++;
                }
                else{
                    ans[l] = rifuru[o];
                    o++;
                }
            }
        }
        else{
            for(l = 1; l <= k; l++){
                kat[l] = ans[l];
            }
            for(l = 1,j = k + 1; j <= n * 2; l++,j++){
                ans[l] = ans[j];
            }
            for(l = n * 2 - k + 1,j = 1; l <= n * 2; l++,j++){
                ans[l] = kat[j];
            }
        }

        for(l = 1; l <= n * 2; l++) rifuru[l] = ans[l];
    }
    for(i = 1; i <= n * 2; i++) printf("%d\n",ans[i]);

    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 200005
#define maxn 30010
typedef pair<int,int> PII;
typedef long long LL;
LL read(){
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}

int n,m,flag,L,R,sz;
char str[N];
int vis;
int main(){
    //freopen("in.txt","r",stdin);
    int i,j,group,x,y,v,Case=0;
    scanf("%s",str);
    int len=strlen(str);
    int ans=len;
    for(i=0;i<len;++i)
        if(str[i]=='S')++vis;
        else{
            if(vis){
                --vis;
                ans-=2;
            }
        }
    printf("%d\n",ans);
    return 0;
}


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

#define reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular

namespace IO {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
}; // namespace IO
using namespace IO;
/*----------------------------------------------------------------------------*/

#define MAX_N 17

int N, C, T;
int len[MAX_N], p[MAX_N];
ll f[40][507];

inline ll work() {
    int R = N * C;
    rep(i, 0, T) rep(l, 0, R) f[i][l] = 0;
    f[0][N * len[N]] = 1;
    lep(i, 0, C) {
        Lep(j, N) {
            int l = i * N + j, r = std::min(R, l + N * len[p[j]]);
            lep(s, 0, T) if (!(s >> p[j] - 1 & 1)) {
                int ns = (s | (1 << p[j] - 1));
                rep(k, l, R) if (f[s][k]) f[ns][std::max(r, k)] += f[s][k];
            }
        }
    }
    return f[T][R];
}

int main() {
#ifdef LOCAL
    FIN("in");
#endif
    read(N), read(C);
    Rep(i, N) read(len[i]);
    std::sort(len + 1, len + N + 1);
    Lep(i, N) p[i] = i;
    ll t = 0;
    T = (1 << N - 1) - 1;
    do {
        t += work();
    } while (std::next_permutation(p + 1, p + N));
    ll s = 1;
    Lep(i, N) s *= i * C;
    printf("%.12lf\n", (double)t / (double)s);
    return 0;
}


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

using namespace std;



int main() {
	
	string a, b;
	cin >> a >> b;

	string c = b.substr(0, b.size() - 1);

	if (c == a && ((int)a.size() + 1 == (int)b.size()))
		cout << "Yes" << '\n';
	else cout << "No" << '\n';

	return 0;	
}

Measured memory_bytes: 3564
N, X = gets.chomp.split.map(&:to_i)
LS = gets.chomp.split.map(&:to_i)


if LS.inject(&:+) <= X # sumは2.4以降
  puts (N + 1)
else
  sum = 0
  i = 0
  
  until sum > X do
    sum += LS[i]
    i += 1
  end
  
  puts i
end

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  string s;
  cin >> s;
  int d; cin >> d;
  int n = s.size();
  int ans = 0, fi = 1, la = 1;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j < n - 1 && s[j + 1] == s[i]) j++;
    ans += (j - i + 1) / 2;
    if (i == 0) fi = j + 1;
    if (j == n - 1) la = j - i + 1;
    i = j;
  }
  if (fi == n) {
    cout << n * d / 2 << '\n';
    return;
  }
  if (d > 1 && s[0] == s[n - 1] && fi != n) {
    cout << ans + (d - 1) * (ans - fi / 2 - la / 2 + (fi + la) / 2) << '\n';
    return;
  }
  cout << ans * d << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

double get_prob(ll K, ll point)
{
    double score = 1;
    while (point < K) {
        point *= 2;
        score /= 2;
    }
    return score;
}

void main_()
{
    ll N, K;
    cin >> N >> K;

    double prob_total = 0.0;
    for (ll i = 1; i <= N; ++i) {
        auto prob = get_prob(K, i);
        prob_total += prob;
    }

    cout << setprecision(15) << prob_total / N << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int sign(int p) {
	if (p == 0) return 1;
	return -1;
}

int n;
int a[3000];
int dp[3000][3000];	//dp[区間] = 先手の得点, playerは区間の長さから定まるので記録しなくてOK
bool used[3000][3000];

int dfs(int l, int r, int p) {
	if (l > r) return 0;
	if (used[l][r]) return dp[l][r];
	
	int x = dfs(l + 1, r, !p) + a[l] * sign(p);
	int y = dfs(l, r - 1, !p) + a[r] * sign(p);
	if (p == 0) return dp[l][r] = max(x, y);
	used[l][r] = true;
	return dp[l][r] = min(x, y);
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	cout << dfs(0, n - 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 78464
a,b,c,d,e,f = map(int, input().split())

per = 0.0
ans = salt = w = s = 0
for i in range(0, f + 1, 100 * a):
    for j in range(0, f + 1, 100 * b):
        w = i + j
        if w > f: break
        for k in range(0, f + 1, c):
            if w + k > f: break
            for l in range(0, f + 1, d):
                w = i + j
                s = k + l
                if w + s > f: break
                if s <= (w // 100) * e:
                    if 0 < s + w <= f:
                        if per < s / (s + w):
                            per = s / (s + w)
                            ans = w + s
                            salt = s
if ans == 0:
    print(100*a,0)
else:
    print(ans,salt)

Measured memory_bytes: 9160
def c2a(c):
    return (26 - ord(c) + ord("a")) % 26


s = input()
k = int(input())
l = len(s)
ans = ""
for i, e in enumerate(s, 1):
    if i == l:
        code = (ord(e) - ord("a") + k) % 26 + ord("a")
        c = chr(code)
    else:
        cnt = c2a(e)
        if cnt <= k:
            c = "a"
            k -= cnt
        else:
            c = e

    ans += c

print(ans)


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

bool isPrime(int n) {
	if (n <= 1) return 0;
	if (n == 2 || n == 3) return 1;
	if (n % 2 == 0 || n % 3 == 0) return 0;
	for (int i = 5; i * i <= n; i += 6) {
		if(n % i == 0 || n % (i + 2) == 0) return 0;
	}
	return 1;
}

signed main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	int a, b; cin >> a >> b;
	int n = __gcd(a, b), c = 1, ans = 1;
	int t = n;
	while (t != 1) {
		c++; if(c * c > n) break;
		if (t % c == 0) ans++;
		while (t % c == 0) t /= c;
	}
	if (isPrime(t)) ans++;
	cout << ans << '\n';
}


Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new java.io.PrintWriter(System.out)

  Iterator.continually(in.readLine)
    .drop(1)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .foreach(ch => out.println(ch.mkString))
  out.flush
}

Measured memory_bytes: 31176
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define int long long
const int N= 1e3+5;
int32_t main()
{
    IOS;
    int a;
    double b;
    cin>>a>>b;
    b = b*100.0;
    int b2= round(b);
   // cout<<b2<<endl;
    int ans= ((a*b2)/100);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    sort(l.begin(), l.end(), greater<int>());

    int len = 0;
    for (int i = 0; i < k; i++) {
        len += l[i];
    }
    cout << len << endl;
    return 0;
}

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(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)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int par[N],rank[N];
int findroot(int u)
{
    if(par[u]==u)
        return u;
    else
        return par[u]=findroot(par[u]);
}
void merge_set(int u,int v)
{
    u=findroot(u);
    v=findroot(v);

    if(u!=v){
        par[u]=v;
    }
}

int main()
{
   int n,m;

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

   for(int i=1;i<=m;i++){
     int u,v,w;
     cin>>u>>v>>w;
     merge_set(u,v);
   }

   set<int>s;
   for(int i=1;i<=n;i++){
    int x=findroot(i);
    s.insert(x);
   }
   cout<<s.size()<<endl;


    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;
const int LOG = 23;
vector<pair<int,long long>> G[100010];
vector<pair<int,pair<int,long long>>> H[100010];
int parent[25][100010];
int d[100010];
long long dist[100010];
void dfs(int v, int p){
	for(auto x:G[v]){
		if(x.first==p) continue;
		parent[0][x.first] = v;
		d[x.first] = d[v] + 1;
		dist[x.first] = dist[v] + x.second;
		dfs(x.first,v);
	}
}

void init(int v,int root){
	d[root] = 0; parent[0][root] = -1;
	dfs(root,-1);
	for(int k=0;k+1<LOG;k++){
		for(int i=0;i<v;i++){
			if(parent[k][i]<0){
				parent[k+1][i] = -1;
			}else{
				parent[k+1][i] = parent[k][parent[k][i]];
			}
		}
	}
}

int lca(int u, int v){
	if(d[u]>d[v]) swap(u,v);
	for(int k = 0;k<LOG;k++){
		if((d[v] - d[u]) & (1<<k)){
			v = parent[k][v];
		}
	}
	if(u==v) return u;
	for(int k = LOG-1;k>=0;k--){
		if(parent[k][u]!=parent[k][v]){
			u = parent[k][u];
			v = parent[k][v];
		}
	}
	return parent[0][u];
}

long long c[100010] = {},cdist[100010] = {};
vector<int> v[100010];
map<pair<int,int>,pair<int,long long>> mp;
void dfs2(int s,int p){
	for(int x:v[s]){
		mp[{s,x}] = {c[x],cdist[x]};
	}
	for(auto x:H[s]){
		if(x.first==p) continue;
		pair<int,long long> q = x.second;
		c[q.first]++; cdist[q.first] += q.second;
		dfs2(x.first,s);
		c[q.first]--; cdist[q.first] -= q.second;
	}
}

long long solve(int v,int c,long long num){
	return dist[v] - mp[{v,c}].second + mp[{v,c}].first*num;
}

int x[100010],y[100010],s[100010],t[100010];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,q;
	cin >> n >> q;
	for(i=0;i<n-1;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		a--; b--;
		G[a].push_back({b,d}); G[b].push_back({a,d});
		H[a].push_back({b,{c,d}}); H[b].push_back({a,{c,d}});
	}
	init(n,0);
	for(i=0;i<q;i++){
		cin >> x[i] >> y[i] >> s[i] >> t[i];
		s[i]--; t[i]--;
		v[s[i]].push_back(x[i]); v[t[i]].push_back(x[i]); v[lca(s[i],t[i])].push_back(x[i]);
	}
	dfs2(0,-1);
	for(i=0;i<q;i++){
		cout << solve(s[i],x[i],y[i]) + solve(t[i],x[i],y[i]) - 2*solve(lca(s[i],t[i]),x[i],y[i]) << "\n";
	}
}

Measured memory_bytes: 56572
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005


enum Type{
	TATE,
	YOKO,
};

struct Line{

	Type type;
	int x1,y1,x2,y2;
};

struct Info{
	Info(int arg_x,int arg_index,Type arg_type){
		x = arg_x;
		index = arg_index;
		type = arg_type;
	}
	bool operator<(const struct Info &arg) const{

		if(x != arg.x){

			return x < arg.x;
		}else{

			return type < arg.type; //右から左に見た場合、縦棒が後に出るようにする
		}
	}
	Type type;
	int x,index;
};

int N;
vector<int> X,Y;
map<int,int> map_Y;
ll BIT[SIZE];
Line line[SIZE];



void add(int loc,ll value){

	BIT[loc] += value;

	loc += loc & -loc; //最後の1ビットを足した場所が次の★更新★場所

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

ll getSum(int loc){

	ll sum = BIT[loc];

	loc -= loc & -loc; //最後の1ビットを引いた場所が次の★加算★場所

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

ll calc(int left,int right){ //left～rightの区間の総和を、sum(1～right)-sum(1～left-1)で求める
	return getSum(right)-getSum(left-1);
}

int main(){

	int num_line;
	scanf("%d",&num_line);

	for(int i = 0; i < num_line; i++){

		scanf("%d %d %d %d",&line[i].x1,&line[i].y1,&line[i].x2,&line[i].y2);

		Y.push_back(line[i].y1);
		Y.push_back(line[i].y2);

		if(line[i].x1 == line[i].x2){ //縦棒

			line[i].type = TATE;

		}else{ //横棒

			line[i].type = YOKO;
		}
	}

	//座標圧縮
	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());

	N = (int)Y.size();

	for(int i = 0; i <= N; i++){

		BIT[i] = 0;
	}

	for(int i = 0; i < Y.size(); i++){

		map_Y[Y[i]] = i+1;
	}

	vector<Info> info;

	for(int i = 0; i < num_line; i++){

		if(line[i].type == TATE){

			info.push_back(Info(line[i].x1,i,TATE));
		}else{

			info.push_back(Info(max(line[i].x1,line[i].x2),i,YOKO)); //BIT加算用
			info.push_back(Info(min(line[i].x1,line[i].x2)-1,i,YOKO)); //BIT削除用
		}
	}

	sort(info.begin(),info.end());

	ll ans = 0;

	for(int i = info.size()-1; i >= 0; i--){

		if(info[i].type == TATE){

			int left = map_Y[min(line[info[i].index].y1,line[info[i].index].y2)];
			int right = map_Y[max(line[info[i].index].y1,line[info[i].index].y2)];

			ans += calc(left,right);

		}else{ //横棒

			if(info[i].x == max(line[info[i].index].x1,line[info[i].index].x2)){ //横線の右側

				add(map_Y[line[info[i].index].y1],1);

			}else{ //横線の左側-1

				add(map_Y[line[info[i].index].y1],-1);
			}
		}
	}

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

	return 0;
}



Measured memory_bytes: 12564
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  vl x(5);
  rep(i, 5) cin >> x[i];
  ll k;
  cin >> k;
  if (x[4] - x[0] > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, k, a[maxn], mark[maxn], dp[maxn], ans;
vector<int> graph[maxn];

void dfs(int u)
{
	if (graph[u].empty())
		dp[u] = 1;
	for (int i : graph[u])
		if (!mark[i])
		{
			dfs(i);
			dp[u] = max(dp[u], ((dp[i] + 1) % k == 0 ? k : (dp[i] + 1) % k));
		}
	//cerr << "DFS AT " << u << ':' << dp[u] << endl;
}

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

	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i]--;
	}
	if (a[0] != 0)
		a[0] = 0, ans++;
	//cerr << '#' << ans << endl;
	for (int i = 0; i < n; i++)
		graph[a[i]].pb(i);
	for (int i : graph[0])
		mark[i] = 1;
	mark[0] = 1;
	for (int i = 0; i < n; i++)
		if (mark[i])
			dfs(i);

	/*for (int i = 0; i < n; i++)
		cerr << '_' << mark[i];
	cerr << endl;
	for (int i = 0; i < n; i++)
		cerr << '_' << dp[i];
	cerr << endl;*/

	for (int i = 0; i < n; i++)
		if (!mark[i] && dp[i] == k)
			ans++;
	cout << ans << endl;
}



Measured memory_bytes: 11264
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let mut ans = 0;
    for j in 1..n+1 {
        let mut v: Vec<i64> = Vec::new();
        for k in 1..j+1 {
            if j % k == 0 && j % 2 == 1 {
                v.push(k);
            }
        }
        if v.len() == 8 {
            ans += 1;
        }
    }
    println!("{}",ans );
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int all = a + b;
	int kei = all - c;
	if (kei >= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 764
N, M, X = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
ans = 10**20

for mask in range(2**N):
    C = [0]*M
    cst = 0
    for i in range(N):
        if (mask>>i)&1:
            cst += x[i][0]
            for j in range(1, M+1):
                C[j-1] += x[i][j]
    if min(C) >= X:
        ans = min(ans, cst)

if ans < 10**20:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9132
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define deb(x) cout<<#x<<" "<<x<<"\n"
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}

int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	cout<<(n^1);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[1252525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int s;
	cin>>s;
	used[s]=true;
	REP(i, 1252525){
		if(s&1){
			s=3*s+1;
		}
		else{
			s/=2;
		}
		if(used[s]){
			cout<<i+2<<'\n';
			return 0;
		}
		else{
			used[s]=true;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	string S,T;
	cin>>S>>T;
	int cnt=0;
	REP(i,S.size()){
		if(S[i]!=T[i]){
			if(cnt>30)break;
			cnt++;
			string a="";
			a+=S[i];
			string b="";
			b+=T[i];
			//cout<<a<<" "<<b<<endl;
			REP(j,S.size()){
				if(S[j]==a[0]){
					S[j]=b[0];
				}else if(S[j]==b[0]){
					S[j]=a[0];
				}
			}
		}
	}
	bool check=false;
	REP(i,S.size()){
		if(S[i]!=T[i])check=true;
	}
	//cout<<S<<endl;
	if(check){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 776
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
char m[10][11];
int main() {
	vector<int> n(3);
	rep(i, 0, 3)scanf("%d", &n[i]);
	sort(all(n));
	printf("%d\n", (n[1] - n[0]) / 2 + n[2] - n[1] + (n[1] - n[0]) % 2 * 2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int arr[4];
	forn(i, 0, 4) in(arr[i]);
	sort(arr, arr+4);
	if (arr[0] == 1 && arr[1] == 4 && arr[2] == 7 && arr[3] == 9) outn("YES");
	else outn("NO");
		
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

a , b , q = map(int, input().split())

s = [int(input()) for i in range(a)]
t = [int(input()) for i in range(b)]
s.sort()
t.sort()
s=[float('INF')*(-1)]+s+[float('INF')]
t=[float('INF')*(-1)]+t+[float('INF')]
for i in range(q):
    x = int(input())
    sp=bisect_left(s,x)-1
    tp=bisect_left(t,x)-1
    s1=s[sp]
    t1=t[tp]
    s2=s[sp+1]
    t2=t[tp+1]
    print(min(max(x-s1,x-t1),max(s2-x,t2-x),x-s1+t2-s1,x-t1+s2-t1,s2-x+s2-t1,t2-x+t2-s1))


Measured memory_bytes: 18240