akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

void view(int A[] ,int N);
void insertSort(int A[],int N);

int main(){
int A[1000];
int N,i,j;
scanf("%d",&N);
for(i=0;i<N;i++){
    scanf("%d",&A[i]);
     }
view(A,N);
insertSort(A,N);
return 0;
}
void insertSort(int A[],int N){
 int i,j,v;
   for(i=1;i<N;i++){ 
     v = A[i];
     j = i - 1;
   
     while (j >= 0 &&A[j] > v){ 
       A[j+1] = A[j];
       j--;
    A[j+1] = v;
   
     }
        view(A,N);
       }
}

     void view(int A[],int N){
     int i;
     for(i=0;i<N;i++){
          if(i)
           printf(" ");

      printf("%d",A[i]);
      }
      printf("\n");
      }


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    ll n, MAX = 0, MAXsec = 0, check = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
        MAX = max(a[i], MAX);
    }
    rep(i, n){
        if(a[i] == MAX){
            check++;
            continue;
        }
        MAXsec = max(a[i], MAXsec);
    }
    check--;
    rep(i, n){
        if(a[i] == MAX && !check) print(MAXsec);
        else print(MAX);
    }
}


Measured memory_bytes: 3200
package main 
import (
        "fmt"
)

func main () {
        var n, l, r, an int
        fmt.Scan(&n)
        for i :=0 ; i < n ; i++ {
                fmt.Scan(&l,&r)
                x := r - l
                an = an + x + 1
        }
        fmt.Println(an)
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;

int main() {
    int count, A[1000];
    cin >> count;
    for (int i = 0; i < count; i++) {
        cin >> A[i];
    }

    int tradeCount = 0;
    for (int i = 0; i < count; i++) {
        for (int j = count - 1; j > i; j--) {
            if (A[j] < A[j - 1]) {
                int swap = A[j - 1];
                A[j - 1] = A[j];
                A[j] = swap;
                tradeCount++;
            }
        }
    }

    for (int j = 0; j < count; j++) {
        if (j > 0) cout << " ";
        cout << A[j];
    }
    cout << endl;
    cout << tradeCount << endl;

   
    /***
    for (int i = 0; i < count; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for (int j = 0; j < count; j++) {
            if (j > 0) cout << " ";
            cout << A[j];
        }
        cout << endl;
    }
    ***/
}

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

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  int ans=0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        if( ((L.at(i)+L.at(j))>L.at(k)) && ((L.at(i)+L.at(k))>L.at(j)) && ((L.at(k)+L.at(j))>L.at(i)) ){
          if( L.at(i)!=L.at(j) && L.at(i)!=L.at(k) && L.at(j)!=L.at(k) ){
          ans++;
          }
        }
           }
           }
           }
   cout << ans << endl;
          
}

