akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
struct cmp
{
	int high, y;
};
int main()
{
	struct cmp x[100010];
	int n, m, i, j=0, a, b;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &x[i].high);
		x[i].y = 1;
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d%d", &a, &b);
		if (x[a - 1].high < x[b - 1].high)
		{
			x[a - 1].y *= 0;
		}
		else if(x[a - 1].high > x[b - 1].high)
		{
			x[b - 1].y *= 0;
		}
		else
		{
			x[a - 1].y *= 0;
			x[b - 1].y *= 0;
		}
	}
	for (i = 0; i < n; i++)
	{
		if (x[i].y == 1)
		{
			j++;
		}
	}
	printf("%d", j);
	return 0;
}

Measured memory_bytes: 2512
let () = Scanf.scanf "%d %d" @@ fun a b ->
  let array = Array.make 100 false in
  for i=1 to 9 do
    for j=1 to 9 do
      array.(i*j) <- true
    done
  done;
  Printf.printf "%d\n" @@
  if a <= 9 && b <= 9
  then a*b
  else -1

Measured memory_bytes: 3784
number = int(input())
word1, word2 = input().split()
moji = ''

word1 = list(word1)
word2 = list(word2)

newword = []

for i in range(number):
    newword.append(word1[i])
    newword.append(word2[i])

moji = ''.join(newword)

print(moji)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> ans(n + 1);
	for (int x = 1; x <= 100; ++x)
		for (int y = 1; y <= 100; ++y)
			for (int z = 1; z <= 100; ++z) {
				int t = x * x + y * y + z * z + x * y + y * z + z * x;
				if (t <= n) ans[t]++;
			}
	for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
}


Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var c = str.Count();
            var ind1 = 0;
            var ind2 = 0;
            for (int i = 0; i < c; i++)
            {
                if (str[i] == 'A')
                {
                    ind1 = i;
                    break;
                }
            }
            for (int i = 0; i < c; i++)
            {
                if (str[i] == 'Z')
                {
                    ind2 = i;
                }
            }
            Console.WriteLine(ind2-ind1 +1);

        }
    }

}

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

#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define deb(x) cerr<<#x" = "<<x<<nl
#define in() ( { int a ; scanf("%d",&a); a; } )

const int N = 3e5 + 9;
const int mod = 1e9 + 7;

int32_t main()
{
    ll a, b; cin>>a>>b; cout<<a*b/__gcd(a, b)<<nl;
    return 0;
}


Measured memory_bytes: 256
import Data.List
import qualified Data.Set as S

main = do
    s<-getLine::IO String
    let cs = foldl (flip S.delete) (S.fromList ['a'..'z']) s
    putStrLn $ if not $ null cs then s ++ [S.findMin cs] else sol cs $ reverse s
--
sol _ [c]
    | c=='z' = "-1"
    | otherwise = [succ c]
sol cs (c:a:s) = case cm of
    Just x -> reverse (x:s)
    _      -> sol cs' (a:s)
    where
        cs' = S.insert c cs
        cm = S.lookupGT a cs'


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

using namespace std;
vector<vector<bool>> isWhite;
vector<vector<int>> dp;

int h, w;

int returnMin(int c, int r)
{
    int extraOps = 0;
    if (c >= w || r >= h)
        return 10000000;
    if (dp[r][c] != -1)
        return dp[r][c];
    int extraOnder = 0;
    int extraRechts = 0;
    if(r >= h -1)
        extraOnder = 10000000;
    else if (isWhite[r][c] && !isWhite[r + 1][c])
        extraOnder++;
    if(c >= w -1)
        extraRechts = 10000000;
    else if (isWhite[r][c] && !isWhite[r][c + 1])
        extraRechts++;

    return dp[r][c] = min(extraRechts + returnMin(c + 1, r), extraOnder + returnMin(c, r + 1));
}

int main()
{
    cin >> h >> w;
    isWhite = vector<vector<bool>>(h, vector<bool>(w, 0));
    dp = vector<vector<int>>(h, vector<int>(w, -1));
    char c;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c;
            if (c == '.')
                isWhite[i][j] = true;
        }
    }
    dp[h - 1][w - 1] = 0;
    if (isWhite[0][0])
        cout << returnMin(0, 0) << endl;
    else
        cout << returnMin(0, 0) + 1 << endl;
    return 0;
}

/*#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	return 0;
}
 
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}

using namespace std;
 
int main() {
	return 0;
}*/

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static inline constexpr ld temp(int T, int x) { return T - x * 0.006; }

