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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 1e4 + 5;
const int inf = 1e15;

string s;

int dp[N][105][4], d;

int solve(int pos, int m, int lim, int ok) {
    if(pos == lim) {
        if(ok == 2) return 0;
        if(m == 0)
            return 1;
        else
            return 0;
    }
    int ans = dp[pos][m][ok];
    //if(m == 0)
    //cout << pos << " " << m << " " << ok << " " << ans << "\n";
    if(ans != -1) return ans;
    if(m == 0)
        ans = 1;
    else
        ans = 0;
    int l = 0, r = 9;
    if(pos == 0) l = 1;
    for(int i = l; i <= r; i++) {
        int ck = ok;
        if(ok == 1 && i == s[pos] - '0') ck = 1;
        if(ok == 1 && i > s[pos] - '0') ck = 2;
        if(ok == 1 && i < s[pos] - '0') ck = 0;
        int lmao = solve(pos + 1, (m + i) % d, lim, ck);
        ans = (ans + lmao) % mod;
    }
    //cout << pos << " " << m << " " << ok << " " << ans << "\n";
    dp[pos][m][ok] = ans;
    return ans;
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> s >> d;
    for(int i = 0; i < s.length(); i++) {
        for(int j = 0; j < d; j++) {
            for(int k = 0; k <= 2; k++)
                dp[i][j][k] = -1;
        }
    }
    cout << (solve(0, 0, s.length(), 1) - 1 + mod) % mod;
}



Measured memory_bytes: 33920
N = int(input())
S = input()

E_count = [0] * (N+1)
for i in range(N):
    E_count[i+1] = E_count[i] + int(S[i] == "E")

W_count = [0] * (N+1)
for i in range(N):
    W_count[i+1] = W_count[i] + int(S[i] == "W")

ans = 10 ** 6
for i in range(1, N + 1):
    change_dir_cnt = (W_count[i - 1] - W_count[0]) + (E_count[-1] - E_count[i])
    ans = min(change_dir_cnt, ans)
print(ans)

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

using namespace std;

const int N = 200005;

vector <pair <int, int>> v;
set <pair <int, int>> S;

int a[N];

int main()
{
  int n;
  scanf("%d", &n);
  
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    v.push_back({a[i], i + 1});
  }
  
  sort(v.begin(), v.end());
  S.insert({n, 1});
  
  long long sum = 0;
  
  for (int i = 0; i < n; ++i) {
    int cur = v[i].second;
    pair <int, int> rl = *S.lower_bound({cur, -1});
    int r = rl.first, l = rl.second;
    
    sum += v[i].first * 1LL * (1 + (cur - l) + (r - cur) + (cur - l) * 1LL * (r - cur));
    S.erase(rl);
    if (cur - 1 >= l) {
      S.insert({cur - 1, l});
    }
    if (r >= cur + 1) {
      S.insert({r, cur + 1});
    }
  }
  
  printf("%lld\n", sum);
  return(0);
}

Measured memory_bytes: 4976
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    A,B = inputMap()
    
    if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
        print("Possible")
    else:
        print("Impossible")
        
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
using namespace std;
#define NUM 600