Measured memory_bytes: 3620
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto H = RD;
	auto W = RD;
	auto K = RD;
	auto S = new string[](H);
	foreach (i; 0..H)
	{
		S[i] = RD!string;
	}
	
	long ans = long.max;
	foreach (i; 0..2^^(H-1))
	{
		auto n = popcnt(cast(int)i)+1;
		auto cnt = new long[][](n, W);
		long pos;
		foreach (y; 0..H)
		{
			foreach (x; 0..W)
			{
				if (S[y][x] == '1')
					++cnt[pos][x];
			}
			auto bit = 1L << y;
			if (i & bit)
			{
				++pos;
			}
		}

		bool ok0 = true;
		(){
		foreach (j; 0..n)
		{
			foreach (x; 0..W)
			{
				if (cnt[j][x] > K)
				{
					ok0 = false;
					return;
				}
			}
		}}();
		if (!ok0)
			continue;

		auto total = new long[](n);
		long ans_t;
		foreach (j; 0..W)
		{
			bool ok = true;
			foreach (k; 0..n)
			{
				if (total[k] + cnt[k][j] > K)
				{
					ok = false;
					break;
				}
			}
			if (!ok)
			{
				++ans_t;
				total[] = 0;
			}
			foreach (k; 0..n)
			{
				total[k] += cnt[k][j];
			}
		}

		ans.chmin(ans_t + n - 1);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

template<typename T, int MAX_N>
struct segment_tree_sum {
    T arr[MAX_N << 1]; int N;

    segment_tree_sum(int n) {
        N = 1;
        while (N < n) N *= 2;

        for (int i = 0; i < 2*N-1; ++i) {
            arr[i] = (T)0;
        }
    }

    void add(int i, T v) {
        int j = i + N-1;
        arr[j] += v;
        while (j > 0) {
            j = (j-1) / 2;
            arr[j] += v;
        }
    }

    T query(int a, int b) {
        return query(a, b, 0, 0, N);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return arr[k];

        int m = (l+r)/2;
        return query(a, b, 2*k+1, l, m) + query(a, b, 2*k+2, m, r);
    }
};

int N, Q;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> Q;
    segment_tree_sum<int, 1 << 17> segt(N+1);
    for (int j = 0; j < Q; ++j) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            segt.add(x, y);
        } else {
            cout << segt.query(x, y+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int K = scan.nextInt();
		String[] D = new String[K];
		for (int i = 0; i < K; i++) {
			D[i] = Integer.toString(scan.nextInt());
		}

		while (true) {
			boolean foundFlag = false;
			String n = Integer.toString(N);
			for (String d : D) {
				if (n.contains(d)) {
					foundFlag = true;
					N++;
					break;
				}
			}
			if (!foundFlag) {
				break;
			}
		}
		System.out.println(N);
	}

}


Measured memory_bytes: 24532
#include <iostream>

using namespace std;

