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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL

template<typename T>
void show(vector<T>& v) {
    cout << '[';
    for (const T& e : v) {
        cout << e << ',';
    }
    cout << ']' << endl;
}

#endif

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

template<typename T>
vector<T> read_n(const size_t n) {
    T dummy;
    vector<T> v(n);
    for (size_t i = 0; i < n; i++) {
        cin >> dummy;
        v[i] = dummy;
    }
    return v;
}

template<typename T>
vector<T> read_n() {
    size_t n;
    cin >> n;
    return read_n<T>(n);
}

int main() {
  init();

  int n;
  cin >> n;
  vector<int> btns = read_n<int>(n);

  bool ok = true;
  int point = 1;
  int res = 0;
  while (point != 2) {
      const int p = point;
      point = btns[point - 1];
      if (point == -1) {
          ok = false;
          break;
      }
      btns[p - 1] = -1;
      res++;
  }

  cout << (ok ? res : -1) << endl;

  return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

const int maxn = 1e5 + 10;

bool good[maxn];
int h[maxn];

bool repeat[maxn];

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

    int n, m; cin >> n >> m;

    int a, b;

    memset(good, true, sizeof(good));
    memset(repeat, false, sizeof(repeat));

    rep(i, 1, n + 1) {
        cin >> h[i];
    }

    rep(i, 0, m) {
        cin >> a >> b;
        if (h[a] > h[b]) {
            if (!repeat[a]) good[a] = true;
            good[b] = false;
            repeat[b] = true;
        }
        else if (h[a] < h[b]) {
            if (!repeat[b]) good[b] = true;
            good[a] = false;
            repeat[a] = true;
        } else {
            good[a] = false; good[b] = false;
            repeat[a] = true; repeat[b] = true;
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (good[i]) ans++;
    }

    cout << ans;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt(), W = sc.nextInt();
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                String cur = sc.next();
                if(!cur.equals("snuke")) continue;
                char col = (char)(j-1+'A');
                String ans = Character.toString(col)+Integer.toString(i);
                System.out.println(ans);
                return;
            }
        }
    }
}


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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pb2 pop_back
#define pf push_front
#define pf2 pop_front
#define line printf("\n")
#define rep(k,i,j) for(int k = (int)i;k<(int) j;k++)
#define repd(k,i,j) for(int k = i;k>=(int)j;k--)
#define ll long long
#define pq priority_queue

int dirx[8] = {0,1,0,-1,1,1,-1,-1};
int diry[8] = {1,0,-1,0,1,-1,1,-1};

const int INF = 1e9+7;
const ll INFLL = 1e16;
const double EPS = 1e-6;

using namespace std;

const int maxn = 2e5+5;

int n,v;
int loc[maxn];

int jump[maxn][20],m;

int dp[maxn*10];

int ch[maxn*10];

int in_q[maxn*10];

queue<int> q;
int solve(){
	while(q.size())q.pop();
	memset(dp,-1,sizeof dp);
	memset(in_q,0,sizeof in_q);
	
	q.push(1);
	dp[1] = ch[0];
	in_q[1] = 1;
	
	
	while(q.size()){
		int mask = q.front();
		int a = dp[mask];
		
		q.pop();
		in_q[mask] = 0;
		
		if(a==n)return 1;
		rep(k,0,m)if(((1<<k)&mask)==0){
			int b = ch[jump[a][k]];
			int maskb = (mask|(1<<k));
			
			if(dp[maskb]<b){
				dp[maskb] = b;
				if(!in_q[maskb])q.push(maskb),in_q[maskb] = 1;
			}
		}
	}
	
	return 0;
}
int main(){
	scanf("%d%d",&n,&v);
	
	rep(k,0,n)scanf("%d",&loc[k]);
	
	
	for(;v>=0;v/=2){
		rep(k,0,n){
			int i = k;
			while(i<n){
				if(i<n-1 && loc[i+1]-loc[i]<=v){
					i++;
				}
				else break;
			}
			while(k<=i)jump[k++][m] = i+1;
			k = i;
		}
		//printf("%d \n",v);
		m++;
		if(v==0)break;
	}
	
	if(m>=20)return 0;
	
	rep(k,0,maxn)ch[k] = k;
	
	int hit = 0;
	rep(k,0,n){
		if(hit>20){
			printf("Impossible\n");
			continue;
		}
		int nxt = jump[k][0];
		
		hit++;
		ch[k] = nxt;
		int ret = solve();
		ch[k] = k;
		
		while(k<nxt)printf("%s\n",ret?"Possible":"Impossible"),k++;
		k = nxt-1;
	}
	
	return 0;
}

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

