akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Your code here!

def Bellman_Ford(g,start):
    n = len(g)    
    dist = [float("inf")]*n
    dist[start] = 0
    a0 = float("inf")
    negative = [False]*n
    for i in range((2*n)):
        updated = False
        for v in range(n):
            for to, cost in g[v]:
                if negative[v]: negative[to] = True
                if dist[to] <= dist[v] + cost: continue
                dist[to] = dist[v] + cost
                updated = True
                if i >= n:
                    negative[to] = True
        if not updated: break
    if negative[-1]: return None, False
    return dist, True
 

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n,m,p = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(m):
    a,b,c = [int(i) for i in readline().split()]
    g[a-1].append((b-1,-c+p))
#    g[b-1].append((a-1,c))

dist, TF = Bellman_Ford(g, 0)

if TF: print(max(-dist[-1],0))
else: print(-1)




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

int main() {
  int N, M;
  cin >> N ;
  vector<string> blue(N);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    blue.at(i) = s;
  }
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++) {
    string t;
    cin >> t;
    red.at(i) = t;
  }
  int maxCnt = 0;
  for (int i = 0; i < N; i++) {
    string tmp = blue.at(i);
    int cnt = 1;
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (blue.at(i) == blue.at(j)) {
        cnt ++;
      }
    }
    for (int j = 0; j < M; j++) {
      if (blue.at(i) == red.at(j)) {
        cnt --;
      }
    }
    if (cnt > maxCnt) {
      maxCnt = cnt;
    }
  }
  cout << maxCnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int n, sec;
    cin >> n;
    vector<int> c(n);
    vector<int> s(n);
    vector<int> f(n);
    vector<int> answer(n+1, 0);
    for(int i=1; i<=n-1; ++i){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=1; i<=n; ++i){
        if(i == n){
            cout << answer[i] << endl;
            break;
        }
        else {
            sec = 0;
            for(int j=i; j<n; ++j){
                if(sec >= s[j]){
                    sec += c[j] + ((sec % f[j] == 0) ? 0 : (f[j] - (sec % f[j])));
                }
                else {
                    sec = s[j] + c[j];
                }
            }
        }
        cout << sec << endl;
    }
}


Measured memory_bytes: 256
from collections import deque
from bisect import bisect_left
inf = float('inf')


N = int(input())
A = [int(input()) for _ in range(N)]

color = deque()

for a in A:
    pos = bisect_left(color, a)
    if pos == 0:
        color.appendleft(a)
    else:
        color[pos-1] = a

ans = len(color)
print(ans)

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define MOD 1000000007
#define F first
#define S second

typedef long long ll;
using namespace std;

