akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int main()
{
    int n, r;
    cin >> n >> r;
    int res = 100 * (10 - n);
    int ans;
    if(n >= 10){
        ans = r;
    }
    else{
        ans = r + res;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Made with <3 by MinumCoklatPanas
typedef long long ll;
const ll INF = 1e9;
const ll INFF = 1e18;
const ll MAXN = 510;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

map<ll,ll> frek;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	for (ll i = 1 ; i <= n ; i++)
	{
		ll ta;
		cin >> ta;
		frek[ta]++;
	}
	ll ans = 0;
	for (auto it : frek)
	{
		if (it.second >= it.first) ans += it.second - it.first;
		else ans += it.second;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const LL MAX = 1e9;
const int SIZE = 410;
LL an;
int d[SIZE][4];
LL val[SIZE];
map<LL,int>H,C;
void ADD(LL& x,LL v){
    x=(x+v);
}
LL fix(LL x){
    vector<LL>ker;
    ker.PB(x);
    LL mi=x;
    REP(k,3){
        LL tmp=x/MAX;
        x=(x-tmp*MAX)*1000+tmp;
        mi=min(mi,x);
        ker.PB(x);
    }
    if(ker[0]==ker[3]&&ker[0]==ker[1]&&ker[2]==ker[3])
        C[mi]=4;
    else if(ker[0]==ker[2]&&ker[1]==ker[3])C[mi]=2;
    else C[mi]=1;
    return mi;
}
int main(){
    DRI(N);
    REP(i,N){
        //printf("%d:%lld\n",i,an);
        REP(j,4)
            RI(d[i][j]);
        REP(j,i){
            H[val[j]]--;
            REP(r,4){
                map<LL,int>shik;
                REP(k,4){
                    LL v=0;
                    v=v*1000+d[j][(r-k+4)&3];
                    v=v*1000+d[j][(r-k+3)&3];
                    v=v*1000+d[i][(k+1)&3];
                    v=v*1000+d[i][k&3];
                    shik[fix(v)]++;
                }
                LL my_v=1;
                for(map<LL,int>::iterator it=shik.begin();it!=shik.end();it++){
                    if(H.count(it->F)){
                        LL nn=H[it->F];
                        REP(ker,it->S){
                            my_v=my_v*nn;
                            nn--;
                            my_v=my_v*C[it->F];
                        }
                    }
                    else my_v=0;
                }
                ADD(an,my_v);
            }
            H[val[j]]++;
        }
        {
            LL v=0;
            REP(k,4)
                v=v*1000+d[i][k];
            val[i]=fix(v);
            H[val[i]]++;
        }
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>

const int x_plus[8]={-1, 0, 1,-1, 1,-1, 0, 1};
const int y_plus[8]={-1,-1,-1, 0, 0, 1, 1, 1};

char banmen[8][12];

int in_range(int num){return 0<=num && num<8;}

int put_count(int x,int y,char now) {
	int i,j;
	int count=0;
	char aite=(now=='o')?'x':'o';
	if(banmen[y][x]!='.')return 0;
	for(i=0;i<8;i++) {
		for(j=1;in_range(x+x_plus[i]*j) && in_range(y+y_plus[i]*j);j++) {
			if(banmen[y+y_plus[i]*j][x+x_plus[i]*j]!=aite)break;
		}
		if(in_range(x+x_plus[i]*j) && in_range(y+y_plus[i]*j)) {
			if(banmen[y+y_plus[i]*j][x+x_plus[i]*j]==now)count+=j-1;
		}
	}
	return count;
}

void put_commit(int x,int y,char now) {
	int i,j;
	char aite=(now=='o')?'x':'o';
	banmen[y][x]=now;
	for(i=0;i<8;i++) {
		for(j=1;in_range(x+x_plus[i]*j) && in_range(y+y_plus[i]*j);j++) {
			if(banmen[y+y_plus[i]*j][x+x_plus[i]*j]!=aite)break;
		}
		if(in_range(x+x_plus[i]*j) && in_range(y+y_plus[i]*j)) {
			if(banmen[y+y_plus[i]*j][x+x_plus[i]*j]==now) {
				for(j--;j>0;j--) {
					banmen[y+y_plus[i]*j][x+x_plus[i]*j]=now;
				}
			}
		}
	}
}

int main(void) {
	int x,y;
	int max_x,max_y,max_num;
	int now_num;
	char now_turn;
	int prev_is_pass;
	for(y=0;y<8;y++)scanf("%s",banmen[y]);
	now_turn='o';
	prev_is_pass=0;
	while(1) {
		max_x=max_y=-1;
		max_num=0;
		for(y=0;y<8;y++) {
			for(x=0;x<8;x++) {
				now_num=put_count(x,y,now_turn);
				if(now_num>max_num ||
						(now_num==max_num && now_turn=='x')) {
					max_num=now_num;
					max_x=x;
					max_y=y;
				}
			}
		}
		if(max_num<=0) {
			if(prev_is_pass)break;
			prev_is_pass=1;
		} else {
			prev_is_pass=0;
			put_commit(max_x,max_y,now_turn);
		}
		now_turn=(now_turn=='o')?'x':'o';
	}
	for(y=0;y<8;y++)puts(banmen[y]);
	return 0;
}

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (B <= A) {
    cout << "delicious";
  }
  else if ((B-A)<=X) {
    cout << "safe";
  }
  else {
    cout << "dangerous";
  }
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  ll N=S.size();
  ll cnt = 0, ans=0;
  rep(i, N){
    if(S[i]=='A')cnt++;
    else if(S[i]=='C')cnt++;
    else if(S[i]=='G')cnt++;
    else if(S[i]=='T')cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

  private static final int MOD = (int) 1e9 + 7;

  void solve(InputReader in, PrintWriter out) {
    int h = in.nextInt();
    int w = in.nextInt();

    char[][] arr = new char[h][w];
    for (int i = 0; i < h; ++i)
      arr[i] = in.next().toCharArray();

    int[][] dp = new int[h + 1][w + 1];
    dp[0][0] = 1;
    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j)
        if (arr[i][j] != '#') {
          dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
          dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
        }

    out.println(dp[h - 1][w - 1]);
  }

  public static void main(String[] args) throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    Main solver = new Main();
    solver.solve(in, out);
    out.close();
  }

  static class InputReader {
    BufferedReader in;
    StringTokenizer st;

    public InputReader(InputStream is) {
      in = new BufferedReader(new InputStreamReader(is));
    }

    public String next() {
      try {
        while (st == null || !st.hasMoreTokens()) {
          st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
  }
}


Measured memory_bytes: 34592
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            int cnt = int.Parse(Console.ReadLine());

            if (cnt % 2 ==0)
            {

                Console.WriteLine((cnt/2).ToString());
            }
            else
            {

                Console.WriteLine(((cnt/2)+1).ToString());
            }
            
        }
    }
}




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t A, B, C;
  cin >> A >> B >> C;
  if (4 * A * B < (C - (A + B)) * (C - (A + B)) && C >= A + B) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
<?php

    $numbers = preg_split('/ /', trim(fgets(STDIN)));
    $i = 0;

    while($i < count($numbers)){

        if($i != count($numbers) - 1){

            echo(min($numbers) . " ");

        }else{

            echo(min($numbers));

        }

        $numbers[array_search(min($numbers), $numbers)] = max($numbers);

        $i++;

    }

?>

Measured memory_bytes: 15740
// https://atcoder.jp/contests/agc031/tasks/agc031_b
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: i64 = 1000000007;

fn main() {
    input! {
        n: usize,
        c: [usize; n]
    };

    let mut a = vec![];
    let mut last = 2000000;
    for col in c {
        if last != col {
            a.push(col);
        }
        last = col;
    }

    let n = a.len();
    let mut sum = vec![0; 200010];
    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for i in 0..n {
        dp[i + 1] = (dp[i] + sum[a[i]]) % MOD;
        sum[a[i]] = (sum[a[i]] + dp[i]) % MOD;
    }

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


Measured memory_bytes: 12908
#include<bits/stdc++.h>
using namespace std;
int n,a[58],t;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;cout<<2*n-1<<'\n';
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	t=1;
	for(int i=2;i<=n;++i){
		if(abs(a[i])>abs(a[t])){
			t=i;
		}
	}
	for(int i=1;i<=n;++i){
		cout<<t<<' '<<i<<'\n';
	}
	if(a[t]>0){
		for(int i=1;i<n;++i){
			cout<<i<<' '<<i+1<<'\n';
		}
	}
	else{
		for(int i=n;i>=2;--i){
			cout<<i<<' '<<i-1<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 384
#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() {
    int H, N;
    cin >> H >> N;
    vector<pair<int, int> > magic(N+1);
    REP(i, N) {
        cin >> magic[i+1].first >> magic[i+1].second;
    }
    // sort(ALL(magic));
    // reverse(ALL(magic));
    vector<vector<int> > dp(N + 1, vector<int>(H + 1, 1e9));
    
    FOR(i, 0, N) dp[i][H] = 0;

    FOR(i, 1, N) {
        FORR(j, H, 0) {
            dp[i][j] = min(dp[i-1][j], dp[i][j]);
            dp[i][max(0, j - magic[i].first)] = min(
                min(dp[i][max(0, j - magic[i].first)], dp[i][j] + magic[i].second), 
                dp[i-1][max(0, j - magic[i].first)]);
        }
    }

    // FOR(i, 1, N) {
    //     FOR(j, 0, H) cerr << dp[i][j] << " ";
    //     cerr << endl;
    // }

    cout << dp[N][0] << endl;

    return 0;
}

Measured memory_bytes: 39424
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int>p(n);
    vector<ll>c(n);
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    rep(i,n){
        cin >> c[i];
    }
    ll ans = -(1LL<<60);
    rep(i,n){
        int now = i;
        ll sum = 0;
        int cnt = 0;
        vector<ll>a;
        a.push_back(0);
        while(1){
            now = p[now];
            sum += c[now];
            a.push_back(sum);
            cnt++;
            if(now == i)break;
        }
        while(1){
            now = p[now];
            sum += c[now];
            a.push_back(sum);
            if(now == i)break;
        }
        ll temp = 0;
        int K = k;
        if(sum > 0){
            temp += sum / 2 * max(0, (K / cnt) - 1);
            K -= max(0, K / cnt - 1) * cnt;
        }
        temp += *max_element(a.begin() + (K == k ? 1 : 0), a.begin() + min(K + 1, (int)a.size()));
        ans = max(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3780
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (long long i = 0; i < m; i++)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  ll b[n];
  b[0] = a[0];
  REP(i, n-1) b[i+1] = b[i] + a[i+1];
  bool c[n];
  REP(i, n-1) c[i] = (2*b[i] >= a[i+1]);
  c[n-1] = true;
  int cr = n-1, ans = 0;
  while(cr >= 0 && c[cr]){
    cr--;
    ans++;
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())

    ans = []
    if(N%2):
        for i in range(1, N):
            for j in range(i+1, N+1):
                if i + j != N:
                    ans.append((i, j))
    else:
        for i in range(1, N):
            for j in range(i+1, N+1):
                if i + j != N + 1:
                    ans.append((i, j))

    print(len(ans))
    for t in ans:
        print(t[0], t[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 43376
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[2];
  cin>>a;
  if(a[0]=='a'||a[0]=='i'||a[0]=='u'||a[0]=='e'||a[0]=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

ll Fact(ll n) {
    ll answer = 1;
    for (ll i = n; i > 1; i--) {
        answer *= i;
    }
    return answer;
}

ll Sum(ll n) {
    ll answer = 0;
    for (ll i = n; i >= 1; i--) {
        answer += i;
    }
    return answer;
}

int main() {
    ll n;
    double answer = 0;
    vector<pair<ll, ll>> xy;

    // input
    cin >> n;
    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        xy.emplace_back(x, y);
    }

    // process
    double sum = 0;
    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            double distance;
            distance = sqrt(pow((xy[i].first - xy[j].first), 2) + pow((xy[j].second - xy[i].second), 2));
            sum += distance * Fact(n - 2) * (n - 1);
        }
    }

    answer = sum * (n - 1) / Sum(n - 1) / (Fact(n - 2) * (n - 1));

    std::cout << std::fixed;
    cout << std::setprecision(6) << answer << endl;

    return 0;
}

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

using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<v.size();i++){
        cin>>v[i];
    }
    for(int i=v.size()-1;i>=0;i--){
        cout<<v[i];
        if(i>0){
            cout<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3052
N, M, X = map(int, input().split())
C = [0] * N
A = []

for __ in range(N):
    nums = list(map(int, input().split()))
    C[__] = nums[0]
    A.append(nums[1:])

mincost = 10e9
ok = False
for i in range(1 << N):
    cost = 0
    skill = [0] * M

    for u in range(N):
        if i & (1<<u):
            cost += C[u]
            for si, s in enumerate(A[u]):
                skill[si] += s
    
    # check
    if all([s >= X for s in skill]):
        ok = True
        if mincost > cost:
            mincost = cost

print(mincost if ok else -1)


Measured memory_bytes: 9164
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [0]+[inf]*(n-1)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j], dp[i])

print(dp[n-1])    

Measured memory_bytes: 55008
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
    void solve()
    {
    long long  i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
  cin>>k>>n>>m;
  rep(i,n,m+1)
  {
      if(i%k==0){cout<<"OK"; return;}
  }
  cout<<"NG";

    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //sieve();
        //pre();
         // cin>>t;
        solve();
    }


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
long long x5(long long a){
	return a*a*a*a*a;
}
int main(){
	long long x;
	cin>>x;
	for(long long i=-500;i<=500;i++){
		for(long long j=-500;j<=500;j++){
			if(x5(i)==x+x5(j)){
				cout<<i<<' '<<j;
				return 0;
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Grouping
            var line = ReadLine();
            int x = line[0];
            int y = line[1];

            var a = new int[7] { 1, 3, 5, 7, 8, 10, 12 };
            var b = new int[4] { 4, 6, 9, 11 };

            if (a.Contains(x) && a.Contains(y))
            {
                Console.WriteLine("Yes");
            }
            else if (b.Contains(x) && b.Contains(y))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int n;
    cin>>n;
    bool bl[1000001]={0};
    int a[200000];
    rep(i, n) cin>>a[i];

    sort(a, a+n);

    int cnt=0;
    rep(i, n){
        if(!bl[a[i]]){
            if(!(i!=n-1 && a[i]==a[i+1])) cnt++;
            for(int c=a[i]; c<=1000000; c+=a[i]){
                bl[c]=true;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5304
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <cmath>

using namespace std;

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

int main()
{
    int n; cin >> n;
    vi h(n), dp(n, 0);
    for (auto &e : h)
        cin >> e;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 

const int MAX = 30000;
signed main() {
    int N; cin >> N;
    if(N == 3) {
        printf("2 5 63\n");
        return 0;
    }

    // max size: N - 2
    vector<int> ans;
    
    int val = 3, lim = (N - 2) / 2 * 2;
    while(val < MAX && (int)ans.size() < lim) {
        ans.push_back(val);
        val += 6;
    }

    vector<int> cand_two[3];
    for(int i=2; i<=MAX; i+=2) {
        if(i % 3 == 0 && i % 2 == 1) continue;
        cand_two[i%3].push_back(i);
    }

    int rest = N - (int)ans.size(), idx = 0, kdx = 0;
    int M = min((int)cand_two[1].size(), (int)cand_two[2].size());
    // printf("A = %zu, B = %zu, C = %zu\n", cand_two[1].size(), cand_two[2].size(), cand_two[0].size());
    while(rest != 0) {
        // printf("rest = %lld, idx = %lld, kdx = %lld\n", rest, idx, kdx);
        if(rest >= 2 && idx < M) {
            ans.push_back(cand_two[1][idx]);
            ans.push_back(cand_two[2][idx]);
            idx++;
            rest -= 2;
        }
        else {
            assert(kdx < (int)cand_two[0].size());
            ans.push_back(cand_two[0][kdx++]);
            rest--;
        }
    }

    assert(ans.size() == N);
    for(size_t i=0; i<N; i++) {
        printf("%lld%c", ans[i], (i+1 == N ? '\n' : ' '));
    }
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
#define MOD 1000000007

//n!を10^9+7で割った余りを返す
long long mod_fac(int n){
  long long ans= 1;
  for(int i=1; i<=n; i++)
    ans = ans*i%MOD;
  return ans;
}


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

  int abso = abs(N-M);
  
  //片方がもう一方より2匹以上少なければ解はなし
  if(abso >= 2){
    cout << 0 << endl;
    return 0;
  }
  
  //犬の並び方はN!通り
  //猿の並び方はM!通り
  long long n = mod_fac(N);
  long long m = mod_fac(M);

  //同じ匹数なら配置の仕方は両端を考える
  if(abso == 0)
    cout << n*m%MOD*2%MOD << endl;
  //1匹差なら犬猿の順列のみ考えればよい
  else 
    cout << n*m%MOD << endl;
  
  return 0;
}


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

using namespace std;

const int maxN = 1e5 + 1;

int n;
int a[maxN];

int t = 0;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] > t)
        {
            --a[i];
            t = a[i];
        }
        else if (a[i] < t)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "memory.h"

int input_int()
{
    const size_t BUF_SIZE = 100;
    char buf[BUF_SIZE];

    memset(buf, 0, BUF_SIZE);
    return atoi(fgets(buf, BUF_SIZE, stdin));
}

char *input_str(unsigned len)
{
  char *buf = (char *)malloc(len);
  memset(buf, 0, len);
  fgets(buf, len, stdin);
  return buf;
}

int main(void)
{
  int n = input_int();

  char *buf = input_str((100 + 1) * 2);
  char *s = strtok(buf, " ");
  char *t = strtok(NULL, " ");

  for (int i = 0; i < n; i++) {
    printf("%c%c", *(s+i), *(t+i));
  }
  fputc('\n', stdout);
  free(buf);

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>

int B[10];
int C[10];
int ball[10];
int res = 0;

void solve(int i, int bi, int ci) {
  if (i == 10) {
    res = 1;
    return;
  }

  if (bi == 0) {
    B[bi] = ball[i];
    solve(++i, 1, ci);
    i--;
    B[bi] = 0;
  } else {
    if (ball[i] > B[bi-1]) {
      B[bi] = ball[i];
      solve(++i, ++bi, ci);
      B[bi] = 0;
      i--;
      bi--;
    }
  }

  if (ci == 0) {
    C[ci] = ball[i];
    solve(++i, bi, 1);
  } else {
    if (ball[i] > C[ci-1]) {
      C[ci] = ball[i];
      solve(++i, bi, ++ci);
    }
  }

}

int main() {
  int i,j;
  scanf("%d", &i);
  while(i) {
    for (j=0;j<10;j++)
      scanf("%d", &ball[j]);
    solve(0,0,0);
    if (res == 1) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
    i--;
    res = 0;
  }
  return 0;
}




Measured memory_bytes: 2672
package main

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

func main() {
	S := sc.next()
	if len(S) == 6 && S[2] == S[3] && S[4] == S[5] {
		yes()
	} else {
		no()
	}
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


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

int main(int argc, char **argv) {
	char s;
	cin >> s;
	if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u')
		cout << "vowel\n";
	else
		cout << "consonant\n";
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace KEYPC2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (N.Contains(1) && N.Contains(9) && N.Contains(7) && N.Contains(4))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N; 
    cin >> N;
    
    vector<int> L(N);
    for(int n=0; n<N; n++) {
        cin >> L[n];
    }
    
    sort(L.begin(), L.end());
    
    vector<int> bcL;
    vector<int> index;
    for(int n1=0; n1<N-1; n1++) {
        for(int n2=n1+1; n2<N; n2++) {
            bcL.push_back(L[n1]+L[n2]);
            index.push_back(n2+1);
        }
    }

    long long int count=0;
    for(int i=0; i<bcL.size(); i++) {
        count += lower_bound(L.begin(), L.end(), bcL[i]) - (L.begin()+index[i]);
        // cout << bcL[i] << endl;
        // cout << lower_bound(L.begin(), L.end(), bcL[i]) - (L.begin()+index[i]) << endl;
        // cout << endl;
    }
    
    cout << count << endl;

    return 0;
    
}

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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

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

int main(){

  char s[13];
  int max = -9999;
  int t;
  int i;
  char *n;

  scanf("%s", s);

  n = s;
  while(*n != '\0'){
    t = 0;
    while(*n == 'A' || *n == 'C' || *n == 'G' || *n == 'T'){
      n++;
      t++;
    }

    if(max < t) max = t;
    n++;
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int
main(void)
{
    int a, b, result;
    char op;
    while (scanf("%d %c %d", &a, &op, &b) && op != '?') {
        switch (op) {
            case '+':
                result = a + b;
                break;
            case '-':
                result = a - b;
                break;
            case '*':
                result = a * b;
                break;
            case '/':
                result = a / b;
        }
        printf("%d\n", result);
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;





int main() {

    ll n, m;
    cin >> n >> m;

    ll ans;
    if (n == 1) {
        if (m == 1) ans = 1;
        else if (m == 2) ans = 0;
        else ans = m - 2;
    }
    else if (n == 2) {
        ans = 0;
    }
    else {
        if (m == 1) ans = n - 2;
        else if (m == 2) ans = 0;
        else ans = m * n - 2 * (m + n) + 4;
    }

    out(ans);


    return 0;
}




//              g++ -std=c++1z






Measured memory_bytes: 888
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (1e9+7)
#define INF (1e9)
#define LLINF (4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

int main() {
    int N, L; input(N, L);
    ll sum = 0;
    int ans = INF;
    int a;
    REP(i, N) {
        sum += L + i;
        if (ans > abs(L + i)) {
            ans = abs(L + i);
            a = i;
        }
    }
    cout << sum - L - a << endl;
    getchar(); getchar();
}

Measured memory_bytes: 256
# 2019/06/22
# AtCoder Beginner Contest 131 - C

import fractions
# Least Common Multiple
def lcm_fgf(a, b):
    return int(a * b / fractions.gcd(a, b))

# Input
a, b, c, d = map(int,input().split())

clist = list()
dlist = list()
cdlist = list()

cd = lcm_fgf(c, d)

ccnt1 = (a - 1) // c
ccnt2 = b // c

dcnt1 = (a - 1) // d
dcnt2 = b // d

cdcnt1 = (a - 1) // cd
cdcnt2 = b // cd

ans = (b - a + 1) - ((ccnt2 - ccnt1) + (dcnt2 - dcnt1) - (cdcnt2 - cdcnt1))

# Output
print(ans)


Measured memory_bytes: 5076
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = 0;
        int f = 0;
        int r = 0;        
        
        while(true) {
            String str[] = br.readLine().split(" ");
            m = Integer.parseInt(str[0]);
            f = Integer.parseInt(str[1]);
            r = Integer.parseInt(str[2]);

            if (m == -1 && f == -1 && r == -1) {
                break;
            }
            if (m == -1 || f == -1)
                System.out.println("F");
            else if (m + f >= 80)
                System.out.println("A");
            else if (m + f >= 65)
                System.out.println("B");
            else if (m + f >= 50)
                System.out.println("C");
            else if (m + f >= 30) {
                if (r >= 50)
                    System.out.println("C");
                else
                    System.out.println("D");
            } else
                System.out.println("F");
        }
    }
}

Measured memory_bytes: 24148
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 1e5+10;
const int mode=1e9+7;
int N,k;
int a[105];
bool dp[MAXN][2];
bool vis[MAXN][2];
int dfs(int K,int p)
{
	if(vis[K][p])return dp[K][p];
	bool ans=0;
	for(int i=1;i<=N;++i)
	{
		if(K>=a[i]&&!dfs(K-a[i],!p))
		{
			ans=1;break;
		} 
	}
	vis[K][p]=1;
	return dp[K][p]=ans;
}
int main()
{
	IO;
	cin>>N>>k;
	for(int i=1;i<=N;++i)
	{
		cin>>a[i];
	}
	if(dfs(k,0)==0)puts("Second");
	else puts("First");
 } 


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

int main(void){
    int n,i,flag;
    flag = -1;

    cin >> n;

    vector<int> a(n);
    for(i=0; i<n; i++){
        cin >> a.at(i);
    }


    sort(a.begin(),a.end());

    for(i=0; i<n-1; i++){
        if(a.at(i+1) == a.at(i)){
            flag = 1;
            break;
        }
        flag = 0;
    }

    if(flag == 1){
        cout << "NO" << endl;
    }else if(flag == 0){
        cout << "YES" << endl;
    }else{
        cout << "-1" << endl;
    }

    return 0;
}

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

int main(){
  string S;
  cin >> S ;
  string divide[4] = {"dream","dreamer","erase","eraser"};
  reverse(S.begin(),S.end());
  for(int i =0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
  
  bool can = true;
  for(int i=0;i<S.size();){
    bool can2 = false;
    for(int j=0 ;j<4;j++){
      string d = divide[j];
      if(S.substr(i,d.size())==d){
        can2 = true;
         i += d.size();
      }
         }
         if(!can2){
           can = false;
         break;
         }
         }
         
         if(can) cout << "YES" <<endl;
         else cout << "NO" << endl;
         }

Measured memory_bytes: 512
s = input()
ans = 0
a = 0
i = 0
while i < len(s):
    c = s[i]
    if c == 'A':
        a += 1
    elif c == 'B':
        i += 1
        if i >= len(s):
            break
        c = s[i]
        if c == 'C':
            ans += a
        elif c == 'A':
            a = 1
        else:
            a = 0
    elif c == 'C':
        a = 0
    i += 1
print(ans)


Measured memory_bytes: 3500
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int Y = cin.ReadInt;
            int co_10000 = -1;
            int co_5000 = -1;
            int co_1000 = -1;
            for(int i=0; i<=N; i++)
            {
                for(int j=0; j<=N-i; j++) {
                    int money = i * 10000 + j * 5000 + (N - i - j) * 1000;
                    if (money == Y)
                    {
                        co_10000 = i;
                        co_5000 = j;
                        co_1000 = N - i - j;
                        j = N;
                        i = N;
                    }
                }
            }
            WriteLine("{0} {1} {2}", co_10000, co_5000, co_1000);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r;
  cin>>r;
  if(r<1200){
    cout<<"ABC"<<'\n';
  }
  if(r>=1200 && r<2800){
    cout<<"ARC"<<'\n';
  }
  if(r>=2800){
    cout<<"AGC"<<'\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;
long long int M;

long long int A[100005];

vector<long long int> S;

int main(void) {

	cin >> N >> M;
	long long int tmp;

	for (int i = 1; i <= N; i++) {
		cin >> tmp; A[i] = tmp;
	}

	S.push_back(0);
	for (int i = 1; i <= N; i++) {
		S.push_back((S[i - 1] + A[i]) % M);
	}

	/*for (int i = 0; i <= N; i++) {
		cout << "S[" <<i<<"]= " << S[i] << endl;
	}*/

	sort(S.begin(), S.end());
	S.push_back(10000000004);

	long long int ans = 0;

	int p, q;
	p = 0; q = 0;
	while (1) {
		while (S[p] == S[q]) { p++; }
		if (p > N+1) { break; }
		long long int h = p - q;
		ans += h*(h - 1) / 2;
		q = p;

	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

int main(void){
    long long A,B,K;cin>>A>>B>>K;
    for(long long i=A;i<=B;i++){
        if(i<=A+K-1||i>=B-K+1){
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int islands,n;
  cin>>islands>>n;
  vector<int>check;
  for(int i=0;i<n;i++){
  	int a,b;
  	cin>>a>>b;
  	if((a==1&&b==islands)||(a==islands&&b==1)){
  		continue;
  	}
  	if(a==1){
  		check.push_back(b);
  	}
  	if(b==islands){
  		check.push_back(a);
  	}
  }
  if(check.size()<=1){
  	cout<<"IMPOSSIBLE"<<endl;
  	return 0;
  }
  sort(check.begin(),check.end());
  for(int i=0;i<check.size()-1;i++){
  	if(check[i]==check[i+1]){
  		cout<<"POSSIBLE"<<endl;
  		return 0;
  	}
  }
  cout<<"IMPOSSIBLE"<<endl;
}




Measured memory_bytes: 1400