akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;

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


int seisei(int keta, ll hitigo, ll n, int three, int five, int seven){
    if(keta==0){
        if(three>0&&five>0&&seven>0){
            if(hitigo<=n){
                return 1;
            }else{
                return 0;
            }
        }else{
            return 0;
        }
    }

    keta--;
    ll san = seisei(keta, hitigo+pow(10, keta)*3, n, three+1, five, seven);
    ll go = seisei(keta, hitigo+pow(10, keta)*5, n, three, five+1, seven);
    ll nana = seisei(keta, hitigo+pow(10, keta)*7, n, three, five, seven+1);
    return san+go+nana;
}

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

    int tmp=n;
    int keta=0;
    while(tmp){
        tmp/=10;
        keta++;
    }

    ll count=0;
    ll ketagoto=0;
    rep(i,keta+1){
        count+= seisei(i, ketagoto, n, 0, 0, 0);
    }

    cc(count);
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

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

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

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

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

signed solve()
{
	i64 x;
	cin >> x;

	i64 ans = (x / 11) * 2;
	i64 mod = x % 11;
	if (mod > 0)
	{
		if (mod < 7)
			ans += 1;
		else
			ans += 2;
	}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
s=input()
n=len(s)

s1=s[:(n-1)//2]
s2=s[(n+3)//2-1:]

if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
	print("Yes")

else:
	print("No")
	
	

Measured memory_bytes: 3060
#include<stdio.h>
int gcd(int x,int y);

int main()
{
  int a,b;
  int gcd_n;
  scanf("%d %d",&a,&b);
  gcd_n = gcd(a,b);
  printf("%d\n",gcd_n);

  return 0;
}

int gcd(int x,int y)
{
int tmp;
  
  while (y)
    {
      tmp = x % y;
      x = y;
      y = tmp;
    }
  
  return x;
}

Measured memory_bytes: 1020
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();	
		int b=sc.nextInt();
		int c=sc.nextInt();
		System.out.println(a+b>=c?"Yes":"No");
	
	
	
	}
}

Measured memory_bytes: 23124
import java.util.*;
import java.lang.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // formatter off
        System.out.println(solve(inputStr(sc, " "), inputStr(sc, " ")));
    }

    /**
     * 指定された区切り文字で区切られた１行の文字列を、文字列配列にして返します。
     */
    private static String[] inputStr(Scanner sc, String... delimiter) {
        return sc.nextLine().split(delimiter == null ? " " : delimiter[0]);
    }

    private static Long[] convertStrToInt(String[] strArray) {
        return Arrays.stream(strArray).map(e -> new Long(Long.parseLong(e))).toArray(Long[]::new);
    }

    private static long outputResult(long a, long b) {
        return LongStream.range(0, b).reduce((long) 0, (sum, i) -> sum += (Math.pow(10, i) * a));
    }

    private static long solve(String[]... inputs) {
        Long[] firstArr = convertStrToInt(inputs[0]);
        long a = firstArr[0];
        Long[] secondArr = convertStrToInt(inputs[1]);

        Predicate<Integer> pred = (
                i) -> Arrays.stream(secondArr).limit(i).max(Comparator.reverseOrder()).get() == secondArr[i - 1];
        // return IntStream.range(1, (int) (a + 1)).reduce(0, (cnt, i) -> pred.test(i) ?
        // ++cnt : cnt);
        Resp res = new Resp(Long.MAX_VALUE, 0);
        IntStream.range(0, (int) (a)).boxed().reduce(res, (p, i) -> {
            if (secondArr[i] <= p.getMin()) {
                p.setMin(secondArr[i]);
                p.addCont();
            }
            return p;
        }, (res1, res2) -> res2);
        return res.getCont();
    }
}

class Resp {
    private long min = Long.MAX_VALUE;
    private int cont = 0;

    public Resp(long min, int cont) {
        this.min = min;
        this.cont = cont;
    }

    public long getMin() {
        return this.min;
    }

    public void setMin(long min) {
        this.min = min;
    }

    public int getCont() {
        return this.cont;
    }

    public void setCont(int cont) {
        this.cont = cont;
    }