int main() {
    int n, r = 0;;

    cin >> n;

    for (int i = 0; i < n; ++i) {
        int a;

        cin >> a;

        if (i == 0) {
            int c = 0;

            while (a % 2 == 0)
                a /= 2, c++;

            r = c;
        } else {
            int c = 0;

            //3
            while (a % 2 == 0 && c < r)
                a /= 2, c++;

            r = c;

        }
    }

    cout << r;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int k;
ll cost(ll dp[],int h[],int x)
{
    if(dp[x]!=-1) return dp[x];
    else
    {   ll miin=abs(h[x-1]-h[x])+cost(dp,h,x-1);
        for(int i=2;i<=k&&x-i>=0;i++){
         ll c= abs(h[x-i]-h[x])+cost(dp,h,x-i);
         if(c<miin)
            miin=c;
       }
       dp[x]=miin;
        return dp[x];
    }
    
}
int main()
{   int n;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    ll dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    cout<<cost(dp,h,n-1);

    return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid &x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid &x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

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

  map<int, map<int, int>> mp;
  i64 ans = 0;
  REP(i, N) {
    string s;
    cin >> s;
    size_t j = s.find('.');
    i64 x;
    int d;
    if (j == string::npos) {
      x = stoll(s);
      d = 0;
    } else {
      string a = s.substr(0, j);
      string b = s.substr(j + 1);
      d = -b.size();
      x = stoll(a + b);
    }

    int d2 = d;
    while (x % 2 == 0) {
      x /= 2;
      ++d2;
    }
    int d5 = d;
    while (x % 5 == 0) {
      x /= 5;
      ++d5;
    }

    i64 cnt = 0;
    auto it1 = mp.lower_bound(-d5);
    for (; it1 != mp.end(); ++it1) {
      auto it2 = it1->second.lower_bound(-d2);
      for (; it2 != it1->second.end(); ++it2) {
        cnt += it2->second;
      }
    }
    ans += cnt;
    mp[d5][d2]++;
    // DEBUG(x, d, d2, d5);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

void solve()
{
  ll n;
  cin>>n;
  ll k=n/500;
  n-=500*k;
  ll d=n/5;
  cout<<(k*1000)+(d*5)<<endl;
}

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

        solve();

    return 0;
}



Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
while True:
    count=0
    n,x = [int(a)for a in input().split(' ')]
    if n+x==0:
        break
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1,n+1):
                if i + j + k ==x:
                    count += 1
    print(count)

Measured memory_bytes: 7724
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {


        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int max = n - (k - 1);
            int min = k == 1 ? max : 1;
            out.println(max - min);
        }


    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            //reader = new BufferedReader(new FileReader(stream), 32768);
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return "";
        }

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

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

        public void close() {
        }

    }
}


Measured memory_bytes: 23380
open System
open System.Collections.Generic
open System.Linq
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ReadIntTriple () = ReadTriple () |> FuncTriple int int int
let ReadIntDouble () = ReadDouble () |> FuncDouble int int

let ensmallen l = l % 1000000007L

let manhattan x y = abs (fst x - fst y) + abs (snd x - snd y)


let sayYESNO b = if b then Puts "YES" else Puts "NO"

// main code

let n, m = ReadIntDouble()

let occurence: int [] = Array.zeroCreate n

for _ in 1..m do
    let a, b = ReadIntDouble()
    occurence.[a-1] <- occurence.[a-1] + 1
    occurence.[b-1] <- occurence.[b-1] + 1

occurence |> Seq.iter Console.WriteLine


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

