akhauriyash/Code-Regression huggingface dataset:
import bisect
from bisect import bisect_left, bisect_right

N = int(input())
a = list(map(int, input().split()))

ma = max(a)
a.sort()

i = bisect_left(a, ma / 2)

if abs(ma / 2 - a[i]) < abs(ma / 2 - a[i-1]):
    print(ma, a[i])
else:
    print(ma, a[i-1])


Measured memory_bytes: 14428
#include<stdio.h>
#include <stdio.h>

int solve(int ,int);

int n;
int A[20];

int main(void)
{
  int q,i,judge=0;
  int M[200];
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&M[i]);
  }
  
  for(i=0; i<q; i++){
    judge = solve(0,M[i]);
    if(judge == 0) printf("no\n");
    else printf("yes\n");
  }
  
  return 0;
  
}

int solve(int x,int M)
{
  if(x == n && M == 0) return 1;
  if(x == n && M != 0) return 0;
  else return solve(x+1,M)+solve(x+1,M-A[x]);
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
long long ans,n,m;
int main()
{
	cin>>n>>m;
	ans=n*(m-1);
	if(ans%m==0)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =998244353;

     signed main(){
             cout << std::setprecision(15) ;
         int n,s;
         cin>>n>>s;
         int a[n];
         for(int i=0;i<n;i++)cin>>a[i];
         int dp[s+1]={},ans=0;
         for(int i=0;i<n;i++){
                 for(int j=s;j>=a[i];j--)dp[j]=(dp[j]+dp[j-a[i]])%MOD;
                 if(a[i]<=s)dp[a[i]]=(dp[a[i]]+i+1)%MOD;
                 ans=(ans+dp[s])%MOD;
         }
         
         cout<<ans;

         
}

        


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	s := []rune(next())
	ans := 0
	idx := 0
	for i := 0; i < len(s); i++ {
		tmp := 0
		for idx < len(s) {
			if string(s[idx]) == "A" || string(s[idx]) == "G" || string(s[idx]) == "C" || string(s[idx]) == "T" {
				tmp += 1
				idx += 1
			} else {
				break
			}
		}
		ans = max(ans, tmp)
		idx = i + 1
	}
	fmt.Fprintln(out, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, K = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

l=[0]*N
for i in range(K):
    d=int(input())
    A = list(map(int, input().split()))
    for a in A:
        l[a-1]+=1
count=0
for li in l:
    if li==0: count+=1
print(count)



Measured memory_bytes: 68388
/**
 *
 * @author Daipayan Mukherjee
 * @Jadavpur University,Information Technology
 *
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] st = br.readLine().split(" ");
        int n = Integer.parseInt(st[0]);
        int k = Integer.parseInt(st[1]);
        String[] s = br.readLine().split(" ");
        int[] heights = new int[n];
        for(int i=0;i<n;i++){
            heights[i] = Integer.parseInt(s[i]);
        }
        int[] dp = new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        
        dp[0] = 0;
        
        for(int i=1;i<n;i++){
            for(int j=i-1;j>=i-k && j>=0;j--){
                dp[i] = Math.min(dp[i],dp[j]+Math.abs(heights[j]-heights[i]));
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 35540
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt(),B=sc.nextInt();
		if(A==1)A=14;
		if(B==1)B=14;
		if(A==B){
			System.out.println("Draw");
		}
		else if(A>B){
			System.out.println("Alice");
		}
		else{
			System.out.println("Bob");
		}
	}
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 1e6;
  int a[max_n + 1];
  int max_a = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    max_a = max(max_a, a[i]);
  }

  // eratosthenes
  vector<int> d(max_a + 1, 0);
  d[0] = d[1] = 1;
  for(int i = 2; i <= max_a; i++){
    int j = i;
    while(j <= max_a){
      if(d[j] == 0) d[j] = i;
      j += i;
    }
  }
  // for(int i = 0; i <= max_a; i++) cout << d[i] << endl;

  vector<int> cnt(max_a + 1, 0);
  bool flag1 = 0;
  bool flag2 = 0;
  int prime = 2;
  for(int i = 0; i < n; i++){
    int tmp = a[i];
    while(tmp > 1){
      prime = d[tmp];
      cnt[prime] ++;
      while(tmp % prime == 0) tmp /= prime;
      if(cnt[prime] > 1) flag1 = 1;
      if(cnt[prime] == n) flag2 = 1;
    }
  }
  string ans = "not coprime";
  if(flag2 == 0) ans = "setwise coprime";
  if(flag1 == 0) ans = "pairwise coprime";
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 14852
from collections import defaultdict


N = int(input())
V = list(map(int, input().split()))

if len(set(V)) == 1:
    print(N // 2)
    exit()

counter = defaultdict(int)
for i in range(N):
    if i % 2 == 0:
        counter[V[i]] += 1

pairs_1 = sorted([(k, v) for k, v in counter.items()], key=lambda p: p[1], reverse=True)

counter = defaultdict(int)
for i in range(N):
    if i % 2 != 0:
        counter[V[i]] += 1

pairs_2 = sorted([(k, v) for k, v in counter.items()], key=lambda p: p[1], reverse=True)

if pairs_1[0][0] != pairs_2[0][0]:
    ans = (N // 2 - pairs_1[0][1]) + (N // 2 - pairs_2[0][1])
else:
    ans = min((N // 2 - pairs_1[0][1]) + (N // 2 - pairs_2[1][1]), (N // 2 - pairs_1[1][1]) + (N // 2 - pairs_2[0][1]))
print(ans)


Measured memory_bytes: 20436
fun main(args: Array<String>)
{
    val n = readInt()
    var ans = 0

    for (i in 1..n)
    {
        var tmp = i
        var cnt = 1
        while (tmp / 10 != 0)
        {
            cnt++
            tmp /= 10
        }

        if (cnt % 2 == 1) ans++
    }

    println(ans)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 29780
import numpy as np
h, w = [int(_) for _ in input().split()]

a = np.empty((h, w), dtype=np.str)
for i in range(0, h):
    a[i] = list(input())


height = h
i = 0
while True:
    if i == height:
        break
    if not '#' in a[i]:
        a = np.delete(a, i, axis=0)
        height -= 1
    else:
        i += 1

width = w
i = 0
while True:
    if i == width:
        break
    if not '#' in a[:, i]:
        a = np.delete(a, i, axis=1)
        width -= 1
    else:
        i += 1

for i in range(0, len(a)):
    print(''.join(a[i]))

Measured memory_bytes: 20748
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;
vector <pair<int, long long>> graph[100001];
const long long INF = 210000000000000000;
long long d[100001];
void dfs(int start)
{
	stack <int> s;
	for (int i = 0; i < 100001; i++)
	{
		d[i] = INF;
	}
	s.push(start);
	d[start] = 0;
	while (!s.empty())
	{
		int now = s.top();
		s.pop();

		for (auto v : graph[now])
		{
			if (d[v.first] == INF)
			{
				d[v.first] = d[now] + v.second;
				s.push(v.first);
			}
		}	
	}

	return;
}
int main(void)
{
	ifstream ifs;
	int n, q, k;
	int a, b;
	long long c;

	//ifs.open("test.txt");
	//ifs >> n;

	cin >> n;
	for (int i = 0; i < n-1; i++)
	{
		//ifs >> a >> b >> c;
		cin >> a >> b >> c;
		graph[a].push_back(make_pair(b, c));
		graph[b].push_back(make_pair(a, c));
	}

	//ifs >> q >> k;
	cin >> q >> k;

	dfs(k);
	for (int i = 0; i < q; i++)
	{
		//ifs >> a >> b;
		cin >> a >> b;
		cout << d[a] + d[b] << endl;
	}


	return 0;
}

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

using namespace std;

int main() {

	long n,k;
	cin >> n >> k;

	long counter = 0;
	long h;
	for (long i = 0; i < n; i++) {
		cin >> h;
		if (h >= k) { counter++; }
	}

	cout << counter << endl;
}

Measured memory_bytes: 256
package abc100A;
use Exporter;
@ISA = (Exporter);
@EXPORT = qw(solve);

# 提出するときのコピーはここから

use strict;
use warnings;

sub main {
    my ($N,$M) = split(/ /,<STDIN>);
    print solve($N,$M);
}

main() unless caller;

sub solve {
    my ($N,$M) = @_;
    return ($N<=8 && $M<=8) ? 'Yay!' : ':(';
}

# ここまで

1;
__END__


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

using namespace std;

long long n;
long long ans=0;

void check(long long x){
	string s=to_string(x);
	int c3,c5,c7;
	c3=c5=c7=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='3'){
			c3++;
		}else if(s[i]=='5'){
			c5++;
		}else if(s[i]=='7'){
			c7++;
		}
	}
	if(c3>0 && c5>0 && c7>0){
		ans++;
	}
}

void dfs(long long x){
	if(x<=n){
		check(x);
	}
	if(x<=1000000000){
		dfs(10*x+3);
		dfs(10*x+5);
		dfs(10*x+7);
	}else{
		//cout << x << endl;
	}
}

int main(){
	cin >> n;
	dfs(0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define mod 1000000007
#define p pair<int,int>
using namespace std;
int gcd(long A,long B){
	if(A==0)
		return B;
	if(B==0)
		return A;
	if(A%B==0)
		return B;
	return gcd(B,A%B);
}
int main(){
	int n;
	cin>>n;
	vector<long>arr(n);
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<long>left(n,0);
	vector<long>right(n,0);
	for(int i=1;i<n;i++){
		left[i]=gcd(left[i-1],arr[i-1]);
	}
	for(int i=n-2;i>=0;i--){
		right[i]=gcd(right[i+1],arr[i+1]);
	}
	int res=INT_MIN;
	for(int i=0;i<n;i++){
		long temp=gcd(left[i],right[i]);
		res=res>temp?res:temp;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18+1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, L, T;
	cin >> N >> L >> T;
	vll X(N), W(N);
	rep(i, N)cin >> X[i] >> W[i];

	vll fin(N);
	rep(i, N) {
		if (W[i] == 1) { fin[i] = (X[i] + T) % L; }
		else { fin[i] = (X[i] - T) % L;}

		if (fin[i] < 0) { fin[i] += L; }
	}

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

	ll sumdis = 0;
	rep(i, N) {
		if (W[i] == 1) { sumdis += T; }
		else { sumdis -= T; }
	}
	//cout << sumdis << endl;

	ll d = 0;
	rep(i, N) {
		ll now = fin[i] + L - X[i];
		d += now;
	}
	//cout << d << endl;

	ll zure = (d - sumdis) % (L * N) / L;
	
	//cout << zure << endl;
	rep(i, N) {
		cout << fin[(i - zure + N) % N] << endl;
	}
}

Measured memory_bytes: 5596
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int=parseInt(readline())
    a::Vector{Int}=parseMap(split(readline()))
    ruiseki::Int=0
    for i in a
        ruiseki⊻=i
    end
    println(join([ruiseki⊻i for i in a]," "))
end
main()

Measured memory_bytes: 205980
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll a, b, x;
    cin >> a >> b >> x; a--; a += x; b += x;
    cout << b / x - a / x;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    ll n,q;
    string s;
    cin >> n >> q >> s;
    vector<ll> dp(n);
    dp[0] = 0;
    rep1(i, n){
        if (s[i] == 'C' && s[i - 1] == 'A') {
            dp[i] = dp[i - 1] + 1;
            
        }else{
            dp[i] = dp[i - 1];
        }
    }
    ll l,r;
    rep0(i, q){
        cin >> l >> r;
        cout << dp[r - 1] - dp[l - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll fun(ll p)
{
    ll ans = 1;
    for (int i = 0; i < 5; i++)
        ans *= p;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    for (int i = -4000; i <= 4000; i++)
    {
        for (int j = -4000; j <= 4000; j++)
            if (fun(i) - fun(j) == n)
            {
                cout << i << " " << j << "\n";
                return 0;
            }
    }
    return 0;
}

Measured memory_bytes: 3616
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll              long long
#define pi              pair<int,int>
#define pll             pair<ll,ll>
#define pb              push_back
#define F               first
#define S               second
#define vi              vector<int>
#define vll             vector<ll>
#define endl            '\n'
#define all(v)          (v).begin(),(v).end()
#define FOR(i,a,b)      for(int i=a;i<b;i++)
#define MP(a,b)         make_pair(a,b)
#define debug(x)        cerr<< #x << " : " << x << endl;
#define debugp(p)       cerr<< #p << " : " << "(" << (p).first << "," << (p).second << ")\n";
#define debugv(v)       cerr<< #v << " : " << "["; for(int i = 0; i < (v).size(); i++) cerr << v[i] << " "; cerr<<"]\n";
#define debugs(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<*itr << " "; cerr << "]\n";
#define debugm(m)       cerr<< #m << " : [ "; for(auto itr = m.begin(); itr != m.end(); itr++) cerr <<"(" << itr->first << "," << itr->second << ") "; cerr << "]\n";

/* ordered set: 
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/

inline ll modexp(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}

const int inf = 1e9 + 7;

void solve(){
    string s;
    cin >> s;
    int r = 0;
    for (auto x : s){
        int num = x - '0';
        r += num;
        r %= 9;
    }
    if (r == 0) cout << "Yes\n";
    else cout << "No\n";
}
int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    #ifdef LOCAL
    cerr << "Time elapsed\t: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";       
    #endif
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  for (int i = 0; i < m; i++)
    cin >> v[i];
  reverse(v.begin(), v.end());
  vector<bool> used(n);
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    if (!used[v[i] - 1]) {
      ans.push_back(v[i]);
    }
    used[v[i] - 1] = true;
  }
  for (int i = 0; i < n; i++)
    if (!used[i])
      ans.push_back(i + 1);
  for (auto &i : ans)
    cout << i << endl;
  return 0;
}


Measured memory_bytes: 4332
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n = sc.read();
    let mut a = 0;
    let mut b = 0;
    for _ in 0..n {
        let s: String = sc.read();
        let t: String = sc.read();
        if s > t {
            a += 3;
        } else if s < t {
            b += 3;
        } else {
            a += 1;
            b += 1;
        }
    }

    println!("{} {}", a, b);
}



Measured memory_bytes: 5036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] sArray = sc.next().split("");
		int[] rList = new int[n+1];
		int[] gList = new int[n+1];
		int[] bList = new int[n+1];
		long redCount = 0;
		long greenCount = 0;
		long blueCount = 0;
		for(int i =0;i < sArray.length;i++) {
			if(sArray[i].equals("R")) {
				redCount++;
				rList[i+1]++;
			}
			if(sArray[i].equals("G")) {
				greenCount++;
				gList[i+1]++;
			}
			if(sArray[i].equals("B")) {
				blueCount++;
				bList[i+1]++;
			}
		}
		long answer = redCount * greenCount * blueCount;
		if(answer == 0) {
			System.out.println(0);
			return;
		}
		for(int red =1;red <= n;red++) {
			if(rList[red] ==0) {
				continue;
			}
			for(int green =1;green <= n;green++) {
				if(gList[green] ==0) {
					continue;
				}
				if(red > green) {
					if(red + (red -green)<=n) {
						if(bList[(red + (red -green))] == 1) {
							answer--;
						}
					}
					if(green - (red -green)>0) {
						if(bList[(green - (red -green))] == 1) {
							answer--;
						}
					}
				}else {
					if(green + (green -red)<=n) {
						if(bList[(green + (green -red))] == 1) {
							answer--;
						}
					}
					if(red - (green -red)>0) {
						if(bList[(red - (green -red))] == 1) {
							answer--;
						}
					}

				}
				if((red + green)%2 ==0 ) {
					if(bList[((red +green)/2)] == 1) {
						answer--;
					}
				}
			}
		}

		System.out.println(answer);
	}

}

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

int main(){
 long long S;
cin>>S;
  int v=1000000000;
	int x=(v-S%v)%v;
	int y=(S+x)/v;
	cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}


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

int gcd(int n, int m){
    int tmp;
    while(m%n){
        tmp = n;
        n = m%n;
        m = tmp;
    }

    return n;
}

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

    int n, X;
    cin >> n >> X;

    int res;
    cin >> res;
    res = abs(X - res);

    rep1(i, n){
        int x;
        cin >> x;
        res = gcd(res, abs(X - x));
    }
    cout << res << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<ll> a(n + 2);
    a[0] = 2;
    a[1] = 1;
    for(int i = 2; i <= n; i++){
        a[i] = a[i - 1] + a[i - 2];
    }
    cout << a[n] << endl;
    return 0;
}


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

int main()
{
    int N, Y;
    cin >> N >> Y;

    int ret[] = {-1, -1, -1};
    REP(i, Y/10000+1) REP(j, (Y-i*10000)/5000+1)
    {
        int k = (Y - (i*10000 + j*5000))/1000;
        if (k == N-(i+j))
        {
            ret[0] = i; ret[1] = j; ret[2] = k;
            break;
        }
    }

    cout << ret[0] << " " << ret[1] << " " << ret[2] << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc023_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<string> S(N);
        for (int i = 0; i < N; ++i) {
            in >> S[i];
        }
        int res = 0;
        for (int b = 0; b < N; ++b) {
            bool ok = true;
            for (int i = 0; ok && i < N; ++i) {
                for (int j = 0; ok && j < N; ++j) {
                    if (S[i][(j + b) % N] != S[j][(i + b) % N]) {
                        ok = false;
                    }
                }
            }
            res += ok * N;
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc023_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#ifndef ONLINE_JUDGE
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> V(n);
  for (int& i : V) cin >> i;
  vector<pair<pair<int, int>, pair<int, int>>> Q;
  int sq = sqrt(n);
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    Q.emplace_back(make_pair(l, r), make_pair(i, l /  sq));
  }

  sort(Q.begin(), Q.end(), [&](pair<pair<int, int>, pair<int, int>>& l, pair<pair<int, int>, pair<int, int>>& r) {
    if (l.second.second == r.second.second) return l.first.second < r.first.second;
    return l.second.second < r.second.second;
  });

  int prev = -1;
  vector<int> ans(m);
  vector<int> cnt(n + 1);
  int anss = 0;
  int prevl = -1;
  int prevr = -1;
  for (int i = 0; i < m; ++i) {
    if (Q[i].second.second != prev) {
      for (int& q : cnt) q = 0;
      anss = 0;
      for (int q = Q[i].first.first; q <= Q[i].first.second; ++q) {
        if (cnt[V[q]] == 0) ++anss;
        cnt[V[q]]++;
      }
    } else {
      int l = Q[i].first.first;
      int r = Q[i].first.second;
      if (prevl < l) {
        for (int q = prevl; q < l; ++q) {
          cnt[V[q]]--;
          if (cnt[V[q]] == 0) --anss;
        }
      } else {
        for (int q = l; q < prevl; ++q) {
          if (cnt[V[q]] == 0) ++anss;
          cnt[V[q]]++;
        }
      }
      for (int q = prevr + 1; q <= r; ++q) {
        if (cnt[V[q]] == 0) ++anss;
        cnt[V[q]]++;
      }
    }
    prevl = Q[i].first.first;
    prevr = Q[i].first.second;
    prev = Q[i].second.second;
    int kek = 0;
    ans[Q[i].second.first] = anss;
  }

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


Measured memory_bytes: 17380
n = int(input())
l = [0]*(55556)
i = 2
while i <= 55555:
    j = 2
    while i*j <= 55555:
        l[i*j] = 1
        j += 1
    i += 1
ans = []
for i in range(3,55556):
    if l[i]:
        continue
    if ((i-1)//2)%5 == 0:
        ans.append(i)
print(*ans[:n])

Measured memory_bytes: 69468
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll>mpp;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        ++mpp[a[i]];
    }
    ll oAns=0;
    for(auto it:mpp){
        oAns+=(it.s*(it.s-1))/2;
    }
    ll temp;
    for(ll i=0;i<n;i++){
        if(mpp[a[i]]>1){
            temp=oAns-(mpp[a[i]]*(mpp[a[i]]-1))/2;
            temp=temp+((mpp[a[i]]-1)*(mpp[a[i]]-2))/2;
        }else{
            temp=oAns;
        }
        cout<<temp<<"\n";
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const ll INF=1e18;
const ll mod = 1e9 + 7;


int main() {
	int	n;
	ll sum = 0, ans = 0;
	cin >> n;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
	}
	rep(i,n - 1){
		sum += a[i];
		sum %= mod;
		ans += sum * a[i + 1] % mod;
		ans %= mod;
	}
	cout << ans <<endl;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

void solution() {
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] != '?') continue;
    if (i - 1 >= 0 && s[i - 1] == 'P') {
      s[i] = 'D';
    } else if (i + 1 < n && s[i + 1] == '?') {
      s[i] = 'P';
      s[i + 1] = 'D';
      i++;
    } else if (i + 1 < n && s[i + 1] == 'D') {
      s[i] = 'P';
    } else
      s[i] = 'D';
  }
  cout << s << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  solution();
}


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

using namespace std;

int main(void)
{
	string s;
	cin>>s;
	long long x;
	cin>>x;
	if(x==1)
		cout<<s[0]<<endl;
	else
	{
		int y=0;
		while(s[y]=='1' && x!=0)
		{
			y++;
			x--;
		}
		if(x==0)
			y--;
		cout<<s[y]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int color[110000];
int N,u,v,temp;
vector<pair<int,ll>> V[110000];

void gogo(int x,int d){
  color[x]=d;
  for(int i=0;i<V[x].size();i++){
    //cout<<i<<" "<<V[x][i].first<<endl;
    if(color[V[x][i].first]==-1) gogo(V[x][i].first,(V[x][i].second+d)%2);
  }
}

int main(){
  for(int i=0;i<110000;i++){
    color[i]=-1;
  }
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>u>>v>>temp;
    V[u].push_back(make_pair(v,temp));
    V[v].push_back(make_pair(u,temp));
  }

  gogo(1,0);

  for(int i=1;i<=N;i++){
    cout<<color[i]<<endl;
  }
}


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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
int dp[50][10000];

int main() {
    int N,a,b;
    cin>>N>>a>>b;
    vector<vector<int>> v(N,vector<int>(3));
    for(int i = 0; i < N; i++) cin>>v[i][0]>>v[i][1]>>v[i][2];
    vector<int> d(N);
    for(int i = 0; i < N; i++) d[i]=b*v[i][0]-a*v[i][1];
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 10000; j++) dp[i][j]=INF;
    }
    dp[0][5000]=0;
    dp[0][5000+d[0]]=v[0][2];
    int ans = INF;
    for(int i = 0; i < N-1; i++){
        for(int j = 0; j < 10000; j++){
            if(dp[i][j]==-1) continue;
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j+d[i+1]],dp[i][j]+v[i+1][2]);
            if(j+d[i+1]==5000) chmin(ans,dp[i][j]+v[i+1][2]);
        }
    }
    if(ans==INF) cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 5548
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int mp[8][8];

int main() {
	rep(i, 8) {
		rep(j, 8) {
			mp[i][j] = 1;
		}
	}
	for (int i = 0; i < 8; i += 2) {
		for(int j = 1; j < 8; j += 2) {
			mp[i][j] = 0;
		}
	}
	int q; cin >> q;
	rep(aa, q) {
		int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; d--;
		int ans = 0;
		Rep1(i, a, c) {
			Rep1(j, b, d) {
				ans += mp[i][j];
			}
		}
		cout << ans << endl;
	}
	//stop
	return 0;
}



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

int main() {
  long long X;
  cin>>X;
  long long N=100;
  int i=1;
  while(1){
    long long ri;
    ri=(long long)(N*0.01);
    N+=ri;
    if(N>=X){
      cout<<i;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 3636
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
	
	var d = parseInt(tmp[0], 10);
	var t = parseInt(tmp[1], 10);
	var s = parseInt(tmp[2], 10);
	
	if  (d / s > t) {
	var result = "No";
	} else {
	var result = "Yes";
	}
	
	console.log(result);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

const int N = 2 * 100000 + 5;
int rad[N * 2];

int longest_palindrome(const char *text, int n)
{
  int i, j, k;
  for (i = 0, j = 0; i < 2*n; i += k, j = max(j-k, 0)) {
    while (i-j >= 0 && i+j+1 < 2*n && text[(i-j)/2] == text[(i+j+1)/2]) ++j;
    rad[i] = j;
    for (k = 1; i-k >= 0 && rad[i]-k >= 0 && rad[i-k] != rad[i]-k; ++k)
      rad[i+k] = min(rad[i-k], rad[i]-k);
  }
  return *max_element(rad, rad+2*n); // ret. centre of the longest palindrome
}

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

  string s;
  while (cin >> s) {
    map<char, lli> cnt;
    each (c, s) ++cnt[c];
    const lli n = s.size();
    lli sum = n * (n - 1) / 2 + 1;
    each (i, cnt) sum -= i.second * (i.second - 1) / 2;
    cout << sum << endl;
  }
  
  return 0;
}


// (length "abracadabra") ; 11
// (/ (* 11 (- 11 1)) 2) ; 55


Measured memory_bytes: 720
#include <iostream>
#include <string>
using namespace std;
int main() {
  int x[5];
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i+1;
      break;
    }
  }

  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  bool flag = true;
 for(int i = 0; i < A; i++) {
   if(S[i] >= '0' && S[i] <= '9') continue;
   else { flag = false; }
 }
 if(S[A] != '-') {
   flag = false;
 }

 for(int i = A + 1; i < A + B + 1; i++) {
   if(S[i] >= '0' && S[i] <= '9') continue;
   else { flag = false; }
 }
 if(flag)
 cout << "Yes";
 else
 {
   cout << "No";
 }
  


  return 0;
}

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

int main()
{
    int m, f, r;
    cin >> m >> f >> r;

    while (m != -1 || f != -1 || r != -1)
    {
        if(m == -1 || f == -1)
        {
            cout << 'F' << endl;
        }
        else
        {
            int total = m + f;
            if(total >=80)
            {
                cout << 'A' << endl;
            }
            else if(total >= 65)
            {
                cout << 'B' << endl;
            }
            else if (total >= 50)
            {
                cout << 'C' << endl;
            }
            else if (total >= 30)
            {
                if(r >=50)
                {
                    cout << 'C' << endl;
                }
                else
                {
                    cout << 'D' << endl;
                }
            }
            else
            {
                cout << 'F' << endl;
            }
            
        }
        cin >> m >> f >> r;
    }
        return 0;
}



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

int main(){
	int h,w;
	char l;
	cin >> h >>w;
	vector<vector<char>> a(h,vector<char>(w));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> l;
			a[i][j] = l;
		}
	}

	vector<vector<int>> ans(h,vector<int>(w,0));
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if (a[i][j] == '#'){
				ans[i][j] = -1;
				for(int k = i - 1; k <= i + 1 ; k++){
					for(int l = j - 1; l <= j + 1; l++) {
						if (k >= 0 && k < h && l >= 0 && l < w){
							ans[k][l]++;
						}
					}
				}
			}
		}
	}

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(a[i][j] == '#'){
				cout << a[i][j]; 
			}
			else{
				cout << ans[i][j];
			}
		}
		cout <<endl;

	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 500011

int n, i;
ll a[maxN], ans;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= 3 * n; i++) scanf("%lld", &a[i]);
    sort(a + 1, a + 3 * n + 1);
    for (i = 1; i <= n; i++) ans += a[3 * n - (2 * i - 1)];

    printf("%lld", ans);


    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ans=0;
    int a[n+5];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2 && a[i]%2)
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    if(n<=99) cout << min(9,n) << endl;
    else if(n<=999) cout << n-90 << endl;
    else if(n<=9999) cout << 909 << endl;
    else if(n<=99999) cout << 909+n-9999 << endl;
    else cout << 90909 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=998244353,N=3e6+5;
int n,m,fac[N],inv[N],ans;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;
	return res;
}

int C(int n,int m){
	if(n<m||m<0) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int calc(int m){
	return C(n+m-1,n-1);
}

void init(int n){
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=fpow(fac[n],mod-2);for(int i=n-1;~i;i--) inv[i]=inv[i+1]*(i+1)%mod;
}

signed main(){
	read(n,m);
	init(3e6);
	for(int i=0;i<=n&&i<=m;i++) if(~i&1^m&1){
		ans=(ans+C(n,i)*calc((3*m-i)/2))%mod;
		ans=(ans-C(n-1,i)*n%mod*calc((m-i-2)/2))%mod;
		ans=(ans-C(n-1,i-1)*n%mod*calc((m-i)/2))%mod;
	}
	write((ans+mod)%mod);
}

Measured memory_bytes: 50484
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    char s[1000];
    int t,i,p=0;
    scanf("%s",s);
    while (s[0]!='0')
    {
    t=strlen(s);
    for(i=0;i<t;i++)
    {
       p=p+s[i]-'0';
    }
    printf("%d\n",p);
    p=0;
    scanf("%s",s);
    }
    return 0;
}


Measured memory_bytes: 2060
N,M = map(int, input().split())

g = [[] for i in range(N)]

for i in range(M):
    A,B = map(int,input().split())
    g[A-1].append(B-1)
    g[B-1].append(A-1)

from collections import deque

queue = deque([0])
d = [None] * N
d[0] = 0
while queue:
    v = queue.popleft()
    for i in g[v]:
        if d[i] is None:
            d[i] = v+1
            queue.append(i)

if None in d:
    print('No')
else:
    print('Yes')
    for i in d[1:]:
        print(i)


Measured memory_bytes: 98512
N, *H = [gets, *gets.split].map(&:to_i)

dp = [0, (H[0]-H[1]).abs]
2.step(N-1) do |i|
  dp[i] = [dp[i-1]+(H[i-1] - H[i]).abs, dp[i-2]+(H[i-2] - H[i]).abs].min
end
puts dp.last

Measured memory_bytes: 12420
L,R=map(int, input().split())

if R-L+1>=2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    if L<R:
        m = 2019
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                m = min(m, (i*j)%2019)
        print(m)
    else:
        print(0)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  int a,b,c,k; cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k << "\n";
    return 0;
  }
  if(k<=a+b){
    cout << a << "\n";
    return 0;
  }
  if(k>a+b){
    cout << a+(k-(a+b))*-1 << "\n";
    return 0;
  }
}

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

const int N = 100005;

int id[N], a[N];

bool cmp(int u, int v) {
	return a[u] < a[v];
}

int n;

int main() {
	while (~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			id[i] = i;
		}
		sort(id + 1, id + 1 + n, cmp);
		int ans = 0;
		for (int i = 1; i <= n; i++) 
			if (i%2 != id[i]%2) ans++;
		printf("%d\n", ans / 2);
	}
	return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL solve(){
	cin >> H >> W;
	if(H==1 or W==1) return 1;
	if(H*W%2==0) return H*W/2;
	else return H*W/2+1;

	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 13824
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int N, an = 0, count = 0;
	int A[100][100];
	scanf("%d", &N);
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	int k = 0;
	for (int i = 0; i < N; i++) {
		k = 0;
		count = 0;
		for (int j = 0; j < N; j++) {
			if (i == j) {
				count += A[k][j];
				k = 1;
			}
			count += A[k][j];
		}
		if (count > an) {
			an = count;
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128