akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 110;
int N, M, L, K, A, H;
struct edge
{
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {}
};
vector<int> facility(MAX_N);
vector<edge> G[MAX_N];
int bfs()
{
    vector<vector<int>> used(MAX_N, vector<int>(MAX_N, INF));
    queue<P> que;
    que.push(P(A, M));
    used[A][M] = 0;
    while(que.size())
    {
        P p = que.front(); que.pop();
        int v = p.first;
        int t = p.second;
        for(int u = 0; u < G[v].size(); u++)
        {
            edge e = G[v][u];
            if(facility[v])
            {
                for(int nt = t; nt <= M; nt++)
                {
                    if(nt - e.cost < 0) continue;
                    if(used[v][t] + e.cost + nt - t < used[e.to][nt - e.cost])
                    {
                        used[e.to][nt - e.cost] = used[v][t] + e.cost + nt - t;
                        que.push(P(e.to, nt - e.cost));
                    }
                }
            }
            else
            {
                if(t - e.cost < 0) continue;
                if(used[v][t] + e.cost < used[e.to][t - e.cost])
                {
                    used[e.to][t - e.cost] = used[v][t] + e.cost;
                    que.push(P(e.to, t - e.cost));
                }
            }
        }
    }
    int res = INF;
    for(int i = 0; i <= M; i++) res = min(res, used[H][i]);
    return res;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> M >> L >> K >> A >> H, N or M or L or K)
    {
        facility.assign(N, 0);
        for(int i = 0; i < MAX_N; i++) G[i].clear();
        for(int i = 0; i < L; i++)
        {
            int x; cin >> x;
            facility[x] = true;
        }
        facility[A] = facility[H] = 1;
        for(int i = 0; i < K; i++)
        {
            int x, y, t; cin >> x >> y >> t;
            G[x].push_back(edge(y, t));
            G[y].push_back(edge(x, t));
        }
        int ans = bfs();
        if(ans == INF) cout << "Help!" << endl;
        else cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int a,b,c,k; cin>>a>>b>>c>>k;
	if(a>=k) cout << k << endl;
	else if(a+b>=k) cout << a << endl;
	else cout << a-(k-(a+b)) << endl;
	
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(ll i=(n);i<(x);++i)
#define RSORT(x) sort(x.rbegin(),x.rend())
using ll = long long;

int main() {
	ll n, m; cin >> n >> m;
	priority_queue<int> pq;
	rep(i, 0, n) {
		int a; cin >> a;
		pq.push(a);
	}
	vector<pair<int, int>> vp(m);
	rep(i, 0, m) cin >> vp[i].second >> vp[i].first;

	RSORT(vp);
	int idx = 0, i = 0;
	while(i < n && idx < m) {
		while (vp[idx].second && i < n) {
			pq.push(vp[idx].first);
			vp[idx].second--; i++;
		}
		idx++;
	}
	ll sum = 0;
	rep(i, 0, n) {
		sum += pq.top();
		pq.pop();
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 2168
def merge(arr, l, mid, r):
    L = [arr[i] for i in range(l, mid)]
    R = [arr[i] for i in range(mid, r)]
    L.append(int(1e9 + 10))
    R.append(int(1e9 + 10))
    i, j = 0, 0
    cnt = 0
    for k in range(l, r):
        if L[i] <= R[j]:
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1
            cnt += len(L) - i -1
    return cnt

def mergeSort(arr, l, r):
    cnt = 0
    if l + 1 < r:
        mid = (l + r) >> 1
        cnt += mergeSort(arr, l, mid)
        cnt += mergeSort(arr, mid, r)
        cnt += merge(arr, l, mid, r)
    return cnt

input()
arr = list(map(int, input().split()))
print(mergeSort(arr, 0, len(arr)))


Measured memory_bytes: 27712
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b,c ;
	cin >> a >> b >> c ;
	YorN(c-b==b-a) ;
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Read();
            var A = int.Parse(input[0].ToString());
            var B = int.Parse(input[1].ToString());
            var C = int.Parse(input[2].ToString());
            var D = int.Parse(input[3].ToString());
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        var ans = A;
                        var b = i == 0 ? "+" : "-";
                        if (b == "+") ans += B;
                        else ans -= B;
                        var c = j == 0 ? "+" : "-";
                        if (c == "+") ans += C;
                        else ans -= C;
                        var d = k == 0 ? "+" : "-";
                        if (d == "+") ans += D;
                        else ans -= D;
                        if (ans == 7)
                        {
                            Console.WriteLine(A + b + B + c + C + d + D + "=7");
                            return;
                        }
                    }
                }

            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long a[n],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i!=0&&a[i-1]>a[i]){
            sum+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5148
#include<stdio.h>
#define MAX 2000000

int n, A[MAX+1];

void swap(int *a, int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
void maxHeapify(int i){
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n &&A[r] > A[largest]) largest = r;

  if(largest != i){
    swap(&A[i], &A[largest]);
    maxHeapify(largest);
  }
}

int main(){
  int i;
  
  scanf("%d",&n);

  for(i = 1; i <= n; i++) scanf("%d",&A[i]);

  for(i = n / 2; i >= 1; i--) maxHeapify(i);

  for(i = 1; i <= n; i++) printf(" %d",A[i]);
  printf("\n");

  return 0;
}

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

class Main
{
    public static void main (String args[]) throws IOException         //?????????
    {
        InputStreamReader is = new InputStreamReader(System.in);       //?????????
        BufferedReader br = new BufferedReader(is);                    //?????????
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if((a < b) && (b < c)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}
    

Measured memory_bytes: 26236
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var V = 10;
		var I = G();
		int Y = I[0], X = I[1];
		var d = new int[V, V];
		for (var i = 0; i < V; i++)
		{
			I = G();
			for (var j = 0; j < V; j++) d[i, j] = I[j];
		}
		for (var i = 0; i < V; i++) for (var j = 0; j < V; j++) for (var k = 0; k < V; k++) d[j, k] = Min(d[j, k], d[j, i] + d[i, k]);
		var s = 0L;
		for (var y = 0; y < Y; y++)
		{
			I = G();
			for (var x = 0; x < X; x++) if (I[x] >= 0) s += d[I[x], 1];
		}
		WriteLine(s);
	}
}


Measured memory_bytes: 15444
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
    int a, b;
    int d, r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    
    
}



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

