akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

man = sum(B)

for i in range(N-1):
    if A[i+1] - A[i] == 1:
        man += C[A[i]-1]

print(man)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		FastScanner fs = new FastScanner();
		int days = fs.nextInt();
		int[][] hap = new int[days][3];
		for (int i = 0; i < days; i++) {
			hap[i][0] = fs.nextInt();
			hap[i][1] = fs.nextInt();
			hap[i][2] = fs.nextInt();

		}
		int a[] = new int[days];
		int b[] = new int[days];
		int c[] = new int[days];
		System.out.println(getMaxHapiness(hap, a, b, c, days));
	}

	private static int getMaxHapiness(int[][] hap, int[] a, int[] b, int[] c, int days) {

		int[] dp = new int[days];
		a[0] = hap[0][0];
		b[0] = hap[0][1];
		c[0] = hap[0][2];
		dp[0] = Math.max(a[0], Math.max(b[0], c[0]));
		for (int i = 1; i < days; i++) {
			a[i] = hap[i][0] + Math.max(b[i - 1], c[i - 1]);
			b[i] = hap[i][1] + Math.max(a[i - 1], c[i - 1]);
			c[i] = hap[i][2] + Math.max(a[i - 1], b[i - 1]);

			dp[i] = Math.max(a[i], Math.max(b[i], c[i]));

		}

		return dp[days - 1];

	}

}

class FastScanner {
	StringTokenizer tok = new StringTokenizer("");
	BufferedReader in;

	FastScanner() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}

	String next() throws IOException {
		while (!tok.hasMoreElements())
			tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}

Measured memory_bytes: 48440
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int N;

int main()
{
    cin >> N;
    char c;
    lint sum, now, msum = 0;
    cin >> sum;
    lint tmp = 0;
    vector<lint> mlst;
    for (int i=1; i<N; i++)
    {
        cin >> c >> now;
        sum += now;
        if (c == '-') {
            mlst.push_back(tmp);
            msum += now;
            tmp = msum;
        }
        else {
            tmp += now;
        }
    }
    if (!mlst.empty()) mlst[0] = -1;
    mlst.push_back(msum);
    sort(mlst.begin(), mlst.end());
    cout << sum - mlst[1] * 2 << endl;
}


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

int main(){
    int n;
    string s;
    cin >> n;
    int x = n / 100;
    int y = n % 100;
    if((1 <= x && x <= 12) && (1 <= y && y <= 12)){
        s = "AMBIGUOUS";
    }else if(1 <= y && y <= 12){
        s = "YYMM";
    }else if(1 <= x && x <= 12){
        s = "MMYY";
    }else{
        s = "NA";
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include<iomanip>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int cnt=1<<30;
  vector<pair<int,int>>as;
  map<int,int>ma;
  rep(i,n)ma[a[i]]++;
  as=vector<pair<int,int>>(all(ma));
  int res=0;
  int l=as.size();
  as.push_back({1e9+1,0});
  for(int i=l-1;i>=0;i--)
  {
    if(as[i].second==0)continue;
    while(cnt>2*as[i].first)cnt/=2;
    pair<int,int> tp={cnt-as[i].first,1};
    int  f=lower_bound(all(as),tp)-as.begin();
    if(as[f].first==cnt-as[i].first)
    {
      if(i==f)
      {
        res+=as[f].second/2;
        as[f].second=as[f].second&1;
      }
      else
      {
        int tmp=min(as[i].second,as[f].second);
        res+=tmp;
        as[i].second-=tmp;
        as[f].second-=tmp;
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 14976
n = int(input())
a = list(map(int,input().split()))
b = [0,0] 
for p in range(2):
  s = 0
  for i in range(n):
    t = s+a[i]
    if (i+p)%2 == 0:
      if t<=0:
        b[p] += 1-t
        s = 1
      else:
        s = t
    else:
      if t>=0:
        b[p] += 1+t
        s = -1
      else:
        s = t
print(min(b))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int K, N;
    cin >> K >> N;
    int A[N];
    rep(i, N){
        cin >> A[i];
    }
    int m = A[0]+K-A[N-1];
    rep(i, N-1){
        m = max(m, A[i+1]-A[i]);
    }
    cout << K-m << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        List<List<Integer>> graph = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int temp1 = in.nextInt();
            int temp2 = in.nextInt();
            graph.get(temp1 - 1).add(temp2-1);
        }
        int max = 0;
        //  System.out.println(go(mat,0,0));
        boolean vis[] = new boolean[n];
        int dis[] = new int[n];
        for (int i = 0; i < n; i++) {
            if (!vis[i]) {
                int temp = go(graph, i, 0, vis,dis);
                //System.out.println(i+" "+temp+" ");
                max = Math.max(max, temp);
            }
        }
        System.out.println(max);

    }

    static int go(List<List<Integer>> graph, int curr, int level, boolean vis[],int dis[]) {
        // System.out.println("Curr = "+curr+" "+level);
        int currL = level;
        if(dis[curr]>0){
            vis[curr] = true;
            return dis[curr];
        }
        for (int i = 0; i < graph.get(curr).size(); i++) {
            level = Math.max(level, go(graph, graph.get(curr).get(i), currL, vis,dis) + 1);
        }
        dis[curr] = level;
        vis[curr] = true;
        return level;
    }

}

Measured memory_bytes: 100352
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    LIST = []
    for i in range(n):
        LIST.append(int(input()))
    #s_L = sorted(LIST,reverse=True)
    # ma_1 = s_L[0]
    # ma_2 = s_L[1]
    #
    # for i in range(n):
    #     if LIST[i] != ma_1:
    #         print(ma_1)
    #     else:
    #         print(ma_2)
    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(1,n):
        left[i] = max(left[i-1],LIST[i-1])
    for i in range(n-2,-1,-1):
        right[i] = max(right[i+1],LIST[i+1])
    for i in range(n):
        print(max(left[i],right[i]))

if __name__ == '__main__':
  main()


Measured memory_bytes: 15644
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    int a,b,c,d,k=0; cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        if(k==0)
        c=c-b;
        else a=a-d;
        k^=1;
    }
    if(a>0) cout<<"Yes"; else cout<<"No";
    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] srgs) {

        Scanner sc = new Scanner(System.in); // ??????????????????????????????.

        // ?????????????????? int ?????¨??????????????\???????????????.
        // ??????????????????????????? 0 ????????????.
        while (true) {
            int x = sc.nextInt();
            String op = sc.next();
            int y = sc.nextInt();
            if (op.equals("?")) { break; }
            if (op.equals("+")) { System.out.println(x + y); }
            if (op.equals("-")) { System.out.println(x - y); }
            if (op.equals("*")) { System.out.println(x * y); }
            if (op.equals("/")) { System.out.println(x / y); }
        }
    }
}

