akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#define MAX_N 10000
#define MAX_k 9
int N, k;
int D[MAX_k];
int check(int a){
    int i, j, n, m;
n=a;
while(n!=0){
        m = n%10;
        for (j=0; j<k; j++)
            if (m==D[j]) return 1;
            n/=10;
}
    return 0;
}
int main(){
    int i;
    scanf("%d%d", &N, &k);
    for (i=0; i<k; i++)
        scanf("%d", &D[i]);
    i=N;
    while (1)
    {
        if(check(i)==0)break;
        else
        {
            i++;
        }
    }
    printf("%d\n", i);
    return 0;
}


Measured memory_bytes: 1732
from collections import deque

n, m = map(int, input().split())

nodes = {i: set() for i in range(n)}

for _ in range(m):
    a, b = map(int, input().split())
    nodes[a-1].add(b)
    nodes[b-1].add(a)

def bfs(r):
    queue = deque([r])
    ds = [None]*n
    ds[r-1] = 0
    while(queue):
        v = queue.popleft()
        for i in nodes[v-1]:
            if ds[i-1] == None:
                ds[i-1] = ds[v-1] + 1
                queue.append(i)
    return ds

ds = bfs(1)
for i in range(n):
    if i == 0:
        print("Yes")
    else:
        for j in nodes[i]:
            if ds[i]-1 == ds[j-1]:
                print(j)
                break

Measured memory_bytes: 70256
import java.util.Scanner;

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

    public static void main(String[] args) {
        Scanner S = new Scanner(System.in);
        while (S.hasNext()) {
            String s = S.nextLine();
            print(s);
        }
    }

    static String swap(String x) {
        int i = 0;
        String[] s = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
                "t", "u", "v", "w", "x", "y", "z" };
        String[] b = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
                "T", "U", "V", "W", "X", "Y", "Z" };

        while (i < s.length && !x.equals(s[i]))
            i++;
        if (i < s.length)
            return b[i];

        i = 0;
        while (i < b.length && !x.equals(b[i]))
            i++;
        if (i < b.length)
            return s[i];

        return x;
    }

    static void print(String s) {
        String sc = "";
        int i;
        String x;
        for (i = 0; i < s.length(); i++) {
            x = s.substring(i, i + 1);
            x = swap(x);
            sc += x;
        }
        System.out.println(sc);
    }

}


Measured memory_bytes: 32172
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = -1, mini = 9999, counter = 0, s = 0, endp = 0, checker = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[1001][1001];
long long int iremono2[1001];
std::vector<unsigned long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input, one, two;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> input;
	if (input == "A") {
		cout << "T" << endl;
	}
	if (input == "T") {
		cout << "A" << endl;
	}
	if (input == "G") {
		cout << "C" << endl;
	}
	if (input == "C") {
		cout << "G" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//cin.sync_with_stdio(false);

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

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

typedef struct _map{
    int num;
    int x;
    int y;
}Map;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //上右下左
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    
    cin >> n;
    Map map[n];
    map[0].num = 0; map[0].x = 0; map[0].y = 0;
    FOR(i, 1, n + 1){
        cin >> map[i].num >> map[i].x >> map[i].y;
    }
    int res;
    int time;
    bool flag = true;
    rep(i, n){
        res = abs(map[i + 1].x - map[i].x) + abs(map[i + 1].y - map[i].y);
        time = map[i + 1].num - map[i].num;
        if(res <= time){
            res = res % 2;
            time = time % 2;
            if(res == time) flag = true;
            else    flag = false;
        }else{
            flag = false;
        }
    }
    
    if(flag)    cout << "Yes" << endl;
    else    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char s[100005];
int dp[100005][13]; //dp[i][j]表示到第i个字符为止，除以13余j(j表示的是到i-1为止模13余j)有多少种情况
// 难在找出状态转移方程
int main()
{
   // cout<<mod<<'\n';
    
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (s[i] != '?')
        {
            s[i] -= '0';
            for (int j = 0; j < 13; j++)
            {
                dp[i][(j * 10 + s[i]) % 13] = (dp[i][(j * 10 + s[i]) % 13] + dp[i - 1][j]) % mod;
            }
        }
        else
        {
            for (int k = 0; k < 10; k++)
            {
                for (int j = 0; j < 13; j++)
                {
                    dp[i][(j * 10 + k) % 13] = (dp[i][(j * 10 + k) % 13] + dp[i - 1][j]) % mod;
                }
            }
        }
    }
    printf("%d\n", dp[n][5]);
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main()
{
	string First;
	string Second;
	int Judge = 0;
	vector<int> Inner_judge(100, 1);

	cin >> First;
	cin >> Second;

	for(int i = 0; i < First.size(); i++)
	{
		for(int j = 0; j < Second.size(); j++)
		{
			if(Second[j] != First[(i+j) % First.size()]) Inner_judge[i] = 0;
		}
		if(Inner_judge[i] == 1) Judge = 1;
	}

	if(Judge == 0) cout << "No" << endl;
	if(Judge == 1) cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1184
n = int(input())
a = list(map(int, input().strip().split()))

ev = 0
s = 0
for i in range(n):
  if a[i]%2 == 0:
    ev += 1
    if a[i]%3 == 0 or a[i]%5 == 0:
      s += 1

if ev == s:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

int a,b;
string p,q;
p=S.substr(0,2);
a=stoi(p);
q=S.substr(2,2);
b=stoi(q);

if(a==0 && b==0){
cout<<"NA"<<endl;
}
else if(a!=0 && b==0){
if(a<=12){cout<<"MMYY"<<endl;}
else{cout<<"NA"<<endl;}
}
else if(a==0 && b!=0){
if(b<=12){cout<<"YYMM"<<endl;}
else{cout<<"NA"<<endl;}
}
else{if(a>=13 && b>=13){cout<<"NA"<<endl;}
else if(a>=13 && b<=12){cout<<"YYMM"<<endl;}
else if(a<=12 && b>=13){cout<<"MMYY"<<endl;}
else {cout<<"AMBIGUOUS"<<endl;}
}

}


Measured memory_bytes: 256
#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 = 11451419194545;

ll A[100][100];
ll B[100][100];
ll D[100][100];
ll dp[100][100][6500];

int main() {

    ll H, W; cin >> H >> W;

    //vector<vector<ll > > A(100, vector<ll >(100, 0));
    //vector<vector<ll > > B(100, vector<ll >(100, 0));
    //vector<vector<ll > > D(100, vector<ll >(100, 0));
    //vector<vector<map<ll, ll > > > dp(100, vector<map<ll, ll > >(100));
    //vector<vector<vector<ll > > > dp(100, vector<vector<ll > >(100, vector<ll >(6500, -1)));
 
    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            cin >> A[i][j];
        }
    }

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            cin >> B[i][j];
            D[i][j] = abs(A[i][j] - B[i][j]);
        }
    }



    //初期化
    dp[0][0][0] = 1;

    for(ll i = 0; i < H; i++){
        for(ll j = 0; j < W; j++){
            for(ll k = 0; k < 6500; k++){
                if(dp[i][j][k] != 0){
                    ll n = dp[i][j][k];
                    if(k + D[i][j] < 6500){
                        dp[i+1][j][k + D[i][j]] = n + 1;
                        dp[i][j+1][k + D[i][j]] = n + 1;
                    }

                    if(k - D[i][j] < 0){
                        dp[i+1][j][D[i][j] - k] = n + 1;
                        dp[i][j+1][D[i][j] - k] = n + 1;
                    }else{
                        dp[i+1][j][k - D[i][j]] = n + 1;
                        dp[i][j+1][k - D[i][j]] = n + 1;                        
                    }
                    
                    //dp[i+1][j][k + abs(D[i+1][j])] = n + 1;
                    //dp[i+1][j][abs(k - abs(D[i+1][j]))] = n + 1;  

                    //dp[i][j+1][k + abs(D[i][j+1])] = n + 1;
                    //dp[i][j+1][abs(k - abs(D[i][j+1]))] = n + 1;
                }
            }
        }
    }

    ll ans = INF;
    for(ll k = 0; k < 6500; k++){
        if(dp[H][W-1][k] != 0) ans = min(ans, k);
    }

    cout << ans << endl;

}

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

