akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <utility>
#include <climits>
#include <tuple>
using namespace std;
using AnsType = long long int;
const AnsType INF = 1LL << 60;

template <typename numericType, numericType infty = numeric_limits<numericType>::max() >
struct IntervalSet : set< pair<numericType, numericType> > {
  auto get(numericType x) {
    auto itr = this->upper_bound(make_pair(x, infty));
    if(itr == this->begin() or (--itr)->second < x) return this->end();
    return itr;
  }

  vector< pair<numericType, numericType> > get(numericType l, numericType r) {
    auto itr = this->upper_bound(make_pair(l, l));
    if(itr != this->begin()) itr--;

    vector< pair<numericType, numericType> > res;
    for(; itr!=this->end(); itr++) {
      numericType il, ir; tie(il, ir) = *itr;
      if(r < il) break;
      if(ir >= l) res.push_back(make_pair(il, ir));
    }
    return res;
  }

  void insert(numericType l, numericType r) {
    auto vec = this->get(l, r);
    numericType il = l, ir = r;
    for(auto e : vec) {
      this->erase(e);
      il = min(il, e.first);
      ir = max(ir, e.second);
    }
    this->emplace(il, ir);
  }

  void remove(numericType l, numericType r) {
    auto vec = this->get(l, r);
    for(auto e : vec) this->erase(e);
  }
};

int main() {
  int N, Q; cin >> N >> Q;
  vector< pair<AnsType, AnsType> > user;
  vector<int> ord(N);
  for(int i=0; i<N; i++) {
    AnsType val; cin >> val;
    user.emplace_back(val, i);
  }

  sort(user.begin(), user.end());
  for(int i=0; i<N; i++) {
    ord[ user[i].second ] = i;
  }

  set< pair<AnsType, AnsType> > S;
  for(int z=0; z<Q; z++) {
    string s; int x;
    cin >> s >> x;
    if(s == "ADD") {
      --x;
      pair<AnsType, AnsType> pr = user[ ord[x] ];
      S.insert(pr);
    }
    else if(s == "REMOVE") {
      --x;
      pair<AnsType, AnsType> pr = user[ ord[x] ];
      S.erase(pr);
    }
    else if(s == "CHECK") {
      AnsType ub = INF, lb = -1;
      while(ub - lb > 1) {
        AnsType mid = (ub + lb) / 2;
        IntervalSet<AnsType> itvl;
        for(auto e : S) {
          AnsType val = e.first;
          AnsType L = val - mid, R = val;
          itvl.insert(L, R);
        }

        // [L, R]
        int sum = 0;
        for(auto e : itvl) {
          AnsType L, R; tie(L, R) = e;
          int idl = lower_bound(user.begin(), user.end(), make_pair(L, -1LL)) - user.begin();
          int idr = upper_bound(user.begin(), user.end(), make_pair(R, INF)) - user.begin();
          
          int rng = idr - idl;
          for(auto e : S) {
            AnsType val = e.first;
            if(L <= val and val <= R) rng--;
          }

          sum += rng;
        }

        int no = N - S.size() - sum;
        if(no <= x) {
          ub = mid;
        }
        else {
          lb = mid;
        }
      }

      if(ub == INF) {
        cout << "NA" << endl;
      }
      else {
        cout << ub << endl;
      }
    }
    else assert(false);
  }
  return 0;
}



Measured memory_bytes: 23196
#include <cassert>
#include <cstdio>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  ll n;
  scanf("%lld", &n);
  for(ll a = 1; a <= 3500; ++a) {
    for(ll b = 1; b <= 3500; ++b) {
      ll num = n*a*b;
      ll den = (4*a*b - n*a - n*b);
      if(den <= 0) {
        continue;
      }
      if(num % den == 0) {
        printf("%lld %lld %lld\n", a, b, num / den);
        return 0;
      }
    }
  }
  assert(false);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>

int main(void){
    int A[100000],n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    
    int q,key,sum = 0;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d", &key);
        if(*std::lower_bound(A, A + n, key) == key) sum++;
    }
    
    std::cout << sum << std::endl;
    
    return 0;
}



