akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	ll ssize,tsize,Q;
	cin >> ssize >> tsize >> Q;
	vector<ll> s(ssize,0),t(tsize,0);
	rep(i,ssize)cin >> s[i];
    rep(i,tsize)cin >> t[i];

	vector<ll> ans(Q,0);
	rep(i,Q){
        ll q;
        cin >> q;
		auto sit=lower_bound(all(s),q);
        auto tit=lower_bound(all(t),q);
        ll s1,s2,t1,t2;
        if(sit==s.begin())s1=1e12;
        else s1=abs(*(sit-1)-q);
        if(sit==s.end())s2=1e12;
        else s2=abs(*sit-q);
        if(tit==t.begin())t1=1e12;
        else t1=abs(*(tit-1)-q);
        if(tit==t.end())t2=1e12;
        else t2=abs(*tit-q);
        ll minval=1e12;
        chmin(minval,max(s1,t1));
        chmin(minval,max(s2,t2));
        chmin(minval,s1*2+t2);
        chmin(minval,t1*2+s2);
        chmin(minval,s2*2+t1);
        chmin(minval,t2*2+s1);
        ans[i]=minval;
	}

	rep(i,Q)p(ans[i]);

	return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll q, h, s, d, n;
    cin>>q>>h>>s>>d>>n;

    ll x = min(8 * q, min(4 * h, min(s * 2, d)));
    ll ans = (n / 2) * x;
    ll sum = n % 2;
    ll y = min(q * 4, min(h * 2, s));
    ans += sum * y;
    cout<<ans<<endl;

    return 0;
}

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int randi(int a, int b) { return uniform_int_distribution(a, b)(rng); }

struct rolling_hash {
  static constexpr uint64_t mod = 2e9 + 33;
  static inline array<long long, 2> base{randi(1e9, 2e9), randi(1e9, 2e9)};
  static inline array<vector<int>, 2> powb{vector{1}, vector{1}};
  int n;
  array<vector<int>, 2> h{vector{0}, vector{0}};
  template <class S = string> rolling_hash(const S& s = "") : n(size(s)) {
    for (int k : {0, 1}) {
      for (auto c : s) h[k].push_back((h[k].back() * base[k] + c) % mod);
      while ((int)size(powb[k]) <= n)
        powb[k].push_back(powb[k].back() * base[k] % mod);
    }
  }
  int get(int l, int r, int k) const {
    return (h[k][r] + (mod - h[k][l]) * powb[k][r - l]) % mod;
  }
  auto get(int l, int r) const { return make_pair(get(l, r, 0), get(l, r, 1)); }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<rolling_hash> rh(n);
  vector<vector<pair<int, int>>> v(26);
  for (auto&& e : rh) {
    string s;
    cin >> s;
    reverse(begin(s), end(s));
    e = s;
    int bt = 0;
    for (int i = e.n; i--; ) {
      bt |= 1 << (s[i] - 'a');
      for (int x = 0; x < 26; ++x) {
        if (~bt >> x & 1) continue;
        v[x].push_back(e.get(0, i));
      }
    }
  }
  for (auto&& e : v) {
    sort(begin(e), end(e));
  }
  auto res = 0LL;
  for (auto&& e : rh) {
    auto&& vx = v[e.get(e.n - 1, e.n, 0) - 'a'];
    auto p = e.get(0, e.n - 1);
    res += upper_bound(begin(vx), end(vx), p) - lower_bound(begin(vx), end(vx), p);
  }
  cout << res - n << '\n';
}


Measured memory_bytes: 213928
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[10][10];
int memo[10000];
bool ans[10000];

int fuc(int N)
{
	vector<int> tmp;
	REP(i,4)
	{
		tmp.PB(N%10);
		N /= 10;
	}
	
	int ret = 0;
	REP(i,4)
	{
		ret = mp[ret][tmp[3-i]];
	}
	return ret;
}

int rev(vector<int> v)
{
	int ret = 0;
	REP(i,4)
	{
		ret *= 10;
		ret += v[3-i];
	}
	return ret;
}