    public void addCont() {
        this.cont++;
    }

}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(auto& x : v) cin >> x;
    const int tmp = accumulate(begin(v) + 1, end(v), v[0],
        [](const int x, const int y){ return __gcd(x, y); });
    const int big = *max_element(begin(v), end(v));
    const bool can = (k%tmp == 0 && k <= big);
    
    cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0; }


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace aizu1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s.Split(' ')[0]);
            int p = int.Parse(s.Split(' ')[1]);
            int time = 0;
            Queue<process> queue = new Queue<process>();

            for (int i = 0; i < n; i++)
            {
                queue.Enqueue(new process(Console.ReadLine()));
            }

            while (queue.Count != 0)
            {
                process _process = queue.Dequeue();
                if (_process.time <= p)
                    Console.WriteLine(_process.name + " "+(time += _process.time));

                else
                {
                    _process.time -= p; queue.Enqueue(_process);
                    time += p;

                }



            }
        }

        public struct process
        {
            public string name;
            public int time;

            public process(string s)
            {
                this.name = s.Split(' ')[0];
                this.time = int.Parse(s.Split(' ')[1]);
            }
        }
    }
}

Measured memory_bytes: 15172
#include<stdio.h>
#define Maxn 10000
#define Maxq 500

int search(int);
int A[Maxn],n;

int main()
{
  int q=0,i=0,k=0;
  int B[Maxq];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
    scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&B[i]);
    }

  
  for(i=0;i<q;i++)
    {
      if(search(B[i])==1)
	k++;
    }

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

  return 0;
}

int search(int key)
{
  int i;
  for(i=0;i<n;i++)
    {
      if(A[i]==key) return 1;
    }
  return 0;
}

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

int main(void) {
 int h, w;
 cin >> h >> w;

 string board[50];

 for (int i = 0; i < h; ++i) cin >> board[i];

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

 for (int i = 0; i < h; ++i) {
 for (int j = 0; j < w; ++j) {
 if(board[i][j]=='#') continue;
   
 //  if(board[i][j] == ’#’) continue;
 int num = 0;
 for (int d = 0; d < 8; ++ d) {
 const int ni = i + dy[d];
 const int nj = j + dx[d];

 if (ni < 0 or h <= ni) continue;
 if (nj < 0 or w <= nj) continue;
 if (board[ni][nj] == '#') num++;
 }

 board[i][j] = char(num + '0');

 }
 }

 for (int i = 0; i < h; ++i) cout << board[i] << endl;

 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int l,r;
    l = r = -1;
    
    for(int i=0;i<S.size();i++){
        if(S[i] == 'A' && l == -1){
            l = i;
        }
        if(S[i] == 'Z'){
            r = i;
        }
    }
    int ans = r - l + 1;
    
    cout << ans << endl;
    
}


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

int main() {
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	long long answer = 0;

	long long addA, addB, addC = 0;
	if (A > K) {
		addA = K;
		K = 0;
	}
	else {
		addA = A;
		K -= A;
	}

	if (B > K) {
		addB = K;
		K = 0;
	}
	else if (K > 0){
		addB = B;
		K -= B;
	}

	if (C > K) {
		addC = K;
		K = 0;
	}
	else if (K > 0){
		addC = C;
		K -= C;
	}

	answer = (1 * addA) + (-1 * addC);

	cout << answer << endl;
}

Measured memory_bytes: 3192
/*input
8 3
ACACTACG
3 7
2 3
1 8
*/
#include <bits/stdc++.h>
using namespace std;
#define MAX 200010

