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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    map<ll, ll> m; // 数のマップ
    rep(i, n) {
        cin >> a[i];
        if(m.count(a[i])) m[a[i]]++;
        else m[a[i]] = 1;
    }

    vector<vector<ll>> div(n, vector<ll>()); // 約数列挙

    // 約数列挙
    rep(i, n) {
        for(ll j = 1; j*j <= a[i]; j++) {
            if((a[i]%j) == 0) {
                div[i].push_back(j);
                if(j*j != a[i]) div[i].push_back(a[i]/j);
            }
        }
    }

    ll ans = 0;
    rep(i, n) {
        bool ok = true;
        // 約数がmに含まれているか
        rep(j, div[i].size()) {
            // 同じときは分岐
            if(div[i][j] == a[i]) {
                if(m.count(div[i][j]) && m[div[i][j]] >= 2) {
                    ok = false;
                }
            }
            else {
                if(m.count(div[i][j])) {
                    ok = false;
                }
            }
        }
        if(ok) ans++;
    }

    cout << ans << endl;


    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 112556
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;

int main(void) {
    FAST_IO;
    int a, b, c;
    cin >> a >> b >> c;
    if (c > a - b) {
        cout << c - a + b << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db double

const int mod = (int)1e9 + 7;

int mult(int a, int b){
	return a * (ll)b % mod;
}

int bp(int a, int k){
	if (k < 0) k += mod - 1;
	if (k == 0) return 1;
	if (k % 2 == 1){
		return mult(a, bp(a, k - 1));
	} else {
		int q = bp(a, k / 2);
		return mult(q, q);
	}
}

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

int sum(int a, int b){
	int ans = a + b;
	if (ans >= mod) ans -= mod;
	return ans;
}

int sub(int a, int b){
	int ans = a - b;
	if (ans < 0) ans += mod;
	return ans;
}

int n;
vector<int> g[5005];
int fac[5005], invfac[5005];
int sz[5005];

void calcSz(int v, int pred){
	sz[v] = 1;
	for (int to : g[v]) if (to != pred){
		calcSz(to, v);
		sz[v] += sz[to];
	}
}

vector<int> t;
int findCentroid(int v, int pred){
	for (int to : g[v]) if (to != pred){
		if (sz[to] >= (n + 1) / 2) return findCentroid(to, v);
	}
	int sum = n - 1;
	for (int to : g[v]) if (to != pred){
		t.pb(sz[to]);
		sum -= sz[to];
	}
	if (sum != 0) t.pb(sum);
	return v;
}

int dp[5005][5005];

int cnk(int k, int n){
	return mult(fac[n], mult(invfac[k], invfac[n - k]));
}

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	fac[0] = 1;
	for (int i = 1; i < 5005; i++) fac[i] = mult(i, fac[i - 1]);
	for (int i = 0; i < 5005; i++) invfac[i] = bp(fac[i], -1);

	calcSz(0, -1);
	int cc = findCentroid(0, -1);
	if (n % 2 == 0 && sz[cc] == n / 2) cout << mult(fac[n / 2], fac[n / 2]), exit(0);

	int ans = 0;
	t.pb(1);

	dp[0][0] = 1;
	for (int i = 0; i < t.size(); i++){
		for (int j = 0; j < 5005; j++) if (dp[i][j]){
			for (int s = 0; s <= t[i]; s++){
				add(dp[i + 1][j + s], mult(dp[i][j], mult(cnk(s, t[i]), mult(fac[s], cnk(s, t[i])))));
			}
		}
	}

	for (int i = 0; i < 5005; i++){
		dp[t.size()][i] = mult(dp[t.size()][i], fac[n - i]);
		if (i % 2 == 0) ans = sum(ans, dp[t.size()][i]);
		else ans = sub(ans, dp[t.size()][i]);
	}

	for (int i = 0; i < 5005; i++) for (int j = 0; j < 5005; j++) dp[i][j] = 0;

	t.pop_back();

	dp[0][0] = 1;
	for (int i = 0; i < t.size(); i++){
		for (int j = 0; j < 5005; j++) if (dp[i][j]){
			for (int s = 0; s <= t[i]; s++){
				add(dp[i + 1][j + s], mult(dp[i][j], mult(cnk(s, t[i]), mult(fac[s], cnk(s, t[i])))));
			}
		}
	}

	for (int i = 0; i < 5005; i++){
		dp[t.size()][i] = mult(dp[t.size()][i], fac[n - i - 1]);
		if (i % 2 == 0) ans = sum(ans, dp[t.size()][i]);
		else ans = sub(ans, dp[t.size()][i]);
	}

	cout << ans;
}       

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll,ll> LL;

int N;
ll calc(ll X, vector<ll> A){
	ll res = 0LL;
	rep (i, N){
		res += (X xor A[i]);
	} // end rep
	return res;
}

LL solve3(ll K, vector<ll> A){
	int m = 40;
	vector<int> c(m,0);	// ビット毎の数

	rep (i, N){
		rep (j, m){
			if (A[i] & (1LL<<j)){
				++c[j];
			} // end if
		} // end rep
	} // end rep

	ll res = 0LL;
	ll X = 0LL;
	rep (i, m){
		ll currX = 0LL;
		for (int j = m - 1; j >= i + 1; --j){
			if (K & (1LL<<j)){
				currX += (1LL<<j);
			} // end if
		} // end for
		for (int k = 0; k < i; ++k){
			if (c[k] <= N - c[k]){
				currX += (1LL<<k);
			} // end if
		} // end for
		if (currX > K) continue;

		ll curr = calc(currX, A);
//		cerr << "currX: " << currX << " curr: " << curr << endl;
		if (curr > res){
			res = curr;
			X = currX;
		} // end if
	} // end rep

	return LL(res,X);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	 ll K; cin >> N >> K;
	vector<ll> A(N, 0LL);
	rep (i,N){
		cin >> A[i];
	} // end rep

	sort(ALL(A));

	LL res = solve3(K, A);	
	cout << res.first << endl;
				
	return 0;
}

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

namespace ABC173_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hwk = Console.ReadLine().Split(' ');
            int H = int.Parse(hwk[0]);
            int W = int.Parse(hwk[1]);
            int K = int.Parse(hwk[2]);
            char[,] c = new char[H, W];

            for (int i = 0; i < H; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < W; j++)
                {
                    c[i, j] = s[j];
                }
            }

            int count = 0;

            // 組合せをBitで表現
            int H_max = 0;
            for (int i = 0; i < H; i++)
            {
                H_max += (1 << i);
            }
            int W_max = 0;
            for (int i = 0; i < W; i++)
            {
                W_max += (1 << i);
            }

            for (int i = 0; i < H_max; i++)
            {
                char[,] temp_c1 = new char[H, W];
                Array.Copy(c, temp_c1, c.Length);

                for (int i2 = 0; i2 < H; i2++)
                {
                    if ((i >> i2 & 0x0001) == 0x0001)
                    {
                        changeXcolor(temp_c1, i2, W);
                    }
                }

                for (int j = 0; j < W_max; j++)
                {
                    char[,] temp_c2 = new char[H, W];
                    Array.Copy(temp_c1, temp_c2, temp_c1.Length);

                    for (int j2 = 0; j2 < W; j2++)
                    {
                        if ((j >> j2 & 0x0001) == 0x0001)
                        {
                            changeYcolor(temp_c2, j2, H);
                        }
                    }
                    if (K == getCount(temp_c2, H, W))
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }

        static void changeXcolor(char[,] c, int num, int max)
        {
            for (int i = 0; i < max; i++)
            {
                c[num, i] = '.';
            }
        }

        static void changeYcolor(char[,] c, int num, int max)
        {
            for (int i = 0; i < max; i++)
            {
                c[i, num] = '.';
            }
        }

        static int getCount(char[,] c, int H, int W)
        {
            int count = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (c[i, j].Equals('#'))
                    {
                        count++;
                    }
                }
            }
            return count;
        }
    }
}


