akhauriyash/Code-Regression huggingface dataset:
def f():
    import sys
    input=sys.stdin.readline
    n,m=[int(i) for i in input().split()]
    s=[int(i) for i in input().split()]
    t=[int(i) for i in input().split()]
    mod=10**9+7
    dp=[[0]*(m+1) for i in range(2)]
    dp[0][0]=1
    for i in range(n+1):
        for j in range(m+1):
            if i!=0:
                dp[i%2][j]=dp[(i-1)%2][j]
            if j!=0:
                dp[i%2][j]+=dp[i%2][j-1]
            if i!=0 and j!=0:
                if s[i-1]!=t[j-1]:
                    dp[i%2][j]-=dp[(i-1)%2][j-1]
            dp[i%2][j]%=mod
    print(dp[n%2][m])


f()




Measured memory_bytes: 42240
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
    int r = floor(sqrt(n));
 	cout << r*r << endl;
	return;
}

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


Measured memory_bytes: 256
object Main extends App {
  val n = io.StdIn.readInt()
  val adjacents = Array.fill[Array[Int]](n)(Array())
  for (_ <- 0 until n) {
    val data = io.StdIn.readLine().split(" ").map(_.toInt)
    val id = data(0)-1
    adjacents(id) = data.drop(2).map(_-1)
  }
  val depth = Array.fill[Int](n)(-1)
  def search(x: Int) = {
    val queue = collection.mutable.Queue.empty[Int]
    depth(x) = 0
    queue.enqueue(x)
    loop()
    def loop(): Unit =
      if (queue.isEmpty) ()
      else {
        val i = queue.dequeue()
        for (a <- adjacents(i))
          if (depth(a) < 0) {
            depth(a) = depth(i)+1
            queue.enqueue(a)
          }
        loop()
      }
  }
  search(0)
  for (i <- 0 until n) println(s"${i+1} ${depth(i)}")
}


Measured memory_bytes: 44388
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MAX = 1e5 + 10;

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

	int N, K;
	cin >> N >> K;

	vector<int> V(N);
	vector<int> DP(MAX,INF);

	for(int i = 0; i < N; i++) cin >> V[i];

	DP[0] = 0;

	for(int i = 0; i < N; i++){
		for(int j = 1; j <= K; j++){
			if(i + j < N){
				DP[i+j] = min(DP[i+j], DP[i] + abs(V[j+i] - V[i]));
			}
		}
	}

	cout << DP[N-1] << endl;


	return 0;
}


Measured memory_bytes: 3964
import sys
from collections import defaultdict

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

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


