akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [int(i) for i in input().split()]

temp = 0
for i in range(N):
    temp += A[i]
for i in range(int((N-1)/2)):
    temp -= 2 * A[2*i+1]

B = [0]*N
B[0] = temp
for k in range(1,N):
    B[k] = 2 * A[k-1] - B[k-1]
for j in range(N):
    print(str(B[j]) , end=" ")


Measured memory_bytes: 63984
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<utility>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
int main(){
string s;
  cin>>s;
  ll count1=0;
  ll count2=0;
  for(ll i=0;i<s.size();i++){
  if(i%2==0){
  if(s[i]=='0'){
  count1++;
  }
    else{
      count2++;
    }
  }
    else{
      if(s[i]=='1'){
  count1++;
  }
    else{
      count2++;
    }
    }
  
  }
  if(count1<count2)
    cout<<count1;
  else
    cout<<count2;
  return 0;
 
}
 

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

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

	if (str.at(2) == str.at(3) && str.at(4) == str.at(5)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	    public static void main(String[] args){
	        Scanner sc=new Scanner(System.in);
	        int i=0,j=0;
	        while(true){
	            int H=sc.nextInt();
	            int W=sc.nextInt();
	            if(H==0&&W==0)break;
	            else for(i=0;i<H;i++){
	                for(j=0;j<W;j++){
	                	if(i%2==1&&j%2==1){
	                    System.out.print("#");
	                	}
	                	else if(i%2==1&&j%2==0)System.out.print(".");
	                	else if(i%2==0&&j%2==1)System.out.print(".");
	                	else System.out.print("#");
	                }
	                System.out.print("\n");
	        }
	            System.out.print("\n");
	    }
	}
	
}



Measured memory_bytes: 35452
N=int(input())
A=list(map(int,input().split()))
add=0
even=0
four=0
for i in range(N):
    if A[i]%4==0:
        four+=1
    elif A[i]%2==0:
        even+=1
    else:
        add+=1
if even%2==1:
    add+=1

if four>=add-1:
    print('Yes')
else:
    print('No')

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

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

	public static void main(String[] args) {
		int N = sc.nextInt();
		char[] val = sc.next().toCharArray();
		BDD bdd = new BDD(N, val);
		while (true) {
			if (!bdd.reduce()) break;
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			ans += bdd.nodes.get(i).size();
		}
		System.out.println(ans);
	}

	static class BDD {
		ArrayList<ArrayList<Node>> nodes = new ArrayList<ArrayList<Node>>();
		Node term0 = new Node();
		Node term1 = new Node();

		BDD(int N, char[] v) {
			for (int i = 0; i < N; ++i) {
				nodes.add(new ArrayList<Node>());
			}
			for (int i = N - 1; i >= 0; --i) {
				for (int j = 0; j < (1 << i); ++j) {
					Node n = new Node();
					if (i == N - 1) {
						n.zero = v[j << 1] == '0' ? term0 : term1;
						n.one = v[(j << 1) + 1] == '0' ? term0 : term1;
					} else {
						n.zero = nodes.get(i + 1).get(j * 2);
						n.one = nodes.get(i + 1).get(j * 2 + 1);
					}
					nodes.get(i).add(n);
				}
			}
		}

		boolean reduce() {
			boolean update = false;
			for (int idx = 0; idx < nodes.size(); ++idx) {
				ArrayList<Node> line = nodes.get(idx);
				ArrayList<Node> replace = new ArrayList<Node>();
				for (int i = 0; i < line.size(); ++i) {
					boolean skip = false;
					Node n = line.get(i);
					if (n.zero.to != null) {
						n.zero = n.zero.to;
						update = true;
					}
					if (n.one.to != null) {
						n.one = n.one.to;
						update = true;
					}
					if (n.zero == n.one) {
						n.to = n.zero;
						update = true;
						skip = true;
						continue;
					}
					for (int j = 0; j < i; ++j) {
						if (line.get(j).zero == n.zero && line.get(j).one == n.one) {
							n.to = line.get(j);
							update = true;
							skip = true;
							break;
						}
					}
					if (!skip) replace.add(n);
				}
				nodes.set(idx, replace);
			}
			return update;
		}
	}

	static class Node {
		Node zero, one, to;
	}

}