vector<long> tp(55);

long f(int n, long x) {
  if ( n==0 && x==0 )
    return 1;

  int sum = 0;
  int res = 0;
  if ( x == 0 )
    return 0;
  if ( x < tp[n+1]-2 )
    return f(n-1, x-1);
  if ( x == tp[n+1]-2 )
    return (tp[n]-1)+1;
  if ( x < tp[n+2]-4 )
    return (tp[n]-1)+1+f(n-1, x-(tp[n+1]-1));
  //  if ( x == tp[nn+2]-4 )
  return tp[n+1]-1;
}

int main() {
  int N;
  long X;
  cin >> N >> X;
  --X;
  
  tp[0] = 1;
  for ( int i=1; i<55; i++ ) {
    tp[i] = tp[i-1]*2;
  }
  cout << f(N, X) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a= sc.nextInt();
        int b = sc.nextInt();

       if((a+b)<10){
         System.out.print(a+b);
       }else{
          System.out.print("error");
       }
 
    }
}

Measured memory_bytes: 25044
#include<stdio.h>

int main(){
	while(1){
		int max=0;
		char sec;
		for(int i=0;i<5;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			if(i==0&&(a|b)==0)return 0;
			if(max<a+b){
				max=a+b;
				sec='A'+i;
			}
		}
		printf("%c %d\n",sec,max);
	}
}



Measured memory_bytes: 2688
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner num = new Scanner(System.in);
		int[] foo = new int[3]; 
		
		foo[0] = num.nextInt();
		foo[1] = num.nextInt();
		foo[2] = num.nextInt();
		
		Arrays.sort(foo);
		System.out.println(foo[0]+" "+foo[1]+" "+foo[2]);
		
	}
	
}


Measured memory_bytes: 26252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 998244353;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);

  int ans = 0, cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    if (a)
      cnt++;
    else
    {
      ans = max(ans, cnt + 1);
      cnt = 0;
    }
  }
  ans = max(ans, cnt + 1);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3096
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){ return b ? gcd(b, a%b): a;}
ll lcm(ll a, ll b){ return a / gcd(a,b) * b;}