int main(){
	long n;
	while(cin >> n){
		long a = NUM/n;
		long b = 0;
		for(long i=1;i<a;i++) b += n*n*n*i*i;
		cout << b << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
int main(){
	cin>>s>>k;
	for(int i=0;i<(int)s.size();i++){
		if(s[i]=='a')continue;
		if(123-s[i]<=k){
			k-=123-s[i];
			s[i]='a';
		}
	}
	if(k){
		while(k&&s[s.size()-1]!='a'){
			if(s[s.size()-1]=='z')s[s.size()-1]='a';
			else s[s.size()-1]++;
			k--;
		}
		s[s.size()-1]+=k%26;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 512
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/13/20 21:03:09
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  struct Data {
    int v=0,w=0;
  };
  vector<Data> ds(n+1);
  for (int i = 0; i < n; i++) {
    int v,w; cin>>v>>w;
    ds[i+1] = {v,w};
  }
  int m = min(1<<9, n);
  vector<vector<int>> dp(m+1, vector<int>(1e5+1, -1));
  dp[0][0]= 0;
  for (int t = 1; t <= m; t++) {
    dp[t] = dp[t/2];
    for (int s = 1e5; s >= ds[t].w; s--) {
      if (dp[t/2][s-ds[t].w] == -1) continue;
      dp[t][s] = max(dp[t][s], dp[t/2][s-ds[t].w]+ds[t].v);
    }
  }
  for (int t = 1; t <= m; t++) {
    for (int s = 1; s <= 1e5; s++) {
      dp[t][s] = max(dp[t][s], dp[t][s-1]);
    }
  }

  auto query = [&](auto& query, int v, int l) -> int {
    if (v <= m) {
      return dp[v][l];
    }
    int res = query(query, v/2, l);
    if (l >= ds[v].w) {
      res = max(res, query(query, v/2, l-ds[v].w)+ds[v].v);
    }
    return res;
  };

  int q; cin>>q;
  for (int i = 0; i < q; i++) {
    int v,l; cin>>v>>l;
    auto ans = query(query, v,l);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 206672
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> x(N);
  REP(i, N) cin >> x[i];
  vector<ll> p(0), m(0);
  REP(i, N) {
    if (x[i] < 0) {
      m.push_back(abs(x[i]));
    } else {
      p.push_back(abs(x[i]));
    }
  }
  sort(m.begin(), m.end());
  sort(p.begin(), p.end());
  ll ans = 1e14;
  if (K <= p.size()) {
    ans = min(ans, abs(p[K - 1]));
  }
  if (K <= m.size()) {
    ans = min(ans, abs(m[K - 1]));
  }
  REP(i, p.size()) {
    ll tmp = abs(p[i]);
    if (m.size() <= K - 2 - i) continue;
    tmp += abs(abs(m[K - 2 - i]));
    tmp += min(abs(p[i]), abs(m[K - 2 - i]));
    ans = min(tmp, ans);
  }
  REP(i, m.size()) {
    ll tmp = abs(m[i]);
    if (p.size() <= K - 2 - i) continue;
    tmp += abs(abs(p[K - 2 - i]));
    tmp += min(abs(m[i]), abs(p[K - 2 - i]));
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5252
#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 repk(i,m,n) for(int i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    ll s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
}


Measured memory_bytes: 3628
<?php
$input = trim(fgets(STDIN));

List($n, $m) = explode(" ", $input);
$arr_a = [];
for ($i=0; $i<$n; $i++) {
  $input = trim(fgets(STDIN));
  $arr_a[] = explode(" ", $input);
}

$arr_b = [];
for ($i=0; $i<$m; $i++) {
  $input = trim(fgets(STDIN));
  $arr_b[] = $input;
}

$arr_c = array_fill(0, $n, 0);
for ($i=0; $i<$n; $i++) {
  for ($j=0; $j<$m; $j++) {
    $arr_c[$i] += ($arr_a[$i][$j] * $arr_b[$j]);
  }
}

for ($i=0; $i<$n; $i++) {
  echo "{$arr_c[$i]}" . PHP_EOL;
}

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

int main(){
  int N,A;
  cin>>N;
  A=N%10;
  switch(A){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon"<<endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon"<<endl;
      break;
    default:
      cout<<"bon"<<endl;
  }
}

Measured memory_bytes: 3620
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 test.cpp && cat test.txt | ./a.out

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>

using namespace std;

#define INF (1<<29)
#define SZ(X) ((int)(X).size())
#define PRINT(A) {for (auto it=A.begin(); it != A.end(); ++it) {cout << *it << ' ';} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define BIT_LENGTH(N) floor(log2(N)) + 1
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define RREP(I, N) for (int I = N-1; I >= 0 ; --I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RREPP(I, A, B) for (int I = A; I > (B); --I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
typedef vector<int> VI;
typedef map<int, int> MII;
typedef set<int> SI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;

void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }

const double PI = acos(-1);
const int MAX_SIZE = 2*1e5+1;
VI A_indexes[MAX_SIZE];

int main() {
    int N;
    _R(N);
    // cout << N << endl;
    VI C(N+1, 0);
    VI A;
    REP(i, N) {
        int a;
        _R(a);
        A.push_back(a);
        C[a] += 1;
    }
    VI B;
    REP(i, N) {
        int b;
        _R(b);
        B.push_back(b);
        C[b] += 1;
    }

    REP(i, N+1) {
        if (C[i] > N) {
            puts("No");
            return 0;
        }
    }

    reverse(B.begin(), B.end());
    int swap_index = 0;
    REP(i, N) {
        if (A[i] == B[i]) {
            while (A[i] == A[swap_index] || B[i] == B[swap_index]) {
                swap_index += 1;
            }
            swap(B[swap_index], B[i]);
            swap_index += 1;
        }
    }
    puts("Yes");
    PRINT(B);

    return 0;
}

Measured memory_bytes: 11096
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    int a, b;
    while(scanf("%d %d", &a, &b) != EOF) {
        char result[10];
        sprintf(result, "%d", a + b);
        printf("%lu\n", strlen(result));
    }
    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d,e=0,f,i,g[100000001],h=100000000000,j,m,n,x=0,k,y=1,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s1,s2,s3,s4,s5,s6;
    cin>>k>>s;
    if(s.size()<=k){
        cout<<s;
        return 0;
    }
    else{
        for(i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main()
{
    int i,j,l;
    bool flag=1;
    string s;
    cin >>l;
    cin >>s;
    if(l%2){ cout << "No"; return 0;}
    for(i=0,j=l/2;j<l;i++, j++) if(s[i]!=s[j]){ flag=0; break;}
    if(flag) cout << "Yes";
    else cout << "No";
}


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

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int mn=INT_MAX;
	for(int i=0;i<=n-k;i++){
		mn=min(mn,arr[i+k-1]-arr[i]);
	}
	cout<<mn;
}

Measured memory_bytes: 640
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdinLock};
#[allow(unused_imports)]
use std::io::prelude::*;
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;
#[allow(dead_code)]
const MODLL: i64 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    let n: usize = sc.read();
    let mut ans = 3;
    for _ in 0..n {
        let c: String = sc.read();
        let c: Vec<char> = c.chars().collect();
        if c[0] == 'Y' {
            ans += 1;
        }
    }
    if min(ans, 4) == 4 {
        println!("Four");
    } else {
        println!("Three");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int N;
string s;

void pre(){
   unordered_set<string> S;
  for (int i = 0; i < N; i++) {
    cin >> s;
    S.insert(s);
  }

  cout << S.size() << "\n";
  
}

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

  cin >> N;
 
  pre();
  
}


Measured memory_bytes: 17756
alphabet = {
  'a': 0,
  'b': 0,
  'c': 0,
  'd': 0,
  'e': 0,
  'f': 0,
  'g': 0,
  'h': 0,
  'i': 0,
  'j': 0,
  'k': 0,
  'l': 0,
  'm': 0,
  'n': 0,
  'o': 0,
  'p': 0,
  'q': 0,
  'r': 0,
  's': 0,
  't': 0,
  'u': 0,
  'v': 0,
  'w': 0,
  'x': 0,
  'y': 0,
  'z': 0,
}

import sys

def main():
  sentence = ''

  for line in sys.stdin:
    for l in line:
      if l.lower() in alphabet:
        alphabet[l.lower()] += 1

  for key, value in alphabet.items():
    print('{} : {}'.format(key, value))

if __name__ == '__main__':
  main()


Measured memory_bytes: 5572
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	string s;
	// AKIHABARA

	set<string> v;
	rep(i,2) rep(j,2) rep(k,2) rep(l,2){
		string res;
		if(i) res += 'A';
		res += "KIH";
		if(j) res += 'A';
		res += "B";
		if(k) res += 'A';
		res += "R";
		if(l) res += 'A';
		v.emplace(res);
	}

	cin >> s;
	cout << (v.count(s) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
'use strict'
function main(input) {
  input = input.trim()
  for (let i = 1; i < input.length; i++) {
    if (input[i]===input[i-1]) return console.log('Bad')
  }
  console.log('Good')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
use std::cmp;
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let _: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);

    let mut max_d = 0;
    let mut map: BTreeMap<i64, i64> = BTreeMap::new();
    for &a in a.iter() {
        *map.entry(a).or_insert(0) += 1;
        if let Some(min) = map.keys().next().cloned() {
            let d = a - min;
            if d > max_d {
                max_d = d;
            }
        }
    }

    let mut max_count = BTreeMap::new();
    let mut min_count = BTreeMap::new();

    let mut map: BTreeMap<i64, i64> = BTreeMap::new();
    for &a in a.iter() {
        *map.entry(a).or_insert(0) += 1;
        if let Some(min) = map.keys().next().cloned() {
            let d = a - min;
            if d == max_d {
                *max_count.entry(a).or_insert(0) += 1;
            }
        }
    }
    let mut map: BTreeMap<i64, i64> = BTreeMap::new();
    for &a in a.iter().rev() {
        *map.entry(a).or_insert(0) += 1;
        if let Some(max) = map.keys().rev().next().cloned() {
            let d = max - a;
            if d == max_d {
                *min_count.entry(a).or_insert(0) += 1;
            }
        }
    }

    let mut sum = 0;
    for (&max, &max_count) in max_count.iter() {
        if let Some(&min_count) = min_count.get(&(max - max_d)) {
            sum += cmp::min(max_count, min_count);
        }
    }

    println!("{}", sum);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 22780
#include <iostream>
//#include <string>
//#include <cmath>
//#include <cstdlib>
#include <algorithm>
//#include <functional>
//#include <array>
#include <vector>

using ssl = signed long long;

int N, M;
ssl v[1000][3] = {0};

std::vector<ssl> ppp;
std::vector<ssl> ppm;
std::vector<ssl> pmp;
std::vector<ssl> pmm;
std::vector<ssl> mpp;
std::vector<ssl> mpm;
std::vector<ssl> mmp;
std::vector<ssl> mmm;

int main(void) {
  std::cin >> N;
  std::cin >> M;

  ssl tmp;
  ppp.reserve(N);
  ppm.reserve(N);
  pmp.reserve(N);
  pmm.reserve(N);
  mpp.reserve(N);
  mpm.reserve(N);
  mmp.reserve(N);
  mmm.reserve(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> v[i][0];
    std::cin >> v[i][1];
    std::cin >> v[i][2];

    ppp.push_back(+v[i][0] +v[i][1] +v[i][2] +30000000000);
    ppm.push_back(+v[i][0] +v[i][1] -v[i][2] +30000000000);
    pmp.push_back(+v[i][0] -v[i][1] +v[i][2] +30000000000);
    pmm.push_back(+v[i][0] -v[i][1] -v[i][2] +30000000000);
    mpp.push_back(-v[i][0] +v[i][1] +v[i][2] +30000000000);
    mpm.push_back(-v[i][0] +v[i][1] -v[i][2] +30000000000);
    mmp.push_back(-v[i][0] -v[i][1] +v[i][2] +30000000000);
    mmm.push_back(-v[i][0] -v[i][1] -v[i][2] +30000000000);
  }

  std::sort(ppp.begin(), ppp.end(), std::greater<ssl>());
  std::sort(ppm.begin(), ppm.end(), std::greater<ssl>());
  std::sort(pmp.begin(), pmp.end(), std::greater<ssl>());
  std::sort(pmm.begin(), pmm.end(), std::greater<ssl>());
  std::sort(mpp.begin(), mpp.end(), std::greater<ssl>());
  std::sort(mpm.begin(), mpm.end(), std::greater<ssl>());
  std::sort(mmp.begin(), mmp.end(), std::greater<ssl>());
  std::sort(mmm.begin(), mmm.end(), std::greater<ssl>());

  for (size_t i = 0; i < N; ++i) {
    ppp[i] -= 30000000000;
    ppm[i] -= 30000000000;
    pmp[i] -= 30000000000;
    pmm[i] -= 30000000000;
    mpp[i] -= 30000000000;
    mpm[i] -= 30000000000;
    mmp[i] -= 30000000000;
    mmm[i] -= 30000000000;
  }

  ssl max = 0;
  std::vector<ssl>* vecs[8] = {&ppp, &ppm, &pmp, &pmm, &mpp, &mpm, &mmp, &mmm};
  for (size_t i = 0; i < 8; ++i) {
    ssl value = 0;
    for (size_t j = 0; j < M; ++j) {
      value += (*vecs[i])[j];
    }
    if (max < value) {
      max = value;
    }
  }

#if 0
  std::sort(v.begin(), v.end(), std::greater<int>());

  std::for_each(v.begin(), v.end(), [](int x) {
      std::cout << x << std::endl;
  });
#endif

  std::cout << max << std::endl;

  return 0;
}

Measured memory_bytes: 384
//
// Created by yamunaku on 2019/08/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n, q;
    cin >> n >> q;
    vl a;
    a.reserve(q);
    int sz = 1;
    a.push_back(n);
    rep(i, q){
        ll x;
        cin >> x;
        while(sz > 0){
            if(a[sz - 1] < x) break;
            a.pop_back();
            sz--;
        }
        a.push_back(x);
        sz++;
    }
    vector<ll> dp(sz, 0);
    vector<pair<int, int>> event(sz);
    vector<vector<pair<int, ll>>> edge(sz);
    event[0] = {a[0], 0};
    repl(i, 1, sz){
        ll len = a[i];
        while(len >= a[0]){
            int idx = upper_bound(a.begin(), a.begin()+i, len) - a.begin() - 1;
            edge[idx].push_back({i, len / a[idx]});
            len %= a[idx];
        }
        event[i] = {len, i};
    }
    ll ans = 0;
    dp[sz - 1] = 1;
    per(i, sz){
        for(auto p:edge[i]){
            dp[i] += dp[p.first] * p.second;
        }
        ans += dp[i];
    }
    sort(all(event));
    int j = 0;
    rep(i, n){
        for(; j < sz; j++){
            if(event[j].first > i) break;
            ans -= dp[event[j].second];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 20568
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int k = sc.nextInt();
  if(k > (b-a)/2){
    for(int i = a;i <= b;i++){
    System.out.println(i);
  }
  }
  else{
  for(int i = a;i < a+k;i++){
    System.out.println(i);
  }
  for(int i = b-k+1;i <= b;i++){
    System.out.println(i);
  }
  }
}}

Measured memory_bytes: 21716
n = gets.to_i

POSSIBLES = [111, 222, 333, 444, 555, 666, 777, 888, 999].freeze

diff = 999 - n
ans = nil

POSSIBLES.each do |p|
  d = p - n

  if d >= 0 && d <= diff
    ans = p
    diff = d
  end
end

puts ans


Measured memory_bytes: 1788
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = 1<<18;

int n, m, dp[N];
VII prz[N];

class treePM
{
  public:
    int w[2*N], W[2*N];

    void init()
    {
      for (int i = 0; i < 2*N; ++i)
        w[i] = W[i] = 0;
    }

    void insert(int a, int b, int v)
    {
      _insert(a, b, v, 0, N-1, 1);
    }

    int query(int a, int b)
    {
      return _query(a, b, 0, N-1, 1, 0);
    }

    void _insert(int a, int b, int v, int beg, int end, int k)
    {
      if (b < beg || a > end)
        return;
      if (a <= beg && end <= b) {
        w[k] += v;
        W[k] += v;
        return;
      }
      _insert(a, b, v, beg, (beg+end)/2, 2*k);
      _insert(a, b, v, (beg+end)/2+1, end, 2*k+1);
      W[k] = w[k] + max(W[2*k], W[2*k+1]);
    }

    int _query(int a, int b, int beg, int end, int k, int war)
    {
      if (b < beg || a > end)
        return 0;
      if (a <= beg && end <= b)
        return war + W[k];
      return max(_query(a, b, beg, (beg+end)/2, 2*k, war+w[k]), _query(a, b, (beg+end)/2+1, end, 2*k+1, war+w[k]));
    }
} drz;

signed main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int l, r, a;
    cin >> l >> r >> a;
    prz[r].PB({l, a});
  }
  for (int i = 1; i <= n; ++i) {
    dp[i] = drz.query(0, i-1);
    drz.insert(i, i, dp[i]);
    for (const auto& el: prz[i])
      drz.insert(el.ST, i, el.ND);
  }
  cout<<drz.query(1, n)<<"\n";
}

Measured memory_bytes: 21376
n,m=map(int,input().split())
AB=[]
CD=[]
for i in range(n):
  AB.append(list(map(int,input().split())))
for i in range(m):
  CD.append(list(map(int,input().split())))

for a,b in AB:
  dis=[abs(a-c)+abs(b-d) for c,d in CD]
  print(dis.index(min(dis))+1)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    ll ans = 0;
    for(ll i=1; i<=N-1; i++) ans += i;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
//#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define INF (long long)102000000000000
#define NAX (int)1e2+2
typedef long long ll;
typedef unsigned long long ull;
//#define NAX (int)1e5+2
class solution{
public:
	void solve(){
		int n;
		string s;
		cin>>n;
		cin>>s;
		int ans =0;
		for(int i=0;i<n-2;i++){
			if(s[i] == 'A'){
				if(s[i+1] == 'B'){
					if(s[i+2] == 'C'){
						ans++;
					}
				}
			}
		}
		cout<<ans;
	}
};
	  
int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

// 素因数分解
// n <= 10^14
// 前処理 O(sqrt(n) loglog sqrt(n))
// クエリ O(sqrt(n)/ln(sqrt(n)) + lg(n)) 素数定理と素因数の個数より
struct PrimeFactorization {
	int max_n;
	vector<int> is_prime;
	vector<int> primes;
	// 前処理
	PrimeFactorization(int max_n) :max_n(max_n) {
		int s = sqrt(max_n);
		is_prime.assign(s + 1, true);
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i*i <= s; i++) {
			if (!is_prime[i])continue;
			for (int j = i + i; j <= s; j += i)
				is_prime[j] = false;
		}
		for (int i = 0; i <= s; i++)
			if (is_prime[i])
				primes.emplace_back(i);
	}
	// 昇順で素因数を返す
	// √n以下の素数に対して割り切れるか調べる
	vector<int> factorize(int n) {
		assert(n >= 2);
		vector<int> factors;
		for (auto &p : primes) {
			while (n%p == 0) {
				n /= p;
				factors.emplace_back(p);
			}
		}
		if (n != 1)factors.emplace_back(n);
		return factors;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	PrimeFactorization pf(N);
	cout << N << ":";
	auto r = pf.factorize(N);
	for (auto x : r)cout << " " << x;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3304
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  int n;cin>>n;
  VL x(n),y(n),h(n);
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>h[i];
  }
  ll now=0;
  ll past=0;


  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      ll high=0;
      for(int r=0;r<n;r++){
        if(h[r]!=0){
          high=h[r]+abs(i-x[r])+abs(j-y[r]);
          break;
        }
      }
      int key=0;
      ll base=0;
      for(int r=0;r<n;r++){
        if(h[r]==max(high-abs(i-x[r])-abs(j-y[r]),base)){
          continue;
        }else{
          key=1;break;
        }
      }
      if(key==0){cout<<i<<" "<<j<<" "<<high<<endl;}
    }
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

int main(){
    string S;
    cin>>S;
    if(S=="AAA" || S=="BBB"){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え
    #B - GCD Sequence
    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if N==3:
        print("2 5 63")
        exit()
    if N==4:
        print("2 5 20 63")
        exit()
    N3=min(5000,N//2*2-2) 
    N2=N-N3
    if N2==0 or N2%3==1:
        N3-=2
        N2+=2
    ans=[3+i*6 for i in range(N3)]+[2*j+2 for j in range(N2)]
    print(*ans)
    #print(sum(ans),max(ans))
if __name__ == "__main__":
    main()

Measured memory_bytes: 41840
n = int(input())
ps = list(map(int,input().split()))

count = 0
for i in range(1,n-1):
	d = sorted(ps[i-1:i+1+1])
	#print(d,d[0],d[1],d[2])
	if d[0] < d[1] and d[1] < d[2] and ps[i] == d[1]:
		count += 1
		
print(count)

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

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

  int N;
  cin >> N;
  vector<int> s(N);
  int sum = 0;
  bool ten = true;
  for(int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
    if(ten && s[i] % 10 != 0) {
      ten = false;
    }
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < N; i++) {
    if(ten) {
      cout << 0 << endl;
      break;
    }
    if(sum % 10 != 0) {
      cout << sum << endl;
      break;
    }
    else if((sum - s[i]) % 10 != 0) {
      cout << sum - s[i] << endl;
      break;
    }
    if(i == N - 1) {
      cout << 0 << endl;
      break;
    }
  }



  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

struct edge{
	llint to;
	double cost;
	edge(){}
	edge(llint a, double b){
		to = a, cost = b;
	}
};

typedef pair<double, llint> P;

llint n, m, p, s, t;
vector<edge> G[30005];
double dist[30005];
llint x[15];
llint N, B;

void add_edge(llint u, llint v, double w)
{
	for(int j = 0; j < B; j++){
		llint U = u+j*n;
		for(int k = 0; k < p; k++){
			if(j & (1<<k)) continue;
			llint V = v+(j|(1<<k))*n;
			G[U].push_back(edge(V, w/x[k]));
		}
	}
}

void dijkstra(vector<edge> G[], llint S, double dist[])
{
	for(int i = 1; i <= N; i++) dist[i] = inf;
	dist[S] = 0;
	
	priority_queue<P, vector<P>, greater<P> > Q;
	Q.push(P(0, S));
	
	llint v; double d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push(P(dist[G[v][i].to], G[v][i].to));
			}
		}
	}
}

int main(void)
{
	while(1){
		cin >> p >> n >> m >> s >> t;
		if(!p && !n && !m && !s && !t) break;
		
		for(int i = 0; i < p; i++) cin >> x[i];
		llint u, v; double w;
		
		B = 1<<p, N = B*n+n;
		
		for(int i = 1; i <= N; i++) G[i].clear();
		for(int i = 1; i <= m; i++){
			cin >> u >> v >> w;
			add_edge(u, v, w);
			add_edge(v, u, w);
		}
		
		dijkstra(G, s, dist);
		
		double ans = inf;
		for(int i = 0; i < B; i++) ans = min(ans, dist[i*n+t]);
		if(ans > inf/2) cout << "Impossible" << endl;
		else printf("%.11f\n", ans);
	}
	
	return 0;
}


Measured memory_bytes: 25820
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 100000

int main(){
    int N;
    vector<int> P;

    cin >> N;

    for (int i = 0; i < N; i++){
        int temp;
        cin >> temp;
        P.push_back(temp);
    }
    sort(P.begin(), P.end());
    int size = P.size();
    P[size - 1] = P[size - 1] / 2;

    int sum = accumulate(P.begin(), P.end(), 0);

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;
    
    int ans = *max_element(a.begin(), a.end());
    ans -= *min_element(a.begin(), a.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())

if 400 <=n <=599:
    print(8)
elif 600 <=n <= 799:
    print(7)
elif 800 <=n <=999:
    print(6)
elif 1000 <=n<=1199:
    print(5)
elif 1200 <=n <=1399:
    print(4)
elif 1400<= n <=1599:
    print(3)
elif 1600 <=n <=1799:
    print(2)
elif 1800<= n <=1999:
    print(1) 

Measured memory_bytes: 9184
<?php

[$N, $K] = fscanf(STDIN, "%d%d");

$A = explode(" ", fgets(STDIN));

for ($i = $K; $i < $N; $i++) {
    if (trim($A[$i]) > trim($A[$i - $K])) {
        echo 'Yes';
    } else {
        echo 'No';
    }
    if ($i < $N - 1) {
        echo "\n";
    }
}

?>

Measured memory_bytes: 32232
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

const int MAXN = 100005;
int a[MAXN];

int main() {
    GI(n);

    FORN(i, n) GI(a[i]);

    int i = 0, res = 0;

    while (i < n) {
        int start = a[i]; res++; //DEBUG(i);

        int j = i+1; int dir = 0;

        while (j < n) {
            if (a[j] == a[j-1]) {
                j++;
            }
            else if (a[j] > a[j-1]) {
                if (dir == 0) {
                    dir = 1;
                    j++;
                }
                else if (dir == -1) {
                    break;
                }
                else {
                    j++;
                }
            }
            else {
                if (dir == 0) {
                    dir = -1;
                    j++;
                }
                else if (dir == 1) {
                    break;
                }
                else {
                    j++;
                }
            }
        }

        i = j;
    }

    printf("%d\n", res);
    
    return 0;
}


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

int main() {
  // 入力部(s1,s2,s3)
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << (char)(s1.at(0)-32) << (char)(s2.at(0)-32) << (char)(s3.at(0)-32) << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>

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

using namespace std;

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

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

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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll L[32] = {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};

    ll K;
    cin >> K;
    cout << L[K - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int getint(void)
{
    int a;
    scanf("%d",&a);
    return a;
}
int main(void)
{
    int ans=1,n=getint(),k=getint();
    for(int i=1;i<=n;i++) ans+=min(ans,k);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
mxabs=-1
pos=0
for i in range(n):
    if abs(lis[i])>mxabs:
        pos=i
        mxabs=abs(lis[i])
answers=[]
if lis[pos]>0:
    x=lis[pos]
    for i in range(n):
        if lis[i]<x:
            lis[i]+=x
            answers.append((pos+1,i+1))
    for i in range(n-1):
        if lis[i+1]<lis[i]:
            lis[i+1]+=lis[i]
            answers.append((i+1,i+2))
elif lis[pos]<0:
    x=lis[pos]
    for i in range(n):
        if lis[i]>x:
            lis[i]+=x
            answers.append((pos+1,i+1))
    for i in range(n-1):
        j=n-i-1
        if lis[j-1]>lis[j]:
            lis[j-1]+=lis[j]
            answers.append((j+1,j))
print(len(answers))
for i in range(len(answers)):
    print(*answers[i])
#print(lis)
    
    


Measured memory_bytes: 66476
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include <cmath>
#include <iomanip>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;
int k;

// ｐは何回２乗したらK以上になるか？
// k/p <= 2^?
// log2(k/p) <= ?
// Σ_p=1~k-1 2^(-?)

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

  scan(n);
  scan(k);

  ld pow2 = 0.5;
  ld ans = (ld)(n-k+1)/n;
  if(ans<0){
    ans=0;
  }
  REP( i, ceil(log2(k)) ){
    if(ceil(k*pow2)<=n){
      ld upper = ceil(k*pow2*2)-1;
      ld botto = ceil(k*pow2);
      ld num;
      if(upper>n && botto <=n)  num = n-botto+1;
      else  num = upper-botto+1;
      if(num>0.1) ans += num *pow2 /n;
      //cout << upper << "\t" << botto << "\t" << num*pow2/n << endl;
      if(botto>0.99 && botto<1.01) break;
    }
  //  cout << pow2 << endl;
    pow2 /= 2;
  }

  cout << fixed;
  cout << setprecision(12);
  cout << ans << endl;

  return 0;
}


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

int main(){

  long long int N, tmp;
  std::vector<long long int> a;

  scanf("%lld", &N);
  for(long long int i = 0; i < N; i++){
    scanf("%lld", &tmp);
    a.push_back(tmp);
  }

  long long int ans;
  tmp = 1;
  for(long long int i = 0; i < N; i++){
    if(a[i] == tmp){
      tmp++;
    }
  }
  if(tmp == 1){
    ans = -1;
  }
  else{
    ans = N-tmp+1;
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << ans << std::endl;

  return 0;
  
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long comb(long long,long long);

int main (){

        long long N;
        long long x,y;
        cin >> N;

        long long *ptr = new long long[N+1];

        for (long long i = 1; i <= N; i++) {
                cin >> ptr[i];
        }

        if (N == 2) {
                if ( ptr[1] < ptr[2] ) {
                        int temp = ptr[1];
                        ptr[1] = ptr[2];
                        ptr[2] = temp;
                }

                cout << ptr[1] <<" "<<ptr[2] <<endl;

        }else{
                sort( ptr+1, ptr+N+1 );

                x = ptr[N];
                int sub = (x+1)/2;

                for (long long i = 1; i <= N; i++) {
                        if( sub >= abs(ptr[i] - (x+1)/2)  ) {
                                sub = abs(ptr[i] - (x+1)/2);
                                y = ptr[i];
                        }
                }
                cout << x <<" "<<y <<endl;

        }

}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int i,A[100],N,v,j,p;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	for(p=0;p<N-1;p++) printf("%d ",A[p]);//判定のために初期配列を出力
	printf("%d\n",A[N-1]);
	
	for(i=1;i<N;i++){
		v=A[i];//初期値
		j=i-1;
		while(j>=0&&A[j]>v){//小さい数値を前にもっていく
			A[j+1]=A[j];
			j--;
		}
		A[j+1] = v;//入れ替える
		for(p=0;p<N-1;p++) printf("%d ",A[p]);//ソート後の配列出力
		printf("%d\n",A[N-1]);
	}
	
	return 0;	
}


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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

struct bit {
    vector<ll> v;
    bit(int n) : v(n + 1) {}
    ll sum(int i) {
        ll res = 0;
        for (; i > 0; i -= i & -i) res += v[i];
        return res;
    }
    void add(int i, ll x) {
        for (i++; i < v.size(); i += i & -i) v[i] += x;
    }
};

int main() {
    int N; cin >> N;
    vector<vector<int>> a(100000);
    rep(i, N) {
        int x; scanf("%d", &x);
        a[x - 1].pb(i);
    }
    bit b(N);
    ll ans = 0;
    for (int x = 99999; x >= 0; x--) {
        for (int i: a[x]) {
            int l = b.sum(i);
            int r = b.sum(N) - b.sum(i);
            ans += min(l, r);
        }
        for (int i: a[x]) b.add(i, 1);
    }
    cout << ans << endl;
}



Measured memory_bytes: 9192
#include <cstdio>
#include <utility>
using namespace std;

// #define LOCAL

#ifndef LOCAL
#define MAX 101000
#endif

#ifdef LOCAL
#define MAX 100
#endif

#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define NIL -1

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

int main() {
	int n; ll x; scanf("%d %lld", &n, &x);
	ll X[MAX]; 
	FOR(i, 0, n) { ll tmp; scanf("%lld", &tmp); X[i] = tmp - x > 0 ? tmp - x : x - tmp; }
	   
#ifdef LOCAL
	FOR(i, 0, n) printf(" %d", X[i]);
	printf("\n");
#endif
	
	ll k;
	if (n == 1) { k = X[0]; }
	else {
		k = gcd(X[0], X[1]);
		FOR(i, 2, n){ k = gcd(k, X[i]); }
	}

	printf("%lld\n", k);

	return 0;
}

Measured memory_bytes: 896