def main():

    #A, B = 123, 456
    A, B = in_nn()
    d = defaultdict(lambda: 0)

    n = 1
    while n <= A:
        n *= 2
        r = A % n
        #print(n, r)
        if r >= n // 2:
            d[n] = (r - n // 2) % 2

    n = 1
    while n <= B:
        n *= 2
        r = B % n
        #print(n, r)
        if r >= n // 2:
            d[n] ^= (r - n // 2 + 1) % 2

    n = 2
    ans = 0
    while n <= max(A, B):
        n *= 2
        ans += (n // 2) * d[n]

    d = (B - A + 1) % 4
    if A % 2 == 0:
        if d == 2 or d == 3:
            ans += 1
    if A % 2 == 1:
        if d == 1 or d == 2:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<string>
using namespace std;
int N, S, i, cnt, R, num;
string str, s;
string ring[101];
int main(){
    cin >> str >> N;
    S = str.size();
    for (i=0; i<N; i++){
        cin >> s;
        ring[i] = s + s;
    }
    cnt = 0;
    for (i=0; i<N; i++){
        R = ring[i].size();
        for (num = 0; num < R-S+1; num++){
            if( ring[i].substr(num,S) == str ){
                cnt++; break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

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

vector<int> adj[200007];
bool vis[200007];
int dist[200007];
int n, m;

int bfs(int st)
{
    queue<int> q;
    q.push(st);
    vis[st] = 1;

    while (!q.empty()) {
        int curpos = q.front();
        q.pop();
        if (curpos == n) return dist[n];

        for (auto x : adj[curpos]) {
            if (vis[x]) continue;

            q.push(x);
            dist[x] = dist[curpos] + 1;
            vis[x] = 1;
        }
    }
    return INT_MAX;
}

int main()
{
    cin >> n >> m;
    int u, v;
    for (int i = 1; i <= m; i++) {
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    int ans = bfs(1);

    if (ans <= 2) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    int k, a, b;
    cin >> k >> a >> b;
    bool flag = false;
    for (int i = a; i <= b; i++) {
        if(i % k == 0) {
            flag = true;
            break;
        }
    }
    if(flag) {
        cout << "OK" << endl;
    }else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define	ll_int long long int


typedef struct{
	ll_int v;
	ll_int w;
	char t;
	ll_int d;
	char i_name[21];
}DATA_T;


DATA_T *WORK;


void Merge_sort(DATA_T *box, int l, int r, int kind)
{
	int mid;
	ll_int num1, num2;
	char str1[21], str2[21];
	int i, j, k;


	if(r <= l)
		return;

	mid = (l + r) / 2;


	Merge_sort(box, l, mid, kind);

	Merge_sort(box, mid + 1, r, kind);


	for(i = l; i <= mid; i++)
		WORK[i] = box[i];

	for(i = mid + 1, j = r; i <= r; i++, j--)
		WORK[i] = box[j];


	j = l;
	k = r;
	for(i = l; i <= r; i++){
		if(kind == 4){
		// 商品名
			strcpy(str1, WORK[j].i_name);
			strcpy(str2, WORK[k].i_name);
		}else if(kind == 3){
		// 日時
			num1 = WORK[j].d;
			num2 = WORK[k].d;
		}else if(kind == 2){
		// 型
			num1 = WORK[j].t;
			num2 = WORK[k].t;
		}else if(kind == 1){
		// 重さ
			num1 = WORK[j].w;
			num2 = WORK[k].w;
		}else{
		// 価値
			num1 = WORK[j].v;
			num2 = WORK[k].v;
		}

		if(kind == 3 || kind == 2 || kind == 1 || kind == 0){
			if(num1 <= num2 && j <= mid)
				box[i] = WORK[j++];
			else
				box[i] = WORK[k--];
		}else{
			if(strcmp(str1, str2) <= 0 && j <= mid)
				box[i] = WORK[j++];
			else
				box[i] = WORK[k--];
		}
	}

}


void Print_box(DATA_T *box, int n)
{
	int i;

	for(i = 0; i < n; i++)
		printf("%lld %lld %c %lld %s\n", box[i].v, box[i].w, box[i].t, box[i].d, box[i].i_name);
}


int main()
{
	int n;
	DATA_T *box;
	int i;


	scanf("%d", &n);

	box = (DATA_T *)malloc(sizeof(DATA_T) * n);
	WORK = (DATA_T *)malloc(sizeof(DATA_T) * n);

	for(i = 0; i < n; i++)
		scanf("%lld %lld %c %lld %s", &box[i].v, &box[i].w, &box[i].t, &box[i].d, box[i].i_name);


	Merge_sort(box, 0, n - 1, 4);
	Merge_sort(box, 0, n - 1, 3);
	Merge_sort(box, 0, n - 1, 2);
	Merge_sort(box, 0, n - 1, 1);
	Merge_sort(box, 0, n - 1, 0);


	Print_box(box, n);

	return 0;
}


Measured memory_bytes: 12804
package main

import (
	"fmt"
)

type ll int64

type part_time_job struct {
	days ll
	paid ll
}

type Bydays []part_time_job
func (a Bydays) Len() int           { return len(a) }
func (a Bydays) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Bydays) Less(i, j int) bool { return a[i].days <  a[j].days }

type Bypaid []part_time_job
func (a Bypaid) Len() int           { return len(a) }
func (a Bypaid) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Bypaid) Less(i, j int) bool { return a[i].paid > a[j].paid }


func main() {

	var A,B int
	fmt.Scan(&A,&B)

	var ans = 0
	if (B - 1) % (A-1) == 0{
		ans = (B - 1) / (A-1)
	}else{
		ans = (B - 1) / (A-1) + 1
	}


	fmt.Println(ans)



}


Measured memory_bytes: 512
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 300 + 10, mod = 998244353;

int add(int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int sub(int a, int b) {
	a -= b;
	if (a < 0) a += mod;
	return a;
}

int mul(ll a, int b) {
	return (a * b) % mod;
}

int pwr(int x, int e) {
	int res = 1;
	while (e) {
		if (e & 1) {
			res = mul(res, x);
		}
		x = mul(x, x);
		e /= 2;
	}
	return res;
}

int divd(int a, int b) {
	return mul(a, pwr(b, mod - 2));
}

int dp[N][N][N], sum[N][N][N];

int main() {
	fast_cin();
	string s; int k;
	cin >> s >> k;
	int n = s.length();
	k = min(k, n);
	vector<int> a;
	s += '0';
	int cur = 0;
	for (auto& i : s) {
		if (i == '1') {
			++cur;
		} else {
			a.pb(cur);
			cur = 0;
		}
	}
	dp[0][0][0] = 1;
	int m = a.size();
	for (int l = 0; l <= k; ++l) {
		dp[0][0][l] = 1;
	}
	for (int i = 1; i <= m; ++i) {
		for (int l = 0; l <= k; ++l) {
			for (int j = 1; j <= k; ++j) {
				sum[i - 1][l][j] = add(sum[i - 1][l][j - 1], dp[i - 1][j - 1][l]);
			}
		}
		for (int j = 0; j <= k; ++j) {
			for (int l = 0; l <= k; ++l) {
				dp[i][j][l] = sum[i - 1][l][j];
				for (int x = 0; x <= a[i - 1] and x <= l; ++x) {
					dp[i][j][l] = add(dp[i][j][l], dp[i - 1][j + x][l - x]);
				}
				// cout << i << ' ' << j << ' ' << l << ' ' << dp[i][j][l] << endl;
			}
		}
	}
	cout << dp[m][0][k] << endl;
}

Measured memory_bytes: 114472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, q, l[112345], r[112345];
    string s;

    cin >> n >> q >> s;
    REP(i, q)
    cin >> l[i] >> r[i];

    int sum[112345];
    sum[0] = 0;
    sum[1] = 0;

    for (int i = 1; i < n; i++)
    {
        sum[i + 1] += sum[i] + (s[i] == 'C' && s[i - 1] == 'A');
    }

    REP(i, q)
    {
        if (s[l[i] - 1] == 'C')
            l[i]++;
        if (s[r[i] - 1] == 'A')
            r[i]--;

        cout << sum[r[i]] - sum[l[i] - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	vector<int> tmp;
	tmp.push_back(0);
	REP(i, m) {
		int a;
		cin >> a;
		tmp.push_back(a);
	}
	int ans = 1e9;
	REP(teas, 2) {
		int now = 0;
		int cnter = 0;
		REP(i, tmp.size()) {
			REP(q, tmp[i]) {
				int cnt = 0;
				REP(j, n) {
					if ((1 << j) & now) {
						continue;
					}
					if (inputs[j] == i % 2) {
						now += (1 << j);
						cnter += cnt;
						break;
					}
					else {
						cnt++;
					}
				}
			}
		}
		if (now == (1 << n) - 1) {
			ans = min(ans, cnter);
		}
		tmp.erase(tmp.begin());
	}
	cout << ans << endl;
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3216
class D_Linked_List:
    """Doubly Linked List class.

    ?????¢?????´???????????¨??????????§???????p.96-100.
    """
    class Node:
        def __init__(self, key, next = None, prev = None):
            self.next = next
            self.prev = prev
            self.key = key

    def __init__(self):
        self.nil = D_Linked_List.Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil

    def insert(self, key):
        node_x = D_Linked_List.Node(key, self.nil.next, self.nil)
        self.nil.next.prev = node_x
        self.nil.next = node_x

    def _listSearch(self, key):
        cur_node = self.nil.next
        while (cur_node != self.nil) and (cur_node.key != key):
            cur_node = cur_node.next
        return cur_node

    def _deleteNode(self, node):
        if node == self.nil:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._deleteNode(self.nil.next)

    def deleteLast(self):
        self._deleteNode(self.nil.prev)

    def deleteKey(self, key):
        node = self._listSearch(key)
        self._deleteNode(node)

    def show_keys(self):    # ????????????node???key????????????????????§??????????????????????????§???
        cur_node = self.nil.next
        keys = []
        while cur_node != self.nil:
            keys.append(cur_node.key)
            cur_node = cur_node.next
        print(' '.join(keys))


import sys

d_ll = D_Linked_List()

for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        d_ll.insert(x)
    elif 'First' in i:
        d_ll.deleteFirst()
    elif 'Last' in i:
        d_ll.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        d_ll.deleteKey(x)
    else:   # ??\??????????????¨?????????command??§??????????????§???pass?????????
        pass

d_ll.show_keys()

Measured memory_bytes: 228676
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		try {
			sc = new Scanner(System.in);
			while (sc.hasNextInt()) {
				int d = sc.nextInt();
				int loopCount = 600 / d - 1;
				long sum = 0L;

				for (int i = 1; i <= loopCount; i++) {
					int x = i * d;
					int pow = x * x;
					sum += pow * d;
				}
				System.out.println(sum);
			}
		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 26172
def move(d, r):
    if r == 'N':
        return (d[1], d[5], d[2], d[3], d[0], d[4])
    if r == 'E':
        return (d[3], d[1], d[0], d[5], d[4], d[2])
    if r == 'W':
        return (d[2], d[1], d[5], d[0], d[4], d[3])
    if r == 'S':
        return (d[4], d[0], d[2], d[3], d[5], d[1])
    return d
     
def gen_all(dice_1):
    dice = {dice_1}
    while True:
        dice2 = {move(d,r) for d in dice for r in list("NEWS")}.union(dice)
        if dice == dice2: break
        dice = dice2
    return dice    


n = int(input())
count = 0
dice = [0 for i in range(n)]


for i in range(n):
    dice[i] = tuple(map(int,input().split()))

for i in range(n):
    for k in range(i):
        if count == 1: break
        if dice[i] in gen_all(dice[k]):
            print("No")
            count = 1
            break
if count == 0:
    print("Yes")   
    

    
    
    

Measured memory_bytes: 7736
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(int argc, const char * argv[]) {
    int N, M;
    
    cin >> N >> M;
    vector<string> A, B;
    A.resize(N);
    B.resize(M);
    
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    
    bool flag;
    for(int i = 0; i < N - M + 1; i++)
    {
        for(int j = 0; j < N - M + 1; j++)
        {
            int starti = i;
            int startj = j;
            
            flag = true;

            for(int k = 0; k < M; k++)
            {
                for(int l = 0; l < M; l++)
                {
                    if (A[k+starti][l+startj] != B[k][l])
                    {
                        flag = false;
                        break;
                    }
                    
                }
            }

            if(flag)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 384
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
r, d, x = M()
temp = x
for _ in range(10):
    a = temp*r-d
    temp = a
    print(a)

Measured memory_bytes: 4020
def main():
    s = input()
    k = int(input())
    
    index = 0
    for i, ss in enumerate(s):
        if ss != '1':
            index = i
            break
    
    if k <= index:
        print(1)
    else:
        print(s[index])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;


	public class Main {
		public static void main(String[] args) {
			int number=0;
			int counter=0;
			int previousCounter=0;
			int number1=1;
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		for( int i=0; i<= x; i++)
		{
			number=i;
			while(number%2==0 && number!=0) 
			{
				number= number/2;
				counter++;
			}
			if(counter>previousCounter)
			{
				previousCounter=counter;
				number1=i;
			}
			counter=0;
			
		}
		System.out.print(number1);
		sc.close();
		}
}

Measured memory_bytes: 21972
import sys
def c():
    p = [[int(t) for t in r.split(' ')] for r in sys.stdin.read().split('\n') if r != '']
    N, M = p[0]
    l = p[1:M + 1]
    cond = p[M + 1]
    count = 0
    for i in range(0, 1<<N):
        cc = 0
        for j in range(0, M):
            b = 0b0
            for k in l[j][1:]:
                if (i >> (k - 1)) & 0b1 == 1:
                    b = ~b
            if b & 0b1 != cond[j]:
                break
            cc = cc + 1
        if cc == M:
            count = count + 1
    print(count)
c()


Measured memory_bytes: 3064
s=input()
s = list(s)
#print(s)
fcount0 = 0
fcount1 = 0

for i in range(len(s)):
   if i%2==0 and s[i] != '0':
       fcount0 += 1
   elif i%2==1 and s[i] != '1':
       fcount0 += 1

for i in range(len(s)):
   if i%2==0 and s[i] != '1':
       fcount1 += 1
   elif i%2==1 and s[i] != '0':
       fcount1 += 1

print(min(fcount0, fcount1))

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

int main(){
  int A, B;
  cin >> A >> B;
  
  int keta;
  if (B <= 9) keta = 10;
  if (B >= 10 && B <= 99) keta = 100;
  if (B == 100) keta = 1000;
  
  int AB = A * keta + B;
  
  for (int i = 0; i < 1000; i++){
    if (i * i == AB){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  
  cout << "No" << endl;

}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> d(n); REP(i, n) cin >> d[i];
  sort(ALL(d));
  int m; cin >> m;
  vector<int> t(m); REP(i, m) cin >> t[i];
  sort(ALL(t));
  int now = 0;
  REP(i, m) {
    bool exist = false;
    for (; now < n; ++now) {
      if (t[i] == d[now]) {
        ++now;
        exist = true;
        break;
      }
    }
    if (now == n) {
      if (i == m-1 && exist) {
        cout << "YES\n";
        return 0;
      } else {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}


Measured memory_bytes: 1792
import sys


N=input()
A=[  int(sys.stdin.readline()) for i in range(N) ] 

A.sort()

K=[]
K2=[]

if N%2==0:
	n=(N-2)/2
	K=[ -2 for i in range(n) ]+[-1,1]+[ 2 for i in range(n) ]
else:
	n=(N-2)/2

	## Pattern 1
	K=[ -2 for i in range(n) ]+[-1,-1]+[ 2 for i in range(n+1) ]
	## End

	## Pattern 2
	K2=[ -2 for i in range(n+1) ]+[1,1]+[ 2 for i in range(n) ]
	## End

ans=0

t1=0
for x, y in zip(A,K):
	t1+=x*y

t2=0
for x, y in zip(A,K2):
	t2+=x*y


print max(t1,t2)





Measured memory_bytes: 41628
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,k,m=0,p,r;(n=s.nextInt())>0;System.out.println(m)){int[]a=new int[k=s.nextInt()];for(r=p=0;p<k;)r+=a[p++]=s.nextInt();for(p=0,n-=k;n-->0;m=m>r?m:r,p=(p+1)%k){r-=a[p];r+=a[p]=s.nextInt();}}}}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const double pai=atan(1.0)*4;
int r;
void solve(){
    cout<<2*pai*r<<endl;
}

int main(){
    cin>>r;

    solve();
    return 0;
}


Measured memory_bytes: 3784
n = int(input())
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

d = []
for i in range(n):
    dif = v[i] - c[i]
    if dif > 0:
        d.append(dif)

res = 0

for i in d:
    res += i

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<typename T>
struct CSum2D {
  vector<vector<T> > d;
  CSum2D(int h, int w):d(h+1, vector<T>(w+1,0)){}
  void add(int y, int x, T v = 1) {
    x++; y++;
    assert(y < (int)d.size() && x < (int)d[0].size());
    d[y][x] += v;
  }
  void build() {
    for (int y = 0; y < (int)d.size(); ++y) {
      for (int x = 1; x < (int)d[0].size(); ++x) {
        d[y][x] += d[y][x-1];
      }
    }
    for (int y = 1; y < (int)d.size(); ++y) {
      for (int x = 0; x < (int)d[0].size(); ++x) {
        d[y][x] += d[y-1][x];
      }
    }
  } 
  T query(int x1, int y1, int x2, int y2) { 
    x1++; y1++; x2++; y2++;
    assert(x2 < (int)d[0].size() && y2 < (int)d.size());
    return d[y2][x2] - d[y1-1][x2] - d[y2][x1-1] + d[y1-1][x1-1];
  }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n, m, q;
  cin >> n >> m >> q;
  CSum2D<int> S(n+1, n+1);
  rep(i,m) {
    int l, r;
    cin >> l >> r;
    S.add(l, r);
  }
  S.build();
  while(q--) {
    int l, r;
    cin >> l >> r;
    cout << S.query(l, l, r, r) << "\n";
  }
  return 0;
}

Measured memory_bytes: 4168
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define fi first
#define se second
#define pt(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N;
    cin >> N;
    ll a[3][111]={};
    ll dp[3][111]={};
    ll i, j;
    
    for(i=1; i<=2; i++)
        for(j=1; j<=N; j++)
            cin >> a[i][j];
    
    for(i=1; i<=2; i++)
        for(j=1; j<=N; j++)
            dp[i][j]=a[i][j]+max(dp[i][j-1], dp[i-1][j]);
    
    pt(dp[2][N]);
    
}



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

int main() {

long long n,i,x,y;

long long z=0;

cin >> n;

vector<long long> a(n);

for(i=0;i<n;++i){
cin >> a.at(i);
}

x=a.at(0);
y=a.at(0);

for(i=0;i<n-1;++i){
x=min(x,a.at(i+1));
y=max(y,a.at(i+1));
z=z+a.at(i);
}

z=z+a.at(n-1);

cout << x << " " << y << " " << z << endl;

}


Measured memory_bytes: 3180
n=int(input())
a=list(map(int,input().split()))
import fractions
d=a[0]
for i in range(n-1):
	d=(d*a[i+1])//fractions.gcd(a[i+1],d)
d-=1
ans=0
for i in range(n):
	ans+=d%a[i]
print(ans)

Measured memory_bytes: 5176
/*
[dwacon5th-prelims] B - Sum AND Subarrays
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1000;
const int D = 40;

int N, K;
int a[MAX_N];

ll solve() {
    ll s[MAX_N + 1];
    s[0] = 0;
    for (int i = 1; i <= N; i++) {
        s[i] = s[i - 1] + a[i - 1];
    }

    vector<ll> bu;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j <= N; j++) {
            bu.push_back(s[j] - s[i]);
        }
    }

    ll ans = 0;
    for (int d = D; d >= 0; d--) {
        ll x = ans | (1LL << d);
        int cnt = 0;
        for (ll b : bu) {
            if ((x & b) == x) {
                cnt++;
            }
        }
        if (cnt >= K) {
            ans = x;
        }
    }

    return ans;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 6512
a,b,c,d = map(int, input().split())
i = 0
while a > 0 and c > 0:
    c -= b
    i += 1
    if c > 0:
        a -= d
        i += 1

if i % 2 == 1:
    print('Yes')
else:
    print('No')
        

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cit(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    cit.at(a - 1)++;
    cit.at(b - 1)++;
  }
  for (int i = 0; i < N; i++)
    cout << cit.at(i) << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
ans = []
for i, a in enumerate(A, start=1):
    ans += [i] * a
for i in range(H):
    if i % 2:
        print(*ans[i * W: (i + 1) * W][::-1])
    else:
        print(*ans[i * W: (i + 1) * W])

Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
 
			if (a < 9 && b < 9) {
				System.out.println("Yay!");
			} else {
				System.out.println(":(");
			}
		}
	}
}

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

int main(){
	int d, t = 0;
	int ans[100] = {0};
	while(cin >> d){
		for(int i = d; i < 600; i = i+d){
			ans[t] = ans[t]+i*i*d;
		}
		t++;
	}
	for(int i = 0; i < t; i++){
		cout << ans[i] << endl;
	}
}

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

const int MOD = 1e9 + 7;
const int MAX_COMB = 1e5;

vector<int64_t> fac(MAX_COMB + 1);
vector<int64_t> fac_inv(MAX_COMB + 1);
vector<int64_t> inv(MAX_COMB + 1);

void init_comb()
{
    fac.at(0) = fac.at(1) = 1;
    fac_inv.at(0) = fac_inv.at(1) = 1;
    inv.at(1) = 1;
    for (int i = 2; i <= MAX_COMB; i++)
    {
        fac.at(i) = fac.at(i - 1) * i % MOD;
        inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
        fac_inv.at(i) = fac_inv.at(i - 1) * inv.at(i) % MOD;
    }
}

int comb(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac.at(n) * (fac_inv.at(k) * fac_inv.at(n - k) % MOD) % MOD;
}

int main()
{
    init_comb();

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }

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

    int64_t res = 0;
    for (int i = 0; i < N; i++)
    {
        if (i < K - 1)
            continue;
        int64_t c = comb(i, K - 1);
        int64_t mx = (MOD + A.at(i)) % MOD;
        res = (res + c * mx % MOD) % MOD;
    }
    for (int i = 0; i < N; i++)
    {
        if (N - i - 1 < K - 1)
            continue;
        int64_t c = comb(N - i - 1, K - 1);
        int64_t mn = (MOD + A.at(i)) % MOD;
        res = (MOD + res - c * mn % MOD) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long n,a3,a5,a15,sum;
	cin>>n;
	a3=n/3;
	a5=n/5;
	a15=n/15;
	sum=(1+n)*n/2;
	sum-=(3+a3*3)*a3/2;
	sum-=(5+a5*5)*a5/2;
	sum+=(15+a15*15)*a15/2;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    string s;
    cin >> s;
    map<char,int> m;
    for(char c : s)m[c]++;
    int maxm = 0;
    int minm = INF;
    if(s.length() == 1){
        cout << "YES\n" << endl;
        return 0;
    }
    if(s.length() == 2 && m.size() == 2){
        cout << "YES\n";
        return 0;
    }else if(s.length() == 2 && m.size() == 1){
        cout << "NO\n";
        return 0;
    }
    for(auto a : m){
        maxm = max(maxm,a.second);
        minm = min(minm,a.second);
    }
    if(m.size() < 3)cout << "NO\n";
    else if(maxm - minm > 1)cout << "NO\n";
    else cout << "YES\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
pl P[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> P[i].fst >> P[i].sec;
		if(P[i].fst > P[i].sec) swap(P[i].fst, P[i].sec);
	}
	sort(P, P + N);
	multiset<ll> R;
	multiset<ll> B;
	rep(i, 0, N) {
		R.insert(P[i].fst); B.insert(P[i].sec);
	}
	ll ans = linf;
	rep(i, 0, N + 1) {
		ll minr = *R.begin(), maxr = *(--R.end());
		ll minb = *B.begin(), maxb = *(--B.end());
		MIN(ans, (maxb - minb) * (maxr - minr));
		if(i == N) break;
		R.erase(R.lower_bound(P[i].fst));
		R.insert(P[i].sec);
		B.erase(B.lower_bound(P[i].sec));
		B.insert(P[i].fst);
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

const int N = 3007;
double mem[N][N],a[N];
int n;

double dp(int i,int k){
    if(i==n){
        if(k>n/2){
            return 1.0;
        }else{
            return 0.0;
        }
    }
    double &ret = mem[i][k];
    if(ret != -1){
        return ret;
    }

    double p1,p2;
    p1= a[i]*dp(i+1,k+1);
    p2= (1-a[i])*dp(i+1,k);

    return ret = p1+p2;

}

int main(){
    SPEED
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            mem[i][j]=-1.0;
    cout<<fixed<<setprecision(10)<<dp(0,0);

}


Measured memory_bytes: 70912
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define ps(x,y)         fixed<<setprecision(y)<<x
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    const int MAX=1000000+5;
    int p[MAX]={0};

     int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}
    bool isPrime(int n) 
    { 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
    } 
    int mm[200000+5];
    int vis[200000+5]={0};
    signed main() {

 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
   // cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        int p[m];
        int k[m];
        int z[m][10];
        f(i,0,m)
        {
            cin>>k[i];
            f(j,0,k[i])
            {
                cin>>z[i][j];
                z[i][j]--;
            }
        }
        f(i,0,m)
        {
            cin>>p[i];
        }
        int ans=0;
        f(i,0,(1<<n))
        {
            bool flag=true;
            f(j,0,m)
            {
                int cnt=0;
                f(r,0,k[j])
                {
                    if((1<<z[j][r])&i)
                        cnt++;
                }
                if(cnt%2!=p[j]%2)
                {
                    flag=false;
                    break;
                }
            }
            if(flag)
            {
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

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

    vector<int> edge[100005];
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    if (m % 2 == 1) {
        cout << -1 << "\n";
        return 0;
    }

    vector<int> size(n);
    vector<int> sum(n, 0);
    vector<bool> visited(n, false);

    priority_queue <P, vector<P>, greater<P>> q;

    int mn = 1 << 30;
    for (int i = 0; i < n; i++) {
        size[i] = edge[i].size();
        mn = min(mn, size[i]);
    }

    for (int i = 0; i < n; i++) {
        if (size[i] == mn) {
            q.push(P(size[i], i));
        }
    }

    while (q.size()) {
        P p = q.top();
        q.pop();

        int cur = p.second;
        if (visited[cur]) continue;
        visited[cur] = true;

        int mx = -1;
        int mx_idx = -1;

        if (sum[cur] % 2 == 1) {
            for (int ch : edge[cur]) {
                if (visited[ch]) continue;

                if (size[ch] > mx) {
                    mx = size[ch];
                    mx_idx = ch;
                }
            }
        }

        for (int ch : edge[cur]) {
            if (visited[ch]) continue;

            if (ch == mx_idx) {
                cout << cur + 1 << " " << ch + 1 << "\n";
            } else {
                cout << ch + 1 << " " << cur + 1 << "\n";
                sum[ch]++;
            }

            size[ch]--;
            q.push(P(size[ch], ch));
        }
    }

    return 0;
}

Measured memory_bytes: 8820
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
    int N;
    int A[210000];
    // int res[210000] = {0};
    unordered_map<int,int> m;
    int sameAll = 0;

    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        m[A[i]]++;
    }
    for(auto k:m)
	{
		sameAll+=(k.second*(k.second-1))/2;
	}

    for (int i = 0; i < N; i++)
    {
        cout << sameAll- m[A[i]] + 1 << endl;
    }






}


Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int main() 
{ 
    fastio
    int x, n;
    cin>>x>>n;
    vector<int> vec(n);
    for(auto& it : vec) cin>>it;
    sort(all(vec));

    int mn = 1e9, ans = 0;
    for(int i = -102; i<=102; ++i) {
        if(count(all(vec), i)) continue;
        if(abs(i-x)<mn) {
            mn = abs(i-x);
            ans = i;
        }
    }
    cout<<ans<<endl;
} 

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;


int main()
{
	for(int N; cin >> N && N; ) {
		vector<int> P(N), J(N, 0);

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

		for(int i = 0; i < N-1; i++) {
			cin >> J[i+1];
		}

		sort(J.begin()+1, J.end(), greater<int>());
		
		long long int best = 0;
		for(long long int i = 0, sum = accumulate(P.begin(), P.end(), 0); i < N; i++) {
			best = max(best, (sum += J[i]) * (N - i));
		}

		cout << best << endl;
	}
}

Measured memory_bytes: 1520
A,B,C=input().split()

a=int(A)
b=int(B)
c=int(C)

if a>=b:
  if a>=c:
    x=a
    if b>=c:
      y=b
      z=c
    else:
        y=c
        z=b
  else:
      x=c
      y=a
      z=b
else:
  if b>=c:
    x=b
    if a>=c:
      y=a
      z=c
    else:
        y=c
        z=a
  else:
      x=c
      y=b
      z=a

n=x*10+y+z
print(n)

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

#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 2 * 1e5 + 2;
int a[N], cnt[101], ans;


int main(){
    speed
    int a, b;
    cin >> a >> b;
    if (a == b)return cout << a + b, 0;
    int mx = max(a, b);
    cout << mx * 2 - 1 << endl;
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
N = int(input())
s = []

for i in range(N):
    s.append(str(input()))

M = int(input())
t = []

for j in range(M):
    t.append(str(input()))

set_s = set(s)
set_t = set(t)
ans = 0
tmp_ans = 0

for tmp_s in set_s:
    # 演算
    tmp_ans = s.count(tmp_s) - t.count(tmp_s)
    # 最大値判定
    ans = max(ans, tmp_ans)

print(ans)

Measured memory_bytes: 9000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

// https://sen-comp.hatenablog.com/entry/2019/11/17/003150, 解法1
// https://atcoder.jp/contests/abc145/submissions/8491663
int dp[2][3005][3005];
void solve() {
    int n, t;
    cin >> n >> t;
    
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    rep(i, n) rep(j, t) {
        chmax(dp[0][i + 1][j], dp[0][i][j]);
        if (j - a[i] < 0) continue;
        chmax(dp[0][i + 1][j - a[i]], dp[0][i][j] + b[i]);
    }
    for (int i = n - 1; i >= 0; --i) rep(j, t) {
        chmax(dp[1][i][j], dp[1][i + 1][j]);
        if (j - a[i] < 0) continue;
        chmax(dp[1][i][j - a[i]], dp[1][i + 1][j] + b[i]);
    }
    
    int ans = 0;
    rep(i, n) rep(j, t) chmax(ans, dp[0][i][j] + b[i] + dp[1][i + 1][t - 1 - j]);
    cout << ans << endl;
}



Measured memory_bytes: 74008
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[300][301];
int t[300][300];
int m=1;

void f(int a, int b, int c, int d, int k){
	if(k==1){
		for(int i=a; i<=b; i++){
			for(int j=c; j<=d; j++){
				t[i][j]=m;
			}
		}
		m++;
	}else{
		int x, y;
		for(int i=a; i<=b; i++){
			bool f=false;
			for(int j=c; j<=d; j++){
				if(s[i][j]=='#'){
					x=i; y=j; f=true;
					break;
				}
			}
			if(f) break;
		}
		int i=1;
		for(int j=y+1; j<=d; j++){
			if(s[x][j]=='#') i++;
		}
		if(i==k){
			f(a, b, c, y, 1);
			f(a, b, y+1, d, k-1);
		}else{
			f(a, x, c, d, i);
			f(x+1, b, c, d, k-i);
		}
	}
}

int main(void){
	int h=nextint();
	int w=nextint();
	int k=nextint();
	for(int i=0; i<h; i++){
		nextstr(s[i]);
	}
	f(0, h-1, 0, w-1, k);
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			printf("%d ", t[i][j]);
		}
		putchar(10);
	}
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int N, Y;

void solve(int &k, int &j, int &i, bool &f) {
    for (j = 0; j < N + 1; ++j) {
        for (k = 0; k < N + 1; ++k) {
            i = (Y - 10000 * k - 5000 * j) / 1000;
            if (i < 0) {
                break;
            }
            int y = 10000 * k + 5000 * j + 1000 * i;
            int n = k + j + i;
            // printf("k = %d, j = %d, i = %d, n = %d\n", k, j, i, n);
            if (y == Y && n == N) {
                f = true;
                return ;
            }
        }
    }
}

int main() {
    scanf("%d %d", &N, &Y);

    bool f = false;
    int i, j, k;
    solve(k, j, i, f);

    if (f) printf("%d %d %d\n", k, j, i);
    else printf("-1 -1 -1\n");

    return 0;
}


Measured memory_bytes: 384