int main()
{
  int N;
  cin >> N;
  priority_queue<
    pair<int,int>,
    vector<pair<int,int>>,
    greater<pair<int,int>>
    > pq;

  rep(i,N) {
    int a;
    cin >> a;
    pq.push(make_pair(a, i));
  }
  
  rep(i,N){
    pair<int,int> p = pq.top(); pq.pop();
    printf("%d", p.second+1);
    if(i==N-1) printf("\n");
    else printf(" ");
  }
  
}



Measured memory_bytes: 1780
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back


signed main(){
    int n;
    cin>>n;
    vector<int> c(n);
    rep(i,n)cin>>c[i];
    
    vector<int> v(n,0);
    int q;
    cin>>q;
    vector<int> t(q),x(q),d(q);
    rep(i,q)cin>>t[i]>>x[i]>>d[i];
    rep(i,q){
        x[i]--;
        if(t[i]==1){   //input
            v[x[i]] += d[i];
            if(v[x[i]]>c[x[i]]){
                cout<<x[i]+1<<endl;
                return 0;
            }
        }else{  //output
            v[x[i]] -= d[i];
            if(v[x[i]]<0){
                cout<<x[i]+1<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
}



Measured memory_bytes: 5204
#include <iostream>
#define NODE_SIZE 25
#define NIL -1

using namespace std;

typedef struct tNode_
{
    int parent, left, right;
}tNode;

int setRoot(tNode node[], int id){
    if(node[id].parent == NIL){ return id; }
    setRoot(node, node[id].parent);
}

void Preorder(tNode node[], int id){
    cout << " " << id;
    if(node[id].left != NIL){ Preorder(node, node[id].left); }
    if(node[id].right != NIL) { Preorder(node, node[id].right); }
}

void Inorder(tNode node[], int id){
    if(node[id].left != NIL){ Inorder(node, node[id].left); }
    cout << " " << id;
    if(node[id].right != NIL) { Inorder(node, node[id].right); }
}

void Postorder(tNode node[], int id){
    if(node[id].left != NIL){ Postorder(node, node[id].left); }
    if(node[id].right != NIL) { Postorder(node, node[id].right); }
    cout << " " << id;
}

int main(){
    tNode node[NODE_SIZE];
    int n, root;

    cin >> n;
    for(int i = 0; i < n; i++){
        node[i].parent = NIL;
        node[i].left = NIL;    
        node[i].right = NIL;
    }
    for(int i = 0; i < n; i++){
        int id, l, r;
        cin >> id >> l >> r;
        node[id].left = l;
        node[id].right = r;
        node[l].parent = id;
        node[r].parent = id;
    }

    root = setRoot(node, 0);

    cout << "Preorder" << endl;
    Preorder(node, root);
    cout << endl;
    
    cout << "Inorder" << endl;
    Inorder(node, root);
    cout << endl;

    cout << "Postorder" << endl;
    Postorder(node, root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  char b;
  cin >> b;
  if (b=='A') {
    cout << 'T' << endl;
  }
  else {
    if (b=='T') {
      cout << 'A' << endl;
    }
    else {
      if (b=='G') {
        cout << 'C' << endl;
      }
      else {
        cout << 'G' << endl;
      }
    }
  }
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define vi vector<int>
#define srt(a) sort(a.begin(), a.end());
#define se second
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

LL res(LL n){
  if(n==1){
    return 1;
  }
  LL an = res(n/2);
  an = (an*2 + 1);
  return an;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    LL h; cin>>h;
    cout<<res(h)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
const long mod=1e9+7;
int main(){
	int N;cin>>N;
	int cnt[N] = {}; int a;
	rep(i,0,N){
		cin>>a; cnt[a]++;
		cnt[abs(N - 2*i - 1)]--;
	}
	rep(i,0,N)if(cnt[i]){
		cout<<0<<endl;
		return 0;
	}
    long res = 1;
	rep(i,0,N/2) (res*=2)%=mod;
    cout<<res<<endl;
}

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

int main() {
	auto optimize_cpp_stdio = []() {
		std::ios::sync_with_stdio(false);
		std::cout.tie(nullptr);
		std::cin.tie(nullptr);
		return 0;
	}();

	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int i = 0; i < n; i++)
		std::cin >> a[i];
	int sum = std::accumulate(a.begin(), a.end(), 0);
	std::pair<int, int> ans(INT_MAX, 0);
	for (int i = 0; i < n; i++)
		ans = std::min(std::make_pair(std::abs(sum - a[i] * n), i), ans);
	std::cout << ans.second << '\n';
 	return 0;
}

Measured memory_bytes: 256
import sys,math
input=sys.stdin.readline
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(100):
    x=math.cos(2*math.pi*i/100)
    y=math.sin(2*math.pi*i/100)
    ax=0
    ay=0
    for dx,dy in xy:
        if x*dx+y*dy>=0:
            ax+=dx
            ay+=dy
    ans=max(ans,(ax**2+ay**2)**0.5)
print(ans)


Measured memory_bytes: 39152
#include<stdio.h>
int main(void){
    int a, b;
    char op;
    while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '+') {
     printf("%d\n", a + b);
    }
    if ( op == '-' ){
    printf("%d\n", a - b);
    } 
    if ( op == '*' ){
    printf("%d\n", a * b);
    } 
    if ( op == '/' ){
    printf("%d\n", a / b);
    } 
    if( op == '?'){
    break;
    }
    }
    return 0;
}



Measured memory_bytes: 2104
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if x  == 500*i + 100*j + 50*k:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]
r=-1
for i in range(10**N):
    n=str(i)
    l=len(n)
    if l!=N:
        continue
    f=1
    for s,c in SC:
        if not (s<=l and n[s-1]==str(c)):
            f=0
    if f==1:
        r=i
        break
print(r)

Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a = [LI() for _ in range(n)]
        b = []
        for _ in range(4):
            b += [c for c in S()]
        s = set()
        ms = 2**16 - 1
        ii = [2**i for i in range(16)]
        for h, w in a:
            for i in range(-h+1, 4):
                for j in range(-w+1, 4):
                    mask = ms
                    for k in range(max(0, i), min(4, i+h)):
                        for l in range(max(0, j), min(4, j+w)):
                            mask -= ii[k*4+l]
                    s.add(mask)
        ta = []
        for mask in s:
            for c in 'RGB':
                t = 0
                for i in range(16):
                    if ii[i] & mask:
                        continue
                    if b[i] == c:
                        t += ii[i]
                if t > 0:
                    ta.append((mask, t))

        v = collections.defaultdict(bool)
        q = set([0])
        r = 0
        while q:
            r += 1
            nq = set()
            for c in q:
                v[c] = True
            for c in q:
                for mask, t in ta:
                    n = (c & mask) + t
                    if v[n]:
                        continue
                    if n == ms:
                        return r
                    nq.add(n)
            q = nq

        return -1

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))
        break

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 18216
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		SortedMap<Long, Integer> AB = new TreeMap<Long, Integer>();
		long ans = 0;

		for (int i = 0; i < N; i++) {
			Long A= reader.nextLong();
			int B = reader.nextInt();
			if (AB.containsKey(A)) {
				AB.put(A, AB.get(A)+B);
			} else {
				AB.put(A, B);
			}
		}

		for (Entry<Long, Integer> entry : AB.entrySet()) {
			if (M <= 0) {
				break;
			} else {
				long key = entry.getKey();
				int value = entry.getValue();
				if (value > M) {
					ans += M * key;
					M = 0;
				} else {
					ans += value * key;
					M -= value;
				}
			}
		}
		System.out.print(ans);
		reader.close();
	}
}



