akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h, w;
    cin >> h >> w;
    vector<string> lines(h + 2);
    
    for (int i = 0; i < h + 2; i++){
        if((i==0)or(i==h+1)){
            for (int j = 0; j < w; j ++){
                lines[i] += "#";
            }
        }else{
            cin >> lines[i];
        }
    }
    for (int i = 0; i < h + 2; i++){
        cout << "#";
        cout << lines[i];
        cout << "#" << endl;
    }
}


Measured memory_bytes: 256
/*
  A - ι⊥l
  Contest 058
  Rakesh Kumar --> 23/08/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0, c = 0;
    std::cin >> a >> b >> c;
    if (b - a == c - b)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;

    return 0;
}


Measured memory_bytes: 3660
N = int(input())
lis = [int(input()) for n in range(N)]
lis = sorted(lis)
half = len(lis) // 2
low = lis[:half]
high = lis[:half-1:-1]
    

def output(low_lis, high_lis):
    ll, hl = len(low_lis), len(high_lis)
    if ll > hl:
        return calc(low_lis, high_lis)
    return calc(high_lis, low_lis)

def calc(lis1, lis2):
    left = lis1[0]
    right = left
    res = 0
    try:
        for n in range((len(lis1) + 1) // 2):
            res += abs(left - lis1[2*n])
            res += abs(right - lis2[2*n])
            res += abs(lis1[2*n + 1] - lis2[2*n])
            res += abs(lis2[2*n+1] - lis1[2*n])
            right = lis1[2*n + 1]
            left = lis2[2*n+1]
        return res
    except IndexError:
        return res

res1 = output(low, high)
res2 = 0
if len(lis) % 2:
    low = lis[:half + 1]
    high = lis[:half:-1]
    res2 = output(low, high)
    
print(max(res1, res2))

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

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::string a,b;
    int count = 0;
    std::cin >> a >> b;
    for (int i = 0; i < a.size(); ++i) {
        if (a[i]!= b[i]){
            ++count;
        }
    }
    std::cout << count;
}

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

int main(){
    string S;cin>>S;
    int l=S.size();
    int res=99999;
    for(int i=0;i<l-2;i++){
        int n=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        res=min(res,abs(n-753));

           }
    cout<<res<<endl;
}

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

int main() {
	int d;
	long long g;
	cin >> d >> g;
	vector<long long>p(d), c(d);
	for (int i = 0;i < d;++i)cin >> p[i] >> c[i];
	long long ans = 1 << 30;
	for (int bit = 0;bit < (1 << d);++bit) {
		long long sum = 0, num = 0;
		for (int i = 0;i < d;++i) {
			if (bit&(1 << i)) {
				sum += c[i] + p[i] * (i + 1) * 100;
				num += p[i];
			}
		}
		if (sum >= g)ans = min(ans, num);
		else {
			for (int i = d - 1;i >= 0;--i) {
				if (bit&(1 << i))continue;
				for (int j = 0;j < p[i];++j) {
					if (sum >= g)break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			ans = min(ans, num);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 1; i <= (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main(){
  ll n;
  cin >> n;
  int ans = 20;
  int until = sqrt(n);
  rep(i,until){
    if (n % i == 0){
      int b = n / i;
      int f = 0;
      while (b != 0){
        ++f;
        b /= 10;
      }
      if (ans > f) ans = f;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    rods = string_to_int(inputs[0])
    rods_counter = collections.Counter(rods)
    available_rods = []
    four_count_rods = []
    for length, count in rods_counter.items():
        if count >= 2:
            available_rods.append(length)
        if count >= 4:
            four_count_rods.append(length)
    available_rods.sort()
    four_count_rods.sort()

    max_square = []

    if len(available_rods) < 2:
        max_square.append(0)
    else:
        max_square.append(available_rods[-1] * available_rods[-2])

    if len(four_count_rods) < 1:
        max_square.append(0)
    else:
        max_square.append(four_count_rods[-1] * four_count_rods[-1])
    return max(max_square)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 72736
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string s;
    cin >> s;
    bool N=false, W=false, S=false, E=false;
    REP(i, s.length()){
        switch (s[i])
        {
        case 'N':
            N=true;
            break;
        case 'W':
            W=true;
            break;
        case 'S':
            S=true;
            break;
        case 'E':
            E=true;
            break;
        default:
            break;
        }
    }
    if(N&&S&&W&&E || N&&S&&!W&&!E || !N&&!S&&W&&E){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string A;
	cin>>A;
	if(A=="RRR"){
			cout<<3;
		}	
	else if(A=="SSS"){
		cout<<0;
	}
	else if(A=="SRR"||A=="RRS"){
		cout<<2;
	} 
	else if(A=="SRS"||A=="RSS"||A=="SSR"||A=="RSR"){
		cout<<1;
	}
	return 0;
}

Measured memory_bytes: 3588
N, M = map(int, input().split())
ans = {}
for i in range(M):
    p, s = list(input().split())
    int(p)
    if p not in ans:
        ans[p] = {"AC": False, "WA": 0}
    if s == "AC":
        ans[p]["AC"] = True
        continue
    if s == "WA":
        if ans[p]["AC"] == True:
            continue
        ans[p]["WA"] += 1
ac = 0
wa = 0
for k, v in ans.items():
    if v["AC"]:
        ac += 1
        wa += v["WA"]
print(ac, wa)

Measured memory_bytes: 44408
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func isPrime(x int) bool {
	y := int(math.Sqrt(float64(x)))
	for i := 2; i <= y; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	x := nextInt()
	for ; !isPrime(x); x++ {
	}
	fmt.Println(x)
}


Measured memory_bytes: 640
using System.Collections.Generic;
using System;

public class Key
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var d = new Dictionary<char, Key>();
        var map = new char[,] { { 'A', 'B', 'C' }, { 'D', 'E', 'F' }, { 'G', 'H', 'I' } };
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++) d[map[i, j]] = new Key { x = i, y = j };
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        for (int i = 0; i < 1000; i++)
        {
            var s = Console.ReadLine().Trim();
            if (checkPw(d, map, s, dx, dy)) Console.WriteLine(s);
        }
    }
    public static bool checkPw(Dictionary<char, Key> d, char[,] map, string s, int[] dx, int[] dy)
    {
        var prekey = s[0];
        for (int i = 1; i < s.Length; i++)
        {
            var okflg = false;
            for (int j = 0; j < 4; j++)
            {
                var nx = d[prekey].x + dx[j];
                var ny = d[prekey].y + dy[j];
                if (nx >= 0 && nx < 3 && ny >= 0 && ny < 3 && map[nx, ny] == s[i]) { okflg = true; break; }
            }
            if (okflg) prekey = s[i];
            else return false;
        }
        return true;
    }
}

Measured memory_bytes: 9384
S = input()

num = 0

r_lst = [0] * 2019
r_lst[0] = 1
cnt = 0
for i, s in enumerate(S[::-1]):
    num = (num + pow(10, i, 2019) * int(s)) % 2019
    cnt += r_lst[num]

    r_lst[num] += 1


print(cnt)


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

int main(){
  int n,q;
  string s;
  cin>>n>>q>>s;
  vector<int>sum(n+1,0);
  vector<int>r(q),l(q);
  for(int i=0;i<q;i++){
    cin>>l[i]>>r[i];
  }
  for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C'){
      sum[i+1]=sum[i]+1;
    }
    else {
      sum[i+1]=sum[i];
    }
  }
  for(int i=0;i<q;i++){
    cout<<sum[r[i]]-sum[l[i]]<<endl;
  }
}
  
  


Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//??????????????°??¨(min????§?????????§???????????°?????????????????§??¨???)
//less???greater???Comp?????\?????????
//???????§??????????operator()???????????????????????§???OK
//??????RMQ<int,less<int>>tree(N,INT_MAX);
template<typename T, typename Comp>
class RMQ {
private:
	const T DEF;//??????????????????(min??§???INF???sum??§???0??????)
	vector<T> seg;//????????????
	int width;//?????°??¨??????(???????????§????????§????????????)
	T query_raw(int a, int b, int k, int l, int r)const {
		if (a >= r || b <= l)return DEF;
		if (a <= l && r <= b)return seg[k];
		return min(
			query_raw(a, b, 2 * k + 1, l, (l + r) / 2),
			query_raw(a, b, 2 * k + 2, (l + r) / 2, r), Comp());
	}
public:
	//?????????n?????????????????????def????????°??¨?????????
	RMQ(int n, T def) :DEF(def) {
		width = 1;
		while (width < n)width *= 2;
		seg.assign(width * 2 - 1, DEF);
	}
	//??????[a,b)????????¨???????????????????????????
	T query(int a, int b)const { return query_raw(a, b, 0, 0, width); }
	//x?????????????´????k?????´??°??????
	void update(int k, T x) {
		k += width - 1;
		seg[k] = x;
		while (k > 0) {
			k = (k - 1) / 2;
			seg[k] = min(seg[2 * k + 1], seg[2 * k + 2], Comp());
		}
	}
	//???????????¨???????????????
	void init(const vector<T>& vec) {
		for (int i = 0; i < min(width, (int)vec.size()); ++i)
			seg[i + width - 1] = vec[i];
		for (int k = width - 2; k >= 0; --k)
			seg[k] = min(seg[2 * k + 1], seg[2 * k + 2], Comp());
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	RMQ<int, less<int>>tree(N, INT_MAX);
	vector<int>vec(N, INT_MAX);
	tree.init(vec);
	for (int i = 0; i < Q; ++i) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com) {
			cout << tree.query(x, y + 1) << endl;
		}
		else {
			tree.update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 4092
#include <stdio.h>

int main(void)
{
	int x,a,b;
	
	scanf("%d %d %d",&x,&a,&b);
	
	if(a>=b){
		printf("delicious\n");
	}else if(b-a<=x){
		printf("safe\n");
	}else{
		printf("dangerous\n");
	}
	
	return 0;
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

ll n;
ll a, b, c, d;  
map<ll, ll> memo;

ll f(ll x){
    if(!x)  return 0;
    if(x==1) return d;
    if(memo.count(x)) return memo[x];
    ll res = LINF;
    
    //x*d<LINFの場合は更新
    if(x < LINF/d) res = x*d;
    //切り捨てしてからかけて左右を求める
    ll l2 = (x/2)*2;
    ll r2 = ((x+1)/2)*2;
    ll l3 = (x/3)*3;
    ll r3 = ((x+2)/3)*3;
    ll l5 = (x/5)*5;
    ll r5 = ((x+4)/5)*5;
    res = min(res, labs(x-l2)*d+a+f(l2/2));
    res = min(res, labs(x-r2)*d+a+f(r2/2));
    res = min(res, labs(x-l3)*d+b+f(l3/3));
    res = min(res, labs(x-r3)*d+b+f(r3/3));
    res = min(res, labs(x-l5)*d+c+f(l5/5));
    res = min(res, labs(x-r5)*d+c+f(r5/5));
    return memo[x] = res;

}




int main(){
    int n;  cin >> n;
    int res=0;
    for(int i=1; i<=n; i+=2){
        int cnt=0;
        for(int j=1; j*j<=i; j++){
            if(i%j==0){
                cnt += 1;
                if(j!=i/j) cnt += 1;
            }
        }
        //cout << i <<':' << cnt << endl;
        if(cnt==8)  res += 1;
    }
    cout << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }

    void solve(){  
        string s,t;
        cin>>s>>t;
        int total=1e5;
        int flag=0;
        for(int i=0;i<(int)s.size();i++){
            int cur=0;
            for(int j=0;j<(int)t.size();j++){
                if(i+j>=(int)s.size()){
                    flag=1;
                    break;
                }
                if(t[j]!=s[i+j])
                    cur++;
            }
            if(flag==1)
                break;
            total=min(total,cur);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int r, g, b;
    cin >> r >> g >> b;

    if((g*10+b)%4) puts("NO");
    else puts("YES");

    return 0;
}

Measured memory_bytes: 256
def c_streamline(N, M, X):
    if N >= M:
        return 0  # コマを各座標に置けば動かす必要がない

    X.sort()
    x_distance_from_left = [0] * M
    for i in range(1, M):
        x_distance_from_left[i] = X[i] - X[i - 1]
    x_distance_from_left.sort(reverse=True)
    # 隣接した2つの位置について、距離が大きなところは移動したくないので、
    # そこにはコマを置いて移動せずに済むようにする
    ans = (X[-1] - X[0]) - sum(x_distance_from_left[:N - 1])
    return ans

N, M = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
print(c_streamline(N, M, X))

Measured memory_bytes: 13840
h,w,a,b=map(int,raw_input().split(' '))
mod=1000000007
inv=[0]*(h+w)
fact=[0]*(h+w)

def ex(x,y):
    if y==0: return 1
    elif y==1: return x%mod
    elif y%2==0: return ex(x,y/2)**2%mod
    else: return ex(x,y/2)**2*x%mod

#factorial
fact[0]=1
for j in range(1,h+w):
    fact[j]=fact[j-1]*j%mod

inv[h+w-1]=ex(fact[h+w-1],mod-2)
for j in reversed(range(h+w-1)):
    inv[j]=inv[j+1]*(j+1)%mod

    

def nck(x,y):
    return fact[x]*inv[y]*inv[x-y]%mod

su=0
for j in range(h-a):
    su=(su+nck(b-1+j,b-1)*nck(h-1-j+w-1-b,w-1-b))%mod

print su

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

//def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

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

    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define NOT -1

typedef struct
{
  int parent;
  int left, right;
}Node;

Node Tree[MAX];
int num,Depth[MAX];

void print(int u)
{
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",Tree[u].parent);
  printf("depth = %d, ",Depth[u]);

  if(Tree[u].parent == NOT) printf("root, ");
  else if(Tree[u].left == NOT) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,c=Tree[u].left;c!= NOT;i++,c=Tree[c].right)
    {
      if(i)printf(", ");
      printf("%d",c);
    }
  printf("]\n");
}

int ans_depth(int u,int par)
{
  Depth[u]=par;
  if(Tree[u].right != NOT) ans_depth(Tree[u].right,par);
  if(Tree[u].left != NOT) ans_depth(Tree[u].left,par+1);
}

int main()
{
  int i,j,dep,adep,c,left,right;
  scanf("%d",&num);
  for(i=0;i<num;i++) Tree[i].parent=Tree[i].left=Tree[i].right=NOT;

  for(i=0;i<num;i++)
    {
      scanf("%d %d",&adep,&dep);
      for(j=0;j<dep;j++)
	{
	  scanf("%d",&c);
	  if(j==0) Tree[adep].left=c;
	  else Tree[left].right=c;
	  left=c;
	  Tree[c].parent=adep;
	}
    }
  for(i=0;i<num;i++)
    {
      if(Tree[i].parent==NOT)right=i;
    }

  ans_depth(right,0);

  for(i=0;i<num;i++)print(i);
  return 0;
}

Measured memory_bytes: 5300
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

// 双方向連結リスト
struct Node
{
    int key;
    Node *prev;
    Node *next;
};

// リスト操作しやすいように起点ノードとなるnilを用意。
Node *nil;
void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

// リストの先頭に要素を追加
void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    x->prev = nil;

    // nilの次の要素が先頭なので、その要素のprevをxに向ける
    nil->next->prev = x;

    nil->next = x;
}

// keyに一致するNodeを返す。存在しない場合は、nilノードを返す。
Node *listSearch(int key)
{
    Node *cur = nil->next;
    while (cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}
void deleteNode(Node *t)
{
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}
void deleteFirst()
{
    deleteNode(nil->next);
}
void deleteLast()
{
    deleteNode(nil->prev);
}
void deleteKey(int key)
{
    // nilはdeleteNodeで削除されないので、nilのチェックは不要。
    deleteNode(listSearch(key));
}
void cleanList()
{
    for (Node *c = nil->next; c != nil; c = c->next)
        free(c);

    if (nil != NULL)
        free(nil);
}
void printList()
{
    if (nil == NULL) return;

    for (Node *c = nil->next; c != nil; c = c->next)
    {
        cout << c->key;
        if (c->next != nil)
            cout << " ";
    }
    cout << endl;
}


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

    init();

    int n;
    cin >> n;
    cin.ignore(); // 改行読み飛ばし

    for (int i = 0; i < n; i++)
    {
        string line;
        getline(cin, line);

        string::size_type pos = line.find(" ");
        if (pos == string::npos)
        {
            if (line.find("F") == string::npos)
                deleteLast();
            else
                deleteFirst();
        }
        else
        {
            int key = atoi(line.substr(pos+1).c_str());
            if (line.find("insert") == 0)
                insert(key);
            else
                deleteKey(key);
        }
    }
    printList();
    cleanList();
    return 0;
}


Measured memory_bytes: 34364
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<int,int>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}

  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
ll n;
ll arr[3001];
ll bruteForce(ll p1,ll p2)
{
    ll x=0;
    if(p1==p2)
    {
        return arr[p1];
    }
    else
    {
        return max(arr[p1]-bruteForce(p1+1,p2),arr[p2]-bruteForce(p1,p2-1));
    }
}
void solve()
{
    cin>>n;
    forn(i,n)cin>>arr[i];
    //cout<<bruteForce(0,n-1)<<endl;
    ll dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=n-1;i>=0;i--)
    {
        for(int j=i;j<n;j++)
        {
            if(j==i)dp[i][j]=arr[i];
            else dp[i][j]=max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1]<<endl;
}  
int main()
{
 
    FastIO;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}

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

int main(){
    int d;
    cin>>d;
    vector<int>c(26),t(d),last(26,0);
    vector<vector<int>>s(d,vector<int>(26));
    rep(i,26)cin>>c[i];
    rep(i,d)rep(j,26)cin>>s[i][j];
    rep(i,d){
        cin>>t[i];
        t[i]--;
    }
    ll ans=0;
    rep(i,d){
        ans+=s[i][t[i]];
        last[t[i]]=i+1;
        rep(j,26)ans-=c[j]*((i+1)-last[j]);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;


// structure ------------------------------------------

// function -------------------------------------------


// main -----------------------------------------------

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n), c(n);
	REP(i, n){
		cin >> p[i];
		p[i]--;
	}
	REP(i, n){
		cin >> c[i];
	}

	ll ans = c[0];
	REP(i, n){
		ll next_i = p[i];
		ll now = c[next_i];
		ll cnt = 1;
		chmax(ans, now);
		while(cnt < k && i != next_i){
			next_i = p[next_i];
			now += c[next_i];
			chmax(ans, now);
			cnt ++;
		}

		if(cnt < k){
			ll amari = k % cnt;
			ll ichideka = 0;
			ll genzai = 0;
			next_i = i;
			REP(j, amari + cnt){
				next_i = p[next_i];
				genzai += c[next_i];
				chmax(ichideka, genzai);
			}
			chmax(ans, ichideka + ((k/cnt) - 1) * now);
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>

int main(void)
{
  int X;
  std::cin >> X;

  unsigned int sum = 0;
  for (unsigned int i = 1; i < 1000000000; i++) {
    sum += i;
    if (sum >= X) {
      std::cout << i << std::endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string str;
  int l;
  int i = 0;
  int count = 0;
  cin >> str;
  l = (int)(str.length());
  while(i < l){
    if(str[i] == str[i+1]){
      i += 3;
      count += 2;
    }else{
      i ++;
      count ++;
    }
  }
  if(i-l > 0) count --;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

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

struct Edge{int to,weight; Edge(int t, int w) : to(t), weight(w) {}};
using DirectedGraph = vector<vector<Edge>>;
using UndirectedGraph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    for(int i=1;i<4;i++){
        if(s[i]==s[i-1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  vector<double> X(n),Y(n);
  rep(i,n) cin>>X[i]>>Y[i];
  
  double sum=0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      sum+=sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
    }
  }
  
  cout<< fixed << setprecision(15)<<2*sum/n<<endl;
  
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a1,a2,a3;
  cin>>a1>>a2>>a3;
  if(a1+a2+a3>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
     
#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll dp[2010][2010];

ll comb( ll a , ll b ){ 
  if( b < 0 or b > a ){
    return 0;
  }
  if( b == 0 or b == a ){
    return 1;
  }
  if( a >= 2010 ){
    if( b == 1 || b == a - 1 ){
      return min( INF , a );
    } else if( b == 2 || b == a - 2 ){
      return min( INF , a * ( a - 1 ) / 2 );
    } else if( b == 3 ){
      return INF;
    } 
  }
  if( dp[a][b] != 0 ){
    return dp[a][b];
  }
  ll res = comb( a - 1 , b ) + comb( a - 1 , b - 1 );
  return dp[a][b] = min( res , INF );
}

int n, m;

pi calc( vi a , vi b ){
  assert( a < b );

  int x = ( b[1] - a[1] ) / a[0];

  FOR( i , 1 , m ){
    ll cur = a[i];
    FOR( j , 1 , i+1 ){
      cur += a[i-j] * comb( x + j - 1 ,  j );
      chmin( cur , INF );
    }
    if( cur > b[i] ){
      return make_pair( x , false );
    }
    if( cur < b[i] ){
      return make_pair( x + 1 , false );
    }
  }
  
  return make_pair( x , true );
}

mi a;

int main(){

  n = in();
  m = in();
  a = mi( n , vi( m ) );
  REP( i , n ){
    REP( j , m ){
      a[i][j] = in();
    }
  }

  if( m == 1 ){
    REP( i , n-1 ){
      if( a[i][0] >= a[i+1][0] ){
	puts( "-1" );
	return 0;
      }
    }
    puts( "0" );
    return 0;
  }
  
  REP( i , n-1 ){
    if( a[i][0] > a[i+1][0] ){
      puts( "-1" );
      return 0;
    }
  }

  ll cur = 0;
  ll ans = 0;
  REP( i , n-1 ){
    if( a[i][0] == a[i+1][0] ){
      if( a[i][1] < a[i+1][1] ){
	pi res = calc( a[i] , a[i+1] );
	cur = cur - res.fi + 1;
      } else if( a[i][1] > a[i+1][1] ){
	pi res = calc( a[i+1] , a[i] );
	if( res.se ){
	  cur = cur + res.fi + 1;
	} else {
	  cur = cur + res.fi;
	}
      } else {
	if( a[i] >= a[i+1] ){
	  cur++;
	}
      }
    } else {
      cur = 0;
    }
    chmax( cur , 0LL );
    ans += cur;
  }

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


Measured memory_bytes: 8192
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007



int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	string s;
	cin >> s;
	string t;
	cin >> t;
	int n = s.length();
	int l = t.length();
	bool x = true;
	if (n + 1 != l)x = false;
	f(n)
	{
		if (s[i] != t[i])x = false;
	}
	if (x)cout << "Yes";
	else cout << "No";

}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    int K;
    cin >> N >> K;
    vector <int> snuke (N);

    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int n;
            cin >> n;
            snuke[n-1] = 1;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (snuke[i] == 0) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=1e6+10;
int a[N];
int main()
{
	int n,m,q,k;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0&&i%15!=0) sum+=i;
	}
	cout<<sum;
}


Measured memory_bytes: 3628
def calc(a):
  if a % 2 == 0:
    return int(a / 2)
  else:
    return 3 * a + 1

s = int(input())
c = 1
n = s
l = [s]

while True:
  m = calc(n)
  if l.count(m) == 1:
    break
  l.append(m)
  c += 1
  n = m
   
print(c+1)

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

int main(){
 string S,T;
 cin>>S;
 T=string(S.rbegin(),S.rend()); 
 int tot=0;
 int len=S.length();
 if(S.length()==len&&T.length()==len&&len>=1&&len<=100){
 for(int i=0;i<len;i++){
     if(S[i]!=T[i]){
         tot++;
     }
 }
 }
 cout<<tot/2;
   return 0;
   
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,max,ans = 0;

  cin >> N;
  for(int i = 0; i < N; i++){
    int h;
    cin >> h;
    if(h >= max){
      ans++;
      max = h;
    }
  }

  cout << ans;
}


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

#define ALL(v) v.begin(), v.end()
typedef long long ll;

using namespace std;
int main() {

	int n;
	string s;
	cin >> n >> s;

	int maxz = 0;
	int ans = 0;

	for (char c : s) {
		if (c == 'I') ans++;
		else ans--;

		maxz = max(maxz, ans);
	}
	

	
	

	 cout << maxz << endl;
}

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 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;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ite=1;
    char col=s[0];
    while(s[ite] != '\0'){
        if(s[ite] == col) {
            s.erase(ite,1);
        }else {
            col = s[ite];
            ite++;
        }
    }
    cout << s.length() << endl;
}

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

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

int main() {
	ll N = 0;
	ll count = 0;
	cin >> N;
	vector<string> S(N);
	rep(i, N) {
		cin>>S[i];
	}

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

	
	rep(i, N-1) {
		if (S[i] != S[i + 1]) {
			count++;
		}
	}
	count++;

	cout << count;


	return 0;
}

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

using namespace std;

int main()
{
    string s;
    long index;
    cin >> s;
    vector<char> v;

    for (long i = 0; i < s.length(); i++)
    {	index = i + 1;
        if (index % 2 != 0)
        {
            v.push_back(s[i]);
        }
    }

    for (long i = 0; i < v.size(); i++)
    {
        cout << v[i];
    }
}


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

int main(){
	char trash;
	double a[10];
	double v1, v2;
	while(cin >> a[0] >> trash){
		double x = a[0];
		for(int i = 1; i < 10; i++){
			cin >> a[i] >> trash;
			x = x+a[i];
		}
		cin >> v1 >> trash >> v2;
		x = x*v1/(v1+v2);
		for(int i = 0; i < 10; i++){
			x = x-a[i];
			if(x <= 0){
				cout << i+1 << endl;
				break;
			}
		}
	}
}

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


// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i=2;i*i<=n;++i) {
        while (n%i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    ll A, B;
    cin >> A >> B;

    map<ll, ll> tmp = prime_factor(A);
    map<ll, ll> tmp2 = prime_factor(B);

    ll ans = 0;
    for (auto a : tmp) {
        if (tmp2.count(a.first) > 0) {
            ans++;
        }
        //cout << a.first << ", " << a.second << endl;
    }

    cout << ans+1 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, k, ans = inf; cin >> n >> k;
	vi h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));
	rep(i, n - k + 1){
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)2e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


double dp[3010][3010];

int main(){
	int N; cin >> N;
	vector<double> p(N);
	rep(i,N) cin >> p[i];
	rep(i,3010)rep(j,3010) dp[i][j] = 0.0;
	dp[1][1] = p[0];
	dp[1][0] = 1-p[0];
	repr(i,1,N)rep(j,i+1){
		dp[i+1][j+1] += dp[i][j]*p[i];
		dp[i+1][j] += dp[i][j]*(1-p[i]);
	}
	double ans = 0.0;
	rep(i,N+1){
		if(i > (N/2)) ans += dp[N][i];
	}
	cout <<  fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 71168
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, d, x;
	cin >> n >> d >> x;
	int sum = n;
	rep(i,n){
		int a; cin >> a;
		loop(j, 1, d){
			int t = j*a+1;
			if(t > d) break;
			else sum++;
		}
	} 
	cout << sum+x << endl;
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



string s;
void solve(){
	cin >> s;
	int n = s.size();
	n--;
	
	i64 ans = 0;
	for(int i = 0; i < (1 << n); i++){
		i64 cnt = s[0]-'0';
		for(int j = 0; j < n; j++){
			if(i>>j & 1){
				ans += cnt;
				cnt = s[j+1]-'0';
			}
			else{
				cnt *= 10;
				cnt += s[j+1]-'0';
			}
		}
		ans += cnt;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

long long int a, b, c, d, flag = 0;

void solve() {
	cin >> a >> b >> c >> d;
	while (a > 0) {
		c -= b;
		if (c <= 0) {
			flag = 1;
			break;
		}

		a -= d;
	}
	if (flag == 1)
		cout << "Yes";
	if (a <= 0)
		cout << "No";
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
}

Measured memory_bytes: 3636
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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


ll dp[60][6];
signed main(void)
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  bool start = true;
  REP(i, n) {
    if(s[i] == t[i]) {
      if(start) {
        start = false;
        dp[i][3] = dp[i][4] = dp[i][5] = 1;
      } else {
        dp[i][3] = (dp[i-1][0] + dp[i-1][4] + dp[i-1][5]) % MOD;
        dp[i][4] = (dp[i-1][1] + dp[i-1][3] + dp[i-1][5]) % MOD;
        dp[i][5] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][4]) % MOD;
      }
    } else {
      ++i;
      if(start) {
        start = false;
        dp[i][0] = dp[i][1] = dp[i][2] = 2;
      } else {
        dp[i][0] = (dp[i-2][5]*2 + dp[i-2][0] + dp[i-2][1] + dp[i-2][2] ) % MOD;
        dp[i][1] = (dp[i-2][4]*2 + dp[i-2][0] + dp[i-2][1] + dp[i-2][2] ) % MOD;
        dp[i][2] = (dp[i-2][3]*2 + dp[i-2][0] + dp[i-2][1] + dp[i-2][2] )% MOD;
      }
    }
    // ll ret = 0;
    // REP(j, 6) {
    //   ret = (ret + dp[i][j]) % MOD;
    // }
    // cout << i << " " << ret << endl;
  }

  ll ret = 0;
  REP(i, 6) {
    ret = (ret + dp[n-1][i]) % MOD;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
 

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
 
    if temp != 1:
        arr.append([temp, 1])
 
    #if arr == []:
    arr.append([1, 1])
 
    return arr


a, b = map(int, input().split())
 
x = np.array(factorization(a))
y = np.array(factorization(b))
 
num = set(x[:, 0]) & set(y[:, 0])
 
print(len(num))

Measured memory_bytes: 12484
#include <stdio.h>
#include <stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool X[N][N];

void initialize(){
  int i;
  for(i=0;i<N;i++) row[i]=col[i]=FREE;
  for(i=0;i<2*N-1;i++) dpos[i]=dneg[i]=FREE;
}

void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }

  for(j=0;j<N;j++){
    if(NOT_FREE==col[j] || NOT_FREE==dpos[i+j] || NOT_FREE==dneg[i-j+N-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  int i,j;
  initialize();

  for(i=0;i<N;i++)
    for(j=0;j<N;j++) X[i][j]=false;

  int k;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    int r,c;
    scanf("%d %d",&r,&c);
    X[r][c]=true;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	long long n,m,sum=0;
	scanf("%lld%lld",&n,&m);
	if(n<=m/2)
	{
	sum=n;
	m=m-2*n;
	sum+=m/4;	
	}
	else 
	sum=m/2;
	
	
	
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n){
    int a,b;cin >> a >> b;
    v[i] = (a == b);
  }
  rep(i,n){
    if(i+1 < n && v[i]+v[i+1]+v[i+2] == 3){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";


  return 0;
}

Measured memory_bytes: 3592
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs


void solve()
{
    IN(h, w, m);
    vector<ll> a(h);
    vector<ll> b(w);
    set<pair<ll,ll>> s;
    rep(i, m) {
        IN(x, y); --x, --y;
        a[x]++;
        b[y]++;
        s.emplace(x, y);
    }
    vector<pair<ll,ll>> a2;
    rep(i, h) {
        a2.emplace_back(a[i], i);
    }
    vector<pair<ll,ll>> b2;
    rep(i, w) {
        b2.emplace_back(b[i], i);
    }
    sort(all(a2), greater<pair<ll,ll>>());
    sort(all(b2), greater<pair<ll,ll>>());
    vector<pair<ll,ll>> a3;
    vector<pair<ll,ll>> b3;
    rep(i, h) {
        if (a2[0].first - a2[i].first == 0) a3.push_back(a2[i]);
    }
    rep(i, w) {
        if (b2[0].first - b2[i].first == 0) b3.push_back(b2[i]);
    }
    ll res = a3[0].first + b3[0].first;
    rep(i, a3.size()) {
        rep(j, b3.size()) {
            if (s.find(make_pair(a3[i].second, b3[j].second)) == s.end()) {
                cout << res << endl;
                return;
            }
        }
    }
    cout << res-1 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 52940