int f(int x){
	int res = 0;
	while(x%2 == 0){
		x/=2;
		res++;
	}
	return res;
}

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i,n) cin >> a[i];

	rep(i,n) {
		if(a[i]%2 == 1){
			cout << 0 << endl;
			return 0;
		}
		a[i] /= 2;
	}

	int t = f(a[0]);
	rep(i,n){
		if(f(a[i]) != t){
			cout << 0 << endl;
			return 0;
		}
		a[i] >>= t;
	}
	m >>= t;

	ll l = 1;
	rep(i,n){
		l = lcm(l, a[i]);
		if(l > m){
			cout << 0 << endl;
			return 0;
		}
	}

	m /= l;
	int ans = (m+1)/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.LinkedList;
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = Integer.parseInt(s.nextLine());
		int[][] input = new int[cnt][cnt+2];
		for(int i=0 ; i<cnt ; i++) {
			String[] tmp = s.nextLine().split(" ");
			int[] a = new int[tmp.length];
			for(int j=0 ; j<a.length ; j++) {
				a[j] = Integer.parseInt(tmp[j]);
			}
			input[i] = a;
		}
		int[] result = bfs(input);
		for(int i=0 ; i<result.length ; i++) {
			System.out.println((i+1) + " " + result[i]);
		}
	}

	public static int[] bfs(int[][] input) {
		int[] result = new int[input.length];
		boolean[] alreadyVisit = new boolean[input.length];
		for(int i=0 ; i<result.length ; i++) {
			result[i] = -1;
			alreadyVisit[i] = false;
		}
		LinkedList<Integer> graph = new LinkedList<Integer>();
		LinkedList<Integer> shortPath = new LinkedList<Integer>();
		graph.offer(new Integer(1));
		shortPath.offer(new Integer(0));

		while(! graph.isEmpty()) {
			Integer g = (Integer) graph.poll();
			Integer s = (Integer) shortPath.poll();
			if(alreadyVisit[g.intValue()-1]){}
			else {
				alreadyVisit[g.intValue()-1] = true;
				if(result[g.intValue()-1]==-1)
					result[g.intValue()-1] = s.intValue();
				for(int i=0 ; i<input[g.intValue()-1][1] ; i++) {
					graph.offer(new Integer(input[g.intValue()-1][i+2]));
					shortPath.offer(new Integer(s.intValue()+1));
				}
			}
		}
		return result;
	}
}

Measured memory_bytes: 19596
import java.util.Scanner;

public class Main {
  static Scanner in = new Scanner(System.in);
  static int[] a;
  static int[] b;
  static int n;
  public static void main(String[] args) {
    n = in.nextInt();
    a = new int[n];
    b = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = in.nextInt();
      b[i] = in.nextInt();
    }
    System.out.println(check());
  }
  static String check() {
    for (int i = 0; i + 2 < n; i++) {
      if (a[i] != b[i]) {
        continue;
      }
      if (a[i + 1] != b[i + 1]) {
        continue;
      }
      if (a[i + 2] != b[i + 2]) {
        continue;
      }
      return "Yes";
    }
    return  "No";
  }
}


Measured memory_bytes: 36136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

    string s, t;
    cin >> s;
    cin >> t;
    for (int i = 0, n = s.size(); i < n; ++i)
    {
        string u = "";
        for (int j = 0; j < n; ++j) u += s[(i+j)%n];
        if (t == u) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n,k,q = invr()
    w = []
    for i in range(q):
        a = inp()
        w.append(a)
    qw = counter(w,n)
    for i in range(n):
        if k - q + qw[i] <= 0:
            qw[i] = "No"
        else:
            qw[i] = "Yes"
    print(*qw,sep = "\n")
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a,n):
    q = [0] * n
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

#-----------------------------------------------------------------------#
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 81232
#include<iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


Measured memory_bytes: 3064
n, m = map(int, input().split())
hs = list(map(int, input().split()))

edge = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True
    for neighbor in edge[node]:
        if hs[node] <= hs[neighbor]:
            good = False
    if good:
        cnt += 1

print(cnt)

