akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
using std::cout;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
typedef std::set<int> si;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str N;
int K;
int D[10];
int main(){
  cin>>N>>K;
  si st;
  rep(i,K){
    cin>>D[i];
    st.insert(D[i]);
  }
  int ns=N.size();
  int j=-1;
  rep(i,ns){
    int n=N[i]-'0';
    if(st.find(n)!=st.end()){
      j=i;
      break;
    }
  }
  if(j==-1){
    prin(N);
  }
  else{
    int n=N[j]-'0';n++;
    while(st.find(n)!=st.end()) n++;
    if(n<=9){
      rep(i,j) cout<<N[i];
      cout<<n;
      int a=0;
      while(st.find(a)!=st.end()) a++;
      for(int k=j+1;k<ns;k++) cout<<a;
      cout<<"\n";
    }
    else{
      j--;
      while(j>=0){
	int m=N[j]-'0';m++;
	while(st.find(m)!=st.end()) m++;
	if(m<=9){
	  rep(i,j) cout<<N[i];
	  cout<<m;
	  int a=0;
	  while(st.find(a)!=st.end()) a++;
	  for(int k=j+1;k<ns;k++) cout<<a;
	  cout<<"\n";
	  j=-2;
	}
	else j--;
      }
      if(j==-1){
	int a=1;
	while(st.find(a)!=st.end()) a++;
	cout<<a;
	if(st.find(0)==st.end()){
	  rep(k,ns) cout<<0;
	  cout<<"\n";
	}
	else{
	  rep(k,ns) cout<<a;
	  cout<<"\n";
	}
      }
    }
  }
  return 0;
}


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

string join(vector<int> v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += to_string(v[0]);
    for (int i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += to_string(v[i]);
    }
  }
  return s;
}

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

    int count = 0;
    for (int i =0; i < N; i++) {
        int minJ = i;
        for (int j=i; j < N; j++) {
            if (vec[j] < vec[minJ]) {
                minJ = j;
            }
        }

        if (i != minJ && vec[i] != vec[minJ])
        {
            int tmp = vec[i];
            vec[i] = vec[minJ];
            vec[minJ] = tmp;
            count += 1;
        }
    }

    const char* delim_ = " ";
    string answer = join(vec, delim_);
    answer.erase(answer.size() - std::char_traits<char>::length(delim_) + 1);
    answer.erase(0, answer.find_first_not_of(" \n\r\t"));
    cout << answer << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cstring>
