akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(){
	int N,a;
	float total=0;
	std::cin >> N;
	//std::cout << "2" << std::endl;
	for(int i; i<N; i++){
		std::cin >> a;
		total += 1.0/a;
	}
	total = 1.0/total;
	std::cout << total << std::endl;
	return 0;
}

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

int Grd(int a,int b){
    if(a<b){
        int c=a;
        a=b;
        b=c;
    }
    
    if(b==0){
        return a;
    }
    return Grd(b,a%b);
}

int main(void){
    int a,b;
    std::cin>>a>>b;
    std::cout<<(long int)a*b/Grd(a,b)<<"\n";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from fractions import gcd

    n, large_x = map(int, input().split())
    x = sorted(list(map(int, input().split())) + [large_x])
    ans = float('inf')

    if len(x) == 2:
        print(x[1] - x[0])
        exit()

    for k in range(n - 1):
        ans = min(ans, gcd(x[k + 2] - x[k + 1], x[k + 1] - x[k]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16236
#include <iostream>
#include <map>

using namespace std;

int main()
{
	int n;
	char ch;
	map<char, int> map_a;

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> ch;
		map_a[ch] += 1;
	}

	int count = 0;
	for (int i = 0; i < map_a.size(); ++i)
		if (map_a[i])
			++count;

	if (count == 3)
		cout << "Three" << endl;
	else if (count == 4)
		cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $a[], $a[]);
$ans = 0;
foreach ($a as $r) {
    if ($r <= 3) {
        $ans += 100000 * (4 - $r);
    }
}
if (array_sum($a) === 2) {
    $ans += 400000;
}
echo $ans;


Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int answer = a + b;
        if(a-b > answer){
            answer = a-b;
        }
        if(a*b > answer){
            answer = a*b;
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 22996
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    B = iln(N)
    t = 1
    cnt = 1
    while True:
        if cnt > N:
            print(-1)
            exit()
        if B[t-1] == 2:
            print(cnt)
            exit()
        cnt += 1
        t = B[t - 1]


if __name__ == '__main__':
    main()


Measured memory_bytes: 7064
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000
 
void mergesort(int *,int,int);
void merge(int *,int,int,int);
 
int L[MAX/2+2],R[MAX/2+2];
int count;
int array[MAX];
 
int main()
{
 
  int n,i;
  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
 
  mergesort(array,0,n);
 
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",array[i]);
  }
  printf("\n");
  printf("%d\n",count);
 
  return 0;
}
 
 
 
void mergesort(int array[],int left,int right)
{
  int mdl;
  if(left+1<right){
    mdl=(left+right)/2;
    mergesort(array,left,mdl);
    mergesort(array,mdl,right);
    merge(array,left,mdl,right);
  }
}
 
void merge(int array[],int left,int mdl,int right)
{
  int i,j,k,n1,n2;
  n1=mdl-left;
  n2=right-mdl;
  for(i=0;i<n1;i++) L[i]=array[left+i];
  for(i=0;i<n2;i++) R[i]=array[mdl+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      array[k]=L[i];
      i=i+1;
    }
    else {
      array[k]=R[j];
      j=j+1;
    }
  }
}

Measured memory_bytes: 4508
#include "bits/stdc++.h"

using namespace std;

int pw(int s, int e) {
	if (e == 0) return 1;
	else return s*pw(s, e - 1);
}

int main() {
	int n,m;
	int x=0;
	cin >>n>>m;
	x += pw(2,m)*((n-m) * 100+m*1900);
	cout << x << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n;
    while (cin >> n) {
        bool fail = false;
        for (int i = 0; i < n; i++) {
            int temp;
            cin >> temp;
            if ((temp % 2 == 0) && (temp % 3 != 0) && (temp % 5 != 0)) {
                fail = true;
            }
        }
        if(!fail)cout<<"APPROVED\n";
        else cout<<"DENIED\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
 
int main()
{
    int k;
    cin>>k;
    int i;
    string s="ACL";
    for(i=1;i<k;i++){
        s+="ACL";
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#define mod (1000000007)
using namespace std;
int prime[1100],cnt[1100],tot=0;
int check(int k)
{
	for(int i=2;i<=sqrt(k);i++)
	if(k%i==0) return 0;
	return 1;
}
void work(int k)
{
	if(k==1) return;
	for(int i=1;i<=tot;i++)
	if(k%prime[i]==0)
	{
		cnt[i]++;
		work(k/prime[i]);
		break;
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1) {printf("1\n");return 0;}
	for(int i=2;i<=n;i++)
	if(check(i)) prime[++tot]=i,cnt[tot]=1;
	else work(i);
	long long ans=1;
	for(int i=1;i<=tot;i++) ans*=(cnt[i]+1),ans%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, _ := strconv.Atoi(scanner.Text())
	return a
}
func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func solve(wholeAppleNum, fragmentNum int) int {
	t := wholeAppleNum*3 + fragmentNum
	return t / 2
}

//
func main() {
	scanner.Split(bufio.ScanWords)
	a := scanInt()
	p := scanInt()
	ans := solve(a, p)
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{

        long long int a,b,c,k,r;
        scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
        if(k<a)
            printf("%lld",k);
        else if(k<=a+b)
            printf("%lld",a);
        else{
            r = k - (a+b);
            a = a - r;
            printf("%lld",a);
        }

    return 0;
}

Measured memory_bytes: 1692
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<stdlib.h>
#include <stdio.h>
#include<ctype.h>

int compare(const void *p,const void *q){
	return *(int *)p  - *(int *)q;
}

int main(int argc, char *argv[])
{
	
	int n;
	scanf("%d",&n);
	int say[n+1];
	for(int i=0;i<n;i++)
		scanf("%d",say+i);
		
	qsort(say,n,sizeof(int),compare);
	
	int last = -1,count =0;
	for(int i=0;i<n;i++)
		if(say[i]!=last){
			count ++;
			last=say[i];
		}
			
		else{
			count--;
			last=-1;
		}
		
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 892
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

while True:
    n = int(input())
    if n == 0:
        break
    else:
        ww = [len(input()) for i in range(n)]

        L = [5,7,5,7,7]
        for i in range(n):
            k = i
            tmp = 0
            S = 0
            flag = False
            while True:
                w = ww[k]
                if L[tmp] - S > w:
                    S += w
                elif L[tmp] - S == w:
                    tmp += 1
                    S = 0
                else:
                    break

                if tmp == 5:
                    flag = True
                    break

                k += 1

            if flag:
                print(i+1)
                break



Measured memory_bytes: 7460
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
ll sum = 0,ans,n,cnt =0,m; 
int main() {
    cin >> n >> m;
    vector<int> a(n); vector<pair<int, int>> b(m);
    rep(i, n) cin >> a[i];
    rep(i, m)cin >> b[i].second >> b[i].first;
    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend()); int j = 0;
    rep(i, n) {
        if (a[i] < b[j].first) {
            a[i] = b[j].first;
            b[j].second--;
        }if (b[j].second == 0) j++;
        if (j >= m) break;
    }
    rep(i, n) {
        sum += a[i];
    }cout << sum << endl;
}

Measured memory_bytes: 1408
n = int(input())
cnt = 0
for i in range(1,n+1):
  if i % 2 == 0:
    continue
  l = []
  for j in range(1,i+1):
    if i % j == 0:
      l.append(i)
  if len(l) == 8:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

ll gcd(ll a, ll b)
{
  while (b > 0) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  std::vector< ll > vl(N, 0LL);
  vl[0] = va[0];
  for (ll i = 1; i < N; i++) {
    vl[i] = gcd(vl[i-1], va[i]);
  }
  std::vector< ll > vr(N, 0LL);
  vr[N-1] = va[N-1];
  for (ll i = N-2; i >= 0; i--) {
    vr[i] = gcd(vr[i+1], va[i]);
  }
  ll ans = -INF;
  for (ll i = 0; i < N; i++) {
    ll cnt = 0;
    if (i == 0) {
      cnt = vr[1];
    } else if (i == N - 1) {
      cnt = vl[N-2];
    } else {
      cnt = gcd(vl[i-1], vr[i+1]);
    }
    ans = std::max(ans, cnt);
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#define int long long
int n,i,j,d[2010][2010]={0};
int MAX(int a,int b){return a<b?b:a;}
int p(){return (j+n-1)%n;}
signed main(){
  scanf("%lld",&n);
  for(i=0;i<2010*2010;i++)d[i/2010][i%2010]=-1000000000;
  for(i=0;i<n;i++)scanf("%lld",&d[1][i]);
  for(i=1;i<n;i++){
    for(j=0;j<n;j++){
      if(i%2){
	if(d[1][p()]>d[1][(i+j)%n])d[i+1][p()]=MAX(d[i+1][p()],d[i][j]);
	else d[i+1][j]=MAX(d[i+1][j],d[i][j]);
      }
      else d[i+1][j]=MAX(d[i][j]+d[1][(i+j)%n],d[i][(j+1)%n]+d[1][j]);
    }
  }
  for(i=j=0;i<n;i++)j=MAX(j,d[n][i]);
  printf("%lld\n",j);
  return 0;
}

Measured memory_bytes: 32156
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];	
	int ans = -1;
  	int flg = 0;
	while(flg == 0) {
      	ans++;
		for (int i = 0; i < n; i++) {
          	if (a[i] % 2 != 0) {
              	flg = 1;
              	break;
            }
          	else {
              	a[i] /= 2;
            }
        }
    }
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>

bool is_upper(char c) //大文字かどうか判定
{
    if ('A' <= c && c <= 'Z')
    {
        return true;
    }
    return false;
}

char swap_letter_case(char c) //is_upperで大文字だったものは小文字、それ以外の英文字は小文字にする
{
    if (is_upper(c))
    {
        c = tolower(c);
    }
    else
    {
        c = toupper(c);
    }

    return c;
}

void swap_string_case(char str[]) //iがNULL文字と一致するまで大文字と小文字を入れ替える
{
    int i = 0;
    while (str[i] != '\0')
    {
        str[i] = swap_letter_case(str[i]);
        i++;
    }
}

int main(void)
{
    char strings[1200] = {'\0'};

    scanf("%[^\n]%*c", strings);
    swap_string_case(strings);
    printf("%s\n", strings);

    return 0;
}


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

int N, Q;
string s;
vector<char> t, d;

int C(int x, const bool dir_flag){
    for(int i = 0; i < Q; ++i){
        if(x < 0) return dir_flag;
        else if(x >= N) return !dir_flag;

        if(s[x] == t[i] && d[i] == 'R') ++x;
        else if(s[x] == t[i] && d[i] == 'L') --x;
    }

    if(x < 0) return dir_flag;
    else if(x >= N) return !dir_flag;

    return false;
}

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

    t.resize(Q);
    d.resize(Q);
    for(int i = 0; i < Q; ++i) cin >> t[i] >> d[i];

    int ans = N;

    int lb = -1, ub = N+1, mid;
    while(ub - lb > 1){
        mid = (lb+ub)/2;
        //cout << lb << " " << ub << " " << mid << endl;
        if(C(mid, true)) lb = mid;
        else ub = mid;
    }
    //cout << lb << " " << ub << " " << mid << endl;
    ans -= ub;

    //cout << endl;
    
    lb = -1;
    ub = N+1;
    while(ub - lb > 1){
        mid = (lb+ub)/2;
        //cout << lb << " " << ub << " " << mid << endl;
        if(C(mid, false)) ub = mid;
        else lb = mid;
    }
    //cout << lb << " " << ub << " " << mid << endl;
    ans -= N-ub;

    cout << ans << endl;
}

Measured memory_bytes: 900
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
};
typedef ModInt<1000000007> mint;

int main() {
	int N;
	while (~scanf("%d", &N)) {
		string S[2];
		cin >> S[0] >> S[1];
		const int K = 3;
		vector<vector<vector<mint>>> dp(N + 1, vector<vector<mint>>(K + 1, vector<mint>(K + 1)));
		dp[0][K][K] = 1;
		rep(i, N) rep(a, K + 1) rep(b, K + 1) {
			mint x = dp[i][a][b];
			if (x.x == 0) continue;
			char p = S[0][i], q = S[1][i];
			if (p == q) {
				rep(c, K) {
					if (c != a && c != b)
						dp[i + 1][c][c] += x;
				}
			} else {
				bool pL = i > 0 && S[0][i - 1] == p;
				bool qL = i > 0 && S[1][i - 1] == q;
				rep(c, K) rep(d, K) {
					if (c == d) continue;
					if (pL ? (c != a) : (c == a))
						continue;
					if (qL ? (d != b) : (d == b))
						continue;
					dp[i + 1][c][d] += x;
				}
			}
		}
		mint ans;
		rep(a, K + 1) rep(b, K + 1)
			ans += dp[N][a][b];
		printf("%d\n", ans.get());
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;
static const int MAX = 1400;
struct Rectangle { int height, pos; };
int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangleR(int idx, int size) {
    stack<Rectangle> S;
    int maxv = 0;
    T[idx][size] = 0;

    Rectangle rect, pre;
    for (int i = 0; i <= size; i++) {
        rect.height = T[idx][i];
        rect.pos = i;
        if ( S.empty() ) {
            S.push(rect);
        } else {
            if (S.top().height < rect.height) S.push(rect);
            else if (S.top().height > rect.height) {
                int target = i;
                while ( !S.empty() && S.top().height >= rect.height) {
                    pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int getLargestRectangle() {
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (buffer[i][j]) T[i][j] = 0;
            else T[i][j] = (i > 0) ? T[i-1][j] + 1 : 1;
        }
    }
    int maxv = 0;
    for (int i = 0; i < H; i++) maxv = max(maxv, getLargestRectangleR(i, W));
    return maxv;
}




int main()
{
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) scanf("%d", &buffer[i][j]);
    }
    printf("%d\n", getLargestRectangle());
    return 0;
}



Measured memory_bytes: 18012
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int X;
  cin>>X;
  int A = X;
  int Y = 0;
  while(X > 0)
  {
     Y+= X%10;
     X/=10;
  }
  if(A%Y == 0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

int main(){
    int i, j, n, m;
    cin >> n >> m;
    int A[100][100];
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> A[i][j];
			// cout << A[i][j] << endl;
        }
    }
    int b[100];
    for(j = 0; j < m; j++) cin >> b[j];
    int c[100];
    for(i = 0; i < n; i++) c[i] = 0;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            c[i] += A[i][j] * b[j];
        }
    }
    for(i = 0; i < n; i++) cout << c[i] << endl;
    return 0;
}


Measured memory_bytes: 3124
import java.util.*;

class Main {
    public static long solve(int arr[], int n) {
        long ans[] = new long[n + 1];

        ans[1] = 0;
        ans[2] = Math.abs(arr[1] - arr[2]);

        for (int i = 3; i <= n; i++) {
            ans[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + ans[i - 1], Math.abs(arr[i] - arr[i - 2]) + ans[i - 2]);
        }

        return ans[n];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int arr[] = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(solve(arr, n));
    }
}

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

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

  set<int> p;
  rep(i, N) {
    int pi;
    cin >> pi;
    p.insert(pi);
  }

  rep(i, N + 1) {
    if (!p.count(X - i)) {
      cout << X - i << endl;
      return 0;
    } else if (!p.count(X + i)) {
      cout << X + i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
const int N=18,M=998244353;
using namespace std;
int n,l,a[1<<N],b[1<<N],t0,t1,sum;
inline int inv(int x){
	int y=1,t=M-2;
	for(;t;t>>=1)
	t&1?y=1ll*y*x%M:0,x=1ll*x*x%M;
	return y;
}
inline void fwt(int*c,int t){
	for(int i=1;i<l;i<<=1)
	for(int j=0;j<l;j++)
	if(j&i)
	t0=(c[j^i]+c[j])%M,t1=(c[j^i]-c[j])%M,
	c[j]=t1*1ll*t%M,c[j^i]=t0*1ll*t%M;
}
int main(){
	scanf("%d",&n),b[0]=l=1<<n;
	for(int i=0;i<l;i++)
	scanf("%d",a+i),sum=(sum+a[i])%M,b[i]--;
	sum=inv(sum);
	for(int i=0;i<l;i++)
	a[i]=1ll*a[i]*sum%M;
	a[0]--;/*
	for(int i=0;i<l;i++)
	cerr<<a[i]<<' ';cerr<<endl;*/
	fwt(a,1),fwt(b,1);/*
	for(int i=0;i<l;i++)
	cerr<<a[i]<<' ';cerr<<endl;
	for(int i=0;i<l;i++)
	cerr<<b[i]<<' ';cerr<<endl;*/
	for(int i=1;i<l;i++)
	a[i]=b[i]=1ll*b[i]*inv(a[i])%M;
	fwt(a,M+1>>1);
	b[0]=-a[0]*1ll*l%M;
	fwt(b,M+1>>1);
	for(int i=0;i<l;i++)
	printf("%d\n",(b[i]+M)%M);
}

Measured memory_bytes: 4864
#include <stdio.h>
int main(void){

int N,n,m,i;


scanf("%d",&N);

	n=N%1110;
	m=N/1000;
	if(n<10){printf("Yes\n",n);}
	
	else{
		for(i=1;i<=m;i++){N = N-1000;}
	if(N%111==0){printf("Yes\n");}
	else{printf("No\n");}
	}

return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char *argv[]){
  int x,y;
  
  scanf("%d %d", &x, &y);
  while( x!=0 || y!=0){
    if( x<y)
      printf("%d %d\n", x, y);
    else
      printf("%d %d\n", y, x);
    scanf("%d %d", &x, &y);
  }
  return(0);
}



Measured memory_bytes: 2040
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int h[100005];
int dp[100005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
		cin >> h[i];
	}
    
    for(int i = 0; i < 100000; i++) dp[i] = INF;
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
		if(i + 1 < n)
			dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
		if(i + 2 < n)
			dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
	}
		
	cout << dp[n-1] << endl;
 
    
    
    
    
    
  
	
	return 0;
}


Measured memory_bytes: 1024
N,A,B=map(int,input().split())
xlist=list(map(int,input().split()))

dp=[float("inf")]*N
dp[0]=0

for i in range(1,N):
  dp[i]=min(dp[i-1]+A*(xlist[i]-xlist[i-1]),dp[i-1]+B)
  
print(dp[N-1])

Measured memory_bytes: 15020
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  map<ll, ll> A;
  A[0] = 0;
  rep(i, N-1){
    ll a;
    cin >> a;
    a--;
    A[a]++;
  }

  rep(i, N){
    cout << A[i] << endl;
  }

  
  return 0;
}


Measured memory_bytes: 16096
#include <iostream>

using namespace std;

int N;
int tama[11];

bool dfs(int x, int l, int r){
	if(x==10) 	return true;
	if(tama[x]>l)	dfs(x+1,tama[x],r);
	else if(tama[x]>r) dfs(x+1,l,tama[x]);
	else return false;
}

int main(){
	cin >> N;
	while(N--){
		for(int i=0;i<10;i++)
			cin >> tama[i];
		if(dfs(0,0,0))	cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
int32_t main()
{
    int n,k;
    cin>>n>>k;
    vector<int> neg,pos;
    pos.push_back(0);
    neg.push_back(0);
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x>0)
           pos.push_back(x);
        else
            neg.push_back(-x);     
    }
    sort(neg.begin(),neg.end());
    int ans=INT_MAX;
    for(int i=0;i<=k;i++)
    {
        int m=k-i;
         if(m>=pos.size() ||m<0|| i>=neg.size())
        continue;
        ans=min({ans,pos[m]+2*neg[i],neg[i]+2*pos[m]});
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4504
N = int(input())
inputs = list(map(int, input().split()))

if inputs.count(0) >= 1:
    multiple = 0
    
else:
    for i in range(N):
        if i == 0:
            multiple = inputs[0]
        else:
            multiple *= inputs[i]

        if multiple > 10**18:
            multiple = '-1'
            break

print(multiple)
    

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int X, Y;
    cin >> X >> Y;
    rep(i, 1000) {
        rep(j, 1000) {
            if (i + j == X && 2 * i + 4 * j == Y) { fin("Yes"); }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	//	String line = br.readLine();

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int ba = b-a;
		
		
		if(ba<=0)
		System.out.println("delicious");
		else if(x>=ba)
			System.out.println("safe");
		else
			System.out.println("dangerous");
		
}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N;
	cin>>N;
	string S;
	cin>>S;
	
	int Q;
	cin>>Q;
	
	vector<set<int>> s(26);
	for(int i=0;i<S.size();i++){
		s[S[i]-'a'].insert(i);
	}
	
	for(int i=0;i<Q;i++){
		int t;
		cin>>t;
		if(t==1){
			int ind;
			char c;
			cin>>ind>>c;
			ind--;
			s[S[ind]-'a'].erase(ind);
			S[ind] = c;
			s[S[ind]-'a'].insert(ind);
		}
		else{
			int l,r;
			cin>>l>>r;
			l--;r--;
			int ans = 0;
			for(int j=0;j<26;j++){
				auto it= s[j].lower_bound(l);
				if(it==s[j].end())continue;
				if((*it)<=r)ans++;
			}
			cout<<ans<<endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 24196
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll powl(ll a, ll b) {
	ll c = 1;
	rep(b)
		c = c * a;
	return c;
}


int main() {
	cout.precision(20);
	string S;
	ll N, M, K;
	ll R;
	cin >> N >> R;
	if (N >= 10)
		cout << R;
	else {
		cout << R + 100 * (10 - N);
	}

}




Measured memory_bytes: 256
N,K = [int(hoge) for hoge in input().split()]
A = [1] + [int(hoge) for hoge in input().split()]
ZeroIndex = [n for n,m in enumerate(A) if m==0]
Zeronum = []
curz = 0
for n,a in enumerate(A):
    if a==0:
        curz += 1
    Zeronum.append(curz)

for gakki in range(K+1,N+1):
    #gakki学期が入り、
    #gakki-K学期がなくなる
    #gakki-K+1学期 ~ gakki-1学期が共通
    if Zeronum[gakki-1] > Zeronum[gakki-K]:
        print("No")
    elif A[gakki] > A[gakki-K]:
        print('Yes')
    else:
        print("No")

Measured memory_bytes: 104412
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    c=-c;
    vector<int> b(m);
    rep(i,m)cin>>b[i];
    vector<vector<int>> a(n,vector<int>(m));
    vector<int> d(n);
    rep(i,n){
        rep(j,m){
            cin>>a[i][j];
            d[i]+=a[i][j]*b[j];
        }
    }
    int ans=0;
    rep(i,n){
        if(d[i]>c)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
long long fac[MAXN];
const long long MOD = 1000000007;
long long modpow(long long a, int b){
    if(b == 0) return 1ll;
    if(b % 2 == 0) {
        long long hlf = modpow(a, b/2);
        return (hlf * hlf) % MOD;
    }
    return (a * modpow(a, b - 1)) % MOD;
}
long long inv(long long x){
    return modpow(x, MOD - 2);
}

long long nck(int n, int k){
    if(k > n) return 0;
    long long res = fac[n];
    res = (res * inv(fac[k])) % MOD;
    res = (res * inv(fac[n - k])) % MOD;
    return res;
}
int pos[MAXN];
int main(){
    fac[0] = 1;
    for(int i = 1; i < MAXN; i++){
        fac[i] = (1ll * i * fac[i - 1]) % MOD;
    }
    //cout << nck(10, 2) << endl;
    int LEFT, RIGHT;
    int n;
    cin >> n;
    vector<int> v(n + 1);
    for(int i = 0; i < n + 1; i++){
        cin >> v[i];
        if(pos[v[i]] != 0){
            LEFT = pos[v[i]];
            RIGHT = i + 1;
        }
        pos[v[i]] = i + 1;
    }
    //cout << LEFT << " " << RIGHT << endl;
    long long dec2 = 1ll * (LEFT - 1) + (n + 1 - RIGHT);

    for(int k = 1; k <= n + 1; k++){
        if(k == 1) cout << (nck(n + 1, k) - 1) << endl;
        else {
            cout << (nck(n + 1, k) - nck((LEFT - 1) + (n + 1 - RIGHT), k - 1) + MOD) % MOD << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2816
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  ll N; cin >> N ;
  string s; cin >> s ;
  int cnt = 0;
  rep(i,N) if(s[i]=='R') cnt++;
  if(cnt>N-cnt) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k)
        cout << s << endl;
    else
    {
        for(ll i = 0; i < k; i++)
            cout << s[i];
        cout << "..." << endl;
    }
}

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

Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
  char c[2];
  int right,left;
  int count;
  int target;
  int n;
  while(1)
    {
      scanf("%d\n",&n);
      if(n==0) break;
      right=left=count=0;
      target=1;
      for(;n>0;n--)
	{
	  while(1)
	    {
	      scanf("%c",&c[0]);
	      if((c[0]=='l')||(c[0]=='r')) break;
	    }
	  while(1)
	    {
	      scanf("%c",&c[1]);
	      if((c[1]=='u')||(c[1]=='d')) break;
	    }
	  switch(c[0])
	    {
	    case 'l':
	      if((c[1]=='u')&&(left==0)) left=1;
	      if((c[1]=='d')&&(left==1)) left=0;
	      break;
	    case 'r':
	      if((c[1]=='u')&&(right==0)) right=1;
	      if((c[1]=='d')&&(right==1)) right=0;
	      break;
	    }
	  if((right==left)&&(right==target))
	    {
	      count++;
	      target=(target+1)%2;
	    }
	}
      printf("%d\n",count);
    }
  return 0;
}

Measured memory_bytes: 1704
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Console.WriteLine(Fp(s[0],s[1]));
	}
	static long Fp(long x,long e){
		long r=1;
		while(e>0){
			if((e&1)>0){r*=x;r%=mod;}
			x=(x*x)%mod;
			e>>=1;
		}
		return r;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 17916
n = int(input())
times = list(map(int,input().split()))


m = int(input())
drink = []

for i in range(m):
  drink.append(list(map(int, input().split())))
  
total = sum(times)

for i in range(m):
    print(total- times[drink[i][0]-1] + drink[i][1])

Measured memory_bytes: 3064
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(a: usize, b: usize);

    let ans = (a + b) / 2;

    println!(
        "{}",
        if ans * 2 == a + b {
            ans.to_string()
        } else {
            "IMPOSSIBLE".to_string()
        }
    );
}


Measured memory_bytes: 2180
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        double n;
        scanf("%lf",&n);
        if(n<0)break;
        int a = (int)(n * 16);
        if(a>=(1<<12) || a<(n*16)){
            cout << "NA" << endl;
        }else{
            for(int i=11;i>=0;i--){
                if(i==3) cout << ".";
                cout << ((a>>i)&1);
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

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

#define INF 1000000000

int main() {
  
  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int H, N;
  cin >> H >> N;

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

  int dp[N + 1][H + 1];
  
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= H; j++) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= H; j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][min(H, j + A[i])] = min(dp[i + 1][min(H, j + A[i])], dp[i + 1][j] + B[i]);
    }
  }

  cout << dp[N][H] << endl;
  
  return 0;  
}


Measured memory_bytes: 39424
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A = []
for i in range(3):
    A.append(LI())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

tables = [[0,0,0] for i in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == b[n]:
                tables[i][j] = 1

ans = 0
for i in range(3):
    if tables[i][0] == tables[i][1] == tables[i][2] == 1:
        ans = 1
    if tables[0][i] == tables[1][i] == tables[2][i] == 1:
        ans = 1
    if tables[0][0] == tables[1][1] == tables[2][2] == 1:
        ans = 1
    if tables[0][2] == tables[1][1] == tables[2][0] == 1:
        ans = 1

if ans:
    print("Yes")
else:
    print("No")

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

int main(void) {
  int n, h[102], ans = 0, kugiri = 0;

  if(scanf("%d", &n) == 1);

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

  while(kugiri != -1) {
    for(int i = 0; i < n; i++) {
      if(h[i] > 0) {
        kugiri = i;
        break;
      } else if(i == n - 1) {
        printf("%d", ans);
        kugiri = -1;
        break;
      }
    }
    for(int i = kugiri; i < n && kugiri != -1; i++) {
      if(i == n - 1) {
        ans++;
        for(int j = kugiri; j < n; j++) {
          h[j]--;
        }
        break;
      } else if(h[i] == 0) {
        ans++;
        for(int j = kugiri; j < i; j++) {
          h[j]--;
        }
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 128