bool check(int a)
{
	//cout << a << endl;
	int A = a;
	vector<int> tmp;
	vector<int> now;
	REP(i,4)
	{
		now.PB(A%10);A/=10;
	}
	tmp = now;
	REP(i,4)
	{
		REP(j,10)
		{
			tmp = now;
			tmp[i] = j;
			int X = rev(tmp);
			//cout << ' ' << X << endl;
			int Y = rev(now);
			if(X!=Y&&(memo[X] == memo[Y]||(mp[memo[X]][memo[a]] == 0)))
			{
				ans[X] = ans[Y] = true;
			}
		}
	}
	
	REP(i,10)
	{
		if(memo[a] != i && mp[memo[a]][i] == 0)ans[a] = true;
	}
	
	tmp = now;
	REP(i,3)
	{
		swap(tmp[i],tmp[i+1]);
		int X = rev(tmp);
		//cout << ' ' << X << endl;
		int Y = rev(now);
		if(X!=Y&&(memo[X] == memo[Y]||(mp[memo[X]][memo[a]] == 0)))
		{
			ans[X] = ans[Y] = true;
		}
		swap(tmp[i],tmp[i+1]);
		
	}
	tmp[0] = memo[a];
	int X = rev(tmp);
	if((memo[X] == now[0] ||mp[memo[X]][now[0]]==0)&& now[0] != memo[a])ans[a] = ans[X]= true;
	
}

int main()
{
	REP(i,10)
	{
		REP(j,10)
		{
			cin >> mp[i][j];
		}
	}

	REP(i,10000)
	{
		memo[i] = fuc(i);
	}
	
	REP(i,10000)
	{
		check(i);
	}
	
	ll out = 0;
	REP(i,10000)
	{
		if(ans[i])out++;
	}
	
	cout << out << endl;
	
	return 0;
}

Measured memory_bytes: 3204
import java.util.*;

public class Main {
    Scanner in = new Scanner(System.in);

    public void run() {
        int N = in.nextInt();
        int[] C = new int[N-1];
        int[] S = new int[N-1];
        int[] F = new int[N-1];

        for (int i = 0; i < N - 1; i++) {
            C[i] = in.nextInt();
            S[i] = in.nextInt();
            F[i] = in.nextInt();
        }

        for (int s = 0; s < N; s++) {
            int cur = 0;
            for (int i = s; i < N - 1; i++) {
                cur = S[i] + ((Math.max(cur - S[i], 0) + F[i] - 1) / F[i]) * F[i] + C[i];
            }
            System.out.println(cur);
        }
    }


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


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

int main(){

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

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()
#LR数できまる.
#両側が同じときはさらにもう一つ減る

#現在のansをはかりKの分2を足す
ans = 0
pre = S[0]
for i in range(N-1):
    if pre == S[i+1]:
        ans += 1
    pre = S[i+1]

ans = min([N-1, ans+2*K])

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e10
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
ll dp[105][maxn];
ll n,w;
vector<pll>v(105);
ll go(ll i,ll j){
    if(i==n){
        if(j==0) return 0;
        return inf;
    }
    ll &ans=dp[i][j];
    if(ans!=-1) return ans;
    ans=inf;
    if(v[i].S<=j) ans=min(ans,v[i].F+go(i+1,j-v[i].S));
    ans=min(ans,go(i+1,j));
    return ans;
}
int main()
{
    ll i,j,val=0,x;
    cin>>n>>w;
    for(i=0;i<n;i++) {
        cin>>v[i].F>>v[i].S;
        val+=v[i].S;
    }
    SET(dp,-1);
    for(i=val;i>0;i--){
        x=go(0,i);
        if(x<=w){
            cout<<i;
            return 0;
        }
    }
}


Measured memory_bytes: 82432
from itertools import permutations

def main():
    n = input()
    pos = []
    for _ in xrange(n):
        x, y = map(float, raw_input().split())
        pos.append([x, y])
    c = 0
    s = 0.0
    for pp in permutations(pos):
        c += 1
        for i in xrange(n - 1):
            x0, y0 = pp[i]
            x1, y1 = pp[i + 1]
            s += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5
    print s / c


main()


Measured memory_bytes: 32924
from sys import stdin
readline = stdin.readline



from collections import namedtuple
Runner = namedtuple('Runner', 'd v')

def main():
    while True:
        ticket, vertex, edge, start, destination = map(int, readline().split())
        if ticket == 0:
            break

        start -= 1
        destination -= 1
        g = defaultdict(list)
        for i in range(edge):
            s, t, length = map(int, readline().split())
            s -= 1
            t -= 1
            g[s].append((length, t))
            g[t].append((length, s))
        
        d = ex_dijkstra(g, vertex, start, ticket)
        print(min(d[destination]))



from heapq import heappush, heappop
from collections import defaultdict
def ex_dijkstra(g, size, start, ticket):
    d = [[float('inf')] * (ticket + 1) for i in range(size)]
    d[start][ticket] = 0
    heap = [(d[start][ticket], start, ticket)]
    while heap:
        du, u, ticket = heappop(heap)
        for length, v in g[u]:
            if d[v][ticket] > du + length:
                d[v][ticket] = du + length
                heappush(heap,(d[v][ticket], v, ticket))
            if ticket and d[v][ticket - 1] > du + length // 2:
                d[v][ticket - 1] = du + length // 2
                heappush(heap,(d[v][ticket - 1], v, ticket - 1))

    return d

main()

Measured memory_bytes: 6860
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	K = rll()[0]
	D = int(rl())
	lim = []
	for c in K: lim.append(int(c))
	n = len(lim)
	dp = [[[0]*D for j in range(2)] for i in range(n+1)]
	dp[0][1][0] = 1
	for i in range(n):
		for tight in range(2):
			for ds in range(D):
				md = lim[i] if tight else 9
				for d in range(md+1):
					nt = 1 if tight and lim[i] == d else 0
					nds = (d + ds) % D
					dp[i+1][nt][nds] += dp[i][tight][ds]
					dp[i+1][nt][nds] %= MOD
	ans = (dp[n][0][0] + dp[n][1][0] - 1) % MOD
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 92892
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, TD):
    TD.sort(key=lambda x: x[1], reverse=True)