using namespace std;
int a[12];
int b[12];
int main()
{
  int n,i,j,c,d,f;
  for(;;){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
    }
    c = 0;
    for(;;){
      f = 1;
      for(i=0;i<n;i++){
	d = 0;
	for(j=0;j<n;j++){
	  if(a[j] == a[i]) d++;
	}
	b[i] = d;
	if(a[i] != b[i]) f = 0;
      }
      if(f) break;
      memcpy(a,b,sizeof(int)*n);
      c++;
    }
    cout << c << endl << a[0];
    for(i=1;i<n;i++){
      cout << " " << a[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools
import bisect

n = int(readline())
a = tuple(map(int, readline().split()))
cumsum = tuple(itertools.accumulate(a))
index = bisect.bisect(cumsum, sum(a) // 2)
ans = min(cumsum[n - 1] - cumsum[index - 1] * 2, cumsum[index] * 2 - cumsum[n - 1])
print(ans)


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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> v;
    ll x;
    rep(i,n){
        cin>>x;
        v.pb(x%m);
    }
    vector<ll> ru,ct;
    map<ll,ll> mod;
    rep(i,n){
        if(i==0){
            ru.pb(v[0]);
            if(mod.count(ru[i])){
                mod[ru[i]]++;
            }else{
                mod.insert(make_pair(ru[i],1));
                ct.pb(ru[i]);
            }
        }else{
            ru.pb((ru[i-1]+v[i])%m);
            if(mod.count(ru[i])){
                mod[ru[i]]++;
            }else{
                mod.insert(make_pair(ru[i],1));
                ct.pb(ru[i]);
            }
        }
    }
    ll ans = 0;
    ll key = 0;
    rep(i,ct.size()){
        if(mod.count(ct[i])){
            key = mod.at(ct[i]);
            if(ct[i]==0)ans += key ;
           // cout<<ans<<endl;
            ans += key*(key-1)/2;
        }else{

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





Measured memory_bytes: 6772
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var hw = Input.ar;
        var gred = Enumerable.Repeat(0, hw[0]).Select(v => ReadLine().Split(' ')).ToArray();
        for(var i=0;i<hw[0];i++)
            for(var j=0;j<hw[1];j++)
                if (gred[i][j] == "snuke")
                {
                    WriteLine($"{Input.Alfa.Substring(j, 1).ToUpper()}{i + 1}");
                }
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const double eps = 1e-11;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13524
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int start=max(a,c);
    int end=min(b,d);
    
    int ans=end-start;
    if(ans>0){
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = in_s()
    N = len(S)

    comb = itertools.product([0, 1], repeat=N - 1)
    ans = 0

    for com in comb:
        now = S[0]
        ts = 0
        for i, f in enumerate(com):
            i = i + 1
            if f == 0:
                now += S[i]
            else:
                ts += int(now)
                now = S[i]
        else:
            ts += int(now)

        # print(ts)
        ans += ts

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9292
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
const int N=0;
const int E=1;
const int S=2;
const int W=3;
const int Z=4;
int rs[5][4]={{0,1,5,4},{0,3,5,2},{0,4,5,1},{0,2,5,3},{3,1,2,4}};
struct xai{
int ds[6];

void round(int n){
	int t=ds[rs[n][0]];
	for(int i=0;i<3;i++){
		ds[rs[n][i]]=ds[rs[n][i+1]];
	}
	ds[rs[n][3]]=t;
}
void roundZ(){
	int cs[4];
	std::vector<int> vec;
	for(int i=0;i<4;i++){
		vec.push_back(ds[rs[Z][i]]);
	}
	for(int i=0;i<4;i++){
		round(Z);
		std::vector<int> vec2;
		for(int i=0;i<4;i++){
			vec2.push_back(ds[rs[Z][i]]);
		}
		if(vec<vec2)vec=vec2;
	}
	for(int i=0;i<4;i++){
		ds[rs[Z][i]]=vec[i];
	}
}
};

int main() {
// your code goes here
xai e;
for(int i=0;i<6;i++){
	scanf("%d",&e.ds[i]);
}
char com[101];
scanf("%s",com);
for(int i=0;com[i]!='\0';i++){
	if(com[i]=='N')e.round(N);
	if(com[i]=='E')e.round(E);
	if(com[i]=='S')e.round(S);
	if(com[i]=='W')e.round(W);
}
printf("%d\n",e.ds[0]);
return 0;
}


Measured memory_bytes: 3224
module Main where

import           Control.Monad
import           Data.List
import           Data.List.Split
import qualified Data.Vector.Unboxed as V

solve xs = if ok
           then 1 + solve ds
           else 0
  where
    dms = map (`divMod` 2) xs

    ok = all (\a -> snd a == 0) dms

    ds = map fst dms

main :: IO ()
main = do
  _ <- getLine
  xs <- map read . words <$> getLine
  print $ solve xs


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

int main() {
	int n;
	cin >> n;
	int a[n];
	int ans[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans[a[i]-1] = i+1;
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 1536
// atcoder/dwacon5th-prelims/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, k;
  while (cin >> n >> k) {
    vec<lli> a(n);
    cin >> a;

    vec<lli> v;
    for (int i = 0; i < n; ++i) {
      lli sum = 0;
      for (int j = i; j < n; ++j) {
        sum += a[j];
        v.push_back(sum);
      }
    }
    sort(v.begin(), v.end());

    for (int i = 60; 0 <= i; --i) {
      vec<lli> u;
      each (j, v) {
        if (j & (1LL << i)) {
          u.push_back(j);
        }
      }
      if (k <= u.size()) {
        v = u;
      }
    }
    // cout << v << endl;
    while (k < v.size()) v.pop_back();
    lli x = v.front();
    each (i, v) x = x & i;
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 8956
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        
    	int W = sc.nextInt();
    	int H = sc.nextInt();
    	int x = sc.nextInt();
    	int y = sc.nextInt();
    	int r = sc.nextInt();
    	
    	if(0<=y-r&H>=y+r&0<=x-r&W>=x+r){
        System.out.println("Yes");
    	}
    	else{
        	 System.out.println("No");
        }
        sc.close();
    }
}



Measured memory_bytes: 26340
#include <stdio.h>

int main(void)
{
  char n[5];
  scanf("%s", n);
  if ( (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) ) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 128
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	hw := "Hello World"
	N := nextInt()
	if N == 1 {
		fmt.Println(hw)
	} else {
		A := nextInt()
		B := nextInt()
		fmt.Println(A + B)
	}
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
N, M = map(int, input().split())
A = list(map(int, input().split()))
weight = [0,2,5,5,4,5,6,3,7,6]
inf = float('inf')
dp = [-inf] * (N+1)
dp[0] = 0
for i in range(N+1):
    for a in A:
        if i + weight[a] < N+1:
            dp[i + weight[a]] = max(dp[i + weight[a]], dp[i]*10 + a)
print(dp[-1])


Measured memory_bytes: 20460
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli h, k, n, m, q, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> m >> q;
  vi a(q), b(q), c(q), d(q);
  vlli e(10);
  rep(i, 0, q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  for (e[0] = 1; e[0] <= m; e[0]++)
  {
    for (e[1] = e[0]; e[1] <= m; e[1]++)
    {
      for (e[2] = e[1]; e[2] <= m; e[2]++)
      {
        for (e[3] = e[2]; e[3] <= m; e[3]++)
        {
          for (e[4] = e[3]; e[4] <= m; e[4]++)
          {
            for (e[5] = e[4]; e[5] <= m; e[5]++)
            {
              for (e[6] = e[5]; e[6] <= m; e[6]++)
              {
                for (e[7] = e[6]; e[7] <= m; e[7]++)
                {
                  for (e[8] = e[7]; e[8] <= m; e[8]++)
                  {
                    for (e[9] = e[8]; e[9] <= m; e[9]++)
                    {
                      lli tmp = 0;
                      rep(i, 0, q)
                      {
                        if (e[b[i] - 1] - e[a[i] - 1] == c[i])
                        {
                          tmp += d[i];
                        }
                      }
                      if (tmp > ans)
                        ans = tmp;
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
int main(){
    int n;cin>>n;
    int a[110];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    int s=a[0];int c=0;int cc=0;int to=a[0];
    bool f=true;
    vector<int> v;
    for(int i=0;i<n;i++){
        if(a[i]==to&&c<s+1){
            cc++;
            c++;
            if(cc==2){
                cc=0;
                to--;
            }
        }else{
            v.push_back(a[i]);
        }
    }
    if(c!=s+1){
        f=false;
    }
    for(int i=0;i<v.size();i++){
        if(v[i]<=(s+(s%2))/2){
            f=false;
        }
    }
    if(f){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[]p =new int[n];
	    
		
	    for(int i=0;i<n;i++) {
	    	p[i]=sc.nextInt();
	    }
	    
	   Arrays.sort(p);
	   
	   int ans=0;
	   
	   for(int i=0;i<k;i++) {
	    	ans+=p[i];
	    }
	   
		System.out.println(ans);
	}
}


Measured memory_bytes: 38700
import java.util.Scanner;
public class Main
 {
    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        int b=in.nextInt();
        int h=in.nextInt();
        System.out.println((a+b)*h/2);
    }
 }

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
int N;
i64 A[101010];
i64 subm[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i <= N; ++i) scanf("%lld", A + i);
	subm[N + 1] = 0;
	for (int i = 0; i <= N; ++i) subm[i] = A[i];
	for (int i = N - 1; i >= 0; --i) subm[i] += subm[i + 1];

	long long ret = 0,k = 1;
	for (int i = 0; i <= N; ++i) {
		if (k < A[i]) goto fail;
		ret += k;
		k -= A[i];
		k = min(k * 2, subm[i + 1]);
	}
	if (k != 0) goto fail;
	printf("%lld\n", ret);
	return 0;
fail:
	puts("-1");
	return 0;
}

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = pow(10,9)+7;

ll factorial(ll a){
    ll ans = 1;
    for(int i=1; i<=a; i++){
        ans = (ans*i)%N;
    }
    return ans;
}

int main(){
    ll n,m;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }
    if(n==m){
        cout << (2*factorial(n)*factorial(m)) % N << endl;
        return 0;
    }
    else{
        cout << (factorial(n)*factorial(m)) % N << endl;
        return 0;
    }
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
    int n,i,a[10005];
    long long int b = 10000000,t= (-10000000),m=0;
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        if(b>a[i]){
            b=a[i];
        }
        if(t<a[i]){
            t=a[i];
        }
        m+=a[i];
    }

    printf("%lld %lld %lld\n",b,t,m);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = int64_t;

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

void solve(){
    ll x;
    cin >> x;
    if(x <= 11){
        if(x <= 6){
            cout << 1 << endl;
        }else{
            cout << 2 << endl;
        }
        return;
    }
    ll t = x/11;
    ll u = x%11;
    if(u == 0){
        cout << t*2 << endl;
    }else if(u > 0 && u <= 6){
        cout << t*2+1 << endl;
    }else{
        cout << t*2+2 << endl;
    }
}

int main(){
    solve();
    return 0;
}

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

typedef long long ll;

pair<ll, ll> bc[111111];
ll a[111111], b[111111];

int main(void)
{
	ll n, m, i, j;

	scanf("%lld %lld" ,&n, &m);
	for (i = 0; i < n; i++)
		scanf("%lld" ,&a[i]);
	sort(a, a + n);
	for (i = 0; i < m; i++)
		scanf("%lld %lld" ,&bc[i].second, &bc[i].first);
	sort(bc, bc + m);

	bool ok = true;
	ll cnt = 0;
	for (i = m - 1; i >= 0 && ok; i--)
		for (j = 0; j < bc[i].second && ok; j++)
		{
			b[cnt++] = bc[i].first;
			if (cnt >= n)
				ok = false;
		}

	ll ans = 0;
	for (i = 0; i < n; i++)
		ans += max(a[i], b[i]);

	printf("%lld" ,ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

int main()
{
  std::string S;
  std::string T;
  std::cin>>S>>T;
  
  std::string result="Yes";
  if(S.size()+1!=T.size())
  {
    result="No";
  }
  else
  {
    for(size_t i=0;i!=S.size();i++)
    {
      if(S[i]!=T[i])
      {
        result="No";
        break;
      }
    }
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long 
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint k;
llint ans[55];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k;
	for(int i = 0; i < 50; i++) ans[i] = (k+49)/50 + i;
	if(k % 50){
		for(int i = 0; i < 50-(k%50); i++) ans[i]--;
	}
	cout << 50 << endl;
	for(int i = 0; i < 50; i++) cout << ans[i] << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct hopcroft{
	vector<int> dist, pair_l, pair_r;
	vector<bool> seen;
	vector<vector<int>> to;
	int n1, n2;
	hopcroft(int n1, int n2) : n1(n1), n2(n2){
		to.resize(n1);
		pair_l.assign(n1, -1);
		pair_r.assign(n2, -1);
		dist.resize(n1);
		seen.resize(n1);
	}
	void add_edge(int u, int v){
		to[u].push_back(v);
	}
	bool bfs(){
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int i = 0; i < n1; i++){
			if (pair_l[i] == -1){
				dist[i] = 0;
				q.push(i);
			}
		}
		bool reach_minus = false;
		while (!q.empty()){
			int u = q.front();
			q.pop();
			for (int adj : to[u]){
				int radj = pair_r[adj];
				if (radj == -1){
					reach_minus = true;
				} else if (dist[radj] == -1){
					dist[radj] = dist[u] + 1;
					q.push(radj);
				}
			}
		}
		return reach_minus;
	}
	bool dfs(int u){
		seen[u] = true;
		for (int adj : to[u]){
			int radj = pair_r[adj];
			if (radj == -1 || (!seen[radj] && dist[radj] == dist[u] + 1 && dfs(radj))){
				pair_l[u] = adj;
				pair_r[adj] = u;
				return true;
			}
		}
		return false;
	}
	int max_matching(){
		int res = 0;
		while (bfs()){
			fill(seen.begin(), seen.end(), false);
			for (int i = 0; i < n1; i++)
				if (pair_l[i] == -1 && dfs(i))
					res++;
		}
		return res;
	}
};
const int maxn = 100100;
int seen[maxn], q[maxn];
int main(){
	int n; scanf("%d", &n);
	hopcroft hop(n, n - 1);
	vector<int> pu(n), pv(n);
	for(int i = 0; i < n - 1; i++){
		int x; scanf("%d", &x);
		for(int j = 0; j < x; j++){
			int y; scanf("%d", &y); y--;
			hop.add_edge(y, i);
		}
	}
	auto bad = [](){
		printf("-1\n");
		exit(0);
	};
	int mx = hop.max_matching();
	if(mx != n - 1) bad();
	int st = -1, tp = 0;
	for(int i = 0; i < n; i++){
		if(hop.pair_l[i] == -1) st = i;
		seen[i] = -2;
	}
	if(st == -1) bad();
	q[tp++] = st; seen[st] = -1;
	for(int tu = 0; tu < tp; tu++){
		int u = q[tu];;
		for(int v :hop.to[u]){
			int nv = hop.pair_r[v];
			if(nv != -1 && seen[nv] == -2){
				pu[v] = nv;
				pv[v] = u;
				seen[nv] = u;
				q[tp++] = nv;
			}
		}
	}
	for(int i = 0; i < n; i++) if(seen[i] == -2) bad();
	for(int i = 0; i < n - 1; i++) 
		printf("%d %d\n", pu[i] + 1, pv[i] + 1);
	return 0;
}


Measured memory_bytes: 11492
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long union_find_find(long c, vector<long> &vec) {
  if (vec[c] == 0) return c;
  long root = union_find_find(vec[c], vec);
  vec[c] = root;
  return root;
}

bool union_find_union(long a, long b, vector<long> &vec) {
  long aroot = union_find_find(a, vec);
  long broot = union_find_find(b, vec);
  if (aroot == broot) return false;
  vec[aroot] = broot;
  return true;
}

void solve() {
  long N, M;
  cin >> N >> M;

  vector<pair<long, long>> AB;
  rep (i, M) {
    long a, b;
    cin >> a >> b;
    AB.push_back(make_pair(a,b));
  }
  reverse(AB.begin(), AB.end());

  vector<long> union_find(N+1, 0);
  vector<long> ans;

  long fuben = N * (N-1) / 2;
  unordered_map<long, long> mp;
  rep (i, N) mp[i+1] = 1;
  rep (i, M) {
    ans.push_back(fuben);
    long aroot = union_find_find(AB[i].first, union_find);
    long broot = union_find_find(AB[i].second, union_find);
    if (union_find_union(AB[i].first, AB[i].second, union_find)) {
      long aroot_size = mp[aroot];
      long broot_size = mp[broot];
      long croot = union_find_find(AB[i].first, union_find);
      fuben -= aroot_size * broot_size;
      if (aroot == croot) {
        mp[aroot] += mp[broot];
        mp.erase(broot);
      } else {
        mp[broot] += mp[aroot];
        mp.erase(aroot);
      }
    }
  }

  reverse(ans.begin(), ans.end());
  for (auto it: ans) cout << it << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 9584
li = []
for i in range(5):
    li.append(int(input()))
mi = 10
for i in range(5):
    a = li[i]%10
    if mi > a and a != 0:
        mi = a
        t = i
if mi != 10:
    a = li[t]
    li.remove(a)
    for i in range(4):
        if li[i] % 10 != 0:
          li[i] += (10 - li[i] % 10)
    print(sum(li) + a)
else:
    print(sum(li))

Measured memory_bytes: 9076
#include<string.h>
#include<stdio.h>
int main()
{	char s[105],t[105];
	int i,j,sl,tl,f;
	scanf("%s%s",&s,&t);
	sl=strlen(s);
	tl=strlen(t);
	for(i=0;i<sl;i++)
	{
		f=1;
		for(j=0;j<sl;j++)
		{
			int c;
			if(j+i>=sl)
				c=j+i-sl;
			else
				c=j+i;
			if(s[j]!=t[c])
				f=0;
		}
		if(f==1)
			break;
	}
	if(f==1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    ll n, a, b;
    cin >> n >> a >> b;

    if (a > b || (n == 1 && a < b)) {
        cout << 0 << endl;
        return 0;
    }

    if (a == b) {
        cout << 1 << endl;
        return 0;
    }

    ll ans = (n - 2) * b - (n-2) * a + 1;
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<stdlib.h>
char d[90][90][6500]={};
int main(){
  int h,w,i,j,k,a[100][100];
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)scanf("%d",&a[i][j]);
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&k);
      a[i][j]=abs(a[i][j]-k);
    }
  }
  d[0][0][a[0][0]]=1;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      for(k=0;k<6410;k++){
	if(d[i][j][k]==0)continue;
	if(i+1<h){
	  d[i+1][j][    k+a[i+1][j] ]=1;
	  d[i+1][j][abs(k-a[i+1][j])]=1;
	}
	if(j+1<w){
	  d[i][j+1][    k+a[i][j+1] ]=1;
	  d[i][j+1][abs(k-a[i][j+1])]=1;
	}
      }
    }
  }
  for(i=0;i<6410;i++){
    if(d[h-1][w-1][i]==0)continue;
    printf("%d\n",i);
    return 0;
  }
}


Measured memory_bytes: 46976
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int idx = 7;
    for (auto s : { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" })
    {
        if (s == S)
        {
            break;
        }
        --idx;
    }
    cout << idx;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int array[9];

    for(int i = 0;i < 9;i++){
        cin >> array[i];
    }

    int checker[9];

    for(int i = 0;i < 9;i++){
        checker[i] = 0;
    }

    int n = 0;
    cin >> n;

    for(int i = 0; i < n ; i++){
        int b = 0;
        cin >> b;
        for(int j = 0;j < 9;j++){
            if(array[j] == b){
                checker[j] = 1;
                break;
            }
        }
    }

    if(checker[0] == 1 && checker[1] == 1 && checker[2] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[3] == 1 && checker[4] == 1 && checker[5] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[6] == 1 && checker[7] == 1 && checker[8] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[0] == 1 && checker[3] == 1 && checker[6] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[1] == 1 && checker[4] == 1 && checker[7] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[2] == 1 && checker[5] == 1 && checker[8] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[0] == 1 && checker[4] == 1 && checker[8] == 1){
        cout << "Yes" << endl;
        return 0;
    }

    if(checker[2] == 1 && checker[4] == 1 && checker[6] == 1){
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int sum = A+B+C;
    int max = Math.max(Math.max(A, B), C);
    int sup = max*3;
    
    if ((sup - sum)%2 == 1) {
      sup += 3;
    }
    System.out.println((sup - sum)/2);
  }
}


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

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

    long long max = a * b;
    long long res = 0;
    int tmp = (a < b ? b : a);
    for (long long i = tmp; i <= max; i += tmp) {
        if (i % a == 0 && i % b == 0) {
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int a[]= {0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y; cin>>x>>y;
  cout<<((a[x]==a[y])? "Yes":"No")<<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 int ll;
typedef pair<int, int> 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; }

bool dp[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    rep(j,k+1){
        rep(i,n){
            if(j-a[i] >= 0) dp[j] |= !dp[j-a[i]];
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 3644
// ※※※ 解答不能 ※※※
// beet氏.
// https://atcoder.jp/contests/abc163/submissions/12125379
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using vvi = vector<vector<int>>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back

template<typename F>
struct FixPoint : F{
    FixPoint(F&& f):F(forward<F>(f)){}
    template<typename... Args>
    decltype(auto) operator()(Args&&... args) const{
      return F::operator()(*this,forward<Args>(args)...);
    }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
    return FixPoint<F>{forward<F>(f)};
}

int main(){
    int n;
    cin>>n;
    vector<int> cs(n);
    rep(i, n){
        scanf("%d", &cs[i]);
        cs[i]--;
    }
    vvi G(n);
    repx(i, 1, n){
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    LL all = 0;
    vector<LL> cnt(n, 0), sub(n, 0);
    
    vector<LL> ans(n, (LL)n * (n - 1) / 2);
    MFP([&](auto dfs, int v, int p) -> int{
        sub[v] = 1;
        LL bfr = cnt[cs[v]];
        for(int u : G[v]){
            if(u == p) continue;
            LL pre = all - cnt[cs[v]];
            sub[v] += dfs(u, v);
            LL nxt = all - cnt[cs[v]];
            ans[cs[v]] -= (nxt - pre) * (nxt - pre - 1) / 2;
        }
        cnt[cs[v]] = bfr + sub[v];
        all++;
        return sub[v];
    })(0, -1);
    
    rep(c, n){
        LL pre = 0, nxt = n - cnt[c];
        ans[c] -= (nxt - pre) * (nxt - pre - 1) / 2;
    }
    for(int c : cs) ans[c]++;
    for(LL a : ans) printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 47832
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=5e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.size())==s and s.size()==t.size()-1) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b==15)printf("+");
	if(a*b==15)printf("*");
	if(a*b!=15&&a+b!=15) printf("x");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e5+7;
const ll INF = 1e18;

ll n,k;
int dp[nax],a[nax];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	for (ll i=0;i<nax;++i) dp[i]=-1;
	
	cin>>n>>k;
	for (ll i=0;i<n;++i) cin>>a[i];
	
	dp[0]=0;
	for (ll st=1;st<=k;++st){
		ll res=0;
		for (ll i=0;i<n;++i) {
			if (st>=a[i]) res|=(!dp[st-a[i]]);
		}
		
		dp[st]=res;
	}
	
	if (dp[k]) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,f;
	cin>>n;
	k=n%1000;
	if(k==0)cout<<k;
	else cout<<1000-k;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define            ll              long long
#define            pb              push_back
#define            mp              make_pair
#define            loop(i,a,n)     for(int i=a;i<=n;++i)
#define            clr(x)          memset(x,0,sizeof x)
#define            min3(a,b,c)     min(a,min(b,c))
#define            max3(a,b,c)     max(a,max(b,c))
#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define            pii             pair<int,int>
#define            pll             pair<ll,ll>
#define            pli             pair<ll,int>
#define            pil             pair<int,ll>
#define            FF              first
#define            SS              second
#define            PI              acos(-1.0)
#define            bug             cout<<"ok"<<endl;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int , null_type,less<int>,
       rb_tree_tag, tree_order_statistics_node_update> anik;

const int MOD = 1e9 + 7;
const ll MX= 1e9;
const ll INF = 1e9;

const ll N=520;
ll a[N][N],ans[N*N][4];

main()
{
   ll n,m;
   cin>>n>>m;

   for(int i=1;i<=n;++i)
   {
       for(int j=1;j<=m;++j)
        cin>>a[i][j];
   }
   int cnt=0,k=0;


   for(int i=1;i<=n;++i)
   {
       for(int j=1;j<m;++j)
       {
           if(a[i][j]%2==1)
           {
                   a[i][j+1]+=1;
                   ans[k][0]=i;
                   ans[k][1]=j;
                   ans[k][2]=i;
                   ans[k++][3]=j+1;

           }

       }
   }
   for(int i=1;i<n;++i)
   {
       if(a[i][m]%2==1)
       {
           a[i+1][m]+=1;
           ans[k][0]=i;
           ans[k][1]=m;
           ans[k][2]=i+1;
           ans[k++][3]=m;
       }
   }

   cout<<k<<endl;
   for(int i=0;i<k;++i)
    cout<<ans[i][0]<<" "<<ans[i][1]<<" "<<ans[i][2]<<" "<<ans[i][3]<<endl;
}



Measured memory_bytes: 9584
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<string>
#include<climits>

using namespace std;

int main(void){
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<long long> s(A);
    vector<long long> t(B);
    for(int i = 0; i < A; i++) cin >> s[i];
    for(int i = 0; i < B; i++) cin >> t[i];

    vector<long long> rs(A), rt(A);

    for(int q = 0; q < Q; q++){
        long long ans;
        long long x;
        cin >> x;

        long long ls, lt, rs, rt;
        vector<long long>::iterator itr;
        itr = lower_bound(s.begin(), s.end(), x);
        if(itr == s.end()){
            ls = x - *(itr - 1);
            rs = LLONG_MAX / 4;
        }else if(itr == s.begin()){
            ls = LLONG_MAX / 4;
            rs = *itr - x;
        }else if(*itr == x){
            ls = rs = 0;
        }else{
            ls = x - *(itr - 1);
            rs = *itr - x;
        }
        itr = lower_bound(t.begin(), t.end(), x);
        if(itr == t.end()){
            lt = x - *(itr - 1);
            rt = LLONG_MAX / 2;
        }else if(itr == t.begin()){
            lt = LLONG_MAX / 2;
            rt = *itr - x;
        }else if(*itr == x){
            lt = rt = 0;
        }else{
            lt = x - *(itr - 1);
            rt = *itr - x;
        }
        // cout << q << " " << ls << " " << lt << " " << rs << " " << rt << endl;
        cout << min(min(ls + rt + min(ls, rt), lt + rs + min(lt, rs)), min(max(ls, lt), max(rs, rt))) << endl;
    }
    return 0;
}


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

int devide_by2(int i, int K){
  i++;
  int count = 0;
  while(i < K){
    i *= 2;
    count++;
  }
  return count;
}

double bi(double &ans, int i, double N, int K){
  double count = 1;
  for(int j = 0; j < devide_by2(i, K); j++){
    count /= 2;
  }
  return count * (1 / N);
}

int main(){
  double N;
  int K;
  cin >> N >> K;
  cout << fixed << setprecision(11);
  
  double ans = 0;
  for(int i = 0; i < N; i++){
    ans += bi(ans, i, N, K);
  }
  
  cout << ans << endl;
}



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

int m, d;
int ans = 0;

int main() {
    cin >> m >> d;

    for (int i = 1; i <= m; ++i) {
        for (int j = 22; j <= d; ++j) {
            int one = j % 10;
            int ten = j / 10;
            if (i == one * ten && one >= 2 && ten >= 2) {
                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include <cstdio>

int n,q;
int s[10001];

int search(int key){
	for(int i=0;i<n;i++){
		if(s[i]==key)return 1;
	}
	return 0;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	int cnt=0;
	for(int i=0;i<q;i++){
		int t;
		scanf("%d",&t);
		cnt+=search(t);
	}
	printf("%d\n",cnt);
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        sum += a;
    }
    if (sum > n) cout << "-1";
    else cout << n - sum;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll R, C, K; cin >> R >> C >> K;
  static ll goods[3000][3000] = {};
  rep(i,K) {
    ll r, c, v; cin >> r >> c >> v; r--; c--;
    goods[r][c] = v;
  }

  static ll dp[3000][3000][4] = {}; dp[0][0][1] = goods[0][0];
  rep(i,R) rep(j,C) rep(k,4) {
    if (i!=R-1) {
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
      dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k]+goods[i+1][j]);
    }
    if (j!=C-1) {
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
      if (k!=3) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k]+goods[i][j+1]);
    }
  }

  ll result = *max_element(dp[R-1][C-1],dp[R-1][C-1]+4);
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 355152
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string n;
  	cin >> n;
  	int s = 0;
  	for (int i = 0; i < n.size(); i++)
    	s += n[i] - '0';
  	if (s % 9 == 0)
      	cout << "Yes";
  	else
    	cout << "No";
    return 0;
}

Measured memory_bytes: 3748
N, M = gets.split.map(&:to_i)

# M >= dNとなる最大のMの約数dが答え
d = M / N
if M % N == 0
  puts d
else
  d.downto(1) do |n|
    if M % n == 0
      puts n
      break
    end
  end
end

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int mod[]={1,3,5,7,9,11,15,17,19,21,23,25};
int main(){
  int n;
  cin >>n;
  cin.ignore();
  while(n--){
    string s,t;
    getline(cin,s);
    t = s;
    for(int i=0; i<12; i++){
      for(int j=0; j<26; j++){
	for(int k=0; k<s.size(); k++){
	  if(s[k]>='a' && s[k]<='z') t[k] = 'a'+((s[k]-'a')*mod[i]+j)%26;
	}
	if(t.find("this") != string::npos){cout <<t<<endl;goto flag;}
	if(t.find("that") != string::npos){cout <<t<<endl;goto flag;}
      }
    }
  flag:;
  }
  return 0;
}

Measured memory_bytes: 1216
from collections import deque

h, w = map(int, input().split())
maze = [input() for _ in range(h)]
dires = [(1,0),(0,1),(-1,0),(0,-1)]
ans = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            continue        
        q = deque()
        q.append((i, j, 0))
        explored = set()
        explored.add((i, j))
        longest = 0
        while q:
            y, x, count = q.popleft()
            for d, r in dires:
                y_ = y+d
                x_ = x+r
                if (y_, x_) in explored or y_ >= h or x_ >= w or y_ < 0 or x_ < 0 or maze[y_][x_] == "#":
                    continue

                explored.add((y_, x_))
                q.append((y_, x_, count+1))
                longest = max(longest, count+1)

        ans = max(ans, longest)

print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, T;
    cin >> X >> T;
    cout << std::max(0LL, X - T) << endl;
    return 0;
}

Measured memory_bytes: 256
S = int(input())
# 10**9 * y - x = S
if S <= 10**9:
    print(0,0,S,0,0,1)
else:
    if S != 10**18:
        y = (S + 10**9) // 10**9
        x = abs((10**9) * y - S)
        print(0,0,10**9,1,x,y)
    else:
        print(0,0,10**9,0,0,10**9)

Measured memory_bytes: 3060
S = input()
y = int(S[:4])
m = int(S[5:7])
d = int(S[8:])
ans = "Heisei"
if y == 2019:
    if m == 4:
        if d > 30:
            ans = "TBD"
    elif m > 4:
        ans = "TBD"
elif y > 2019:
    ans = "TBD"

print(ans)

Measured memory_bytes: 38384
N, M = map(int, input().split())
mod=10**9+7
dp = [1]*(N+1)
for _ in range(M):
    a, = map(int, input().split())
    dp[a] = 0
for i in range(2,N+1):
    if dp[i] != 0:
        dp[i] = (dp[i-1] + dp[i-2])%mod
print(dp[N])


Measured memory_bytes: 44248