int q, n, a[MAX] = {}, b[MAX];
char c[MAX];

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

    c[0] = 'X';
    for (int i = 1; i <= n; i++) {
        cin >> c[i];

        if (c[i] == 'C' && c[i - 1] == 'A') a[i] ++, b[i - 1] --;
        a[i] += a[i - 1];
    }
    while (q--) {
        int x, y, ans; 
        cin >> x >> y;

        ans = a[y] - a[x - 1] + b[x - 1];

        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 1664
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

void main() {
    immutable nums = readRows(1).joiner.map!(c => to!int(c) - '0').array;
    foreach(ops; 0 .. 0b1000) {
        int value = nums[0];
        string exp = to!string(nums[0]);
        foreach(i, n; nums[1 .. $]) {
	immutable plus = (ops & (1u << i));
	value += plus ? +n : -n;
	exp ~= plus ? '+' : '-';
	exp ~= to!string(n);
        }
        
        if(value == 7) {
	writefln("%s=7", exp);
        	return;
        }
    }
    
    assert(false);
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;

// Java8
public class Main
{
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		int a = sc.nextInt();
		int b = sc.nextInt();
		Pattern ptn = Pattern.compile("\\d{" + a + "}-\\d{" + b + "}");
		String s = sc.next();
		System.out.println(ptn.matcher(s).matches() ? "Yes" : "No");
	}
}


Measured memory_bytes: 23508
#include<stdio.h>
#include<stdlib.h>
main()
{
  int k,x,i,rem,s,e;
  scanf("%d %d",&k,&x);
  rem=k-1;
  s=x-rem;
  e=x+rem;
  for(i=s;i<e+1;++i)
  {
    printf("%d ",i);
  }
  
  
}

Measured memory_bytes: 128
a, b, c, d, e, f = map(int, input().split())

max_nodo = 0
ans = [100*a, 0]
for i in range(30//a+1):
    for j in range(30//b+1):
        mizu = 100*i*a + 100*j*b
        if mizu > f: break
        if mizu == 0: continue
        maxi = (i*a + j*b) * e
        for k in range(maxi//c+1):
            for l in range(maxi//d+1):
                sato = c*k + d*l
                if mizu+sato > f: break
                if sato > maxi: break
                nodo = sato / (mizu+sato)
                if nodo > max_nodo:
                    max_nodo = nodo
                    ans = [mizu+sato, sato]

print(ans[0], ans[1])

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

#ifndef LOCAL
#define fprintf if(false) fprintf
#endif
#define debug_int(x) fprintf(stderr, "%s = %d\n", #x, x)
#define debug_double(x) fprintf(stderr, "%s = %llf\n", #x, x)
#define debug_array(v,n) fprintf(stderr, "%s = [ ", #v); for(int i=0; i<n; i++) fprintf(stderr, "%d ", v[i]); fprintf(stderr, "]\n")
#define forr(i,start,end) for(int i=start; i<end; i++)

using lli = long long int;
using ii = pair<int, int>;

const int MAXN = 100010;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    vector<vector<int>> adj(n+1);
    while(m--) {
        int u, v;
        scanf("%d %d", &u, &v);

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int> parent(n+1, 0);
    int visi_count = 0;

    queue<ii> q;
    q.push({1, 1});
    while(!q.empty()) {
        ii u = q.front();
        q.pop();

        if(parent[u.first]) continue;
        parent[u.first] = u.second;
        visi_count++;

        for(int v : adj[u.first]) {
            q.push({v, u.first});
        }
    }

    if(visi_count < n) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
        for(int i=2; i<=n; i++) {
            printf("%d\n", parent[i]);
        }
    }
}


Measured memory_bytes: 12076
#include <stdio.h>
int caculate_pro(int shop[10],int per[100][10],int pro[100][11],int size)
{
    int i,j,result=0;
    int temp[100]={0};
    for (i=0;i<10;i++)
    {
        if (shop[i]==1){
            for(j=0;j<size;j++)             //j可以理解为店铺号
            {
                temp[j]+=per[j][i];         //和第j家店铺相同的天数加一或者不加
            }
        }
    }
    for (i=0;i<size;i++)
    {
        result+=pro[i][temp[i]];             //算出利润
    }
    return result;
}
int  main()
{
    int n,result,fold,i,i1,j,max,index;
    int per[100][10]={0},pro[100][11]={0};
    int shop[10];
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        for (j=0;j<10;j++)
        {
            scanf("%d",&per[i][j]);
        }
    }
    for (i=0;i<n;i++)
    {
        for (j=0;j<11;j++)
        {
            scanf("%d",&pro[i][j]);
        }
    }
    for (i=1;i<1024;i++)
    {
        i1=i;
        for (j=0;j<10;j++)
        {
            shop[j]=i1%2;
            i1=i1/2;
        }
        if (i==1){
            max=caculate_pro(shop,per,pro,n);
            index=1;
        }
        else if (max<caculate_pro(shop,per,pro,n))
        {
            max=caculate_pro(shop,per,pro,n);
            index=i;
        }
    }
    printf("%d\n",max);
}


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

int main(){
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c.at(i).at(j);
    }
  }

  bool flag=true;
  for(int i=0;i<2;i++){
    if(c.at(i+1).at(0)-c.at(i).at(0)==c.at(i+1).at(1)-c.at(i).at(1)&&c.at(i+1).at(1)-c.at(i).at(1)==c.at(i+1).at(2)-c.at(i).at(2)){
      continue;
    }
    flag=false;
  }
  for(int i=0;i<2;i++){
    if(c.at(0).at(i+1)-c.at(0).at(i)==c.at(1).at(i+1)-c.at(1).at(i)&&c.at(1).at(i+1)-c.at(1).at(i)==c.at(2).at(i+1)-c.at(2).at(i)){
      continue;
    }
    flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := makeWordScanner()
	h := eGetInt(scanner)
	n := eGetInt(scanner)
	for i := 0; i < n; i++ {
		a := eGetInt(scanner)
		h = h - a
		if h <= 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	return int(math.Pow(float64(a), float64(n)))
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
int main(){
    ll n,ans=0;
    cin >> n;
    ll a[n];
    ll x[101000];
    fill(x,x+100100,0);
    for (ll i=0;i<n;i++){
        cin >> a[i];
        x[a[i]]=x[a[i]]+1;
        ans+=a[i];
    }
    ll q;
    cin >> q;
    for (ll i=0;i<q;i++){
        ll b,c;
        cin >> b >> c;
        ans+=x[b]*c;
        ans-=x[b]*b;
        x[c]=x[c]+x[b];
        x[b]=0;
        cout << ans << endl;
    }
    return 0;
}


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

char s[30];
int a[30];
int main()
{
	while(scanf("%s", s) != EOF)
	{
		int len = strlen(s);
		for(int i = 0; i < len; i++)
			a[s[i] - 'a']++;
		bool f = 1;
		for(int i = 0; i < 26; i++)
		{
			if(a[i] > 1) {
				f = 0;
				break;
			}
		}
		if(f == 1) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =200001;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}

int main()
{
  
  IOS
  ll n,d,A;
  cin>>n>>d>>A;
  pll a[n];
  for(ll i=0;i<n;i++)
  {
    cin>>a[i].ff>>a[i].ss;
  }
  sort(a,a+n);
  ll ans=0;
  ll last_x = -1e15;
  ll last_bombs=0;
  queue<pll> q;
  for(ll i=0;i<n;i++)
  { 
    while((!q.empty())&&(a[i].ff-q.front().ff>2*d))
    { 
      last_bombs-=(q.front().ss);
      q.pop();
    }
    //trace(i,q.size());
    a[i].ss=max(0ll,a[i].ss-last_bombs*A);
    
    if(a[i].ss>0)
    {
      last_bombs += (a[i].ss+A-1)/A;
      ans+=(a[i].ss+A-1)/A;
      q.push({a[i].ff,(a[i].ss+A-1)/A});
      //trace(q.front());
    }
    //trace(i,q.size(),q.front());
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


int main(void){
    int n;
    int i;
    int root;

    scanf("%d", &n);
    for (i = n; i > 0; i--){
        root = (int)sqrt((double)i); 
        if (root * root == i){
            printf("%d\n", i);
            return 0;
        }
    }

    return 0;
    
}


Measured memory_bytes: 128
def root(x):
  if data[x]<0:return x
  else:
    data[x]=root(data[x])
    return data[x]
def unite(x,y):
  x,y=root(x),root(y)   
  if x!=y:
    if data[x]>data[y]:x,y=y,x
    data[x]+=data[y]
    data[y]=x
from collections import*
r=range
h,*s=open(0)
h,w=map(int,h.split())
data=[-1]*h*w
for i in r(h):
  for j in r(w):
    if i+1<h and s[i][j]!=s[i+1][j]:
      unite(i*w+j,-~i*w+j)
    if j+1<w and s[i][j]!=s[i][j+1]:
      unite(i*w+j,i*w+j+1)
d=defaultdict(lambda:[0,0])
for i in r(h*w):d[root(i)][s[i//w][i%w]<'.']+=1
print(sum(i*j for i,j in d.values()))

Measured memory_bytes: 28368
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


while 1:
    h, w = LI()
    if w == h == 0:
        break
    for i in range(h):
        for q in range(w):
            if (1 <= i <= h-2) and (1 <= q <= w-2):
                print('.', end='')
            else:
                print('#', end='')
        print('', end='\n')
    print('', end='\n')



Measured memory_bytes: 7108
N = int(input())
lst = [[0 for i in range(10)]for j in range(10)]
ans = 0
for i in range(1,N+1):
    tmp = list(str(i))
    lst[int(tmp[0])][int(tmp[-1])]+=1
for i in range(10):
    for j in range(10):
        if i == 0 or j == 0:
            continue
        if i == j:
            ans+=lst[i][j]**2
        else:
            ans+=lst[i][j]*lst[j][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<template<class...> class ContT, class ValueT, size_t Dim>
struct vec_type
{
    using type = ContT<typename vec_type<ContT, ValueT, Dim-1>::type>;
};

template<template<class...> class ContT, class ValueT>
struct vec_type<ContT, ValueT, 0>
{
    using type = ValueT;
};

template<class ValueT, size_t Dim = 1>
using vec_t = typename vec_type<std::vector, ValueT, Dim>::type;


template<class ValueT, size_t Dim, class = typename std::enable_if<Dim == 0>::type>
auto make_vec(ValueT value = ValueT()) -> ValueT
{
    return value;
}

template<class ValueT, size_t Dim, class... Rest>
auto make_vec(size_t size0, Rest... rest)
{
    auto vec = make_vec<ValueT, Dim-1>(rest...);
    return std::vector(size0, vec);
}

int diffabs(int l, int r)
{
    if (l < r) return r-l;
    else return l-r;    
}


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

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

    for (char c : S)
    {
        int i = c - 'A';
        i = (i + N) % 26;
        char cc = 'A' + i;
        cout << cc;
    }
    cout << endl;
}

Measured memory_bytes: 3660
#include <cstdio>

int main()
{
  char s[20];
  scanf("%s",s);
  for(int i=0;i<4;i++){
    putchar(s[i]);
  }
  putchar(' ');
  for(int i=4;i<12;i++){
    putchar(s[i]);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

int main(){
	int n;
	int d;
	int min;
	int num_watch;
	
	scanf("%d %d", &n, &d);
	
	num_watch=(2*d)+1;
	min=n/num_watch;
	
	if(n%num_watch!=0){
		min++;
	}
	
	printf("%d",min);
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
#define ll long long
#define inf 1000000001
using namespace std;
#define N 305
int n,K,mod,f[N][N],s[N][N],C[N][N];
void init(int n){
	rep (i,0,n) C[i][0]=1;
	rep (i,1,n) rep (j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
void upd(int &x,int y){x+=y;x-=x>=mod?mod:0;}
int main(){
	cin>>n>>K>>mod;init(n);n++;
	rep (i,0,K) f[1][i]=1;
	per (i,K,0) s[1][i]=(s[1][i+1]+1)%mod;
	/*f[n][x]+=f[n-k][x]*f[k][y]*C(n-2,k-1);(y--->x)y>x*/
	rep (i,2,n){
		rep (j,0,K) rep (k,1,i-1) upd(f[i][j],(ll)f[i-k][j]*s[k][j+1]%mod*C[i-2][k-1]%mod);
		per (j,K,0) s[i][j]=(s[i][j+1]+f[i][j])%mod;
	}
	cout<<f[n][0]<<'\n';
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    
    vector<ll> a(n);
    ll mn = mod;
    ll ans = 0;
    int cnt = 0;
    
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] < 0) cnt++;
        ans += abs(a[i]);
        mn = min(mn,abs(a[i]));
    }
    if(cnt%2 == 0) cout << ans << endl;
    else cout << ans-2*mn << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Integer> countPrimeFactor = new HashMap<>();
        for(int i = 1; i <= n; i++) {
            int num = i;
            while(num > 1) {
                for(int j = 2; j <= num; j++) {
                    if(num % j == 0) {
                        countPrimeFactor.put(j, countPrimeFactor.getOrDefault(j, 0) + 1);
                        num /= j;
                        break;
                    }
                }
            }
        }
        long count = 1;
        long mod = 1000000007;
        for(int primeNum: countPrimeFactor.values()) {
            count *= (primeNum + 1);
            count %= mod;
        }
        System.out.println(count);
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;
const ll M = 1e2+5;
const ll mod = 1e9+7;

ll dp[L];

void solve()
{
    ll n = nxt(), k = nxt();

    basic_string <ll> a(n, 0);
    generate(all(a), nxt);

    dp[0] = 1;

    for(ll i=0; i<n; i++)
    {
        vector <ll> pref(k + 5, 0);
        for(ll j=k; j>=0; j--)
        {
            ll l = j + 1, r = j + min(a[i], k - j);

            if(l <= r)
            {
                pref[l] += dp[j];
                pref[l] %= mod;

                pref[r+1] -= dp[j];
                pref[r+1] += mod;
                pref[r+1] %= mod;
            }
        }

        for(ll i=1; i<=k; i++)
        {
            pref[i] += pref[i-1];
            pref[i] %= mod;
        }

        for(ll i=0; i<=k; i++)
        {
            dp[i] += pref[i];
            dp[i] %= mod;
        }
    }

    cout << dp[k] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5224
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      int max = 0;
      int output = 0;
      for(int i = 0; i < N; i++){
        if(max <= list.get(i)){
          max = list.get(i);
          output++;
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
  string s;
  cin >> s;
  
  //後ろから解く代わりに全ての文字列を「左右反転」する
  reverse(s.begin(), s.end());
  for (int i=0; i<4; ++i)
    reverse(divide[i].begin(), divide[i].end());
  
  //端から切っていく
  bool can = true;
  for (int i=0; i<s.size();){
    bool can2 = false; //4個の文字列たちどれかでdevideできるか
    for (int j=0; j<4; ++j){
      string d = divide[j];
      if (s.substr(i, d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  
  if(can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
	
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	
	int aa;
	if(a>=x){
		aa=a-x;
	}
	else{
		aa=x-a;
	}

	int bb;
	if(b>=x){
		bb=b-x;
	}
	else{
		bb=x-b;
	}
	
	if(aa<bb){
		printf("A\n");
	}
	else{
		printf("B\n");
	}

    return 0;
}


Measured memory_bytes: 3176
#!/usr/bin/env python
import math

import numpy as np

n = int(input())
flag = np.ones(55555 + 1)

for i in range(2, int(math.sqrt(55555)) + 1):
    if flag[i] == 0:
        continue
    for j in range(2, 55555 // i + 1):
        flag[i * j] = 0

t = [i for i in range(2, 55555 + 1) if flag[i] == 1 and i % 5 == 1]

print(' '.join(map(str, t[:n])))


Measured memory_bytes: 18856
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> a(n);
rep(i,n)
cin >> a[i];
ll sum_xor = 0;
rep(i,n){
    sum_xor = sum_xor ^ a[i];
}
rep(i,n){
    cout << (a[i] ^ sum_xor) << (i == n - 1 ? "\n" : " ");
}
}

Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

//! [Xのi番目までの和で][kが作れるか]
bool dpx[4000][8000];
bool dpy[4000][8000];

int main()
{
	string S;
	cin >> S;
	int x, y;
	cin >> x >> y;
	vector<int> X, Y;
	int n = 0;
	int t = 0;
	REP(i, S.length())
	{
		if (S[i] == 'F')
		{
			n++;
			if (i != S.length() - 1)
			{
				continue;
			}
		}
		t++;
		if (t == 1)
		{
			x -= n;
			n = 0;
			continue;
		}

		if (n != 0)
		{
			if (t % 2 == 1)
			{
				X.push_back(n);
			}
			else
			{
				Y.push_back(n);
			}
		}
		n = 0;
	}

	memset(dpx, 0, sizeof(dpx));
	memset(dpy, 0, sizeof(dpy));
	dpx[0][0] = dpy[0][0] = true;

	ll max = 0;
	FOR(i, X.size() + 1, 1)
	{
		ll m = max;
		REP(j, max + 1)
		{
			if (dpx[i - 1][j])
			{
				m = std::max(m, std::max(j + X[i - 1], abs(j - X[i - 1])));
				dpx[i][j + X[i - 1]] = dpx[i][abs(j - X[i - 1])] = true;
			}
		}
		max = std::max(max, m);
	}
	max = 0;
	FOR(i, Y.size() + 1, 1)
	{
		ll m = max;
		REP(j, max + 1)
		{
			if (dpy[i - 1][j])
			{
				m = std::max(m, std::max(j + Y[i - 1], abs(j - Y[i - 1])));
				dpy[i][j + Y[i - 1]] = dpy[i][abs(j - Y[i - 1])] = true;
			}
		}
		max = std::max(max, m);
	}

	if (dpx[X.size()][abs(x)] && dpy[Y.size()][abs(y)])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 62848
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main(void)
{
    int n,l;
    while(scanf("%d%d",&n,&l)!=EOF)
    {
    	vector<string>words;
    	string s;
    	for(int i=0;i<n;i++)
       {
       	cin>>s;
       	words.push_back(s);
	   }
	   sort(words.begin(),words.end());
	   for(int i=0;i<words.size();i++)
	    cout<<words[i];
	    cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from numba import njit
from numpy import int32,zeros,arange
@njit('i4(i4[:])')
def solve(s):
    a=0
    d=zeros(2019,int32)
    for i in s:
        p=zeros(2019,int32)
        for j in range(2019):p[(j*10+i)%2019]+=d[j]
        d=p
        d[i]+=1
        a+=d[0]
    return a
print(solve(int32([*input()])))

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

vector<vector<P>> g;
vector<int> visit;
int colorSize;
map<P, int> color;

void dfs(int node, int edgeColor) {
	if (visit[node]) return;
	visit[node] = 1;
	unordered_set<int> used;
	used.insert(edgeColor);
	int current = 0;
	for (P edge : g[node]) {
		auto f = color.find(edge);
		if (f == color.end()) {
			while (used.count(current)) {
				current++;
			}
			color.emplace(edge, current);
			used.insert(current);
		}
	}
	for (auto e : g[node]) {
		if (e.first == node) {
			dfs(e.second, color.at(e));
		}
		else {
			dfs(e.first, color.at(e));
		}
	}
}


int main(void)
{
	ll n;
	cin >> n;
	g.resize(n);
	visit.resize(n, 0);
	vector<P> input;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(a,b);
		g[b].emplace_back(a,b);
		input.emplace_back(a, b);
	}
	dfs(0, -1);
	colorSize = 0;
	for (auto e : input) {
		colorSize = max(colorSize, color.at(e) + 1);
	}
	cout << colorSize << endl;
	for (auto e : input) {
		cout << color.at(e)+1 << endl;
	}


	return 0;
}


Measured memory_bytes: 27636
n = input()
n = n.split()
d = int(n[1])
n = int(n[0])
c = 0
for a in range(n):
    b = input()
    b = b.split()
    x = int(b[0])
    y = int(b[1])
    if x * x + y * y <= d * d:
        c = c + 1
print(c)

Measured memory_bytes: 9088
#include <iostream>
#include <numeric>
#include <queue>
#include <cstring>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
int dp[1<<16][16];
int dis[20][20];
int V,E;
const int inf=1e9+5;

int rec(int S,int v)
{
  if(dp[S][v]>=0)
    {
      return dp[S][v];
    }
  if(S==(1<<V)-1 && v==0)
    {
      return dp[S][v]=0;
    }
  int res=inf;
  for(int u=0;u<V;u++)
    {
      if(!(S>>u & 1))
	{
	  res=min(res,rec(S | (1<<u),u)+dis[v][u]);
	}
    }
  return dp[S][v]=res;
}

int main(int argc,char const* argv[])
{
  memset(dp,-1,sizeof(dp));
  memset(dis,inf,sizeof(dis));
  cin >> V >> E;
  for(int i=0;i<E;i++)
    {
      int s,t,d;
      cin >> s >> t >> d;
      dis[s][t]=d;
    }
  int ans=rec(0,0);
  if(ans>150000)
    {
      cout << -1 << endl;
    }
  else
    {
      cout << ans << endl;
    }
  return 0;
}



Measured memory_bytes: 7196
#include<bits/stdc++.h>
using namespace std;
string m,n="CODEFESTIVAL2016";
int tot; 
int main()
{
    cin>>m;
    for(int i=0;i<16;i++)
	{
        if(m[i]!=n[i]) tot++;
    }
    cout<<tot;
	cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 500000
#define INFTY 1000000000
void merge(int *,int,int,int);
void sort(int *,int,int);
int right[N/2+2],left[N/2+2],cnt=0;

int main() {
  int i,n,S[N];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
  sort(S,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",S[i]);
    else printf("%d ",S[i]);
  }
  printf("%d\n",cnt);
  return 0;
}
void merge(int S[],int left_s,int mid,int right_s){
  int s1 = mid - left_s;
  int s2 = right_s - mid;
  int i,j=0,m;
  for(i=0;i<s1;i++)left[i]=S[left_s+i];
  for(i=0;i<s2;i++)right[i]=S[mid+i];
  left[s1]=INFTY;
  right[s2]=INFTY;
  i=0;
  for(m=left_s;m<right_s;m++){
    cnt++;
    if(right[j]>=left[i]){
      S[m]=left[i];
      i++;
    }
    else {
      S[m]=right[j];
      j++;
    }
  }
}
void sort(int S[],int left_s,int right_s){
  int mid;
  if(left_s + 1 < right_s){
    mid=(left_s + right_s)/2;
    sort(S,left_s,mid);
    sort(S,mid,right_s);
    merge(S,left_s,mid,right_s);
  }
}



Measured memory_bytes: 5672
#include <iostream>
#include <vector>
#include <map>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

long long calc(long long N, long long A, long long B, long long C, long long D, map<long long, long long>& mp)
{
    if(N == 0) return 0;
    if(N == 1) return D;
    if(mp.count(N)) return mp[N];

    long long y, t;
    mp[N] = ((long long) 1) << 60;
    if(1e+18/D > N) mp[N] = N*D;

    for(t = 0, y = N; y%2 != 0; ++y, ++t);
    mp[N] = min(mp[N], (y/2? calc(y/2, A, B, C, D, mp)+A: 0) + t*D);
    for(t = 0, y = N; y%2 != 0; --y, ++t);
    mp[N] = min(mp[N], (y/2? calc(y/2, A, B, C, D, mp)+A: 0) + t*D);

    for(t = 0, y = N; y%3 != 0; ++y, ++t);
    mp[N] = min(mp[N], (y/3? calc(y/3, A, B, C, D, mp)+B: 0) + t*D);
    for(t = 0, y = N; y%3 != 0; --y, ++t);
    mp[N] = min(mp[N], (y/3? calc(y/3, A, B, C, D, mp)+B: 0) + t*D);

    for(t = 0, y = N; y%5 != 0; ++y, ++t);
    mp[N] = min(mp[N], (y/5? calc(y/5, A, B, C, D, mp)+C: 0) + t*D);
    for(t = 0, y = N; y%5 != 0; --y, ++t);
    mp[N] = min(mp[N], (y/5? calc(y/5, A, B, C, D, mp)+C: 0) + t*D);

    return mp[N];
}

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

    while(T--){
        long long N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;

        map<long long, long long> mp;
        cout << calc(N, A, B, C, D, mp) << endl;
    }

    return 0;
}

Measured memory_bytes: 4304
#include <stdio.h>
long long n[1000005]={0};
int main() 
{
    long long i,z,j=0;
    long long  sum=0;
    scanf("%lld",&z);
    for(i=1;i<=z;i++)
    {
    	if(i%3==0||i%5==0||(i%5==0&&i%3==0))
    	    continue;
	    n[j]=i;
	    j++;
	}
	for(i=0;i<=z;i++)
	{
		sum =sum+n[i];
	}
	printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 5848
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		Array.Sort(A);
		long[]NC = new long[100010];
		long[]ND = new long[100010];
		NC[0] = 1;
		ND[0] = 1;
		NC[1] = 1;
		ND[1] = 1;
		long mod = 1000000007;
		for(var i=2;i<100010;i++){
			NC[i] = NC[i-1] * i % mod;
			ND[i] = ND[i-1] * Mpow(i,mod-2,mod) % mod;
			//Console.Error.WriteLine(NC[i]+" "+ND[i]);
		}
		long[]B = new long[100010];
		B[K-1] = 1;
		for(var i=K;i<100010;i++){
			long a1 = i;
			long b1 = i-K+1;
			B[i] = NC[a1] * ND[b1] % mod * ND[a1-b1] % mod;
			//Console.Error.WriteLine(B[i]+" "+a1+" "+NC[a1]+" "+(a1-b1)+" "+ND[a1-b1]);
		}
		long min1 = 0;
		long max1 = 0;
		for(var i=0;i<N;i++){
			min1 = min1 + B[i] * A[i] % mod;
		}
		for(var i=N-1;i>=0;i--){
			max1 = max1 + B[N-1-i] * A[i] % mod;
		}
		Console.Error.WriteLine(min1+" "+max1);
		Console.WriteLine((min1-max1+mod)%mod);
	}
	
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}

	public static long Ncr(long n,long r,long m)
	{
		long ans = 1;
		for(var i=n-r+1;i<=n;i++){
			ans = ans * i % m;
		}
		for(var i=2;i<=r;i++){
			ans = ans * Mpow(i,m-2,m) % m;
		}
		return ans;
	}
}

Measured memory_bytes: 29276
n,a,b=map(int, input().split())
r=0
for x in range(1,n+1):
    p=str(x)
    l=len(p)
    s=0
    for y in range(l):
       s=s+int(p[y]) 
    if s>=a and s<=b:
        r+=x
print(r)

Measured memory_bytes: 3060