Measured memory_bytes: 27932
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Getting Started - Maximum Profit
 */
public class Main {

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

		int n = parseInt(br.readLine());

		int max = (int) -Math.pow(10, 9);
		int min = parseInt(br.readLine());

		for (int i = 0; i < n - 1; i++) {
			int r = parseInt(br.readLine());
			max = Math.max(max, r - min);
			min = Math.min(min, r);
		}
		System.out.println(max);
		
	} //end main
}

Measured memory_bytes: 37608
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


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


def main():
    A, B, C = LI()
    K = I()
    for i in range(K):
        if A >= B:
            B *= 2
        else:
            if B >= C:
                C *= 2
            else:
                break

    if A < B and B < C:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		String o = (s.length() <= k) ? s : s.substring(0, k) + "...";
		System.out.println(o);
	}

}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
const int INF = MD;

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	VI a(n);
	rep(i, n) cin >>a[i];
	auto b= a;
	reverse(all(b));
	vector<int> hk(n, INF);
	for(auto x: b) *upper_bound(all(hk), x) = x;
	int ans = lower_bound(all(hk), INF) - hk.begin();
	
	cout <<ans <<"\n";
	return 0;
}


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

int d;

int f(int x){
	return x*x*d;
}

int main(){
	int i;
	while(scanf("%d",&d)!=EOF){
		int ans=0;
		for(i=0;i<600/d;i++){
			ans+=f(i*d);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

size_t non_zero_min(vector<int> &V){
  int min = 1e9;
  int pos = -1;
  for(int i=0; i<V.size(); i++){
    if(V[i]!=0 && min >= V[i]){
      min = V[i];
      pos = i;
    }
  }
  return pos;
}



int main(){
  int N;
  cin >> N;
  vector<int> As(N);
  for(int i=0; i<N; i++){
    scanf("%d", &As[i]);
  }
  size_t min_pos;
  while(true){
    min_pos = non_zero_min(As);
    for(int i=0; i<N; i++){
      if(i==min_pos) continue;
      As[i] %= As[min_pos];
    }
    int zero_cnt=0;
    for(int i=0; i<N; i++){
      if(As[i]==0) zero_cnt++;
    }
    if(zero_cnt==N-1) break;
  }
  cout << As[min_pos] << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


const int MAX = 55;
int n, w, h;


bool no_puyo(const int (*f)[MAX])
{
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			if (f[y][x] >= 0)
				return false;
	return true;
}
void fall(int (*f)[MAX])
{
	for (int x = 0; x < w; ++x)
	{
		for (int y = 0; y < h; ++y)
		{
			if (f[y][x] == -1)
			{
				for (int i = y + 1; i < h; ++i)
				{
					if (f[i][x] != -1)
					{
						f[y][x] = f[i][x];
						f[i][x] = -1;
						break;
					}
				}
			}
		}
	}
}
bool go(const int (*field)[MAX])
{
	int f[MAX][MAX];
	memcpy(f, field, sizeof(f));

	while (!no_puyo(f))
	{
		fall(f);

		bool vani[MAX][MAX];
		CLEAR(vani, 0);
		for (int y = 0; y < h; ++y)
		{
			for (int x = 0; x < w; ++x)
			{
				if (f[y][x] >= 0)
				{
					int c = f[y][x];
					int seq = 1;
					for ( ; x + 1< w && f[y][x + 1] == c; ++x)
						++seq;

					if (seq >= n)
					{
						for (int i = 0; i < seq; ++i)
							vani[y][x - i] = true;
					}
				}
			}
		}
		for (int x = 0; x < w; ++x)
		{
			for (int y = 0; y < h; ++y)
			{
				if (f[y][x] >= 0)
				{
					int c = f[y][x];
					int seq = 1;
					for ( ; y + 1< h && f[y + 1][x] == c; ++y)
						++seq;

					if (seq >= n)
					{
						for (int i = 0; i < seq; ++i)
							vani[y - i][x] = true;
					}
				}
			}
		}

		bool any = false;
		for (int y = 0; y < h; ++y)
			for (int x = 0; x < w; ++x)
				if (vani[y][x])
					f[y][x] = -1, any = true;

		if (!any)
			return false;
	}

	return true;
}
int main()
{
	int field[MAX][MAX];
	scanf("%d%d%d", &h, &w, &n);
	for (int y = h - 1; y >= 0; --y)
	{
		char buf[MAX];
		scanf("%s", buf);
		for (int x = 0; x < w; ++x)
		{
			if (buf[x] != '.')
				field[y][x] = buf[x] - 'A';
			else
				field[y][x] = -1;
		}
	}

	for (int y = 0; y < h; ++y)
	{
		for (int x = 1; x < w; ++x)
		{
			swap(field[y][x - 1], field[y][x]);
			if (go(field))
			{
				puts("YES");
				return 0;
			}
			swap(field[y][x - 1], field[y][x]);
		}
	}
	puts("NO");
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  long long onecouter = 0, zerocounter = 0;
  std::string number;
  std::cin >> number;
  int length = number.length();
  char idx = '0';
  for (long long  i = 0; i < length; i++) {

    if (number[i] == idx) zerocounter++;
    if (idx == '0') idx = '1';
    else idx = '0';
    if (number[i] == idx) onecouter++;
  }

  std::cout << min(zerocounter,onecouter) << '\n';

  return 0;
}


Measured memory_bytes: 512
'''input
3
28 27 24
'''
n = input()
a = map(int, input().split())

ok = 1
for i in a:
	if i % 2 == 0:
		if i % 3 != 0 and i % 5 != 0:
			ok = 0

if ok == 1:
	print("APPROVED")
else:
	print("DENIED")

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=5e5+5,Mo=998244353;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,m,fac[N],inv[N],pwn[N],pwm[N];

void pre(int N) {
	fac[0]=1;fo(i,1,N) fac[i]=(ll)fac[i-1]*i%Mo;
	inv[N]=pwr(fac[N],Mo-2);fd(i,N-1,0) inv[i]=(ll)inv[i+1]*(i+1)%Mo;
	pwn[0]=1;fo(i,1,N) pwn[i]=(ll)pwn[i-1]*(n+1)%Mo;
	pwm[0]=1;fo(i,1,N) pwm[i]=(ll)pwm[i-1]*(m+1)%Mo;
}

int main() {
	scanf("%d%d",&n,&m);pre(max(n,m));
	int ans=0;
	fo(i,0,min(n,m)) (ans+=(ll)(i&1?-1:1)*inv[i]*inv[n-i]%Mo*inv[m-i]%Mo*pwn[m-i]%Mo*pwm[n-i]%Mo)%=Mo;
	ans=(ll)ans*fac[n]%Mo*fac[m]%Mo;
	printf("%d\n",(ans+Mo)%Mo);
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  vector<int> c(S.size()+1, 0);
  for (int i=0; i<S.size(); i++) {
    if (S.at(i) == '<') {
      c.at(i+1) = c.at(i)+1;
    }
  }
  for (int i=S.size()-1; i>=0; i--) {
    if (S.at(i) == '>') {
      c.at(i) = max(c.at(i), c.at(i+1)+1);
    }
  }
  long long sum = 0;
  for (int i=0; i<c.size(); i++) {
    sum += c.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 2820
#include <stdio.h>
#define N 100000
#define NIL -1

struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[100000];
int C[100000];

void getDepth(int, int);

int main()
{
  int n, i, j, k, x, y, id, key, root;
  
  for( i=0 ; i<N ; i++ ){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d %d",&id,&key);
    for( j=0 ; j<key ; j++ ){
      scanf("%d",&x);
      if(j==0)
	T[id].left = x;
      else
	T[y].right = x;
      y = x;
      T[x].parent = id;
    }
  }

  for( i=0 ; i<n ; i++ )
    if(T[i].parent==NIL) root = i;

  getDepth(root,0);

  for( i=0 ; i<n ; i++ ){
    printf("node %d: parent = %d, depth = %d,",i,T[i].parent,C[i]);
    if(T[i].parent==NIL)
      printf(" root, [");
    else if(T[i].left==NIL)
      printf(" leaf, [");
    else
      printf(" internal node, [");
    
    k = T[i].left;
    for( j=0 ; k!=NIL ; j++, k = T[k].right){
      if(j!=0)printf(", ");
      printf("%d",k);
    }
    printf("]\n");
  }



  return 0;
}
void getDepth(int r, int d)
{
  C[r] = d;
  if(T[r].right!=NIL)
    getDepth(T[r].right,d);
  if(T[r].left!=NIL)
    getDepth(T[r].left,d+1);
}

Measured memory_bytes: 5296
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int i,cnt=0,tmp;
  bool b=0;
  string s;
  cin>>s;

  for(i=s.size()-1;i>0;i--){
    tmp=s[i]-'0';
    if(b){
      tmp++;
      if(tmp==10){
        continue;
      }
    }

    if(tmp>5){
      cnt += 10-tmp;
      b=1;
    }
    else if(tmp<5){
      cnt+=tmp;
      b=0;
    }
    else{
      if(s[i-1]-'0'>4){
        cnt+=5;
        b=1;
      }
      else{
        cnt+=5;
        b=0;
      }
    }
  }

  tmp=s[0]-'0';
    if(b){
      tmp++;
      if(tmp==10){
        cnt++;
        cout<<cnt<<endl;
        return 0;
      }
    }

    if(tmp>5){
      cnt += 10-tmp+1;
      cout<<cnt<<endl;
      return 0;
    }
    else if(tmp<5){
      cnt+=tmp;
      cout<<cnt<<endl;
      return 0;
    }
    else{
      cnt+=5;
      cout<<cnt<<endl;
      return 0;
    }
  
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
 
    int mx = max({a, b, c});
    int ans = a + b + c + 9 * mx;

    cout << ans;

   return 0;
}

Measured memory_bytes: 256
N, Y = map(int, input().split())

for i in range(0,Y//10000+1):
    price = Y
    price -= i*10000
    for j in range(0, price//5000+1):
        if (i*10000 + j*5000 + (N-i-j)*1000 == Y and (N-i-j)>=0):
            print(i, j, N-i-j)
            exit()

print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    lint a[2], b[2];
    rep(i, 2) scanf("%lld", &a[i]);
    rep(i, 2) scanf("%lld", &b[i]);
    lint ans = -INF;
    rep(i, 2) rep(j, 2) chmax(ans, a[i] * b[j]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 3824
S = input()
MOD = 10 ** 9 + 7

# ある余りを10倍して13で割ったときの余りへの変換表
rests = [0] * 13
for i in range(len(rests)):
  rests[i] = i * 10 % 13
  
dp = [[0] * 13 for i in range(len(S))]

x0 = S[0]
if x0 != "?":
  dp[0][int(x0)] = 1
else:
  # ?の場合は0～9を全て取ることができ、その余りは0～9となる
  for i in range(10):
    dp[0][i] = 1

for i in range(1, len(dp)):
  x = S[i]
  if x != "?":
    x = int(x)
    # ?じゃない場合は、直前の各あまりをrestsで変換して、その数を足したところに数を代入する
    for j in range(len(dp[i - 1])):
      dp[i][(rests[j] + x) % 13] += dp[i - 1][j]
      dp[i][(rests[j] + x) % 13] %= MOD
  else:
    # ?は0～9の全てを取ることができる
    for j in range(len(dp[i - 1])):
      for k in range(10):
        dp[i][(rests[j] + k) % 13] += dp[i - 1][j]
        dp[i][(rests[j] + k) % 13] %= MOD
  
print(dp[-1][5])

Measured memory_bytes: 96032
import sys
S = input()
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i, s in enumerate(S):
  if (i+1) % 2 != 0: # 奇数の場合
    if s not in odd:
      print('No')
      sys.exit()
  else:
    if s not in even:
      print('No')
      sys.exit()
print('Yes')
    
      


Measured memory_bytes: 38384
// ABC160 C

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int k, n, tmp;
    cin >> k >> n;
    long int anw, dis, buf;
    vector<int> houses;
    for(int i = 0; i < n; i++){
        cin >> tmp;
        houses.push_back(tmp);
    }
    dis = houses.back() - houses.front();
    anw = dis;

    for(int i = 0; i < n; i++){
        houses.push_back(houses.at(i) + k);
    }

    for(int i = 1; i < n; i++){
        buf = dis - (houses.at(i) - houses.at(0)) + (houses.at(n + i -1) - houses.at(n-1));
        if(buf < anw) anw = buf;
    }
    cout << anw << endl;
    return 0;
}

Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] d = new long[N];
		int[]t = new int[N];
		Data[] v = new Data[N];
		Set<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			d[i] = sc.nextLong();
			v[i] = new Data(t[i], d[i]);
			set.add(t[i]);
		}
		sc.close();
		Arrays.sort(v, new MyCompData());
//		for(int i = 0; i < N; i++) {
//			System.out.println(v[i].c);
//		}
		if(set.size() == N) {
			long ans = 0;
			for(int i = 0; i < K; i++) {
				ans += v[i].c;
			}
			long x = K;
			ans += x * x;
			System.out.println(ans);
			System.exit(0);
		}
		int l1 = set.size();
		int l2 = N - set.size();
		Long[]d1 = new Long[l1];
		Long[]d2 = new Long[l2];
		set.clear();
		int idx1 = 0;
		int idx2 = 0;
		for(int i = 0; i < N; i++) {
			if(!set.contains(v[i].id)) {
				set.add(v[i].id);
				d1[idx1++] = v[i].c;
			}else {
				d2[idx2++] = v[i].c;
			}
		}
		long[] s1 = new long[l1 + 1];
		long[] s2 = new long[l2 + 1];
		s1[0] = 0;
		s2[0] = 0;
		Arrays.sort(d1, Collections.reverseOrder());
		Arrays.sort(d2, Collections.reverseOrder());
		for(int i = 1; i <= l1; i++) {
			s1[i] += s1[i - 1] + d1[i - 1];
		}
		for(int i = 1; i <= l2; i++) {
			s2[i] += s2[i - 1] + d2[i - 1];
		}
		long ans = 0;
		int max = Math.min(K, l1);
		for(int i = max; i >= 1; i--) {
			if(K - i > l2) break;
			long x = i;
			long sum = s1[i] + s2[K - i] + x * x;
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}
	static void disp(Long[] d1) {
		for(long i : d1) {
			System.out.print(i +" ");
		}
		System.out.println();
	}
	static void disp(long[] d1) {
		for(long i : d1) {
			System.out.print(i +" ");
		}
		System.out.println();
	}
	static class Data{
		int id;
		long c;
		public Data(int id, long c) {
			this.id = id;
			this.c = c;
		}
	}
	static class MyCompData implements Comparator<Data>{
		@Override
		public int compare(Data d1, Data d2) {
			if(d1.c < d2.c) {
				return 1;
			}else if(d1.c == d2.c) {
				return 0;
			}else {
				return -1;
			}
		}
	}
}

Measured memory_bytes: 99548
#include<cstdio>

int a, b;

int main() {
	scanf("%d%d", &a, &b);
	int ans;
	if(a<=5) ans=0;
	else
	if(a<=12) ans = b/2;
	else ans=b;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8
n = int(input())

alphas = "abcdefghij"
init_str = ""

def standard(moji, x):
    # print("standard({},{})".format(moji,x))
    if len(moji) == n:
        print(moji)
    else:
        for j in range(x+1):
            if j == x:
                # print("j == x")
                standard(moji + alphas[j], x + 1)
            else:
                # print("j != x")
                standard(moji + alphas[j], x)


standard(init_str, 0)


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int ans = 0;
    int len = 0;
    REP(i, N - 1){
        if(H[i] >= H[i + 1]) len++;
        else {
            chmax(ans, len);
            len = 0;
        }
    }
    chmax(ans, len);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
function Main(a, b) {
	if(b.startsWith(a)) {
    	console.log("Yes");
    } else {
    console.log("No");
                    }
  	
}

const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
Main(input[0].trim(), input[1].trim());

Measured memory_bytes: 29624
'use strict'

const main = (input) => {
    input = input.split(' ').map(v => parseInt(v))
    const a = input[0]
    const b = input[1]
    const c = input[2]
    if(b - a === c - b){
        console.log('YES')
    }else{
        console.log('NO')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    // first = b, second = a;
    vector<pair<int, int>> a(N);
    REP(i, N) cin >> a[i].second >> a[i].first;

    SORT(a);
    int time = 0;
    REP(i, N) {
        time += a[i].second;
        if (a[i].first < time) {
            std::cout << "No" << '\n';
            return 0;
        }
    }

    std::cout << "Yes" << '\n';

    return 0;
}

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

int main() {
  int N, K, D = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if (D * 2 <= D + K) {
      D *= 2;
    }
    else {
      D += K;
    }
  }
  cout << D << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i;
	long long a[1000];
	scanf("%d",&n);
	a[0]=2;
	a[1]=1;
   if(n >= 1 && n<=86 && a[n]<1e18)	{
	for(i = 2;i <= n;i++)
        {
        	a[i]=a[i-1]+a[i-2];
		}
       printf("%lld",a[n]);
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ll D;
    cin >> D;
    vl c(26);
    rep(i,26){
        cin >> c[i];
    }
    ll s[D][26];
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }
    vl latest_t(26,0);
    ll k=0;
    vl answer(D);
    FOR(i,1,D+1){
        vl nt=latest_t;
        ll nk=k;
        ll MX=-INF;
        ll ans;
        rep(j,26){
            nt=latest_t;
            nk=k;
            nk+=s[-1+i][j];
            nt[j]=i;
            rep(l,26){
                nk-=c[l]*(i-nt[l]);
            }
            if(nk>MX){
                MX=nk;
                ans=j;
            }
            if(j==25){
                k=MX;
            }
        }
        //cout << ans+1 << endl;
        answer[-1+i]=ans+1;
        latest_t[ans]=i;
    }
    //rep(i,D){
      //  cout << answer[i] << endl;
    //}
    rep(i,2*pow(10,7)){
        int x=rand();
        x%=D-1;
        vl n_answer=answer;
        swap(n_answer[x],n_answer[x+1]);
        if(s[x][n_answer[x]]+s[x+1][n_answer[x+1]]>s[x][answer[x]]+s[x+1][answer[x+1]]){
            answer=n_answer;
        }
    }
    rep(i,D){
        cout << answer[i] << endl;
    }
}

Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main() {
	double W = 0, H = 0, x = 0, y = 0;
	cin >> W >> H >> x >> y;
	if (x == W / 2 && y == H / 2) {
		cout << W * H / 2 << " " << 1;
	}
	else {
		cout << W * H / 2 << " " << 0;
	}
}
 

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

// #define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;

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

const int N = 3e5 + 20;

int32_t main() {

    sync;

    string s; cin >> s;
    int p = 0, q = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] != (i % 2) + '0') p++;
        if (s[i] != !(i % 2) + '0') q++;
    }

    cout << min(p, q) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
int k[10], s[10][10];
int p[10];

void _main() {
    cin >> N >> M;
    REP (i, M) {
        cin >> k[i];
        REP (j, k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    REP (i, M) cin >> p[i];
    int ans = 0;
    REP (bit, 1LL << N) {
        bool ok = true;
        REP (i, M) {
            int cnt = 0;
            REP (j, k[i]) {
                cnt += (bit >> s[i][j] & 1);
            }
            ok &= (cnt % 2 == p[i]);
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main() {
  long long A, B;
  cin >> A >> B;
  
  string result = "Yes";
  if (A % 2 == 0 || B % 2 == 0) {
    result = "No";
  }
  
  cout << result << endl;
  
  return 0;
}

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

using namespace std;


int main()
{
	int A, B;
	cin >> A >> B;
	map<int, int> result;
	float ApNum = ((float)A + 1.0f) / 0.08f;
	float ANum = (float)A / 0.08f;
	int Anum1 = ceil(ANum);
	int Anum2 = floor(ApNum - 0.0000001);
	
	int error = -1;
	float BpNum = ((float)B + 1.0f) / 0.1f;
	float BNum = (float)B / 0.1f;
	int Bnum1 = ceil(BNum);
	int Bnum2 = floor(BpNum - 0.0000001);

	if (Anum1 < Bnum1 && Anum2 < Bnum1) {
		cout << error << endl;
		return 0;
	}

	if (Anum1 > Bnum1 && Bnum2 < Anum1) {
		cout << error << endl;
		return 0;
	}

	int minval = max(Anum1, Bnum1);
	int maxval = min(Anum2, Bnum2);
	minval = min(minval, maxval);

	cout << minval << endl;

	return 0;



}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

typedef long long ll;
using namespace std;
const int maxn = 2e5+10;
const int maxm = 4e6+10;
const double eps = 1e-5;
const int mod = 1e9+7;

int dis[maxn];
bool vis[maxn];
deque<int> q;
int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif // local
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    dis[1]=1;
    q.push_front(1);
    while(!q.empty()) {
        int tmp=q.front();
        q.pop_front();
        if(vis[tmp]) continue;
        vis[tmp]=true;
        if(tmp==0) break;
        if(!dis[tmp*10%k]||dis[tmp*10%k]>dis[tmp]) {
            dis[tmp*10%k]=dis[tmp];
            q.push_front(tmp*10%k);
        }
        if(!dis[(tmp+1)%k]||dis[(tmp+1)%k]>dis[tmp]+1) {
            dis[(tmp+1)%k]=dis[tmp]+1;
            q.push_back((tmp+1)%k);
        }
    }
    cout<<dis[0]<<endl;
    return 0;
}


Measured memory_bytes: 896
import itertools

n = int(input())
s = list(map(int, input().split(' ')))
t = list(map(int, input().split(' ')))
hoge = list(itertools.permutations(range(1, n+1)))
p = 0
q = 0
for i in range(len(hoge)):
  if list(hoge[i]) == s:
    p = i
  if list(hoge[i]) == t:
    q = i
print(abs(p - q))

Measured memory_bytes: 80204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int k;
string s;

int main() {
	fastio; cin >> k >> s;
  if (s.length() <= k) cout << s;
  else cout << s.substr(0, k) << "...";
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<string.h>
int main ()
{
	int b,c;
	char a[111];
	scanf("%s",&a);
	for(c=0;c<strlen(a);c++)
	{
		if(a[c]=='C')
		{
			for(b=c;b<strlen(a);b++)
			{
				if(a[b]=='F')
				{
					printf("Yes\n");break;
				}
				if(b==strlen(a)-1&&a[b]!='F')
				{
					printf("No\n");
				} 
			}
			break;
		}
		if(a[c]!='C'&&c==strlen(a)-1)
		{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
  var n, k, s;
  n = Number(input.split('\n')[0].split(' ')[0]);
  k = Number(input.split('\n')[0].split(' ')[1]);
  s = input.split('\n')[1];
  replaceChar = s.charAt(k-1).toLowerCase();
  s = s.split('')
  s.splice(k-1, 1, replaceChar);
  console.log(s.join(''));
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
# -*- coding: utf-8 -*-S
a,b,c = [int(i) for i in input().split()]

if (a + b) <= (b + c) and (a + b) <=(c + a):
    print(a + b)
elif(b + c) <= (a + b) and (b + c)<= (c + a):
    print(b +c)
elif(c + a) <= (a + b) and (c + a) <= (b + c):
    print(c + a)


Measured memory_bytes: 3060
from heapq import heappop, heappush
X,Y,Z,K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

count = 0
memo = []
H = []
H.append([-(A[0]+B[0]+C[0]),0,0,0])
memo.append((0,0,0))

while count < K:
  p,i,j,k = heappop(H)
  print(-p)
  count += 1
  if (i+1,j,k) not in memo and i <= X-2:
    memo.append((i+1,j,k))
    heappush(H,[-(A[i+1]+B[j]+C[k]),i+1,j,k])
  if (i,j+1,k) not in memo and j <= Y-2:
    memo.append((i,j+1,k))
    heappush(H,[-(A[i]+B[j+1]+C[k]),i,j+1,k])
  if (i,j,k+1) not in memo and k <= Z-2:
    memo.append((i,j,k+1))
    heappush(H,[-(A[i]+B[j]+C[k+1]),i,j,k+1])

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int a, b, x, y ;
    char B='#', W='.' ;
    cin>> a >> b ;
    if(a<b) swap(a, b), swap(B, W) ;
    char grid[105][105] ;
    for(int i=1 ; i<=100 ; i++)
      for(int j=1 ; j<=100 ; j++)
        grid[i][j]=B ;
    x=2 ; y=1 ;
    while(a-1>0)
      {
        grid[x][y]=W ;
        if(y+2>100) x+=2, y=1 ;
        else y+=2 ;
        a-- ;
      }
    x+=2 ; y=1 ;
    for(int i=x ; i<=100 ; i++)
      for(int j=1 ; j<=100 ; j++)
        grid[i][j]=W ;
    x++ ;
    while(b-1>0)
      {
        grid[x][y]=B ;
        if(y+2>100) x+=2, y=1 ;
        else y+=2 ;
        b-- ;
      }
    cout<< 100 << " " << 100 << endl ;
    for(int i=1 ; i<=100 ; i++, cout<< endl)
      for(int j=1 ; j<=100 ; j++)
        cout<< grid[i][j] ;
  }


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

h = [''] * n
c = {'r': 'p', 's': 'r', 'p': 's'}
points = 0

for i, ti in enumerate(t):
    ci = c[ti]
    if i < k or h[i - k] != c[ti]:
        h[i] = ci
        points += eval(ci)
    else:
        p1, p2 = eval(ci), eval(h[i - k])
        if p1 > p2:
            h[i] = ci
            points -= p2
            points += p1
        else:
            h[i] = '*'


print(points)


Measured memory_bytes: 4084
def solve():
    INF = float('inf')

    def WarshallFloyd(adjList):
        numV = len(adjList)
        D = [[INF]*numV for _ in range(numV)]
        for u, adj in enumerate(adjList):
            for v, wt in adj:
                D[u][v] = wt
            D[u][u] = 0
        for k in range(numV):
            Dk = D[k]
            for i in range(numV):
                Di = D[i]
                Dik = Di[k]
                for j in range(numV):
                    D2 = Dik + Dk[j]
                    if D2 < Di[j]:
                        D[i][j] = D2
        return D

    N, M, L = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        A, B = A-1, B-1
        adjL[A].append((B, C))
        adjL[B].append((A, C))

    D = WarshallFloyd(adjL)

    adjL2 = [[] for _ in range(N)]
    for i in range(N):
        for j in range(i+1, N):
            if D[i][j] <= L:
                adjL2[i].append((j, 1))
                adjL2[j].append((i, 1))

    D = WarshallFloyd(adjL2)

    Q = int(input())
    anss = []
    for _ in range(Q):
        s, t = map(int, input().split())
        s, t = s-1, t-1
        if D[s][t] == INF:
            anss.append(-1)
        else:
            anss.append(D[s][t]-1)

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 90968
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 200010
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define ll 	long long  int 
 
#define mod  1000000007


int main()
{
	FAST;
	ll n; ll k;
	cin >> n >> k;
	ll a[n+5];
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	ll x = INT_MAX;
	sort(a, a + n);
	for(ll i = 0; i <= n-k; i ++){
		x = min(x, (a[i+k-1] - a[i]));
	} cout << x;
	return 0;
}

Measured memory_bytes: 4432
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n,t,a;cin>>n;
  cin>>t>>a;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  double sub=inf;
  int mn_num=0;
  rep(i,n){
      if(sub>abs(-(double)h[i]*0.006+t-a)){
          sub=abs(-(double)h[i]*0.006+t-a);
          mn_num=i+1;
      }
  }
  cout<<mn_num<<"\n";
  return 0;
}

Measured memory_bytes: 3608
n=int(input())
mojilist=[]

for i in range(n):
    moji=input()
    moji2=sorted(moji)
    #print(moji2)
    mojilist.append(moji2)

mojilist=sorted(mojilist)
combo=0
answer=0
for i in range(n-1):
    if mojilist[i]==mojilist[i+1]:
        combo+=1
    else:
        if combo!=0:
            answer+=int(combo*(combo+1)/2)
        combo=0

if combo!=0:
    answer+=int(combo*(combo+1)/2)

print(answer)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  string ans;
  if (x == 7 || x == 5 || x == 3) {
    ans = "YES";
  } else {
    ans = "NO";
  }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private class Point {
		double x, y;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		reader.close();
		
		Point a = new Point();
		Point b = new Point();
		a.x = 0;
		a.y = 0;
		b.x = 100;
		b.y = 0;
		print(a);
		koch(n, a, b);
		print(b);
	}
	
	private void koch(int n, Point a, Point b) {
		if (n == 0) return;
		Point s = new Point();
		Point t = new Point();
		Point u = new Point();
		double th = Math.PI * 60.0 / 180.0;
		
		s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
		s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
		t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
		t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
		u.x = (t.x - s.x) * Math.cos(th) - (t.y - s.y) * Math.sin(th) + s.x;
		u.y = (t.x - s.x) * Math.sin(th) + (t.y - s.y) * Math.cos(th) + s.y;
		
		koch(n - 1, a, s);
		print(s);
		koch(n - 1, s, u);
		print(u);
		koch(n - 1, u, t);
		print(t);
		koch(n - 1, t, b);
	}

	private void print(Point p) {
		System.out.println(String.format("%.8f %.8f", p.x, p.y));
	}
}



Measured memory_bytes: 39272
L = list(input().split())
numstack = []
for item in L:
    if item == '+':
        tmp = numstack.pop() + numstack.pop()
        numstack.append(tmp)
    elif item == '-':
        tmp = - numstack.pop() + numstack.pop()
        numstack.append(tmp)
    elif item == '*':
        tmp = numstack.pop() * numstack.pop()
        numstack.append(tmp)
    else:
        numstack.append(int(item))
print(numstack[-1])



Measured memory_bytes: 5600