Measured memory_bytes: 3560
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  string a, b;
  cin >> a >> b;
  vector<int> start(26, -1);
  vector<int> goal(26, -1);
  for (int i = 0; i < a.size(); i++) {
    int ca = a[i] - 'a';
    int cb = b[i] - 'a';
    
    if (start[ca] != -1 || goal[cb] != -1) {
      if (start[ca] != cb || goal[cb] != ca) {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      start[ca] = cb;
      goal[cb] = ca;
    }
    
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    ans=0
    for x in range(k,n+2):
        ans+=(1+((n*(n+1)//2-(n-x)*(n-x+1)//2)/x-(x*(x-1)//2)/x)*x)%(10**9+7)
    print(int(ans)%(10**9+7))

if __name__=='__main__':
    main()

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    string S(' ', N);
    cin >> S;
    vector<int> rs, bs;
    set<int> gs;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R')
            rs.emplace_back(i);
        if (S[i] == 'B')
            bs.emplace_back(i);
        if (S[i] == 'G')
            gs.emplace(i);
    }
    ll s = 0;
    for (int i : rs)
        for (int j : bs) {
            int a = i < j ? i : j;
            int b = i + j - a;
            s += gs.size();
            if (gs.count(a + a - b))
                s--;
            if (gs.count(b + b - a))
                s--;
            if ((a + b) % 2 == 0 && gs.count((a + b) / 2))
                s--;
        }
    cout << s << endl;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
using VI  = vector<int>;
using VVI = vector<VI>;
VVI g;
VI dp;
inline void DFS(int x) {
    if (dp[x] > -1)
        return;
    dp[x] = 0;
    for (const int& y : g[x]) {
        DFS(y);
        dp[x] = max(dp[x], dp[y] + 1);
    }
}
int n, m, x, y, res;
int main() {
    DAU
    cin >> n >> m;
    g = VVI(n + 1);
    for (int i = 1; i <= m; ++i) {
        cin >> x >> y;
        g[x].emplace_back(y);
    }
    dp = VI(n + 1, -1);
    for (int i = 1; i <= n; ++i)
        DFS(i);
    for (int i = 1; i <= n; ++i)
        res = max(res, dp[i]);
    cout << res;
    PLEC
}

Measured memory_bytes: 7296
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"yes":"no")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	while(true){
		int n, m, u, v;
		bool flag = true;
		vector<vector<int>> graph;
		vector<int> used;
		
		cin>>n>>m;
		
		if(!n && !m) break;
		
		graph.resize(n+1);
		used.resize(n+1);
		// for(int y : used){
			// cout<<"used "<<y<<endl;
		// }
		
		for(int i = 0; i < m; i++){
			cin>>u>>v;
			graph[u].push_back(v);
			graph[v].push_back(u);
		}
		
		for(int i = 1; i <= n; i++){//cout<<i<<endl;
			if(graph[i].size() > 2){
				flag = false;
				break;
			} else if(graph[i].size() == 1 && used[i] == false){
				int n = graph[i][0];
				used[i] = true;
				
				// cout<<" AA "<<i<<endl;
				while(true){
					// cout<<" BB "<<n<<endl;
					if(graph[n].size() > 2){
						flag = false;
						break;
					} else if(graph[n].size() == 2){
						if(used[graph[n][0]] == false){
							used[n] = true;
							n = graph[n][0];
						} else if(used[graph[n][1]] == false){
							used[n] = true;
							n = graph[n][1];
						} else {
							flag = false;
							break;
						}
					} else if(graph[n].size() == 1){
						used[n] = true;
						break;
					}
				}
				
				if(flag == false) break;
			}
		}
		// cout<<"END"<<endl;
		
		for(int i = 1; i <= n && flag; i++){
			// cout<<i<<endl;
			if(graph[i].size() && used[i] == false){
				flag = false;
			}
		}
		
		
		cout<<yn(flag)<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 8376
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<pair<int, int>> query;

int main()
{
    int N, M;
    cin >> N >> M;
    query.resize(M);
    for (int i = 0; i < M; i++)
    {
        cin >> query[i].first >> query[i].second;
    }

    sort(query.begin(), query.end(), [](const auto &lh, const auto &rh) {
        if (lh.second == rh.second)
        {
            return lh.first < rh.first;
        }
        return lh.second < rh.second;
    });

    int removeCount = 0;
    int lastRemoved = -1;
    for (const auto &q : query)
    {
        if (lastRemoved < q.first)
        {
            lastRemoved = q.second - 1;
            removeCount++;
        }
    }

    cout << removeCount << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

int cost[12];
int a[12][12];

int main()
{
	int n, m, x;
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", cost + i);
		for (int j = 0; j < m; ++j)
		{
			scanf("%d", a[i] + j);
		}
	}
	int ans = 1e9;
	int b[12];
	for (int i = 0; i < (1 << n); ++i)
	{
		std::fill(b, b + m, 0);
		int c = 0;
		for (int j = 0; j < n; ++j)
		{
			if ((i & (1 << j)) != 0)
			{
				c += cost[j];
				for (int k = 0; k < m; ++k)
				{
					b[k] += a[j][k];
				}
			}
		}
		bool ok = true;
		for (int k = 0; k < m; ++k)
		{
			if (b[k] < x)
			{
				ok = false;
				break;
			}
		}
		if (ok && c < ans)
		{
			ans = c;
		}
	}
	if (ans == 1e9)
	{
		ans = -1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
itg=sorted([int(i) for i in input().split()])
a=itg[2]-itg[0]
b=itg[2]-itg[1]
#print(a)
#print(b)
if (a-b)%2==0:
    print(b+((a-b)//2))
else:
    print(b+((a+1-b)//2)+1)

Measured memory_bytes: 3060
n = gets.chomp.to_i
array = gets.split(" ").map(&:to_i)
array_num = []

array.each.with_index(1) do |a, b|
    array_num << [b, a]
end

array_num = array_num.sort {|a,b| a[1] <=> b[1]}
ans = []

n.times do |i|
    ans << array_num[i][0]
end

puts ans.join(' ')


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

int sumOfDigits(int n) {
  int sum = 0;
  while (n / 10 != 0) {
    sum += n % 10;
    n /= 10;
  }
  sum += n;
  return sum;
}

int main() {
  int N; cin >> N;
  if (N % sumOfDigits(N) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        if (a <= k) {
            k -= a;
            a = 0;
            b = Math.max(0, b - k);
        } else {
            a -= k;
        }
        System.out.println(a + " " + b);
    }

}


Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextLine(scanner)

	var k int

	sorted := make(SortBy, len(s))
	for i, l := 0, len(s); i < l; i++ {
		sorted[i].i = i
		sorted[i].s = s[i:]
	}
	sort.Sort(sorted)
	fmt.Sscan(getNextLine(scanner), &k)
	exists := make(map[string]int)

	for i, l := 0, len(s); i < l; i++ {
		for ii, ll := 1, len(sorted[i].s); ii <= ll; ii++ {
			if _, ok := exists[sorted[i].s[0:ii]]; ok {
				continue
			}
			exists[sorted[i].s[0:ii]] = 1
			k--
			if k <= 0 {
				fmt.Fprintln(writer, sorted[i].s[0:ii])
				writer.Flush()
				return
			}
		}
	}

}

type List struct {
	i int
	s string
}

type SortBy []List

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i].s < a[j].s }


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h,a;
    cin>>h>>a;
    int ans = h/a;
    if(h%a!=0) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys


def main():
    num, move, telepote = map(int, input().split())
    data = list(map(int, input().split()))

    ans = 0
    for i in range(num - 1):
        ans += min(telepote, move * (data[i + 1] - data[i]))

    print(ans)



if __name__ == '__main__':
    main()


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

int main() {
  
  vector<int> bng(9);
  for (int i = 0; i < 9; i++) {
    cin >> bng.at(i);
  }
  
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for ( int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
    
  for (int j = 0; j < 9; j++){
    for ( int k = 0; k < N; k++) {
      if (bng.at(j) == vec.at(k)) {
        bng.at(j) = 0;
      }  
    }
  }
  
  if ( bng.at(0)+bng.at(1)+bng.at(2) == 0 || 
       bng.at(3)+bng.at(4)+bng.at(5) == 0 || 
       bng.at(6)+bng.at(7)+bng.at(8) == 0 || 
       bng.at(0)+bng.at(3)+bng.at(6) == 0 ||
       bng.at(1)+bng.at(4)+bng.at(7) == 0 || 
       bng.at(2)+bng.at(5)+bng.at(8) == 0 ||
       bng.at(0)+bng.at(4)+bng.at(8) == 0 || 
       bng.at(2)+bng.at(4)+bng.at(6) == 0 ) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }  
  
}


Measured memory_bytes: 256
class Dice
  #   1
  # 4 2 3 5
  #   6
  attr_reader :pips
  def initialize(*pips)
    @pips = pips
  end

  TN = [
    [0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1],
    [0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0],
  ]
  TE = [
    [0, 0, 0, 1, 0, 0],
    [0, 1, 0, 0, 0, 0],
    [1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1],
    [0, 0, 0, 0, 1, 0],
    [0, 0, 1, 0, 0, 0],
  ]
  TW = [
    [0, 0, 1, 0, 0, 0],
    [0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0],
    [0, 0, 0, 1, 0, 0],
  ]
  TS = [
    [0, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 1],
    [0, 1, 0, 0, 0, 0],
  ]
  TZ = [
    [1, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0],
    [0, 0, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 1],
  ]

  def rotate!(direction)
    pips = case direction
    when :n then TN
    when :e then TE
    when :w then TW
    when :s then TS
    when :z then TZ
    end
    @pips = pips.map do |pips_j|
      @pips.zip(pips_j).map {|i, j| i * j }.inject(:+)
    end
    self
  end

  def rotate_to_top!(index)
    case index
    when 1 then self
    when 2 then self.rotate!(:n)
    when 3 then self.rotate!(:w)
    when 4 then self.rotate!(:e)
    when 5 then self.rotate!(:s)
    when 6 then self.rotate!(:n).rotate!(:n)
    end
  end

  def ==(other)
    other.pips.each.with_index(1) do |pip, idx|
      next unless pip == @pips[0]
      other.rotate_to_top!(idx)
      return true if other.pips == @pips
      3.times do
        other.rotate!(:z)
        return true if other.pips == @pips
      end
    end
    return false
  end
end

dice1 = Dice.new(*gets.split.map(&:to_i))
dice2 = Dice.new(*gets.split.map(&:to_i))

puts dice1 == dice2 ? 'Yes' : 'No'

Measured memory_bytes: 6108
import sys
from math import ceil
def main():
    T1, T2, A1, A2, B1, B2 = map(int, sys.stdin.read().split())
    
    BA1 = A1 - B1
    BA2 = A2 - B2

    if BA1 == 0:
        print(0)
        sys.exit()

    # A1, B1の速い方が速い方をA1とする
    if BA1 < 0:
        BA1 = -BA1
        BA2 = -BA2
    
    d = BA1 * T1 + BA2 * T2
    if d > 0:
        print(0)
        sys.exit()
    if d == 0:
        print('infinity')
        sys.exit()
    
    n = ceil((- BA1 * T1) / d)
    if n * d == - BA1 * T1:
        ans = 2 * n
    else:
        ans = 2 * n - 1
    
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
char s[N];
int n,a[N],t[N];
bool vis[N];
priority_queue<int>q[27],del[27];
void add(int x,int v)
{
    x=n-x+1;
    while(x<=n) t[x]+=v,x+=x&-x;
}
int query(int x)
{
    x=n-x+1;
    int ans=0;
    while(x) ans+=t[x],x-=x&-x;
    return ans;
}
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'a'+1,q[a[i]].push(i),add(i,1);
    int len=n;
    ll ans=0;
    bool flag=len&1;
    for(int i=1;i<=n;i++)
        if(!vis[i])
    {
        del[a[i]].push(i);
        add(i,-1);
        while(!del[a[i]].empty()&&!q[a[i]].empty()&&del[a[i]].top()==q[a[i]].top()) del[a[i]].pop(),q[a[i]].pop();
        if(q[a[i]].empty())
        {
            if(flag)
            {
                len--;
                ans+=len/2;
                flag=false;
                continue;
            }
            else
                {printf("-1\n");return 0;}
        }
        int x=q[a[i]].top();q[a[i]].pop();
        add(x,-1);
        vis[x]=true;
        ans+=query(x);
        len-=2;
    }
    printf("%lld\n",ans);
}


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

int main() {
  string str;
  cin >> str ;
  bool ans=true;
  for (int i=0;i<str.size();i+=2){
    if (str.size()%2==1){
      ans=false;
      break;
    }
    if (str.at(i)!='h' || str.at(i+1)!='i'){
      ans=false;
      break;
    }
  }
  string a= ans==true ? "Yes":"No";
  cout << a << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <sstream>
#include <cstdlib>
using namespace std;

int main(){

  char s[402],G[5][7]={'a','f','k','p','u','z','\0','b','g','l','q','v','.','\0','c','h','m','r','w','?','\0','d','i','n','s','x','!','\0','e','j','o','t','y','&','\0'};
  int i,j,temp,a,b,c;

  


  while(scanf("%s", s)!= EOF){
     temp = strlen(s);
     c=0;
     if(temp==0) continue;
     if(temp %2 == 0) {
       for(i=0;;i+=2){
	 if(s[i]=='\0' || s[i+1]=='\0') break;
	 if(s[i]-'0'<1 || s[i]-'0'>6) c=1;
	 if(s[i+1]-'0'<1 || s[i+1]-'0'>5) c=1;
       }
       if(c==1){
	 printf("NA\n");
	 continue;
       }
       for(i=0; i<temp; i+=2){
	 //a = atoi(s[i+1]);
	 //b = atoi(s[i]);
	 a=s[i+1]-'0';
	 b=s[i]-'0';
	 if(G[a-1][b-1] == '&') printf(" ");
	 else printf("%c",G[a-1][b-1]);
       }
     }else printf("NA");
     printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int num[7], tp;
int main(){
    for(int i = 1; i <= 6; ++i) cin >> num[i];
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); ++i){
        switch(s[i]){
            case 'E': tp = num[1]; num[1] = num[4]; num[4] = num[6]; num[6] = num[3]; num[3] = tp; break;
            case 'N': tp = num[1]; num[1] = num[2]; num[2] = num[6]; num[6] = num[5]; num[5] = tp; break;
            case 'S': tp = num[1]; num[1] = num[5]; num[5] = num[6]; num[6] = num[2]; num[2] = tp; break;
            case 'W': tp = num[1]; num[1] = num[3]; num[3] = num[6]; num[6] = num[4]; num[4] = tp; break;
        }
    }
    cout << num[1] << endl;
    return 0;
}


Measured memory_bytes: 3172
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            Arrays.sort(p);

            for (int i = 0; i < k; i++) {
                ans += p[i];
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 37496
#include <stdio.h>

int solve(int,int);	
int a[2000],b[2000],N,M,x=0;
int main (){

	int i;
	scanf("%d",&N);
	for (i = 0; i < N; i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&M);
	for (i = 0; i < M; i++)
	{
		scanf("%d",&b[i]);
	}

	for (i = 0; i < M; i++)
	{
		if(solve (x,b[i]) == 1) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

int solve(int i,int m){

	int res;

	if (m == 0)
		return 1;
	if (i >= N)
		return 0;
	res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	return res;

}

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a.at(i);
    vector<ll> dp(n);
    map<ll,ll> memo;
    ll sum=0;
    memo[sum]++;
    rep(i,n){
        if(i!=0) dp.at(i)=dp.at(i-1);
        sum+=a.at(i);
        dp.at(i)+=memo[sum];
        memo[sum]++;
    }
    cout<<dp.at(n-1)<<endl;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  bool ok = false;
  for(int i=0;i<SZ(s)-1;++i) {
    if(s[i] == 'A' && s[i+1] == 'C'){
      ok = true;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}


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

typedef long long ll;
#define max 1000006
int arr[max]={};

bool calPrimeFactors(int x){

    if(arr[x]>1){
        return false;
    }
    int temp = sqrt(x);
    for(int i=2; i<=temp; i++){
        if(x%i==0){
            if(arr[i]>0 || arr[x/i]>0) return false;
        }
    }
    return true;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    int temp;
    unordered_map<int,int> umap;
    for(int i=0; i<n; i++){
        cin >>temp;
        arr[temp]++;
        umap[temp]++;
    }

    if(arr[1]==1) cout<<1<<'\n';
    else if(arr[1]>1) cout<<0<<'\n';
    else{
        int count=0;
        for(auto x: umap){
            if(calPrimeFactors(x.first)) count++;
        }
        cout<<count<<'\n';
    }

    return 0;
}


Measured memory_bytes: 14688
n = gets.to_i
h = Hash.new(0)
n.times do |i|
    h[gets.chomp] += 1
end

# p h

l =  h.sort {|a,b| a[1]<=>b[1]}.reverse

ans = []
m = l[0][1]
l.each do |v|
    if v[1] == m
        ans << v[0]
    else
        break
    end
end

puts ans.sort

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    REP(i, S.length() - 1) {
        if (S[i] != S[i + 1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}

int log(int x) {
    int i;
    for(i=0;(1ll<<i)<=x;i++);
    return i;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int a,b;
    cin >> a >> b;
    int ar[a];
    int c=0;
    fff(i,a)
    cin >> ar[i];
   
   sort(ar,ar+a);
   
   fff(i,a) {
       if(b>=ar[i]) {
           c++;
           b-=ar[i];
       } 
   }
   if(c==a and b>0)
   c--;
    
    cout << c;
    
	return 0;
    
}


Measured memory_bytes: 8832
N = gets.to_i
a = 0
ar = []
max = 0
max_index = 0
max_dup_flag = false
N.times do |i|
  a = gets.to_i
  ar << a
  if max < a
    max_index = i
    max_dup_flag = false
    max = a
  elsif max == a
    max_dup_flag = true
  end
end

if max_dup_flag
  N.times do |i|
    puts max
  end
else
  N.times do |i|
    if i == max_index
      puts ar.sort[-2]
    else
      puts max
    end
  end
end


Measured memory_bytes: 8224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,d,e,n;
	cin>>n;
	cin>>a>>b>>c>>d>>e;
	ll mn=min({a,b,c,d,e});
	ll ans=(n-1)/mn+1+4;
	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	double A, B;
	cin >> A >> B;

	cout << A / B << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
long long Read() {
    long long x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9') {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}
long long num[10];
int main(){
    int n=Read();
    num[0]=2,num[1]=1;
    if(n<=1) {
    	cout<<num[n]<<endl;
    	return 0;
	}
    for(int i=2;i<=n;i++){
    	  num[2]=num[0]+num[1];
    	  num[0]=num[1];
    	  num[1]=num[2];
	}
	cout<<num[2]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int,int>;
using vii = vector<pii>;
using vvii = vector<vii>;


int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    vi eastsum(N+1), westsum(N+1);
    westsum[0] = 0;
    for (int i = 0; i < N; ++i)
    {
        int d = ((S[i] == 'W') ? 1 : 0);
        westsum[i+1] = westsum[i] + d;
    }
    eastsum[N] = 0;
    for (int i = N - 1; i >= 0; --i)
    {
        int d = ((S[i] == 'E') ? 1 : 0);
        eastsum[i] = eastsum[i+1] + d;
    }
    
    int min_ninzu = N+1;
    for (int l = 0; l < N; l++)
    {
        int ninzu = westsum[l] + eastsum[l+1];
        min_ninzu = min(min_ninzu, ninzu);
    }
    cout << min_ninzu << endl;    
    
    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <string.h>
int main (void){
    char str[11];
    scanf("%s",str);
    //printf("%s",str);
    int i;
    int length = 0;
    int length_max = 0;
    for(i=0;i<strlen(str);i++){
        if(str[i] != 'A' &&
            str[i] != 'C' &&
            str[i] != 'G' &&
            str[i] != 'T'){
              length = 0;  
        }else{
            length++;
            if(length >length_max){
                length_max = length;
            }
        }
    }
    printf("%d",length_max);
    
}

Measured memory_bytes: 2152
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  string a, b, c;
  cin >> a >> b >> c;
  int ai = 0, bi = 0, ci = 0;
  bool first = true;
  char det;
  while(true) {
    if (det == 'a' or first) {
      first = false;
      if (ai < a.size()) {
        det = a[ai];
        ai++;
      } else {
        D('A');
        return 0;
      }
    } else if (det == 'b') {
      if (bi < b.size()) {
        det = b[bi];
        bi++;
      } else {
        D('B');
        return 0;
      }
    } else {
      if (ci < c.size()) {
        det = c[ci];
        ci++;
      } else {
        D('C');
        return 0;
      }
    }
  }

  return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdint>

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            auto r = min(k - j, a[i + 1] - a[i]);
            auto mc = a.back()  - a[i + 1];
            for (auto b : irange(1L, mc + r + 1)) {
                for (auto c : irange(max(0L, b - r), min(b, mc + 1))) {
                    auto w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (auto i : irange(0L, mk + 1)) {
        ans += dp[i][0];
    }

    cout << ans % M << "\n";
}


Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A,B; cin >> A >> B;
    rng(i,1,2000){
        if(floor(i*0.08)==A && floor(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

int main() {
    int n;
    int x[8];
    int y[8];

    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];

        //pair
        p[i] = i;
    }

    long double distance = 0;
    int divisor = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            //cout << p[i] << p[i+1] << endl;
            int left  = pow(x[p[i]] - x[p[i+1]],2);
            int right = pow(y[p[i]] - y[p[i+1]],2);
            //cout << left << right << endl;

            distance += sqrt(left + right);
            //cout << sqrt(left + right) << endl;
        }
        divisor += 1;
        //cout << test++ << endl;

    } while(next_permutation(p.begin(), p.end()));

    long double ret =  distance / divisor;
    //cout << divisor << endl;
    cout << setprecision(12) << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/* ex3_3
   tamayama */

#include<stdio.h>
 int main (void){
 
    int N,K;
    int input_K;
    int digit=1;
    scanf("%d %d",&N,&K);
    input_K = K;

    while(K <= N){  /*Nを超えないように何回KをK倍したかを求める*/
    K = input_K*K;  /*もとのKの値をinput_KとおいてKと区別*/
    digit++;
    }
    printf("%d\n",digit);

    return 0;
}


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

int main() {
	int s;
	cin >> s;
	int forward = s / 100;
	int back = s % 100;

	if (forward > 12 && back > 12) cout << "NA" << endl;
	else if (forward > 12 && back == 0)  cout << "NA" << endl;
	else if (forward == 0 && back > 12) cout << "NA" << endl;
	else if (forward == 0 && back == 0) cout << "NA" << endl;
	else if (forward <= 12 && back > 12) cout << "MMYY" << endl;
	else if (forward > 12 && back <= 12) cout << "YYMM" << endl;
	else if (forward <= 12 && back == 0) cout << "MMYY" << endl;
	else if (forward == 0 && back <= 12) cout << "YYMM" << endl;
	else cout << "AMBIGUOUS" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_v(h, w, 0);
    auto v2 = v;
    for (int i = 1; i < h-1; ++i) {
        if(i&1){
            for (int j = 1; j < w-1; ++j) {
                v[i][j] = 1;
            }
        }else {
            if(i&2){
                v[i][1] = 1;
            }else {
                v[i][w-2] = 1;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            v2[i][j] = 1-v[i][j];
            if(s[j] == '#'){
                v2[i][j] = v[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << (v[i][j] ? '#' : '.');
        }
        cout << "\n";
    }
    cout << "\n";
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << (v2[i][j] ? '#' : '.');
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	int d,m;
	cin >> d;
	vector<int> c(26), l(26), t(d);
	rep(i, 26) cin >> c[i];

	vector<vector<int>> s(d, vector<int>(26));

	rep(i, d) {
		int now = 0;
		int nowi = 0;
		rep(j, 26) {
			cin >> s[i][j];
			if (now < s[i][j]) {
				now = s[i][j];
				nowi = j;
			}
		}
		t[i] = nowi;
	}
	int best = 0;
	rep(i, d) {
		int x = t[i];
		best += s[i][x];
		l[x] = i + 1;
		rep(j, 26) {
			if (j == x)continue;
			best -= c[j] * (i + 1 - l[j]);
		}
	}
	l = vector<int>(26);
	rep(di,d){
		int maxi = t[di];

		rep(i, 26) {
			t[di] = i;
			int ans = 0;
			rep(i, d) {
				ans += s[i][t[i]];
				l[t[i]] = i + 1;
				rep(j, 26) {
					if (j == t[i])continue;
					ans -= c[j] * (i + 1 - l[j]);
				}
			}
			if (best < ans) {
				best = ans;
				maxi = i;
			}
			l = vector<int>(26);
		}
		t[di] = maxi;
	}
	rep(i, d) cout << t[i]+1 << endl;
}


Measured memory_bytes: 3684
a,b,x=map(int,input().split())
import math
if 0.5*a*a*b>=x:
  print(math.degrees(math.atan(0.5*a*b*b/x)))
else:
  c=2*(b-(x/(a**2)))
  print(math.degrees(math.atan(c/a)))







Measured memory_bytes: 2940
n = int(input())
s = input()

a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
p = ''
for i in range(len(s)):
  x = a.find(s[i])
  x += n
  if x <= 25:
    p += a[x]
  else:
    p += a[x-26]
print(p)

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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> d.at(i);
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      ans += d.at(i) * d.at(j);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int fun(int n, int m, vector<int> c) {
    int dp[n+1]; mset(dp, 0); dp[0] = 1;
    for(int i = 1; i <= n; ++i){
        for(int x : c){
            int to_add;
            if(i-x < 0) to_add = 0;
            else to_add = dp[i-x];
            
            dp[i] = (dp[i] + to_add) % MOD;
        }
    }
    return dp[n];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in6.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T = 1;
    // cin >> T;
    
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int s; cin >> s;
        vector<int> coins;
        for(int i = 3; i <= s; ++i){
            coins.pb(i);
        }
        cout << fun(s, coins.size(), coins);
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3704
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 


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

	for (int i = 0; i < N; i++) {
		if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
		}
	}

	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
X_sum = sum(X)

if X_sum % N == 0:
    div = X_sum // N
    ans = 0
    for i in range(N):
        ans += (X[i] - div) ** 2
    print(ans)
else:
    # print(X_sum / N)
    div_1 = X_sum // N
    ans_1 = 0
    for i in range(N):
        ans_1 += (X[i] - div_1) ** 2

    div_2 = X_sum // N + 1
    ans_2 = 0
    for i in range(N):
        ans_2 += (X[i] - div_2) ** 2
    print(min(ans_1, ans_2))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
int sum,digit;
signed main(){
	int m,d,c;
	cin>>m;
	while(m--){
		cin>>d>>c;
		digit+=c;
		sum+=d*c;
	}
	int ans=digit-1+(sum-1)/9;
	cout<<ans;
	return 0;
} 

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

int main() {
  int N, K;
  string S;
  cin >> N >> S >> K;

  rep(i, N) {
    if (S[i] != S[K - 1])
      cout << '*';
    else
      cout << S[i];
  }

  return 0;
}

Measured memory_bytes: 3624