    c = Counter()
    base = 0
    rc = []
    for i in range(K):
        t, k = TD[i]
        c[t] += 1
        base += k
        if c[t] > 1:
            rc.append((t, k))

    mi = i
    ans = [base + len(c)**2]
    while True:
        if len(rc) == 0:
            break
        rt, rk = rc.pop()
        cc = len(c)
        d = (cc+1)**2 - cc**2
        for i in range(mi+1, len(TD)):
            if TD[i][0] not in c:
                c[TD[i][0]] += 1
                c[rt] -= 1
                base -= rk
                base += TD[i][1]
                mi = i
                ans.append(base + len(c)**2)
                break

        else:
            break
    return max(ans)


def main():
    # N = read_int()
    N, K = read_int_n()
    TD = [read_int_n() for _ in range(N)]
    print(slv(N, K, TD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 35376
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N, K; cin >> N >> K;
  set<int> vec;
  for (int i = 0; i < K; ++i){
    int d; cin >> d;
    vector<int> A(d);
    rep(j, d) cin >> A[j];
    rep(j, d) vec.insert(A[j]);
  }
  cout << N - vec.size() << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
using namespace std;



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

	int a[201] = { 0 };
	int N;
	cin >> N;
	rep(i, N) {
		int x;
		cin >> x;
		a[x + 100]++;
	}

	int min_score = 0x1111111111111111LL;
	rep(i, 201) {
		int score = 0;
		rep(j, 201)score += a[j] * (i - j) * (i - j);
		min_score = min(min_score, score);
	}
	cout << min_score << endl;
}

Measured memory_bytes: 256
import math,itertools

def combinations_count(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

def main():
    N,P = map(int,input().split())
    A = list(map(int,input().split()))
    odd_A = [A[i] for i in range(N) if A[i]%2 != 0]
    even_A = [A[i] for i in range(N) if A[i]%2 == 0]
    allpat = 2**N
    comb = 0
    for i in range(0,len(odd_A)+1,2):
        comb += combinations_count(len(odd_A),i)
    evenpat = (2**len(even_A))*comb
    oddpat = allpat - evenpat
    ans = oddpat if P == 1 else evenpat
    print(ans)


if __name__ == '__main__':
    main()

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

int main(int argc, char** argv) {
    int n, a, b; cin >> n >> a >> b;
    if (n == 1) cout << (a == b ? 1 : 0)<< endl;
    else if (a > b) cout << 0 << endl;
    else cout << (long long)(b - a) * (n - 2) + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n,c; cin >> n >> c;
    vector<vector<int>> c_num(3,vector<int>(35,0));
    // map<int, int> d0, d1, d2;
    vector<int> d[c];
    rep(i,c){
        rep(j,c){
            int temp;
            cin >> temp;
            d[i].push_back(temp);
        }
    }
    vector<int> c_mp[n];
    rep(i,n)rep(j,n){
        int temp;cin >> temp;
        temp--;
        c_mp[i].push_back(temp);
        c_num[(i+j)%3][temp]++;
    }

    int res = INT_MAX;
    // c_numの 
    // [0] => i
    // [1] => j
    // [2] => k
    rep(i,c)rep(j,c)rep(k,c){
        if(i == j || j == k || i == k)continue;
        int temp_sum = 0;
        rep(l,c){
            temp_sum += d[l][i] * c_num[0][l];
            temp_sum += d[l][j] * c_num[1][l];
            temp_sum += d[l][k] * c_num[2][l];
        }
        res = min(res, temp_sum);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 300010;

LL ar[N],n,bu[N],sum=0;

int main(void)
{
    scanf("%lld", &n);
    for (int i = 1; i <= n;i++){
        cin >> ar[i];
        bu[ar[i]]++;
        if(bu[ar[i]]>=2)
            sum += bu[ar[i]] - 1;
    }
    for (int i = 1; i <= n;i++)
        cout << sum - (bu[ar[i]] - 1)<<endl;
    return 0;
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n;
    cin >> n;
    Int res = 2 * (n / 11);
    n %= 11;
    if (n == 0) {
        print(res);
    } else if (n <= 6) {
        print(res + 1);
    } else {
        print(res + 2);
    }
    return 0;
}

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

int main() {
  string N;
  cin >> N;
 
  for (int i = 0; i < 3; i++) {
    if ( N.at(i) ==  '1' ) {
      N.at(i) = '9';  
    }
    else if ( N.at(i) ==  '9' ) { 
      N.at(i) = '1';  
    }
  }
    
  cout << N << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#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...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        int x;
        Int(x);

        printf("%d\n",(1000 - x%1000)%1000);

        //printf("Case %d: ",++te);
    }
    return 0;
}






Measured memory_bytes: 3760
N=int(input())
n=[input()[0] for _ in range(N)]
m,a,r,c,h=n.count("M"),n.count("A"),n.count("R"),n.count("C"),n.count("H")
print(m*a*(r+c+h)+m*r*(c+h)+m*c*h+a*r*(c+h)+a*c*h+r*c*h)

Measured memory_bytes: 3864
#include<stdio.h>
int main()
{
    long long int i,j,a,max,s;
    double sum;
    scanf("%lld",&a);
    j=0;
    long long int b[a+10];
    for(i=0;i<a;i++)
    {
        scanf("%lld",&b[i]);
    }
    max=b[0];
    for(i=0;i<a;i++)
    {
        if(max<b[i])
        {
            max=b[i];
            j=i;
        }
    }
    b[j]=0;
    sum=max/2.0;
    for(i=0;i<a;i++)
    {
        sum=sum+b[i];
    }
   s=(long long int)sum;
   if(s==sum)
   {
       printf("%lld\n",s);
   }
   else
    printf("%.1lf\n",sum);
   return 0;

}

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

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){
    
}

void solve(){
    ll n;
    cin >> n;
    ll ans = (n+1)/2;
    cout << ans;
}

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

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long; 
using ld=long double;
void solve()
{
  ld x,k,d; cin>>x>>k>>d; 
  ld l=0,r=k,ans=1e18; 
  while(l<=r)
  {
    ll mid=(l+r)/2;
    if(abs(x+(2*mid-k)*d)<ans)
    {
      ans=abs(x+(2*mid-k)*d); if(ans==0) break; 
    }
    if(x+(2*mid-k)*d>0){ r=mid-1; }
      else { l=mid+1; } 
  }
  ll res=ans; 
  cout<<res<<"\n"; 
}
int main()
{
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr); 
  int t=1; 
  while(t--)
  {
    solve(); 
  }
  return 0; 
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N,K;
int main(){
	cin >> N >> K;
	if(K>(N-1)*(N-2)/2){
		cout << -1 << endl;
		return 0;
	}
	int m = (N-1)*(N-2)/2-K;
	cout << N-1+m << endl;
	int cnt = 0;
	for(int i=1;i<=N-1;i++)cout << i << ' ' << N << endl;
	for(int i=1;i<=N-1;i++){
		for(int j=i+1;j<=N-1;j++){
			if(cnt>=m)continue;
			cnt++;
			cout << i << ' ' << j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    char s[4];
    scanf("%s",s);

    int flag=0;
    if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]){
        flag=1;
    }
    if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]){
        flag=1;
    }
    if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]){
        flag=1;
    }
    if(flag){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#define MAX 10000005
int p[MAX];
int four[1000];

int main(void)
{
  int i,j,f=0;

  for(i=2;i<MAX;i++)
    if(!p[i])
      for(j=i*2;j<MAX;j+=i)
	p[j]=1;
  
  for(i=3 ; i < MAX-7 ; i+=2){
    if(p[i] == 0 && p[i+2]==0 && p[i+6]==0 && p[i+8]==0)
      {
	four[f++]=i+8;
      }
    four[f]=10000005;
  }
  
  for(;scanf("%d",&j);)
    {
      if(j==0)
	exit(0);
      for(i=0 ;four[i]<=j; i++);
      printf("%d\n",four[i-1]);
    }
  
  return 0;
}

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

int main() {
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	int ans = 0;
	for( int i = 0; i < 3; i++ ) {
		for( int j = 0; j < 3; j++ ) {
			for( int k = 0; k < 3; k++ ) {
				if( i == j || j == k || k == i ) {
					continue;
				}
				int res = a[i] * 10  + a[j] + a[k];
				ans = max( ans, res );
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
check = []
for i in range(4):
    check.append(0)


for i in range(3):
    inp = input().split()
    a = int(inp[0])
    b = int(inp[1])
    check[a-1] += 1
    check[b-1] += 1

odd_count = 0
for i in range(4):
    if (check[i]%2 == 1):
        odd_count += 1

if (odd_count==0 or odd_count==2):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

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++)

int main()
{
	int x;
	cin >> x;
	if (x > 29) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}//どうして・・・(´･_･`)


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll par[N],siz[N];
ll dsu_parent(ll node){
    if(node==par[node])return node;
    return par[node]=dsu_parent(par[node]);
}
void dsu_union(ll a,ll b){
    a=dsu_parent(a);
    b=dsu_parent(b);
    if(a==b)return;
    if(siz[a]<siz[b])swap(a,b);
    par[b]=a;
    siz[a]+=siz[b];
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=m;i++)par[i]=i,siz[i]=1;
    set<ll> lang;
    for(ll i=1;i<=n;i++){
        ll k;cin>>k;
        ll pr;cin>>pr;
        lang.insert(pr);
        for(ll j=1;j<k;j++){
            ll c;cin>>c;
            dsu_union(pr,c);
            lang.insert(c);
        }
       // cout<<i<<" DONE"<<endl;
    }
    set<ll> st;
    for(ll i=1;i<=m;i++)if(lang.count(i))st.insert(dsu_parent(i));
    cout<<(st.size()==1?"YES":"NO");
}





Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include <deque>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<iostream>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include<numeric>
using namespace std;
#define ll  long long
#define pb push_back
#define sz(v)               ((int)((v).size()))
#define all(x)          (x).begin(),(x).end()
#define REP(i, v)       for(int i=0;i<sz(v);i++)
using namespace std;
typedef pair<int,int> pii;
#define f first
#define s second
int main() {
	int n,g;
	cin >> n >> g;
	vector<pii> v(n);
	for (int i = 0 ; i < n ; ++i) {
		scanf("%d %d",&v[i].f,&v[i].s);
	}
	int ans = 1 << 30;
	for (int msk = 0 ; msk < (1 << n) ; ++msk) {
		int pay = 0, rem = g;
		for (int i = 0 ; i < n ; ++i) {
			if (msk & (1 << i)) {
				pay += v[i].f;
				rem -= v[i].f * 100 * (i + 1) + v[i].s;
			}
		}
		for (int i = n - 1; i >= 0 ; --i) {
			if ( ! ( (msk & (1 << i)) > 0) ) {
				int cur = v[i].f;
				while (rem > 0 && cur > 0) {
					++pay; rem -= (i + 1) * 100; --cur;
				}
			}
		}
		ans = min(ans,pay);
	}
	cout << ans << "\n";

}


Measured memory_bytes: 256
#include <stdio.h>

struct Card {
  char mark;
  int value;
};

void BubbleSort(struct Card*,int);
void SerectionSort(struct Card*,int);
int hantei(struct Card*,struct Card*,int);

int main(){
  struct Card card1[100],card2[100]; 
  int i,n;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf(" %c%d",&card1[i].mark,&card1[i].value);
  }

  for(i = 0;i < n;i++)
    card2[i] = card1[i];

  BubbleSort(card1,n);

  for(i = 0;i < n;i++){
    if(i > 0) printf(" ");
    printf("%c%d",card1[i].mark,card1[i].value);
  }
  printf("\nStable\n");
  
  SerectionSort(card2,n);
  
  for(i = 0;i < n;i++){
    if(i > 0) printf(" ");
    printf("%c%d",card2[i].mark,card2[i].value);
  }

  if(hantei(card1,card2,n) == 1)
    printf("\nStable\n");
  else printf("\nNot stable\n");
  
  return 0;
}
  
void BubbleSort(struct Card *c,int n){
  int i,j;
  
  for(i = 0;i < n ;i++){
    for(j = n - 1;j > i ; j--){
      if(c[j].value < c[j-1].value){
        struct Card C = c[j];
        c[j] = c[j-1];
        c[j-1] = C;
      }
    }
  }
}

void SerectionSort(struct Card *c,int n){
  int i,j,minj;

  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n;j++){
      if(c[j].value < c[minj].value)
        minj = j;
    }
    struct Card C = c[i];
    c[i] = c[minj];
    c[minj] = C;
  }
}

