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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int x;
    int n;
    cin >> x >> n;
    vector<bool> flg(300, false);
    REP(i,n){
        int p;
        cin >> p;
        flg[p+100] = true;
    }

    int l,r;
    l = r = x+100;

    while(true){
        if(r>=300 && l<0)break;
        if(l>=0 && flg[l]==false){
            cout << l -100 << endl;
            break;
        }
        if(r<300 && flg[r] == false){
            cout << r-100 << endl;
            break;
        }
        l--;
        r++;
    }
}


Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
//typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
//const ll INFL = 1LL << 60;//10^18 = 2^60
const ll INFL = 1LL << 60;
const int INF = 1 << 30;//10^9
ll MOD = 1e9 + 7;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

//最大公約数
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main(void){
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll ans = 0;
  rep(i, N){
    if(i == 0){
      ans += A[i] / 2;
      A[i] %= 2;
    }else{
      if(A[i-1]){
        if(A[i]){
          ans += (A[i-1] + A[i]) / 2;
          A[i] = (A[i-1] + A[i]) % 2;
        }
      }else{
        ans += A[i] / 2;
        A[i] %= 2;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int count=0;
  long N;
  cin>>N;
  vector<int>B(N);
  vector<int>A(N);
  B[0]=99999399;
  rep(i,N-1){
    cin>>B[i+1];
  }
  A[N-1]=B[N-1];
  rep(i,N-1){
    A[N-2-i]=min(B[N-1-i],B[N-2-i]);
  }
  rep(i,N){
    count+=A[i];
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, x;
    cin >> N;
    vector<int> cnt(200002);
    for (int i = 0; i < N - 1; i++) {
        cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= N; i++) {
        cout << cnt[i] << '\n';
    }
}


Measured memory_bytes: 3984
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int cnt = 0;
        int[][] ar = new int[n][d];
        double[][] dist = new double[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                ar[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                for (int k = 0; k < d; k++) {
                    dist[i][j] += Math.pow(Math.abs(ar[i][k]-ar[j][k]),2);
                }
                dist[i][j] = Math.sqrt(dist[i][j]);
                if(dist[i][j]-(int)dist[i][j] == 0){
                    cnt++;
                }
            }
        }
        System.out.println(cnt);

    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

struct BIT { // 0 indexed
  int n;
  vector<ll> bit;
  BIT(int n) : n(n) {}
  BIT(vector<ll> v) {
    n = sz(v);
    bit.resize(n);
    rep(i, n) add(i, v[i]);
  }
  void add(int a, ll w) { for (int x = a; x < n; x |= x + 1) bit[x] += w; }
  ll sum(int a) { // [0, a)
    ll ret = 0;
    for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) ret += bit[x];
    return ret;
  }
  ll sum(int a, int b) { return sum(b) - sum(a); } // [a, b)
};

void solve() {
  int n, k;
  cin >> n >> k;
  vector<ll> v;
  // dp[i + 1][j] = \sum_{k = 1}^{n/j} dp[i][k]
  for (ll i = 1; i * i <= n; ++i) {
    v.eb(n / i); v.eb(i);
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  // 各ブロックの個数を求める
  rep(i, sz(v) - 1) v[i] = v[i + 1] - v[i];
  v.pop_back();
  v.insert(v.begin(), 1);
  // cout << v << '\n';
  vector<ll> dp = v;
  rep(i, k - 1) {
    BIT bit(dp);
    rep(j, sz(v)) dp[j] = bit.sum(sz(v) - j) % mod * v[j] % mod;
    // cout << dp << '\n';
  }
  cout << accumulate(all(dp), 0LL) % mod << '\n';
}


Measured memory_bytes: 2424
#include<stdio.h>

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    char map[h+2][w+2];
    for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            map[i][j] = '#';
        }
    }
    for(int i=0; i<h; i++){
        char s[w+1];
        scanf("%s", s);
        for(int j=0; j<w; j++){
            map[i+1][j+1] = s[j];
        }
    }
    int row[h+2][w+2], col[h+2][w+2];
    for(int i=0; i<=h+1; i++){
        int cnt = 1;
        for(int j=0; j<=w+1; j++){
            if(map[i][j] == '.'){
                row[i][j] = cnt;
                cnt += 1;
            }else{
                cnt = 1;
                row[i][j] = 0;
            }
        }
    }
    for(int i=0; i<=h+1; i++){
        int buf = -1;
        for(int j=w+1; j>=0; j--){
            if(map[i][j] == '.'){
                if(buf == -1){
                    buf = row[i][j];
                }else{
                    row[i][j] = buf;
                }
            }else{
                buf = -1;
            }
        }
    }
    for(int j=0; j<=w+1; j++){
        int cnt = 1;
        for(int i=0; i<=h+1; i++){
            if(map[i][j] == '.'){
                col[i][j] = cnt;
                cnt += 1;
            }else{
                cnt = 1;
                col[i][j] = 0;
            }
        }
    }
    for(int j=0; j<=w+1; j++){
        int buf = -1;
        for(int i=h+1; i>=0; i--){
            if(map[i][j] == '.'){
                if(buf == -1){
                    buf = col[i][j];
                }else{
                    col[i][j] = buf;
                }
            }else{
                buf = -1;
            }
        }
    }
    /*for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            printf("%c ", map[i][j]);
        }
        printf("\n");
    }
    printf("\n");    
    
    for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            printf("%d ", row[i][j]);
        }
        printf("\n");
    }
    printf("\n");
    for(int i=0; i<=h+1; i++){
        for(int j=0; j<=w+1; j++){
            printf("%d ", col[i][j]);
        }
        printf("\n");
    }
    printf("\n");*/
    int max = 0;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            if(map[i][j] == '#'){
                continue;
            }else{
                int buf = row[i][j] + col[i][j] - 1;
                if(max < buf){
                    max = buf;
                }
            }
        }
    }
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 35328
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号


