akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string S;
	cin >> S;
	deque< char > T;
	N = S.size();
	rep(i, N) T.push_back(S[i]);
	//cout << T.front();
	cin >> Q;
	int f = 0;
	while (Q--) {
		int t;
		cin >> t;
		if (t == 1) {
			f = 1 - f;
		} else {
			int F;
			char C;
			cin >> F >> C;
			if (F == 1) {
				if (f) {
					T.push_back(C);
				} else {
					T.push_front(C);
				}
			} else {
				if (f) {
					T.push_front(C);
				} else {
					T.push_back(C);
				}
			}
		}
		//cout << T.size() << endl;
	}
	if (f)
		reverse(T.begin(), T.end());
	//cout << f;
	//cout << T.size();
	M = T.size();
	while (!T.empty()) {
		char c = T.front();
		T.pop_front();
		cout << c;
		//cout << i;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int a,b,t;
    cin >> a >> b >> t;
    int z = a;
    int cnt = 0;
    while(z <= t){
        cnt+=b;
        z+=a;
    }
    cout << cnt << endl;
} 

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
// #define map unordered_map
// #define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  ll N, K;
  scanf("%lld %lld", &N, &K);

  string s;
  cin >> s;

  // map<ll, ll> m;

  // ll start1_index = -1;
  // for (ll i = 0; i < s.size(); i++) {
  //   char ch = s[i];

  //   if (ch == '0') {
  //     if (start1_index >= 0) {
  //       m[start1_index] = i - start1_index;
  //       start1_index = -1;
  //     } else {
  //     }
  //   } else {
  //     if (start1_index >= 0) {
  //     } else {
  //       start1_index = i;
  //     }
  //   }
  // }

  // if (!(m.find(0) != m.end())) {
  //   m[-1] = 0;
  // }
  // if (s[s.size() - 1] == '1') {
  //   m[start1_index] = s.size() - start1_index;
  // } else {
  //   m[s.size()] = 0;
  // }

  // auto ite = m.begin();

  // for (; ite != end(m); ite++) {
  //   cout << (*ite).first << "," << (*ite).second << endl;
  // }

  vector<pair<ll, ll>> list;

  if (s[0] == '0') {
    list.emplace_back(make_pair(0, 0));
  }

  ll start1_index = -1;
  for (ll i = 0; i < s.size(); i++) {
    char ch = s[i];

    if (ch == '0') {
      if (start1_index >= 0) {
        ll len = i - start1_index;
        list.emplace_back(make_pair(start1_index, len));
        start1_index = -1;
      } else {
      }
    } else {
      if (start1_index >= 0) {
      } else {
        start1_index = i;
      }
    }
  }

  if (s[s.size() - 1] == '1') {
    ll len = s.size() - start1_index;
    list.emplace_back(make_pair(start1_index, len));
  } else {
    list.emplace_back(make_pair(s.size(), 0));
  }

  // for (ll i = 0; i < list.size(); i++) {
  //   cout << list[i].first << "," << list[i].second << endl;
  // }

  ll ans = 0;

  for (ll i = 0; i < list.size(); i++) {
    ll start_index = list[i].first;

    ll index2 = min((ll)(list.size() - 1), i + K);

    ll end_index = list[index2].first;

    ll length = (end_index - start_index) + list[index2].second;

    ans = max(ans, length);
  }

  cout << ans << endl;
}

// 11101010110011

// 0,3
// 4,1
// 6,1
// 8,2
// 12,2


Measured memory_bytes: 1528
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


N, M = LI()
FACT = FLIST(M)


def NCR(n, r):
    res = 1
    res *= FACT[n-r]
    res *= FACT[r]
    res %= DVSR
    res = INV(res)
    res *= FACT[n]
    res %= DVSR
    return res


def NPR(n, r):
    res = 1
    res *= FACT[n]
    res *= INV(FACT[n-r])
    res %= DVSR
    return res


ALL = NPR(M, N)
ALL %= DVSR
ALL *= ALL
ALL %= DVSR