Measured memory_bytes: 20652
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)










int main(){
    ll n;
    string s;
    cin >> n >> s;
    vector<vector<bool>> a1(n, vector<bool>(10));
    vector<vector<bool>> a2(n, vector<bool>(10));
    a1[0][s[0] - '0'] = true;
    for(ll i = 1; i < n; i++){
        REP(j, 10){
            a1[i][j] = a1[i - 1][j];
        }
        a1[i][s[i] - '0'] = true;
    }
    a2[n - 1][s[n - 1] - '0'] = true;
    for(ll i = n - 2; i >= 0; i--){
        REP(j, 10){
            a2[i][j] = a2[i + 1][j];
        }
        a2[i][s[i] - '0'] = true;
    }
    set<string> st;
    for(ll i = 1; i < n - 1; i++){
        REP(j, 10){
            if(!a1[i - 1][j]) continue;
            REP(k, 10){
                if(!a2[i + 1][k]) continue;
                string t;
                t += '0' + j;
                t += s[i];
                t += '0' + k;
                st.insert(t);
            }
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

int A[100006];
int N;

int f(double n){
	int ret=0;
	bool a = (n<A[0]);
	for(int i=0;i<N-1;i++){
		if((A[i]-n)*(A[i+1]-n)<0){
			if(a){
				ret++;
				a=false;
			}
			else a=true;
		}
	}
	if(a)ret++;
	//cout<<n<<" "<<ret<<endl;
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	vector<pair<int,int> >A;
	for(int i=1;i<=N;i++){
		int a;
		cin>>a;
		A.push_back(make_pair(a,i));
	}
	
	sort(A.begin(),A.end());
	
	for(int i=0;i<N;i++){
		if(i!=N-1)cout<<A[i].second<<" ";
		else cout<<A[i].second<<endl;
	}
}
	


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;



int main(){
	string s; cin>>s;
    ll n = s.size();
    ll N = 0,E = 0,W = 0,S = 0;
	REP(i,n){
      if(s[i] =='N')N++;
      if(s[i] =='E')E++;
      if(s[i] =='W')W++;
      if(s[i] =='S')S++;
    }
    bool flg = true;
  	if(N==0 && S!=0) flg = false;
    if(S==0 && N!=0) flg = false;
    if(E==0 && W!=0) flg = false;
    if(W==0 && E!=0) flg = false;
  
    if(flg) cout << "Yes";
    else cout << "No";

  	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] N = new int[NM[0]];
        for (int i = 0; i < NM[1]; i++)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N[a[0] - 1]++;
            N[a[1] - 1]++;
        }
        for (int i = 0; i < NM[0]; i++)
        {
            Console.WriteLine(N[i]);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++) cin >> vec[i];
  sort(vec.begin(),vec.end());
  cout << vec[N-1] - vec[0] << endl;
}


Measured memory_bytes: 256
#main
line = gets
a = line.split(" ")
h = Hash.new
h.default = 0
a.each do |i|
  h[i] += 1
end
g = h.to_a.sort{|a, b| b[1] <=> a[1]}
f = g.sort{|a, b| b[0].length <=> a[0].length}
puts "#{g[0][0]} #{f[0][0]}"

Measured memory_bytes: 6104
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <cstdio>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int ar[4];
	for (int i = 0; i<4; ++i) {
		ar[i] = 0;
	}
	int a, b;
	cin >> a >> b;
	ar[--a]++;
	ar[--b]++;
	int c, d;
	cin >> c >> d;
	ar[--c]++;
	ar[--d]++;
	int e, f;
	cin >> e >> f;
	ar[--e]++;
	ar[--f]++;
	if (ar[e] == 3 || ar[f] == 3) {
		cout << "NO\n";
	}
	else {
		cout << "YES\n";
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;


class Graph2{
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph2() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		for(int i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(int j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int v;
		for(int i = 0; i < totalVertex; i ++) {
			for(int j = 0; j < totalVertex; j ++) {
				v = in.nextInt();
				if (v > -1) {adjMatrix[i][j] = 1;
				adjWeight[i][j] = v;
				}
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int mst(int s) {
		int[] dist = new int[totalVertex];
		//boolean[] visited = new boolean[totalVertex];
		dist[0] = 0;
		for (int i = 1; i< dist.length; i++) {
			dist[i] = Integer.MAX_VALUE;
		}
		/*visited[0] = true;
		for (int i = 1; i< visited.length; i++) {
			visited[i] = false;
		}*/
		for(int i = 0 ; i < totalVertex; i++) {
			int node = getUnsettledNearest(dist);
			ifSettled[node] = true;
			LinkedList<Integer> nb = getUnsettledNeighbors(node);
			for(Integer n : nb) {
				dist[n] = Math.min(dist[n],getWeight(node,n));
			}
		}
		int result = 0;
		for (int i = 0; i < dist.length; i++) {
			result += dist[i];
		}
		return result;
	}
}

public class Main{
	public static void main(String[] argv) {
		Graph2 g = new Graph2();
		g.loadAdjMatrix();
		System.out.println(g.mst(0));
		}
	}


Measured memory_bytes: 41028
N, W = map(int, input().split())

max_total = 0
p = []
for it in range(N):
    p.append(list(map(int,input().split())))
    max_total += p[-1][1]
    
    
MAX_WEIGHT = 1000000009
dp = [[MAX_WEIGHT for i in range(max_total+1)] for j in range(N+1)]
dp[0][0]=0
i = 0
for w, v in p:
    i += 1
    for target_val in range(0, max_total+1):
        
        if target_val-v >=0 and dp[i-1][target_val] > (dp[i-1][target_val-v]+w):
            dp[i][target_val] = dp[i-1][target_val-v]+w
        else:
            dp[i][target_val] = dp[i-1][target_val]
            
ret = 0
for v, w in enumerate(dp[N]):
    if w<=W and v>ret:
        ret = v
print(ret)

Measured memory_bytes: 171248
#include <iostream>

using namespace std;
int main()
{
	int n;
	cin >> n;
	int ans;
	if (n >= 400 || n <= 1999)
	{
		if (n >= 400 && n <= 599)
		{
			ans = 8;
		}
		else if (n >= 600 && n <= 799)
		{
			ans = 7;
		}
		else if (n >= 800 && n <= 999)
		{
			ans = 6;
		}
		else if (n >= 1000 && n <= 1199)
		{
			ans = 5;
		}
		else if (n >= 1200 && n <= 1399)
		{
			ans = 4;
		}
		else if (n >= 1400 && n <= 1599)
		{
			ans = 3;
		}
		else if (n >= 1600 && n <= 1799)
		{
			ans = 2;
		}
		else if (n >= 1800 && n <= 1999)
		{
			ans = 1;
		}
	}
	else ans = 0;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')


def solve():
    n, k = MI()
    B = [i for i in range(n+1)]
    # print(B)
    mod = 1000_000_007
    def f(l, r):
        return (r + l) * (r - l + 1) // 2

    ans = 0
    for i in range(k, n+2):
        # print(B[0], B[i-1], B[n-i+1], B[-1])
        _min = f(B[0], B[i-1])
        _max = f(B[n-i+1], B[-1])
        # print('  ', _min, _max, _max - _min + 1)
        ans = (ans + _max - _min + 1) % mod
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16976
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter, mul
from functools import reduce

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
C = list(map(int,readline().split()))

sgn = [0] * N
for i,(a,b,c) in enumerate(zip(A,B,C)):
    if a == b-1 and c == b+1:
        sgn[i] = 1
    elif a == b+1 and c == b-1:
        sgn[i] = -1
    else:
        print('No')
        exit()

if any(x%6 != 2 for x in B[::2]) or any(x%6 != 5 for x in B[1::2]):
    print('No')
    exit()

class BinaryIndexedTree():
    def __init__(self, seq):
        self.size = len(seq)
        self.depth = self.size.bit_length()
        self.build(seq)
        
    def build(self,seq):
        data = seq
        size = self.size
        for i,x in enumerate(data):
            j = i+(i&(-i))
            if j < size:
                data[j] += data[i]
        self.data = data
        
    def __repr__(self):
        return self.data.__repr__()
        
    def get_sum(self,i):
        data = self.data
        s = 0
        while i:
            s += data[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        data = self.data
        size = self.size
        while i < size:
            data[i] += x
            i += i & -i
    
    def find_kth_element(self,k):
        data = self.data; size = self.size
        x,sx = 0,0
        dx = 1 << (self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= size:
                continue
            y = x + dx
            sy = sx + data[y]
            if sy < k:
                x,sx = y,sy
        return x + 1

def Inversion(seq):
    # seqは、1,2,...,Nの順列
    N = len(seq)
    bit = BinaryIndexedTree([0] * (N+1))
    inv = N*(N-1)//2
    for x in seq:
        inv -= bit.get_sum(x)
        bit.add(x,1)
    return inv

OD = sorted(enumerate(B[::2],1), key=itemgetter(1))
ind, val = zip(*OD)
od_inv = Inversion(ind)

EV = sorted(enumerate(B[1::2],1), key=itemgetter(1))
ind, val = zip(*EV)
ev_inv = Inversion(ind)

od_sgn = reduce(mul, sgn[::2])
ev_sgn = reduce(mul, sgn[1::2])

condition = (od_sgn == (-1)**ev_inv) and (ev_sgn == (-1)**od_inv)

answer = 'Yes' if condition else 'No'
print(answer)

Measured memory_bytes: 32620
#include <iostream>
using namespace std;
int main()
{
	int k,s;
	cin>>k>>s;
	int ans=0;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			int ij=s-i-j;
			if(ij<=k && ij >=0)ans++;
			
			
		}
	}
	cout<<ans<<endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
      cin >> A.at(i);
    }
 
    map<int, int> cnt;//counterの略
    for (int x : A) {
      if (cnt.count(x)) {
        cout << "NO" << endl;
        return 0;
      } else {
        cnt[x] = 1;
      }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main()
{
	double x1, x2, x3, xp;
	double y1, y2, y3, yp;

	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
		double S = fabs((x2 - x1)*(y3 - y1) - (y2 - y1)*(x3 - x1)) / 2.0;
		
		x1 -= xp; y1 -= yp;
		x2 -= xp; y2 -= yp;
		x3 -= xp; y3 -= yp;
		
		double s1 = fabs(x1*y2 - y1*x2) / 2.0;
		double s2 = fabs(x2*y3 - y2*x3) / 2.0;
		double s3 = fabs(x3*y1 - y3*x1) / 2.0;

		if (fabs(S - s1 - s2 - s3) < 0.00000000001)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll dist(pll a, pll b) {
    return abs(a.first - b.first) + abs(a.second - b.second);
}

ll optimize(const pll &init, const vector<pll> &v) {
    pll p = init;
    pll q = init;
    ll max_d = 0;
    bool updated = true;
    while (updated) {
        updated =false;
        for (const auto &c: v) {
            ll d_ = dist(p, c);
            if (d_ > max_d) {
                q = c;
                max_d = d_;
                updated = true;
            }
        }
        if (updated) p = q;
    }
    return max_d;
}

int main() {
    ll N; cin >> N;
    vector<pll> v(N);
    for (int i = 0; i < N; ++i) {
        ll x, y; cin >> x >> y;
        v[i] = {x, y};
    }
    ll ans = 0;
    std::mt19937 mt{ std::random_device{}() };
    std::uniform_int_distribution<int> d(0, N - 1);
    for (int i = 0; i < 2000; ++i) {
        int r = d(mt);
        ans = max(ans, optimize(v[r], v));
    }
    ans = max(ans, optimize(v[0], v));
    ans = max(ans, optimize(v[N-1], v));
    for (int i = 0; i < N - 1; ++i) {
        ans = max(ans, dist(v[i], v[i + 1]));
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    int n;
    cin >> n;
    string _357 = "357";
    if (n < 357) {
        cout << 0 << endl;
    } else {
        vector<int> nums = {357, 375, 537, 573, 735, 753};
        nums.reserve(30000);
//        vector<int> tmp = {357, 375, 537, 573, 735, 753};
        vector<set<string>> tmp(10);
        tmp[3] = {"357", "375", "537", "573", "735", "753"};
        for (int i = 4; i < 10; ++i) {
            for (auto& x : tmp[i - 1]) {
//                cout << x << endl;
                for (char c : string("357")) {
                    for (int j = 0; j < x.length(); ++j) {
                        string t = x;
//                        cout << c << endl;
                        t.insert(j, 1, c);
//                        cout << t << endl;
                        tmp[i].insert(t);
                    }
//                    tmp[i].insert(x + to_string(c));
                }
            }
        }
        for (int i = 4; i < 10; ++i) {
            for (auto& s : tmp[i]) {
//                cout << s << endl;
                nums.push_back(stoi(s));
            }
        }
        sort(nums.begin(), nums.end());
        auto it = upper_bound(nums.begin(), nums.end(), n);
        cout << distance(nums.begin(), it) << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


Measured memory_bytes: 2816
#include<stdio.h>
#include<math.h>

int sosu(int);

int main(){
  int a,b,i,sum=0,c;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b);
    c=sosu(b);
    sum=sum+c;
  }
  printf("%d\n",sum);
  return 0;
}
int sosu(int n){
  int i;
  if(n==2)return 1;
  if(n%2==0 || n<2)return 0;
  for(i=3;i<=sqrt(n);i=i+2){
    if(n%i==0)return 0;
    
  }
  return 1;
}



Measured memory_bytes: 2072
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    cin >> N;
    vl a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }

    int count = 0;
    rep(i, 0, N) {
        if (a[i] != i+1) ++count;
    }
    if (count == 0 || count == 2) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

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

int main() {
	string ans;
	int x,a,b;
	cin >> x>>a>>b;
	if (a >= b) {
		ans = "delicious";
	}
	else if (b - a < x+1) {
		ans = "safe";
	}
	else {
		ans = "dangerous";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

ll X;

int main() {
    cin >> X;
    int step = 0;
    ll cur = 100;
    while(cur < X) {
        cur += cur/100;
        step++;
    }
    cout << step << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s;
	ll k;

	cin>>s;
	cin>>k;

	if(k==1){
		cout<<s[0]<<endl;
		return 0;
	}
	if(s[0]=='1'){
		ll o=0;
		rep(i,k){
			if(s[i]!='1'){
				cout<<s[i]<<endl;
				return 0;
			}else{
				o++;
			}
			if(o==k){
				cout<<"1"<<endl;
			}
		}

	}else{
		cout<<s[0]<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int H,A,B;

	scanf("%d %d %d",&H,&A,&B);

	int ans = 0;

	for(int i = A; i <= B; i++){

		if(H%i == 0)ans++;
	}

	printf("%d\n",ans);

	return 0;
}



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

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

  int w, h, x, y; cin >> w >> h >> x >> y;
  int ans = 0;
  if(w==x+x && h==y+y) ans = 1;
  cout << fixed << setprecision(6);
  cout << (double)h*w/2 << " " << ans << '\n';
  return 0;
}


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

int h, a, ans;

int main(){
  cin >> h >> a;
  
  ans =h/a;
  if (h%a == 0) cout << ans << endl;
  else cout << ans + 1 << endl;
  

  }

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e5 + 9;
int l[N], r[N];
multiset<pii> il,jl;
int n;

ll solve(int pr){
    for(int i = 0 ; i < n; i ++ ){
        il.insert(mp(l[i],r[i]));
        jl.insert(mp(r[i],l[i]));
    }
    ll answ = 0;
    int L, R;
    int pos=0;
    for(int i = 0 ; i < n; i ++ ){
        if(i % 2 == pr){
            auto it = il.end();
            -- it;
            L = it->fi;
            R = it->se;
            if(pos >= L && pos <= R){
                continue;
            }
            else{
                if(pos < L){
                    answ += L - pos;
                    pos = L;
                }
                else{
                    answ += pos - R;
                    pos = R;
                }
            }
            il.erase(il.find(mp(L,R)));
            jl.erase(jl.find(mp(R,L)));
        }
        else{
            auto it = jl.begin();
            L = it->se;
            R = it->fi;
            if(pos >= L && pos <= R){
                continue;
            }
            else{
                if(pos < L){
                    answ += L - pos;
                    pos = L;
                }
                else{
                    answ += pos - R;
                    pos = R;
                }
            }
            il.erase(il.find(mp(L,R)));
            jl.erase(jl.find(mp(R,L)));
        }
    }
    return answ+max(pos,-pos);
}

int main(){
    fastIO;
    cin >> n;
    for(int i = 0 ; i < n;  i ++ ){
        cin >> l[i] >> r[i]; 
    }
    cout << max(solve(0),solve(1));
    return 0;
}


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

int N;
string S;

void solve_tle()
{
    for (int len = N / 2; len >= 1; len--) {
        for (int i = 0; i <= N - len; i++) {
            for (int l = 0; l < i - len; l++) {
                if (S.compare(l, len, S, i, len) == 0) {
                    cout << len << endl;
                    return;
                }
            }
            for (int r = i + len; r <= N - len; r++) {
                if (S.compare(r, len, S, i, len) == 0) {
                    cout << len << endl;
                    return;
                }
            }
        }
    }
    cout << 0 << endl;
}

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

void solve()
{
    int ans = 0;
    vector<vector<int>> dp(N+1, vector<int>(N+1));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (S[i] == S[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
                chmax(ans, min(dp[i+1][j+1], abs(i-j)));
            } else {
                dp[i+1][j+1] = 0;
            }
        }
    }
    cout << ans << endl;
}

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

    cin >> N >> S;

    solve();
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
const int mod=1000000007;
const int inf=1000000009;
const long long int INF=1000000000000000009;
using namespace std;
int T[200005];
ll S[200005],D[200005];
int main()
{
    int n,x;
    scanf("%d %d",&n,&x);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&T[i]);
        S[i]=S[i-1]+T[i];
    }
    ll wynik=INF;
    D[1]=5;
    D[2]=5;
    for(int i=3; i<=n; i++)
        D[i]=D[i-1]+2;
    for(int i=1; i<=n; i++)
    {
        ll aktual=(ll)x*n;
        aktual+=(ll)i*x;
        int ile=n;
        int wsk=1;
        while(ile>0)
        {
            if(aktual>wynik)
                break;
            if(S[ile]-S[max(0,ile-i)]>INF/(ll)D[wsk])
                break;
            aktual+=(ll)D[wsk]*(S[ile]-S[max(0,ile-i)]);
            wsk++;
            ile-=i;
        }
        wynik=min(wynik,aktual);
    }
    printf("%lld",wynik);
    return 0;
}


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

int main(void) {
    i64 r, d, x;
    cin >> r >> d >> x;
    for (i64 i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;
constexpr int mod = 1e9+7;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j] && j - dp[i][j] > i) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
    }
  }

  int res = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) res = max(res, dp[i][j]);
  }
  cout << res << endl;
  return 0;
} 


Measured memory_bytes: 101196
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    char c;
    int a,b;
    while(scanf("%d %c %d",&a,&c,&b)){
        if(c=='?')break;
        if(c=='+')out(a+b);
        if(c=='-')out(a-b);
        if(c=='*')out(a*b);
        if(c=='/')out(a/b);
    }
}



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

bool good_linear_search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) {
        i++;
    }
    return i != n;
}