Measured memory_bytes: 26332
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<list>

typedef long long ll;

using namespace std;

char H[1046527][15];

int getCharKey(char a){
	if(a == 'A')
		return 1;
	else if(a == 'C'){
		return 2;
	}
	else if(a == 'G'){
		return 3;
	}
	else if(a == 'T'){
		return 4;
	}
	else
		return 0;
}

ll getKey(char a[]){
	ll sum = 0;
	ll p = 1;
	for(ll i = 0 ; i<strlen(a) ; i++){
		sum += p*getCharKey(a[i]);
		p *=5;
	}
	return sum;
}

int h1(int key){
	return key%1046527;
}
int h2(int key){
	return 1+ (key%1046526);
}

int insert(char a[]){
	ll key = getKey(a);
	for(ll i = 0 ; ; i++){
		ll h = (h1(key) + i*h2(key)) %1046527;
		if(strcmp(H[h] , a) == 0)
			return 1;
		else if(strlen(H[h]) == 0){
			strcpy(H[h] , a);
			return 0;
		}
	}
	return 0;
}

int find(char a[]){
	ll key = getKey(a);
	for(ll i = 0 ; ; i++){
		ll h = (h1(key) + i*h2(key)) %1046527;
		if(strcmp(H[h] , a) == 0)
			return 1;
		else if(strlen(H[h]) == 0)
			return 0;
	}
	return 0; 
}
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i = 0 ; i<n ; i++)
		H[i][0] = '\0';
	
	char a[20] , b[20];
	for(int i = 0 ; i<n ; i++){
		cin>>a>>b;
		if(a[0] == 'i')
			insert(b);
		else{
			if(find(b))
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 18444
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([(0, -1)])
    visited = [False]*N
    visited[0] = True
    ans = [-1]*(N-1)

    while q:
        v, prev = q.popleft()
        now = 0

        for nv in G[v]:
            if not visited[nv]:
                if now==prev:
                    now += 1

                visited[nv] = True
                ans[idx[(min(v, nv), max(v, nv))]] = now
                q.append((nv, now))
                now += 1

    return ans

N = int(input())
G = [[] for _ in range(N)]
idx = defaultdict(int)

for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    idx[(min(a-1, b-1), max(a-1, b-1))] = i

ans = bfs()
print(max(ans)+1)

for ans_i in ans:
    print(ans_i+1)

Measured memory_bytes: 102664
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
board = [[0 for i in range(14)] for j in range(14)]
for l in range(0,len(N)):
    x,y,s = [int(i) for i in N[l].split(",")]
    x = x + 2
    y = y + 2
    if s >= 1:
        board[x+1][y] += 1
        board[x-1][y] += 1
        board[x][y+1] += 1
        board[x][y-1] += 1
        board[x][y] += 1
    if s >= 2:
        board[x+1][y+1] += 1
        board[x+1][y-1] += 1
        board[x-1][y+1] += 1
        board[x-1][y-1] += 1
    if s >= 3:
        board[x+2][y] += 1
        board[x-2][y] += 1
        board[x][y+2] += 1
        board[x][y-2] += 1

a = 0
b = 0
for i in range(2,12):
    for j in range(2,12):
        if board[i][j] == 0:
            a += 1
        if board[i][j] > b:
            b = board[i][j]

print(a)
print(b)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,i;
  string s;
  cin>>n>>q>>s;
  vector<int> l(q);
  vector<int> r(q);
  vector<int> ans(n);
  for(i=0;i<q;i++){
    cin>>l.at(i)>>r.at(i);
    l.at(i)-=2;r.at(i)-=2;
  }
  if((s.at(0) =='A')&&(s.at(1) =='C')){ans.at(0)=1;}else{ans.at(0)=0;}
  for(i=1;i<n-1;i++){
   if((s.at(i) =='A')&&(s.at(i+1) =='C')){
     ans.at(i)=(ans.at(i-1)+1);
   }else{
     ans.at(i)=ans.at(i-1);
   }
  }
  for(i=0;i<q;i++){
    if(l.at(i)!=-1){
    cout<<(ans.at(r.at(i))-ans.at(l.at(i)))<<endl;
    }else{
      cout<<ans.at(r.at(i))<<endl;
    }
  }
}

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

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

	int ans = 0;
	
	for (int i = 0; i < s.size(); ) {

		int cnt = 0;
		for (int j = i; j < s.size(); j++) {
			
			if (s.at(j) == 'A' || s.at(j) == 'C' || s.at(j) == 'G' || s.at(j) == 'T') {
				cnt++;
			}
			else {
				break;
			}

		}

		i += max(1, cnt);

		ans = max(ans, cnt);

	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    while(1){    
        int n;
        cin >> n;
        if(n==-1) break;
        vector<int> seg(10,0);
        seg.at(0)=0b0111111;
        seg.at(1)=0b0000110;
        seg.at(2)=0b1011011;
        seg.at(3)=0b1001111;
        seg.at(4)=0b1100110;
        seg.at(5)=0b1101101;
        seg.at(6)=0b1111101;
        seg.at(7)=0b0100111;
        seg.at(8)=0b1111111;
        seg.at(9)=0b1101111;
        vector<int> data(n+1,0);
        vector<int> out(n,0);
        for(int i=0;i<n;i++){
            cin >> data.at(i+1);
            data.at(i+1)=seg.at(data.at(i+1));
        }
        for(int j=0;j<n;j++){
            out.at(j)=data.at(j)^data.at(j+1);
        cout << bitset<7>(out.at(j)) << endl;
        }
    }    
}



Measured memory_bytes: 2996
using System;

public class p0044
{
	static void eratosthenes(bool[] prime, int nlimit){
		for(int i = 0; i < nlimit; ++i)
			prime[i] = true;
		prime[0] = prime[1] = false;
		
		for(int i = 2; i < nlimit; ++i)
			if(prime[i])
				for(int j = i*2; j < nlimit; j += i)
					prime[j] = false;
	}
	
	static void Main(string[] args){
		string input_str;
		int nlimit = 55000;
		bool[] prime = new bool[nlimit];
		
		eratosthenes(prime, nlimit);
		
		while((input_str = Console.ReadLine()) != null){
			int number = int.Parse(input_str);
			
			for(int i = number-1; i > 1; --i)
				if(prime[i]){
					Console.Write("{0} ", i);
					break;
				}
			
			for(int i = number+1; i < nlimit; ++i)
				if(prime[i]){
					Console.WriteLine("{0}", i);
					break;
				}
		}
	}
}

Measured memory_bytes: 5680
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		//int a = sc.nextInt();
		//List<Integer> check=new ArrayList<Integer>();
		//array = new int[h+1][w+1];
		List<Integer> list=new ArrayList<Integer>();
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//Collections.reverse(list);
		List<Integer> list_two=new ArrayList<Integer>();

		int n = sc.nextInt();

		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
			list_two.add(a);
		}


		Collections.sort(list, Collections.reverseOrder());
		//System.out.println(list);
		//System.out.println(list_two);
		int list_in_max = Collections.max(list_two);
		int maxIndex = list_two.indexOf(Collections.max(list_two));
		//System.out.println(maxIndex);
		if(list.get(0).equals(list.get(1))) {
			for(int i=0;n>i;i++) {
				System.out.println(list_in_max);
			}
			System.exit(0);
		}

		else {
			for(int i=0;n>i;i++) {
				if(i==maxIndex) {
					list_two.remove(i);
					System.out.println(Collections.max(list_two));
				}
				else {
					System.out.println(list_in_max);
				}
			}

		}
		/*

		List<Integer> list_max=new ArrayList<Integer>();

		for(int i=0;n>i;i++) {
			int max =0;

			for(int j=0;n>j;j++) {
				if(i==j)
					continue;
				if(list.get(j)>max) {
					max = list.get(j);
				}

			}
			list_max.add(max);
		}

		for(int i=0;list_max.size()>i;i++) {
			System.out.println(list_max.get(i));
		}
		*/

	}

}


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