int main(){
	string str;
	int m,a;
	
	REP(i,9){
		cin>>str>>m>>a;
		cout<<str<<" "<<m+a<<" "<<m*200+a*300<<endl;
	}
	return 0;
}

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

using Graph = vector< vector<int> >;


int main() {
    int N, M; cin >> N >> M;
    int h[N];
    for (int i = 0; i < N; i++)
    {
         cin >> h[i];
    }
    
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    int count = N;
    for (int v = 0; v < N; ++v) {
        for (auto next_v : G[v]) { 
            if(h[v] <= h[next_v]){
                count--;
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int  x,a,b;
  cin >> x>>a>>b;
  
  cout << (x-a)%b << endl;

  
}



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

#define SLAY ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("/Users/amrfahmy/Documents/Problem solving/CF/CF/input.txt", "r", stdin);
using namespace std;
 
const LL MOD = 1000000007;
LL arr[1000000];
LL b[1000];
LL n,q,c,cnt,mx,m,temp,k;
string s,t;



bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
    return (a.first < b.first);
}

int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}
    
 

    cin>>n;
    cin>>s>>t;
    string ans="";
    for(int i = 0 ; i < n ; i++){
        ans+=s[i];
        ans+=t[i];
    }
   
    cout<<ans;
    return 0;
}
 



Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
int main(void){
  int a, b, i, ans=0;
  scanf("%d %d", &a, &b);
  for(i=b;i<a+b;i++){
    ans+=i;
  }
  if(b>=0){
    ans-=b;
  }else if(b<0&&a>abs(b)){
  }else{
    ans=ans-i+1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
using System;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        int x = sc.NextInt();
        int y = sc.NextInt();

        int ans = int.MaxValue;
        if (x <= y) ans = Math.Min(ans, y - x);
        if (x <= (-y)) ans = Math.Min(ans, (-y) - x + 1);
        if ((-x) <= y) ans = Math.Min(ans, y - (-x) + 1);
        if ((-x) <= -y) ans = Math.Min(ans, (-y) - (-x) + 2);
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s = Console.ReadLine();
                while (s.Length == 0)
                {
                    s = Console.ReadLine();
                }

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 27476
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

long factorial(int n) {
    if (n == 0) return (long)1;
    return (long)2 * factorial(n - 1);
}

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> X(N, vector<int>(N, -1)), Y(N, vector<int>(N, -1));
    rep(i, N) {
        cin >> A.at(i);
        rep(j, A.at(i)) {
            cin >> X.at(i).at(j) >> Y.at(i).at(j);
            X.at(i).at(j)--;
        }
    }

    long max2= factorial(N);
    int cnt;
    int ans = 0;

    for (long i = 0; i < max2; i++) {
        //long temp = i;
        int flag = true;
        rep(j, N) {
            if ( ( (i >> j) & 1L ) == 0L) {                
                continue;
            }
            else {
                rep(k, A.at(j)) {
                    if ((( i >> X.at(j).at(k) ) & 1L ) != Y.at(j).at(k)) {
                        flag = false;
                        break;
                    }
                }
            }

            if (flag == false) break;

        }

        if (flag == true) {
            cnt = 0;
            rep(l, N) {                
                cnt += ((i >> l) & 1L);
            }
        }

        ans = max(ans, cnt);
    }

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

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_string(S),
    get_string(T),
    get_number(A),
    get_number(B),
    get_string(U),
    ((S = U) -> X is A - 1, writeln(X) ; writeln(A)),
    ((T = U) -> X is B - 1, writeln(X) ; writeln(B)).


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

using namespace std;

int main() {
  size_t N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  const char* s = S.c_str();
  auto l = locale::classic();
  for (size_t i = 0; i < N; i++) {
    if (i + 1 == K) {
      cout << tolower(s[i], l);
    } else {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
struct Grid{
  int h,w;
  vector<vector<bool>> grid;
  vector<vector<int>> d;
  vector<int> dx = {1,0,-1,0};
  vector<int> dy = {0,1,0,-1};
  
  Grid(int h_,int w_){
    h = h_;
    w = w_;
    grid.resize(h,vector<bool>(w));
  }

  Grid(int h_,int w_,vector<vector<bool>> grid_){
    h = h_;
    w = w_;
    grid = grid_;
  }
  
  void make_grid(int x,int y,bool c){
    grid[x][y] = c;
  }

  void grid_bfs(int sx,int sy){
    d.assign(h,vector<int>(w,-1));
    queue<pair<int,int>> q;
    d[sx][sy] = 0;
    q.push(make_pair(sx,sy));
    while(!q.empty()){
      pair<int,int> p = q.front();
      q.pop();
      int x = p.first;
      int y = p.second;
      for(int i=0;i<4;++i){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(nx>=0&&nx<h&&ny>=0&&ny<w){
	  if(grid[nx][ny]&&d[nx][ny]<0){
	    d[nx][ny] = d[x][y] + 1;
	    q.push(make_pair(nx,ny));
	  }
	}
      }
    }
  }

  int get_d(int x,int y){
    return d[x][y];
  }
  
};

int main()
{
  int h,w;
  cin >> h >> w;
  vector<vector<bool>> f(h,vector<bool>(w));
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      char c;
      cin >> c;
      if(c=='.'){
	f[i][j] = true;
      }
      else{
	f[i][j] = false;
      }
    }
  }
  Grid gd(h,w,f);
  int res = 0;
  rep(i,h){
    rep(j,w){
      if(!f[i][j]) continue;
      gd.grid_bfs(i,j);
      rep(k,h){
	rep(l,w){
	  int d = gd.get_d(k,l);
	  res = max(res,d);
	}
      }
    }
  }

  cout << res << "\n";

  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    char b[2];
    int x[4] = {0};
    int i;

    while (scanf("%d,%s", &n, b) != EOF)
    {
        if (b[0] == 'A' && b[1] == 'B'){
            x[2]++;
        }else if(b[0] == 'B'){
            x[1]++;
        }else if(b[0] == 'O'){
            x[3]++;
        }else{
            x[0]++;
        }
    }
    for (i = 0; i < 4; i++){
        printf("%d\n", x[i]);
    }

    return (0);
}


Measured memory_bytes: 2024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm> 
#include <vector> 

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL;

int x;

int main()
{
 scanf("%d",&x);
 if (x<1200) printf("ABC\n"); else printf("ARC\n");
 return 0;
}

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

using namespace std;

bool comp(long a, long b) {

    return (a < b); 
} 

int main() {

    long N, temp[3];
    cin >> N;
    long abc[N][3];
    long dystruct[3][N];

    for(int i = 0; i < N; i++) {

        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }

    dystruct[0][0] = abc[0][0];
    dystruct[1][0] = abc[0][1];
    dystruct[2][0] = abc[0][2];
    
    for(int i = 1 ; i < N; i++) {

        dystruct[0][i] = max(dystruct[1][i - 1], dystruct[2][i - 1]) + abc[i][0];
        dystruct[1][i] = max(dystruct[0][i - 1], dystruct[2][i - 1]) + abc[i][1];
        dystruct[2][i] = max(dystruct[0][i - 1], dystruct[1][i - 1]) + abc[i][2];
    }

    cout << max({dystruct[0][N - 1], dystruct[1][N - 1], dystruct[2][N - 1]}, comp);

    return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int h, w, d;
	cin >> h >> w >> d;
	vpint a(h*w);
	int x;
	rep(i, h) {
		rep(j, w) {
			cin >> x;
			a[x - 1].first = i;
			a[x - 1].second = j;
		}
	}
	int q;
	cin >> q;
	vpint b(q);
	rep(i, q) {
		cin >> b[i].first >> b[i].second;
	}
	vint c(h*w);
	rep(i, h*w - d) {
		if (i / d == 0) {
			c[i + d] = abs(a[i].first - a[i + d].first) + abs(a[i].second - a[i + d].second);
		}
		else {
			c[i + d] = c[i] + abs(a[i].first - a[i + d].first) + abs(a[i].second - a[i + d].second);
		}
	}
	int left;
	int right;
	rep(i, q) {
		if (b[i].first <= d) {
			left = 0;
		}
		else {
			left = c[b[i].first - 1];
		}
		if (b[i].second <= d) {
			right = 0;
		}
		else {
			right = c[b[i].second - 1];
		}
		cout << right - left << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,pi> pii;
typedef pair<pi,int> pip;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll x, ll y){
	if (x == y) return x;
	return x + ((rng()*rng())%(y-x+1)+(y-x+1))%(y-x+1);
}

int subtask, N, A[200005], ans[200005], cnt = 0, m1[200005], m2[200005];


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> A[i];
	}
	for (int i = 0; i <= N+1; ++i){
		m1[i] = m2[i] = 0;
	}
	for (int i = 1; i <= N; ++i){
		m1[i] = max(m1[i-1],A[i]);
		m2[N-i+1] = max(m2[N-i+2],A[N-i+1]);
	}
	for (int i = 1; i <= N; ++i){
		ans[i] = max(m1[i-1],m2[i+1]);
	}
	for (int i = 1; i <= N; ++i){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 4736
#include<cstdio>
#include<algorithm>
#define MAX 100005
#define MAXH 1000000005
using namespace std;
 
int main(){
  long long n, a, b, h[MAX], l, r, mid, i, c, d;
  scanf("%lld%lld%lld", &n, &a, &b);
  for(i = 0; i < n; i++) scanf("%lld", &h[i]);
  l = 0; r = MAXH;
  while(r - l > 1){
    mid = (l + r) / 2;
    c = 0;
    for(i = 0; i < n; i++){
      d = h[i] - b * mid;
      if(d > 0) c += (d - 1) / (a - b) + 1;
    }
    if(c <= mid) r = mid;
    else l = mid;
  }
  printf("%lld", r);
}

Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <stdlib.h>
using namespace std;
typedef long long int ll;
ll a, b, c;
ll ans=1e18+5;
int main(void)
{
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0)
	{
		cout<<0;
	}
	else
	{
		if(a%2==1)
		{
			ans=min(ans,b*c);
		}
		if(b%2==1)
		{
			ans=min(ans,c*a);
		}
		if(c%2==1)
		{
			ans=min(ans,a*b);
		}
		cout<<ans;
	}
	
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
    int a[150];
    main()
    {
        int n, x;
        cin >> n >> x;
        int suma = 0;
        int m = x;
        int ans = 0;
        for(int i = 1 ; i <= n;i++)
            cin >> a[i];
        sort(a+1,a+n+1);
        int cnt = 0;
            int maxe = 0;
            for(int j = 1 ; j <= n;j++)
            {
                if(m == a[j] and j == n){

                    cnt++;
                    break;
                }
                if(m > a[j] and j == n){
                    break;
                }
                if(m >= a[j]){
                    m -= a[j];
                    cnt++;


                }




            }

            maxe = max(cnt,maxe);
            m = x;
            cnt = 0;
            for(int i = n ; i >= 1;i--)
            {
                if(m == a[i] and i == 1){
                    cnt++;
                    break;
                }
                if(m > a[i] and i == 1){
                    break;
                }
                if(m >= a[i]){
                    m -= a[i];
                    cnt++;


                }




            }
            maxe = max(cnt,maxe);
            cout << maxe;




    }


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
S = [input() for _ in range(N)]
march = ["M", "A", "R", "C", "H"]

cnt = defaultdict(int)

for s in S:
	if s[0] in march:
		cnt[s[0]] += 1

#print(march_lis)
ans = 0
#print(cnt)
#print(cnt.keys())
#print(cnt.values())

for x, y, z in combinations(cnt.values(), 3):
	#print(x, y, z)
	ans += x*y*z
print(ans)

Measured memory_bytes: 19952
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,l,r) for(int i=(l),i##_len=(r);i<r;++i)
#define int long long
using namespace std;
constexpr int mod = 1e9+7;
signed main(){
    typedef vector<int> vi;
    typedef vector<vi> vvi;
    typedef vector<vvi> vvvi;
    string K;cin>>K;
    int D;cin>>D;
    int N=K.size();
    vvvi dp(N+1,vvi(D,vi(2,0)));
    //dp[i][j][k]:i桁目までで総和をDで割った余りがjであるもの,k=1ならばKに一致
    dp[0][0][1]=1;
    REP(i,K.size()) REP(j,D){
        REP(k,10){
            (dp[i+1][(j+k)%D][0]+=dp[i][j][0])%=mod;
            if(k<K[i]-'0') (dp[i+1][(j+k)%D][0]+=dp[i][j][1])%=mod;
            if(k==K[i]-'0') (dp[i+1][(j+k)%D][1]+=dp[i][j][1])%=mod;
        }
    }
    cout<<(dp[N][0][0]+dp[N][0][1]+mod-1)%mod<<endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
int n;
int dp1[1000005], dp2[1000005];
vector<int> sei5, sei5_odd;
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    for(int i = 1; ; i++){
        int x = i * (i+1) * (i+2) / 6;
        if(x > 1000000) break;
        sei5.pb(x);
        if(x % 2 == 1) sei5_odd.pb(x);
    }

    REP(i, 1000001){
        dp1[i] = INF;
        dp2[i] = INF;
    }
    dp1[0] = 0;
    dp2[0] = 0;
    FOR(i, 1, 1000001){
        REP(j, sei5.size()){
            if(i-sei5[j] < 0) break;
            dp1[i] = min(dp1[i], dp1[i-sei5[j]] + 1);
        }
    }
    FOR(i, 1, 1000001){
        REP(j, sei5_odd.size()){
            if(i-sei5_odd[j] < 0) break;
            dp2[i] = min(dp2[i], dp2[i-sei5_odd[j]] + 1);
        }
    }
    while(cin >> n, n){
        cout << dp1[n] << " " << dp2[n] << endl;
    }
}



Measured memory_bytes: 10924
/*
Author : N_o_o_B
Created : June 14 2020 17:29:43 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int x[5];
    fori(i,5) {
        cin >> x[i];
        if(x[i]==0) {
            cout << i+1 << endl;
            return 0;
        }
    }


    time_taken();
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N,A;
cin>>N;
bool judge=true;
vector<long long> v;
for(int i=0;i<N;++i){
  cin>>A;
  v.push_back(A);
  }
std::sort(v.begin(),v.end());
for(int i=1;i<N;++i){
  if(v[i-1]==v[i]){
    judge=false;
    break;
  }
}
if(judge){
  cout<<"YES"<<"\n";
}
else{
  cout<<"NO"<<"\n";
}
return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,k; cin >> n >> k;
	vector<ll> a(n),b(n),c(n);
	for(ll i=0;i<n;i++){
		c[i]=k+2*n+i;
	}
	for(ll i=0;i<n;i+=2){
		a[i]=k+i/2;
		b[i]=k+n+(n+1)/2+i/2+(n%2^1)-1;
	}
	for(ll i=1;i<n;i+=2){
		a[i]=k+(n+1)/2+i/2;
		b[i]=k+n+i/2;
	}
	for(ll i=0;i<n;i++){
		if(c[i]<a[i]+b[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	for(ll i=0;i<n;i++){
		cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}
}

Measured memory_bytes: 4608
#pragma region Macros
#include <bits/stdc++.h>
#define int long long
using ll = long long;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b+a); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#pragma endregion

set<string> st;

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

  int n;
  cin >> n;

  // st.resize(n);

  rep(i,n) {
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;

  return 0;
}


Measured memory_bytes: 19136
/**Bismillahir Rahmanir Rahim.**/
#include<stdio.h>
#include<string.h>
int main()
{
    int want_time,want_takoyaki,time,takoyaki,a,b;
    scanf("%d %d %d",&want_takoyaki,&takoyaki,&time);
    if(want_takoyaki<=takoyaki)
    {
        printf("%d",time);
    }
    else
    {
        if(want_takoyaki%takoyaki==0)
        {
            printf("%d",(want_takoyaki/takoyaki)*time);
        }
        else
        {
            printf("%d",((want_takoyaki/takoyaki)+1)*time);
        }
    }
    return 0;
}


Measured memory_bytes: 1732
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<string> S(H);
	for (int i = 0; i < H; i++) cin >> S[i];

	vector<int> dxdy{ -1,0,1 };
	for (int row = 0; row < H; row++) {
		for (int col = 0; col < W; col++) {
			if (S[row][col] == '.') {
				
				int cnt = 0;
				for (const auto &dx : dxdy) {
					for (const auto &dy: dxdy) {
						if (0 <= row + dx && row + dx < H
							&& 0 <= col + dy && col + dy < W
							 && S[row + dx][col +dy] == '#') cnt++;
					}
				}
				cout << cnt;
			}
			else cout << "#";
		}
		cout << "\n";
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			double n = sc.nextInt();
			// 出力(整数)
			double z = n % 2 == 0 ? n / 2 : (n + 1) / 2;
			double result = z / n;
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 21844
def sum_of_three_integers(K: int, S: int)->int:
    count = 0
    for x in range(K+1):
        for y in range(x, K+1):
            z = S - (x + y)

            if z < 0 or K < z:
                # out of range
                continue

            if z < y:
                # x <= y <= z の場合だけ考えて計算回数を減らしたい。
                break

            if x == y and y == z:
                # 全文字一緒なら 1 通り
                count += 1
            elif x == y or y == z:
                # 同じ文字が 2 つだけなら 3C1 = 3 通り
                count += 3
            else:
                # 全て違う文字なら 3P3 = 6 通り
                count += 6
    return count


if __name__ == "__main__":
    K, S = map(int, input().split())
    ans = sum_of_three_integers(K, S)
    print(ans)


Measured memory_bytes: 3060
using System;

namespace test01
{
    class Program
    {
        static void Main(string[] args)
        {
            string i = Console.ReadLine();
            string[] ArryNum = i.Split();

            int a = int.Parse(ArryNum[0]);
            int b = int.Parse(ArryNum[1]);

            Console.Write(a * b);
            Console.WriteLine(" " + (a+b) * 2);
        }
    }
}

Measured memory_bytes: 17880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;
int a[305][305], b[305], c[305];
bool used[305];

bool C(int x) {
	fill(b, b+m+1, 0);
	fill(c, c+n, 0);
	fill(used, used+m+1, false);
	FOR(i, n) b[a[i][c[i]]]++;
	while (true) {
		bool ok = true;
		FOR(i, n) {
			if (b[a[i][c[i]]] > x) {
				used[a[i][c[i]]] = true;
				ok = false;
			}
		}
		if (ok) break;
		FOR(i, n) {
			if (used[a[i][c[i]]]) {
				while (used[a[i][c[i]]]) c[i]++;
				if (c[i] >= m) return false;
				b[a[i][c[i]]]++;
			}
		}
	}
	return true;
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	FOR(i, n) {
		FOR(j, m) cin >> a[i][j];
	}
	int l = 1, r = n;
	while (r > l) {
		int mid = (l+r)/2;
		if (C(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}

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

int main(){
    int r,c;
    cin >> r >> c;
    int x[r+1][c+1] = {};
    //入力、一番右の列を埋める
    for(int i = 0; i < r; i++){
        int sum = 0;
        for(int j = 0; j < c; j++){
            cin >> x[i][j];
            sum += x[i][j];
        }
        x[i][c] = sum;
    }

    //一番下の列を埋める
    for(int i = 0; i <= c; i++){
        int sum = 0;
        for(int j = 0; j <= r; j++){
            sum += x[j][i];
        }
        x[r][i] = sum;
    }

    for(int i = 0; i <=r; i++){
        for(int j = 0; j <= c; j++){
            if(j != c)cout << x[i][j] << " ";
            else cout << x[i][j];
        }
        cout << endl;
    }



    return 0;
}


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

using namespace std;;
int n;
int k;
vector<int>a;
int memo[100001];

int dp(int i){
    if(i == n-1){
        return 0;
    }
    if(memo[i] !=-1) return memo[i];
    int ans = 1e9;
    int j = 1;
    while(j <= k && i < n-j){
        ans = min(ans,dp(i+j)+abs(a[i]-a[i+j]));
        j++;
    }
    return memo[i] = ans;
}


int main(){
    memset(memo,-1,sizeof(memo));
    cin >> n >> k;
    a.resize(n);
    for(int&i: a) cin >> i;
    cout << dp(0);

}


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

int main()
{
	int A, B;
	int max;
	cin >> A >> B;
	int a1, a2, a3;
	
	a1 = A + B;
	a2 = A - B;
	a3 = A * B;
	
	// cout << max({a + b, a - b, a * b}) << endl;

	if (a1 > a2) {
		if (a1 > a3) {
			max = a1;
		}
		else {
			max = a3;
		}
	}
	else if (a2 > a3) {
		max = a2;
		
	}
	else {
		max = a3;
	}

	cout << max;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

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

	int a, b;
	cin >> a >> b;
	if(a * b % 2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
}


Measured memory_bytes: 256
N ,M ,X ,Y = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
ylist = list(map(int,input().strip().split()))
 
x_max = X
y_min = Y
 
for i in range(0,N):
    x_max = max(int(xlist[i]),x_max)
 
for i in range(0,M):
    y_min = min(int(ylist[i]),y_min)

if x_max < y_min:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int i, j, k;
        String moji = "";
        int count[] = new int[26];
        while(sc.hasNextLine()) {
            moji += sc.nextLine();
        }
        moji = moji.toLowerCase();
        for(i = 0; i < moji.length(); i++) {
            char c = moji.charAt(i);
            if('a' <= c && 'z' >= c) {
                count[c - 'a']++;
            }
        }
        for(i = 0; i < 26; i++) {
            System.out.println((char)(i + 'a') + " : " + count[i]);
        }
    }
}


Measured memory_bytes: 26128
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int primes[3000];
int siz = 0;
int num[40000]={0};
bool isprime[200000]={false};

int main() {
  for(int i=2;i<20000;i++){
    if(isprime[i])continue;
    primes[siz++]=i;
    for(int j=i*2;j<20000;j+=i){
      isprime[j]=true;
    }
  }
  for(int a=0;primes[a]<=15000;a++){
    for(int b=a;primes[b]<=15000;b++){
      for(int c=b;primes[c]<=15000;c++){
        if(primes[a]+primes[b]<=primes[c])continue;
        if(primes[a]+primes[b]+primes[c]>30000)continue;
        num[primes[a]+primes[b]+primes[c]]++;
        // LOG("%d %d %d\n",primes[a],primes[b],primes[c]);
      }
    }
  }
  // cout << "end works" << endl;

  int T;
  while(cin>>T,T){
    cout << num[T] << endl;
  }
}

Measured memory_bytes: 1320
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    if(a.equals(b) || b.equals(a)){
      System.out.println("H");
    }
    else{
      System.out.println("D");
    }
  }
}


Measured memory_bytes: 23252
#include<stdio.h>

int main(void){
    int A[52]={0};
    int N=0;
    int CP=0;
    int CN=0;
    int count=0;
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
        if(A[i]!=i){
            if(CP!=0){
                if(count==1){
                     printf("NO\n");
                     return 0;
                }
                if(CP==A[i]&&CN==i){
                    count=1;
                }
                else{
                      printf("NO\n");
                      return 0;
                }
            }
            else{
                CP=i;
                CN=A[i];
            }
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

template<class T = ll>
T in() {
    T x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll x, y, z, k;
        cin >> x >> y >> z >> k;
        vll a(x), b(y), c(z);
        rep(i, x) a[i] = in();
        rep(i, y) b[i] = in();
        rep(i, z) c[i] = in();

        vll ab;
        rep(i, x) rep(j, y) ab.eb(a[i] + b[j]);
        sort(all(ab), greater<>());
        sort(all(c), greater<>());

        vll ans(k);
        rep(i, min(x * y, k)) {
            rep(j, min(z, k)) {
                ans.eb(ab[i] + c[j]);
            }
        }
        sort(all(ans), greater<>());
        rep(i, k) cout << ans[i] << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 39928
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int  n = sc.nextInt();
    int  m = sc.nextInt();    
    int[] a = new int[m];
    int sum = 0;
    for(int i = 0;i < m;i++){
      a[i] = sc.nextInt();
      sum += a[i];
    }
    if(n >= sum){
      System.out.println(n - sum);
    }else{
      System.out.println("-1");
    }
  }
}

Measured memory_bytes: 46488