PAT = 0
for i in reversed(range(1, N+1)):
    v = NCR(N, i)
    v *= NPR(M, i)
    v %= DVSR
    v *= NPR(M-i, N-i)
    v %= DVSR
    v *= NPR(M-i, N-i)
    v %= DVSR
    PAT = v - PAT
    PAT %= DVSR

print((ALL - PAT) % DVSR)


Measured memory_bytes: 110856
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n,m,x;cin>>n>>m>>x;
    bool a[110]={false};
    for(int i=0;i<m;i++){
      int aa;
      cin>>aa;
      a[aa-1]=true;
    }
    int ans=INF;
    int ma=0;
    for(int i=min(n-1,x);i<n;i++){
        if(a[i]){
            ma++;
        }
    }
    ans=min(ma,ans);
    ma=0;
    for(int i=max(x-2,0);i>=0;i--){
        if(a[i]){
            ma++;
        }
    }
    ans=min(ma,ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
ll dp[105][15];
int a[105];
int k;
char s[105];
ll dfs(int len,int num,bool zero,bool equ)
{
    if (num<0) return 0;
    if (len<=0) {
        if (num==0) return 1;
        return 0;
    }
    if (!zero&&!equ&&dp[len][num]!=-1) return dp[len][num];
    int up=equ?a[len]:9;
    ll ans=0;
    for (int i=0;i<=up;i++) {
        if (i==0&&zero) ans+=dfs(len-1,num,true,equ&(i==up));
        else if (i==0) ans+=dfs(len-1,num,false,equ&(i==up));
        else ans+=dfs(len-1,num-1,false,equ&(i==up));
    }
    if (!equ&&!zero) return dp[len][num]=ans;
    return ans;
}
ll calc()
{
    scanf("%s",s);
    scanf("%d",&k);
    int len=strlen(s);
    for (int i=1;i<=len;i++) a[i]=s[len-i]-'0';
    memset(dp,-1,sizeof(dp));
    return dfs(len,k,true,true);
}
int l,r;
int main()
{
    printf("%lld\n",calc());
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, a, b;
    cin >> n >> a >> b;

    string s;
    cin >> s;

    int passed = 0;
    int oversea = 1;
    rep(idx, n) {
        if (s[idx] == 'a') {
            if (passed < a + b) {
                passed++;
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        } else if (s[idx] == 'b') {
            if (passed < a + b && oversea <= b) {
                passed++;
                oversea++;
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        } else {
            cout << "No\n";
        }
    }
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll count_inside = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(a[i] > a[j]) count_inside++;
        }
    }
    ll ans = 0;
    ans += k * count_inside % mod;

    ll count_outside = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i] > a[j]) count_outside++;
        }
    }
    //cout << ans << endl;
    ll kousu = k * (k - 1) / 2;
    ans += kousu % mod * count_outside % mod;
    ans %= mod;
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    int n;
    
    while (scanf("%d", &n) && n){
        pair<int, string> info[32];
        int b[32];
        
        for (int i = 0; i < n; i++){
            char tmp[32];
            scanf("%s", tmp);
            info[i].first = 0;
            info[i].second = (string)tmp;
            
            b[i] = 0;
            
            int m;
            scanf("%d", &m);
            for (int j = 0; j < m; j++){
                int x;
                scanf("%d", &x);
                b[i] |= (1 << x);
            }
        }
        
        for (int i = 0; i < 30; i++){
            int base = n + 1;
            int cnt = 0;
            for (int j = 0; j < n; j++){
                if (b[j] >> i & 1) cnt++;
            }
            for (int j = 0; j < n; j++){
                if (b[j] >> i & 1) info[j].first += base - cnt;
            }
        }
        
        sort(info, info + n);
        
        printf("%d %s\n", info[0].first, info[0].second.c_str());
    }
    
    return (0);
}

Measured memory_bytes: 1236
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.Bits (testBit)