int main()
{
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D >> S; --A, --B, --C, --D;
	bool ng = false;
	for (int i = A; i < C; i++) {
		if (S[i] == '#' && S[i + 1] == '#') {
			ng = true;
			break;
		}
	}
	for (int i = B; i < D; i++) {
		if (S[i] == '#' && S[i + 1] == '#') {
			ng = true;
			break;
		}
	}
	if (ng) {
		puts("No");
		return 0;
	}
	if (C < D) {
		puts("Yes");
		return 0;
	}
	bool ok = false;
	for (int i = max(0, B - 1); i < D; i++) {
		if (i + 2 < N && S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
			ok = true;
			break;
		}
	}
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//try thinking from a different angle after spending some time
//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
	speed
	//global var
	int n;cin>>n;
	std::vector<int> inp(n);
	int amount=1000;
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];
	}
	for(int i=0;i<n-1;++i){
		if(inp[i]<inp[i+1]){
			int q=amount/inp[i];
			amount+=q*(inp[i+1]-inp[i]);
		}
	}
	cout<<amount<<"\n";
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int n,a[3005],ans;
main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        ans+=a[i]-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 1e6 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
queue<ll> q;
string s;
ll n,i,ans,cur = 0;
ll res[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>s; n = s.size(); s = " " + s;
    for (i = 1;i <= n;i++) if (s[i] == '<') q.push(i);
    q.push(n + 1);
    while(!q.empty()){
        ll t = q.front(); q.pop();
        for (i = cur; i < t;i++) res[i] = (t - i - 1);
        if (cur > 0) res[cur] = max(res[cur],res[cur - 1] + 1);
        cur = t;
    }
    for (i = 0;i <= n;i++) ans += res[i];
    cout<<ans;
}


