akhauriyash/Code-Regression huggingface dataset:
N = int(input().strip())
D = list(map(int, input().strip().split()))
tmpD = D[1:]
tmpD = sorted(tmpD)




# D[0]!=0ならば0
if D[0] != 0 or tmpD[0] == 0:
    print(0)
else:
    ans = 1
    max_depth = max(tmpD)
    count = [0] * (max_depth+1)
    for num in tmpD:
        count[num]+=1
    for i in range(1, max_depth):
        ans *= (count[i]**count[i+1])
        ans %= 998244353
    print(ans)


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int main() {
  std::cout << std::setprecision(9);
  double w, h;
  int x, y;
  cin >> w >> h >> x >> y;

  double area = w * h / 2.0;
  if (x * 2 == w && y * 2 == h) {
    cout << area << ' ' << 1 << endl;
  }
  else {
    cout << area << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 256
#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>;
const int INF = 1000000007;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i, h) {
    rep(j, w) { cin >> c[i][j]; }
  }
  int res = 0;
  for (int bit = 0; bit < (1 << h + w); ++bit) {
    int total = 0;
    vector<string> a(h);
    rep(i, h) rep(j, w) a[i][j] = c[i][j];
    for (int i = 0; i < h + w; ++i) {
      if (bit & (1 << i)) {
        if (i < h) {
          for (int j = 0; j < w; j++) {
            a[i][j] = 'r';
          }
        } else {
          for (int j = 0; j < h; j++) {
            a[j][i - h] = 'r';
          }
        }
      }
    }
    rep(i, h) rep(j, w) {
      if (a[i][j] == '#') total++;
    }
    if (total == k) res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3588
// D - Ki

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct Node {
	int d_counter = 0;
	int counter = 0;
	int parent = 0;
	vector<int> neibours;
};

// 親をセット
void set_parent(vector<Node>& nodes, int i, int parent) {
	nodes[i].parent = parent;
	for (int neibour : nodes[i].neibours) {
		if (neibour == parent) continue;
		set_parent(nodes, neibour, i);
	}
}

// カウンターの増分をセット
void add_d_counter(vector<Node>& nodes, int p, int x) {
	nodes[p].d_counter += x;
}

// カウンターの実際の値を増分から計算
void calc_counter(vector<Node>& nodes, int i) {
	Node& node = nodes[i];
	Node& parent_node = nodes[node.parent];

	node.counter = parent_node.counter + node.d_counter;
	for (int neibour : node.neibours) {
		if (neibour == node.parent) continue;
		calc_counter(nodes, neibour);
	}
}

// 最終結果の表示
void print_counter(vector<Node>& nodes) {
	bool first = true;
	for (int i=1; i<nodes.size(); i++) {
		if (i > 1) cout << " ";

		cout << nodes[i].counter;
	}

	cout << endl;
}

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

	vector<Node> nodes(N+1); // nodes[0]はdummy node

	int a, b;
	for (int i=1; i<N; i++) {
		cin >> a >> b;
		nodes[a].neibours.push_back(b);
		nodes[b].neibours.push_back(a);
	}

	set_parent(nodes, 1, 0);

	int p, x;
	for (int i=0; i<Q; i++) {
		cin >> p >> x;
		add_d_counter(nodes, p, x);
	}

	calc_counter(nodes, 1);

	print_counter(nodes);

	return 0;
}

Measured memory_bytes: 25856
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int A, B, T; cin >> A >> B >> T;

    int ans = T/A * B;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	ds := 0
	for num := n; num > 0; num /= 10 {
		ds += num % 10
	}
	
	if n % ds == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

suma = sum(a)

anslist = []
anslist.append(suma)
for i in range(1, n -1, 2):
    anslist[0] -= 2 * a[i]

for i in range(1, n):
    anslist.append(2 * a[i - 1] - anslist[i - 1])

for ans in anslist:
    print(ans)

Measured memory_bytes: 14092
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;

int main(){
    int N,H,W;
    cin >> N >> H >> W;
    cout << (N+1-H)*(N+1-W);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main(){
    double a,b;
    cin >> a >> b;
    cout  << ceil((a+b)/2) << endl;

    return 0;
}

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

const int max_N = 2000 + 21;

const int mod = 924844033;

int n,k,ans,siz[max_N],fac[max_N];

int f[max_N],g[max_N][max_N][4];

int getG(int i,int j){
	return (g[i][j][0]+g[i][j][2])%mod;
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i)++siz[i%k];
	g[1][0][0]=1;
	g[1][1][1]=1;
	for(int i=2;i<=n;++i)
		for(int j=0;j<=i;++j){
			g[i][j][0]=(g[i-1][j][0]+g[i-1][j][2])%mod;
			g[i][j][2]=(g[i-1][j][1]+g[i-1][j][3])%mod;
			if(!j)continue;
			g[i][j][0]=(g[i][j][0]+g[i-1][j-1][0])%mod;
			g[i][j][1]=(g[i-1][j-1][0]+g[i-1][j-1][2])%mod;
			g[i][j][2]=(g[i][j][2]+g[i-1][j-1][1])%mod;
			g[i][j][3]=(g[i-1][j-1][1]+g[i-1][j-1][3])%mod;
		}
	f[0]=1;
	for(int x=0;x<k;++x)
		for(int i=n;i;--i)
			for(int j=1;j<=i&&j<=siz[x];++j){
				f[i] = (f[i] + 1ll*f[i-j]*getG(siz[x],j)) % mod;
			}
	fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=0;i<=n;++i){
		int tmp=1ll*f[i]*fac[n-i]%mod;
		if(i&1)ans=(ans-tmp+mod)%mod;
		else ans=(ans+tmp)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 61952
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

c = 0
for i in range(N):
    if a[i] == c+1:
        c += 1
if c > 0:
    print(N-c)
else:
    print(-1)

Measured memory_bytes: 105416
a, v = gets.to_s.split.map{|t| t.to_i }
b, w = gets.to_s.split.map{|t| t.to_i }
t    = gets.to_s.to_i

d = ( a - b ).abs

if v <= w || d > (v-w) * t
  puts "NO"
else
  puts "YES"
end

Measured memory_bytes: 14336
import bisect
INF = 10 ** 18
a, b, Q = map(int, input().split())
s = [-INF] + [int(input()) for i in range(a)] + [INF]
t = [-INF] + [int(input()) for i in range(b)] + [INF]
for q in range(Q):
  x = int(input())
  s_idx = bisect.bisect_left(s, x)
  t_idx = bisect.bisect_left(t, x)
  ans = INF
  for i in [s_idx, s_idx-1]:
    for j in [t_idx, t_idx-1]:
      temp1 = abs(s[i] - x) + abs(s[i] - t[j])
      temp2 = abs(t[j] - x) + abs(s[i] - t[j])
      ans = min(ans, temp1, temp2)
  print(ans)
      


Measured memory_bytes: 14612
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
using namespace std;

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


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

int decode(std::string key){
    int sum = 0;
    int k = 1;
    for(int i = 0; i < key.size(); i++){
	char c = key.at(i);
	switch(c){
	case 'A': sum += k * 1; break;
	case 'C': sum += k * 2; break;
	case 'G': sum += k * 3; break;
	case 'T': sum += k * 4; break;
	}
	k = k * 5;
    }
    return sum;
}

const int M = 1046527;

int h1(int x){
    return x % M;
}
int h2(int x){
    return 1 + (x % (M - 10));
}
int h(int x, int i){
    return (h1(x) + i * h2(x)) % M;
}

int my_insert(std::vector<int> &map, std::string key){
    int x = decode(key);
    int i = 0;
    for(;;){
	int j = h(x, i);
	if(map.at(j) == -1){
	    map.at(j) = x;
	    return j;
	}else{
	    i = i + 1;
	}
    }
}

int my_find(std::vector<int>&map, std::string key){
    int x = decode(key);
    int i = 0;
    for(;;){
	int j = h(x, i);
	if(map.at(j) == x){
	    return j;
	}else if(map.at(j) == -1 || i >= M){
	    return -1;
	}else{
	    i = i + 1;
	}
    }
}

int main(int argc, char **argv){

    std::vector<int> map(16*1024*1024, -1); // (4)^12

    int N;
    std::cin >> N;

    std::vector<std::string> result;
    
    for(int i = 0; i < N; i++){
	std::string command;
	std::string key;
	std::cin >> command >> key;
	if(command == "insert"){
	    my_insert(map, key);
	}else if(command == "find"){
	    if(my_find(map, key) >= 0){
		result.push_back("yes");
	    }else{
		result.push_back("no");
	    }
	}
    }

    for(int i = 0; i < result.size(); i++){
	std::cout << result.at(i) << std::endl;
    }
    
}



Measured memory_bytes: 91872
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
using ll=long long;
const ll MOD=100000007;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return (v[(size / 2) - 1] + v[size / 2]) / 2;
}


int main(){
    string s;
    cin>>s;
    const string t="CODEFESTIVAL2016";
    ll cnt=0;
    rep(i,0,s.size()){
        if (s[i]!=t[i]) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    vector<int> v;

    rep(_, 0, 2) {
        cin >> N;
        rep(i, 0, N) {
            int h, m; cin >> h >> m;
            v.push_back(h * 60 + m);
        }
    }
    
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    rep(i, 0, v.size()) {
        if (i) printf(" ");
        printf("%d:%02d", v[i] / 60, v[i] % 60);
    }
    printf("\n");
}



Measured memory_bytes: 3300
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

ll sum(ll a, ll l, ll d) {
    ll n = (l - a) / d + 1;
    return n * (a + l) / 2LL;
}

int main() {
    ll N;
    cin >> N;

    ll res = 0;
    ll i;
    for (i=1; i<=N; ++i) {
        res += sum(i, (N/i)*i, i);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3596
def run(n, k, x):
    # ri = 0
    # li = k-1
    # if n == 1:
    #    return x[0]
    # x2 = x
    ret = abs(x[0]) + abs(x[0] - x[k-1])
    for i in range(n-k+1):
        ri = i
        li = i + k - 1
        tmp = min(abs(x[ri]) + abs(x[ri] - x[li]), abs(x[li]) + abs(x[ri] - x[li]))
        ret = min(ret, tmp)
        '''
        if x[ri] > x[i]:
        elif x[ri] == x[i]:
            if x[ri+1] < x[i-1]:
                ri = i-k+1
                li = i
        else:
            if x2[li] <= 0:
                return x[ri]
            elif x2[ri] >= 0:
                return x[li]
            elif x[ri] > x[li]:
                return x[ri] + 2*x[li]
            else:
                return 2*x[ri] + x[li]
    if x2[li] <= 0:
        return x[ri]
    elif x2[ri] >= 0:
        return x[li]
    elif x[ri] > x[li]:
        return x[ri] + 2*x[li]
    else:
        return 2*x[ri] + x[li]
        '''
    return ret


def read_line():
    n, k = map(int, input().split())
    x = list(map(int, input().split()))
    return (n, k, x)


def main():
    n, k, x = read_line()
    print(run(n, k, x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

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

    int l[100];
    fill(l, l, 0);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l, l+n);
    int dist = numeric_limits<int>::max();
    for(int p = 1; p <= 100; p++){
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum += pow(l[i] - p, 2);
        }
        dist = min(dist, sum);
    }

    cout << dist << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc157/tasks/abc157_e

class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

sc = iter(open(0).read().split())
ni = lambda: int(next(sc))
ns = lambda: next(sc)

N, S, Q = ni(), list(ns()), ni()

B = [BIT(N) for _ in range(26)]
for i, s in enumerate(S, 1):
    B[ord(s) - ord('a')].add(i, 1)

A = []
for _ in range(Q):
    if ni() == 1:
        i, c = ni(), ns()
        B[ord(S[i - 1]) - ord('a')].add(i, -1)
        S[i - 1] = c
        B[ord(c) - ord('a')].add(i, 1)
    else:
        l, r = ni(), ni()
        A.append(sum(b.sum(l - 1) < b.sum(r) for b in B))

print("\n".join(map(str, A)))

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ull H, W;
    cin >> H >> W;
    ull ans = INT_MAX;
    for (int i = 1; i < H; i++) {
        ull b1 = i * W;
        if (H - i == 1) {
            ull a = W / 2;
            ull b = W - a;
            ull b2 = a;
            ull b3 = b;
            ull areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
        } else {
            ull h = H - i;
            ull a = h / 2;
            ull b = h - a;
            ull b2 = a * W;
            ull b3 = b * W;
            ull areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
            a = W / 2;
            b = W - a;
            b2 = a * h;
            b3 = b * h;
            areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
        }
    }
    swap(H, W);
    for (int i = 1; i < H; i++) {
        ull b1 = i * W;
        if (H - i == 1) {
            ull a = W / 2;
            ull b = W - a;
            ull b2 = a;
            ull b3 = b;
            ull areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
        } else {
            ull h = H - i;
            ull a = h / 2;
            ull b = h - a;
            ull b2 = a * W;
            ull b3 = b * W;
            ull areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
            a = W / 2;
            b = W - a;
            b2 = a * h;
            b3 = b * h;
            areaD = max(b1, max(b2, b3)) - min(b1, min(b2, b3));
            ans = min(ans, areaD);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - XXFESTIVAL
https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_a

"""
import sys


def solve(S):
    return S[:-8]


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL K;

vector<LL> ans;

void solve(){
	const LL N = 50;
	ans = vector<LL>(N,0);
	for(int i=0;i<N;i++){
		ans[i] = (N-1 + K/N - K%N);
	}
	for(int i=0;i<K%N;i++){
		ans[i] += (N+1);
	}
}
 
int main(){
    cin >> K;
 
    solve();

    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++)cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  int a,b,m,n;
  /*二つの自然数を入力*/
  scanf("%d",&a);
  scanf("%d",&b);
  /*自然数a<bを入れ替えて計算を統一*/
  if(a<b){
    n=a;
    a=b;
    b=n;
  }
  /*ユークリッドの互除法を使う*/
  m=a%b;
  
  while(m!=0){
    a=b;
    b=m;
    m=a%b;}
  /*最大公約数出力*/
  printf("%d\n",b);
  return 0;}



Measured memory_bytes: 2736
#include <iostream>
#include <cstdio>
#include <string>
#include <map>

using namespace std;

int main()
{
    int n, i;
    char str[10], com[13];
    map<string, bool> T;

    cin >> n;
    for (i = 0; i < n; i++) {
        scanf("%s%s", com, str);
        if (com[0] == 'i') T[string(str)] = true;
        else {
            if (T[string(str)]) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}


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

#define LL long long

const int maxN = 1e5 + 10;

int n;
LL a[maxN + 1], ans;
LL L[maxN + 1], R[maxN + 1];

int main()
{
	scanf("%d", &n);
	for(int i = 0; i <= n; i++) scanf("%lld", &a[i]);

	if(n == 0) 
	{ 
		if(a[0] != 1) puts("-1");
		else puts("1"); 
		return 0; 
	}
	if(a[0]) { puts("-1"); return 0; }

	L[n] = R[n] = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		R[i] = R[i + 1] + a[i + 1];
		L[i] = (a[i + 1] + L[i + 1] + 1) / 2;
	}

	L[0] = R[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		R[i] = min(R[i], 2ll * R[i - 1] - a[i]);
		L[i] = max(L[i], L[i - 1] - a[i]);
	}

	for(int i = 0; i <= n; i++)
		if(L[i] > R[i]) { puts("-1"); return 0; }
	
	LL ans = 0;
	for(int i = 0; i <= n; i++) ans += R[i] + a[i];

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6168
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

class Edge{
public:
	int to;
	bool is_passed;

	Edge() : to(-1), is_passed(false){
		return;
	}
	~Edge(){
		return;
	}
};



int main(int argc, char **argv){
	std::vector<std::vector<Edge> > edges(101);
	int a, b;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> a >> b){
#else
	while(std::cin >> a >> b){
#endif
		if(a == 0 && b == 0){ 
			bool can_patrol = true;

			if(edges[1].size() % 2 == 0){
				can_patrol = false;
			}
			else if(edges[2].size() % 2 == 0){
				can_patrol = false;
			}
			else{
				for(int i = 3; i < edges.size(); i++){
					if(edges[i].size() % 2 == 1){
						can_patrol = false;
						break;
					}
				}
			}

			if(can_patrol){
				std::cout << "OK" << std::endl;
			}
			else{
				std::cout << "NG" << std::endl;
			}
			edges.clear();
			edges.resize(101);
			continue;
		}
		Edge e;
		e.to = b;
		edges[a].push_back(e);
		e.to = a;
		edges[b].push_back(e);
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3096
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }



    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);


        var input = Reads();
        var n = input[0];
        var k = input[1];
        var input0 = Reads();
        var h = new long[n];
        var count = 0;
        for(int i = 0; i < n; i++)
        {
            h[i] = input0[i];
            if (h[i] >= k)
                count++;
        }
        Console.WriteLine(count);



        Console.Out.Flush();
    }
}

Measured memory_bytes: 21216
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int month = sc.nextInt();
    int date = sc.nextInt();
    int month2 = sc.nextInt();
    int date2 = sc.nextInt();
    
    if(month2 == month+1){
      System.out.println(1);
    }else{
      System.out.println(0);
    }
  }
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	string T = S;
	reverse(all(T));
	int ans = 0;
	rep(i, S.size()) {
		if (S[i] != T[i]) ans++;
	}
	cout << ans / 2 << endl;
	return 0;
}

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

#define ll long long
#define pb push_back
vector<int>vc;
int n,dp[100009],m,k;

int DP(int ind)
{
    if(ind==n-1)return 0;
    if(~dp[ind])return dp[ind];
    int x=1e9+9;
    for(int i=1;i<=k&&i+ind<n;i++)x=min(x,DP(ind+i)+abs(vc[i+ind]-vc[ind]));
        return dp[ind]=x;
}

int main()
{
    ios_base::sync_with_stdio(false);  cin.tie(NULL);
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)cin>>m,vc.pb(m);
    cout<<DP(0)<<"\n";
    return 0;
}



Measured memory_bytes: 7416
def main():
    q = int(input().split()[1])
    s = input()
    a = make_array(s)
    for i in range(q):
        l, r = [int(x) - 1 for x in input().split()]
        print(a[r] - a[l])

def make_array(s):
    array = []
    ac_count = 0
    a_flag = False
    for c in s:
        if c == "A":
            a_flag = True
        elif c == "C":
            if a_flag:
                ac_count += 1
                a_flag = False
        else:
            a_flag = False

        array.append(ac_count)

    return array


if __name__ == '__main__':
    main()


Measured memory_bytes: 6152
#include<stdio.h>
int main(void)
{
	int j,a[101],b[100],i,n,z[99],k,flg;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		n++;
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(k=0;k<n;k++){
			j=0;
			for(i=0;i<n;i++){
				if(k!=i){
					b[j]=a[i];
					j++;
				}
			}
			j=0;
			for(i=1;i<n-1;i++){
				z[j]=b[i]-b[i-1];
				j++;
			}
			flg=1;
			for(i=0;i<n-2;i++){
				if(z[0]!=z[i]){
					flg=0;	
					break;
				}
			}
			if(flg==1){
				break;
			}
		}
		printf("%d\n",a[k]);
	}
	return 0;
}

Measured memory_bytes: 2716
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

const int nmax = 100100;
int N, M, Q;
int ans[510][510];
void read(){
    cin >> N >> M >> Q;
    for(int i=0;i < M; ++i){
        int L, R;
        cin >> L >> R;
        ++ans[R-L+1][L];
    }
}

void solve(){
    for(int i = 1; i<=N; ++i)
        for(int j = 1;j <= N; ++j)
            ans[i][j] += ans[i][j-1];
    for(int i =0; i< Q; ++i)
    {
        int L,R;
        cin >> L >> R;
        int answer = 0;
        for(int j = 1; j<=(R-L+1); ++j)
        {
           answer +=  ans[j][R-j+1] - ans[j][L-1];
        }
        cout << answer << endl;
    }
}

int main(){
    read();
    solve();
}

Measured memory_bytes: 1920
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int N=Integer.parseInt(br.readLine());
		StringBuilder sb=new StringBuilder();
		for(int i=1;i<=N;i++){
			int x=i;
			if(x%3==0||check3(i, Integer.toString(i).length())) sb.append(" "+i);
		}
		System.out.println(sb);
	}
	
	private static boolean check3(int n, int k){
		boolean res=false;
		int t=(int)Math.pow(10, k-1);
		if(n/t==3){
			res=true;
		}else if(k>1){
			res=check3(n%t, k-1);
		}
		return res;
	}
}

Measured memory_bytes: 23172
n,m=map(int, input().split())
h=list(map(int, input().split())) 

s = l = [n-1] * n
cnt = 0

for i in range(m):
    a,b=map(int, input().split())
    if h[a-1] < h[b-1]:
        s[a-1] = s[a-1] - 1
    elif h[a-1] > h[b-1]:
        s[b-1] = s[b-1] - 1
    else:
        s[a-1] = s[a-1] - 1
        s[b-1] = s[b-1] - 1

for i in range(n):
    if s[i] == n-1:
        cnt = cnt + 1 

print(cnt)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/20  Problem: ABC 051 C / Link: http://abc051.contest.atcoder.jp/tasks/abc051_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

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

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int U = ty - sy;
	int D = U;
	int R = tx - sx;
	int L = R;
	string US = string(U, 'U');
	string DS = string(D, 'D');
	string RS = string(R, 'R');
	string LS = string(L, 'L');
	string ans = "";

	ans = US + RS + DS + LS + "LU" + US + RS + "RDRD" + DS + LS + "LU";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int N,K,zj;
bool visit[10],tf;
int main()
{
	scanf("%d %d",&N,&K);
	for(int i=1,D;i<=K;i++)
	{
		scanf("%d",&D);
		visit[D]=true;
	}
	while(!tf)
	{
		tf=true;
		zj=N;
		while(zj!=0)
		{
			if(visit[zj%10])
			{
				tf=false;
				break;
			}
			zj/=10;
		}
		N++;
	}
	printf("%d",N-1);
	return 0;
}

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

using namespace std;

int tst_A[100001];

int main(){
    int n,q;
    int k,count;

    count = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        scanf("%ld",&tst_A[i]);
    }
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        scanf("%ld",&k);
        if (*lower_bound(tst_A,tst_A+n,k) == k) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a,b;
	int mx;
	char res;
	while(a=in(),b=in()){
		mx=a+b;
		res='A';
		int i;
		for(i=1;i<5;i++){
			a=in(),b=in();
			if(mx<a+b){
				mx=a+b;
				res='A'+i;
			}
		}
		cout<<res<<" "<<mx<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	int num;
	cin >> num;
	queue <int> p[num];

	int opr;
	cin >> opr;
	while (opr--)
	{
		int oper;
		cin >> oper;
		switch(oper)
		{
			int num;
		case 0:
		    cin>>num;
			int integrate;
			cin >> integrate;
			p[num].push(integrate);
			break;
		case 1:
		    cin>>num;
			if(p[num].empty()==false)
                cout<<p[num].front()<<endl;
			break;
		case 2:
		    cin>>num;
		    if(p[num].empty()==false)
			p[num].pop();
			break;
		}
	}

}



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

using namespace std;

using ll = long long;
using ld = long double;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  map<ll, ll> m;

  rep(i, n) {
    m[a[i]]++;
  }
  FORm(it, m) {
    if (it->second > 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 14336
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;
int n;
string s,t;

pi ps[1000005];

void ng(){
  puts("-1");
  exit(0);
}

int main(){
  cin>>n>>s>>t;
  if(s==t){
    puts("0");
    return 0;
  }

  int q=n-1;
  int m=0;
  for(int i=n-1;i>=0;--i){
    int j=i;
    while(j>=0 && t[j]==t[i]) --j;

    int p=i;
    q=min(j+1,q);
    while(q>=0 && s[q]!=t[p]) --q;

    if(q<0) ng();

    ps[m++]=mp(q,p);
    if(p<q) ng();

    i=j+1;
  }
  ps[m++]=mp(INF,0);
  sort(ps,ps+m);

  int lb=-1,ub=n+1;
  while(ub-lb>1){
    int md=(lb+ub)>>1;
    bool fail=false;
    REP(i,m-1){
      int trg=ps[min(m-1,i+md)].fr-md;
      if(trg<ps[i].sc) fail=true;
    }
    if(fail) lb=md;
    else ub=md;
  }
  printf("%d\n",ub);
  return 0;
}





Measured memory_bytes: 10120
N = int(input())

S = [""]*N

for i in range(N):
    S[i] = input()
    
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

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

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

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

    return result
  
  
S_set = ["".join(sorted(s)) for s in S]


import collections
import itertools

same_list = collections.Counter(S_set)

ans = [0]*len(same_list)

for i,v in enumerate(same_list.values()):
    if i==0:
        if v==1:
            ans[i] = 0
        else:
            ans[i] = cmb(v, 2)
    else:
        if v==1:
            ans[i] = ans[i-1] + 0
        else:
            ans[i] = ans[i-1] + cmb(v, 2)

print(ans[-1])

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

using namespace std;

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

    if(S == "A"){
        cout << "T" << endl;
    }else if(S == "C"){
        cout << "G" << endl;
    }else if(S == "G"){
        cout << "C" << endl;
    }else{
        cout << "A" << endl;
    }

    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int l, r, d;
    cin >> l >> r >> d;
        
    int ans = 0;
    irep2(i,l,r) {
        if(i % d == 0) { ans++; }
    }
    cout << ans << endl;
    return 0;
}
/*atcoder*/


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, ans;

int main()
{
	in >> N;
	std::vector<int>D(N);
	rep(i, N) in >> D[i];
	D.push_back(0); ++N;
	std::sort(D.begin(), D.end());
	rep(i, N)
	{
		if (i % 2) D[i] = 24 - D[i];
	}
	ans = 24;
	rep(i, N)
	{
		rep(j, N)
		{
			if (i == j) continue;
			auto d = abs(D[i] - D[j]);
			ans = std::min(ans, std::min(d, 24 - d));
		}
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  char last[4];
  
  scanf("%s", last);
  char ABC[] = "ABC";
  
  if(strcmp(last,ABC) == 0){
    printf("ARC\n");
    return 0;
  }
  
  printf("ABC\n");
  return 0;
}

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



int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n;
  string s; cin >> s;
  string tmp = s.substr(0, n / 2);
  tmp += tmp;
  if (tmp == s and n % 2 == 0) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h_array = [0]+[int(x) for x in input().split()]
hh_array = []
res = 0
tmp = 0
for i, j in enumerate(h_array[:-1]):
    if h_array[i] < h_array[i + 1]:
        hh_array.append(h_array[i+1] - h_array[i])
    else:
        hh_array.append(0)

print(sum(hh_array))


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    rep(i, n)
    {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int n,a[100];

void dfs(int p,int lim){
	if(p==n+1){
		for(int i=1;i<=n;i++){
			cout<<char(a[i]+'a'-1);
		}
		cout<<endl;
	}else{
		for(int i=1;i<=lim;i++){
			a[p]=i;
			dfs(p+1,lim+(i==lim));
		}
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	dfs(1,1);
	return 0;
}

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

const int MAX = 100001;
int main() {
	int N;
	cin >> N;
	int operate, get[] = {6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049}, dp[MAX];
	dp[0] = 0;
	for (int i = 1;i <= N;i ++) {
		dp[i] = dp[i - 1] + 1;
		for (int j = 0;j < 11;j ++) {
			if (i >= get[j]) dp[i] = min(dp[i], dp[i - get[j]] + 1);
		}
	}
	cout << dp[N];
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

動的計画法を用いて考えます
*/

Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int main(){
    int n;
    cin >>n;
    int a, b, c, k=0;
    int p[n+2];
    rep2(i,n){
        cin >> p[i];
    }
    for(int i=2;i<n;i++){
        a=p[i-1];
        b=p[i];
        c=p[i+1];
        if((a<b&&b<c)||(a>b&&b>c)){
            k++;
        }
    }
    cout <<k<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp::min;
use std::io::stdin;
use std::io::Error;
use std::io::ErrorKind;
use std::io::Read;

#[derive(Debug)]
struct Input {
    s: String,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    Ok(Input {
        s: input_str.trim().to_string(),
    })
}

fn handle_output(input: Input) -> Result<String, Error> {
    let zeroone = "01".chars().cycle();
    let onezero = "10".chars().cycle();
    let zeroone_diff = input.s.chars().zip(zeroone).fold(0, |acc, (x, y)| {
        if x != y {
            return acc + 1;
        }
        acc
    });
    let onezero_diff = input.s.chars().zip(onezero).fold(0, |acc, (x, y)| {
        if x != y {
            return acc + 1;
        }
        acc
    });
    Ok(format!("{}", min(zeroone_diff, onezero_diff)))
}

fn main() {
    let mut input_str = String::new();
    let stdin = stdin();
    stdin.lock().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(int argc, const char * argv[])
{

    char str[8][8];
    char line[8][8];
    int i, j, k = 1;
    
    scanf("%s", str[0]);
    scanf("%s", str[1]);
    scanf("%s", str[2]);
    scanf("%s", str[3]);
    scanf("%s", str[4]);
    scanf("%s", str[5]);
    scanf("%s", str[6]);
    scanf("%s", str[7]);
    while (k <= 3) {
        printf("%d\n", 90 * k);
        for (i = 0; i < 8; i++) {
            for (j = 0; j < 8; j++) {
                line[i][j] = str[i][j];
            }
        }
        for (i = 0; i < 8; i++) {
            for (j = 0; j < 8; j++) {
                str[i][7 - j] = line[j][i];
            }
        }
        for (i = 0; i < 8; i++) {
            for (j = 0; j < 8; j++) {
                printf("%c",str[i][j]);
            }
            puts("");
        }
        k++;
    }
    
    return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

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

    int a, b;
    cin >> a >> b;
    int socket = 1, cnt = 0;
    while (socket < b) {
        --socket;
        socket += a;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
#define EPS 1e-5
#define all(a) (a).begin(),(a).end()
#define INTCEIL(a, b) ((a + (b - 1)) / b)
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;


int main() {
	cin >> N >> M;
	vector<int> a(N);
	for (int i = 0; i < N; i++)cin >> a[i];
	int sum = accumulate(a.begin(), a.end(), 0);
	for (int i = 0; i < N; i++) {
		if (a[i] < INTCEIL(sum, (4 * M))) {
			ans++;
		}
	}
	ans = N - ans;
	if (ans >= M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long A,B;
	A=1;
	B=1;
	int N;
	cin>>N;
	while(N--)
	{
		long long a,b;
		cin>>a>>b;
		long long x=max((A+a-1)/a,(B+b-1)/b);
		A=x*a;
		B=x*b;
	}
	cout<<A+B<<endl;
	return 0;
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces
 
Compile: g++  -o B_Robot_Arms.exe B_Robot_Arms.cpp 
Execute: ./B_Robot_Arms
*/ 
 
#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include<bits/stdc++.h> 
using namespace std;
 
bool sortbysec(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second < b.second; 
} 
 
int main() { 	
	/* Input */ 
	int N;
	cin >> N;
	int X[N], L[N];
	for(int i = 0; i < N; i++) cin >> X[i] >> L[i]; 
	
	// Vector of robots. Ordered pairs represent intervals of each robot's reach. 
	vector< pair <int,int> > robots; 
	for(int i = 0; i < N; i++) 
		robots.push_back(make_pair(X[i]-L[i], X[i]+L[i])); 
	sort(robots.begin(), robots.end(), sortbysec); 
	
	int num_streaks = 1, right_endpoint;  
	right_endpoint = robots[0].second; 
	
	for(int i = 1; i < N; i++) {
		if(robots[i].first < right_endpoint) {
			right_endpoint = min(right_endpoint, robots[i].second); 
		} else { 
			num_streaks++; 
			right_endpoint = robots[i].second; 
		} 
	}
	
	/* Output */ 
	cout << num_streaks << endl;
	
	return 0; 
} 


Measured memory_bytes: 2168