int hantei(struct Card *c1,struct Card *c2,int n){
  int i;

  for(i = 0;i < n;i++)
    if(c1[i].mark != c2[i].mark) return 0;

  return 1;
}


Measured memory_bytes: 2100
#include <stdio.h>
using namespace std;
int main(){
	int a,b,c,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for(int i = a; i <= b; i++){
		if(c%i == 0) count++;
	}
	printf("%d\n",count);
}


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

vector<int> S;

void countingSort(vector<int>& A, vector<int>& B, int l, int k) {
    vector<int> C(k+1, 0);

    for (int j=0; j<l; j++)
        C[A[j]]++;

    for (int i=1; i<=k; i++)
        C[i] = C[i] + C[i-1];

    for (int j=l-1; j>=0; j--) {
        B[C[A[j]]-1] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int n;
    cin >> n;
    int i;
    int max = -1;
    rep(i, n) {
        int input;
        cin >> input;
        S.push_back(input);
        if (max < input) max = input;
    }
    vector<int> T(n);
    countingSort(S, T, n, max);

    rep(i, n-1) {
        cout << T[i] << " ";
    }
    cout << T[n-1] << endl;

    return 0;
}



Measured memory_bytes: 18416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string S, T;
    cin >> S >> T;
    int N = S.size(), M = T.size();
    int st = inf;
    rep(i, N-M+1){
        int able = true;
        rep(j, M){
            if(S[i+j] != T[j] && S[i+j] != '?'){
                able = false;
                break;
            }
        }
        if(able) st = i;
    }
    if(st == inf) cout << "UNRESTORABLE" << endl;
    else{
        rep(i, st){
            if(S[i] == '?') cout << 'a';
            else cout << S[i];
        }
        cout << T;
        rep2(i, st+M, N-1){
            if(S[i] == '?') cout << 'a';
            else cout << S[i];
        }
        cout << endl;
    }
}

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

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int hoge = sc.nextInt();
        int hoge2 = sc.nextInt();
        int sum = 0;

        if(hoge == 1 && hoge2 == 1){
            sum+=400000;
        }
            
        if(hoge ==1){
            sum += 300000;
        }
        if(hoge == 2){
            sum+= 200000;
        }
        if(hoge == 3){
            sum += 100000;
        }
        if(hoge2 == 1){
            sum += 300000;
        }
        if(hoge2 == 2){
            sum+= 200000;
        }
        if(hoge2 == 3){
            sum += 100000;
        }
        System.out.println(sum);
    }     
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  vector<char> vec(H*W);
  
  for (int i=0; i<H*W ; i++){
    cin >> vec.at(i);
  }
  for (int i=0; i<W+2 ; i++){
    cout << "#";
  }
  cout <<endl;
  
  for (int i=0; i<H ;i++){
    cout << "#";
    for (int j=0; j<W ; j++){
      cout << vec.at(i*W+j);
    }
    cout <<"#"<<endl;
  }
  for (int i=0; i<W+2 ; i++){
    cout << "#";
  }
  cout <<endl;
}



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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 998244353;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);


    ll n, s;
    cin >> n >> s;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    vector<int> dp(s+1);
    dp[0] = 1;
    for(ll i=1; i<=n; i++) {
        vector<int> pre = dp;
        for(ll j=0; j<=s; j++) {
            (dp[j] = pre[j] * 2) %= MOD;
            if(j-a[i-1]>=0)
                (dp[j] += pre[j-a[i-1]]) %= MOD;
        }
    }
    cout << dp[s] << endl;
}


Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    int A[N];
    int sum = 0;

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

    float border = ((float)sum) / ((float) 4 * M);

    int counter = 0;

    for(int i = 0; i < N; i++) {
        if(A[i] >= border) {
            counter++;
        }
    }

    if(counter < M) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));
    reverse(all(h));

    ll ans = 0;
    Rep(i, k, n) {
        ans += h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int cnt=0;
    while(cnt<K && A>=B){
        B*=2;
        cnt++;
    }
    while(cnt<K && B>=C){
        C*=2;
        cnt++;
    }
    if(A<B && B<C)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll K, N;
    cin >> K >> N;
    vll A(N+1);
    A[0] = 0;
    ll total = 0, maxa = 0;
    rep(i, N) {
        cin >> A[i+1];
        total += A[i+1] - A[i];
        chmax(maxa, A[i+1] - A[i]);
    }
    chmax(maxa, A[1] + K - A[N]);
    cout << K - maxa << endl;
}