Measured memory_bytes: 11492
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int dp[202020],p[202020];

int calc(int n){
  if(dp[n]!=0)return dp[n];
  if(n==0)return 1;
  if(p[n]>p[n-1])return dp[n]=calc(n-1)+1;
  else return dp[n]=1;
  }



int main(){
  int n;
  cin>>n;
  rep(i,n){
    int x;cin>>x;
    p[x-1]=i;
    }
  int ans=0;
  rep(i,n)ans=max(ans,calc(i));
  cout<<n-ans<<endl;
  return 0;
  }


Measured memory_bytes: 1792
from sys import exit


N, Y = map(int, input().split())

res = 0

for i in range(N+1):
    for j in range(N+1):
        k = N - i - j
        if k >= 0:
            amm = 10000 * i + 5000 * j + 1000 * k
            if amm == Y:
                res += 1
                print('{} {} {}'.format(i, j, k))
                exit()

if res == 0:
    print('{} {} {}'. format(-1, -1, -1))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int N,K,ans;

	cin >> N >> K;

	ans = N + 1 - K;

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n,k,q;
    cin>>n>>k>>q;

    vector<int> a(q);
    vector<int> p(n,k-q);

    REP(i,q){
        cin>>a.at(i);
        p.at( a.at(i) - 1) ++;
    }

    REP(i,n){
        if(p.at(i) <= 0){
            cout<<"No"<<endl;
        } else {
            cout<<"Yes"<<endl;
        }
    }

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

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

using namespace std;

using ll = long long;
const ll INF = 2e9, N = 1e5 + 15;

ll n, c, a[ 101 ], b[ 101 ], dp[ 101 ][ N ];

