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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int64_t r=0,g=0,b=0;
  int64_t ans=0;
  int64_t w=0;
  for(int i=0;i<N;i++){
    S[i]=='R' ? r++
      : S[i]=='G' ? g++
      : b++;
  }
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N;j++){
      if(j+j-i<N){
        if((S[i]!=S[j]) && (S[j]!=S[j+j-i]) && (S[j+j-i]!=S[i])) w++;
      }
    }
  }
  ans = r*g*b-w;
  cout << ans << endl;
}

Measured memory_bytes: 3620
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())


typedef unsigned long long ull;

ull inversion_count;

void merge(vi& A, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  vi L(n1+1), R(n2+1);
  for (int i = 0; i < n1; i++) {
    L[i] = A[left+i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid+i];
  }
  L[n1] = R[n2] = INF;
  for (int i = 0, j = 0, k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
      inversion_count += n1 - i;
    }
  }
}

void mergeSort(vi& A, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(int argc, char **argv)
{
  int n;
  scanf("%d", &n);
  vi A(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);
  printf("%llu\n", inversion_count);
  return 0;
}

Measured memory_bytes: 4380
SX,SY,TX,TY =gets.split.map &:to_i
GX=TX-SX
GY=TY-SY
puts "U"*GY+"R"*GX+"D"*GY+"L"*GX+"L"+"U"*(GY+1)+"R"*(GX+1)+"D"+"R"+"D"*(GY+1)+"L"*(GX+1)+"U"


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

namespace Baumkuchen {
	class Baumkuchen {
		static void Main(string[] args) {		
			int N = int.Parse(Console.ReadLine());
			long[] v_list = new long[N + 1];
			v_list[0] = 0;
			for (int n = 1; n < N + 1; n++) {
				v_list[n] = v_list[n - 1] + long.Parse(Console.ReadLine());
			}
			Baumkuchen baumkuchen = new Baumkuchen(v_list);
			Console.WriteLine(baumkuchen.GetAnwser());
		}

		readonly long[] v_list;
		readonly int N;
		readonly double tripartition;
		public Baumkuchen(long[] _v_list) {
			N = _v_list.Length - 1;
			v_list = _v_list;
			tripartition = v_list[N] / 3.0;
		}

		public long GetAnwser() {
			long interm_maxV = -1;
			int n0_max = findLeftIndex(0, N, tripartition);
			for (int n0 = 0; n0 <= n0_max; n0++){
				long tmp = searchOne(n0);
				if (tmp > interm_maxV) interm_maxV = tmp;
			}
			return interm_maxV;
		}

		private long searchOne(int n0) {
			int n1_left = findLeftIndex(n0, N, tripartition + v_list[n0]);
			int n2_left = findLeftIndex(n1_left, N, 2 * tripartition + v_list[n0]);
			long V_ll = getMinV(n0, n1_left, n2_left);
			long V_lr = getMinV(n0, n1_left, n2_left + 1);
			long V_rl = getMinV(n0, n1_left + 1, n2_left);
			long V_rr = getMinV(n0, n1_left + 1, n2_left + 1);
			return Math.Max(Math.Max(V_ll, V_lr), Math.Max(V_rl, V_rr));
		}

		private long getMinV(int n0, int n1, int n2) {
			long V0 = v_list[n1] - v_list[n0];
			long V1 = v_list[n2] - v_list[n1];
			long V2 = v_list[n0] - v_list[n2] + v_list[N];
			return Math.Min(Math.Min(V0, V1), V2);
		}

		private int findLeftIndex(int from_n, int to_n, double target) {
			int n_left = from_n;
			int n_right = to_n;
			while (n_right - n_left !=1) {
				int n_mid = (n_right + n_left) / 2;
				if (v_list[n_mid] <= target) n_left = n_mid;
				else n_right = n_mid;
			}
			return  n_left;
		}
	}
}

Measured memory_bytes: 16024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int n,k;
    while(cin >> n >> k, n){
        vi a(n);
        rep(i,n) cin >> a[i];
        set<string> st;
        if(k == 2){
            rep(i,n)rep(j,n)if(i-j){
                st.insert(to_string(a[i]) + to_string(a[j]));
            }
        }
        if(k == 3){
            rep(i,n)rep(j,n)rep(k,n)if(i-j && j-k && i-k){
                st.insert(to_string(a[i]) + to_string(a[j]) + to_string(a[k]));
            }
        }
        if(k == 4){
            rep(i,n)rep(j,n)rep(k,n)rep(l,n)if(i-j && j-k && i-k && i-l && j-l && k-l){
                st.insert(to_string(a[i]) + to_string(a[j]) + to_string(a[k]) + to_string(a[l]));
            }
        }
        cout << st.size() << endl;
    }
}