Measured memory_bytes: 1792
#
# abc071 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """atcoderregularcontest"""
        output = """b"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """abcdefghijklmnopqrstuvwxyz"""
        output = """None"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg"""
        output = """d"""
        self.assertIO(input, output)


def resolve():
    S = input()
    n = [0 for _ in range(26)]
    for i in range(len(S)):
        n[ord(S[i]) - ord("a")] = 1
    for i in range(26):
        if n[i] == 0:
            print(chr(ord("a")+i))
            break
    else:
        print("None")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16380
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 and (new_inputed[0] != last or new_inputed in inputed):
        judge = "No"
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)

Measured memory_bytes: 3060
def solv(x):
    if x % 2 == 0:
        return -1
    count = 0
    for i in range(1, x+1):
        if x % i == 0:
            count += 1
    return count


N = int(input())
ans = 0
for i in range(1, N+1):
    if solv(i) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


int query(int a, int b, int c, int d) {
  cout << "? " << a << " " << b << " " << c << " " << d << "\n";
  int r;
  cin >> r;
  return r;
}

const int H = 50;
int board[H][H] = {};
// [a, a + x) * [b, b + y)
void solve(int a, int b, int x, int y, int dir, int tot) {
  //cerr << "solve:" << a << " " << b << " " << x << " " << y << " " << dir << " " << tot << "\n";
  if (x * y == tot) {
    REP(i, a, a + x) {
      REP(j, b, b + y) {
	board[i][j] = 1;
      }
    }
    return;
  }
  if (tot == 0) {
    return;
  }
  assert (x >= 2 || y >= 2);
  if ((dir == 0 && x == 1) || (dir == 1 && y == 1)) {
    dir = 1 - dir;
  }
  int nx = dir == 0 ? x / 2 : x;
  int ny = dir == 1 ? y / 2 : y;
  int dx = dir == 0 ? x / 2 : 0;
  int dy = dir == 1 ? y / 2 : 0;
  int res_half = query(a, b, a + nx - 1, b + ny - 1);
  solve(a, b, nx, ny, 1 - dir, res_half);
  solve(a + dx, b + dy, x - dx, y - dy, 1 - dir, tot - res_half);
}