ll dfs(ll pos = 1, ll s = 0) {
    if( pos == n + 1 )
        return 0LL;
    ll &ret = dp[ pos ][ s ];
    if( ~ret ) return ret;
    ret = dfs(pos + 1, s);
    if( s + a[ pos ] <= c )
        ret = max(ret, b[ pos ] + dfs(pos + 1, s + a[ pos ]));
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> c;
    for(ll i = 1; i <= n; i += 1) {
        cin >> a[ i ] >> b[ i ];
    }
    memset(dp, -1, sizeof dp);
    cout << dfs() << '\n';
    return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
 
if(a==b){
    printf("%d\n",c);
}else if(a==c){
    printf("%d\n",b);
}else{
    printf("%d\n",a);
}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(all(a))
#define RSORT(a) stable_sort(rall(a))
#define rev(a) reverse(all(a))
#define uniq(a) a.erase(unique(all(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(all(a))
#define max_of(a) *max_element(all(a))
#define sum(a) accumulate(all(a), 0)
#define count_of(a, i) count(all(a), i)
#define lower(a, i) (lower_bound(all(a), i) - begin(a))
#define upper(a, i) (upper_bound(all(a), i) - begin(a))
#define binary(a, i) binary_search(all(a), i)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define sz(a) (int)(a).size()
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod_add(int A, int B) { return (A + B) % MOD; }
int mod_sub(int A, int B) { return (A + MOD - B) % MOD; }
int mod_mul(int A, int B) { return ((A % MOD) * (B % MOD)) % MOD; }
int mod_bipow(int X, int Y) {
  if (Y == 0) return 1;
  else if (Y == 1) return X % MOD;
  else if (Y % 2 == 0) {
    int Z = mod_bipow(X, (int)(Y / 2));
    return mod_mul(Z, Z);
  } else {
    int Z = mod_bipow(X, (int)(Y / 2));
    return mod_mul(mod_mul(Z, Z), X);
  }
}
int mod_inv(int X) { return mod_bipow(X, MOD - 2); }
int mod_div(int A, int B) { return mod_mul(A, mod_inv(B)); }

template<class T> bool amin(T& A, T B) {
  if (A > B) {
    A = B;
    return true;
  }
  return false;
}
template<class T> bool amax(T& A, T B) {
  if (A < B) {
    A = B;
    return true;
  }
  return false;
}

int ceil_div(int X, int Y) { return (X - 1) / Y + 1; }

vi cum(vi V) {
  vi U(sz(V));
  partial_sum(all(V), begin(U));
  return U;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

struct vertex {
  vector<int> adj = vi(0);
};


void solve() {
  int a,b,c,d;
  string s;
  int ans = 0;

  cin >> a>>b>>c>>d;
  // vi a(n);
  // rep(i, n) {
  //   cin >> a[i];
  // }

  cout << max(a * b, c * d) << endl;
}


signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

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

  uint64_t N = s.size();
  vector<uint64_t> S(N);
  N_TIMES(n, N) { S[n] = s[n] - '0'; }

  uint64_t base = 1;
  vector<uint64_t> dp(N + 1, 0);
  N_TIMES(n, N) {
    dp[n + 1] = (dp[n] + S[(N - 1) - n] * base) % 2019;
    base = (base * 10) % 2019;
  }

  vector<uint64_t> count(2019, 0);
  N_TIMES(n, N + 1) {
    ++count[dp[n]];
  }

  uint64_t T = 0;
  N_TIMES(i, 2019) {
    if (count[i] >= 2) {
      T += (count[i] * (count[i] - 1)) >> 1;
    }
  }
  cout << T << endl;

  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    vector<ll> L(N), R(N);
    REP(i, N) cin >> L[i] >> R[i];

    sort(L.rbegin(), L.rend());
    sort(R.begin(), R.end());

    ll res = 0;
    ll tmp = 0;
    REP(i, N){
        chmax(res, tmp);
        chmax(res, tmp+L[i]);
        chmax(res, tmp-R[i]);
        tmp += (L[i]-R[i]);
    }
    cout << 2*res << endl;

    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n,t,sum=0,l;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>l;
        sum+=l;
        if(i==0 || l>t)
            t=l;
    }
    if(sum-t>t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( )
{
  int a,b,c,i,count = 0;

  scanf("%d%d%d",&a,&b,&c);

  //if(a != b)
   //{
      for(i = a; i <= b; i++)   //カウンタ変数がどこまで続くかを知れ
	{
	  //printf("%d c%d \n",i,count);
	  if(c % i == 0)count++;
	  else continue;
	}
      //  }
  /* else
    {
      if(c % a == 0)count++;
      }*/

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

  return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T>
struct BIT{
    int n;
    vector<T> d;
    BIT(int n = 0):n(n), d(n+1){}
    void add(int i, T x = 1){
        for(i++; i <= n; i += i&-i){
            d[i] += x;
        }
    }
    T sum(int i){
        T x = 0;
        for(i++; i; i -= i&-i){
            x += d[i];
        }
        return x;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	BIT<ll> bit(n+1);
	vector<ll> a(n);
	ll ans = 0;
	rep(i,n){
		cin >> a[i];
		bit.add(i, a[i]);
		ll sum = bit.sum(i);
		if(i%2 == 1){
			if(sum >= 0){
				ans += 1 + sum;
				bit.add(i, -(1 + sum));
			}
		}
		else{
			if(sum <= 0){
				ans += 1 - sum;
				bit.add(i, 1 - sum);
			}
		}
	}
	ll cmp = 0;
	BIT<ll> bit2(n+1);
	rep(i,n){
		bit2.add(i, a[i]);
		ll sum = bit2.sum(i);
		if(i%2 == 0){
			if(sum >= 0){
				cmp += 1 + sum;
				bit2.add(i, -(1 + sum));
			}
		}
		else{
			if(sum <= 0){
				cmp += 1 - sum;
				bit2.add(i, 1 - sum);
			}
		}
	}
	chmin(ans, cmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;

int main(){
	int n,t;
	cin>>n>>t;
	int ans=INT_MAX;
	while(n--){
		int a,b;
		cin>>a>>b;
		if(b<=t){
			ans=min(ans,a);
		}
	}
	if(ans==INT_MAX)puts("TLE");
	else cout<<ans;
	return 0;
}


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

void solve() {
	ll n;
	cin>>n;
	
	map<int, int> mp;
		for(ll j = 1; j*j<=n; ++j) {
			for(ll k = 1; k*k<=n; ++k) {
				for(ll l = 1; l*l<=n; ++l) {
					mp[j*j + k*k + l*l + j*k + j*l + l*k] += 1;
				}
			}
		}
	
	for(int i = 1; i<=n; ++i) {
		cout<<mp[i]<<endl;
	}
}	

int32_t main() 
{
    fastio
    int t;
    t = 1; //cin>>t;
    while(t--) {
		solve();
	}
}


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

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

    string s;
    ll ans = 0;

    while (1) {
        cin >> s;
        if (s == "END_OF_TEXT")
            break;
        rep(i, s.size()) {
            if (s[i] >= 'A' && s[i] <= 'Z')
                s[i] += 'a' - 'A';
        }
        if (s == t)
            ++ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
#define MAX 200000
#define S 1000000000
int L[MAX],R[MAX];
long long merge(int A[],int n,int left,int mid,int right){
  int i,j,k;
  long long cnt =0;
  int n1 = mid-left;
  int n2 = right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=S;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j])
      A[k]=L[i++];
    else{
      A[k]=R[j++];
      cnt += n1-i;
    }
  }
  return cnt;
}

long long mergeSort(int A[],int n,int left,int right){
  int mid;
  long long v1,v2,v3;
  if(left+1<right){
    mid=(left+right)/2;
    v1=mergeSort(A,n,left,mid);
    v2=mergeSort(A,n,mid,right);
    v3=merge(A,n,left,mid,right);
    return v1+v2+v3;
  }
  else return 0;
}

int main(){
  int A[MAX],n,i;
  long long ans;
  scanf("%d",&n);;
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  ans=mergeSort(A,n,0,n);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2160
#include<stdio.h>

int main(){
    char S[4];
    char judge;

    scanf("%s",S);
    judge = S[0];
    if(judge != S[1]){
        printf("Yes\n");
    }else if(judge != S[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
x=[]
y=[]
for i in range(m):
    xy=list(map(int,input().split()))
    x.append(xy[0]-1)
    y.append(xy[1]-1)

red=[0]*n
red[0]=1
cnt=[1]*n

for i in range(m):
    cnt[x[i]]-=1
    cnt[y[i]]+=1

    if red[x[i]]==1:
        red[y[i]]=1
    
    if cnt[x[i]]==0:
        red[x[i]]=0

ans=0
for i in range(n):
    if red[i]==1 and cnt[i]>0:
        ans+=1

print(ans)

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

using namespace std;

typedef long long ll;

int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end(), greater<int>());
	ll l = 0, r = a[n - 1] * b[0];
	while (l <= r) {
		ll m = (l + r) / 2;
		ll tmp = 0;
		for (int i = 0; i < n; i++) {
			tmp += max(a[i] - m / b[i], 0LL);
		}
		if (tmp > k) {
			l = m + 1;
		} else {
			r = m - 1;
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<long long , int> PII;

const int N = 2e5 + 10;

int n, m, k, q, x, y;
int h[N], e[N], ne[N], idx;
long long w[N];
long long  dist[N];
bool st[N];

void add(int a, int b, int c)
{
    e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}

void dijkstra()
{
    memset(dist, 0x3f, sizeof dist);
    
    dist[k] = 0;
    priority_queue<PII, vector<PII>, greater<PII>> heap;
    heap.push({0, k});

    while (heap.size())
    {
        auto t = heap.top();
        heap.pop();

        int ver = t.second; long long distance = t.first;

        if (st[ver]) continue;
        st[ver] = true;

        for (int i = h[ver]; i != -1; i = ne[i])
        {
            int j = e[i];
            if (dist[j] > distance + w[i])
            {
                dist[j] = distance + w[i];
                heap.push({dist[j], j});
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    // scanf("%d",&n);
    cin >> n;
    
    m = n - 1;
    memset(h, -1, sizeof h);
    while (m -- )
    {
        int a ,b ,c;
        cin >>a >> b >> c;
        add(a, b, c);
        add(b, a, c);
    }
    
    cin >> q>> k;
    dijkstra();
    while(q--)
    {
        cin >>x >>y;
        cout << dist[x] + dist[y] <<endl;
    }

    return 0;
}

Measured memory_bytes: 7924
H, W, M = list(map(int, input().split()))
bomb = set([tuple(map(int, input().split())) for i in range(M)])

column_cnt = [0]*W
row_cnt = [0]*H

for bomb_pos in bomb:
    row_cnt[bomb_pos[0]-1] += 1
    column_cnt[bomb_pos[1]-1] += 1

row_max_index = row_cnt.index(max(row_cnt))
column_max_index = column_cnt.index(max(column_cnt))

bomb_cnt_max = 0

for bomb_pos in bomb:
    bomb_cnt = row_cnt[bomb_pos[0]-1] + column_cnt[column_max_index]
    if (bomb_pos[0], column_max_index+1) in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

    bomb_cnt = column_cnt[bomb_pos[1]-1] + row_cnt[row_max_index]
    if (row_max_index+1, bomb_pos[1]) in bomb:
        bomb_cnt -= 1
    bomb_cnt_max = max(bomb_cnt_max, bomb_cnt)

print(bomb_cnt_max)

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

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

vector<int>vc;
long long int sum=0;
for(int i=0;i<n;i++)
{
    int a;
    cin>>a;
    vc.push_back(a);
    sum+=a;
}


int i=0;

int ct=0;
while(i<vc.size())
{
    if(4*m*vc[i]>=sum)
    {
        ct++;
    }
    i++;
}

if(ct>=m)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 40
#include <vector>

using namespace std;

int idx=0;
int n;
int pre[MAX],in[MAX+1];
vector<int> ans;

int find(int x){
  for(int i=0;i<n;i++){
    if(x==in[i]) return i;
  }
  return -1;
}

void reconstruction(int l,int r){
  if(l>=r) return;
  int c=pre[idx++];
  int m=find(c);
  reconstruction(l,m);
  reconstruction(m+1,r);
  ans.push_back(c);
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> pre[i];
  for(int i=0;i<n;i++) cin >> in[i];
  in[n]=0;
  reconstruction(0,n);
  for(int i=0;i<n;i++){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}

Measured memory_bytes: 3136
n, a, b, c, d = [int(i) for i in input().split(" ")]
s = "_" + input() + "_"

def no2rock(l, r):
    global s
    for i in range(l + 1, r + 1):
        if s[i - 1] == "#" and s[i] == "#":
            return False
    return True

def rest(l, r):
    global s
    for i in range(l, r + 1):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if c < d:
    if no2rock(a, c) and no2rock(b, d):
        print("Yes")
    else:
        print("No")
else:
    if no2rock(a, c) and no2rock(b, d) and rest(b, d):
        print("Yes")
    else:
        print("No")

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, p;
  cin >> a >> p;

  cout << (a * 3 + p) / 2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;

const ll modo=1e9+7;
const ll ms=5010;
const ll inf=1e15;

ll ar[ms];
ll br[ms];
ll pp[ms];
int vis[ms];
ll tot;
ll sum;
ll ans=LONG_LONG_MIN;
ll k;
void go(int i)
{
    vis[i]=1;
    tot++;
    sum+=br[i];
    pp[tot]=sum;
    if(tot<=k)ans=max(ans,sum);

  //  cout<<i<<" "<<tot<<" "<<sum<<"\n";
    if(!vis[ar[i]])
    {
        go(ar[i]);
    }
    else{
        ll mov=k/tot;
        ll aa=mov*sum;
        int j;
        if(mov){
        ans=max(ans,aa);}
        for(j=1;j<tot;j++)
        {
           mov=(k-j)/tot;
           if(k>=j)
           {
               aa=mov*sum+pp[j];
               ans=max(ans,aa);
           }
        }
    }
}





int main()
{
    idfc;
    int n;
    cin>>n>>k;
    int i;
    for(i=1;i<=n;i++)cin>>ar[i];

    for(i=1;i<=n;i++)cin>>br[i];
    int j;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)vis[j]=0;
        tot=0;
        sum=0;
        go(ar[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3736
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==1&&b==0&&c==0||a==0&&b==1&&c==0||a==0&&b==0&&c==0)
	{
		printf("Close\n");
	}
	else
	{
		printf("Open\n");
	}
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if((a+b)>(c+d)){
    cout << "Left" << endl;
  }else if((a+b)<(c+d)){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
x = int(input())
y = 0
if x==1 or x==2 or x==3 or x==4:
    print(1)
    exit()
else:
    for a in range(2,(x+1)):
        for b in range (2,10):
            if b==2 and a**b>x:
                print(y)
                exit()
            elif a**b<=x:
                y=max(a**b,y)


Measured memory_bytes: 3060
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}


void solve(){
  string s;
  cin >> s;

  int n = s.size();
  int zero =0, one=0;

  for(int i = 0;i<n;i++){
    if(s[i]=='0')zero++;
    else one++;
  }

  cout << 2*min(zero,one) << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

using namespace std;

typedef long long int big;

big relVel(big v,big w){
    return v-w;
}

bool posbl(big a,big v,big b,big w,big dead){
    big dist = (b-a);
    big rel = relVel(v,w);
    // cout<<rel<<" ";
    if(rel>0){
        double time = ((double)abs(dist))/((double)abs(rel));
        // cout<<time<<"\n";
        if(time>dead){
            return false;
        }
        return true;
    }
    return false;
}

int main(){
  big t=1;
//   cin>>t;
  while(t--){
     big a,v,b,w,dead;
     cin>>a>>v>>b>>w>>dead;
     cout<< (posbl(a,v,b,w,dead)?"YES":"NO")<<"\n"; 
  }
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>


/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;

int main() {
  int a, b;
  scanf("%d%d", &a, &b);
  printf("%d\n", max(a+b, max(a-b, a*b)));
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[300005],l[300005],r[300005],ans=-1e18;
multiset<long long>s;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=3*n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=3*n;i++)
	{
		s.insert(a[i]);
		l[i]=l[i-1]+a[i];
		if(s.size()>n)
		{
			l[i]-=(*s.begin());
			s.erase(s.begin());
		}
	}
	s.clear();
	for(int i=3*n;i>=1;i--)
	{
		s.insert(-a[i]);
		r[i]=r[i+1]+a[i];
		if(s.size()>n)
		{
			r[i]+=(*s.begin());
			s.erase(s.begin());
		}
	}
	for(int i=n;i<=2*n;i++)ans=max(ans,l[i]-r[i+1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11904
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int N, a[MAX], ans;

int main()
{
    optimiza_io
    cin >> N;
    for( int i = 1; i <= N; i ++ )
        cin >> a[i];
    
    for( int i = 2; i < N; i ++ ) {
        if( a[i] > a[i - 1] && a[i] < a[i + 1] )
            ans++;
        if( a[i] > a[i + 1] && a[i] < a[i - 1] )
            ans++;
    }
    
    cout << ans << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 


#x,y = [int(i) for i in readline().split()]

n = int(input())
s = input()

if n&1: print("No")
else:
    if s == s[:n//2]+s[:n//2]: print("Yes")
    else:
        print("No")
    

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



int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    
    int sum = a1 + a2 + a3;
    
    if(sum > 21)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(void) {
	int h,w;
	while(scanf("%d%d", &h,&w)){
		if(h == 0 && w == 0)
			break;
		int i,c;
		for(i =0; h > i; i++){
			for(c = 0; w > c; c++){
				if(i == 0 || c == 0 || c == w-1 || i == h-1)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;
#define int long long

signed main(){
    int N,M;
    cin >> N >> M;
    
    int L=0,R=1000000;
    int tmp,tmp2;
    for(int i=0;i<M;i++){
        cin >> tmp >> tmp2;
        L = max(tmp,L);
        R = min(tmp2,R);
    }
    int cnt = 0;
    if(L<=R){
        for(int i=L;i<=R;i++){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n, m, x, *a, i, ai, down = 0, up;

	cin >> n >> m >> x;

	a = new int[m];

	for (i = 0; i < m; i++) {
		cin >> ai;
		a[i] = ai;
	}

	for (i=0; i < m; i++) {
		if (a[i] > x)
			break;
		down++;
	}
	up = m - down;

	cout << (down < up ? down : up);

	return 0;
}

Measured memory_bytes: 256