akhauriyash/Code-Regression huggingface dataset:
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    int n = szz(s);
    int k; cin >> k;
    for(int i=0; i < n; i += k) cout << s[i];
    return 0;
}

Measured memory_bytes: 256
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
  if (ib == ie) {
    ib = ibuf;
    ie = ibuf + fread(ibuf, 1, BUFF, stdin);
  }
  return ib == ie ? -1 : *ib++;
}

}

LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}

int main() {
  const vector<int> arr {1, 2, 4, 7, 12, 20, 29, 38, 52, 73};
  int n = read();
  vector<vector<LL> > w(n, vector<LL>(n));

  auto get_max = [&](int n) {
    vector<int> vc(n);
    iota(vc.begin(), vc.end(), 0);
    LL ret = 0;
    do {
      LL cur = 0;
      for (unsigned i = 1; i < vc.size(); ++i) {
        cur += w[vc[i - 1]][vc[i]];
      }
      ret = max(ret, cur);
    } while (next_permutation(vc.begin(), vc.end()));
    return ret;
  };

  LL m = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < i; ++j) {
      w[i][j] = w[j][i] = (m + 1) * arr[j];
    }
    m = get_max(i + 1);
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cout << w[i][j] << "\n "[j < n - 1];
    }
  }
  return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;

int main()
{
    int N;
    cin >> N;
    vi ti(N+1), xi(N+1), yi(N+1);
    REP(i, N) cin >> ti[i+1] >> xi[i+1] >> yi[i+1];

    bool suc = true;
    REP(i, N) {
        int dis = abs(xi[i+1] - xi[i]) + abs(yi[i+1] - yi[i]);
        int time = ti[i+1] - ti[i];
        if(dis > time || dis %2 != time % 2) {
            suc = false;
            break;
        }
    }
    if(suc) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
K = int(input())

now = 0
dic = {}

import sys
cnt = 1
while True:

    now = (now * 10 + 7) % K
    if now == 0:
        print (cnt)
        sys.exit()
    elif now in dic:
        print (-1)
        sys.exit()
    else:
        dic[now] = 1
    cnt += 1


Measured memory_bytes: 158092
#include <iostream>
using namespace std;
#include<string>
#define ll long long

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
//const ll N=1e5+5;


int main(){
    ll n,s=0,q,a;
    cin>>n;
    map<ll,ll> ml;
    fr(i,0,n){
        cin>>a;
        ml[a]++;
        s+=a;
    }
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        ll diff=c-b;
        s+=(c-b)*ml[b];
        ml[c]+=ml[b];
       ml[b]=0;
        cout<<s<<'\n';
    }
	return 0;
}


Measured memory_bytes: 9360
s = input()
ab, cd = int(s[0:2]), int(s[2:4])
if 0 < ab <= 12:
    if 0 < cd <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < cd <= 12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
def main():
    import sys

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

    def gcd(x,y):
        r = x%y
        if r==0:
            return y
        return gcd(y, r)

    n, k =map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    c = a[0]
    for i in range(n):
        c = gcd(a[i], c)
    if k%c == 0 and k <= a[0]:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 19788
#include<iostream>
#include<fstream>

using namespace std;

bool isPrime(int n){
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;

	for (int i = 3; i * i <= n; i += 2){
		if (n % i == 0)return false;
	}
	return true;
}