int main(void){
  ios::sync_with_stdio(false);
  int h, w, n;
  ll k;
  cin >> h >> w >> n >> k;
  solve(0, 0, h, w, 0, n);
  
  ll sum = 0;
  ll cur = 1;
  REP(i, 0, h) {
    REP(j, 0, w) {
      int res = board[i][j];
      sum = (sum + res * cur) % k;
      cur = cur * 2 % k;
    }
  }
  cout << "! " << sum << "\n";
}


Measured memory_bytes: 720
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for ai in a:
    absum = 0
    for i in range(m):
        absum += ai[i] * b[i]
    if absum + c > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
n = int(input())
D = list(map(int,input().split()))
Y = [0]*n

for i in range(n):
  if i%2==0:
    Y[0] += D[i]
  else:
    Y[0] -= D[i]

for i in range(1,n):
  Y[i] = 2*D[i-1] - Y[i-1]

print(*Y)

Measured memory_bytes: 14092
N,M=map(int,input().split())

ans = 0
limit = M//N
for i in range(1,int(M**0.5)+1):
    if i > limit:
        break
    if M%i==0:
        ans=max(ans,i)
        if M//i <= limit:
            ans=max(ans,M//i)

print(ans)

Measured memory_bytes: 38768
// IncludingFiles
#include<iostream>
#include<vector>
#include<cmath>

// Defines
#define     MAX_NUMBER     (999999)
#define     MIN_NUMBER     (1)
// #define     __DEBUG__

// Using Namespace
using namespace std;

// Function
int main(){
	vector <int> PrimeNumbers;
	vector <int> input;
	int buf;
	int sz,maxn;
	int i,root;

	// 入力
	while(cin >> buf){
		// 入力値のチェック
		if((buf < ((int)(MIN_NUMBER))) || (buf > ((int)(MAX_NUMBER)))){
			cerr << "InputError!!" << endl;
			cerr << "The number has to more than " << (((int)(MIN_NUMBER)) - 1);
			cerr << " and less than " << (((int)(MAX_NUMBER)) + 1) << "." << endl;
		}else{
			// 問題がなければ入力値をリストに追加
			input.push_back(buf);
		}
	}

	// n の最大値を求めて maxn に代入
	sz = (int)input.size();
	maxn = input[0];
	for(i=1;i<sz;i++){
		if(maxn < input[i]){
			maxn = input[i];
		}
	}

	// 素数2 を 素数表PrimeNumbers に追加
	PrimeNumbers.push_back(2);

	// 3 から maxn までの整数が素数かどうかを調べ、素数であれば 素数表PrimeNumbers に追加
	for(i=3;i<=maxn;i+=2){
		// root に i の平方根を代入
		root = (int)sqrt(i);
		// sz に 素数表PrimeNumbers の大きさを代入
		sz = (int)PrimeNumbers.size();
		// i が 素数表PrimeNumbers に含まれている素数で割り切れないかを確認
		for(buf=0;(buf < sz) && (PrimeNumbers[buf] <= root);buf++){
			if((i % PrimeNumbers[buf]) == 0){						// もし割り切れたら
				goto NotPrime;										// i を素数表に追加しない
			}
		}
		// i は素数である ならば i を 素数表PrimeNumbers に追加
		PrimeNumbers.push_back(i);
		// ここにジャンプする
		NotPrime:;
	}

	// n 以下の素数の個数を計測
	sz = (int)input.size();
	for(i=0;i<sz;i++){
		// input[i] == 1  ならば  0 [個]を出力
		if(input[i] == 1){
			cout << 0 << endl;
			continue;
		}

		// a, b および flag の宣言・初期化
		int a = 0,b = (int)PrimeNumbers.size() - 1,m,n;
		bool flag = false;

		// PrimeNumbers の最大値 <= input[i] となっていないかどうかを調べる
		if(PrimeNumbers[b] <= input[i]){
			n = b;
			flag = true;
		}

		// 二分検索
		while (flag == false){
			m = (a + b) / 2;
			if(PrimeNumbers[m] > input[i]){
				b = m;
			}else if((PrimeNumbers[m] <= input[i]) && (PrimeNumbers[m+1] > input[i])){
				n = m;
				flag = true;
			}else if(PrimeNumbers[m] < input[i]){
				a = m;
			}else{
				cerr << "BinarySearchError!!" << endl << endl;
				cerr << "PrimeNumbers[" << m << "] = " << PrimeNumbers[m] << endl;
				cerr << "PrimeNumbers[" << (m + 1) << "] = " << PrimeNumbers[m+1] << endl;
				cerr << "input[" << i << "] = " << input[i] << endl;
				return -1;
			}
		}

		// 出力
		cout << (n + 1) << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//前半と後半で赤と青がまぜこぜで選ばれることはない
//Nこずつしか選ばれない
//ある地点を境界としたときそこまでで赤と青をそれぞれN個選んだときの合計値を効率良く求める

int main() {

    ll N;
    cin >> N;

    for(ll i = 0; i < N*3; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    //前から大きくなるような累積ワ
    vector<ll > maxF(N*2+19, 0);
    for(ll i = 0; i < N*2; i++){
        maxF[i+1] = vec[i] + maxF[i]; 
    }
    //小さい数字なるべく吐き出す
    priority_queue<ll, vector<ll >, greater<ll > > queF;
    for(ll i = 0; i < N*2; i++){
        if(i < N) queF.push(vec[i]);
        else{
            //今までに選ばれている数字より大きい数じが来たら更新
            ll top = queF.top();
            if(vec[i] > top){
                //次の合計値を更新（最大化）
                maxF[i+1] = maxF[i] - top + vec[i];
                queF.pop();
                queF.push(vec[i]);
            }else{
                maxF[i+1] = maxF[i];
            }
        }
   }

    //後から大きくなるような累積ワ
    vector<ll > minB(N*2+19, 0);
    for(ll i = 0; i < N; i++){
         minB[i+1] = vec[N*3-1-i] + minB[i]; 
    }
    priority_queue<ll > queB;
    //なるべく大きい数字を吐き出す
    for(ll i = 0; i < N*2; i++){
        if(i < N) queB.push(vec[N*3-1-i]);
        else{
            ll top = queB.top();
            if(vec[N*3-1-i] < top){
                //次の合計値を更新（最小化）
                minB[i+1] = minB[i] - top + vec[N*3-1-i];
                queB.pop();
                queB.push(vec[N*3-1-i]);
            }else{
                minB[i+1] = minB[i];
            }
        }
   }

    //選ぶ 
    ll ans = -INF;
    for(ll i = N; i <= N*2; i++){
        //cout << i << " " << N*3-i << endl;
        ans = max(maxF[i]-minB[N*3-i], ans);
    }
    cout << ans << endl;

}

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

int main(){
  string T;
  cin >> T;
  int num;
  num = T.length();
  for(int i=0;i<num;i++){
    if(T[i]=='?'){
      T[i]='D';
    }
    cout << T[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3756
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


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

	ll sum = 0;

	vector<ll> A(N);

	rep(i, N)
	{
		cin >> A[i];
		sum += A[i];
	}

	ll count = 0;
	rep(i, N)
	{
		if (A[i] * 4 * M >= sum) count++;
	}

	if (count >= M)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256