Measured memory_bytes: 29504
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string t = s;
    sort(ALL(t));
    ll cnt = 0;
    REP(i, n){
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 3920
S = input()
K = 10 ** 100
RL_counts = []
ptr = []
ans = [0] * len(S)
cnt = 1
for i in range(1, len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        RL_counts.append(cnt)
        if (S[i] == "L"):
            ptr.append(i - 1)
        cnt = 1
RL_counts.append(cnt)

for i in range(0, len(RL_counts), 2):
    ans[ptr[int(i / 2)]] += int((RL_counts[i] + 1) / 2) + int(RL_counts[i+1] / 2)
    ans[ptr[int(i / 2)] + 1] += int(RL_counts[i] / 2) + int((RL_counts[i+1] + 1) / 2)

print(" ".join(map(str, ans)))




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

#define N 200010 

using namespace std;

typedef long long ll;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0, f = 1;
	char c = nc();
	while (c < 48) {
		if (c == '-')
			f = -1;
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x * f;
}

int a[N], n;

map <ll, ll> MP;

bool check(int x) {
	MP.clear();
	for (int i = 2; i <= n; i ++ ) {
		if (a[i - 1] >= a[i]) {
			if (x == 1) {
				return false;
			}
			while (!MP.empty()) {
				ll mx = MP.rbegin() -> first;
				if (mx > a[i]) {
					MP.erase(mx);
				}
				else {
					break;
				}
			}

			int j = a[i];
			while (j > 0 && MP[j] + 1 == x) {
				MP.erase(j);
				j -- ;
			}
			if (!j) {
				return false;
			}
			MP[j] ++ ;
		}
	}
	return true;
}


int main() {
	n = rd();
	for (int i = 1; i <= n; i ++ ) {
		a[i] = rd();
	}

	int l = 1, r = n, ans = n;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	cout << ans << endl ;
	return 0;
}

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

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

	if (A == B) {
		if (A != C) {
			cout << "Yes" << endl;
		} else {
      cout << "No" << endl;
    }
	} else if (A == C || B == C) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	x := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&x[i])
	}

	sort.Sort(sort.IntSlice(x))

	if (3*x[2]-mySum(x))%2 == 0 {
		fmt.Println((3*x[2] - mySum(x)) / 2)
	} else {
		fmt.Println((3*(1+x[2]) - mySum(x)) / 2)
	}
}

func mySum(x []int) int {
	sum := 0
	for i := 0; i < len(x); i++ {
		sum += x[i]
	}
	return sum
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>> 
#define vll vector <pair<ll,ll>> 
#define vi vector <int> 
#define vl vector <ll> 
#define mp(a,b) nake_pair(a,b)
#define F first
#define S second
using namespace std;



int main()
{
   int k,x;
   cin>>k>>x;

   for(int i=x-k+1;i<=x+k-1;i++) cout<<i<<" ";
    return 0;
    }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=n; i<N; i++)
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll inf=1e18;

int main() {
	ll N;
	while(cin>>N && N > 0){
		vector<pair<pair<ll, ll>, ll>> vt;
		vt.push_back({{0, inf}, -1});
		REP(i,0,N){
			char command;
			cin >> command;
			if(command == 'W'){
				ll a , left;
				cin >> a >> left;
				for(int i=0; i< vt.size(); i++){
					if(vt[i].second == -1){
						if(left >= vt[i].first.second - vt[i].first.first){
							left -= vt[i].first.second - vt[i].first.first;
							vt[i].second = a;
						}else{
							vt[i].first.first = vt[i].first.first + left;
							vt.push_back({{vt[i].first.first-left, vt[i].first.first}, a});
							left = 0;
						}
						if(left == 0) break;
					}
				}
				sort(vt.begin(), vt.end());

			}else if(command == 'D'){
				ll a;
				cin >> a;
				for(int i=0; i< vt.size(); i++){
					if(vt[i].second == a){
						vt[i].second = -1;
					}
				}
			}else{
				ll idx;
				cin >> idx;
				for(auto v: vt){
					if(v.first.first <= idx && idx < v.first.second){
						p(v.second);
						break;
					}
				}
			}
//			for(auto v:vt){
//				p2(v.first.first, v.first.second);
//				p(v.second);
//			}

		}
		p("");
	}
	return 0;
}


Measured memory_bytes: 3228
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

ans = []
for i in range(N):
  a_t = T - (H[i] * 0.006)
  Abs = abs(A - a_t)
  ans.append(Abs)

print(ans.index(min(ans)) + 1)

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

#define ll long long

using namespace std;