Measured memory_bytes: 3448
// In the name of god
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define use_file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;
const ll N = 3e5+5, inf = 4e18, mod = 1e9 + 7;
ll n, k, a[N], seg[N*4] , dp[N];
ll get(ll l, ll r, ll v = 1, ll s = 0, ll e = N-4){
	if(l >= e || r <= s)
		return -inf;
	if(l <= s && e <= r)
		return seg[v];
	ll mid = (e + s) / 2, lc = v + v, rc = lc + 1;
	return max(get(l, r, lc, s, mid),get(l, r, rc, mid, e));
}
void fix(ll p, ll x, ll v = 1, ll s = 0, ll e = N-4){
	if(e - s == 1){
		if(seg[v] < x)
			seg[v] = x;
		return;
	}
	ll mid = (e + s) / 2, lc = v + v, rc = lc + 1;
	if(p < mid)
		fix(p, x, lc, s, mid);
	else 
		fix(p, x, rc, mid, e);
	seg[v] = max(seg[lc], seg[rc]);
}
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >>  n >> k;
	for(int i =  0; i < n; i++){
		cin >>  a[i];
		ll b=300 * 1000;
		ll x = min(b, a[i] + k), y = max(b - b, a[i] - k);
		ll z = get(y, x+1);
		dp[i] = z + 1;
		fix (a[i], dp[i]);
		if(i > 0 )dp[i] = max(dp[i - 1], dp[i]);
	}
	cout << dp[n - 1];
	cout << endl;
}


Measured memory_bytes: 16484
# AOJ ITP2_7_B: Set: Delete
# Python3 2018.6.24 bal4u

tbl = set()
q = int(input())
for i in range(q):
	a = input().split()
	x = int(a[1])
	if a[0] == '0':
		tbl.add(x)
		print(len(tbl))
	elif a[0] == '1': print(1 if x in tbl else 0)
	else:
		if x in tbl: tbl.remove(x)


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;
long double A, B, H, M;

int main(){
  cin >> A >> B >> H >> M;
  long double Mtheta = (360/60)*M;
  long double Htheta = ((long double)(360/12)/(long double)60)*(H*60+M);
  long double theta = max(Htheta, Mtheta) - min(Htheta, Mtheta);
  // theta = min(theta, 360-theta);
  theta = Htheta - Mtheta;
  long double pi = acos(-1);
  long double ans = A*A+B*B-2*A*B*cos(2*pi*theta/(long double)360);
  printf("%.10Lf\n", sqrtl(ans));
  return 0;
}


Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

int a[105];