bool linear_search2(int A[], int n, int key) {
    for (int i = 0; i < n; ++i) {
        if(A[i] == key) {
            return true;
        }
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int q;
    int count = 0;
    cin >> q;
    int t;
    for (int j = 0; j < q; ++j) {
        cin >> t;
        if(good_linear_search(S, n, t)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3476
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    long t1, t2; cin >> t1 >> t2;
    long a1, a2; cin >> a1 >> a2;
    long b1, b2; cin >> b1 >> b2;

    if (a1 > b1) {
        swap(a1, b1);
        swap(a2, b2);
    }

    long a = a1 * t1 + a2 * t2;
    long b = b1 * t1 + b2 * t2;

    if (a < b) {
        cout << 0 << endl;
    }
    if (a == b) {
        cout << "infinity" << endl;
    }
    if (a > b) {
        long n = (b1 * t1 - a1 * t1) / (a - b);
        long diff = (a - b) * n;
        if (b1 * t1 - a1 * t1 == diff) {
            cout << 2 * n << endl;
        } else {
            cout << 2 * n + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか
int main() {
	int n, ks;
	cin >> n >> ks;
	vector<long long int> s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	long long int ans = 0;

	for (int i = 0; i <= ks; i++) {
		if (i < s.size()){

			for (int k = 0; k <= i; k++) {
				priority_queue<long long int, vector<long long int>, greater<long long int>> q;
				long long int sum = 0;
				for (int l = 1; l <= i-k; l++) {
					q.push(s[l-1]);
					sum = sum + s[l-1];
				}
				reverse(s.begin(), s.end());
				for (int m = 1; m <= k; m++) {
					q.push(s[m-1]);
					sum = sum + s[m-1];
				}
				reverse(s.begin(), s.end());
				for (int n = i + 1; n <= ks; n++) {
					if (q.size()) {
						if (q.top() <= 0) {
							sum = sum - q.top();
							q.pop();
						}
					}
				}
				ans = max(sum, ans);
			}

		}
		else {
			priority_queue<long long int, vector<long long int>, greater<long long int>> q;
			long long int sum = 0;
			for (int k = 0; k < s.size(); k++) {
				q.push(s[k]);
				sum = sum + s[k];
			}
			for (int l = s.size() + 1; l <= ks; l++) {
				if (q.top() <= 0) {
					sum = sum - q.top();
					q.pop();
				}
			}
			ans = max(sum, ans);
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,m;cin>>n>>m;
	vector<int> k(m);
	vector<vector<int>>s(m,vector<int>(n,0));
	for(int i = 0; i < m; i++) {
		cin>>k[i];
		for(int j = 0; j < k[i]; j++) {
			int x;cin>>x;
			s[i][x - 1] = 1;
		}
	}
	vector<int> p(m);
	for(int i = 0; i < m; i++) {
		cin>>p[i];
	}
	int ans = 0;
	for(int i = 0; i < (1 << n); i++) {
		bool flag = true;
		for(int j = 0; j < m; j++) {
			int tmp = 0;//ONになっているスイッチの数
			for(int l = 0; l < n; l++) {
				if (((i >> l) & 1) && s[j][l] == 1){
					tmp++;
				}
			}
			if (tmp % 2 != p[j]){
				flag = false;
				break;
			}
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    # black
    . white
    """
    
    black = "#"
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < H - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < W - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    #print(i, j)
                    #print(above, under, left, right)
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}


template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

int main(){
   string s;
   int n;
   cin>>n;
   cin>>s;
   int cnt=0;
   rep(i,s.size()){
       if(s[i]=='R'){
           cnt++;
       }
   }
   if((s.size()-cnt)<cnt){
       op("Yes");
   }else op("No");
    return 0;
}

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

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    int i;
    for(i = 0; i < n; i++) {
        cin >> t[i];
    }

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

    int ans = 0;
    for(i = 0; i < n;) {
        int start = i;
        while(i < n && t[i] - t[start] <= k && i - start < c) {
            i++;
        }
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;

/* main関数 */
int main(void) {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (d2 == 1) cout << 1;
	else cout << 0;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
	int n,x,c=0;
	cin>>n>>x;
	int m=1e9;
	r(i,n){
		int a;
		cin>>a;
		m=min(a,m);
		x-=a;
		c++;
	}
	while(m<=x){
		x-=m;
		c++;
	}
	cout<< c <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    float x;
    scanf("%f", &x);
    if (x >= 400 & x <= 1999) {
    if (x >= 400 & x <= 599)
        printf("8");
    if (x >= 600 & x <= 799)
        printf("7");;
    if (x >= 800 & x <= 999)
        printf("6");
    if (x >= 1000 & x <= 1199)
        printf("5");
    if (x >= 1200 & x <= 1399)
        printf("4");
    if (x >= 1400 & x <= 1599)
        printf("3");
    if (x >= 1600 & x <= 1799)
        printf("2");
    if (x >= 1800 & x <= 1999)
        printf("1");
    }
    else
    {
    printf("input error");
    }
    return 0;
}


Measured memory_bytes: 1724
from functools import *
import sys
sys.setrecursionlimit(100000)



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


def II():
    return int(input())
mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def cmb2(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return int(result)

    return count


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
    
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
    
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modpow(a, n, mod):
    res = 1
    while n > 0:
        #print(n)

        if n & 1:
            res = res*a % mod
        a = a*a % mod
            #n >>= 1
        n>>=1

    return res


n,a,b=acinput()




#print(combination(n,a))
c=combination(n,min(n,n-a))+combination(n,min(b,n-b))



print((modpow(2,n,mod)-c-1)%mod)


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

const int N = 10001;
int n, m;
int a[N] = {};

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d", &a[i]);
	int ans = 0;
	for (int i=1;i<=n;i++) {
		for (int j=i+1;j<=n;j++)
			ans += a[i] * a[j];
	}
	printf("%d",ans);
	return 0;
} 

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


LL N, M;
LL a[123456];
bool flag[123456];
vector<int>graph[123456];
void dfs(int v, vector<LL>&que) {
	if (flag[v])return;
	que.push_back(a[v]);
	flag[v] = true;
	for (int next : graph[v]) {
		dfs(next, que);
	}
}

vector<vector<LL>>vec;

int main(void)
{
	cin >> N >> M;
	LL need = N - 1 - M;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	for (int j = 0; j < M; ++j) {
		int x, y;
		cin >> x >> y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	for (int i = 0; i < N; ++i) {
		if (!flag[i]) {
			vec.push_back(vector<LL>());
			dfs(i, vec.back());
			sort(vec.back().rbegin(), vec.back().rend());
		}
	}
	need *= 2;
	LL ans = 0;
	if (need - (int)vec.size() < 0) {
		vector<LL>srt;
		for (int i = 0; i < vec.size(); ++i) {
			srt.push_back(vec[i].back());
		}
		sort(srt.begin(), srt.end());
		for (int i = 0; i < need; ++i) {
			ans += srt[i];
		}
		cout << ans << endl;
		return 0;
	}
	for (int i = 0; i < vec.size(); ++i) {
		ans += vec[i].back();
		vec[i].pop_back();
	}
	vector<LL>save;
	for (int i = 0; i < vec.size(); ++i) {
		for (LL elm : vec[i]) {
			save.push_back(elm);
		}
	}

	sort(save.begin(), save.end());
	for (int i = 0; i < need - (int)vec.size(); ++i) {
		if (save.size() <= i) {
			cout << "Impossible" << endl;
			return 0;
		}
		ans += save[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12084
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define fastIO_ ios_base::sync_with_stdio(false); cin.tie(false); cout.tie(false);
int main()
{
    ll n, k, s=0;
    cin>>n>>k;
    vector<ll> ar(n+1);
    for (ll i=1, d; i<=n; i++)
        cin>>ar[i];
    sort(ar.begin(), ar.end());
    for (ll i=1; i<=n-k; i++)
        s += ar[i];
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll fact[1001];
ll inv_fact[1001];
ll comb(ll n, ll k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
ll dp[1001][1001]; //i人の人をj人以下のグループにわける方法が何通りか
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= N; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
	for (int i = 0; i <= N; i++) dp[0][i] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = A; j <= B; j++) {
			(dp[i][j] += dp[i][j - 1]) %= MOD;
			if (j*C > i) continue;
			ll mul = 1;
			int rest = i;
			for (int k = 1; k < C; k++) {
				(mul *= comb(rest, rest - j)) %= MOD;
				rest -= j;
			}
			for (int k = C; k <= min(i/j,D);k++) {
				(mul *= comb(rest, rest - j)) %= MOD;
				rest -= j;
				ll t = (mul*inv_fact[k]) % MOD;
				(dp[i][j] += (dp[i - j * k][j - 1] * t) % MOD) %= MOD;
			}
		}
	}
	cout << dp[N][B] << endl;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

bool prime[1000000];

int main(void)
{
	for(int i=0;i<1000000;i++)prime[i] = true;
	prime[0] = prime[1] = false;
	for (int i = 4; i < 1000000; i+=2) prime[i] = false;
	for (int i = 3; i < 1000000; i+=2){
		for (int j = i+i; j < 1000000; j+=i) prime[j] = false;
	}
	//for (int i = 0; i < 100; i++) if (prime[i]) cout << i << endl;
	int a, d, n;
	while (cin >> a >> d >> n, a && d, d && n){
		int cnt = 0;
		int tmp = a;
		if (prime[tmp]) cnt++;
		if (cnt == n) goto A;
		while (1){
			tmp += d;
			if (prime[tmp]) cnt++;
			if (cnt == n) break;
		}
		A:;
		cout << tmp << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0