const int N=1e5+100;
long double n;
ll q,h,s,d,ans,m,x;

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

    cin>>q>>h>>s>>d>>n;
    m=min( min(d,s*2) , min(h*4,q*8) );

    if(n>=2)
    {
        m=min( min(d,s*2) , min(h*4,q*8) );
        x=n/2;
        n-=x*2;
        ans+=m*x;
    }
    if(n<2 && n>=1)
    {
        m=min( s , min(h*2,q*4) );
        x=n/1;
        n-=x*1;
        ans+=m*x;
    }
    if(n<1 && n>=0.5)
    {
        m=min(h,q*2);
        x=n*2;
        n-=x*0.5;
        ans+=m*x;
    }
    if(n<0.5 && n>0)
    {
        n-=0.25;
        n-=x*0.25;
        ans+=q*x;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string ss[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
    for (int i = 0; i < 7; i++) {
        if (s == ss[i]) {
            cout << 7 - i << endl;
        }
    }
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(I,N) for(I=0;I<N;++I)
ll n,k;
vector<ll> a,b,c, memo[3];

ll DP(ll x, ll y)
{
	if(x>=n)
		return 0;
	if(memo[y][x] != -1)
		return memo[y][x];				
	ll p = 0;
	switch(y)
	{
		case 0: 	p= max(c[x]+DP(x+1,2), b[x]+DP(1+x,1));  break; 
		case 1: 	p= max(c[x]+DP(x+1,2), a[x]+DP(1+x,0));  break; 
		case 2: 	p= max(a[x]+DP(x+1,0), b[x]+DP(1+x,1));  break; 
	}											
	memo[y][x]=p;
	return memo[y][x];
}

int main()
{
	ll i,p,q,r;
	cin>>n;	
	FOR(i,n)
	{	
		cin>>p>>q>>r;
		a.pb(p);
		b.pb(q);
		c.pb(r);
		memo[0].pb(-1);
		memo[1].pb(-1);
		memo[2].pb(-1);
	}
	//memo[n-1]=0;
	//memo[n-2]= abs(h[n-1]-h[n-2]);
	p= max(a[0]+DP(1,0), b[0]+DP(1,1));
	p = max( p, c[0]+ DP(1,2));
	cout<<p;
}

Measured memory_bytes: 10064
#include<iostream>
using namespace std;
int main(void)
{
  int k, s;
  int c=0;
  cin>>k>>s;
  for(int x=0; x<=k; x++)
    for(int y=0; y<=k; y++)
      {
	int z=s-x-y;
	if(0<=z && z<=k)
	  c++;
      }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;

public class Hello
{

    public static void Main()
    {
        int n = cin();
        int[,] test = new int[n - 1, 3];
        int[] box;
        for (int i = 0; i < n - 1; i++)
        {
            box = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            test[i, 0] = box[0];
            test[i, 1] = box[1];
            test[i, 2] = box[2];
        }

        for (int i = 0; i < n; i++)
        {
            int sec = 0;
            int start = 0;
            for (int j = i; j < n - 1; j++)
            {
                //走り始める時間
                start = test[j, 1];
                int v = 0;
                if (start < sec)
                {
                    v = (sec - start) / test[j, 2];
                    if ((sec - start) % test[j, 2] != 0) v += 1;
                    start += v * test[j, 2];
                }
                sec = start + test[j, 0];
            }
            Console.WriteLine(sec);
        }
    }

}



public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int cin()
    {
        return int.Parse(Console.ReadLine());
    }

    public static List<int> IndexOfPlural(string a, string b)
    {
        List<int> list = new List<int>();
        if (a.Length == 0 || b.Length == 0) { list.Add(-1); return list; }
        if (a.IndexOf(b) == -1) { list.Add(-1); return list; }
        int box = 0;
        int revision = 0;
        while (true)
        {
            if (a.Length == 0) break;
            box = a.IndexOf(b);
            if (box == -1) { break; }
            else
            {
                list.Add(box + revision);
                a = a.Remove(box, b.Length);
                revision += b.Length;
            }
        }
        return list;
    }
}


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

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i, h) cin >> grid[i];

  int res = -1;
  rep(sh, h) {
    	rep(sw, w) {
      		if(grid[sh][sw] == '#') continue;
          
      		queue<pair<int, int>> que;
      		vector<vector<int>> dist(h, vector<int> (w, -1));
      		dist[sh][sw] = 0;
      		que.push({sh, sw});
       
      		while(!que.empty()) {
        		int vh = que.front().first;
        		int vw = que.front().second;
        		que.pop();
              
        		rep(dir, 4) {
          			int nvh = vh + dy[dir];
          			int nvw = vw + dx[dir];
          			if(nvh < 0) continue;
          			if(nvw < 0) continue;
          			if(nvh >= h) continue;
          			if(nvw >= w) continue;
          			if(dist[nvh][nvw] != -1) continue;
          			if(grid[nvh][nvw] == '#') continue;
          			dist[nvh][nvw] = dist[vh][vw]+1;
          			que.push({nvh, nvw});
                }
      		 	rep(gh, h) rep(gw, w) res = max(res, dist[gh][gw]);
            }
        }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
H, W, K =  [int(i) for i in input().split()]

masme = []
for i in range(H):
    masme.append(list(input()))

#print(masme)

h_p = []
for h in range(pow(2,H)):
    h_p.append( [int(i) for i in list(str(bin(h))[2:].zfill(H))] )

#print(h_p)

w_p = []
for w in range(pow(2,W)):
    w_p.append( [int(i) for i in list(str(bin(w))[2:].zfill(W))] )

#print(w_p)

def count(mas, h_b, w_b):
    ans = 0
    for i in range(H):
        for j in range(W):
            if h_b[i] * w_b[j] == 1 and mas[i][j] == "#" :
                ans += 1
    return ans


ans_cnt = 0
for h in h_p:
    for w in w_p:
        cnt = count(masme, h, w)
        if(cnt == K):
            ans_cnt += 1

print(ans_cnt)

Measured memory_bytes: 9096
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

ll N,X,T;
void solve(){
	cout<<(N+X-1)/X * T;
}
int main(){
	// debug;
	ios;

	cin>>N>>X>>T;

	solve();
	
	return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args) throws IOException{
		// TODO ??????????????????????????????????????????

		String str;


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		str = br.readLine();


		String[] st = str.split(" ");

		int a = Integer.parseInt(st[0]);
		int b = Integer.parseInt(st[1]);

		int area = a*b;
		int cir = (2*a)+(2*b);

		System.out.println(area+(" ")+cir);

	}

}

Measured memory_bytes: 24144
while True :
    l = int(input())
    if l == 0 :
        break
    
    money = 0
    END = False
    for i in range(12) :
        m, n = map(int, input().split())
        money += m - n
        
        if money >= l and END == False :
            month = i + 1
            END = True
    
    if END == False :
        print("NA")
    else :
        print(month)
        



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

int main() {
  int N,R;
  cin>>N>>R;
  if(N>=10) cout<<R<<endl;
  else cout<<R+(100*(10-N))<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define N 100005
#define maxn 10005
#define INF 0x3f3f3f3f
#define mase(a,b) memset(a,b,sizeof(a))
#define MIN(a,b) (a<b?a:b)
#define MAX(a,b) (a>b?a:b)
#define DS DisputeSegement
using namespace std;
int Healthy[N];
int n;
int da,db;
bool isAce(LL At)
{
    LL damage=At*db;
    LL daTimes=0;
    for(int i=0;i<n;i++)
    {
        if(Healthy[i]>damage)
        {
            daTimes+=(LL)ceil((Healthy[i]-damage)/((da-db)*1.0));
            if(daTimes>At||daTimes<0)
                return false;
        }
    }
    return true;
}
int main()
{
    int maxH;
    int re;
    scanf("%d %d %d",&n,&da,&db);
    maxH=-INF;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&Healthy[i]);
        maxH=MAX(Healthy[i],maxH);
    }
    LL l=1,r=maxH/db+1;
    while(l<=r)
    {
        LL mid=(l+r)/2;
        if(isAce(mid))
        {
            re=mid;
            r=mid-1;

        }
        else
        {
            l=mid+1;
        }
    }
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int x, y;
    cin >> x >> y;
    if(y%2 == 0 && 2*x <= y && 4*x >= y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using i8  = int8_t;using i16 = int16_t;using i32 = int32_t;using i64 = int64_t;using u8  = uint8_t;using u16 = uint16_t;using u32 = uint32_t;using u64 = uint64_t;using f32 = float;using f64 = double;
using vi32 = vector<i32>;using vi64 = vector<i64>;using vvi32 = vector<vi32>;using vvi64 = vector<vi64>;using pi32 = pair<i32,i32>;using pi64 = pair<i64,i64>;

#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,x) for(i64 i=1;i<=(i64)(x);i++)
#define RREPS(i,x) for(i64 i=((i64)(x));i>0;i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define SZ(x) ((i64)(x).size())
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define cauto const auto&
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

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

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


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

int_fast64_t _gcd(int_fast64_t x, int_fast64_t y) {
    while(x^=y^=x^=y%=x);
    return y;
}

void Main() {
    //-------------------------------------------------------------------------
    int_fast64_t x, y; cin >> x >> y;
    cout << _gcd(x, y) << endl;
    //-------------------------------------------------------------------------
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
ll const MOD=1e9+7;

const int MAX = 1000000;
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;
}

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

    int X,Y;
    cin>>X>>Y;
    if((X+Y)%3!=0){cout<<0<<endl;exit(0);}
    COMinit();
    int N=(X+Y)/3;
    X-=N;
    Y-=N;
    cout<<COM(X+Y,X)<<endl;
}


Measured memory_bytes: 23680
import heapq
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N = int(input())
adj = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    adj[a].append(b)
    adj[b].append(a)

L = list(map(lambda x: -int(x), input().split()))
heapq.heapify(L)
print(-sum(L[1:]))


node = [-1]*N

# leafを探す
leaf = -1
for i, a in enumerate(adj):
    if len(a) == 1:
        leaf = i
        break

Q = [leaf]
while Q:
    cur = Q.pop()
    for a in adj[cur]:
        if node[a] == -1:
            node[a] = - heapq.heappop(L)
            Q.append(a)
print("\n".join(map(str, node)))


Measured memory_bytes: 6004
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
A, B, C, K = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#list = [input() for i in range(N)]

ans = 0
if A >= K:
    ans = ans+K
else:
    ans = ans+A
    K = K-A
    if B >= K:
        ans = ans+0
    else:
        K = K - B
        if C >= K:
            ans = ans - K
        else:
            ans = ans-C

print(ans)


Measured memory_bytes: 61832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ans[101];
int main() {
	ll n;
	cin>>n;
	ll b[101];
	for(ll i=0;i<n-1;i++){
		cin>>b[i];
	}
	ans[0]=b[0];
	ans[n-1]=b[n-2];
	for(ll i=1;i<n-1;i++){
		ans[i]=min(b[i],b[i-1]);
	}
	ll sum=0;
	for(ll i=0;i<n;i++){
		sum+=ans[i];
	}
	cout <<sum;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110;
int A, B, C, D, E, F;

int get_sugar(int limit) {
    int maxs = 0;
    rep(d, limit / D + 1) {
        int c = (limit - d*D) / C;
        if (c < 0) break;
        int sugar = c*C + d*D;
        if (sugar > limit) break;
        chmax(maxs, c*C + d*D);
    }
    // printf("limit:%d, %d\n", limit, (limit + D - 1) / D + 1);
    return maxs;
}

int main(int argc, const char * argv[]) {
    cin >> A >> B >> C >> D >> E >> F;

    double maxd = -1;
    pair<int, int> ans;

    int maxA = F / (100*A);
    int maxB = F / (100*B);
    rep(a, maxA+1) {
        rep(b, maxB+1) {
            int num = a*A+b*B;
            int water = 100*num;
            if (water > F) break;
            if (water == 0) continue;

            int limit = min(F - water, num*E);
            int sugar = get_sugar(limit);
            double d = sugar*1.0 / (water+sugar);
            // printf("%d,%d,%f\n",water+sugar,sugar,d);

            if (chmax(maxd, d)) {
                ans = make_pair(water+sugar, sugar);
            }
        }
    }

    printf("%d %d\n", ans.first, ans.second);

    return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  if (S.size() + 1 == T.size() &&
      T.substr(0, S.size()) == S) {
    cout << "Yes" << endl;
  } else {
    cout << "No"<< endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;



int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int x,n;
   	cin>>n>>x;
   	int a[n];
   	for(int i=0;i<n;i++)
   	{
   		cin>>a[i];
   	}
   	int sum=0;
   	int i;
   	for(i=0;i<n;i++)
   	{
   		sum+=a[i];
   		if(sum>x)
   		{
   			break;
   		}
   	}
   	cout<<i+1<<endl;
	return 0;

}

Measured memory_bytes: 3656
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    int N,M;
    cin >> N >> M;
    vector<int> v(N+1,true);
    int a;
    REP(i,M) cin >> a,v[a]=false;
    long long limit=(long long) pow(10,9)+7;
    long long ans=0;
    vector<int> dp(N+1,0);
    dp[0]=1;
    if(v[1]) dp[1]=1;
    for(int i=2; i<=N;++i){
        if(v[i-1]) dp[i]+=dp[i-1];
        if(v[i-2]) dp[i]+=dp[i-2];
        dp[i]%=limit;
    }
    cout << dp[N];
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,M,d;
	cin >> N >> M >> d;
	string col ="RYGB";
	vector< vector<int> > C(N,vector<int>(M,-1));
	if(d%2) {
		for(int i =0; i < N; i++) for(int j =0; j < M; j++) C[i][j] =(i+j)%4;
	}
	else {
		for(int i =0; i < N; i++) for(int j =0; j < M; j++) if(C[i][j] == -1) {
			for(int k =i-d; k < N+d; k +=d/2) for(int l =j-d; l < M+d; l +=d/2) if((k-i+l-j)%d == 0) {
				int kn =(k-i)/(d/2), ln =(l-j)/(d/2), colc;
				if(kn%2 == 0) colc =((kn+ln)/2+10)%2;
				else colc =2+((kn+ln)/2+10)%2;
				for(int a =0; a < d/2; a++) if(k+a >= 0 && k+a < N && l+a >= 0 && l+a < M) C[k+a][l+a] =colc;
				for(int a =0; a < d/2; a++) if(k+a < N && k+a >= 0 && l-a < M && l-a >= 0) C[k+a][l-a] =colc;
				for(int a =0; a < d/2; a++) if(k+d-2-a >= 0 && k+d-2-a < N && l-a < M && l-a >= 0) C[k+d-2-a][l-a] =colc;
				for(int a =0; a < d/2; a++) if(k+d-2-a >= 0 && k+d-2-a < N && l+a >= 0 && l+a < M) C[k+d-2-a][l+a] =colc;
			}
			i =N;
			break;
		}
		for(int i =0; i < N; i++) for(int j =0; j < M; j++) if(C[i][j] == -1) {
			for(int k =i-d; k < N+d; k +=d/2) for(int l =j-d; l < M+d; l +=d/2) if((k-i+l-j)%d == 0) {
				int kn =(k-i)/(d/2), ln =(l-j)/(d/2), colc;
				if(kn%2 == 0) colc =((kn+ln)/2+10)%2;
				else colc =2+((kn+ln)/2+10)%2;
				for(int a =0; a < d/2; a++) if(k+a >= 0 && k+a < N && l+a >= 0 && l+a < M) C[k+a][l+a] =colc;
				for(int a =0; a < d/2; a++) if(k+a < N && k+a >= 0 && l-a < M && l-a >= 0) C[k+a][l-a] =colc;
				for(int a =0; a < d/2; a++) if(k+d-2-a >= 0 && k+d-2-a < N && l-a < M && l-a >= 0) C[k+d-2-a][l-a] =colc;
				for(int a =0; a < d/2; a++) if(k+d-2-a >= 0 && k+d-2-a < N && l+a >= 0 && l+a < M) C[k+d-2-a][l+a] =colc;
			}
			i =N;
			break;
		}
		for(int i =0; i < N; i++) for(int j =0; j < M; j++) if(C[i][j] == -1) {
			if(i > 0 && C[i-1][j] != -1) C[i][j] =C[i-1][j];
			if(j > 0 && C[i][j-1] != -1) C[i][j] =C[i][j-1];
		}
	}
	for(int i =0; i < N; i++) {
		string s;
		for(int j =0; j < M; j++) s +=col[C[i][j]];
		cout << s << "\n";
	}
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 1536
import math
n,d=map(int,input().split())
x=[]
for _ in range(n):
    x.append(list(map(int,input().split())))
ans=0
i=0
for i in range(n-1):
    for j in range(i+1,n):
        l2=0
        for k in range(d):
            l2+=(x[i][k]-x[j][k])**2
        if math.ceil(math.sqrt(l2))==math.floor(math.sqrt(l2)):
            ans+=1
print(ans)


Measured memory_bytes: 9152
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*3 for _ in range(n)]
for i in range(3):
    dp[0][i] = abc[0][i]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i+1][k])
print(max(dp[-1]))


Measured memory_bytes: 47312