main(){
  int a, b, c, d;
  while(cin >> a >> b >> c >> d){
    int sum1, sum2;
    sum1=a+b+c+d;
    cin >> a >> b >> c >> d;
    sum2=a+b+c+d;
    if(sum1>=sum2) cout << sum1 << endl;
    else cout << sum2 << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int L[220];
  for (auto i = 0; i < 2*N; i++) {
    cin >> L[i];
  }
  sort(L, L+2*N);
  int ans = 0;
  for (auto i = 0; i < 2*N; i++) {
    if (i%2 == 0) ans += L[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;

#define DescSort(a) sort(a.begin(),a.end(),std::greater<LL>())
#define Sort(a) sort(a.begin(),a.end())

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

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

	LL N, M;
	LL ans = 0;

	cin >> N >> M;

	vector<LL>X(M);

	for (int i = 0; i < M; i++) {
		cin >> X.at(i);
	}

	Sort(X);

	vector<LL>A(M, 0);

	for (int i = 1; i < M; i++) {
		A[i] = X[i] - X[i - 1];
	}

	Sort(A);

	for (int i = 0; i < M - N + 1; i++) {
		ans += A[i];
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 
//

using namespace std;

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

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); 
}

int main(){
	long long A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;
}

Measured memory_bytes: 3624
s=input()
b=[0]*2019
b[0]=1
now=0
m=2019
c=1
ans=0
for i in range(len(s)-1,-1,-1):
    now+=int(s[i])*c
    now=now%m
    c=c*10
    ans=ans+b[now]
    b[now]=b[now]+1
    c=c%m

print(ans)

Measured memory_bytes: 9312
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}


int main()
{
	long long a;
	long double b;
	cin>>a>>b;
	long long result =(long long)( a*b );
	cout<<result<<endl;
}

Measured memory_bytes: 3732
#include<iostream>
using namespace std;
int main(){
int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51},k;
cin>>k;
cout<<a[k-1];
return 0;
}

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

int main() {
    int a, b, d, r;
    double f;

    cin >> a >> b; 

    d = a / b;
    r = a % b;
    f = (double)a / b;

    printf("%d %d %lf\n", d, r, f);

    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;

//for(int32_t i = 0; i < N; i++)

int main(void)
{
    int32_t N, H, W;
    cin >> N >> H >> W;

    int32_t A, B;
    int32_t count = 0;
    for(int32_t i = 0; i < N; i++) {
        cin >> A >> B;


        if (A >= H && B >= W) {
            count ++;
        }
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

char input(){
  char a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = n/11*2;
    n%=11;
    if(n>6)ans++;
    if(n)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 384
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(A, B),
    X is (A - 1) * (B - 1),
    writeln(X).


Measured memory_bytes: 8176
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

var input: [Int] = []
for _ in 0..<5 {
    input.append(readInt()!)
}
print(input[4]-input[0] > readInt()! ? ":(" : "Yay!")


Measured memory_bytes: 7012
#include <iostream>
#include <stack>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> piii;

#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define ppb pop_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define show(x) cerr << "# " << #x << " = " << (x) << endl
//#define int ll
#define TOKAEV_NE_MOI_PRESIDENT ios_base :: sync_with_stdio(false)

const int N = 2e5 + 1;

int n, a[N], l[N], r[N];
ll ans;
stack <int> st;

int main () {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
	TOKAEV_NE_MOI_PRESIDENT;
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; ++i) {
		while(sz(st) && a[i] < a[st.top()]) {
			r[st.top()] = i;
			st.pop();
		}
		st.push(i);	
	}
	while(sz(st)) {
		r[st.top()] = n + 1;
		st.pop();
	}
	for(int i = n; i >= 1; --i) {
		while(sz(st) && a[i] < a[st.top()]) {
			l[st.top()] = i;
			st.pop();
		}
		st.push(i);	
	}
	while(sz(st)) {
		l[st.top()] = 0;
		st.pop();
	}
	for(int i = 1; i <= n; ++i) {
		ans += 1ll * (r[i] - i) * (i - l[i]) * a[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3228
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[n];
    for(int i=0; i<n; ++i) a[i] = sc.nextInt()-1;
    for(int i=0; i<n; ++i) b[i] = sc.nextInt();
    for(int i=0; i<n-1; ++i) c[i] = sc.nextInt();

    int happy = 0;
    for(int i=0; i<n; ++i) {
      happy += b[a[i]];
      if( i < n-1 && a[i+1] - a[i] == 1)
        happy += c[a[i]];
    }
    System.out.println(happy);
  }
}

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

int main() {
    
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    for (int i = 4; i <= 400; i++) {
        int sq = i*i;
        if (sq > n) {
            cout << "No" << endl;
            return 0;
        } else if (sq == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3572
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    d = collections.defaultdict(str)
    for i in range(97, 97 + 25):
        d[chr(i)] += chr(i+1)
    print(d[str(readline().rstrip().decode('utf-8'))])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> u, v, w;
	int l;
	cin >> l;
	int n = 1;
	while((1 << n) <= l) n++;
	n--;
	assert(n <= 19);
	for(int i = 1; i <= n; i++){
		u.push_back(i);
		v.push_back(i + 1);
		w.push_back((1 << (n - i)));
		u.push_back(i);
		v.push_back(i + 1);
		w.push_back(0);
	}
	int covered = (1 << n);
	int up_to = (1 << n);
	for(int i = n - 1; i >= 0; i--){
		if(covered + (1 << i) <= l){
			u.push_back(1);
			v.push_back(1 + n - i);
			w.push_back(covered);
			covered += (1 << i);
		}
	}
	int m = u.size();
	printf("%d %d\n", n + 1, m);
	for(int i = 0; i < m; i++) printf("%d %d %d\n", u[i], v[i], w[i]);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, K, S;
        cin >> N >> K >> S;

        Int neri = 1000000000;

        vector<Int> ans(N);

        if (S < neri) {
            for (int i = 0; i < K; ++i) {
                ans[i] = S;
            }

            for (int i = K; i < N; ++i) {
                ans[i] = neri;
            }

        } else {
            for (int i = 0; i < K; ++i) {
                ans[i] = S;
            }

            for (int i = K; i < N; ++i) {
                ans[i] = 1;
            }

        }

        for (int i = 0; i < N; ++i) {
            cout << ans[i] << " ";
        }
        cout << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 2176
N = int(input())
A = list(map(int,input().split()))

a = list(range(1,N+1,2))
b = list(range(2,N+1,2))

if N%2 == 0:
    b.reverse()
    ind = b + a
else:
    a.reverse()
    ind = a + b

ans = []
for i in ind:
    ans.append(A[i-1])

print(*ans)


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

int main()
{
	long long int n,i, j,k, total, r = 0, g = 0, b = 0;
	cin >> n;
	string s;
	cin >> s;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			r++;
		else if (s[i] =='G') g++;
		else b++;
	}
	total = r*b*g;
	int x=(int)'R' + (int)'G' + (int)'B';
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			k = 2*j - i;
			if(k<n&&((int)s[i] + (int)s[j]+(int)s[k])== x)
			      total--;
		}
	}
	cout << total << endl;
	return 0;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 1e6 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;
const int mod = inf;

ll a[N], tree[N], b[N];
int n;

ll sum (ll r) {
    ll res = 0;
    for (; r > 0; r -= (r & (-r))) {
        res += tree[r];
    }
    return res;
}

void up (int pos, ll val) {
    for (; pos <= n; pos += (pos & (-pos))) {
        tree[pos] += val;
    }
}

ll res;

main() {
    ll k; scanf ("%d %I64d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf ("%I64d", a + i);
        a[i] -= k;
        a[i] += a[i - 1];
        if (a[i] < 0) res--;
        b[i] = a[i];
    }
    sort (b + 1, b + n + 1);
    int m = unique(b + 1, b + n + 1) - b - 1;

    for (int i = 1; i <= n; i++) {
        a[i] = lower_bound(b + 1, b + m + 1, a[i]) - b;
    }
    for (int i = 1; i <= n; i++) {
        up(a[i], 1);
        res += sum(a[i]);
    }
    printf ("%lld", res);
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

vector<vector<ll>> e;
template <class T>
void printArray(const vector<T>& a) {
  int n = a.size();
  for (int i = 0; i < n; i++) {
    cout << a[i] << " \n"[i == n - 1];
  }
}

void pr(ll u, ll v, ll w) { e.push_back({u, v, w}); }

struct Edge {
  ll dst, wgt;
  Edge(ll dst, ll wgt) : dst(dst), wgt(wgt){};
};

vector<bool> seen;
vector<ll> paths;
vector<vector<Edge>> g;
ll sum = 0;
ll goal = 0;
ll l;

void dfs(ll cv) {
  if (cv == goal) {
    paths.push_back(sum);
    return;
  }

  seen[cv] = true;
  for (Edge e : g[cv]) {
    ll nv = e.dst, w = e.wgt;
    if (seen[nv]) {
      continue;
    }
    sum += w;
    dfs(nv);
    sum -= w;
  }
  seen[cv] = false;
}

bool check() {
  ll n = 20;
  ll m = SZ(e);
  g = vector<vector<Edge>>(n);
  seen = vector<bool>(n, false);
  paths.clear();
  goal = 0;
  REP(i, m) {
    ll u = e[i][0], v = e[i][1], w = e[i][2];
    u--, v--;
    g[u].push_back(Edge(v, w));
    goal = max(goal, max(u, v));
  }
  dfs(0);

  if (SZ(paths) != l) {
    return false;
  }
  sort(ALL(paths));
  REP(i, l - 1) {
    if (paths[i] + 1 != paths[i + 1]) {
      return false;
    }
  }
  return true;
}

void solve() {
  e.clear();
  ll k = -1, c = 1;
  while (c <= l) {
    c *= 2;
    k++;
  }

  FOR(i, 1, k + 1) {
    pr(i, i + 1, 0);
    pr(i, i + 1, 1LL << (i - 1));
  }

  ll l2 = l;
  IFOR(i, 1, k + 1) {
    if (l2 - (1LL << (i - 1)) >= (1LL << k)) {
      pr(i, k + 1, l2 - (1LL << (i - 1)));
      l2 -= 1LL << (i - 1);
    }
  }

  // debug
  // cout << (check() ? "OK" : "NG") << "\n";

  cout << k + 1 << " " << SZ(e) << "\n";
  REP(i, SZ(e)) { printArray(e[i]); }
}

int main() {
  cin >> l;
  solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int32_t main(){
  fast;

  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int val = 0;
  int i = 0;
  int prev = '.';
  int cc = 0;
  while(i < n) {
    if(s[i] == prev)
      cc++;
    else {
      val += max(0LL,cc - 1);
      cc = 1;
      prev = s[i];
    }
    i++;
  }
  val += cc - 1;
  // cout << val << "\n";
  cout << min(2 * k + val, n - 1);
  

  return 0;
}

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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())
#c=1
#ans_l=[]
#while(N==0):
#    tmp=N%(26**c)
#    ans_l.append(tmp//(26**(c-1)))
#    N-=tmp**(c-1)

#for i in ans_l:




Measured memory_bytes: 72708
from functools import lru_cache
inf = 10**18
T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    @lru_cache(maxsize=None)
    def solve(N):
        #print(N)
        if N==0:
            return 0
        elif N==1:
            return D
        elif N==2:
            return min(D*2, D+A)
        # elif N==3:
        #     return min(D*3, D+B, D+A+D)
        # elif N==4:
        #     return min(D*4, D+A+A, D+D+A, D+B+D, D+C+D)
        # elif N==5:
        #     return min(D*5, solve(2)+D*3, D+A*3+D*3, solve(3)+D*2, solve(4)+D, D+A+B+D, D+C)
        # elif N==6:
        #     return min(
        #         D*6,
        #         solve(1)+D*5
        #     )
        res = D*N
        for v, cost in zip([2,3,5], [A,B,C]):
            q, m = divmod(N, v)
            if m==0:
                res = min(res, solve(q)+cost)
            else:
                res = min(res, solve(q)+cost+m*D, solve(q+1)+cost+(v-m)*D)
        return res
    print(solve(N))
    
        


Measured memory_bytes: 11660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    set<int> s;
    rep(i, 3) {
        int a; cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    
    ll ans = 0;
    for(ll i = 1; i <= N; i++){
        ll sum = 0;
        ll i_sub = i;
        while(i_sub > 0){
            sum += i_sub % 10;
            i_sub /= 10;
        }
        if(sum >= A && sum <= B) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const ll mod = 998244353 ;
const int N = 1e5+5;
typedef pair<int,int> pii;




void TEST_CASES(int cas)
{
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
    {
        printf("3\n");
        return;
    }
    if(s[0]=='R' && s[1]=='R')
    {
        printf("2\n");
        return;
    }
    if(s[1]=='R' && s[2]=='R')
    {
        printf("2\n");
        return;
    }
    if(s[0]=='R' || s[1]=='R' || s[2]=='R')
    {
        printf("1\n");
        return;
    }
    printf("0\n");
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



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

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3620
p=input().rstrip().split(' ')
l=[int(p[1])]*int(p[0])
q=[0]*1000000;
for i in range(0,int(p[2])):
    o=int(input())
    q[o-1]+=1;
for i in range(0,int(p[0])):
    A=int(p[2])-q[i];
    l[i]-=A;
#print(l)
for i in range(0,len(l)):
    if l[i]>0:
        print("Yes")
    else:
        print("No")


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

vvi dp;
vp data(510);
int n;

int solve(int l, int r)
{
    int ret = INF;
    if (dp[l][r] != INF) {
        return dp[l][r];
    } else if (l == r) {
        dp[l][r] = 0;
        return 0;
    } else {
//        cout << l << " " << r << endl;
        for (int i = l; i < r; i++) {
            ret = min(ret, solve(l, i) + solve(i+1, r) + 
                    data[l].fir * data[i].sec *
                    data[i+1].fir * data[r].sec);
        }
    }
    dp[l][r] = ret;
    return ret;
}

signed main()
{
    cin >> n;
    dp = vvi(n, vi(n, INF));
    rep(i, n) {
        cin >> data[i].fir >> data[i].sec;
    }
    /*
    Rep(i, n) {
        dp[i-1][i] = data[i-1].fir*data[i-1].sec*data[i].fir*data[i].sec;
    }*/
    cout << solve(0, n-1) << endl;


    return 0;
}

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

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

    int cnt = 0, tmp;
    while (cnt++ < 50000) {
        tmp = cnt * 1.08;
        if (tmp == n) break;
    }

    if(cnt < 50000) {
        cout << cnt << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    size_t len = s.length();
    int mid = len / 2;
    int n1 = (len - 1) / 2;
    int n2 = (len + 3) / 2;
    //cout << s[0] << s[1] << endl;
    //cout << len << ":" << n1 << ":" << n2 << endl;
    int i, k = 0;
    bool isStrong = true;
    for (i = 0; i < mid; i++)
    {
        //cout<<i<<"周目"<<endl;
        if (s[i] != s[len-1 - i])
        {
            //cout<<s[i]<<s[len-1-i]<<endl;
            isStrong = false;
            break;
        }
        if (i < n1 && s[i] != s[n1 -1- i])
        {
            //cout<<"test"<<endl;

            //cout<<s[i]<<s[n1-1-i]<<endl;
            isStrong = false;
            break;
        }
        if (n2-1 <= i)
        {
            cout<<s[i]<<s[n2-1-k]<<endl;
            if (s[i] != s[n2-1 - k])
            {
                isStrong = false;
                break;
            }
            k++;
        }
    }

    if (isStrong)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
inputLine=input()
N=int(inputLine)

inputLine=input()
A=inputLine.split(" ")

result = []
for i in range(N):
    result.append(0)

for i in range(len(A)):
    result[int(A[i])-1] += 1

for i in range(len(result)):
    print(result[i])





Measured memory_bytes: 27564
### constant

KMAP = {
  '2' => /[a-c]/, '3' => /[d-f]/, '4' => /[g-i]/, '5' => /[j-l]/,
  '6' => /[m-o]/, '7' => /[p-s]/, '8' => /[t-v]/, '9' => /[w-z]/
}

### subroutines

def match?(word, seq, k)
  for i in (0...word.length)
    return false if word[i] !~ KMAP[seq[k + i]]
  end
  true
end

def check_rec(dic, seq, k = 0, words = [])
  if k >= seq.length
    $ans << words.join(' ') + '.' if ! words.empty?
    return
  end

  for word in dic
    if match?(word, seq, k)
      check_rec(dic, seq, k + word.length, words + [word])
    end
  end
end

### main

loop do
  n = gets.to_i
  break if n == 0

  dic = n.times.map{gets.strip}
  seq = gets.strip.split('')
  #p dic
  #p seq

  $ans = []
  check_rec(dic, seq)

  puts $ans.sort
  puts '--'
end

Measured memory_bytes: 6224
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		int N = scan.nextInt();

		// mapにkeyとvalue格納
		for(int i = 0; i < N; i++) {
			map.put(i + 1, scan.nextInt());
		}

		List<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer, Integer>>(map.entrySet());

		//昇順ソート
		Collections.sort(list, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
				return obj1.getValue().compareTo(obj2.getValue());
			}
		});
		for (Entry<Integer, Integer> entry : list) {
			//System.out.println(entry.getKey() + " : " + entry.getValue());
			System.out.print(entry.getKey()+ " ");
		}

	}
}

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

int main() {
	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  
  	int dis1 = abs(b - a);
  	int dis2 = abs(c - b);
  	int dis3 = abs(c - a);
  
  	if(dis3 <= d || (dis1 <= d && dis2 <= d)) {
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def divis(l):
    seq = []
    beg, end = 0, 0
    le = len(l)
    for i in range(1,le):
        end = i
        if l[i] < l[i-1]:
            seq.append(l[beg:end])
            beg = i
    seq.append(l[beg:end+1])
    return seq

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    a = divis(a)
    yosan = 1000
    for i in a:
        yosan += (i[-1]-i[0])*(yosan//i[0])
    print(yosan)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10448
#include <stdio.h>
int main(void) {
    int n,m,i,j,temp,place[101][2];
    while (scanf("%d %d",&n,&m)!=EOF&&(m!=0||n!=0)) {
        for (i=0; i<m; i++) {
            place[i][0]=i;
            place[i][1]=0;
        }
        for (i=0; i<n; i++) {
            for (j=0; j<m; j++) {
                scanf("%d",&temp);
                place[j][1]+=temp;
            }
        }
        for (i=0; i<m; i++) {
            for (j=0; j<m-i-1; j++) {
                if (place[j][1]<place[j+1][1]) {
                    temp=place[j][1];
                    place[j][1]=place[j+1][1];
                    place[j+1][1]=temp;
                    temp=place[j][0];
                    place[j][0]=place[j+1][0];
                    place[j+1][0]=temp;
                }
            }
        }
        for (i=0; i<m; i++) {
            if (i) printf(" ");
            printf("%d",place[i][0]+1);
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ok(n, false);
  vector<int> penas(n, 0);
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "WA") {
      if (!ok[p]) {
        penas[p]++;
      }
    }
    if (s == "AC") {
      ok[p] = true;
    }
  }
  int ac = 0;
  int pena = 0;
  rep(i, n) {
    if (ok[i]) {
      ac++;
      pena += penas[i];
    }
  }
  cout << ac << " " << pena << endl;
  return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b,c,sum;
  cin >> N;
  c = N%10;
  b = (N%100 - c)/10;
  a = (N - N%100) /100;
  sum = a + b + c;
  cout << sum << endl;
}

Measured memory_bytes: 256
import sys
def main():
    t = sys.stdin.readline()
    t1 = t.rstrip()
    t2 = t1.split(' ')
    stra = [] 
    for i in range(int(t2[0])):
        y = sys.stdin.readline()
        t = y.rstrip()
        stra += [t]
    strb = [] 
    for i in range(int(t2[1])):
        y = sys.stdin.readline()
        t = y.rstrip()
        strb += [t]
 
    suma = 0
    for x in strb:
        for y in stra:
            if x in y:
                suma +=1 
    if int(t2[0])*int(t2[1])==suma:
        print("Yes")
    else:
        print("No")
main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
int main(){  
    int n,l;
    cin>>n>>l;
    
    int apple[n];
    for (int i = 1; i <= n; i++)
    {
        apple[i-1]=l+i-1;
    }
    int ans=100;
    int ansnumber;
    for (int i = 0; i < n; i++)
    {
        if (ans>=abs(apple[i]))
        {
            ansnumber=i;
            ans=abs(apple[i]);
        }
        
    }
    apple[ansnumber]=0;
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        sum+=apple[i];
    }
    
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 200000 + 5
#define M 
#define inf 123456789
#define Inf 1000000000000000000
#define Mod 1000000007
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++i)
#define dep(i, l, r) for(register int i = r; i >= l; --i)
#define Next(i, u) for(register int i = h[u]; i; i = e[i].next)
#define mem(f, x) memset(f, x, sizeof(f))
#define file(a) freopen(#a".in","r",stdin); freopen(#a".out","w",stdout);
typedef long long ll;
typedef double D;
int n, m, k, l, r, pos1, pos2, pos, pre, len, a[N], b[N];
int read(){
	char c; int x = 0, f = 1;
	c = getchar();
	while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ x = (x << 3) + (x << 1) + c - '0'; c = getchar();}
	return x * f;
}
int Mul(int a, int b) { return 1ll * a * b % Mod; }
int Inc(int a, int b) { return (a += b) >= Mod ? a - Mod : a; }
int Dec(int a, int b) { return (a -= b) < 0 ? a + Mod : a; }
bool check(int Mid){
    int sum = 0;
    if(Mid < 0){
        if(pos > n) return false;
        rep(i, 1, pos - 1){
            int l = pos, r = n;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] <= Mid) r = mid;
                else l = mid + 1; 
            }
            if(a[i] * a[r] > Mid) r++;
            if(r == i) r++;
            if(n >= r) sum += n - r + 1;
        }
        if(sum >= k) return true;
        else return false;
    }
    else if(Mid == 0){
        sum = (pos - 1) * (n - pos + 1) + pre;
        if(sum >= k) return true;
        else return false;
    }
    else{
        sum = (pos - 1) * (n - pos + 1) + pre;
        rep(i, 1, pos - 1){
            int l = i, r = pos - 1;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] <= Mid) r = mid;
                else l = mid + 1; 
            }
            if(a[i] * a[r] > Mid) r++;
            if(r == i) r++;
            if(pos > r) sum += pos - r;
        }
        rep(i, pos, n){
            int l = i, r = n;
            while(l < r){
                int mid = (l + r) >> 1;
                if(a[i] * a[mid] < Mid) l = mid + 1;
                else r = mid;
            }
            if(a[i] * a[r] > Mid) r--;
            if(r > i) sum += r - i;
        }
        if(sum >= k) return true;
        else return false;
    }
}
signed main(){
	//file(data);
	n = read(), k = read();
    rep(i, 1, n) b[i] = read();
    sort(b + 1, b + n + 1);
    b[n + 1] = 1;
    rep(i, 1, n){
        if(b[i] == 0 && !pos1) pos1 = i;
        if(b[i] == 0 && b[i + 1] != 0 && !pos2) pos2 = i;
    } 
    if(pos1) len = pos2 - pos1 + 1, pre += len * (len - 1) / 2 + (n - len) * len;
    m = n, n = 0;
    rep(i, 1, m) if(!(i >= pos1 && i <= pos2)) a[++n] = b[i];
    rep(i, 1, n) if(a[i] > 0 && !pos) pos = i;
    if(!pos) pos = n + 1;
    l = -Inf, r = Inf;
    while(l < r){
        int Mid = (l + r) >> 1;
        if(check(Mid)) r = Mid;
        else l = Mid + 1;
    }
    printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m,k;

int main(){
	cin>>n>>m>>k;
	vi a(n),b(m);
	for(auto &i:a) cin>>i;
	for(auto &i:b) cin>>i;
	int res=inf;
	for(int i=0;i<k;i++){
		int u,v,w;
		cin>>u>>v>>w;
		u--;v--;
		res=min(res,a[u]+b[v]-w);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	cout<<min(res,a[0]+b[0])<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cassert>
#include <string.h>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  REP(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
typedef vector<lld> vl;
typedef vector<int> vi;
typedef vector<char> vc;



//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());

int main(){
	long int N;
	int blue=0,ans=0;
	vi vec;
	string S;
	cin>>S;
	int len;
	len=int(S.size());
	for (int i = 0; i < len; i ++) {
			if (S[i]=='0')
				blue++;
	}

	cout<<min(blue,len-blue)*2;


	return 0;
}

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

int main() {
    int n;
    ll ans=0;
    cin>>n;
    map<int,int> mp;
    rep(i,n) {
        int temp;
        cin>>temp;
        mp[temp]++;
    }
    for (auto v : mp) {
        if (v.first<v.second) {
            ans+=v.second-v.first;
        } else if(v.first>v.second) {
            ans+=v.second;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4736