int n, a, pre, ans;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    while (n--) {
        cin >> a;
        if (a == pre) {
            pre = 0;
            ++ans;
        }
        else pre = a;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  double a, b, h, m, x, y, z, x2, y2, ans; cin >> a >> b >> h >> m;
  x = m / 60;
  y = (h + m / 60) / 12;
  x2 = max(x, y);
  y2 = min(x, y);
  if(x2 - y2 < 0.5){
    z = x2 - y2;
  }
  else{
    z = 1 - (x2 - y2);
  }
  ans = a * a + b * b - 2 * a * b * cos(z * 2 * M_PI);
  ans = sqrt(ans);
  cout << fixed << setprecision(10) << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

bool is_753(ll n) {
  string s = to_string(n);
  int cnt_3 = 0;
  int cnt_5 = 0;
  int cnt_7 = 0;
  for (auto &c : s) {
    if (c == '3')
      cnt_3++;
    else if (c == '5')
      cnt_5++;
    else if (c == '7')
      cnt_7++;
    else
      return false;
  }
  if (cnt_3 > 0 && cnt_5 > 0 && cnt_7 > 0) {
    return true;
  } else {
    return false;
  }
}

ll n;

int count_753(ll a) {
  int ret;
  if (a > n) {
    return 0;
  }
  if (is_753(a)) {
    ret = 1;
  } else {
    ret = 0;
  }
  ret += count_753(a * 10 + 3);
  ret += count_753(a * 10 + 5);
  ret += count_753(a * 10 + 7);
  return ret;
}

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

  cout << count_753(0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int ni, si, li;
long long ds;

void read(void)
{
    scanf("%d %d %d", &ni, &si, &li);
}

void exec(void)
{
    long long ss, ls;
    
    ss = 1LL * si * (ni - 1) + li, ls = si + 1LL * li * (ni - 1);
    ds = ls - ss + 1, ds = (ds < 0) ? 0 : ds;
}

void write(void)
{
    printf("%lld\n", ds);
}

int main(void)
{
    read();
    exec();
    write();
    return 0;
}


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

int main(){
    ll  h , w , k ;
    cin >> h >> w >> k ;
    vector<string> S(h) ;
    rep(i,h) cin >> S[i] ;
    ll ans = 0 ;
    rep(i,1<<h){
      rep(j,1<<w){
        ll count = 0 ;
        rep(n,h){
          rep(m,w){
            if(i&1<<n) continue ;
            if(j&1<<m) continue ;
            if(S[n][m] == '#')count++ ;
          }
        }
        if(count == k )ans++ ;
      }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>

using namespace std;

void recur(int index, int num, vector<int>& vec){
    if(index==vec.size()){
        for(int v : vec){
            cout << (char)('a'+v);
        }
        cout << endl;
        return;
    }
    for(int i=0;i<num;++i){
        vec[index] = i;
        recur(index+1, num, vec);
    }
    vec[index] = num;
    recur(index+1, num+1, vec);
}
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    recur(0, 0, vec);

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int l[n], r[n];
  rep(i, n) cin >> l[i] >> r[i];
  int ans = 0, tmp = 0;
  rep(i, n) ans += (r[i] - l[i]) + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())
cnt = 0

for i in range(n+1):
    ans = 0
    tmp = i
    while(tmp>0):
        ans += tmp%10
        tmp = tmp//10
        #print(ans, tmp)
    
    if(a<=ans and ans<=b):
        cnt+=i

print(cnt)



Measured memory_bytes: 9068
#include"iostream"
#include"stdio.h"
#include"cmath"
#include"algorithm"

#define MAXN 1000050
using namespace std;

long long A[MAXN];

int main()
{
    int X;
    int ans = 1;
    scanf("%d", &X);
    for(int i = 2; i < X; i++)
        for(int j = i * i; j <= X; j *= i)
            ans = max(ans, j);
    printf("%d\n", ans);        
    return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
a = map(int, raw_input().split())
count = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [0 for i in range(n1+1)]
    R = [0 for i in range(n2+1)]
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = 10**9 + 1
    R[n2] = 10**9 + 2
    i = 0
    j = 0
    for k in range(left, right):
        global count
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = int((left + right) /2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

mergeSort(a, 0, n)
print ' '.join(map(str, a))
print count

Measured memory_bytes: 70392
def DFS(n):
    global ans
    stack.append(n)
    for i in range(M):
        if graf[i][0] ==n:
            if graf[i][1] not in stack:DFS(graf[i][1])
        if graf[i][1]==n:
            if graf[i][0] not in stack:DFS(graf[i][0])
    if len(stack)==N:ans+=1
    stack.pop()

N,M=map(int,input().split())
graf,stack,ans=[],[],0
for _ in range(M):
    graf.append(list(map(int,input().split())))
DFS(1)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;

    return 0;
}

Measured memory_bytes: 3616
"""
n=int(input())
s=[int(x) for x in input().split()]
q=int(input())
t=[int(x) for x in input().split()]
#print(s)
c=0
for i in t:
    if i in s:
        c+=1
print(c)
"""
"""
n=int(input())
s=[int(x) for x in input().split()]
q=int(input())
t=[int(x) for x in input().split()]
#binary search
a=0
for i in range(q):
    L=0
    R=n-1#探索する方の配列(s)はソート済みでないといけない
    while L<=R:
        M=(L+R)//2
        if s[M]<t[i]:
            L=M+1
        elif s[M]>t[i]:
            R=M-1
        else:
            a+=1
            break
print(a)
"""
#Dictionary
#dict型オブジェクトに対しinを使うとキーの存在確認になる
n=int(input())
d={}
for i in range(n):
    command,words=input().split()
    if command=='find':
        if words in d:
            print('yes')
        else:
            print('no')
    else:
        d[words]=0



Measured memory_bytes: 33120
def main():
    H, W, K = map(int, input().split())
    C = [list(input()) for _ in range(H)]
    def cnt(C, hp, wp):
        c = 0
        for h in range(H):
            if hp & (1 << h):
                continue
            for w in range(W):
                if wp & (1 << w):
                    continue
                if C[h][w] == '#':
                    c += 1
        return c

    c = 0
    for hp in range(2 ** H):
        for wp in range(2 ** W):
            if cnt(C, hp, wp) == K:
                c += 1
    return c

print(main())


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

int main() {
  int N, K, D, T, Sum=0;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, K){
    cin >> D;
    rep(j, D){
      cin >> T;
      A.at(T-1)++;
    }
  }
  rep(i, N) if(A.at(i)==0) Sum++;
  cout << Sum << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>

using namespace std;

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

int main (int argc, char*argv[]) {
  int n;
  cin >> n;
  vector<int> array (n, 0);
  for(int i=0; i<n; i++) {
    cin >> array[i];
  }
  ll count = 0;
  for(auto a : array) {
    for(int i=30; i>0; i--) {
      if(a % (1<<i) == 0) {
        count += i;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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;}

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

int main(){
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int width=x2-x1;
    int height=y2-y1;
    if(width==0){
        if(height<0){
            height*=-1;
            cout<<x2+height<<endl<<y2<<endl<<x1+height<<endl<<y1<<endl;
        }else{
            cout<<x2-height<<endl<<y2<<endl<<x1-height<<endl<<y1<<endl;
        }
    }else if(height==0){
       if(width<0){
            width*=-1;
            cout<<x2<<endl<<y2-width<<endl<<x1<<endl<<y1-width<<endl;
        }else{
            cout<<x2<<endl<<y2-width<<endl<<x1<<endl<<y1-width<<endl;
        } 
    }else if(width>0&&height>0){
        cout<<x2-height<<endl<<y2+width<<endl<<x1-height<<endl<<y1+width<<endl;
    }else if(width>0&&height<0){
        height*=-1;
        cout<<x2+height<<endl<<y2+width<<endl<<x1+height<<endl<<y1+width<<endl;
    }else if(width<0&&height>0){
        width*=-1;
        cout<<x2-height<<endl<<y2-width<<endl<<x1-height<<endl<<y1-width<<endl;
    }else{
        height*=-1;
        width*=-1;
        cout<<x2+height<<endl<<y2-width<<endl<<x1+height<<endl<<y1-width<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
// by syu
package main

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

var in = NewScanner(os.Stdin, 0)

func main() {
	N, K := in.Int(), in.Int()
	x := in.ArrayInt(N)
	min := math.MaxInt64
	for i := 0; i < N-K+1; i++ {
		a, b := x[i], x[i+K-1]
		sum := Min(Abs(a), Abs(b)) + b - a
		if sum < min {
			min = sum
		}
	}
	Pln(min)
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) ArrayInt(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Min(arr ...int) (r int) {
	r = arr[0]
	for _, x := range arr {
		if x < r {
			r = x
		}
	}
	return
}
func Abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


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

using namespace std;

void solveA()
{
    int a, b;
    cin >> a >> b;
    int coins = 0, t = 2;
    while(t--){
        if (a >= b){
            coins += a;
            a--;
        }
        else{
            coins += b;
            b--;
        }
    }

    cout << coins << endl;
}

void solveB()
{
    int p, q, r;
    int ans = 0;
    cin >> p >> q >> r;
    int menor = min(p, q);
    menor = min(menor, r);
    ans = menor;
    if (menor == p){
        ans += min(q, r);
    }
    else
    if (menor == q){
        ans += min(r, p);
    }
    else{
        ans += min(p, q);
    }

    cout << ans << endl;
}

int main(int qtd, char* nome[])
{
    solveB();

    return 0;
}

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

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int MOD = 1'000'000'000 + 7;
const int INF = 1'000'000'000 + 5;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);

	int r; std::cin >> r;
	std::cout << (r * r) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;cin>>N;
  ll H[N];
  rep(i,N) cin>>H[i];
  
  for(int i=0;i<N-1;i++){
    if(H[i]>H[i+1]||H[i]>H[N-1]) H[i]--;
  }
  bool judge=true;
  
  for(int i=0;i<N-1;i++){
    if(H[i]>H[i+1]){
      judge=false;
      break;
    }
  }
  if(judge) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 1e5 + 5;
int n;
int arr[MAX];
ll pre[MAX];

int main() {
	scanf("%d", &n);
	fori(i, 0, n) {
		scanf("%d", arr + i);
	}
	sort(arr, arr + n);
	pre[0] = arr[0];
	fori(i, 1, n) {
		pre[i] = pre[i - 1] + arr[i];
	}

	int ans = 1;
	bool good = true;
	ford(i, n - 2, 0) {
		if(good && 2 * pre[i] >= arr[i + 1]) {
			ans++;
		}
		else {
			good = false;
		}
	}
	
	printf("%d\n", ans);

	return 0;
}



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

const int maxn=2e5+50;
const long long MOD=998244353;

struct Seg_Tree{
		long long val[maxn<<2];
		int lazy[maxn<<2];
		void init(){
			memset(val,0,sizeof(val));
			memset(lazy,0,sizeof(val));
		}
		inline void up(int rt){
			val[rt]=val[rt<<1]+val[rt<<1|1];
		}
		inline void down(int rt,int l,int r){
			int mid=l+r>>1;
			if(lazy[rt]){
				lazy[rt<<1]+=lazy[rt];
				lazy[rt<<1|1]+=lazy[rt];
				val[rt<<1]+=lazy[rt]*(mid-l+1);
				val[rt<<1|1]+=lazy[rt]*(r-mid);
				lazy[rt]=0;
			}
		}
		void build(int rt,int l,int r){
			if(l==r){
				val[rt]=0;
				return ;
			}
			int mid=l+r>>1;
			build(rt<<1,l,mid);
			build(rt<<1|1,mid+1,r);
			up(rt);
		}
		void update(int rt,int l,int r,int L,int R,long long del){
			if(l>R||r<L)return ;
			if(L<=l&&r<=R){
				val[rt]+=del*(r-l+1);
				lazy[rt]+=del;
				return ;
			}
			int mid=l+r>>1;
			down(rt,l,r);
			update(rt<<1,l,mid,L,R,del);
			update(rt<<1|1,mid+1,r,L,R,del);
			up(rt);
		}
		void add(int rt,int l,int r,int L,long long del){
			if(l==r){
				val[rt]+=del;
				return ;
			}
			down(rt,l,r);
			int mid=l+r>>1;
			if(L<=mid)add(rt<<1,l,mid,L,del);
			else add(rt<<1|1,mid+1,r,L,del);
			up(rt);
		}
		long long query_sum(int rt,int l,int r,int L,int R){
			if(L<=l&&r<=R)return val[rt];
			int mid=l+r>>1;
			down(rt,l,r);
			long long res=0;
			if(L<=mid)res+=query_sum(rt<<1,l,mid,L,R);
			if(R>mid)res+=query_sum(rt<<1|1,mid+1,r,L,R);
			return res;
		}
	}seg;

int L[maxn],R[maxn];

int main(){
#ifdef LOCAL
	freopen("in.txt","r",stdin);
#endif
	memset(L,0,sizeof L);
	memset(R,0,sizeof R);
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		scanf("%d%d",&L[i],&R[i]);
	}
	seg.build(1,1,n);
	seg.add(1,1,n,1,1);
	for(int i=2;i<=n;i++){
		long long now=0;
		for(int j=0;j<k;j++){
			int nowR=i-L[j];
			int nowL=max(1,i-R[j]);
			if(nowR<1)continue;
			now+=seg.query_sum(1,1,n,nowL,nowR);
			//printf("%d %d %lld %lld\n",nowL,nowR,seg.query_sum(1,1,n,nowL,nowR),now);
		}
		//printf("%d %lld\n",i,now);
		now=now%MOD;
		seg.add(1,1,n,i,now);
	}
	long long ans=seg.query_sum(1,1,n,n,n)%MOD;
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 9412
H, W = gets.split(' ').map(&:to_i)
cost = Array.new(10){}
10.times do |i|
	cost[i] = gets.split(' ').map(&:to_i)
end

to_1 = [-1] * 10
0.upto(9) do |i|
	queue = [[i, 0]]
	cl = [10000] * 10
	while !queue.empty?
		now, c = queue.shift
		cl[now] = [cl[now], c].min
		0.upto(9) do |j|
			if c + cost[now][j] < cl[j]
				queue.push([j, c + cost[now][j]])
			end
		end
	end
	to_1[i] = cl[1]
end

number = [0] * 10
H.times do
	a = gets.split(' ').map(&:to_i)
	0.upto(9) do |i|
		number[i] += a.count(i)
	end
end

puts (0..9).to_a.collect{|i| number[i] * to_1[i]}.inject(:+)

Measured memory_bytes: 3836
#include<iostream>
#include<string>

using namespace std;

int main(void){
  string buf;
  int cnt = 0;
  while(getline(cin,buf),buf!=""){
    bool ans = true;
    for(int i = 0 ; i < buf.size()/2 ; i ++){
      if(buf[i]!=buf[buf.size()-i-1]){
        ans = false;
        break;
      }
    }
    if(ans)cnt++;
  }
  cout<<cnt<<endl;
}

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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int cost1 = A * N;
    int cost2 = B;
    if (cost1 >= cost2) {
        cout << cost2 << endl;
    }
    else {
        cout << cost1 << endl;
    }
}

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

int main()
{

    int n;
    cin>>n;
    long long arr[n+1];
    for(int i=1;i<=n;i++) cin>>arr[i], arr[i]-=i;
    sort(arr+1,arr+n+1);
    long long temp=(n+1)/2;
    temp=arr[temp];
    long long ans=0;
    for(int i=1;i<=n;i++) ans+=abs(arr[i]-temp);
    cout<<ans<<endl;

    return 0;
}

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

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

  int64_t l = 0, r = 0, tmpl = 0, tmpr = 0, ans = 0;
  bool flag = true;

  if (s[0] == '<') {
    tmpl++;
  }
  else if (s[0] == '>') {
    flag = false;
    tmpr++;
  }

  for (int64_t i = 1; i < s.size(); i++) {
    if (flag) {
      if (s[i] == '<' && s[i] == s[i-1]) {
        tmpl++;
      }
      else if (s[i] == '>' && s[i] != s[i-1]) {
        l = tmpl;
        tmpl = 0;
        tmpr++;
      }
    }


    if (s[i] == '>' && s[i] == s[i-1]) {
      tmpr++;
    }
    else if (s[i] == '<' && s[i] != s[i-1]) {
      r = tmpr;
      tmpr = 0;
      tmpl++;

      ans += max(l, r) * (max(l, r) + 1) / 2;
      ans += min(l, r) * (min(l, r) - 1) / 2;
      l = 0;
      r = 0;
      flag = true;
    }
  }
  r = tmpr;
  ans += max(l, r) * (max(l, r) + 1) / 2;
  ans += min(l, r) * (min(l, r) - 1) / 2;
  ans += tmpl * (tmpl + 1) / 2;

  cout << ans << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int>prime;
  for(int i=2;i<=55555;i++){
    bool flag=true;
    for (int j=2;j*j<=i;j++){
      if(i%j==0){
        flag=false;
        break;
      }
    }
    if(flag==true){
      prime.push_back(i);
    }
  }
  vector<int>one;
  for(int i=0;i<prime.size();i++){
    if(prime[i]%10==1){
      one.push_back(prime[i]);
    }
  }
  for(int i=0;i<N;i++){
    if(i!=0){
      cout<<" ";
    }
    cout<<one[i];
  }
  cout<<endl;
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
//prototyoe
int main(void);

int main(void){
    char str[1001];
    char judge_str[1001];
    char order[8];
    int  q;
    int  count = 0;
    char PRINT[]   = "print";
    char REVERSE[] = "reverse";
    char REPLACE[] = "replace";

    scanf("%s", str);
    scanf("%d", &q);


    while (count < q) {
      int a, b;
      char change[1000];

      scanf("%s", order);

      if(strcmp(order, PRINT) == 0){
        scanf("%d %d", &a, &b);

        for (int i = a; i <= b; i++) {
          printf("%c", str[i]);
        }
        printf("\n");
      }
      else if(strcmp(order, REVERSE) == 0){
        scanf("%d %d", &a, &b);

        memcpy(judge_str, str, 1001);
        int j = b;
        for (int i = a; i <= b; i++) {
          judge_str[j] = str[i];
          j--;
        }
        memcpy(str, judge_str, 1001);
      }
      else if(strcmp(order, REPLACE) == 0){
        scanf("%d %d %s", &a, &b, change);

        memcpy(judge_str, str, 1001);
        int j = 0;
        for (int i = a; i <= b; i++) {
          judge_str[i] = change[j];
          j++;
        }
        memcpy(str, judge_str, 1001);
      }
      count++;
    }

    return 0;
}



Measured memory_bytes: 2056
import Data.Char
import Control.Monad

main = do
  [a,b,c,d] <- map digitToInt <$> getLine
  putStrLn $ head $ solve a b c d

solve a b c d = do
  let opss = [("+",(+)),("-",(-))]
  (ops1,op1) <- opss
  (ops2,op2) <- opss
  (ops3,op3) <- opss
  guard (a `op1` b `op2` c `op3` d == 7)
  return (show a ++ ops1 ++ show b ++ ops2 ++ show c ++ ops3 ++ show d ++ "=7")


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

int main(void){
  int N,M,l[100005],r[100005],lmax,rmin,i;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  M=atoi(p);
  
  for(i=0;i<M;i++){
    fgets(str,sizeof(str),stdin);
  	p=strtok(str," \n");
    l[i]=atoi(p);
    p=strtok(NULL," \n");
  	r[i]=atoi(p);
  }
  
  lmax=1,rmin=N;
  
  for(i=0;i<M;i++){
    if(l[i]>lmax){
      lmax=l[i];
    }
    if(r[i]<rmin){
      rmin=r[i];
    }
  }
  
  if(rmin<lmax){
    printf("0");
  }else{
    printf("%d\n",rmin-lmax+1);
  }
  
  return 0;
}

Measured memory_bytes: 896
function Main(input) {
    input = input.split("\n");
    var num = input[0].split(" ");
    var data = input[1].split(" ");
    num = Number(num);
    var ans = "";
    var index = 0;
    if(num === 1){
        ans = data[0];
    } else if(num % 2 === 0){
        index = num-1;
        while(1){
            ans+=data[index]+" ";
            if(index === 1){
                break;
            } else {
                index -= 2;
            }
        }
        
        index = 0;

        while(1){
            ans+=data[index];
            if(index === num-2){
                break;
            } else {
                ans+=" ";
                index += 2;
            }
        }        
    } else {
        index = num-1;
        while(1){
            ans+=data[index]+" ";
            if(index === 0){
                break;
            } else {
                index -= 2;
            }
        }
        
        index = 1;

        while(1){
            ans+=data[index];
            if(index === num-2){
                break;
            } else {
                ans+=" ";
                index += 2;
            }
        }     
    }
    
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 75052
#include<iostream>
#include<string>
using namespace std;
int main(){
  string text;
  int num=0,i;
  while(cin>>text){
    for(i=0;i<text.size();i++){
      if(text[i]!=text[text.size()-i-1])break;
    }
    if(i==text.size())num++;
  }  
  cout<<num<<endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

PII a[200010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    int b;
    cin >> b;
    a[i] = MP(b, i);
  }
  sort(a, a+n);

  ll res = 0;
  set<int> s;
  REP(i, n) {
    ll c, d;
    auto it = s.lower_bound(a[i].second);
    if(it == s.end()) d = n;
    else d = *it;
    if(s.empty() || it == s.begin()) c = -1;
    else if(it == s.end()) c = *(--s.end());
    else c = *(--it);

    //cout << c << " " << d << " " << a[i].second << endl;
    res += ((ll)a[i].second-c)*(d-a[i].second)*a[i].first;
    //cout << ((ll)a[i].second-c)*(d-a[i].second) << " " << res << endl;*/
    s.insert(a[i].second);
    /*cout << "set:";
    for(int j: s) cout << j << " ";
    cout << endl;*/
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

typedef struct{
	char name[11];
	int time;
}Process;

class ProcessQueue{
public:
	ProcessQueue(int size):
		m_size(size),
		m_head(0),
		m_tail(0),
		number(0)
	{
		m_process = new Process[m_size];
	};

	~ProcessQueue(){
		delete[] m_process;
	};

	void enQueue(Process process){
		//strcpy(m_process[m_tail].name,process.name);
		//m_process[m_tail].time = process.time;

		m_process[m_tail] = process;	//=??§??£??\????

		number++;

		if(m_tail < m_size-1){
			m_tail++;
		}else{	//?????°?????????
			m_tail = 0;
		}
	};

	Process deQueue(){
		number--;
		if(m_head < m_size-1){
			m_head++;
			return m_process[m_head-1];
		}else{	//?????°?????????
			m_head = 0;
			return m_process[m_size-1];
		}
	};

	int getNumber(){
		return number;
	}

private:
	int m_head;
	int m_tail;
	int m_size;
	int number;
	Process* m_process;

};

int main(){

	int n,q,totaltime=0;
	scanf("%d%d",&n,&q);

	ProcessQueue queue(n);

	Process tmp;
	for(int i = 0; i < n; i++){
		scanf("%s%d",&tmp.name,&tmp.time);
		queue.enQueue(tmp);
	}

	while(queue.getNumber() != 0){
		tmp = queue.deQueue();
		if(tmp.time - q > 0){
			totaltime += q;
			tmp.time -= q;
			queue.enQueue(tmp);
		}else{
			totaltime += tmp.time;
			printf("%s %d\n",tmp.name,totaltime);
		}
	}

}






  

 



Measured memory_bytes: 3580
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    s,t=input().split()
    a,b=map(int,input().split())
    u=input()

    if u==s:
        a-=1
    else:
        b-=1
    print(a,b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    auto start = clock();

    int a, b, c; cin >>  a >> b >> c;
    if (a + b + c >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }


    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

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

const int MAXN = 100010;
typedef long long LL;
LL pre[MAXN];
int n, m, A[MAXN];
void add(int l, int r, int v, int d) {
	if (l > r) return ;
	pre[l] += v; pre[l + 1] -= v; v += (r - l) * d;
	pre[r + 1] -= v; pre[r + 2] += v;
	pre[l + 1] += d; pre[r + 1] -= d;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> m >> n;
	for (int i = 1; i <= m; ++i) std::cin >> A[i];
	for (int i = 1; i < m; ++i) {
		int t = A[i + 1] - A[i];
		if (A[i] <= A[i + 1]) {
			add(A[i] + 1, A[i + 1], t, -1);
			add(1, A[i], t, 0);
			add(A[i + 1] + 1, n, t, 0);
		} else {
			t += n;
			add(A[i + 1] + 1, A[i], t, 0);
			add(A[i] + 1, n, t, -1);
			add(1, A[i + 1], t - (n - A[i]), -1);
		}
	}
	LL ans = std::numeric_limits<LL>::max();
	for (int i = 1; i <= n; ++i) pre[i] += pre[i - 1];
	for (int i = 1; i <= n; ++i) pre[i] += pre[i - 1];
	for (int i = 1; i <= n; ++i) ans = std::min(ans, pre[i]);
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1408
var
	n,sum,ans,id,i:Longint;
	a:array[0..99]of Longint;
begin
	read(n);
	for i:=0 to n-1 do begin
		read(a[i]);
		inc(sum,a[i]);
	end;
	ans:=1000000000;
	for i:=0 to n-1 do begin
		if ans>abs(sum-a[i]*n)then begin
			ans:=abs(sum-a[i]*n);
			id:=i;
		end;
	end;
	writeln(id);
end.

Measured memory_bytes: 128
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	s := getNextString(scanner)
	q := getNextInt(scanner)
	seg := newSegment(n)
	for i := 0; i < n; i++ {
		seg.update(i, 1<<uint(s[i]-'a'), seg.or)
	}
	for i := 0; i < q; i++ {
		switch getNextInt(scanner) {
		case 1:
			seg.update(getNextInt(scanner)-1, 1<<uint(getNextString(scanner)[0]-'a'), seg.or)
		case 2:
			fmt.Fprintln(writer, pcount(seg.query(getNextInt(scanner)-1, getNextInt(scanner), 0, seg.or)))
		}
	}
}
func pcount(x uint32) int {
	y := 0
	for x > 0 {
		if x&1 == 1 {
			y++
		}
		x >>= 1
	}
	return y
}

type segment [][]uint32

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]uint32, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]uint32, 1))
	return seg
}
func (seg segment) update(i int, v uint32, f func(x, y uint32) uint32) {
	seg[0][i] = v
	for h := 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i] = f(seg[h-1][i<<1], seg[h-1][i<<1+1])
		} else {
			seg[h][i] = seg[h-1][i<<1]
		}
	}
}
func (seg segment) query(l, r int, s uint32, f func(x, y uint32) uint32) uint32 {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			s = f(s, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			s = f(s, seg[h][r-1])
		}
		r >>= 1
	}
	return s
}
func (seg segment) or(x, y uint32) uint32 {
	return x | y
}


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

int main(){

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

    }
  
	cout << res << endl;  	
  
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];

	map<int, int> odd, even;
	rep(i, n) {
		if (i % 2 == 0) {
			odd[v[i]]++;
		}
		else {
			even[v[i]]++;
		}
	}

	int omax1 = 0;
	int onum1 = 0;
	for (auto o : odd) {
		if(omax1 < o.second) {
			omax1 = o.second;
			onum1 = o.first;
		}
	}

	int omax2 = 0;
	int onum2 = 0;
	for (auto o : odd) {
		if (omax2 < o.second && o.first != onum1) {
			omax2 = o.second;
			onum2 = o.first;
		}
	}

	int emax1 = 0;
	int enum1 = 0;
	for (auto e : even) {
		if (emax1 < e.second) {
			emax1 = e.second;
			enum1 = e.first;
		}
	}

	int emax2 = 0;
	int enum2 = 0;
	for (auto e : even) {
		if (emax2 < e.second && e.first != enum1) {
			emax2 = e.second;
			enum2 = e.first;
		}
	}

	if (onum1 == enum1) {
		cout << min(n - emax1 - omax2, n - emax2 - omax1) << endl;
	}
	else {
		cout << n - emax1 - omax1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 100100;
bool dp[maxn][2];
ll a[110], n, k;

int main() {
	cin>>n>>k;
	ll minval = INT_MAX;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		minval = min(minval, a[i]);
	}

	// First

	for(int i=0;i<minval;i++) {
		dp[i][0] = 0;
		dp[i][1] = 0;
	}

	for(int i=minval;i<=k;i++) {
		for(int j=1;j<=n;j++) {
			if(i-a[j]>=0) {
				if(!dp[i-a[j]][0]) {
					dp[i][1] = true;
				}

				if(!dp[i-a[j]][1]) {
					dp[i][0] = true;
				}
			}
		}
	}

	if(dp[k][0]) cout<<"First\n";
	else cout<<"Second\n";
}

Measured memory_bytes: 384
package main

import "fmt"

func min(a, b int64) int64 {
  if a < b { return a
  } else { return b }
}

func main() {
  // Scc を可能な限り作りたい
  // cc -> S に変換可能
  // S: N個, c: M個
  // まず Scc を可能な限り作る.
  // この操作のあと考えられる状況は以下のようなもの
  // 1. ちょうど全てを使い切る
  // 2. S が 0個以上, c が1個以下余る.
  // 3. c だけが余る.
  // 3 の場合のみ考える cccc で Scc が作れるので,
  // mod 4 を足せば良い
  var n, m, ans int64
  fmt.Scan(&n, &m)

  ans += min(n, m/2)
  t := min(n, m/2)
  n -= t
  m -= t*2

  if m > 3 {
    ans += m / 4
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int k;
  cin >> k;
  cin.ignore();
  string n="";
  getline(cin, n);

  int l = n.length();
  if(l<=k) cout << n << endl;
  else
    cout << n.substr(0,k) << "..." <<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  outl(a[k-1]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
#define For(i,n) for(int i=0;i<n;i++)

int main(){
    int t,i,n,j,k;
    cin>>n>>k;
    ll dig=0;
    ll res=0;
    while(n!=0){
        dig++;
        n/=k;
    }
    cout<<dig;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

score = 0

for val in b_list :
	score +=val
	
for val in range(n-1):
	if a_list[val+1] - a_list[val] == 1:
		score += c_list[a_list[val]-1]
	else:
		pass

print(score)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1e6+5;
int n,m;
vector<double>v(N);
bool check(int p)
{
	int sum=0;
    for(int i=0;i<n;++i)
    {
        sum+=ceil(v[i]/p)-1;
    }
    if(sum<=m) return true;
    return false;
}
int main()
{
    cin>>n>>m;
    double ma=0;
    for(int i=0;i<n;++i)
    {
        cin>>v[i];
        ma=max(ma,v[i]);
    }
    int left=0,right=ma;
    while(right-left>1)
    {
        int mid=(right+left)/2;
        if(check(mid))
        {
            right=mid;
        }
        else
        {
            left=mid;
        }
    }
    cout<<right<<endl;
	return 0;
}


Measured memory_bytes: 10992
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, s.size() - 1) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A, B, C, X;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &X);

    int count = 0;
    for (int a=0; a<=A; a++) {
        for (int b=0; b<=B; b++) {
            for (int c=0; c<=C; c++) {
                if (500*a+100*b+50*c == X) {
                    count++;
                }
            }
        }
    }
    printf("%d\n", count);

    return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	if(a>0) cout << "Positive" << endl;
	else if(a<=0&&b>=0) cout << "Zero" << endl;
	else cout << ( (abs(a)-abs(b)-1)%2?"Negative":"Positive" ) << endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;

int main(){
	int n , k ;
	cin >> n >> k ;
	vector<int> L,R ;
	L.push_back(0) ;
	R.push_back(0) ;
	for(int i=0;i<n;i++){
		int x ;
		cin >> x ;
		if ( x <= 0 ) L.push_back(x) ;
		else R.push_back(x) ;
	}
	sort(L.rbegin(),L.rend()) ;
	debug() << imie(L) ;
	debug() << imie(R) ;
	int a = (int)L.size() ;
	int b = (int)R.size() ;
	ll ans = 1e18 ;
	for(int i=0;i<=k;i++){
		if ( i < a ){
			int r = k - i ;
			if ( r < b ){
				if ( r == 0 ) {
					ans = min(ans,L[i]*-1LL);
				}
				else{
					ans = min(ans,L[i]*-1*2LL+R[r]);
				}
			}
		}
		debug() << imie(ans) ;
	}
	for(int i=0;i<=k;i++){
		if ( i < b ){
			int l = k - i ;
			if ( l < a ){
				if ( l == 0 ) {
					ans = min(ans,R[i]*1LL);
				}
				else{
					ans = min(ans,R[i]*1*2LL+L[l]*-1LL);
				}
			}
		}
		debug() << imie(ans) ;
	}

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


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
const int N = 1e5+5;
const int M = 5e5+5;
#define pi acos(-1)
#define INF 1e18
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
	int n,m,sum = 0;sdd(m,n);
	for(int i=1;i<=n;++i)
	{
		int x;sd(x);
		sum += x;
	}
	if(sum > m) printf("-1\n");
	else printf("%d\n",m-sum);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3824
/******************
*  Writer: Oh no  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;

vector<int> v;
int n,emp,x;
int d;

int abs(int y){
	return y>=0 ? y : -y;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>emp;
		v.push_back(emp);
	}
	sort(v.begin(),v.end());
	
	d=abs(x-v[0]);
	for(int i=1;i<n;i++){
		d=__gcd(abs(x-v[i]),d);
	}
	cout<<d<<endl;
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int a[5];
    rep(i,5)cin >> a[i];
    int idx=0,res=0;
    rep(i,5){
        if(a[i]%10!=0&&res<10-(a[i]%10)){
            res = 10-a[i]%10;
            idx = i;
        }
    }
    int ans=0;
    rep(i,5){
        if(i!=idx){
            ans+=a[i];
            while(ans%10!=0){
                ans++;
            }
        }
    }
    ans+=a[idx];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256