bool solve() {
    int n,m,x; cin >> n >> m >> x;
    REP (i,m) {
        int x; cin >> x;
        a[x] = 1;
    }
    int tmp = 0;
    int tmp2 = 0;
    for (int i = x+1; i < n; i++) {
        tmp += a[i];
    }
    for (int i = x-1; i > 0; i--) {
        tmp2 += a[i];
    }
    cout << min(tmp,tmp2) << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    while(true) {
        int n, x;
        cin >> n >> x;

        if(n == 0 and x == 0) break;

        int cnt = 0;
        for (auto i = 1; i <= n; i++) {
            for (auto j = i + 1; j <= n; j++) {
                for (auto k = j + 1; k <= n; k++) {
                    if(i + j + k == x) cnt++;
                }
            }
        }

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


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

int main() {
  int N;
  cin >>N;
  vector<pair<string,pair<int,int>>> pe(N);
  for(int i=0;i<N;i++){
    int a;
    cin >> pe[i].first >>a;
    pe[i].second.first=-a;
    pe[i].second.second=i+1;
  }
  sort(pe.begin(),pe.end());
  for(int i=0;i<N;i++){
    cout << pe[i].second.second << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
L = get_ints

L.sort!

longest = L.last
rest = L[0...-1].sum

puts longest < rest ? 'Yes' : 'No'


Measured memory_bytes: 14500
using System;
using System.Collections.Generic;

namespace cswork
{

    class Program
    {
        public Program() { }

        Scanner cin;

        void Omame()
        {
            cin = new Scanner();

            int n = cin.nextInt();
            int m = cin.nextInt();

            List<int> sList = new List<int>();
            for (int i = 0; i < m; i++)
            {
                int k = cin.nextInt();
                int s = 0;
                for (int j = 0; j < k; j++)
                {
                    int tmpS = cin.nextInt() - 1;
                    s += 1 << tmpS;
                }
                sList.Add(s);
            }

            List<int> pList = new List<int>();
            for (int i = 0; i < m; i++)
            {
                int p = cin.nextInt();
                pList.Add(p);
            }

            int ans = 0;
            for (int i = 0; i < 1 << n; i++)
            {
                bool add = true;
                for (int j = 0; j < m; j++)
                {
                    int s = i & sList[j];
                    int count = 0;
                    for (int k = 0; k < n; k++)
                    {
                        if ((s >> k & 1) == 1)
                        {
                            count++;
                        }
                    }

                    if (count % 2 != pList[j])
                    {
                        add = false;
                        break;
                    }
                }

                if (add) ans++;
            }

            Console.WriteLine(ans);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main()
{
    ll N;
    vector<ll> H;
    cin >> N;
    REP(i, N)
    {
        ll tmp;
        cin >> tmp;
        H.push_back(tmp);
    }

    ll countMax = 0;
    ll countCurrent = 0;
    REP(i, N - 1)
    {
        if (H[i] >= H[i + 1])
        {
            countCurrent++;
        }
        else
        {
            countCurrent = 0;
        }
        countMax = max(countMax, countCurrent);
    }

    ll ans = countMax;
    cout << ans << endl;
}


Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str, T: str, A: int, B: int, U: str):
    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    U = next(tokens)  # type: str
    solve(S, T, A, B, U)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

A, B, C, D = map(int, input().split())
mod = 998244353

dp = [[0]*(D+1) for _ in range(C+1)]
dp[A][B] = 1
for i in range(A, C):
    dp[i+1][B] = dp[i][B] * B % mod

for i in range(B, D):
    dp[A][i+1] = dp[A][i] * A % mod


for i in range(A, C):
    for j in range(B, D):
        dp[i+1][j+1] += dp[i+1][j] * (i+1)
        dp[i+1][j+1] %= mod
        dp[i+1][j+1] += dp[i][j+1] * (j+1)
        dp[i+1][j+1] %= mod
        dp[i+1][j+1] -= dp[i][j] * i % mod * j % mod
        if dp[i+1][j+1] < 0:
            dp[i+1][j+1] += mod

print(dp[C][D])


Measured memory_bytes: 144308
# coding: utf-8
# Your code here!

def printFormula(x):
    print(nums[0], end = "")
    for i in range(len(nums) - 1):
        if x & (1 << i):
            print("+", end = "")
        else:
            print("-", end = "")
        print(nums[i + 1], end = "")
    print("=7")
        


str1 = input()
nums = []
for i in range(len(str1)):
    nums.append(int(str1[i]))
    
ope = []
for i in range(1 << (len(str1) - 1)):
    sum_num = nums[0]
    
    for j in range(len(str1) - 1):
        if i & (1 << j):
            sum_num += nums[1 + j]
        else:
            sum_num -= nums[1 + j]
        
    if sum_num == 7:
        printFormula(i)
        exit()
    















Measured memory_bytes: 38384
#include <stdio.h>

int main(){
  int n, p, max, ans, i;
  scanf("%d %d", &n, &p);
  max = p;
  ans = p;
  for(i=1; i<n; i++){
    scanf("%d", &p);
    ans+=p;
    if(max<p) max = p;
  }
  ans-=max/2;
  printf("%d\n", ans);
  return 0;
}

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

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

    //エッジに番号を付けておく
    map<pair<int64_t, int64_t>, int64_t> edge_id;
    int64_t id = 0;
    vector<vector<int64_t>> connect(N);
    for (int64_t i = 0; i < N - 1; i++) {
        int64_t a, b;
        cin >> a >> b;
        a--; b--;
        connect[a].push_back(b);
        connect[b].push_back(a);
        edge_id[{a, b}] = edge_id[{ b, a }] = id++;
    }

    assert(id == N - 1);

    int64_t M;
    cin >> M;
    vector<int64_t> u(M), v(M);
    for (int64_t i = 0; i < M; i++) {
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
    }

    //白い辺はコスト0,黒い辺はコスト１とする
    //(方針1)制約を満たすものを直接数える
    //  M個のパスについてどれもコスト1以上でなければならない
    //  それは結構難しい
    //(方針2)制約を満たさないものを数えて2^(N - 1)から引く
    //  M個の制約のいずれかがコスト0だったらダメ
    //iがダメだとするとiのルートだけ0にしてほかはどうでも良い
    //しかしこれでは同じものを何度も数えてしまう
    //2^20はOK
    //制約のどれに反するかを全列挙？ いくつかの条件にちょうど反するものを数えるのは困難
    //包除祭りか

    //制約iが通るパスをビットで管理する
    vector<int64_t> path(M, 0);
    for (int64_t i = 0; i < M; i++) {
        //uからvへ行く
        //uを根として見ていく
        vector<int64_t> pre(N, -1);
        stack<int64_t> st;
        st.push(u[i]);
        while (!st.empty()) {
            int64_t top = st.top();
            st.pop();
            if (top == v[i]) {
                break;
            }
            for (int64_t next_node : connect[top]) {
                if (next_node == pre[top]) {
                    continue;
                }

                pre[next_node] = top;
                st.push(next_node);
            }
        }

        for (int64_t j = v[i]; pre[j] != -1; j = pre[j]) {
            path[i] |= (1LL << edge_id[{ j, pre[j] }]);
        }
    }

    int64_t MAX = (1LL << M);
    vector<int64_t> num(MAX);
    for (int64_t i = 1; i < MAX; i++) {
        //iの1が立っているような制約には反することが確定している場合の数

        //0でなければならないパスの数を数える
        int64_t constraint = 0;
        for (int64_t j = 0; j < M; j++) {
            if (i & (1LL << j)) {
                constraint |= path[j];
            }
        }
        int64_t path_num = 0;
        for (int64_t j = 0; j < N - 1; j++) {
            if (constraint & (1LL << j)) {
                path_num++;
            }
        }

        num[i] = pow(2, N - 1 - path_num);
    }

    //包除で頑張って計算
    int64_t ans = 0;
    for (int64_t i = 1; i < MAX; i++) {
        int64_t bit_num = 0;
        for (int64_t j = 0; j < M; j++) {
            if (i & (1LL << j)) {
                bit_num++;
            }
        }

        ans += (bit_num % 2 == 1 ? num[i] : -num[i]);
    }

    cout << (int64_t)pow(2, N - 1) - ans << endl;
}

Measured memory_bytes: 8448
k,n = map(int,input().split())
a = [int(i) for i in input().split()]
a.append(k)
dist = []
for i in range(1,n+1):
    cou = abs(a[i-1] - a[i])
    dist.append(cou)
if a[0] !=0:
    dist[-1]+=a[0]
dist.sort()
print(sum(dist[:n-1]))

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

//隣接リスト

int main(){

    int V; cin >> V;
    vector<vector<int> > adjlist(V);      

    //入力
    for(int i = 0; i < V; i++){
        int gomi; cin >> gomi;
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a;
            adjlist[i].push_back(a - 1);
        }
    }

    vector<vector<int> > array(V, vector<int> (V, 0));

    for(int i = 0; i < V; i++){
        for(int j = 0; j < adjlist[i].size(); j++){
            array[i][adjlist[i][j]] = 1;
        }
    }

    //出力
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            if(j == V - 1) cout << array[i][j] << endl;
            else cout << array[i][j] << " ";
        }
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
    int a[3][3];
	ll i, j, k;
	ll ret = 0;
	
    for ( i = 0;i < 3; i++ ) {
        for ( j = 0; j < 3; j++ ) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    vector<int> b(n);
    for ( i = 0; i < n; i++ ) {
        cin >> b[i];
    }
    
    for ( i = 0;i < 3; i++ ) {
        for ( j = 0; j < 3; j++ ) {
            for ( k = 0; k < n; k++ ) {
                if ( a[i][j] == b[k] ) {
                    a[i][j] = 0;
                }
            }
        }
    }

    for ( i = 0;i < 3; i++ ) {
        if ( (a[i][0] == 0) && (a[i][1] == 0) && (a[i][2] == 0) ) ret++;
    }
    for ( i = 0;i < 3; i++ ) {
        if ( (a[0][i] == 0) && (a[1][i] == 0) && (a[2][i] == 0) ) ret++;
    }
    if ( (a[0][0] == 0) && (a[1][1] == 0) && (a[2][2] == 0) ) ret++;
    if ( (a[2][0] == 0) && (a[1][1] == 0) && (a[2][0] == 0) ) ret++;
    cout << ((ret > 0) ? "Yes" : "No") << endl;
	
	
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll L, R;
    cin >> L >> R;

    for (ll i = L; i <= R && i < L + 2019; ++i) {
        if (i % 2019 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll m = 2019;
    for (ll i = L; i <= R - 1; ++i) {
        for (ll j = i + 1; j <= R; ++j) {
            ll k = (i * j) % 2019;
            if (m > k) m = k;
        }
    }
    cout << m << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> a(n), b(n + 1);
    for(auto&& i : a){
        cin >> i;
    }
    map<long long, long long> cnt;
    cnt[0] = 1;
    long long ans = 0;
    for(int i = 1; i <= n; i++){
        b[i] = b[i - 1] + a[i - 1] + k - 1;
        if(i - k >= 0) cnt[b[i - k] % k]--;
        ans += cnt[b[i] % k];
        cnt[b[i]%k]++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void fast()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}
int main()
{
    fast();
    unsigned long long int n, ans=0, temp=10;
	cin>>n;
	if(n%2){
		cout<<"0\n";
		return 0;
	}
	for(ll i=10;n/i>=1;i*=5)
        ans+=n/i;
	cout<<ans<<endl;
    return 0;

}


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

int main(){
  int N,M;
  cin >> N >> M;
  int a,b,c,d;
  a=1; b=N;
  for (int i=0;i<M;i++){
    cin >> c >> d;
    if (a<c) a=c;
    if (d<b) b=d;
  }
  cout << max(0,b-a+1) << endl;
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  string ans;
  if(a > 8 || b > 8) ans = ":(";
  else ans = "Yay!";
  cout << ans << endl;

  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);   
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int l;
    cin >> l;

    const int INF = 1e6;
    vector<vector<int>> table(n, vector<int>(21, INF));

    int r = 0;
    rep(i,n){
        while(1){
            if(r == n-1) break;
            if(x[r+1] - x[i] <= l) r++;
            else break;
        }
        table[i][0] = r;
    }

    rep(j,20) rep(i,n){
        if(table[i][j] == INF) table[i][j+1] = INF;
        else table[i][j+1] = table[table[i][j]][j];
    }

    int q;
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(a > b) swap(a,b);
        int ans = 1;
        for(int i = 20; i >= 0; i--){
            if(table[a][i] < b){
                a = table[a][i], ans += 1<<i;
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;
using ll = long long;

int numOfDigits(int n){
    int ans = 0;
    while(n){
        ans++;
        n /= 10;
    }
    return ans & 1;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    int lst = -1;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        if (x != lst){
            a.push_back(x);
        }
        lst = x;
    }
    n = a.size();
    for (int i = 1; i < n; i++){
        if (a[i] < a[i - 1]){
            a[i - 1]--;
        }
    }

    bool flg = 1;
    for (int i = 0; i < n - 1; i++){
        if (a[i + 1] < a[i]){
            flg = 0;
            break;
        }
    }
    if (flg){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 892
// TODO: Why there are at most O(2^n poly(n)) states?
// Solution by official editorial

#include<cstdio>

using ll = long long;

constexpr ll inf = 0x3f3f3f3f3f3f3f3f;

inline void dmin(ll &m, ll n) {
	if (n < m) m = n;
}

ll z[21];

ll dfs(int l, int r, int xl, int xr) {
	if (l + 1 == r) return z[l] * xl + z[r] * xr;
	ll ans = inf;
	for (int m = l + 1; m < r; ++m)
		dmin(ans, dfs(l, m, xl, xl + xr) + dfs(m, r, xl + xr, xr) - z[m] * (xl + xr));
	return ans;
}

int main() {
	int N;

	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
		scanf("%lld", z + i);

	printf("%lld", dfs(1, N, 1, 1));
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
using namespace std;
int n,m,a[100005];
int main(){
	cin>>n>>m;
	if(n<m)cout<<0<<endl;
	else cout<<n-m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 300
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, m, l;
  cin >> n >> m >> l;
  int a[m], b[m], c[m];
  for(int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i];
  int q;
  cin >> q;
  int s[q], t[q];
  for(int i = 0; i < q; i++) cin >> s[i] >> t[i];

  int dist[n][n];
  for(int i = 0; i < n; i++){
    fill(dist[i], dist[i] + n, INF_INT);
    dist[i][i] = 0;
  }
  for(int i = 0; i < m; i++){
    dist[a[i] - 1][b[i] - 1] = c[i];
    dist[b[i] - 1][a[i] - 1] = c[i];
  }
  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
      }
    }
  }


  int dist2[n][n];
  for(int i = 0; i < n; i++){
    fill(dist2[i], dist2[i] + n, INF_INT);
    dist2[i][i] = 0;
  }
  for(int u = 0; u < n; u++){
    for(int v = u + 1; v < n; v++){
      if(dist[u][v] <= l){
        dist2[u][v] = 1;
        dist2[v][u] = 1;
      }
    }
  }
  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        dist2[i][j] = min(dist2[i][k] + dist2[k][j], dist2[i][j]);
      }
    }
  }

  string buf;
  for(int i = 0; i < q; i++){
    if(dist2[s[i] - 1][t[i] - 1] != INF_INT) buf += to_string(dist2[s[i] - 1][t[i] - 1] - 1);
    else buf += "-1";
    buf += "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5,mod=998244353;
char ch[M];
int n,sum,i,j,k,a,b,dp[M][3][3][2];
bool flag=1;
void spj()
{
	for(i=2;i<=n;++i)if(ch[i]!=ch[i-1]){flag=0;break;}
	if(flag)puts("1"),exit(0);
	if(n<=3)(n==2?puts("2"):((ch[1]!=ch[2]&&ch[1]!=ch[3]&&ch[2]!=ch[3])?puts("3"):((ch[1]==ch[3])?puts("7"):puts("6")))),exit(0);
}
bool check(){for(int i=1;i<=n;++i)if(ch[i]==ch[i-1])return 0;return 1;}
void in(){scanf("%s",ch+1);}
void ac()
{
	n=strlen(ch+1);spj();
	for(i=1;i<=n;++i)sum=(sum+ch[i]-'a')%3;
	for(i=0;i<=2;++i)dp[1][i][i][0]=1;
	for(i=1;i<=n-1;++i)for(j=0;j<=2;++j)for(k=0;k<=2;++k)for(a=0;a<=1;++a)for(b=0;b<=2;++b)
	(dp[i+1][(j+b)%3][b][a|(k==b)]+=dp[i][j][k][a])%=mod;
	printf("%d",(0ll+dp[n][sum][0][1]+dp[n][sum][1][1]+dp[n][sum][2][1]+check())%mod);
}
int main(){in();ac();}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = long long int;
using uli = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;
    int alpha[26]{0};
    for (auto ch : s) alpha[ch - 'a'] = 1;
    rep(i, 26) {
        if (alpha[i] != 1) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None\n";
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n; cin >> n;
	int t[n], a[n];
	zip(i, 0, n)
	{
		cin >> t[i] >> a[i];
	}
	int ans1 = t[0], ans2 = a[0];
	zip(i, 1, n)
	{
		int var = max(ans1, ans2);
		if (t[i] < ans1 && a[i] < ans2)
		{
			int y = min(t[i], a[i]);
			int x = (var + y - 1) / y;
			x = max((ans1 + t[i] - 1) / t[i], (ans2 + a[i] - 1) / a[i]);
			ans1 =  (x * t[i]);
			ans2 = (x * a[i]);
		}
		else if (t[i] >= ans1 && a[i] < ans2)
		{
			int x = (ans2 + a[i] - 1) / a[i];
			ans1 = (t[i] * x);
			ans2 = (a[i] * x);
		}
		else if (t[i] < ans1 && a[i] >= ans2)
		{
			int x = (ans1 + t[i] - 1) / t[i];
			ans1 = (t[i] * x);
			ans2 = (a[i] * x);
		}
		else
		{
			ans1 = t[i];
			ans2 = a[i];
		}
		//cout << ans1 << " " << ans2 << en;
	}
	cout << ans1 + ans2 << en;

	return 0;
}



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

int main(void){
    int n, k;
    cin >> n >> k;

    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    
    int ans = 0;
    rep(i,k) ans += v[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
  string a,b,c,d;
  cin>>a;
  if(a=="abc" || a=="acb" ||a=="bac"||a=="bca"||a=="cab"||a=="cba"){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc115 {

    class Program {
        /**
         * in
         *  3
         *  4980
         *  7980
         *  6980
         * out
         *  15950
         */
        main(inp: string): void {

            const p = inp.split('\n');
            p.shift();

            const sorted: string[] = p.sort((a, b) => {
                return parseInt(b) - parseInt(a);
            });
            const sortedNum: number[] = sorted.map(Number);

            const ans: number = sortedNum.reduce(
                (accumulator, currentValue, idx) =>
                    idx === 0 ? (accumulator + currentValue) / 2 : accumulator + currentValue, 0);
            console.log(ans);
        }
    }

    const prg = new Program();
    prg.main(fs.readFileSync('/dev/stdin', 'utf8').trim());
}




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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if((a + b) % 2 == 0) {
    cout << (a + b) / 2 << '\n';
  } else {
    cout << "IMPOSSIBLE" << '\n';
  }
}

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

int main(){
    int a, b, c;
    while(true){
        cin >> a >> b >> c;
        if(a == -1 && b == -1 && c == -1)return 0;
        int sum=a + b;
        if(a==-1 || b == -1)cout << 'F' << endl;
        else if(sum >= 80)cout << 'A' << endl;
        else if(sum >= 65)cout << 'B' << endl;
        else if(sum >= 50)cout << 'C' << endl;
        else if(sum >= 30){
            if(c >= 50)cout << 'C' << endl;
            else cout << 'D' << endl;
        }else cout << 'F' << endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  for(;;){
    int n,m;
    cin >> n >> m;
    if(!n&&!m) return 0;
    vector<int> hi;
    hi.assign(2048576,0);
    vector<int> wi;
    wi.assign(2048576,0);
    vector<int> h;
    h.resize(n+1);
    h[0]=0;
    REP(i,n) cin >> h[i+1];
    vector<int> w;
    w.resize(m+1);
    w[0]=0;
    REP(i,m) cin >> w[i+1];
    REP(i,n) h[i+1]+=h[i];
    REP(i,m) w[i+1]+=w[i];
    REP(i,n+1) REP(j,i)
      hi[h[i]-h[j]]++;
    REP(i,m+1) REP(j,i)
      wi[w[i]-w[j]]++;
    int answer=0;
    REP(i,2048576) answer+=hi[i]*wi[i];
    cout << answer << endl;
  }
}

Measured memory_bytes: 17148
K, N = map(int, input().split())
A = [int(i) for i in input().split()]
M = list()
ans = 0
for i in range(N-1):
    M.append(A[i+1]-A[i])
    #print(M[i])
M.append(K-A[N-1]+A[0])
print(K-max(M))



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

int n;
int a[int(1e5+7)];
int ans,cnt;

int main()
{
//	freopen("t.txt","r",stdin);
	scanf("%d",&n);
	int t;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&t);
		if(a[cnt]==t)continue;
		a[++cnt]=t;
	}
	int temp=a[2]>a[1],last=a[1];
	ans++;
	for(int i=2;i<=cnt;++i)
	{
		if(temp==1)
		{
			if(last<a[i])last=a[i];
			else ans++,last=a[i],temp=a[i+1]>a[i];
		}
		else if(temp==0)
		{
			if(last>a[i])last=a[i];
			else ans++,last=a[i],temp=a[i+1]>a[i];
		}
	}
	printf("%d",ans);
}

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

int main(){
  long long  n;
  cin >> n;
  long long ans = n * (n + 1) / 2;
  long long k, l, m;
  k = n / 3;
  l = n / 5;
  m = n / 15;
  ans -= 3 * k * (k + 1) / 2;
  ans -= 5 * l * (l + 1) / 2;
  ans += 15 * m * (m + 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string.h>

using namespace std;
char field[14][14];
int dx[12] = {-3, -2, -1, 0, 0, 0,  0,  0,  0, 1, 2, 3};
int dy[12] = { 0,  0,  0, 1, 2, 3, -1, -2, -3, 0, 0, 0};

void DFS(int y, int x)
{
	field[y][x] = '0';
	for(int i = 0; i < 12; ++i)
	{
		int X = x + dx[i];
		int Y = y + dy[i];
		if((3 <= X && X <= 10 && 3 <= Y && Y <= 10) && field[Y][X] == '1')
		{
			DFS(Y, X);
		}
	}		
}

void solve()
{
	int n;
	cin >> n;
	int count = 0;
	while(n--)
	{
		count++;
		memset(field, 0, sizeof(field));
		for(int i = 3; i < 11; ++i)
		{
			for(int j = 3; j < 11; ++j)
			{
				cin >> field[i][j];
			}
		}
		int x, y;
		cin >> x >> y;
		DFS(y + 2, x + 2);
		cout << "Data " << count << ":" << endl;
		for(int i = 3; i < 11; ++i)
		{
			for(int j = 3; j < 11; ++j)
			{
				cout << field[i][j];
			}
			cout << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		for (int i = 0; i < n.length();i++) {
			if (n.charAt(i) == '1') {
				System.out.print('9');
			} else {
				System.out.print('1');
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<bool>dp((int)s.size()+1213,0);
  int n=s.size();
  dp.at(0)=1;
  for(int i=0;i<n;++i){
    if(dp.at(i)==0)continue;
    if(i+5<=n && s.substr(i,5)=="dream")dp.at(i+5)=1;
    if(i+7<=n && s.substr(i,7)=="dreamer")dp.at(i+7)=1;
    if(i+5<=n && s.substr(i,5)=="erase")dp.at(i+5)=1;
    if(i+6<=n && s.substr(i,6)=="eraser")dp.at(i+6)=1;
  }
  if(dp.at(n))cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
    using namespace std;
     
    const int M = 50;
     
    int n, m,g[M+10][M+10];
    pair<int, int> a[M+10];
    bool bo[M + 10];
     
    void dfs(int x)
    {
        if (bo[x]) return;
        bo[x] = true;
        for (int i = 1;i <= n;i++)
            if (i!=x && g[x][i])
                dfs(i);
    }
     
    int main()
    {
        //freopen("F:\\rush.txt", "r", stdin);
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= m; i++)
        {
            int x, y;
            scanf("%d%d", &x, &y);
            g[x][y] = g[y][x] = 1;
            a[i] = make_pair(x, y);
        }
     
        int ans = 0;
        for (int i = 1; i <= m; i++)
        {
            g[a[i].first][a[i].second] = 0;
            g[a[i].second][a[i].first] = 0;
            for (int j = 1; j <= n; j++) bo[j] = 0;
            dfs(1);
            int ok = false;
            for (int j = 1; j <= n; j++)
                if (bo[j] == 0)
                    ok = 1;
            ans += ok;
            g[a[i].first][a[i].second] = 1;
            g[a[i].second][a[i].first] = 1;
        }
        printf("%d\n", ans);
        return 0;
    }

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    string t;
    string u;
    int a;
    int b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(s==u){
        a-=1;
    }else{
        b-=1;
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;
using pl  = pair<ll,ll>;
using tl  = pair<pl,ll>;

#define ff first
#define ss second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
const ll inf = 1e9;

int main() {
    ll h, w, n;
    cin >> h >> w >> n;
    swap(h,w);
    vvl xs(h, vl(1, w));
    rep(i,n) {
        int x, y; scanf("%d %d", &x, &y);
        x--; y--;
        if (x >= y) xs[y].push_back(x);
    }
    rep(i,h) sort(all(xs[i]));

    ll ans = xs[0][0];
    ll l = 0, r = xs[0][0];
    rng(y,1,h) {
        ans = min(ans, r);
        int l_i = lower_bound(all(xs[y]), l+1) - xs[y].begin();
        int r_i = lower_bound(all(xs[y]), r-1) - xs[y].begin();

        ll curr = l;
        rng(i,l_i,r_i+1) {
            ll next = xs[y][i];
            if (next - curr > 1) {
                l = curr+1, r = next;
                break;
            }
            curr = next;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

long long mod_pow(long long x, long long n, long long mod = 1e9 + 7) {
    long long ans = 1;
    while(n > 0) {
        if ((n % 2) == 0) {
            x = (x * x) % mod;
            n >>= 1;
        }
        else {
            ans = (ans * x) % mod;
            n--;
        }
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(k + 1, 0);
    ll ans = 0;
    rreps(i, 1, k + 1) {
        ll tmp = mod_pow(k / i, n, mod);
        ll cv = i * 2;
        while(cv <= k) {
            tmp = (tmp - cnt[cv] + mod) % mod;
            cv += i;
        }
        cnt[i] = tmp;
        ans = (ans + tmp * i) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3988
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,c,k,t[100000],cnt = 0;
	cin >> n >> c >> k;
	for(int i = 0;i < n;i++) cin >> t[i];
	sort(t,t + n);
	for(int i = 0;i < n;i++){
		cnt++;
		int nt = t[i] + k;
		for(int j = 0;j < c - 1;j++){
			if(t[i + 1] <= nt) i++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
N=int(input())
a=list(map(int,input().split()))
L=[str(bin(i))[2:] for i in a]
dic=dict([(i,0) for i in range(32)])
for s in L:
    for i,c in enumerate(s[::-1]):
        if c=='1':
            dic[i]+=1
for i in dic.values():
    if i%2==1:
        print("No")
        exit(0)
else:
    print("Yes")



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

int main() {
	string a, b;
	cin >> a >> b;
	int c = stoi(a + b);

	for (int i = 1; i <= 1000; i++) {
		if (c == i * i){cout << "Yes"; return 0;
	}
	}
	cout << "No";
}

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

int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> a(M), b(N+1,-1);
  for (int i = 0; i < M; ++i) cin >> a.at(i);
  
  bool isCandi = true;
  for (int i = 1; i < M; ++i) {
    if(a.at(i) - a.at(i-1) == 1) isCandi = false;
  }
  
  if (isCandi) {
    b.at(0) = 1;
    b.at(1) = 1;
    for (int i = 0; i < M; ++i) b.at(a.at(i)) = 0;
    for (int i = 2; i < N+1; ++i) {
       if(b.at(i) != 0) {
          b.at(i) = b.at(i-1) + b.at(i-2);
       }
      b.at(i) %= 1000000007; // 加算は連続modulo
    }
    cout << b.at(N) << endl;
  }
  else cout << 0 << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env pypy3
 
def main():
    string = input()
    count = 0
    maxv = -1
    for s in string:
        if s == "R":
            count = count + 1
        else:
            maxv = max(count, maxv)
            count = 0
    maxv = max(count, maxv)
    print(maxv)
 
main()

Measured memory_bytes: 61676