Measured memory_bytes: 97824
use std::io::stdin;

fn main() {
    let mut s = String::new();

    stdin().read_line(&mut s).ok();
    let o: Vec<char> = s.trim().chars().collect();
    s.clear();

    stdin().read_line(&mut s).ok();
    let e: Vec<char> = s.trim().chars().collect();

    let mut res = vec!['_'; o.len() + e.len()];
    if o.len() > e.len() {
        res[o.len() + e.len() - 1] = o[o.len() - 1];
    }

    for ((i, &o_i), e_i) in o.iter().enumerate().zip(e) {
        res[i * 2] = o_i;
        res[i * 2 + 1] = e_i;
    }

    let res_str: String = res.into_iter().collect();
    println!("{}", res_str);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int N,K,A=0;cin>>N>>K;
  vector<pair<int,int>>X(N);
  for(int i=0;i<N;i++)cin>>X.at(i).first>>X.at(i).second;
  sort(X.begin(),X.end());
  while(K>X.at(A).second)K-=X.at(A).second,A++;
  cout<<X.at(A).first<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;

    if (n % (2 * d + 1) == 0) {
        cout << n / (2 * d + 1) << endl;
    }else{
        cout << n / (2 * d + 1) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans = (x / 11) * 2;
	x %= 11;
	if(x == 0) ;
	else if(x <= 6) ++ans;
	else ans += 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N, L, Q, B;
	long x[100001];
	long i, j, k;
	long a, b, tmp;
	long move1day[100001];
	long moveBday[100001] = {0};
	long right;
	long ans[100001] = {0};
	
	scanf("%ld", &N);
	B = sqrt(N);
	for(i=1;i<=N;i++) scanf("%ld", &x[i]);
	scanf("%ld", &L);
	
	/* 各ホテルから1日でどこまでいけるか計算 O(N) */
	right = 2;
	for(i=1;i<=N;i++) {
		for(j=right;j<=N;j++) {
			if(x[j] - x[i] > L) {
				j--;
				break;
			}
		}
		move1day[i] = j;
		right = j;
	}
	
	/* 各ホテルから√N日でどこまでいけるか計算 O(N√N) */
	for(i=1;i<=N;i++) {
		k = i;
		for(j=0;j<B;j++) {
			if(k >= N) break;
			k = move1day[k];
		}
		if(j == B) moveBday[i] = k;
	}
	
	scanf("%ld", &Q);
	for(i=1;i<=Q;i++) {
		scanf("%ld %ld", &a, &b);
		
		if(a > b) { tmp = a; a = b; b = tmp; }
		
		/* √N日ずつ移動する */
		j = a;
		while(moveBday[j] > 0 && moveBday[j] < b) {
			j = moveBday[j];
			ans[i] += B;
		}
		
		/* 1日ずつ移動する */
		while(j < b) {
			j = move1day[j];
			ans[i]++;
		}
	}
	
	for(i=1;i<=Q;i++) printf("%ld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3968
# Problem E - Yutori
# 上限と下限の一致

# input
N, K, C = map(int, input().split())
S = list(input())

# initialization
left_list = [0]*(N+1)
right_list = [0]*(N+1)

# left count
i = 0
num_count = 1
while i<N:
    c = S[i]
    if c=='o':
        left_list[i+1] = num_count
        i += C+1
        num_count += 1
    else:
        i += 1

# right count
i = N-1
num_count = K
while i>=0:
    c = S[i]
    if c=='o':
        right_list[i+1] = num_count
        i -= C+1
        num_count -= 1
    else:
        i -= 1

# check
for i in range(1, N+1):
    if not left_list[i]==0 and not right_list[i]==0:
        if left_list[i]==right_list[i]:
            print(i)


Measured memory_bytes: 64880
use proconio::{input, fastout};

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }

    let mut last = vec![0; TYPE_COUNT];

    for s in ss {
        let mut max = 0;
        let mut index = 0;
        for (i, x) in s.into_iter().enumerate() {
            let x = x + cc[i] * last[i] * 4;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        println!("{}", index+1);
    }
}


Measured memory_bytes: 2344
from fractions import gcd

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

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]


for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

M = [0 for _ in range(N)]

for i in range(N):
    M[i] = gcd(L[i], R[i+1])

print(max(M))


Measured memory_bytes: 16152
def answer(n: int) -> int:
    if n == 1:
        return 1

    two_previous_l = 2
    previous_l = 1
    l = 3
    for _ in range(n - 2):
        two_previous_l = previous_l
        previous_l = l
        l = previous_l + two_previous_l

    return l


def main():
    n = int(input())
    print(answer(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 3e5 + 7;
const double pi = acos(-1);
int fact[maxn], inv[maxn];

int binpow(int a, int b){
    if(b == 0){
        return 1;
    }
    int res = 1;
    while(b){
        if(b & 1) res = (res * a) % modd2;
        a = (a * a) % modd2;
        b >>= 1;
    }
    return res;
}

void init(){
    int i;
    fact[0] = 1;
    inv[0] = 1;
    for1(i, 1, maxn){
        fact[i] = (fact[i - 1] * i) % modd2;
        inv[i] = (inv[i - 1] * binpow(i, modd2 - 2)) % modd2;
    }
}

int nCk(int n, int k){
    if(n < k) return 0;
    return (((fact[n] * inv[k]) % modd2) * inv[n - k]) % modd2;
}

void solve(){
    int n, a, b, k, l, r, x, y;
    cin >> n >> a >> b >> k;
    init();
    int ans = 0;
    for1(x, 0, n){
        if((k - x * a) % b == 0){// cout << x << ' ';
            y = (k - x * a) / b; //cout << y << ' ';
            if(y >= 0 && y <= n){
                int temp = (nCk(n, x) * nCk(n, y)) % modd2;
                ans = (ans + temp) % modd2;
            }
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main()
{
    long long int x, i, n, sum, min, max, input;
   
    cin >> n;
    sum = 0;
    x = 1;
    
    if ( n == 1 )
        {
            cin >> input;
            max = min = sum = input;
        }
    else {    
    for(i=1; i<=n; i++)
    {
        cin >> input;
        sum = sum + input;
        if(input > max)
            max = input;
        if( x == 1 )
            {
                min = input;
                x = x + 1;
            }
        else if(input < min)
            min = input;
    }
    }
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <time.h>
int main() {
  long P,Q,N,count,score,j,a,b;
  score=1.0;
  cin>>N>>P;
  Q=P+1;
  if(N==1){
cout<<P<<endl;
  }else{
  for(j=2;pow(j,N)<Q;j++){
  for(;;){
    
  if(fmod(P,pow(j,N))==0){
  P=P/pow(j,N);
    Q=P+1;
   score=score*j;
  } else{
    break;
  }
  
  }
  }
    cout<<score<<endl;
  }
  
   
}

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

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

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

typedef pair<long, long> P;

long GCD(long a, long b){
    if(b == 0) return a; 
    if(a < b) return GCD(b, a);
    else return GCD(b, a%b);
}

int main()
{   
    int A, B, H, M; cin >> A >> B >> H >> M;
    double ans = sqrt((double)(A*A)+(double)(B*B)-(double)(2*A*B)*cos(((double)H/12.0-11.0/720.0*(double)M)*2.0*M_PI));
    cout << fixed;
    cout << setprecision(10) << ans << endl;
    /*
    int N; cin >> N;
    long A[200005], B[200005];
    REP(i, N) cin >> A[i] >> B[i];
    int bothzero = 0, azero = 0, bzero = 0, nonzero = 0;
    vector<P> ba(N), ab(N);
    REP(i, N){
        if(A[i] == 0l && B[i] == 0l) bothzero++;
        else if(A[i] == 0l && B[i] != 0l) azero++;
        else if(A[i] != 0l && B[i] == 0l) bzero++;
        else{
            long temp;
            temp = GCD(abs(A[i]), abs(B[i]));
            if(B[i]/temp > 0){
                ba[nonzero].first = B[i]/temp;
                ba[nonzero].second = A[i]/temp;
            }else{
                ba[nonzero].first = -B[i]/temp;
                ba[nonzero].second = -A[i]/temp;
            }

            if(A[i]/temp > 0){
                ab[nonzero].first = A[i]/temp;
                ab[nonzero].second = -B[i]/temp;
            }else{
                ab[nonzero].first = -A[i]/temp;
                ab[nonzero].second = B[i]/temp;
            }
            nonzero++;
        }
    }
    cout << nonzero << endl;
    REP(i, nonzero) cout << ab[i].first << " " << ab[i].second << endl;
    cout << endl;
    REP(i, nonzero) cout << ba[i].first << " " << ba[i].second << endl;

    long mod = 1000000007;
    long ans = 0l;
    ans += bothzero; ans %= mod;
    long temp;
    temp = azero*(azero-1l); temp %= mod;
    temp *= modinv(2l, mod); temp %= mod;
    ans += temp; ans %= mod;
    temp = (azero * nonzero) % mod;
    ans += temp; ans %= mod;
    temp = bzero*(bzero-1l); temp %= mod;
    temp *= modinv(2l, mod); temp %= mod;
    ans += temp; ans %= mod;
    temp = (bzero * nonzero) % mod;
    ans += temp; ans %= mod;
    */



    return 0;
}



Measured memory_bytes: 4296
import           Data.List
import           Data.Maybe
import qualified Data.ByteString.Char8         as C8

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    [n, m] <- getInts
    xs     <- getInts
    print $ solve (m - n) (sort xs)

solve :: Int -> [Int] -> Int
solve k xs = sum . take k . sort . zipWith (-) (tail xs) $ xs


Measured memory_bytes: 17788
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            ushort[] u = (Console.ReadLine().Split(' ').Select(_ => ushort.Parse(_)).ToArray());
            Console.WriteLine(string.Format("{0} {1}",u[0]*u[1],u[0]*2+u[1]*2));
        }
    }
}


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

int selectionSort(int A[], int N) {
	int i, j, t, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for ( j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		t = A[i];
		A[i] = A[minj];
		A[minj] = t;
		if (i != minj) sw++;
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;

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

	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
}


Measured memory_bytes: 3080
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
	public static final int[] blockW = {4,2};
	public static final int[] blockH = {2,4};
	public static final int[] vx = {1,0,-1,0};
	public static final int[] vy = {0,-1,0,1};
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while(true) {
			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w+h==0) {
				break;
			}

			Pos2d start = new Pos2d(sc.nextInt()-1,sc.nextInt()-1);
			Pos2d goal = new Pos2d(sc.nextInt()-1,sc.nextInt()-1);

			int n = sc.nextInt();
			int[][] maze = new int[w][h];
			for (int i=0;i<n;i++) {
				int c = sc.nextInt();
				int d = sc.nextInt();
				int x = sc.nextInt()-1;
				int y = sc.nextInt()-1;
				for (int j=0;j<blockW[d];j++) {
					for (int k=0;k<blockH[d];k++) {
						maze[x+j][y+k] = c;
					}
				}
			}

			boolean ans = false;
			if (maze[start.x][start.y]!=0) {
				int mc = maze[start.x][start.y];
				boolean[][] reach = new boolean[w][h];
				Queue<Pos2d> q = new ArrayDeque<Pos2d>();
				q.offer(start);
				while(!q.isEmpty()) {
					Pos2d p = q.poll();
					for(int i=0;i<4;i++) {
						int nx = p.x + vx[i];
						int ny = p.y + vy[i];
						if (nx>= 0 && nx<w && ny>=0 && ny<h) {
							if (maze[nx][ny]==mc) {
								if (!reach[nx][ny]) {
									reach[nx][ny]=true;
									q.offer(new Pos2d(nx,ny));
								}
							}
						}
					}
				}
				ans = reach[goal.x][goal.y];
			}
			System.out.println(ans ? "OK" : "NG");
		}
	}
}
class Pos2d {
	public int x;
	public int y;
	public Pos2d(int x,int y) {
		this.x = x;
		this.y = y;
	}
}

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

int a[200005];

int main() {
  int n;
  cin >> n;
  for (int ni = 0; ni < n; ni++) {
    cin >> a[ni];
  }
  int left = 0;
  int right = 1;
  int cur = a[0];
  long long answer = 0;
  while (left < n) {
    while (right < n) {
      if ((cur & a[right]) > 0) break;
      cur |= a[right];
      right++;
    }
    answer += right - left;
    cur ^= a[left];
    left++;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MAX(type)   std::numeric_limits<type>::max()
#define MIN(type) std::numeric_limits<type>::min()
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

ll mod = 1e9+7;
ll dp[1010][1010];
char m[1010][1010];
ll r,c;
ll fun(ll i,ll j){
	ll &ref = dp[i][j];
	if(i==r && j==c)
		return ref = 1;
	if(ref!=-1)
		return ref;
	ref = 0;
	if(i+1<=r ){
		if(m[i+1][j]=='.')
			ref = fun(i+1,j),ref%=mod;
		else if(j+1>c || m[i][j+1]=='#')
			return ref = 0;//infinity 

	}
	if(j+1<=c){
		if(m[i][j+1]=='.')
			return ref +=  fun(i,j+1),ref%=mod;
		else if(i+1>r || m[i+1][j]=='#')
			return ref = 0;
	}
	return ref;
}
int main(){
	fast;
	cin>>r>>c;
	memset(dp,-1,sizeof(dp));
	for(ll i=1;i<=r;++i){
		for(ll j=1;j<=c;++j){
			cin>>m[i][j];
		}
	}
	ll ans = fun(1ll,1ll);
/*
	for(ll i=1;i<=r;++i){
		for(ll j=1;j<=c;++j){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	cout<<ans%mod;
	return 0;
}

Measured memory_bytes: 9344
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(int argc, char* argv[]) {
	ll n, m, sum = 0;
	cin >> n >> m;
	ll a[10004];
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (n - sum <= -1)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << n-sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,j=1,max,a[3];
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	if(n==2){
		if(a[1]<=a[0]) max=a[0];
		else max=a[1];
		while(1){
			if(j==max) break;
			if(a[0]%j==0 && a[1]%j==0){
				cout<<j<<endl;
			}
			j+=1;
		}
	}
	if(n==3){
		if(a[0]>=a[1] && a[0]>=a[2]) max=a[0];
		else if(a[1]>=a[0] && a[1]>=a[2]) max=a[1];
		else max=a[2];
		while(1){
			if(j==max) break;
			if(a[0]%j==0 && a[1]%j==0 && a[2]%j==0){
				cout<<j<<endl;
			}
			j+=1;
		}
	}
	return 0;
}


Measured memory_bytes: 3072
N,M= list(map(int , input().split()))
H = list(map(int , input().split()))
A = []
B = []
for i in range(M):
    x,y=[int(i) for i in input().split()]
    A.append(x)
    B.append(y)
S = []
for j in range (M):
    if H[A[j]-1] > H[B[j]-1]:
        S.append(B[j])        
    elif H[A[j]-1] < H[B[j]-1]:
        S.append(A[j])
    else:
        S.append(A[j])
        S.append(B[j])
S = list(set(S))
print(N-len(S))


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

int main() {
	map<string, int> m;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
    	string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x " << m["WA"] << "\n";
    cout << "TLE x " << m["TLE"] << "\n";
    cout << "RE x " << m["RE"] << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int p[20];
int h[20];
double ABS(double a){return max(a,-a);}
int main(){
	int d,n,b;
	scanf("%d%d%d",&d,&n,&b);
	for(int i=0;i<n;i++){
		scanf("%d%d",p+i,h+i);
	}
	double ret=999999999.9;
	for(int i=1;i<=b+1;i++){
		bool dame=false;
		for(int j=0;j<n;j++)if(i*p[j]%d==0)dame=true;
		if(dame)continue;
		double l=0;
		double r=999999999.9;
		for(int j=0;j<100;j++){
			double m=(l+r)/2;
			bool ok=true;
			for(int k=0;k<n;k++){
				double x=(double)p[k];
				while(x>(double)d/i)x-=(double)d/i;
				double w=ABS((double)d/i/2-x);
				double u=(double)d/i/2;
				double he=m*(1.0-w*w/u/u);
				if(he<(double)h[k])ok=false;
			}
			if(ok)r=m;
			else l=m;
		}
		double L=l;
		double R=999999999.9;
		for(int j=0;j<100;j++){
			double m1=(L*2+R)/3;
			double m2=(L+R*2)/3;
			double vy=sqrt(m1*2);
			double t=vy*2*i;
			double vx=(double)d/t;
			double v1=sqrt(vx*vx+vy*vy);
			ret=min(ret,v1);
			vy=sqrt(m2*2);
			t=vy*2*i;
			vx=(double)d/t;
			double v2=sqrt(vx*vx+vy*vy);
			ret=min(ret,v2);
			if(v1<v2)R=m2;else L=m1;
		}
	}
	printf("%.12f\n",ret);
}

Measured memory_bytes: 1068
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
bool f(const pair<string,int> &a,const pair<string,int> &b)
{
    return(a.second>b.second);
}
bool lexi(const pair<string,int> &a,const pair<string,int> &b)
{
    return (a.first<b.first);
}
int main()
{
    int n;
    cin>>n;
    string s;
    map<string,int> m;
    vector<pair<string,int>>A;
    vector<pair<string,int>>C;
    int maxi=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]=m[s]+1;
       // maxi=max(maxi,m[s]);
    }
    //auto it;
    for(auto it=m.begin();it!=m.end();it++)
    {
        A.push_back(make_pair(it->first,it->second));
    }
    sort(A.begin(),A.end(),f);
    maxi=A[0].second;
    auto it2=A.begin();
    for(int i=0;i<A.size();i++)
    {
        if(A[i].second==maxi)
        {
            C.push_back(make_pair(A[i].first,A[i].second)); //pushing max freq elements to array
        }
    }
    sort(C.begin(),C.end(),lexi);
    for(int i=0;i<C.size();i++)
    {
        cout<<C[i].first<<endl;
    }






}


Measured memory_bytes: 41900
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#define MAX 100
#define INFTY INT_MAX
#define WHITE 0
#define GRAY 1
#define BLACK 2

/* Prototype Declaration */
void enqueue(int);
int dequeue(void);
int isEmpty(void);
int isFull(void);
void breadthFirstSearch(int);

/* Global Variables */
int Queue[MAX];
int head, tail;
int AM[MAX][MAX], color[MAX], d[MAX];
int n;

int main() {
  int i, j;
  int u, k, v;

  scanf("%d", &n);

  //Initialize Adjacency Matrix
  for ( i = 0; i < n; i++ )
    for ( j = 0; j < n; j++ )
      AM[i][j] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%d%d", &u, &k);
    for ( j = 0; j < k; j++ ) {
      scanf("%d", &v);
      AM[u - 1][v - 1] = 1;
    }
  }

  breadthFirstSearch(0);

  for ( i = 0; i < n; i++ ) {
    printf("%d ", i + 1);
    if ( d[i] == INFTY )
      printf("-1\n");
    else
      printf("%d\n", d[i]);
  }

  return 0;
}

/* Queue Statements */
void enqueue(int x) {
  if ( isFull() ) {
    fprintf(stderr, "Error : Queue Overflow\n");
    exit(1);
  }

  Queue[tail] = x;

  // Ring Buffer
  if ( tail + 1 == MAX ) tail = 0;
  else tail++;

}

int dequeue(void) {
  int e;

  if ( isEmpty() ) {
    fprintf(stderr, "Error : Queue Underflow\n");
    exit(2);
  }

  e = Queue[head];

  // Ring Buffer
  if ( head + 1 == MAX ) head = 0;
  else head++;

  return e;
}

int isEmpty() {
  return ( head == tail ) ? 1 : 0;
}

int isFull() {
  return ( head == ((tail + 1) % MAX) ) ? 1 : 0;
}

/* Breadth First Search Statement */
void breadthFirstSearch(int s) {
  int i, u, v;

  for ( i = 0; i < n; i++ ) {
    color[i] = WHITE;
    d[i] = INFTY;
  }

  color[s] = GRAY;
  d[s] = 0;
  enqueue(s);

  while ( !isEmpty() ) {
    u = dequeue();
    for ( v = 0; v < n; v++ ) {
      if ( AM[u][v] == 1 && color[v] == WHITE ) {
        color[v] = GRAY;
        d[v] = d[u] + 1;
        enqueue(v);
      }
    }
    color[u] = BLACK;
  }
}

Measured memory_bytes: 632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,c,d,n;
    cin>>a>>b>>c>>d>>n;
    if(b>2*a)b=2*a;
    if(c>2*b)c=2*b;
    if(c>4*a)c=4*a;
    if(d>2*c)d=2*c;
    if(d>4*b)d=4*b;
    if(d>8*a)d=8*a;
    cout<<n/2*d+n%2*c<<endl;
}

Measured memory_bytes: 256
def make_line(line_str):
    x1, y1, x2, y2 = map(int, line_str.split())
    return (x1 + 1j * y1, x2 + 1j * y2)
 
 
def cross_point(l1, l2):
    (p1, p2), (p3, p4) = l1, l2
    v34, v12, v23, v31 = p4 - p3, p2 - p1, p3 - p2, p1 - p3
    s1 = v34.real * v31.imag - v34.imag * v31.real
    s2 = v34.real * v23.imag - v34.imag * v23.real
    if s1 + s2 == 0:
        return None
    rt = s1 / (s1 + s2)
    if 0 < rt < 1:
        cp = (p1 + v12 * rt) * 1e10
        return (int(cp.real), int(cp.imag))
    else:
        return None
 
 
while True:
    n = int(input())
    if not n: break
    lines = [make_line(input()) for _ in range(n)]
 
    num_crossed = 0
    for i, line in enumerate(lines):
        crossed = set(cross_point(line, l) for l in lines[:i])
        crossed.discard(None)
        num_crossed += len(crossed)
 
    print(1 + n + num_crossed)

Measured memory_bytes: 7724
#include <iostream>
#include <math.h>

using namespace std;

int main(){
  int N;
  int n_digit[4];
  cin>>N;
  for(int i=0;i<4;i++){
    n_digit[i]=(N%int(pow(10,i+1)))/pow(10,i);
  }
  for(int i=0;i<2;i++){
    if(n_digit[i]==n_digit[i+1]&&n_digit[i+1]==n_digit[i+2]){
      cout<<"Yes\n";
      return 0;
    }
  }
  // cout<<n_digit[0]<<n_digit[1]<<n_digit[2]<<n_digit[3];
  cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
a = []
M = 0
for i in range(N):
  a.append(tuple(map(int,input().split())))
a.sort()
for i in range(N):
    K = K-a[i][1]
    if K <= 0:
        print(a[i][0])
        break

Measured memory_bytes: 16952
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define ll  long long
  #define ld long double
  #define pb push_back
  #define mp3 make_pair
  #define rep1(i,a,b) for(ll i=a;i<=b;i++)
  #define rep2(i,a,b) for(ll i=a;i<b;i++)
  const ll  mod=1e9+7;
  const ll INF=1e18;
  template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
  template<typename T> T add(T a,T b,ll m){a+=b;while(a>=0)a-=m;while(a<0)a+=m; return a;}
  template<typename T> T mul(T a,T b,ll m){return (a*1ll*b)%m;}
  
  int main(){
    IOS;
   ll n;
   cin>>n;
   ll x=pow(10ll,n,mod);
   ll p=2*pow(9ll,n,mod);
   ll ans=x-p;
   ans=add(ans,pow(8ll,n,mod),mod);
   cout<<ans<<endl;

  }

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

int main(){
  string s;
  cin >> s;
  int a=-1;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='C' && a==-1) a=0;
    if(s[i]=='F' && a==0) a=1;
  }
  if(a==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3628
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
ll f(ll a, ll b) {
  ll mx = max(a, b);
  ll mn = min(a, b);
  if(mn == mx) return mx;
  if(mx % mn == 0) return 2 * mx - mn;
  return 2 * mn * (mx / mn) + f(mn, mx % mn);
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, X; cin >> N >> X;
  cout << N + f(X, N - X) << endl;
  return 0;
}

Measured memory_bytes: 256
#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(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, K;
    cin >> N >> K;
    int a[N];
    rep(i, N) cin >> a[i];
    sort(a, a+N, greater<int>());
    bool dp[N+1][K+1];
    fill(dp[0], dp[N+1], false);
    dp[0][0] = true;
    rep(i, N){
        rep(j, K+1){
            if(!dp[i][j]) continue;
            dp[i+1][min(j+a[i], K)] = true; 
            dp[i+1][j] = true;
        }
    }
    int cnt = 0;
    rep3(i, N-1, 0){
        bool res = false;
        rep2(j, max(0, K-a[i]), K-1){
            if(dp[i][j]) res = true;
        }
        if(res) break;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 24704
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int a,b,c;

int main()
{
  cin >> a >> b >> c;
  if(a <= c && c <= b) puts("Yes");
  else puts("No");
  return 0;
}


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

ans_omosa = 0
ans_sugar = 0
per_checker = 0

for _a in range(f // (a * 100)+1):
    for _b in range(f // (b * 100)+1):
        for _c in range((f // c)+1):
            for _d in range((f // d)+1):
                # 砂糖溶かしすぎチェック
                if (_c * c + _d * d) > (_a * a + _b * b) * e:
                    break
                # 重さチェック
                elif (_c * c + _d * d) + (_a * a + _b * b) * 100 > f:
                    break
                elif (_a * a * 100 + _b * b * 100 + _c * c + _d * d) == 0:
                    break
                else:
                    if per_checker < (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d):
                        per_checker = (_c * c + _d * d) / (_a * a * 100 + _b * b * 100 + _c * c + _d * d)
                        ans_omosa = (_c * c + _d * d) + (_a * a + _b * b) * 100
                        ans_sugar = (_c * c + _d * d)
                        #print(_a, a, _b, b, _c, c, _d, d)

print("{} {}".format(max(a*100,ans_omosa), ans_sugar))

Measured memory_bytes: 3064