int main() {
  int N;
  cin >> N;
  bool judge = false;
  for (int i = 0; i < N; i++){
    int A;
    cin >> A;
    if (A % 2 == 0){
      if (A % 3 != 0 && A % 5 != 0){
        judge = true;
        break;
      }
    }
  }
  if (judge){
    cout << "DENIED" << endl;
  }
  else{
    cout << "APPROVED" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * main
 */
int main () {
  using Cell = pair<int, bool>;

  vector<Cell> t;

  for (int i = 0; i < 9; i++) {
    int input;
    cin >> input;
    t.push_back(make_pair(input, false));
  }

  int N;
  cin >> N;

  while (N--) {
    int input;
    cin >> input;

    for (int i = 0; i < 9; i++) {
      if (t.at(i).first == input) t.at(i).second = true;
    }
  }

  auto f = [&](int a, int b, int c) {
    return (t.at(a).second && t.at(b).second && t.at(c).second);
  };

  if (f(0, 3, 6) || f(1, 4, 7) || f(2, 5, 8) || f(0, 1, 2) || f(3, 4, 5) || f(6, 7, 8) || f(0, 4, 8) || f(2, 4, 6)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
using System;

namespace pro
{




    class MainClass
    {
        public static void Main()
        {

            string s = Console.ReadLine();
            if (s == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            else if (s == "Cloudy")
            {
                Console.WriteLine("Rainy");
            }
            else if (s == "Rainy")
            {
                Console.WriteLine("Sunny");
            }



        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;

 
const int maxN = 1e5+10;

const int INF = 1e9+6;
const int MOD = 1e9+7;


int n,k;
int a[maxN];
int b[maxN];
int main() {
	scanf("%d",&n);
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		b[a[i]] = i;
	}
	for(int i=1;i<n;i++)
	{
		printf("%d ",b[i]);
	}
	cout<<b[n]<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> to[n];
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  int root = -1;
  queue<int> q;
  vector<int> p(n, -1);
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : to[u]) {
      if (v == p[u]) continue;
      p[v] = u;
      q.push(v);
    }
  }
  rep(i, n) if (p[i] == -1) root = i;

  ll ans = k;
  q.push(root);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int d = k - 2;
    if (u == root) ++d;
    for (auto v : to[u]) {
      if (v == p[u]) continue;
      ans = ans * d % mod;
      --d;
      q.push(v);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9916
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 16

using namespace std;

ll v[maxn+5][maxn+5], best[(1<<maxn)+5], contrib[(1<<maxn)+5];
bool viz[(1<<maxn)+5];

void umax (ll &a, ll b) { a = max(a,b); }
ll Dp (int conf) {
  if (__builtin_popcount(conf) <= 1) return 0;
  if (viz[conf]) return best[conf];
  viz[conf] = 1;
  int conn, conp;
  for (conn = conf; conn > 0; conn = (conn-1)&conf) {
    conp = conf-conn;///conn=ce bagi in aceeasi grupa, conp iei din Dp
    umax(best[conf], contrib[conn] + Dp(conp));
  }
  return best[conf];
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z, conf;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> v[i][j];
  for (conf = 0; conf < (1<<n); conf++)
    for (i = 0; i < n; i++)
      for (j = i+1; j < n; j++)
        if ((conf & (1<<i)) && (conf & (1<<j))) contrib[conf] += v[i][j];
  for (conf = 0; conf < (1<<n); conf++) best[conf] = -infl;
  cout << Dp((1<<n)-1);
  return 0;
}


Measured memory_bytes: 1408
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int rui[6010][6010];

int n, k;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'B') y += k;
		x %= 2 * k;
		y %= 2 * k;
		for (int j = 0; j < 4; j++) {
			for (int l = 0; l < 4; l++) {
				if ((j + l) % 2 == 1)continue;
				rui[x + j*k][y + l*k]++;
				rui[x + j*k + k][y + l*k]--;
				rui[x + j*k][y + l*k + k]--;
				rui[x + j*k + k][y + l*k + k]++;
			}
		}
	}
	for (int i = 1; i < 6000; i++) {
		for (int j = 0; j < 6000; j++) {
			rui[i][j] += rui[i - 1][j];
		}
	}
	for (int i = 0; i < 6000; i++) {
		for (int j = 1; j < 6000; j++) {
			rui[i][j] += rui[i][j - 1];
		}
	}
	int ans = 0;
	for (int i = 0; i < 6000; i++) {
		for (int j = 0; j < 6000; j++) {
			ans = max(ans, rui[i][j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 141056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, char const *argv[])
{
    int n,m;cin>>n>>m;
    int a;
    vector<long long> dp(n+1,0);
    for(int i=0;i<m;++i){
        cin>>a;
        dp[a]=-1;
    }
    dp[0]=1;
    for(int i=1;i<=n;++i){
        if(dp[i]!=-1){
            if(i>=2){
                if(dp[i-2]!=-1)dp[i]+=dp[i-2];
            }
            if(dp[i-1]!=-1)dp[i]+=dp[i-1];
            dp[i]%=1000000007;
        }
        else
        {
            if(dp[i-1]==-1){
                dp[n]=0;
                break;
            }
        }

        
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main() {
    char S[11],T[12];	//Char型宣言
    int i;
    
    scanf("%s %s",S,T);	//標準入力の取得
    
    for (i = 0;S[i] != '\0';i++){
        if (S[i] != T[i]){
            printf("No\n");
            return 0;
        }
    }
 
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  string S;
  vector<long long int> l_v;
  cin >> N;
  l_v.push_back(2);
  l_v.push_back(1);
  
  for (int i = 2; i <= N; i++) {
    long long int l = l_v[i-1] + l_v[i-2];
    l_v.push_back(l);
  }
  cout << l_v[N] << endl;
  return 0;
}


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

using namespace std;

string s;
int f[maxn][3],n;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   // freopen("in.txt","r",stdin);
    cin>>s;
    n = s.length();
    for (int i=0;i<n;i++)
        for (int k=0;k<3;k++) f[i][k]=-1;
    f[0][0]=0;
    for (int i=0;i<n;i++)
        for (int j=0;j<3;j++) {
            if (f[i][j]==-1) continue;
            for (int k=1;k<3;k++) {
                if (i+k>n) continue;
                if (j!=k || s.substr(i-j,j)!=s.substr(i,k)) f[i+k][k] = max(f[i+k][k],f[i][j]+1);
            }
            //cout<<f[i][j]<<endl;
        }
    int ans=0;
    for (int i=0;i<3;i++) ans=max(ans,f[n][i]);
    cout<<ans;
}


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

int main(){
    
    int x;
    cin>>x;
    
    int h = x / 3600;
    int m =  (x/60) %60;
    int s =  x % 60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3104
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
//long long solve(long long test)
//{
//    int cnt=0;
//    while(test)
//    {
//        tmp[++cnt]=test%10;
//        test/=10;
//    }
//    return dfs(cnt,0,1,1);
//}
ll a[1000010];
ll cnt=0;
void solve()
{
	ll n;
	cin>>n;
	int x=0;
	for(int i=1;i<=n;i++)
		cin>>a[i],x=x^a[i];
	for(int i=1;i<=n;i++)
		cout<<(x^a[i])<<" ";
	cout<<endl;
}
int main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



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

int main(){
    int n,A[100]={},l,c = 0;

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> l;
        A[i] = l;
    }
    

    for (int i = 0;  i < n; i++){
        for (int j = n - 1; i < j; j--){
            if (A[j] < A[j-1]){
                int a = A[j-1];
                A[j-1] = A[j];
                A[j] = a;
                c += 1;
            }
        }
    }

    for (int i = 0; i < n; i++){
        if (i == n-1){
            cout << A[i] << '\n';
        }
        else {
            cout << A[i] << " ";
        }
    }
    cout << c << '\n';
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  set<string> S;
  int N;
  cin >> N;
  string K;
  for(int i=0;i<N;i++){
    cin >> K;
    S.insert(K);
  }
  cout << S.size() << endl;
}
    

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


int main() {
  int N;
  cin >> N;
  int num = 0;
  while(N--) {
    string S;
    cin >> S;
    if(S == "A") num++;
    else num--;
    if(num < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if(num == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
    return 0;
}



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

#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1000000007;
const ll DIV = 13;

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

	ll N = s.size();
	vector<vector<ll>> dp(N+1, vector <ll> (13, 0));
	ll base = 1;
	for (ll ii = N-1; ii >= 0; --ii){
		ll keta = N-1 - ii;
		if (ii < N-1){
			base = (base * 10) % DIV;  
		}
		ll num = (s[ii] == '?') ? -1 : s[ii] - '0';

		if (keta == 0){
			if (num == -1){
				for (int kk = 0; kk < 10; ++kk){
					dp[keta+1][kk] = 1;
				}
			} else {
				dp[keta+1][num] = 1;
			}
		} else {
			if (num == -1){
				for (int kk = 0; kk < 10; ++kk){
					ll cont = (base * kk) % DIV;
					for (int jj = 0; jj < DIV; ++jj){
						dp[keta+1][(jj+cont)%DIV] = (dp[keta+1][(jj+cont)%DIV] + dp[keta][jj]) % MOD;
					}
				}
			} else {
				ll cont = (base * num) % DIV;
				for (int jj = 0; jj < DIV; ++jj){
					dp[keta+1][(jj+cont)%DIV] = dp[keta][jj];
				}
			}
		}
	}

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

	return 0;
}


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

struct tree{int p,l,r,s,dg,dp,h;};

tree t[30];


void depth(int n,int d){
  if(n==-1)return;
  t[n].dp=d;
  depth(t[n].l,d+1),depth(t[n].r,d+1);
}

void height(int n,int h){
  if(n==-1)return;
  t[n].h=max(t[n].h,h);
  height(t[n].p,h+1);
}

int main(){
  int n,id,l,r,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++)t[i].h=t[i].s=t[i].p=-1;
  for(int i=0;i<n;i++){
    cin>>id>>l>>r;
    t[id].r=r;
    t[id].l=l;
    cnt=0;
    if(l!=-1)t[l].p=id,cnt++;
    if(r!=-1)t[r].p=id,cnt++;
    if(cnt==2)t[r].s=l,t[l].s=r;
    t[id].dg=cnt;
  }
  for(int i=0;i<n;i++){
    height(i,0);
    if(t[i].p==-1)depth(i,0);
  }
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,t[i].p,t[i].s);
    printf("degree = %d, depth = %d, height = %d, ",t[i].dg,t[i].dp,t[i].h);
    if(t[i].p==-1)printf("root\n");
    else if(t[i].r==-1&&t[i].l==-1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

Measured memory_bytes: 3184
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
h = na()
dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2,n):
    op1 = dp[i-2] + abs(h[i-2] - h[i])
    op2 = dp[i-1] + abs(h[i-1] - h[i])
    dp[i] = min(op1, op2)

print(dp[-1])

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

int main(){
    int n, m;
	cin >> n >> m;
	vector<int> s(m);
	vector<char> c(m);

    for(int i=0;i<m;i++){
        cin >> s.at(i) >> c.at(i);
        s.at(i)--;
    }
    int ans = -1;

    for(int i=0;i<1000;i++){
        string I = to_string(i);
        if(I.size() != n){
            continue;
        }

        bool valid = true;
        for(int j=0;j<m;j++){
            if(I.at(s.at(j)) != char(c.at(j))){
                valid = false;
            }            
        }
        if(!valid){
                continue;
            }
        ans = i;
        break;        
    }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<assert.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define setIO(x) freopen(x".in","r", stdin);freopen(x".out","w",stdout);
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e10 + 7;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
int n;
char str[N];
vector<int> pos[30];
set<pii> S;
set<pii>::iterator it;
bool solve(vector<int> &p) {
	if (!sz(p))
		return false;
	S.clear();
	S.insert(mp(p[0], 0));
	rep(i, 1, sz(p))
	{
		it = S.lower_bound(mp(p[i] - 2 * i, -1));
		if (it != S.end()) {
			printf("%d %d\n", p[it->second] + 1, p[i] + 1);
			return true;
		}
		S.insert(mp(p[i] - 2 * i, i));
	}
	return false;
}
int main() {
	scanf("%s", str);
	n = strlen(str);
	rep(i, 0, n)
		pos[str[i] - 'a'].pb(i);
	bool flag = false;
	rep(i, 0, 26)
		if (solve(pos[i])) {
			flag = true;
			break;
		}
	if (!flag)
		puts("-1 -1");
	return 0;
}


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;
using Si = set<int>;
using vSi = vector<Si>;
using vvSi = vector<vSi>;

#define fi first
#define se second
#define INF 1e9 + 5
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n;
	while(cin >> n) {
		vi b(n-1);
		for (int i = 0; i < n-1; ++i) {
			cin >> b[i];
		}
		int ans = b[0] + b[n-2];
		for (int i = 0; i < n-2; ++i) ans += min(b[i], b[i+1]);
		cout << ans << '\n';
	}
}



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

int N;
int A[100010];

int main () {

    scanf("%d", &N);

    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }

    int total_dist = 0;

    for (int i = 1; i <= N+1; i++) {
        total_dist += abs(A[i] - A[i-1]);
    }

    for (int i = 1; i <= N; i++) {
        printf("%d\n", total_dist - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]));
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
int n;
ll a, b, h[100001];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(a);
    read(b);
    FOR(i, 1, n) read(h[i]);
    a-=b;
    ll ans=0, l=1, r=1e16/b, m;
    while(l<=r){
        m=(l+r)/2;
        ll res=0;
        FOR(i, 1, n) if(b*m<h[i]) res+=(h[i]-b*m-1)/a+1;
        if(res<=m){
            ans=m;
            r=m-1;
        }
        else l=m+1;
    }
    writeln(ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

const int MAXN = 602;
vector<pair<int,int>> e[MAXN][MAXN];
const int MAXD = 300228;

using Lst = vector<pair<int, int>>;

int k;

int sq[MAXD];

Lst g[2];

bool wa[MAXN][MAXN];
bool wb[MAXN][MAXN];
Lst mvs;

void dfs(int x, int y, int id) {
    if (wb[x][y]) {
        return;
    }

    wb[x][y] = true;
    if (wa[x][y]) {
        g[id].emplace_back(x, y);
    }

    for (auto ed : mvs) {
        int nx = x + ed.first, ny = y + ed.second;
        if (nx >= 0 && ny >= 0 && nx < k && ny < k) {
            dfs(nx, ny, id ^ 1);
        }
    }
}

Lst sep(Lst a, int d) {
    mvs.clear();
    for (int i = 0; i * i <= d; ++i) {
        int j = sq[d - i * i];
        if (j != -1) {
            mvs.emplace_back(i, j);
            mvs.emplace_back(i, -j);
            mvs.emplace_back(-i, j);
            mvs.emplace_back(-i, -j);
        }
    }


    memset(wa, 0, sizeof(wa));
    memset(wb, 0, sizeof(wb));
    g[0].clear();
    g[1].clear();

    for (auto& val : a) {
        wa[val.first][val.second] = true;
    }


    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < k; ++j) {
            dfs(i, j, 0);
        }
    }

    return g[g[0].size() < g[1].size()];
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n, a, b;
    cin >> n >> a >> b;
    fill(begin(sq), end(sq), -1);
    k = 2 * n;
    for (int i = 0; i * i < MAXD; ++i) {
        sq[i * i] = i;
    }

    Lst l;

    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < k; ++j) {
            l.emplace_back(i, j);
        }
    }

    l = sep(l, a);
    l = sep(l, b);
    l.resize(n * n);
    for (auto& val : l) {
        cout << val.first << " " << val.second << "\n";
    }
}

Measured memory_bytes: 40428
/*2019/09/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/

int main(){
    char s[100];
    scanf("%s",s);
    if(!strcmp(s,"Sunny")){
        printf("Cloudy\n");
    }else if(!strcmp(s,"Cloudy")){
        printf("Rainy\n");
    }else{
        printf("Sunny\n");
    }

    return 0;
}

Measured memory_bytes: 128
a_origin, b_origin = [int(s) for s in input().split(" ")]

def press_x(x, coin):
    coin += x
    x -= 1
    return x, coin

a, b = a_origin, b_origin
coin_aa = 0
a, coin_aa = press_x(a, coin_aa)
a, coin_aa = press_x(a, coin_aa)

a, b = a_origin, b_origin
coin_ab = 0
a, coin_ab = press_x(a, coin_ab)
b, coin_ab = press_x(b, coin_ab)

a, b = a_origin, b_origin
coin_bb = 0
b, coin_bb = press_x(b, coin_bb)
b, coin_bb = press_x(b, coin_bb)

a, b = a_origin, b_origin
coin_ba = 0
b, coin_ba = press_x(b, coin_ba)
a, coin_ba = press_x(a, coin_ba)

print(max([coin_aa, coin_ab, coin_ba, coin_bb]))

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

set<long long> st;

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

  long long v;

  for(int i=0; i<n; i++){
    cin >> v;
    if(st.count(v) == 1)
      st.erase(v);
    else
      st.insert(v);
  }

  cout << st.size() << endl;
  
  return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    while (k--)
    {
        int a, b;
        cin >> a >> b;
        cout << (min(min(n - a + 1, n - b + 1), min(a, b)) + 2) % 3 + 1 << endl;
    }
}



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

int main() {
  int N;
  string s, t;
  cin >> N >> s >> t;

  int ans = 2 * N;
  for (int i = 0; i < N; i++) {
    if (s.substr(i) == t.substr(0, N - i)) {
      ans = 2 * N - (N - i);
      break;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from bisect import bisect

def solve():
      input = sys.stdin.readline
      N, M, K = map(int, input().split())
      A = [int(a) for a in input().split()]
      B = [int(b) for b in input().split()]
      AS = [0] * (N + 1)
      BS = [0] * (M + 1)
      for i in range(N):
            AS[i+1] = AS[i] + A[i]
      for i in range(M):
            BS[i+1] = BS[i] + B[i]
      
      maxCount = 0
      for i in range(N + 1):
            if AS[i] > K: break

            bcount = bisect(BS, K - AS[i])
            maxCount = max(maxCount, i + bcount - 1)
            
      print(maxCount)


      return 0

if __name__ == "__main__":
      solve()

Measured memory_bytes: 48932
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x1,y1,x2,y2,x3,y3,x4,y4;
	cin>>x1>>y1>>x2>>y2;
	int a = x1 - x2;
	int b  = y1 - y2;
	x3 = x2 + b;y3 = y2 - a;
	x4 = x1 + b;y4 = y1 - a;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n,d;
    cin >> n >> d;
    print(rp(n, d * 2 + 1));
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

const int maxn = 5000 + 10;
int n, m;
int f[maxn], C[maxn];

void initDP() {
    Set(f, 0);
    f[0] = 1;

    int mid = n >> 1;
    _rep(i, 2, mid + 1) C[i] = i - 1;
    _rep(i, mid + 2, n) C[i] = n - i + 2;
}

int dp() {
    initDP();

    _rep(i, 2, n) _rep(j, C[i], n - 1) {
        f[j] = (f[j] + f[j - C[i]]) % m;
    }

    ll ans = 0;
    _rep(i, 0, n - 1) {
        ans = ans + 1ll * (n - i) * f[i] % m;
        ans %= m;
    }
    return ans;
}

int main() {
    //freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &m);

    int res = dp();
    cout << res << endl;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int worktime[m];
	long long sum = 0;
	for (int i = 0; i < m; ++i)
	{
		cin >> worktime[i];
	}
	for (int i = 0; i < m; ++i)
	{
		sum += worktime[i];
	}
	if (sum <= n)
	{
		cout << n - sum << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

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

int main(){
	int a,b;
	cin>>a>>b;
    if(a<b) {
		cout<<"a < b"<<endl;
	}
	else if(a>b){
	cout<<"a > b"<<endl;	
	}
	else cout<<"a == b"<<endl;
    return 0;
}




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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n >= 1000) {
		cout << "ABD" << endl;
	} else {
		cout << "ABC" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    counter = {}
    total = 0
    for num in A:
        total += num
        counter[num] = counter.get(num, 0) + 1

    Q = int(input())
    for i in range(Q):
        B,C = [int(i) for i in input().split()]
        if B in counter:
            B_cnt = counter[B]
            counter[C] = counter.get(C, 0) + B_cnt
            total += (C-B) * B_cnt
            counter[B] = 0
        print(total)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 20452
S = input()
words = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * (len(S) + 1)
dp[0] = 1
ans = 'NO'

for i in range(len(S)):
    if dp[i] == 0:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1
    if dp[len(S)] == 1:
        ans = 'YES'
        break
print(ans)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

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

    Vl csum(N + 1);
    for (int i = 0; i < N; i++) {
        csum[i + 1] = csum[i] + A[i];
    }

    ll ans = L_INF;
    for (int i = 0; i < N - 1; i++) {
        ans = min(ans, abs(csum[i + 1] - (csum[N] - csum[i + 1])));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456