int main() {
  ld N, T, A;
  cin >> N >> T >> A;

  int answer = 0;
  ld near = numeric_limits<int>::max();
  REP1(i, N) {
    ld H;
    cin >> H;
    const ld t = temp(T, H);
    const ld d = abs(t - A);
    if (d < near) {
      answer = i;
      near = d;
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3728
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	char ori[60][60],sub[60][60];
	int m, n;
	cin >> m >> n;
	rep(i, 0, m) {
		rep(j, 0, m) {
			cin >> ori[i][j];
		}
	}

	rep(i, 0, n) {
		rep(j, 0, n) {
			cin >> sub[i][j];
		}
	}

	rep(i, 0, m - n+1) {
		rep(j, 0, m - n+1) {
			bool key = true;
			if (ori[i][j] == sub[0][0]) {
				rep(k, 0, n) {
					rep(l, 0, n) {
						if (ori[i + k][j + l] != sub[k][l]) {
							key = false;
						}
						if (k == n - 1 && l == n - 1&&key==true) {
							Yes;
							return 0;
						}
					}
				}
			}
		}
	}

	No;

	return 0;
}


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

#define int ll 
typedef long long        ll;
 
#define fastio        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
 
const int N = 2e5+7; 

void solve() {
	int x, y;	cin >> x >> y;
	for (int l1 = 0; l1 <= x; l1++) {
		int t = 2 * l1 + 4 * (x - l1);
		if (t == y) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

signed main() {
 
    fastio;
    int t = 1;	
    // cin > > t;
    while (t--) {
    	solve();
    }

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
    //freopen("a.in","r",stdin);
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.15lf\n", sqrt(r2));
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(void)
{
  int sec;
  std::cin >> sec;
  int hour = sec / 3600;
  sec = sec % 3600;
  int min = sec / 60;
  sec = sec % 60;
  std::cout << hour << ':' << min << ':' << sec << '\n';
  return 0;
}

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

#define int long long

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int a, b, c;
    cin>>a>>b>>c;
    swap(a, b);
    swap(a, c);
    cout<<a<<" "<<b<<" "<<c<<"\n";
    

    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print(b+1)
    return

#C
def C():
    def dfs(d,k):
        if d == n:
            l.append(k)
        else:
            dfs(d+1,k+[0])
            dfs(d+1,k+[1])
    n,m = LI()
    l = []
    dfs(0,[])
    qu = LIR(m)
    p = LI()
    ans = 0
    for k in l:
        s = 0
        for q in range(m):
            num = qu[q][0]
            lis = list(map(lambda x:x-1, qu[q][1:]))
            su = 0
            for i in lis:
                su ^= k[i]
            if su == p[q]:
                s += 1
        if s == m:
            ans += 1
    print(ans)
    return

#D
def D():
    n,k = LI()
    v = LI()
    ans = -float("inf")
    for l in range(min(k,n)+1):
        for r in range(min(k,n)-l+1):
            m = 0
            q = v[:l]+v[n-r:]
            q.sort()
            res = max(0,k-r-l)
            for i in range(len(q)):
                if q[i] < 0 and res > 0:
                    res -= 1
                else:
                    m += q[i]
            if m > ans:
                ans = m
    print(ans)
    return

#E
def E():
    n,q = LI()
    a = LIR(n)
    a.sort(key = lambda x : x[2])
    d = IR(q)
    ans = [-1]*(q+1)
    right = [0]*q
    for s,t,x in a:
        l = bisect.bisect_left(d,s-x)
        r = bisect.bisect_left(d,t-x)
        while l < r:
            while ans[l] != -1:
                l = right[l]
            if r <= l:
                break
            ans[l] = x
            right[l] = r
            l += 1
    print(*ans[:-1], sep = "\n")
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 96460
#include <iostream>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, ans = 0; cin>>n;
	for(ll i = 1;i<=n;i++){
		ans += i*(n / i)*(n/i + 1) / 2;
	}
	cout<<ans;
}

Measured memory_bytes: 3168
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc159_a();
	}
  
  	public static void solve_abc159_a(){

		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int ans = N * (N- 1) / 2 + M * (M - 1) / 2;
		System.out.println(ans);

		sc.close();
	}

}

Measured memory_bytes: 22608
#include <stdio.h>

#define N 100000

int main(void) {
    int n;
    int arr[N];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        arr[x-1] = i + 1;
    }

    printf("%d", arr[0]);
    for (int i = 1; i < n; i++) {
        printf(" %d", arr[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

const int MAXN = 1e5 + 10;
int n, m, first[MAXN], tot, d[MAXN], s, t;

struct edge { int from, v, w; } e[20 * MAXN];
struct Node
{
	int x, d;
	bool operator <(const Node &b)const
	{
		return d > b.d;
	}
}cyc;
priority_queue<Node> q;
inline void insert(int u, int v, int w)
{
	tot++; e[tot].v = v; e[tot].w = w; e[tot].from = first[u]; first[u] = tot;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (register int i = 1; i <= n; i++)
		for (register int j = 0; j <= 9; j++)insert(i, ((i - 1) * 10 + j) % n + 1, j);
	for (register int j = 1; j <= 9; j++) insert(0, j + 1, j);
	s = 0; t = 1;
	memset(d, 0x3f, sizeof d);
	d[s] = 0; q.push((Node) { s, d[s] });
	while (!q.empty())
	{
		cyc = q.top(); q.pop();
		if (cyc.d != d[cyc.x])continue;
		register int x = cyc.x;
		for (register int i = first[x]; i; i = e[i].from)
			if (d[e[i].v] > d[x] + e[i].w)
			{
				d[e[i].v] = d[x] + e[i].w;
				q.push((Node) { e[i].v, d[e[i].v] });
			}
	}
	return cout << d[t], 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,M;
ll ma[10];
const ll mn[]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
ll dp[10101][11],dpr[10101];
ll i,j,k;

int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i,0,M){
        ll aa = 0;
        scanf("%lld", &aa);
        ma[aa] = 1;
    }
    fornum(i,0,N){
        dpr[i + 1] = -1;
    }
    fornum(i,0,N){
        if(dpr[i]==-1)
            continue;
        fornum(j,1,10){
            //printf("%lld ", dp[i][j]);
            if(!ma[j])
                continue;
            ll flag = 1;
            if(dpr[i+mn[j]]==dpr[i]+1){
                fornum(k,0,9){
                    ll a= dp[i][9-k] + (j == 9-k ? 1 : 0)-dp[i + mn[j]][9-k];
                    if(a>0){
                        flag = 0;
                        break;
                    }else if(a<0){
                        break;
                    }
                }
            }
            if(dpr[i+mn[j]]>=dpr[i]+1&&flag==1)
                continue;
            dpr[i + mn[j]] = dpr[i] + 1;
            fornum(k,1,10){
                dp[i + mn[j]][k] = dp[i][k] + (j == k ? 1 : 0);
            }
        }
        //printf("\n");
    }
    fornum(i,0,9){
        fornum(j,0,dp[N][9-i]){
            printf("%lld", 9 - i);
        }
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);

//再帰で書いたほうがシンプル．


ll attack(ll x){
  ll num;
  if(x == 1) return 1;
  else {
    num = 2 * attack(x/2) + 1;
    return num;
  }
}


int main(){
  ll h;
  cin >> h;
  ll ans = 0;
  ans = attack(h);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3532
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$A = $key->X[0];
$mx = max($A);
$mi = min($A);
printf("%d\n",$mx-$mi);


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
 int	n=s.size();
	if(n>=6)
	{
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
    }
    else if(n>=4)
    {
    if(s[2]==s[3])
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	}
	else
	{
		cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    ll K;
    cin >> s;
    cin >> K;
    map<string, ll> m;
    REP(i, 7) {
        REP(j, s.length() - i + 1) { m[s.substr(j, i)]++; }
    }
    debug(m);
    ll counter = 0;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        counter++;
        if (counter == K+1) {
            cout << iter->first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
// #include "bits:stdc++.h"
using namespace std;
#define pb push_back
#define LLINF 1234567890987654321
#define INF 1234567890
#define f first
#define s second
#define flase false
typedef long long ll;
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
ll n, A[100000], ans_total;
int main()
{
	// freopen("inputfile.cpp", "r", stdin);
	cin >> n;
	for(ll i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	for(ll i = 0; i < n; i++)
	{
		ans_total += max((ll)0, A[i]-1); 
	}
	cout << ans_total << '\n';
}


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

using namespace std;

const int mod = 1'000'000'007;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int get(int b) {
  int res = pw(10, b);
  add(res, mod - pw(10, b - 1));
  return res;
}

int main() {
  int s;
  scanf("%d", &s);
  int ans = 0;
  for (int i = 1; i <= s; ++i) {
    if (s % i == 0) {
      int cnt = get(i);
      if (i >= 9 || cnt >= s / i) {
        add(ans, cnt);
        add(ans, mod - s / i + 1);
      }
    }
  }
  for (int i = 1; i <= 8; ++i) {
    long long v = 0;
    for (int j = i + 1; j <= 9; ++j) {
      for (int k = 1; k <= get(i); ++k) {
        if (v + i * k >= s) {
          break;
        }
        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= get(j)) {
          add(ans, 1);
        }
      }
      v += j * get(j);
      if (v >= s) {
        break;
      }
    }
  }
  for (int i = 9; i < s; ++i) {
    int v = s / (i + 1);
    if (s % (i + 1) == 0) {
      --v;
    }
    int r = s % i;
    if (v >= r) {
      add(ans, (v - r) / i + (r != 0));
    }
  }
  printf("%d\n", ans);
}


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

using namespace std;

int main() {
  int D;
  
  cin >> D;
  
  if (D == 25) {
    cout << "Christmas" << endl;
  }
  else if (D == 24) {
    cout << "Christmas Eve" << endl;
  }
  else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  }
  else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}

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

int main(){
    string T;
    cin >> T;
    int N = T.size();
    vector<int> A(N);
    for(int i=0; i<N; i++) A[i] = T[i]-'0';
    
    int64_t one = accumulate(A.begin(), A.end(), 0);
    int64_t pairs = 0;
    vector<int> B;
    for(int a : A){
        if(a && B.size() && B.back()){
            pairs++;
            B.pop_back();
        }else{
            B.push_back(a);
        }
    }
    int sz = B.size();
    vector<int> S0(sz+1);
    for(int i=0; i<sz; i++) S0[i+1] = S0[i] + (B[i]==0);

    int64_t ans = 0;
    for(int i=0; i<sz; i++) if(B[i]) ans += (S0[i]+(i%2==0))/2 + (S0[sz] - S0[i]);
    ans += S0[sz]*pairs;
    while(one){
        ans += (one+1)/2;
        one--;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5968
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int p[200010];
int root(int x){
	return x == p[x] ? x : (p[x] = root(p[x]));
}
void merge(int a, int b){
	a = root(a); b = root(b);
	if(a != b) p[b] = a;
}


int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vi cost(n, 2e9);
	vector<tuple<int,int,int>> e;
	rep(i, m){
		int a, b, c; cin >> a >> b >> c;
		e.emplace_back(c, a, b);
		cost[a] = min(cost[a], c + 1);
		cost[b] = min(cost[b], c + 2);
	}
	rep(i, 2 * n) cost[(i + 1) % n] = min(cost[(i + 1) % n], cost[i % n] + 2);
	rep(i, n){
		p[i] = i;
		e.emplace_back(cost[i], i, (i + 1) % n);
	}
	sort(all(e));
	
	ll ans = 0;
	for(auto i : e){
		int c, a, b; tie(c, a, b) = i;
		if(root(a) == root(b)) continue;
		merge(a, b);
		ans += c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9200
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	char a[1], b[1];
	cin >> a >> b;
	if (a[0] == b[0])
		printf("=");
	else if (a[0] < b[0])	
		printf("<");
	else
		printf(">");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

int main(void) {
	ll x,y = 100;
	scanf("%ld", &x);
	for (int i = 1;; i++) {
		y += y / 100;
		if (y >= x) {
			printf("%d\n", i);
			return 0;
		}
	}
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b;
  	cin >> a >> b;
  	int res=0,m = min(a,b),M=max(a,b);
  	for(int i=0;i<M;i++){
    	res += m*pow(10,i);
    }
  	cout << res << endl;
}

Measured memory_bytes: 4008
let () =
  let q, h, s, d = Scanf.scanf "%d %d %d %d\n" (fun q h s d -> q, h, s, d) in
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  [(1, q); (2, h); (4, s); (8, d)]
  |> List.sort (fun (size, price) (size', price') -> compare (price * size') (price' * size))
  |> List.fold_left (fun (acc, n) (size, price) -> (acc + n / size * price, n mod size)) (0, 4 * n)
  |> fst
  |> Printf.printf "%d\n"

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

int main() {
  int N;
  cin >> N;
 
  if (N/100 >= 7 && N/100 < 8) {
    cout << "Yes" << endl;
  }
  else if (N%100/10 >= 7 && N%100/10 <8){
    cout << "Yes" << endl;
  }
  else if (N%100%10 >= 7 && N%100%10 <8){
    cout << "Yes" << endl;
  }
  else  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
char c;cin>>c;
if(c>='a')
cout<<'a';
else
cout<<"A";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int MAX=1e6+10;
int main()
{
    LL b[5];
    LL k;
    cin >> b[0] >> b[1] >> b[2];
    cin >> k;
    sort(b, b+3);
    for(int i = 1; i <= k; i++)
    b[2] = (LL)2*b[2];
    cout << b[0]+b[1]+b[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define ll long long
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;
		
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) {
  cout<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}";
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#define endl '\n'
#endif

struct edge{
	int a, b, weight;
};
		
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
		
long long modInverse(long long a, long long m) { 
    if(__gcd(a, m) != 1){
		throw "modular inverse does not exist.";
	}
	long long m0 = m;
    long long y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1) {  
        long long q = a / m; 
        long long t = m;  
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }  
    if (x < 0) 
       x += m0; 
    return x; 
} 
 
long long modExp(long long a, long long b, long long p) {
	long long res = 1;
	long long mult = a;
	while (b > 0) {
		if (b % 2 != 0) {
			res = (res * mult) % p;
		}
		mult = (mult * mult) % p;
		b >>= 1;
	}
	return res;
}
 
vector<int> sieveOfEratosthenes(int n) {
	vector<int> primes;
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int p = 2; p * p <= n; p++) {
		if (prime[p] == true) {
			for (int i = p * p; i <= n; i += p)
				prime[i] = false;
		}
	}
	for (int p = 2; p <= n; p++)
		if (prime[p])
			primes.push_back(p);
	return primes;
}
 
void solve() {
	int a, b;
	cin >> a >> b;
	cout << a*b;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
long i,j,n,x[100010],y[100010],t[100010];
int main ()
{
    cin >> n ;
    for (i=1;i<=n;i++)
    {
        cin >> t[i] >> x[i] >> y[i];
        long a=(fabs(x[i]-x[i-1])+fabs (y[i]-y[i-1]));
        if (( a-t[i]-t[i-1])%2  !=0 || a>t[i]-t[i-1] )
            j++;
    }
    cout << (j>0 ? "No" : "Yes" ) ;;
    return 0;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  if(x < 600) cout << 8 << endl;
  else if(x < 800) cout << 7 << endl;
  else if(x < 1000) cout << 6 << endl;
  else if(x < 1200) cout << 5 << endl;
  else if(x < 1400) cout << 4 << endl;
  else if(x < 1600) cout << 3 << endl;
  else if(x < 1800) cout << 2 << endl;
  else if(x < 2000) cout << 1 << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  int q[60];
  for (int i=0; i<60; i++) {
    q[i] = 0;
  }
  for (int i=0; i<m*2; i++) {
    int p = 0;
    cin >> p;
    q[p] += 1;
  }
  for (int i=1; i<=n; i++) {
    cout << q[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const p=1e9+7;
ll a[200005],b[200005];
bool cmp(ll x,ll y){return x>y;}
ll pw(ll x,ll y)
{
    x=(x%p+p)%p;
    ll res=1;
    while(y)
    {
        if(y&1)res*=x,res%=p;
        x*=x,x%=p;
        y>>=1;
    }
    return res;
}
int main()
{
    int n,k,t1=0,t2=0,now1=0,now2=0,r;
    ll x,ans=1;
    scanf("%d%d",&n,&k);
    r=k;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&x);
        if(x>=0)a[++t1]=x;
        else b[++t2]=x;
    }
    sort(a+1,a+t1+1,cmp);
    sort(b+1,b+t2+1);
    while(k>=2)
    {
        if(t1-now1>=2&&t2-now2>=2)
        {
            if(a[now1+1]*a[now1+2]>b[now2+1]*b[now2+2])
                ans*=a[now1+1],ans%=p,ans*=a[now1+2],ans%=p,now1+=2;
            else
                ans*=b[now2+1],ans%=p,ans*=b[now2+2],ans%=p,now2+=2;
        }
        else if(t1-now1>=2)
        {
            ans*=a[now1+1],ans%=p,ans*=a[now1+2],ans%=p,now1+=2;
        }
        else if(t2-now2>=2)
        {
            ans*=b[now2+1],ans%=p,ans*=b[now2+2],ans%=p,now2+=2;
        }
        else
        {
            ans*=a[now1+1],ans%=p;
            ans*=b[now2+1],ans%=p;
        }
        k-=2;
    }
    if(k)
    {
        if(now1<t1)ans*=a[now1+1],ans%=p;
        else
        {
            if(t2-now2>=2&&now1>=2)
            {
                ans*=pw(a[now1],p-2);
                ans%=p;
                ans*=b[now2+1];
                ans%=p;
                ans*=b[now2+2];
                ans%=p;
            }
            else
            {
                k=r;
                ans=1;
                for(int i=1;i<=t1;i++)ans*=a[i],ans%=p;
                k-=t1;
                for(int i=t2;k;i--,k--)ans*=b[i],ans%=p;
            }
        }
    }
    printf("%lld",(ans%p+p)%p);
    return 0;
}

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

using namespace std;

typedef long long llint;

const int MAXN = 100005;

llint n, tip, ofs, cnt;
llint a[MAXN];
vector <llint> v;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    for (int i=1; i<n; i++) {
        ofs--;
        if (a[i] == a[i-1]) {
            tip = !tip;
            continue;
        }
        if ((a[i] - a[i-1]) % 2 == tip) v.push_back(a[i-1] + 1-tip - ofs);
        tip = 0;
    }
    for (auto x : v) {
        llint val = x + ofs;
        if (val == 1 || val == 2) {
            cout << "First";
            return 0;
        }
        if (val > 1) cnt++;
    }
    if ((a[n-1] + tip + cnt) % 2 == 0) cout << "First"; else cout << "Second";
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a)%mod,n/2))%mod;
	else
	  return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}


int main()
 {
      IOS;
  ll d,t,s;
  cin>>d>>t>>s;
  if(d<=t*s)
  {
  	cout<<"Yes"<<endl;
  }
  else
  {
  	cout<<"No"<<endl;
  }
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;
vector <set<int>> t;
vector <int >ar;
void build(int v, int tl, int tr){
    if(tl == tr){
        t[v].insert(ar[tl]);
        return;
    }
    int tm =(tl + tr) >> 1;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v].clear();
    set_union(t[v * 2].begin(), t[v * 2].end(),
            t[v * 2 + 1].begin(), t[v * 2 + 1].end(),
            inserter(t[v], begin(t[v])));
}
void modify(int v, int tl, int tr, int p, int x){
    if(tl == tr){
        t[v].clear();
        t[v].insert(x);
        return;
    }
    int tm = (tl +tr) >> 1;
    if(p <= tm)
        modify(v * 2, tl, tm, p,x);
    else
        modify(v * 2 + 1, tm + 1, tr, p,x);
    t[v].clear();
    set_union(t[v * 2].begin(), t[v * 2].end(),
            t[v * 2 + 1].begin(), t[v * 2 + 1].end(),
            inserter(t[v], begin(t[v])));
}
set<int> get(int v, int tl, int tr, int l, int r){
    if(l > r)
        return set<int> ();
    if(tl == l && tr == r)
        return t[v];
    int tm = (tl + tr) >> 1;
    set<int>res;
    set<int> sl = get(v * 2,tl,tm, l, min(tm,r));
    set<int> sr =get(v * 2 + 1,tm + 1,tr, max(l,tm + 1), r);
    set_union(sl.begin(), sl.end(),
            sr.begin(), sr.end(),
            inserter(res, begin(res)));
    return res;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n;
    cin >> n;
    t.resize(n * 4);
    ar.resize(n);
    for(int i = 0; i < n; ++i){
        char c;
        cin >> c;
        ar[i] = c - 'a';
    }
    build(1,0, n - 1); 
    int q;
    cin >> q;
    while(q--){
        int c;
        cin >> c;
        if(c == 1){
            int p;
            char x;
            cin >> p >> x;
            --p;
            modify(1,0, n - 1,p,x - 'a');
        }
        else{
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << get(1,0, n - 1, l, r).size() << '\n';
        }
    }
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 237184
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < N2; i++) {
			for (int j = 0; j < N2; j++) {
				MDT[i][j] = Math.abs(i / N - j / N) + Math.abs(i % N - j % N);
			}
		}
		Puzzle in = new Puzzle();
		for (int i = 0; i < N2; i++) {
			in.map[i] = scanner.nextInt();
			if (in.map[i] == 0) {
				in.space = i;
			}
		}
		iterative_deepening(in);
		System.out.println(limit);
	}

	private void iterative_deepening(Puzzle in) {
		in.MD = getAllMD(in);
		for (limit = in.MD; limit <= 45; limit++) {
			state = in.clone();
			if (dfs(0, -3)) {
				return;
			}
		}
	}

	private boolean dfs(int depth, int prev) {
		if (state.MD == 0)
			return true;
		if (depth + state.MD > limit)
			return false;

		int y = state.space / N;
		int x = state.space % N;
		for (int i = 0; i < 4; i++) {
			int dy = y + dxy[i][0];
			int dx = x + dxy[i][1];
			if (dy < 0 || dx < 0 || N <= dy || N <= dx)
				continue;
			if (Math.max(i, prev) - Math.min(i, prev) == 2)
				continue;
			int newSpace = dy * N + dx;
			Puzzle tmpPuzzle = state.clone();
			state.MD -= MDT[newSpace][state.map[newSpace] - 1];
			state.MD += MDT[state.space][state.map[newSpace] - 1];
			swap(newSpace, state.space);
			state.space = newSpace;
			if (dfs(depth + 1, i)) {
				return true;
			}
			state = tmpPuzzle;

		}
		return false;
	}

	private void swap(int newSpace, int space) {
		int tmp = state.map[newSpace];
		state.map[newSpace] = state.map[space];
		state.map[space] = tmp;
	}

	private int getAllMD(Puzzle in) {
		int sum = 0;
		for (int i = 0; i < N2; i++) {
			if (in.map[i] == 0)
				continue;
			sum += MDT[i][in.map[i] - 1];
		}
		return sum;
	}

	int N = 4;
	int N2 = 16;
	int[][] MDT = new int[N2][N2];
	int limit;
	Puzzle state;
	int[][] dxy = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };

	class Puzzle implements Cloneable {
		int[] map = new int[N2];
		int space;
		int MD;

		@Override
		public Puzzle clone() {
			Puzzle clonePuzzle;
			try {
				clonePuzzle = (Puzzle) super.clone();
				clonePuzzle.map = Arrays.copyOf(map, N2);
				return clonePuzzle;
			} catch (CloneNotSupportedException e) {
				throw new InternalError();
			}

		}

	}
}

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

class Dice {
    int num[6];
    public:
        void set(int n, int d){
            num[n] = d;
        }
        
        void roll(char c){
            if(c == 'N'){
                swap(num[0],num[1]);
                swap(num[1],num[5]);
                swap(num[5],num[4]);
            }else if(c == 'W') {
                swap(num[0],num[2]);
                swap(num[2],num[5]);
                swap(num[5],num[3]);
            }else if(c == 'S') {
                swap(num[0],num[4]);
                swap(num[4],num[5]);
                swap(num[5],num[1]);
            }else{
                swap(num[0],num[3]);
                swap(num[3],num[5]);
                swap(num[5],num[2]);
            }
        }
        
        int up(){
            return num[0];
        }
        
        void rollUp(int n){
            for(int i=0; up() != n && i<4;i++){
                roll('E');
            }
            for(int i=0; up() != n && i<4;i++){
                roll('N');
            }
        }
        
        int fromUpToRight(int n, int f) {
            rollUp(n);
            if(num[1] == f){
                return num[2];
            }else if(num[2] == f){
                return num[4];
            }else if(num[3] == f) {
                return num[1];
            }else{
                return num[3];
            }
        }
};

int main(){
    Dice d;
    int num,q,n,f;

    for(int i=0;i<6;i++){
        cin >> num;
        d.set(i,num);
    }
    
    cin >> q;
    
    for(int i=0;i<q;i++){
        cin >> n >> f;
        cout << d.fromUpToRight(n,f) << endl;
    }
    
    
}


Measured memory_bytes: 3080
import java.util.Scanner;	
public class Main {
    public static void main(String[] args) throws Exception {
    Scanner stdIn= new Scanner(System.in);
    int K=stdIn.nextInt();
    String S = stdIn.next();
    for(int t=0;t<K;t++){
       if(S.length()<t+1)break;   
    System.out.print(S.charAt(t));
    }
    if(S.length()>K)System.out.print("...");
  }
}
 


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 2010;

int n, m, q;
int cntr[N][N], cntc[N][N], sum[N][N], A[N][N];

inline int calc(int S[N][N], int x1, int x2, int y1, int y2){
	--y1, --x1;
	return S[x2][y2] + S[x1][y1] - S[x2][y1] - S[x1][y2];
}

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

	For(i, 1, n) For(j, 1, m){
		scanf("%1d", &A[i][j]);
		sum[i][j] = A[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
	}

	For(i, 1, n) For(j, 2, m)
		cntr[i][j] = (A[i][j] && A[i][j - 1]) + cntr[i - 1][j] + cntr[i][j - 1] - cntr[i - 1][j - 1];
	
	For(i, 2, n) For(j, 1, m)
		cntc[i][j] = (A[i][j] && A[i - 1][j]) + cntc[i][j - 1] + cntc[i - 1][j] - cntc[i - 1][j - 1];

	while(q--){
		int x1, x2, y1, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		printf("%d\n", calc(sum, x1, x2, y1, y2) - calc(cntr, x1, x2, y1 + 1, y2) - calc(cntc, x1 + 1, x2, y1, y2));
	}
	return 0;
}

Measured memory_bytes: 64896
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long

ll x,y,z,k;
ll a[1001], b[1001], c[1001];
ll v[3][1001];
int n[3];

priority_queue<ll> pq;


bool dfs(int depth,ll sum){
  if(depth == 3){
    if(pq.size() == k){
      ll top = -(pq.top());
      if(top >= sum)return false;
    }
    pq.push(-sum);
    if(pq.size() > k){
      pq.pop();
    }
    return true;
  }
  for(int i = 0;i < n[depth];i++){
    bool ret = dfs(depth+1,sum+v[depth][i]);
    if(ret == false)break;
  }
  return true;
}

int main(){

  cin >> x >> y >> z >> k;
  n[0] = x;
  n[1] = y;
  n[2] = z;

  for(int i = 0;i < x;i++){
    cin >> a[i];
  }
  for(int i = 0;i < y;i++){
    cin >> b[i];
  }
  for(int i = 0;i < z;i++){
    cin >> c[i];
  }
  sort(a,a+x,greater<ll>());
  sort(b,b+y,greater<ll>());
  sort(c,c+z,greater<ll>());
    for(int i = 0;i < x;i++){
    v[0][i] =  a[i];
  }
  for(int i = 0;i < y;i++){
    v[1][i] =  b[i];
  }
  for(int i = 0;i < z;i++){
    v[2][i] =  c[i];
  }

  dfs(0,0);
  ll ans[3001];
  int index = 0;
  while(!pq.empty()){
    ans[index++] = -(pq.top());
    pq.pop();
  }
  for(int i = k-1;i != -1;i--){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
/*
AizuOnline A0139
Snakes
*/
#include <stdio.h>
#include <string.h>

extern int is_SNAKEA_body(char *s,int len);
extern int is_SNAKEB_body(char *s,int len);



int is_SNAKEA_body(char *s,int len)
   { if(len == 0)
       return(0);
     else if(len==1 && s[0] == '#')
       return(-1);
     else if(s[0] == '=' && s[len-1] == '=')
       return(is_SNAKEA_body(s+1,len-2));
     else
       return(0);
   }

int is_SNAKEA(char *s)
{  int len = strlen(s);
   if(0==strncmp(">'=",s,3)   /*caution! at least 1 '=' */
      && is_SNAKEA_body(s+2,len-3)
      && s[len-1]=='~'
      )
     return(-1);
       else
     return(0);
  
}

int is_SNAKEB_body(char *s,int len)
   { if(len == 0 || len & 1)
       return(-0);
     else if(len == 2 && 0 == strncmp("Q=",s,2))
       return(-1);
     else if(0 == strncmp("Q=",s,2))
       return(is_SNAKEB_body(s+2,len-2));
     else
       return(0);
   }

int is_SNAKEB(char *s)
{  int len = strlen(s);
   if(0==strncmp(">^",s,2)
      && is_SNAKEB_body(s+2,len-4)
      && s[len-2]=='~'
      && s[len-1]=='~'
      )
     return(-1);
       else
     return(0);
  
      }

main()
{
  int i;
  char snake[201];
  int cnt;
  
  scanf("%d",&cnt );
  for(i=0;i<cnt;i++)
    { scanf("%s",snake);
      if(is_SNAKEB(snake))
        printf("B\n");
      else if(is_SNAKEA(snake))
        printf("A\n");
      else
        printf("NA\n");
    }
  return(0);
  }

Measured memory_bytes: 0
# include <bits/stdc++.h>
using namespace std;
int main() {
    int S;
    int h,m,s;
    cin >> S ;
    h = S/3600;
    S = S-3600*h;
    m = S/60;
    s = S-60*m;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100