main :: IO ()
main = do
  [h, w, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    decode :: Int -> (Int, Int)
    decode = (`divMod` w)
    count :: (Int, Int) -> VU.Vector Bool -> Int
    count (s, t) = VU.length . VU.ifilter p
      where
        p :: Int -> Bool -> Bool
        p m b = not $ testBit s i || testBit t j || not b
          where
            (i, j) = decode m :: (Int, Int)
    patterns = (,) <$> [0..(2 ^ h - 1)] <*> [0..(2 ^ w - 1)] :: [(Int, Int)]
  css <- sequence . replicate h $ map (== '#') <$> getLine :: IO [[Bool]]
  let
    v = VU.fromList . concat $ css :: VU.Vector Bool
  print . length . filter (== k) . map (flip count v) $ patterns

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

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

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

#define M (1000000007)

int main() {
    ios::sync_with_stdio(false);

    int s, w;
    cin >> s >> w;

    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){

	int x,a,b;
	cin >> x >>a >>b;

	if(abs(x-a) > abs(x-b)){
		cout << 'B' <<endl;
	}

	else{
		cout << 'A' <<endl;
	}
}	

Measured memory_bytes: 3560
import sys
import heapq
import math

INF = float("inf")


def main():
    N = int(input())
    ans = N

    for i in range(1, int(N ** 0.5)+1):
        if N % i == 0:
            j = N // i
            ans = min(i + j - 2, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    string s; cin >> s;
    int N = s.size();
    int ans = INF;

    REP(i, N){
        int tmp = 0, a = 0;
        REP(j, N){
            if(s[j] != s[i]){
                tmp++;
                Max(a, tmp);
            }else tmp = 0;
        }
        Min(ans, a);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> D;

  invec<int> c(26);
  vector<invec<int>> s(D, invec<int>(26));

  REP(i, D) {
    cout << i % 26 + 1 << endl;
  }
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
//typedef unsigned long long uint;
typedef pair<long long, long long> pint;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vint;
typedef vector<vint> vvint;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpint;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define M 1000006
# define N 100006
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define INF 100000000
# define A 1000006


int main()
{ 
    int n;
    cin >> n;
    int x[n],y[n],t[n];
    for(int i=0;i<n;i++)
        cin >> t[i] >> x[i] >> y[i];
    int prev1=0,prev2=0;
    int pt=0;
    for(int i=0;i<n;i++)
    {
        int t1=abs(x[i]-prev1)+abs(y[i]-prev2);
        if(t1>(t[i]-pt))
        {
            cout << "No";
            return 0;
        }
        int left=((t[i]-pt)-t1);
        if(left%2)
        {
            cout << "No";
            return 0;
        }
        prev1=x[i];
        prev2=y[i];
        pt=t[i];
    }
    cout << "Yes";
    
}





Measured memory_bytes: 1408
S = input()
N = len(S)

ans_1 = 0
ct = 0
for i in range(N):
  if int(S[i]) != ct:
    ans_1 += 1
  ct += 1
  ct %= 2
  
ans_2 = 0
ct = 1
for i in range(N):
  if int(S[i]) != ct:
    ans_2 += 1
  ct += 1
  ct %= 2
  
print(min(ans_1, ans_2))

Measured memory_bytes: 73684
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		double t = saori.Hayamin();
		double x = saori.Hayamin();
		System.out.println(t/x);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

int main(){
  int k,x,s,e;
  cin >> k >> x;
  k=k-1;
  s = x-k;
  e = x+k;
  cout << s;
  for (int i=s+1;i<=e;i++){
    cout << " " << i;
  }
  return 0;
}

Measured memory_bytes: 256
package main
import . "fmt"
import . "os"
func main() {
  var s string
  var n int
  var m = make(map[string]struct{},26)
  Scan(&s)
  n = len(s)
  for i:=0;i<n;i++ {
    m[s[i:i+1]] = struct{}{}
    if len(m) == 26 {
      Println("None")
      Exit(0)
    }
  }
  for i:=0;i<26;i++ {
    var t = string(i+97)
    _,ok := m[t]
    if !ok {
      Println(t)
      Exit(0)
    }
  }
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,ans;
  string s,t;
  cin >>a;
  b=a;
  ans=1;
  while(b!=0){
    b+=a;
    ans++;
    if(b>=360)b-=360;
  }
  cout <<ans;
}

Measured memory_bytes: 3660
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846

void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld x,lld mod){return (x%mod+mod)%mod;}
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<int> v[maxi];
// long long a[maxi];
// void dfs(int x,int y){
//     a[x]+=a[y];
//     for(int i:v[x]){
//         if(i!=y){
//             dfs(i,x);
//         }
//     }
// }

void test_case(){
    int n;
    cin>>n;
    cout<<fixed<<setprecision(20)<<2*pi*n;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}

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

int main()
{
  string s;
  cin >> s;

  if (s.length() == 1)
  {
    cout << 0 << endl;
    return 0;
  }
  int cnt1 = 0;
  for (int i = 0; i < s.length(); ++i)
  {
    if (i % 2 == 0)
    {
      if (s[i] == '0') cnt1++;
    }
    else
    {
      if (s[i] == '1') cnt1++;
    }
  }
  int cnt2 = 0;
  for (int i = 0; i < s.length(); ++i)
  {
    if (i % 2 == 0)
    {
      if (s[i] == '1') cnt2++;
    }
    else
    {
      if (s[i] == '0') cnt2++;
    }
  }
  cout << min(cnt1, cnt2) << endl;
  return 0;
}


Measured memory_bytes: 512
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let xs = get_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect::<Vec<usize>>();

    for (i, x) in xs.iter().enumerate() {
        if *x == 0 {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main()
{
  int N;
  cin >> N;
  map<int,int> mp;
  FOR(i,2,N+1){
    int flag=0;
    FOR(j,2,i){
      if(i%j==0){
        flag=1;
        break;
      }
    }
    if(flag==0){
      FOR(j,i,N+1){
        int x = j;
        while(x%i==0){
          x/=i;
          mp[i]++;
        }
      }
    }
  }

  mint ans = 1;
  for(auto x:mp){
    ans*=x.second+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
if s == 'SUN':
    print('7')
elif s == 'MON':
    print('6')
elif s == 'TUE':
    print('5')
elif s == 'WED':
    print('4')
elif s == 'THU':
    print('3')
elif s == 'FRI':
    print('2')
elif s == 'SAT':
    print('1')

Measured memory_bytes: 2940
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

ll cal(ll n){
    ll res=1;
    while(res*2<=n){
        res*=2;
    }
    return res;
}
vector<l_l>ans;

bool solve(){
    ll n;cin>>n;
    //cout<<__builtin_popcount(n)<<endl;
    if(__builtin_popcount(n)==1){
        cout<<"No"<<endl;
        return 0;
    }
    
    rep(i,1,5){
        ll j=i+1;
        ll si=i,sj=j;
        if(i>=4)si=i-3+n;
        else si=i;
        if(j>=4)sj=j-3+n;
        else sj=j;
        ans.pb({si,sj});
    }
    for(ll i=4;i<=n-1;i+=2){
        ans.pb({i,i+1});
        ans.pb({i+1,1});
        ans.pb({1,i+n});
        ans.pb({i+n,i+n+1});
    }
    if(n%2==0){
        ll c=cal(n);
        ll e=n+1-c;
        if(e==3){
            ans.pb({n-1,n});
            ans.pb({2,n*2});
        }else{
            ans.pb({n,c+n});
            ans.pb({2*n,e});
        }
    }
    cout<<"Yes"<<endl;
    
    for(auto x:ans){
        cout<<x.fi<<" "<<x.se<<endl;
    }
    return 0;
}
int main(){fastio
    solve();
    return 0;
}


Measured memory_bytes: 6128
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * N

for i in range(1, N):
    calc = max(0, a[i-1] + a[i] - x)
    if a[i-1] <= calc <= a[i]:
        a[i] -= calc
        ans[i] = calc
    elif a[i] < calc:
        a[i] = 0
        ans[i] = calc
    else:
        a[i] -= calc
        ans[i] = calc

print(sum(ans))

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

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

// constexpr int MOD = 1e9+7;

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

Measured memory_bytes: 764
s = int(input())
a = []
ans = 0
i = 0
while ans == 0:
    if i == 0:
        a.append(s)
        i += 1
    else:
        if a[i - 1] % 2 == 0:
            a.append(a[i - 1] // 2)
        else:
            a.append(a[i - 1] * 3 + 1)
        if a[i] in a[:i]:
            ans = i + 1
        i += 1
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

bool is_prime(i32 num) {
  if(num < 2) {return false;}
  if(num == 2) {return true;}
  if(num % 2 == 0) {return false;}
  auto buf = sqrt(num);
  for(i32 i = 3; i < ceil((double)buf); i+=2) {
    if(num%i == 0) {return false;}
  }
  return true;
}

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i32 X;
  cin >> X;
  
  while(!is_prime(X)) {
    ++X;
  }
  cout << X << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
    vector<int> bell(3);
    cin >> bell[0] >> bell[1] >> bell[2];
    sort(bell.begin(), bell.end());
    cout << bell[0] + bell[1] << endl;

    return 0;
}


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

const int maxn = 3030;

int n;
int a[maxn];
std::vector<int> g[maxn];

int dfs(int u, int p = 0) {
	bool leaf = 1;
	for (int v: g[u]) {
		if(v == p) {
			continue;
		}
		leaf = 0;
		if(a[v] >= a[u]) {
			continue;
		}
		if(dfs(v, u) - 1) {
			return 1;
		}
	}
	return leaf ? -1 : 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) {
		if(dfs(i)) {
			printf("%d ", i);
		}
	}
	return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    K,T=MI()
    a=LI()
    M=max(a)
    if M<=(K+1)//2:
        print(0)
    else:
        temp=sum(a)-M
        ans=M-temp-1
        print(ans)
        

main()


Measured memory_bytes: 79156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];

  vi dp(h+1,INF);// dp[i] モンスターに合計iのダメージを与えるのに必要な魔力の最小値
  dp[0] = 0;
  rep(i,n)rep(j,h) {
    int nj = min(j+a[i],h);
    chmin(dp[nj], dp[j]+b[i]);
  }

  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
field = list(input() for i in range(h))

row = [0] * h
column = [0] * w
for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            row[i] = 1
            column[j] = 1

for i in range(h):
    if row[i] == 1:
        for j in range(w):
            if column[j] == 1:
                print(field[i][j], end='')
        print()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double r;
    cin>>r;
    double pi=3.1415926;
    pi=2*pi*r;
    cout<<pi<<endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(4), t(4);
    for(int i = 0; i < 4; i++) {
        cin >> p[i];
    }
    for(int i = 0; i < 4; i++) {
        cin >> t[i];
    }
    int ans = 10000000;
    for(int i = 0; i <= (n + t[0] - 1) / t[0]; i++) {
        for(int j = 0; j <= (n + t[1] - 1) / t[1]; j++) {
            for(int k = 0; k <= (n + t[2] - 1) / t[2]; k++) {
                for(int l = 0; l <= (n + t[3] - 1) / t[3]; l++) {
                    int cnt = t[0] * i + t[1] * j + t[2] * k + t[3] * l;
                    int cost = p[0] * i + p[1] * j + p[2] * k + p[3] * l;
                    if(cnt >= n) {
                        ans = min(ans, cost);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
#define ld long double
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactive problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main(){ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    vector<ll> v1;
    vector<ll> v2;
    for (int i = 0; i < n; ++i)
    {
        ll a,b;
        cin>>a>>b;
        ll x1 = a+b;
        ll y1 = a-b;
        v1.push_back(x1);
        v2.push_back(y1);
    }

    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    ll an1 = abs(v1[0]-v1[v1.size()-1]);
    ll an2 = abs(v2[0]-v2[v2.size()-1]);
    cout<<max(an1, an2);

    return 0;
}

Measured memory_bytes: 6632
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
using namespace std;
priority_queue<ll>q1;
priority_queue<ll,vector<ll>,greater<ll> >q2;
ll dlt,sum1,sum2;
int main()
{
	int t,opt;ll x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&opt);
		if(opt==1)
		{
			scanf("%lld %lld",&x,&y);
			dlt+=y;
			if(q1.empty()||x<=q1.top())q1.push(x),sum1+=x;
			else q2.push(x),sum2+=x;
			if(q1.size()>q2.size()+1)
			{
				q2.push(q1.top()),sum2+=q1.top();
				sum1-=q1.top(),q1.pop();
			}
			while(q2.size()>q1.size())
			{
				q1.push(q2.top()),sum1+=q2.top();
				sum2-=q2.top(),q2.pop();
			}
		}
		else 
		{
			y=q1.top();
			printf("%lld %lld\n",y,y*q1.size()-sum1+sum2-y*q2.size()+dlt);
		}
	}
	return 0;
}

Measured memory_bytes: 5060
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int[] num = new int[3];
        for(int i = 0; i < 3; i++){
            num[i] = input.nextInt();
        }
        for(int i = 2; i > 0; i--){
            for(int j = 0; j < i; j++){
                int temp = 0;
                if(num[j] > num[j+1]){
                    temp = num[j+1];
                    num[j+1] = num[j];
                    num[j] = temp;
                }
            }
        }
        System.out.println(String.format("%d %d %d", num[0], num[1], num[2]));
    }
}



Measured memory_bytes: 26408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
/*ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
*/


/*最小公倍数*/
/*
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
*/

/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,sum=0;
    string x;
    cin>>n;
    vector<string>s(n);
    vector<ll>t(n);
    for(ll i=0;i<n;i++){
        cin>>s[i]>>t[i];
    }
    cin>>x;
    bool flag=false;
    for(ll i=0;i<n;i++){
        if(x==s[i]){
            flag=true;
        }
        else if(flag){
            sum+=t[i];
        }
    }
    cout<<sum<<endl;



}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        char[] s = S.toCharArray();
        if(s[0] == s[1] && s[0] == s[2]){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


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

const int N = 123456;

int n;
ll a[N];
vector<int> g[N];
ll f[N];

void fuck() {
    puts("NO");
    exit(0);
}

void dfs(int v, int p) {
    f[v] = (g[v].size() == 1 ? a[v] : 2 * a[v]);
    for (int u: g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        if (f[u] > a[v]) {
            fuck();
        }
        f[v] -= f[u];
    }

    if (g[v].size() > 1) {
        if (f[v] > a[v]) {
            fuck();
        }
    }

    if (f[v] < 0) {
        fuck();
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0, -1);

    if (f[0] != 0) {
        fuck();
    }
    
    puts("YES");
}


Measured memory_bytes: 13184
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

n,x = map(int,input().split())
a = list(map(int,input().split()))
p = []
for i in a:
    p.append(abs(i - x))
g = p[0]
for i in p:
    g = gcd(i, g)
print(g)

Measured memory_bytes: 16300
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int N;
    vector<int> A,B;
    cin>>N;

    int l = N-1;

    int m = (l+1)/2;
    B.push_back(0);
    for(int i = 1;i <= N;i++) {
        int temp;
        cin>>temp;
        A.push_back(temp);
        B.push_back(temp);
    }

    sort(B.begin()+1,B.end());

    int index = m;
    for(int i = 1;i <= N;i++) {
        if(A[i-1] <= B[index]) {
            cout<<B[index+1]<<endl;
        } else {
            cout<<B[index]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3948
using System;
using System.Linq;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int amx = a.Max();
    int[] table = new int[amx+1];
    Array.Sort(a);
    if(a[0] == 1){
      if(n == 1){
        Console.Write(1);
        return;
      }
      if(a[1] == 1){
        Console.Write(0);
        return;
      }else{
        Console.Write(1);
        return;
      }
    }
    for(int i = 0;i < n;i++){
      for(int j = a[i];j <= amx; j += a[i]) table[j]++;
    }
    int ans = 0;
    for(int i = 0;i < n;i++){
      if(table[a[i]] == 1) ans++;
    }
    Console.Write(ans);
  }
}

Measured memory_bytes: 46844