int main(){
//	ifstream fin("in.txt");

	int n = 0;
	int count = 0;

	while (true){
		count = 0;

		cin >> n;
		if (n == 0)break;

		for (int i = n + 1; i <= 2 * n; i++)
			if (isPrime(i))count++;

			cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	for i := 0; i < n; i++ {
		sc.Scan()
		edges := make([]int, 3, 3)
		for i, c := range strings.Split(sc.Text(), " ") {
			edges[i], _ = strconv.Atoi(c)
			edges[i] = int(math.Pow(float64(edges[i]), 2))
		}
		sort.IntSlice(edges).Sort()
		msg := "NO"
		if edges[2] == edges[0]+edges[1] {
			msg = "YES"
		}
		fmt.Println(msg)
	}
}

Measured memory_bytes: 1240
//file_name:ABC70_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;


    ll ans = 0;

    int s = max(a,c);
    int g = min(b,d);

    if(g>s){
        ans = g-s;
    }

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



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

#define TOP 100001
#define INF 1e14

using namespace std;

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

    int n, w;
    cin >> n >> w;

    long long a, b;
    vector<long long> cost(TOP + 1, INF);
    cost[0] = 0;

    cost[0] = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a >> b;
        for (int j = TOP; j >= b; j--) {
            if (cost[j - b] != INF && cost[j - b] + a <= w)
                cost[j] = min(cost[j], cost[j - b] + a);
        }
    }

    int ans = TOP;
    for(; ans >= 0; ans--)
        if(cost[ans] != INF)
            break;


    cout << ans << "\n";

    return 0;
}//RUL0

Measured memory_bytes: 1024
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
    ll len;
    cin>>len;
    string a,b;
    cin>>a>>b;
    for(auto i=0; i<len;i++){
        cout<<a[i]<<b[i];
    }
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int R,C,i,j,r[105]={0},c[105]={0},t;
    scanf("%d%d",&R,&C);
    for(i=0;i<=R;i++)
        for(j=0;j<=C;j++)
        {
            if(i<R&&j<C)
            {
                scanf("%d",&t);
                r[i]+=t;c[j]+=t,c[C]+=t;
            }
            printf("%d%s",i==R?c[j]:j==C?r[i]:t,j==C?"\n":" ");
        }
    return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
std::vector<int>A['   '];int N,M,S['   '],B,L,R,I;void U(int z,int u){while(z<=N)S[z]+=u,z+=z&-z;}main(){std::cin>>M>>N;for(I=1;I<=M;I++)std::cin>>L>>R,A[R-L+1].push_back(L);for(L=1;L<=N;L++){B=M;for(I=L;I<=N;I+=L){R=I;while(R)B+=S[R],R-=R&-R;}for(int u:A[L])U(u,1),U(u+L,-1),M--;printf("%d\n",B);}}

