akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int main(void)
{

	int n, y;
	cin >> n >> y;

	y /= 1000;

	//10000円の枚数
	for (int i = 0; i <= n; i++) {
		//5000円の枚数
		for (int j = 0; i + j <= n; j++) {
			int t = i * 10 + j * 5;
			if (n == i + j + (y - t)) {
				cout << i << " " << j << " " << y - t << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}



Measured memory_bytes: 256
# import math
n = int(input())
s = list(map(int,input().split()))

def gcd(a,b):
    if (a==0) or (b==0):
        return max(a,b) 
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

lm = [0] *(n+1)
rm = [0] *(n+1)
for i in range(1,n):
    lm[i+1] = gcd(lm[i],s[i-1])
for i in range(n-1,0,-1):
    rm[i] = gcd(rm[i+1],s[i])

ans = float('-inf')
for i in range(1,n+1):
    ans = max(ans,gcd(lm[i],rm[i]))
print(ans)

Measured memory_bytes: 14432
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <tuple>
#include <map>

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1e9;

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

int main() {
    int n,m; cin >> n >> m;
    vector<int> a(m+1),b(m+1);
    vector<vector<int>> c(m+1,vector<int> (15));
    for (int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
    vector<int> dp(5000,inf);
    dp[0] = 0;
    for (int item = 1; item <= m; item++) {
        int now = 0;
        for (int j = 1; j <= b[item]; j++) {
            now += (1 << (c[item][j] - 1));
        }
        for (int bits = 0; bits < (1 << n); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if (dp[(1 << n) - 1] == inf) dp[(1 << n) - 1] = -1;
    cout << dp[(1 << n) - 1] << "\n";
}

Measured memory_bytes: 384
#![allow(unused)]

use std::cmp::{min, max};
use std::io::Write;

macro_rules! dbg {
    ($($a:expr),*) => {
        writeln!(
            std::io::stderr(),
            concat!($(stringify!($a), " = {:?}, "),*),
            $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

const M: i64 = 1000000007;

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let k: usize = sc.get();
    let xs: Vec<usize> = (0..n).map(|_| sc.get()).collect();

    //
    // dp[p][c] = 最初の p + 1 人で飴ちょうど c 個を分ける配り方の数
    //
    let mut dp: Vec<i64> = vec![0; k + 1];
    dp[0] = 1;

    for p in 0..n {
        dp = (0..(k + 1)).scan(0, |a, c| {
            let dec = if c > xs[p] { dp[c - xs[p] - 1] } else { 0 };
            *a = (*a + dp[c] - dec + M) % M;
            Some(*a)
        }).collect();
    }

    println!("{}", dp[k]);
}

Measured memory_bytes: 4052
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

ll n, k;

int main() {
    fastio();

    cin >> n >> k;

    ll ans = 0;
    for (ll b = 1; b <= n; b++) {
        ll p = n / b;
        ll r = n % b;
        //cout << b << " " << p << " " << r << endl;
        //cout << p * max(0LL, b - k) << " " << max(0LL, r - k) << endl;
        ans += p * max(0LL, b - k) + max(0LL, r - k + 1);
    }

    if (k == 0) ans -= n;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

typedef std::pair<int,int> P;
//親,深さ

P node[10001];

void init(){
	for(int i = 0; i < 10001; i++){
		node[i].first = i;
		node[i].second = 0;
	}
}

int find(int x){
	if(node[x].first == x)return x;
	else return node[x].first = find(node[x].first);
}

void unite(int x, int y){
	x = find(x), y = find(y);
	if(x == y)return;
	
	if(node[x].second < node[y].second)node[x].first = y;
	else {
		node[y].first = x;
		if(node[x].second == node[y].second)node[x].second++;
	}
}

int main(){
	init();

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

	for(int i = 0; i < q; i++){
		int a, b, c;
		ch = scanf("%d %d %d", &a, &b, &c);
		
		if(!a)unite(b, c);
		else printf("%d\n", (find(b) == find(c) ? 1 : 0));
	}

	return 0;
}

Measured memory_bytes: 1268
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
	ll n,m,d;
	cin>>n>>m>>d;
	double ans;
	if(n==1)
		ans=m-1;
	else
	{
		ans=(m-1)*1.0/n;
		if(d!=0)
			ans=ans*(2.0/n)*(n-d);	
	}
	printf("%.10lf",ans);
}

Measured memory_bytes: 384
N = int(input())
ABC = []

for n in range(N):
  ABC.append(list(map(int, input().split())))

import numpy as np
ABC = np.array(ABC)

## 「日付」、「選択した行動」ごとの幸福度の最大値を格納するarray
hp=np.zeros((N,3),dtype=int)
hp[0] = ABC[0]

for n in range(1,N):# 日単位でのループ
  for c in range(3): # 選択肢ごとのループ
    ## n日にcを選択した場合の幸福度。つまり前日はc以外を選択している
    if c == 0:
      hp[n][0] = max(hp[n-1][1],hp[n-1][2]) + ABC[n][0]
    elif c == 1:
      hp[n][1] = max(hp[n-1][0],hp[n-1][2]) + ABC[n][1]
    elif c == 2:
      hp[n][2] = max(hp[n-1][0],hp[n-1][1]) + ABC[n][2]


ans = max(hp[-1])
print(ans)

Measured memory_bytes: 42120
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ans = 0
nums =[a, b, c, d, e]
tmp = [i % 10 for i in nums]
if a % 10 == b % 10 == c % 10 == d % 10 == e % 10 == 0:
    print(a + b + c + d + e)
else:
    mm = [10 - i % 10 for i in nums]
    mm = [x for x in mm if x != 10]
    for i in range(5):
        if nums[i] % 10 == 0:
            ans += nums[i]
        else:
            ans += nums[i] + (10 - nums[i] % 10)
    print(ans - max(mm))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> AB(N);
    rep(i, N)
    {
        int a, b;
        cin >> a >> b;
        AB[i] = mp(a, b);
    }
    sort(AB.begin(), AB.end());
    ll cnt = 0;
    ll ans = 0;
    int idx = 0;
    while (cnt < M)
    {
        cnt++;
        AB[idx].second--;
        ans += AB[idx].first;
        if (AB[idx].second == 0)
        {
            idx++;
        }
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

LL gcd(LL a, LL b) {
  if( b == 0 ) { return a; }
  return gcd(b, a % b);
}

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

int main() {
  LL A,B,C,D;
  std::cin >> A >> B >> C >> D;

  LL g = gcd(C, D);
  LL lcm = D * C / g;

  LL n_c = B / C - A / C;
  if(A % C == 0) { n_c++; }

  LL n_d = B / D - A / D;
  if(A % D == 0) { n_d++; }

  LL n_lcm = B / lcm - A / lcm;
  if(A % lcm == 0) { n_lcm++; }

  std::cout << (B - A + 1) - (n_c + n_d - n_lcm) << std::endl;

  return 0;
}



Measured memory_bytes: 256
N,M = map(int, input().split())
V = []

for _ in range(N):
    V.append(0)

for _ in range(M):
    a,b = map(int, input().split())
    a = a - 1
    b = b - 1
    V[a] = V[a] + 1
    V[b] = V[b] + 1

for node in range(N):
    print(V[node])

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <string>

using namespace std;

queue <string> N;
queue <int> T;


int n = 0, q = 0, nowtime = 0;
string na;
int ti;

int main() {




	cin >> n >> q;
	for (int i = 0; i<n; ++i) {
		
		cin >> na >> ti;
		N.push(na); T.push(ti);

	}

	while (!T.empty()) {

		string fn = N.front();
		int ft = T.front();

		N.pop(); T.pop();

		if (ft - q <= 0) {
			nowtime += ft;
			cout << fn << " " << nowtime << endl;
		}

		else {

			nowtime += q;
			ft -= q;

			N.push(fn); T.push(ft);
		}

	}
	return 0;

}


Measured memory_bytes: 5780
#include <bits/stdc++.h>
#define all(x) (x).begin() , (x).end();
#define rall(x) (x).rbegin() , (x).rend();
using namespace std;

void deb(){
    cerr<<endl;
}
template<typename T , typename... t>
void deb(T a , t...b){
    cerr<<a<<" ";
    deb(b...);
}
template<typename T>
void dev(vector<T>v){
    int c = 0;
    for(auto i : v){
        cerr<<i<<" ";
        c++;
    }
    cerr<<endl;
}
void add_self(int& a, int b , int M = 1e9 + 7){
    a += b;
    if(a > M){
        a -= M;
    }
}

char grid[1001][1001];
int dp[1001][1001];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n , m ; cin>>n>>m;
    for(int i = 0 ; i < n; ++i){
        for(int j = 0 ; j < m; ++j){
            cin>>grid[i][j];
        }
    }
    dp[0][0] = 1;
    for(int i = 0 ; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(grid[i][j] == '.'){
                if(i > 0) add_self(dp[i][j] , dp[i - 1][j]);
                if(j > 0)add_self(dp[i][j] , dp[i][j - 1]);
            }
        }
    }
    cout<<dp[n - 1][m - 1]<<endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int N, Y;
  cin >> N >> Y;
  
  int ans10, ans5, ans1;
  bool is_find = false;
  for(int num10=0; num10<=N; num10++){
    for(int num5=0; num5<=N-num10; num5++){
      if(is_find == true) break;
      int num1 = N - num10 - num5;
      int sum = num10*10000 + num5*5000 + num1*1000;
      if(sum == Y){
        is_find = true;
        ans10 = num10; ans5 = num5; ans1 = num1;
        break;
      }
    }
  }

  if(is_find == false){
    cout << "-1 -1 -1" << endl;
    return 0;
  }
  cout << ans10 << " " << ans5 << " " << ans1 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> cnt(m,0);
  for(Int i=0;i<n;i++){
    Int x;
    cin>>x;
    for(Int j=0;j<x;j++){
      Int y;
      cin>>y;
      y--;
      cnt[y]++;
    }
  }
  Int ans=0;
  for(Int i=0;i<m;i++) ans+=cnt[i]==n;
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int a;
    cin >> a;
    int ans = a+pow(a,2)+pow(a,3);
    cout << ans << endl;
}


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

/**
 * Copyright (c)
 * author        :   Sujeet Kumar 
 * question name :   
 * link          :   
 */

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define repA(i,v) for(auto i:v)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define vi vector<int>
#define vll vector<ll>
#define vi2(n,m) vector<vector<int> > v(n,vector<int>(m));
ll power(ll x,ll y,ll p){ll res=1; x=x%p;if(x==0) return 0;while(y>0)
{if(y&1) res=(res*x)%p;y=y>>1; x=(x*x)%p;}return res;}


void solve(){
	string s;cin>>s;
	int n = s.size();
	if(s[n-1]=='s')	s+="es";
	else	s+='s';
	cout<<s<<endl;
	return ;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    clock_t start=clock();

	ll test = 1;
	// cin>>test;
	while(test--)	solve();

	clock_t end=clock();
	cerr<<fixed<<setprecision(15)<<((double)(end-start))/CLOCKS_PER_SEC<<endl;
	return 0;
}
/**
 * Test Cases:-
 */


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define MAX 1100000

using namespace std;

typedef long long ll;

ll A,B,MOD;
ll dp[MAX];

inline
int toIndex(ll a){ return a-A+1; }

int main()
{
  while(cin >> A >> B >> MOD,A|B|MOD)
    {
      ll range = B-A+5;
      rep(i,range)dp[i] = 0;
      dp[1] = 1;//1-indexed
      dp[toIndex(B+1)] = -1;

      REP(cur,A,B+1)
	{
	  if(cur != A)dp[toIndex(cur)] = (dp[toIndex(cur)] + dp[toIndex(cur-1)]) % MOD;
	  ll sp = cur;
	  while(sp <= B)
	    {
	      int digit = (int)log10(sp) + 1;
	      ll p10 = 1LL;
	      rep(i,digit)p10 *= 10LL;
	      ll nsp = (sp == cur?cur+1LL:sp);
	      p10 = min(p10,B+1);

	      dp[toIndex(nsp)]  = (dp[toIndex(nsp)]  + dp[toIndex(cur)]) % MOD;
	      dp[toIndex(p10)] = (dp[toIndex(p10)] + MOD - dp[toIndex(cur)]) % MOD;
	      sp = sp*10;
	    }

	}

      ll ans = 0;
      REP(i,A,B+1)ans = (dp[toIndex(i)] + ans) % MOD;

      cout << ans << endl;

    }
  return 0;
}

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

using namespace std;

template <typename T>
class Dllist{
  struct Node{
    T value;
    Node *prev, *next;
  };
  
  Node first,end;
  public:
  Dllist(){
    first.next = &end;
    end.prev = &first;
  }

  void insert(T v){
    Node *n = new Node;
    n->value = v;
    n->next = first.next;
    n->prev = &first;
    n->next->prev = n;
    first.next = n;
  } 

  void delete_node(Node *node){
    node->prev->next = node->next;
    node->next->prev = node->prev;
    delete node;
  }

  void delete_last(){
    delete_node(end.prev);
  }

  void delete_first(){
    delete_node(first.next);
  }

  void delete_val(T v){
    Node *cur = first.next;
    while(cur!=&end){
      if(v==cur->value){
        delete_node(cur);
        return;
      }
      cur = cur->next;
    }
  }

  bool is_empty(){
    return first.next == &end;
  }

  void output(){
    Node *n = first.next;
    int i = 0;
    while(n!=&end){
      if(i) {cout<<" ";}
      cout<<n->value;
      n = n->next;
      i++;
    }
    cout<<endl;
  }
};

int main(){
  Dllist<int> list;
  int n;
  cin>>n;

  string ope;
  int val;
  for(int i=0;i<n;i++){
    cin>>ope;

    if(ope=="insert"){
      cin>>val;
      list.insert(val);
    }else if(ope=="delete"){
      cin>>val;
      list.delete_val(val);
    }else if(ope=="deleteFirst"){
      list.delete_first();
    }else if(ope=="deleteLast"){
      list.delete_last();
    }
  }
  list.output();
}

Measured memory_bytes: 34384
#include <bits/stdc++.h>
using namespace std;
string S;
long long K, C;
vector<int> dp, cnt, can;
bool dfs(int ind, int cnt1){
    if(dp[ind] != 0){
        if(dp[ind] == cnt1) return true;
        return false;
    }
    auto ite = upper_bound(can.begin(), can.end(), can[ind] + C);
    if(ite == can.end()){
        if(cnt1 == K){
            dp[ind] = cnt1;
            cnt[cnt1]++;
            return true;
        }
        return false;
    }
    int ind2 = ite - can.begin();
    bool flag = dfs(ind2, cnt1 + 1);
    if(flag){
        dp[ind] = cnt1;
        cnt[cnt1]++;
        return true;
    }
    return false;
}
int main(){
    long long N;
    cin >> N >> K >> C;
    cin >> S;
    can.resize(0);
    for(int i = 0; i < N; i++){
        if(S[i] == 'o') can.push_back(i + 1);
    }
    int size= can.size();
    dp.resize(size, 0);
    cnt.resize(K + 1, 0);
    dfs(0, 1);
    int flag = 0;
    for(int i = 0; i < size; i++){
        if(dp[i] == K) flag = 1;
        if(dp[i] > K){
            cout << endl;
            return 0;
        }
    }
    if(flag == 0){
        cout << endl;
        return 0;
    }
    for(int i = 0; i < size; i++){
        if(dp[i] != 0) continue;
        int temp;
        if(can[i] - C - 1 < can[0]) temp = 1;
        else{
            int inde = upper_bound(can.begin(), can.end(), can[i] - C - 1) - can.begin() - 1;
            temp = dp[inde] + 1;
        }
        dfs(i, temp);
    }
    for(int i = 0; i < size; i++){
        if(cnt[dp[i]] == 1) cout << can[i] << endl;
    }
}

Measured memory_bytes: 11928
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
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 exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    if(k <= a) {
        out(k);
    }
    else if(k <= a+b) {
        out(a);
    }
    else {
        ll x = k -(a+b);
        out(a - x);
    }

    re0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))


int main(){
    double a, b, h, m; cin >> a >> b >> h >> m;
    double hd = 30.0*h+0.5*m, md = 6*m;
    double degree = min(abs(hd-md), 360-(abs(hd-md)));
    double theta = degree/180.0*PI;
    //cout << degree << endl;
    if(a<b) swap(a, b);
    double ans = pow((pow(b-(a*cos(theta)), 2.0)+pow(a*sin(theta), 2.0)), 0.5);
    cout << fixed << setprecision(20) << ans << endl;
}

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

typedef long long ll;

using namespace std;

int gcd(int a,int b){
    return b != 0 ? gcd(b,a%b) : a;
}

int main(){
    ll k;
    ll sum = 0;
    cin >> k;
    for(int i=1;i<=k;i++){
        for(int j= 1;j<=k;j++){
            for(int m = 1; m <= k; m++){
                sum += gcd(i,gcd(j,m));
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
	int N, K, C;
	char S[200001];
	scanf("%d %d %d", &N, &K, &C);
	scanf("%s", S);
	
	int i, k, dp[200002] = {};
	for (i = N, k = N * 2 + 1, dp[N+1] = 0; i >= 1; i--) {
		if (S[i-1] == 'o' && i + C < k) {
			dp[i] = dp[i+1] + 1;
			k = i;
		} else dp[i] = dp[i+1];
	}
	if (dp[1] > K) return 0;

	for (i = 1; i <= N; i++) {
		if (dp[i] > dp[i+1]) {
			printf("%d\n", i);
			i += C;
		} else if (S[i-1] == 'o') {
			for (k = i; k <= N && dp[k+1] == dp[i]; k++);
			i = (k > i + C)? k: i + C;
		} 
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2708
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	a = sort(a)
	m = 0
	l = n
	if a[n] < 0
		println(a[n]-sum(a[1:n-1]))
		for i in 1:n-1
			x = shift!(a)
			println(a[l-1], " ",x)
			a[l-1] -= x
			l -= 1
		end
	elseif a[1] > 0
		println(sum(a[2:n])-a[1])
		for i in 1:n-2
			x = pop!(a)
			println(a[1], " ",x)
			a[1] -= x
		end
		println(a[2], " ", a[1])
	else
		for i in 1:n
			m += abs(a[i])
		end
		println(m)
		p = shift!(a)
		q = pop!(a)
		for i in 1:n-2
			x = pop!(a)
			if x<0
				println(q," ",x)
				q -= x
			else
				println(p, " ",x)
				p -= x
			end
		end
		println(q, " ", p)
	end
end

main()

Measured memory_bytes: 174772
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
        
    int n; cin >> n;
    vector <int > a(n);

    forn(i, n) cin >> a[i];
    sort(all(a));

    long long int ans = 0;  
    forn(i, n) {
        forn(j, n) {
            if(i == j) continue;
            int t = lower_bound(all(a), a[i] + a[j]) - upper_bound(all(a), abs(a[i] - a[j]));
            // cout << a[i] <<" " << a[j] << " " << t << endl;
            
            if(a[i] + a[i] > a[j]) t --;
            if(a[j] + a[j] > a[i]) t --;

            // cout << a[i] <<" " << a[j] << " " << t << endl;
            ans += t;
        }
    }

    cout << ans / 6;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		
		int n = getInt();
		int a[] = getIntArray(n);
		double d = 0D;
		for ( double aa : a ) {
			d += 1D / aa;
		}

		System.out.println( 1D / d );
	}
}


Measured memory_bytes: 20820
#include <stdio.h>

int main(){
	int N,A,B,C,D;
	scanf("%d%d%d%d%d",&N,&A,&B,&C,&D);
	int ma = (N / A + (N%A != 0 ? 1 : 0)) * B;
	int mb = (N / C + (N%C != 0 ? 1 : 0)) * D;
	printf("%d\n",ma > mb ? mb : ma);
	return 0;
}



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

int main()
{
	int n[4][3][10] = { 0 };

	int count;
	cin >> count;

	for (int i = 0; i < count; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		n[b - 1][f - 1][r - 1] += v;
	}

	for (int b = 0; b < 4; b++)
	{
		for (int f = 0; f < 3; f++)
		{
			for (int r = 0; r < 10; r++)
			{
				cout << " " << n[b][f][r];
			}
			cout << endl;
		}
		if(b < 3) cout << "####################" << endl;
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const long inf = 1e18;
int n;
long a[200000];
long dp[5][200001];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  
  for (int i = 0; i <= n; ++i) {
    for (int k = 0; k < 5; ++k) {
      dp[k][i] = inf;
    }
  }
  
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i) {
    long mn = inf;
    for (int k = 0; k < 5; ++k) {
      mn = min(mn, dp[k][i]);
      long c;
      if (k == 0 || k == 4) c = a[i];
      if (k == 1 || k == 3) c = a[i] == 0 ? 2 : a[i] % 2;
      if (k == 2) c = a[i] % 2 == 0;
      dp[k][i + 1] = min(dp[k][i + 1], mn + c);
    }
  }
  
  long mn = inf;
  for (int k = 0; k < 5; ++k) {
    mn = min(mn, dp[k][n]);
  }
  cout << mn << endl;
}



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

int H, W;
int wall;
int M[102][102];
bool visited[102][102];

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

bool isInField(int x, int y) {
  return 0<=x&&x<=W+1 && 0<=y&&y<=H+1;
}

void dfs(int x, int y){

  visited[y][x] = true;

  for(int i=0; i<6; i++) {
    int nx = x+dx[y%2][i], ny = y+dy[y%2][i];
    if(isInField(nx, ny)) {
      if(visited[ny][nx]) continue;
      if(M[ny][nx]) wall ++;
      else dfs(nx, ny);
    }
  }
}

int main(){

  fill(M[0], M[102], 0);
  fill(visited[0], visited[102], false);

  cin >> W >> H;

  for(int i=1; i<=H; i++) {
    for(int j=1; j<=W; j++) {
      cin >> M[i][j];
    }
  }
  
  wall = 0; dfs(0, 0);
  cout << wall << endl;
  
  return 0;
}

Measured memory_bytes: 1456
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  vector<vector<char>> p(n,vector<char>(n));
  rep(i,n){
    rep(j,n){
      cin>>p[i][j];
    }
  }

  int ans=0;
  rep(i,n){
    bool ok=true;
    rep(j,n){
      rep(k,n){
        int a,b,c,d;
        a=j,b=k+i,c=k,d=j+i;
        if(b>=n) b-=n;
        if(d>=n) d-=n;
        if(p[a][b]!=p[c][d]) ok=false;
      }
    }
    if(ok) ans++;
  }

  cout << ans*n << endl;
}

Measured memory_bytes: 3724
import numpy as np
n = int(input())
a = list(map(int,input().split()))
s = np.zeros(n+1)
for i in a:
    s[i]+=1
al = sum((s*(s-1))/2)
for i in range(n):
    ans=al-(s[a[i]]-1)
    print(int(ans))

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

int main() {
  int n;
  cin >> n;
  map<ll, int> m;
  ll s = 0;
  while (n--) {
    int e;
    cin >> e;
    m[e]++;
    s += e;
  }

  int q;
  cin >> q;
  while (q--) {
    ll b, c;
    cin >> b >> c;
    if (m.count(b)) {
      s += m[b] * (c - b);
      m[c] += m[b];
      m.erase(b);
    }
    cout << s << endl;
  }
}


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

int main()
{
	int n, a[1000],c=0,d=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			d++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (a[i] %2==0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) {
				c++;
			}
		}
	}
	if (c == d) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

	cin.get();
    cin.get();
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

int main(void){
	int32 N, K;
	cin >> N >> K;
	vector<int64> a(N), sum(N+1, 0);
	vector<int64> h;
	REP(i, N) cin >> a[i];
	REP(i, N) sum[i+1] = sum[i]+a[i];
	
	REP(i, N){
		FOR(j, i, N){
			h.push_back(sum[j+1]-sum[i]);
		}
	}
	int64 res = 0;
	for(int64 b = 40;b >= 0;b--){
		vector<int64> next;
		REP(i, h.size()){
			if(h[i] >> b & 1){
				next.push_back(h[i]);
			}
		}
		if(next.size() >= K){
			swap(h, next);
			res += (1LL) << b;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 6516
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int d = a[j] - a[i];
            
            auto ind = lower_bound(a.begin(), a.begin() + i, a[i] - d) - a.begin();
            
            if (ind == i || a[ind] != a[i] - d) {
                int cnt = 2;
                int k = j;
                
                while(true) {
                    ind = lower_bound(a.begin() + k, a.end(), a[k] + d) - a.begin();
                    
                    if (ind == n || a[ind] != a[k] + d) {
                        break;
                    }
                    
                    k = ind;
                    cnt++;
                }
                
                ans = max(ans, cnt);
            }
        }
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long q,h,s,d,n;
    cin>>q>>h>>s>>d;
    cin>>n;
    q=q*4;
    h=min((h*2),q);
    s=min(h,s);
    if(s*2<d)
        cout<<s*n<<endl;
    else
        cout<<(n/2)*d+((n%2==1)*s)<<endl;
}


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

std::vector<std::string> properties;
std::string yaml;
int p_i{};

std::string calcProperty(int);
int calcDepth(std::string&);
void readThrough(int);
std::string calcString(int&);
std::string getString(std::string&, int&);

int main()
{
	std::string tmp;
	std::getline(std::cin, tmp);
	for (int p_i{1}; p_i < (int)tmp.size(); p_i++)
	{
		properties.push_back({});
		while (p_i < (int)tmp.size() && tmp[p_i] != '.')
		{
			properties.back().push_back(tmp[p_i]);
			p_i++;
		}
	}
	
	std::getline(std::cin, yaml);
	std::cout << calcProperty(0) << std::endl;

	return 0;
}

std::string calcProperty(int depth)
{
	if (p_i == (int)properties.size())
		return "object";

	while (!std::cin.eof() && calcDepth(yaml) == depth)
	{
		int s_i{depth};
		std::string key{getString(yaml, s_i)};
		if (key != properties[p_i])
			readThrough(depth);
		else
		{
			p_i++;
			if (s_i == (int)yaml.size())
			{
				std::getline(std::cin, yaml);
				return calcProperty(calcDepth(yaml));
			}
			else
			{
				s_i++;
				return calcString(s_i);
			}
		}
	}
	return "no such property";
}

int calcDepth(std::string& str)
{
	for (int i{}; i < (int)str.size(); i++)
		if (str[i] != ' ')
			return i;
	return -1;
}

std::string getString(std::string& yaml, int& s_i)
{
	std::string ret;
	while (s_i < (int)yaml.size() && yaml[s_i] != ':')
	{
		ret += yaml[s_i];
		s_i++;
	}
	s_i++;
	return std::move(ret);
}

std::string calcString(int& s_i)
{
	if (p_i < (int)properties.size())
		return "no such property";
	else
		return "string \"" + getString(yaml, s_i) + "\"";
}

void readThrough(int depth)
{
	std::getline(std::cin, yaml);
	while (!std::cin.eof() && calcDepth(yaml) > depth)
		std::getline(std::cin, yaml);
}


Measured memory_bytes: 3324
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
long long MAX(long long a,long long b){return a<b?b:a;}
long long n,m,i,j,k,a[100010],b[100010],c[100010],min,d[2][100010];
int main(){
	char s[100010][10];
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++)scanf("%lld",&a[i]);
		scanf("%d",&m);
		for(i=0;i<m;i++)scanf("%*s %lld %s %lld",&b[i],&s[i],&c[i]);
		for(i=0;i<100010;i++)d[0][i]=d[1][i]=1e9+10;
		for(i=d[0][0]=d[1][0]=0;i<100000;i++){
			for(j=0;j<m;j++){
				k=(s[j][0]=='S'?0:1);
				d[k][MIN(100000,i+c[j])]=MIN(d[k][MIN(100000,i+c[j])],d[k][i]+b[j]);
			}
		}//return 0;
		for(i=0;i<2;i++){
			for(j=100000;j;j--)d[i][j-1]=MIN(d[i][j-1],d[i][j]);
		}
		min=1e9+10;
		for(i=0;i<100001;i++){
			k=d[1][i];
			for(j=0;j<n;j++)k+=d[0][MAX(0,a[j]-i)];
			min=MIN(min,k);
		}
		printf("%lld\n",min);
	}
	return 0;
}


Measured memory_bytes: 3288
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { n:usize, }
    println!("{}", n * n * n);
}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int m = n * 100 + n * 10 + n;
    int c = 0;
    bool k = true;
    for (int i = 111; i <= m; i++)
    {
        int f = i;
        for (int j = 0; j <3 ; ++j)
        {
            if (f%10 == 0)
            {
                k = false;
                break;
            }
            k = true;
            f /= 10;
        }
        if (i / 100 <= n and (i / 10) % 10 <= n and i % 10 <= n and k)
            c++;
    }
    cout << c;
}


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

s1 = s // 100
s2 = s % 100

if (1 <= s1 <= 12) and (1 <= s2 <= 12):
    print("AMBIGUOUS")
elif ((s1 == 0) or (12 < s1 <= 99)) and (1 <= s2 <= 12):
    print("YYMM")
elif (1 <= s1 <= 12) and ((s2 == 0) or (12 < s2 <= 99)):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
        string S;
        cin >> S;
        int a=0;
    
    for ( int i=0;i<S.size();i++ ){
            if ( i%2 == 0 && S.at(i) == 'L' ){
                cout << "No" << endl;
                
                break;
            }
             if ( i%2 == 1 && S.at(i) == 'R' ){
                cout << "No" << endl;
                break;
            
             }
             a++;
             
        }
        if(a==S.size()){
            cout <<"Yes"<<endl;
        }
    }

Measured memory_bytes: 256
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = str(input())
A = []
count = 0

for i in range (0, N):
	if T[i] == 'r':
		A.append('p')
	elif T[i] == 's':
		A.append('r')
	else:
		A.append('s')

for i in range (K, N):
	if A[i] == A[i-K]:
		A[i] = 'd'

for i in range (0, N):
	if A[i] == 'r':
		count+=R
	if A[i] == 's':
		count+=S
	if A[i] == 'p':
		count+=P
        
print(count)

Measured memory_bytes: 10020
inpl = lambda: list(map(int,input().split()))
N, T = inpl()
AB = sorted([inpl() for _ in range(N)])

ans = 0
dp_intime = [0]*T
for n in range(N):
    dp_intime_prev = dp_intime
    dp_intime = [0]*T
    a, b = AB[n]
    for t in range(T):
        if t < a:
            dp_intime[t] = dp_intime_prev[t]
        else:
            dp_intime[t] = max(dp_intime_prev[t], dp_intime_prev[t-a]+b)
    ans = max(ans, dp_intime_prev[-1]+b)
print(ans)

Measured memory_bytes: 48216
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e5;
int n, k, h[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n  >> k;
  mins(k, n);
  FOR(i, 0, n) cin >> h[i];
  sort(h, h+n);
  ll ans = 0;
  FOR(i, 0, n-k) ans += h[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
using namespace std;
long B,a,b;
int id,w;
priority_queue<int>L,R;
main()
{
	for(cin>>a;cin>>id;)
	{
		if(id==1)
		{
			cin>>a>>b;
			B+=b;
			if(w++%2)
			{
				L.push(a);
				B-=a;
				a=L.top();
				B+=a+a;
				L.pop();
				R.push(-a);
			}
			else
			{
				R.push(-a);
				B+=a;
				a=-R.top();
				B-=a+a;
				R.pop();
				L.push(a);
			}
		}
		else
		{
			a=L.top();
			cout<<a<<" "<<B+a*((int)L.size()-(int)R.size())<<endl;
		}
	}
}

Measured memory_bytes: 3452
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	int result = 0;
	for (int i = 0; i < S.size(); i++)
	{
		result += S[i] - '0';
	}

	if (result % 9 == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(void) {
	int n,count=0,i;
	int a[10000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		while((a[i]%2)==0){
			count++;
			a[i]/=2;
		}
	}
	printf("%d",count);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct p{
    int a;
    int f;
}k[1000000];
bool cmp(p xx,p yy){
    return xx.a>yy.a;
}
int main(){
    int c=0,i,n,h,s=0;
    cin>>n>>h;
    for(i=1;i<=n;i++){
        cin>>k[c++].a;
        k[c].f=1;
        cin>>k[c++].a;
    }
    sort(k,k+c,cmp);
    for(i=0;i<c;i++){
        if(k[i].f==1)
        {
            h-=k[i].a;
            s++;
            if(h<=0){cout<<s<<endl;return 0;}
        }
        else if(k[i].f!=1){
            if(h%k[i].a==0)s+=h/k[i].a;
            else s+=h/k[i].a+1;
            cout<<s<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
def main():
    # 入力
    s = input()

    x = len(s)
    limit = int(x/2)+1 if x % 2 == 0 else int(x/2)+2
    limit2 = int(x/2) if x % 2 == 0 else int(x/2)+1

    n = int(s)

    min_l = 11

    # ccc = 0
    for i in range(1, n+1):
        # ccc += 1
        il = len(str(i))
        if il == limit:
            break
        if n % i != 0:
            continue
        if il == min_l:
            break
        j = int(n / i)

        jl = len(str(j))
        f = max(il, jl)
        if f < min_l:
            min_l = f
        if jl == limit2 or il == jl or il > jl:
            break


    # print(ccc)
    print(min_l)


main()


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>

using namespace std;

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

    int b[p];
    memset(b, 0, sizeof(b));
    for (int i = 0; i < p; i++) {
        int a;
        cin >> a;

        if (i == 0) {
            b[0] += a;
        }

        int t = p - a;
        for (int j = p - 1; j >= 1; j--) {
            b[j] = (b[j] + t) % p;
            t = t * i % p;
        }
    }

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int degree,number,num,count;
	cin>>degree;
	int arr[100][100];
	for(int i=0;i<degree;i++)
	{
		for(int j=0;j<degree;j++)
		{
			arr[i][j]=0;
		}
	}
	for(int i=0;i<degree;i++)
	{
		cin>>count;
		cin>>number;
		for(int j=0;j<number;j++)
		{
			cin>>num;
			arr[i][num-1]=1;
		}
	}
	int queue[100];
	int L=0,R=0;
	int ans[degree];
	bool flag=false;
	for(int i=0;i<degree;i++)
	{
		ans[i]=0;
	}
	R+=1;
	while(L!=R)
	{
		for(int i=0;i<degree;i++)
		{
			if(arr[queue[L]][i]!=0 && ans[i]==0)
			{
				queue[R++]=i;
				ans[i]=ans[queue[L]]+1;
			}
		}
		L++;
	}
	for(int i=0;i<degree;i++)
	{
		cout<<i+1<<" ";
		if(ans[i]==0 && i!=0)
		{
			cout<<"-1"<<endl;
		}
		else if(i!=0)
		{
			cout<<ans[i]<<endl;
		}
		if(i==0)
			cout<<0<<endl;
	}
} 


Measured memory_bytes: 3120
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	vector<int>P(N), Q(N);
	rep(i, N)cin >> P[i];
	rep(i, N)cin >> Q[i];
	vector<int>v(N);
	rep(i, N)v[i] = i + 1;
	int a = 0, b = 0;
	int cnt = 0;
	do
	{
		if (v == P)a = cnt;
		if (v == Q)b = cnt;
		cnt++;
	}while (next_permutation(v.begin(), v.end()));
	cout << abs(a - b);
}

Measured memory_bytes: 256
n = int(input().strip())
h = list(map(int, input().split(" ")))

ans = 0
cnt = 0

for i in range(1, n, 1):
    if (h[i] <= h[i - 1]):
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

print(max(ans, cnt))


Measured memory_bytes: 63708