Measured memory_bytes: 53760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++) {
    int temp=i;
    int s[5];
    s[0]=temp%10;
    REP1(j,4) {
      temp/=10;
      s[j]=temp%10;
    }
    if(s[0]==s[4]&&s[1]==s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int R;
int main() {
  cin >> R;
  printf("%.6lf", 2 * M_PI * R);
}

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

using namespace std;
#define N 100010
int main(){
	int n,m,h[N],ma[N];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		ma[i]=0;
	}
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
		ma[b]=max(ma[b],h[a]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=h[i]>ma[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

void solve(){
	char c; cin>>c;
	if(c >= 'a' && c <= 'z') cout << 'a';
	else cout << 'A';
}
int main() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n<3200) cout << "red" << endl;
  else cout << s << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (var h in Enumerable.Range(0, int.Parse(Console.ReadLine()))
                                        .Select(_ => Console.ReadLine()
                                            .Split(' ')
                                            .Select(int.Parse)
                                            .OrderBy(i => i)
                                            .ToArray()))
            {
                Console.WriteLine(h[0] * h[0] + h[1] * h[1] == h[2] * h[2] ? "YES" : "NO");
            }
        }
    }
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  if (S[0] == T[0])
    ++ans;
  if (S[1] == T[1])
    ++ans;
  if (S[2] == T[2])
    ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

int n;
int q;
int l[N];
int r[N];
int tim = 1;
int disc[N];
long long cm[N];
vector < int > adj[N];

void dfs(int u , int p){
     for(auto v : adj[u]){
        if(v == p)
            continue;
        cm[v] += cm[u];
        dfs(v , u);
     }
}

void dfs1(int u , int p){
     for(auto v : adj[u]){
        if(v == p)
            continue;
        dfs(v , u);
        cm[u] += cm[v];
     }
}

int main(){
    scanf("%d%d" , &n , &q);
    for(int i = 1; i < n; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while(q--){
        int p , x;
        scanf("%d%d" , &p , &x);
        cm[p] += x;
    }
    dfs(1 , -1);
    for(int i = 1; i <= n; i++){
        printf("%lld " , cm[i]);
    }
}

Measured memory_bytes: 26240
#include <stdio.h>
 
int main(void)
{
	int i,j,n,m,cn;

	char c,s[5]={'S','H','C','D','\0'};

	static int card[4][13];

	scanf("%d\n",&n);
 
	for(i=0;i<n;i++){
	scanf("%c %d\n",&c,&m);
	for(j=0;j<4;j++)
	if(s[j]==c)
	card[j][m-1]=1;
	}
   
	for(i=0;i<4;i++)
	for(j=0;j<13;j++)
	if(card[i][j]==0)
	printf("%c %d\n",s[i],j+1);
 
return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 string s;
 cin >> s;
 if(s=="SUN") cout << 7 << endl;
 if(s=="MON") cout << 6 << endl;
 if(s=="TUE") cout << 5 << endl;
 if(s=="WED") cout << 4 << endl;
 if(s=="THU") cout << 3 << endl;
 if(s=="FRI") cout << 2 << endl;
 if(s=="SAT") cout << 1 << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


double dp[301][301][301];
int po[305][305][305];
int n;
double fun(vector<int> v){
    int p=v[0],q=v[1],r=v[2];
if(v[0]+v[1]+v[2]==0)
    return 0.0;
if(po[p][q][r])
    return dp[p][q][r];
double x=0.0;
if(v[0]!=0){
        vector<int> v1=v;
        v1[0]--;

    x+=double(v[0]*(fun(v1)+1));
}
if(v[1]!=0){
        vector<int> v1=v;
        v1[1]--;
        v1[0]++;

    x+=double(v[1]*(fun(v1)+1));
}
if(v[2]!=0){
        vector<int> v1=v;
        v1[2]--;
        v1[1]++;

    x+=double(v[2]*(fun(v1)+1));
}
float p1=(double(n)-double(v[0]+v[1]+v[2]));
x=(x+p1)/(n-p1);
dp[p][q][r]=x;
po[p][q][r]=1;
return x;







}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
vector<int>v(3);
for(int i=0;i<n;i++){
    int x;
    cin>>x;
    x--;
    v[x]++;
}


double ans=fun(v);
cout<<fixed<<setprecision(15)<<ans<<endl;



}


Measured memory_bytes: 323968
#include<bits/stdc++.h>
using namespace std;
main()
{
   int i,k,l,m,n;
    while(cin>>m>>n){
double x[m],j;
 for(i=0;i<m;i++){
    cin>>j;
    x[i]=(j+1)/2;

 } double a=0,b,c;
for(i=0;i<n;i++) a+=x[i];
b=a;
for(i=n;i<m;i++){
    b+=x[i];
    b-=x[i-n];
    k=b/a;
    if(k>0) a=b;
}
    printf("%.12f\n",a);
    } return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;


int32_t main() {
	// your code goes here
int k,count=0,sum=0,i,j;
cin>>k;
if(k%2==0)
{
    cout<<"-1\n";
}
else
{
    while(1)
    {
        if(count>k)
        {cout<<"-1\n";
        break;
        }
        sum=10*sum+7;
        count++;
        sum%=k;
        if(!sum)
        {
            cout<<count<<"\n";
            break;
        }
    }
}
	return 0;
}


Measured memory_bytes: 3632
import math

n, m, x = map(int, input().split())
a = [int(i) for i in input().split()]
l = 0
r = 0
for i in range(x):
    if i in a:
        l += 1
for i in range(x + 1, n):
    if i in a:
        r += 1
print(min(l, r))


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

int main(void){
    // Your code here!
   char a, b, c;
   cin >> a >> b >> c;
   if((a == '5' && b == '5' && c == '7') || (b == '5' && c == '5' && a == '7') || (a == '5' && c == '5' && b == '7')){
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            //int i = 0;
            int n;
            int min = 1000000;
            int max = -1000000;
            long total = 0;

            string num1 = Console.ReadLine();
            n = int.Parse(num1);

            string[] num2 = Console.ReadLine().Split(' ');
            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(num2[i]);
            }
            
            foreach (int ai in array)
            {
                total += ai;

                if (min > ai)
                {
                    min = ai;
                }
                if (max < ai)
                {
                    max = ai;
                }
            }
            Console.WriteLine(min + " " + max + " " + total);
        }
    }



Measured memory_bytes: 10068
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

int main(){
    ll d, g;
    ll p[102], c[102];
    ll used[102] = {};
    cin >> d >> g;
    REP(i, d){
        cin >> p[i] >> c[i];
    }
    ll ans = mod;
    REP(mask, (1 << d)){
        ll s = 0, num = 0, rest_max = -1;
        REP(i, d){
            if(mask >> i & 1){
                s += 100 * p[i] * (i + 1) + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        if(s < g){
            ll s1 = 100 * (rest_max + 1);
            ll need = (g - s + s1 - 1) / s1;
            if(need >= p[rest_max]){ continue;}
            num += need;
        }
        ans = min(ans, num);
    }
    print(ans);
}


Measured memory_bytes: 256
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mod 1000000007
// -----------------------------------------------------------------
void solve()
{
    int n,i,j,k,m;
    cin>>n>>m;
    int ans = n*(n-1)/2 +  m*(m-1)/2;
    cout<<ans;
}
signed main()
{
    out_of_reach;
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

int main(){
int N; cin >> N ; vector<double> p(N);
  for(int i = 0; i < N; i++){
    cin >> p[i];}
  
  double dp[3000][3000];
  
  for(int i = 0; i < 3000; i++){
    for(int j = 0; j < 3000; j++){
      dp[i][j] = 0;}}
  
  dp[0][0] = 1.0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * ( 1.0 - p[i]);}}

  
   double sum = 0;
  for(int j = (N + 1) / 2; j <= N; j++){
    sum += dp[N][j];}
  cout << setprecision(10) << sum << endl; return 0;}
                       
  
 


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

struct Node{
	int key;
	struct Node *right, *left , *parent;
};

struct Node *root , *NIL;

void insert(int k)
{
	struct Node *y = NIL;
	struct Node *x = root;
	struct Node *z;
	
	z = (struct Node *)malloc(sizeof(struct Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while( x != NIL)
	{
		y = x;
		if(z->key < x->key)
		{
			x = x->left;
		}
		else{
			x = x->right;
		}
	}
	z->parent = y;
	if(y == NIL)
	{
		root = z;
	}
	else{
		if(z->key < y->key)
		{
			y->left = z;
		}
		else{
			y->right = z;
		}
	}
}

void inorder(struct Node *u)
{
	if( u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u)
{
	if( u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void)
{
	int n , i , x;
	char  com[100];
	char str1[] = "insert";
	char str2[] = "print";
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		while(scanf("%s",com) != EOF)
		if(strcmp(com,str1)==0)
		{
			scanf("%d",&x);
			insert(x);
		}
		else if( strcmp(com,str2)==0)
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}


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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
    if(debug_flag){
        cout<<str;
    }
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(10);

    string str;
    cin>>str;
    int n=false, e=false, w=false, s=false;
    for(int i=0; i<str.length(); ++i){
        if(str[i]=='N'){
            n=true;
        }
        if(str[i]=='E'){
            e=true;
        }
        if(str[i]=='W'){
            w=true;
        }
        if(str[i]=='S'){
            s=true;
        }
    }

    if(n==s && e==w){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> a(N); 
  for(int i=0;i<N;i++) {
    cin >> a.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> b(M);
  for(int j=0;j<M;j++) {
    cin >> b.at(j);
  }
  
  vector<int> x(N);
  for(int i=0;i<N;i++) {
    int z=0;
    for(int j=0;j<N;j++) {
      if(a.at(i)==a.at(j)) {
        z++;
      }
    }
    x.at(i)=z;
  }
  
  vector<int> y(N);
  for(int i=0;i<N;i++) {
    int w=0;
    for(int j=0;j<M;j++) {
      if(a.at(i)==b.at(j)) {
        w++;
      }
    }
    y.at(i)=w;
  }
  
  int n=x.at(0)-y.at(0);
  for(int i=0;i<N;i++) {
    if(x.at(i)-y.at(i)>n) {
      n=x.at(i)-y.at(i);
    }
  }
  if(n<0) {
    cout << 0 << endl;
  }
  else {
    cout << n << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll  long long
const int N=1e5+10;
pair<int,int>a[N];
priority_queue<ll,vector<ll>,greater<ll> > p;
int main()
{
		int n,k;
		cin>>n>>k;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i].first;
			cin>>a[i].second;
			a[i].first=k-a[i].first+1;
		}
		if(n==1)
		{
			if(a[1].first>0)
			cout<<a[1].second;
			else
			cout<<0;
			return 0;
		}
		sort(a+1,a+1+n);
		for(int i=1;i<=n;i++)
		{
			if(p.size()<a[i].first&&a[i].first>0)
			{
				p.push(a[i].second);
			}
			else if(p.size()==a[i].first&&a[i].first>0)
			{
				if(p.top()<a[i].second)
				{
					p.pop();
					p.push(a[i].second);
				}
			}
		}
		ll ans=0;
		while(!p.empty())
		{
			ans=ans+p.top();
			p.pop();
		}
		cout<<ans<<"\n";
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  if (A.size() < N) {
    cout << "NO" << endl;
  }
  else {
    cout << "YES" << endl;
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(20)
#define Accepted_MAGIC cin.tie(0);ios::sync_with_stdio(false)

// typedef long long ll;
using Real = long double;
#define int long long

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;
constexpr Real eps = 1e-11, pi = acos(-1);

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

signed main(void){
  Accepted_MAGIC;
  
  int K, N, A[200000]; cin >> K >> N;
  REP(i, N) cin >> A[i];
  int ans = K-(A[0]+(K-A[N-1]));
  for(int i = 1; i < N-1; i++){
  	chmin(ans, min(K-(A[i]-A[i-1]), K-(A[i+1]-A[i])));
  }
  chmin(ans, K-A[N-1]+A[N-2]);
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> P;
#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()
vi dy = { 0,0,1,-1 };
vi dx = { 1,-1,0,0 };
constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;



int main() {
	int n;
	cin >> n;
	vi gap(13, 0);
	rep(i, n) {
		int d;
		cin >> d;
		gap[d]++;
	}
	bool same = false;
	rep(i, 13)if (gap[i] >= 3)same = true;
	if (gap[0] > 0||gap[12]>=2)same = true;

	if (same) {
		cout << 0 << endl;
		return 0;
	}

	vi c = { 0,24 };
	bool mns = false;
	rep1(i, 11) {
		if (gap[i] == 0)continue;
		if (gap[i] == 1) {
			if (!mns) { c.push_back(i); mns = true; }
			else { c.push_back(24-i); mns = false; }
		}
		if (gap[i] == 2) {
			c.push_back(i);
			c.push_back(24-i);
		}
	}
	if (gap[12] == 1) {
		c.push_back(12);
	}

	sort(all(c));

	int ans = 12;

	rep(i, c.size() - 1) ans = min(ans, c[i + 1] - c[i]);
	
	cout << ans << endl;

}

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

#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()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
	ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }
	ll lcm(ll x, ll y){ return (x  / gcd(x, y) * y ); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI a(n);
	rep(i, n) cin >>a[i];
	ll zz=a[0]; int ng= 0, zm=-1;
	rep(i, n){
		zz = lcm(zz, a[i]);
		if(zz > 2LL*m){ ng=1; break;}
		int c=0;
		for(int w=a[i]; w>0 && w%2==0; w/=2) c++;
		if(zm ==-1 && c>0) zm=c;
		if(zm !=-1 && c>0 && zm !=c){ ng=1; break;}
	}
	ll ans = 0;
	if(2LL*m >= zz) ans = 1 + (m-zz/2)/zz;

	if(ng) ans =0;
	cout << ans <<"\n";

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a,b;
  cin >> a >> b;
  int ans = a + b;
  if(ans < 10)cout << ans << endl;
  else cout << "error" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    vector<string> v{"dream","dreamer","erase","eraser",""};
    string s; cin >> s;

    bool ans = true;

    while(s.size() != 0) {
        REP(i,v.size()) {
            if (i == v.size()-1) {
                ans = false;
            } else {
                if( s.size() >= v[i].size() && s.compare(s.size()-v[i].size(),string::npos,v[i]) == 0) {
                    REP(j,v[i].size()) s.pop_back();
                    break;
                }
            }
        }
        if (!ans) break;
    }

    CFYN(ans);

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args)
	{
		FastReader in = new FastReader();
		int n = in.nextInt();
		int k = in.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++)
		{
			h[i] = in.nextInt();
		}
		int[] dp = new int[n];
		for(int i = 1; i < n; i++)
		{
			int min = Integer.MAX_VALUE;
			for(int j = 1; j <= k && i-j >= 0; j++)
			{
				min = Math.min(dp[i-j]+Math.abs(h[i-j]-h[i]), min);
			}
			dp[i] = min;
		}
		System.out.println(dp[n-1]);
	}
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                }
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 200111, inf = 1000111222;
const ll mod = 1000000007;

int n, m;
string s;

ll dp[max_n];
ll pr[max_n];
ll dp2[max_n];

ll solve_allr() {
    ll ans = 1;
    dp[1] = 1;
    dp[2] = 0;
    ll sum = dp[1];
    for (int i = 3; i < max_n; ++i) {
        dp[i] = sum;
        sum += dp[i - 1];
        sum %= mod;
    }
    for (int len = 1; len < n; ++len) {
        ans += dp[n - len] * (len + 1);
        ans %= mod;
    }
    return ans;
}

ll solve(int L) {
    int L1 = L / 2;
    pr[1] = 1;
    dp2[1] = 1;
    for (int i = 2; i < max_n; ++i) {
        dp2[i] = (pr[i - 1] - pr[max(1, i - L1 - 1) - 1] + 2 * mod) % mod;
        pr[i] = pr[i - 1] + dp2[i];
        pr[i] %= mod;
    }
    dp[1] = 1;
    for (int i = 3; i < max_n; i += 2) {
        dp[i] = dp2[i / 2 + 1];
    }
    ll ans = 0;
    for (int len = 1; len <= min(L, n - 1); len += 2) {
        ans += dp[n - len] * (len + 1);
        ans %= mod;
    }
    return ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    cin >> s;
    if (s[0] == 'B') {
        for (int i = 0; i < s.size(); ++i) {
            s[i] = (s[i] == 'B' ? 'R' : 'B');
        }
    }
    bool allr = 1;
    for (char c : s) {
        if (c == 'B') {
            allr = 0;
            break;
        }
    }
    if (allr) {
        cout << solve_allr() << endl;
        return 0;
    }
    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    while (s.back() == 'R') {
        s.pop_back();
    }
    int L = 0;
    int st;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'B') {
            st = i;
            break;
        } else {
            ++L;
        }
    }
    if (L % 2 == 0) {
        ++L;
    }
    int len = 1;
    for (int i = st + 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            ++len;
        } else {
            if (s[i] == 'B' && len % 2 == 1) {
                L = min(L, len);
            }
            len = 1;
        }
    }
    cout << solve(L) << endl;
    return 0;
}

// think 2:06


Measured memory_bytes: 5252
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int K;
    string s;
    cin >> K;
    cin >> s;

    if (s.size() <= K)cout << s << endl;
    else cout << s.substr(0,K) << "..." << endl;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  int l;
  if(S.size() > K)  l = K;
  else  l = S.size();
  
  rep(i, l){
   cout << S.at(i); 
  }
  if(S.size() > K) cout << "...";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
//
// Created on 2020/08/16.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



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


Measured memory_bytes: 3524
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 4000 + 5;
int vis[N][3];
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int t1 = 0,t2 = 0,t3 = 0;
	for(int i = n-1; i > 0; i--){
		if(s[i] == 'R'){
			t1++;
			vis[i][0] = t1;
		}
		else{
			vis[i][1] = t2;
			vis[i][2] = t3;
		}
		if(s[i] == 'G'){
			t2++;
			vis[i][1] = t2;
		}
		else{
			vis[i][0] = t1;
			vis[i][2] = t3;
		}
		if(s[i] == 'B'){
			t3++;
			vis[i][2] = t3;
		}
		else{
			vis[i][1] = t2;
			vis[i][0] = t1;
		}
	}
	ll sum = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(s[i] != s[j]){
				int k = 2 * j - i;
				if((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B')){
					sum += vis[j][0];
					if(s[k] == 'R')
						sum -= 1;
				}
				if(s[i] == 'B' && s[j] == 'R' || (s[i] == 'R' && s[j] == 'B')){
					sum += vis[j][1];
					if(s[k] == 'G')
						sum -= 1;
				}
				if(s[i] == 'R' && s[j] == 'G' || (s[i] == 'G' && s[j] == 'R')){
					sum += vis[j][2];
					if(s[k] == 'B')
						sum -= 1;
				}
			}
		}
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3652
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
vector<P> ans;

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

  cin >> s;

  if (s[Size(s) - 1] == '1' || s[0] == '0') {
    Cout(-1);
    return 0;
  }
  rep(i, Size(s) - 1) {
    if (s[i] == s[Size(s) - i - 2]) continue;
    Cout(-1);
    return 0;
  }
  ll now = 0;
  rep(i, Size(s) - 1) {
    if (s[i] == '1') {
      ans.p_b({now, now + 1});
      now++;
    } else {
      cnt = 0;
      while (1) {
        if (s[i] == '0')
          cnt++, i++;
        else {
          break;
        }
      }
      ll to = now + 1;
      rep(j, cnt) {
        ans.p_b({now, to});
        to++;
      }
      ans.p_b({now, to});
      now = to;
    }
  }
  rep(i, Size(s) - 1) { cout << ans[i].fi + 1 << " " << ans[i].se + 1 << "\n"; }
  return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()

ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll c(ll a,ll b)
{
  if(a==0)return b==0?1:0;

if(b>a)return 0;

  ll val=1;
ll fac=1;
for(int i=1;i<=b;i++)fac*=i;
for(int i=a;i>=a-b+1;i--)val*=i;

  return val/fac;

}

ll f(ll n)
{
  ll ans=1LL;
  while(ans<=n)ans<<=1;

return ans;
}

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


    ll n;cin>>n;

    vl v={1,2,3,5,6,9,10,13,17};

    for(int i=0;i<9;i++)
    {
      if(v[i]==n)
      {
        cout<<"No"<<"\n";
        return 0;
      }
    }
  cout<<"Yes"<<"\n";

return 0;

}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

sum = sum(B)
for i in range(0, N):
  if i > 0 and A[i] - A[i - 1] == 1:
    sum += C[A[i] - 2]

print(sum)

Measured memory_bytes: 3064
MOD = 10**9+7
n = int(input())
c = [int(input())]
for _ in range(n-1):
    x = int(input())
    if x != c[-1]: c.append(x)
n = len(c)
t = [-1] * (10**5*2+1)
t[c[0]] = 0
dp = [1] + [0] * (n-1)

for i in range(1, n):
    dp[i] += dp[i-1]
    if t[c[i]] != -1:
        dp[i] += dp[t[c[i]]]
    dp[i] %= MOD
    t[c[i]] = i

print(dp[-1])


Measured memory_bytes: 24404