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


int pos[200000];
int idx = 0;

int findL(int l){
    int lb = -1, ub = idx;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        if (pos[mid] >= l)
            ub = mid;
        else
            lb = mid;
    }
    return ub;
}

int findR(int r){
    int lb = -1, ub = idx;
    while(ub - lb > 1){
        int mid = (lb + ub) / 2;
        if (pos[mid] <= r)
            lb = mid;
        else
            ub = mid;
    }
    return lb;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, q;
    cin >> n >> q;
    
    string s;
    cin >> s;

    for (int i = 1; i < s.length(); i++){
        if (s[i] == 'C' && s[i - 1] == 'A')
            pos[idx++] = i;
    }

    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        r--;
        int fdl = findL(l), fdr = findR(r);
        
        if (fdr < fdl)
            cout << "0\n";
        else
            cout << fdr - fdl + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main(){
  string alf = "abcdefghijklmnopqrstuvwxyz";
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  int p = 0, l = s.size();
  string ans = "";
  for(int i=0; i<26; ++i){
    bool e = false;
    for(int j=p; j<l; ++j){
      if(alf[i] == s[j]) e = true;
      if(alf[i] < s[j]){
        if(!e) ans.push_back(alf[i]);
        p = j;
        break;
      }
    }
    if(!e) ans.push_back(alf[i]);
  }
  if(ans.size()) cout << ans[0] << endl;
  else cout << "None" << endl;
}

Measured memory_bytes: 3688
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,x,y) for(int i=x;i<y;i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b)swap(a,b);
    if(a+w>=b){
        cout<<0;
    }else{
        cout<<b-(a+w);
    }

    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a[i] = ai;
  }

  vector<int> b;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
	b.push_back(a[i]);
      } else {
	b.insert(b.begin(), 1, a[i]);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i % 2 != 0) {
	b.push_back(a[i]);
      } else {
	b.insert(b.begin(), 1, a[i]);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << b[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
#include<string.h>


  char str[12];

int calc(){
  int num=0;
  int n=0;
  int i;
  for(i=0;i<11;i++){
    if(0<=i&&i<=4){
      num+=(str[i]-'0')*(6-i)%11;
    }else {
      num+=(str[i]-'0')*(12-i)%11;
    }
  }
  n=num%11;
  if(n<=1){
    return 0;
  }else return 11-n;
}

int main(){
  int i=0;
  int index=0;
  char ans= ' ';
  int c;
  gets(str);

  for(i=0; i<12; i++){
    if(str[i]=='?'){
      index=i;
    } 
  }

  if(index==11){
    printf("%d\n",calc());
  }else{
    char c;
    for(c='0'; c<='9'; ++c){
      str[index]=c;

      if(str[11]-'0'!=calc()) continue;
      if(ans==' '){
	ans=c;
      }else ans='#';
    }

    if(ans=='#'){
      puts("MULTIPLE");
    }else printf("%c\n",ans);
  }
  return 0;
}

Measured memory_bytes: 524
S=input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            a=int(S[0])
            if i==0:
                a+=int(S[1])
            else:
                a-=int(S[1])
            if j==0:
                a+=int(S[2])
            else:
                a-=int(S[2])
            if k==0:
                a+=int(S[3])
            else:
                a-=int(S[3])
            if a==7:
                b=[i,j,k]
                break
st=S[0]
for l in range(3):
    if b[l]==0:
        st+="+"+S[l+1]
    else:
        st+="-"+S[l+1]
print(st+"=7")


Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

using mint = atcoder::modint998244353;

ll N;
ll h[100010];
mint fact[100010], inv[100010], dfact[100010];
std::map<ll, ll> cnt;

int main() {
  std::cin >> N;

  rep( i, 2*N ) {
    std::cin >> h[i];

    ++cnt[h[i]];
  }

  std::vector<ll> fs;
  
  for( auto m : cnt )
    fs.emplace_back( m.second );

  ll M = fs.size();

  fact[0] = mint(1);
  rep( i, 2*N )
    fact[i+1] = fact[i]*(i+1);

  inv[2*N] = fact[2*N].inv();
  repd( i, 2*N )
    inv[i] = inv[i+1]*(i+1);

  // dfact[i] = (2*i-1)!!
  dfact[0] = mint(1);
  rep( i, N )
    dfact[i+1] = dfact[i]*(2*i+1);

  std::vector<std::vector<mint>> d( M );

  rep( i, M ) {
    ll k = fs[i]/2;

    rep( j, k+1 )
      d[i].emplace_back( fact[fs[i]]*inv[2*j]*inv[fs[i]-2*j]*dfact[j] );
  }

  while( d.size() != 1 ) {
    auto pd = d;

    d = std::vector<std::vector<mint>>();

    rep( i, pd.size() ) {
      auto a = pd[i];

      if( i == pd.size()-1 ) {
        d.emplace_back( a );

        break;
      }

      auto b = pd[++i];

      d.emplace_back( atcoder::convolution(a,b) );
    }
  }

  mint ans = 0;

  rep( i, d[0].size() ) {
    ans += d[0][i]*(i&1 ? -1 : 1)*dfact[N-i];
  }

  std::cout << ans.val() << endl;

  return 0;
}

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

namespace myApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
            Console.WriteLine(inputs[2] / inputs[0] * inputs[1]);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(void){
	int W, H, x, y, r;
	
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if((((x - r) >= 0) && ((x + r) <= W)) && (((y - r) >= 0) && ((y + r)<= H))){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return(0);
}

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

using namespace std;
typedef long long ll;
int main() {
	int n;
	scanf("%d", &n);
	int a = n % 10;
	int b = n / 10;
	if (a == 9 || b == 9) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a;
        rep(i,n)
        {
            vp(a,x);
        }
        c=INT_MAX;
        Rep(i,100)
        {
            x=i,s=0;
            rep(j,n)
            {
                y=a[j];
                s+=(x-y)*(x-y);
            }
            c=min(c,s);
        }
        cout<<c<<en;
    }
}



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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int n;
    while (cin >> n) {
        string s;
        cin >> s;

        int c = 1;
        forr(i, 1, n) {
            if (s[i] != s[i - 1]) {
                c++;
            }
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 200001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int arr[3]; cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    cout << arr[0] + arr[1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#define  _USE_MATH_DEFINES
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int binary_search(vector<int> v, int q) {
 
  int l = 0;
  int r = v.size() - 1;
  int mid = 0;

  while (l <= r) {
    mid = (l + r) / 2;
    if (v[mid] > q)
      r = mid - 1;
    else if (v[mid] < q)
      l = mid + 1;
    else
      return mid;
  }
  return -1;
}

int main() {

  int n;
  cin >> n;
  
  vector<int> v(n);
  rep(i, n) cin >> v[i];

  int m;
  cin >> m;

  int ans = 0, q;
  rep(i, m) {
    cin >> q;
    int x = binary_search(v, q);
    if (x > -1)
      ans += 1;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int compute_remaining_characters(const vector<int>& characters,int idx,int color){
  int prev_lhs = idx;
  int prev_rhs = idx - 1;
  int lhs = idx;
  int rhs = idx;

  for(int round = 0; round <= characters.size(); round++){
    color = characters[lhs];
    for(;lhs >= 0;lhs--){
      if(characters[lhs] != color){
	lhs++;
	break;
      }
    }
    for(;rhs < characters.size();rhs++){
      if(characters[rhs] != color){
	rhs--;
	break;
      }
    }
    if(lhs < 0) lhs++;
    if(rhs >= characters.size()) rhs--;
    
    if((rhs - lhs + 1)-(prev_rhs-prev_lhs + 1) < 4){
      break;
    }
    prev_lhs = lhs;
    prev_rhs = rhs;
    
    //next pos
    lhs--;
    rhs++;
  }
  return characters.size() - (prev_rhs - prev_lhs + 1);
}

int main(){
  int n;
  while(~scanf("%d",&n)){
    if(n==0) break;

    vector<int> characters;
    for(int i=0;i<n;i++){
      int color;
      scanf("%d",&color);
      characters.push_back(color);
    }

    int res = n;
    for(int idx=0;idx<characters.size();idx++){
      for(int color=1;color<=3;color++){
	vector<int> store = characters;
	characters[idx] = color;
	res = min(res,compute_remaining_characters(characters,idx,color));
	characters = store;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1316
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    string s, t;
    cin >> s >> t;
    bool flag = false;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]) flag = true;
    }
    if(flag) puts("No");
    else puts("Yes");
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;



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

  string s;
  cin >> s;
  if (s[sz(s) - 1] == 's')
    s += "es";
  else 
    s += "s";
  cout << s;
}

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

int main() {
	int n,k,ans=0;
	cin >> n >> k;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	sort(p.begin(),p.end());
	for(int i=0;i<k;i++){
		ans+=p[i];
	}
	cout << ans <<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

ll as[MAX], acc[MAX];
map <ll, ll> mp;
void solve(void){
    ll N;
    cin >> N;
    rep(N, i) scanf("%lld ", &as[i]);
    acc[0] = 0LL;
    rep(N, i) {
        acc[i+1] = acc[i] + as[i];
    }
    rep(N+1, i) {
        mp[acc[i]]++;
    }
    ll ans = 0LL;
    for (P p : mp) {
        ll x = p.second;
        ans += x*(x-1)/2;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll n,a[22][22],dp[(1<<18)];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
    for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++){
        if(((i>>j)&1)==1){
            dp[i]=dp[i-(1<<j)];
            for(int k=0;k<n;k++)if(((i>>k)&1)==1)dp[i]+=a[j][k];
        }
    }
    for(int i=0;i<(1<<n);i++)for(int j=i;j;j=(j-1)&i)dp[i]=max(dp[i],dp[j]+dp[i^j]);
    cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=2e3+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int x,ans;
int main(){
	sci(x);
	ans=(x/500)*1000+(x%500)/5*5;
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,m; 
    cin>>n>>m; 
    string a[n],b[m];
    for (int i=0;i<n;i++) cin>>a[i];
    for (int i=0;i<m;i++) cin>>b[i];
    for (int i=0;i<=n-m;i++){
    	for (int j=0;j<=n-m;j++){
    		bool ok=true;
    		for (int k=i,ii=0;k<n and ii<m;k++,ii++){
    			for (int l=j,jj=0;l<n and jj<m;l++,jj++){
    				if(b[ii][jj] != a[k][l]) ok=false;
    			}
    			if(!ok) break;
    		}
    		if (ok){
    			printf("Yes\n");
    			return;
    		}
    	}
    }
    printf("No\n");
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n;
char s[101];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>(s+1);
	if(n&1) return cout<<"No"<<'\n',0;
	for(res i=1;i<=n/2;++i) if(s[i]!=s[i+n/2]) return cout<<"No"<<'\n',0;
	cout<<"Yes"<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
<?php
  
$n = trim(fgets(STDIN));
$s = trim(fgets(STDIN));

for($i=0; $i<strlen($n); $i++){
  $nn[$i] = $n[$i];
  $ss[$i] = $s[$i];
}

$ans = 'No';
for($i=0; $i<strlen($n); $i++){
  array_unshift($nn, $nn[count($nn)-1]);
  array_pop($nn);
  if ($nn == $ss){
    $ans = 'Yes';
    break;
  }
}

echo $ans;

  
?>

Measured memory_bytes: 4604
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define vvl(n,m) vector<vector<ll> > a( n , vector<ll> (m))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = -1000000000000000, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 
ll countPairs(ll arr[], ll n) 
{ 
    map<ll, ll> map; 
    for (ll i = 0; i < n; i++) {
        if (map.find(arr[i]-i) == map.end()) { 
            map[arr[i]-i] = 1; 
        } 
        else { 
            map[arr[i]-i]++; 
        } 
    }
    ll res = 0; 
    for (auto x : map) { 
        ll cnt = x.second; 

        res += ((cnt * (cnt - 1)) / 2); 
    } 
  
    return res; 
} 
ll findSubarraySum(ll arr[], ll n, ll sum) 
{ 
    unordered_map<ll, ll> prevSum; 
  
    int res = 0; 
  
    int currsum = 0; 
  
    for (int i = 0; i < n; i++) { 
        currsum += arr[i]; 
        if (currsum == sum)  
            res++;         
  
        if (prevSum.find(currsum - sum) !=  
                                  prevSum.end())  
            res += (prevSum[currsum - sum]);
        prevSum[currsum]++; 
    } 
  
    return res; 
} 
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
long long modpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    fast
    string s;
    ll i,c=0;
    cin>>s;
    for(i=0;i<3;i++){
        if(s[i]=='R')
        c++;
    }
    if(c<2 || c==3)
    cout<<c;
    else if(c==2){
        if(s[1]=='R')
        cout<<"2";
        else
        cout<<"1";
    }
}

Measured memory_bytes: 3652
//
//  main.cpp
//  C - Traveling Salesman around Lake
//
//  Created by Hashizo on 2020/03/28.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = 0;
	
	
	ll k,n;
	cin >> k >> n;
	
	vector<ll> a(n+1);
	a[0] = 0;
	vector<ll> point(n);
	REP(i, n) {
		cin >> a[i+1];
		point[i] = a[i+1] - a[i];
	}

	point[0] += (k - a[n]);
	
	SORT(point);
	
	REP(i, n-1) {
		ans += point[i];
	}
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n,count = 0;
    cin >> n;
    vector<int>v(n);
    vector<int>check(n);

    for(int i = 0;i < n;i++){
        cin >>v[i];
        check[i] = i+1;
    }

    for(int i = 0;i < n;i++){
        if(v[i] != check[i]){
            count++;
        }
    }

    if(count == 2 || count == 0){
        cout << "YES" <<endl;
    }else 
        cout << "NO" <<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;

char dir[]{ 'r','g','b' };
int main() {
	string s;
	while (cin >> s, s != "0") {
		queue<string>que;
		unordered_map<string, int>mp;
		que.push(s);
		mp[s] = 1;
		while (!que.empty()) {
			string u = que.front(); que.pop();
			int r, g;
			if ((r = count(u.begin(), u.end(), 'r')) == u.size() ||
				(r == 0 && (g = count(u.begin(), u.end(), 'g')) == u.size()) ||
				(r == 0 && g == 0)) {
				printf("%d\n", mp[u] - 1);
				goto goal;
			}
			rep(i, u.size() - 1) {
				if (u[i] != u[i + 1]) {
					string v = u;
					v[i] = v[i + 1] = dir[3 - (find(dir, dir + 3, u[i]) - dir) - (find(dir, dir + 3, u[i + 1]) - dir)];
					if (!mp[v]) {
						mp[v] = mp[u] + 1;
						que.push(v);
					}
				}
			}
		}
		puts("NA");
	goal:;
	}
}

Measured memory_bytes: 4648
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	string s, t;
	cin >> s >> t;
	string u = s + s;
	bool ans = false;
	for (int i = 0; i < (int)s.length(); ++i) {
		if (u.substr(i, s.length()) == t) {
			ans = true;
			break;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n, first, second int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)

	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())

		if i == 1 {
			if a[0] >= a[1] {
				first = a[0]
				second = a[1]
			} else {
				first = a[1]
				second = a[0]
			}
		}
		if i > 1 {
			if a[i] > first {
				second = first
				first = a[i]
			} else if a[i] > second {
				second = a[i]
			}
		}
	}

	if first == second {
		for i := 0; i < n; i++ {
			fmt.Println(first)
		}
	} else {
		for i := range a {
			if a[i] != first {
				fmt.Println(first)
			} else {
				fmt.Println(second)
			}
		}
	}
}


Measured memory_bytes: 6400
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<char> vc;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;
typedef vector<vector<char>> vcc;

class ATwoIntegers {
public:
    int X, Y;
    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>X>>Y;
    }

    void solve(std::istream& in, std::ostream& out){
        input(in, out);
        if(X%Y==0) out<<"-1\n";
        else out<<X<<'\n';
    }
};


int main() {
	ATwoIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n=0, w=0, ss=0,e=0;
    rep(i, s.size()) {
        if (s.at(i) == 'N')
            n++;
        else if (s.at(i) == 'W')
            w++;
        else if (s.at(i) == 'S')
            ss++;
        else if (s.at(i) == 'E')
            e++;
    }
    if (n == 0 && ss != 0) {
        puts("No"); return 0;
    }
    if (ss == 0 && n != 0) {
        puts("No"); return 0;
    }
    if (w == 0 && e != 0) {
        puts("No"); return 0;
    }
    if (e == 0 && w != 0) {
        puts("No"); return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    a70(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a70(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val str = args[0]
    println(if (str == str.reversed()) "Yes" else "No")
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    std::map< int, int > mp;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        auto itr = mp.find(A[i]);
        if(itr != mp.end()){
            mp[A[i]]++;
        }else{
            mp[A[i]] = 1;
        }
    }
    
    long long ans_all = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        int cnt = itr->second;
        long long c = 1;
        for(int i=0; i<2; i++){
            c = c * (cnt - i) / (i + 1);
        }
        ans_all += c;
    }
    
    for(int i=0; i<N; i++){
        int cnt = mp[A[i]];
        long long c = 1;
        for(int i=0; i<2; i++){
            c = c * (cnt - i) / (i + 1);
        }
        long long c_1 = 1;
        for(int i=0; i<2; i++){
            c_1 = c_1 * (cnt - i - 1) / (i + 1);
        }
        long long ans_cur = ans_all - c + c_1;
        std::cout << ans_cur << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
#define int long long

struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init(-1);}
  BIT(int n_){init(n_);}
  void init(int n_){
    n=n_;
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    if(i==0) return;
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};


signed main(){
  string s;
  int k;
  cin>>s>>k;
  int n=s.size();
  string ans;
  BIT bit(n+100);
  queue<int> p[26];
  for(int i=0;i<n;i++)
    p[s[i]-'a'].push(i);
  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      if(p[j].empty()) continue;
      char c='a'+j;
      int e=p[j].front();
      int x=e+bit.sum0(e);
      if(x<=k){
	p[c-'a'].pop();
	bit.add0(e,-1);
	k-=x;
	ans.push_back(c);
	break;
      }
    }
    //cout<<k<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6784
def is_in_rectangle(W,H,x,y,r):
    """円の4点ではみだし判定を行う"""
    left=x-r
    right=x+r
    top=y+r
    bottom=y-r
    
    if left<0:
        return False
        
    if right>W:
        return False
        
    if top>H:
        return False
        
    if bottom < 0:
        return False
        
    return True


def show_result(flag):
    if flag:
        print("Yes")
    else:
        print("No")

line=input()
W,H,x,y,r=tuple(map(int,line.split(" ")))
result=is_in_rectangle(W,H,x,y,r)

show_result(result)



Measured memory_bytes: 5600
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(calculator9x9(a,b));

	}
	
	static int calculator9x9(int a, int b) {
		if(a > 9 || b > 9) {
			return -1;
		}else {
			return a*b;
		}		
	}
}



Measured memory_bytes: 21844
#include<stdio.h>

// define
#define MAX_INPUT 1000

// function
void inputArray(int a[], int *num);
void insertionSort(int a[], int num);

int main(void)
{
  int size;
  int input[MAX_INPUT];
  
  inputArray(input, &size);
  insertionSort(input, size);
  
  return 0;
}

void inputArray(int a[], int *num)
{
  //  printf("input array size =\n");
  scanf("%d", num);

  //  printf("input array = \n");
  for ( int i = 0; i < *num; i++ ) {
    scanf("%d", &a[i]);
  }

  for (int k=0; k < *num-1; k++) {
    printf("%d ", a[k]);
  }
  printf("%d\n", a[*num-1]);
}

void insertionSort(int a[], int num)
{
  int v;
  int j;
  
  for (int i=1; i < num; i++) {
    v = a[i];
    j = i - 1;
    while ( (j >= 0) && (a[j] > v) ) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    
    for (int k=0; k < num-1; k++) {
      printf("%d ", a[k]);
    }
    printf("%d\n", a[num-1]);
  }
}

Measured memory_bytes: 1028
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
	fastio();
	string s;
	cin>>s;
	int n=s.length();
	if(s[0]==s[n-1])
	{
		int remove=n-3;
		if(remove%2==0)
		{
			cout<<"Second\n";
		}
		else
		{
			cout<<"First\n";
		}
	}
	else
	{
		int remove=n-2;
		if(remove%2==0)
		{
			cout<<"Second\n";
		}
		else
		{
			cout<<"First\n";
		}
	}
}


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

int main() {
  	int A,B;
  	cin >> A >> B;
  
  	if( A >= 13)
      cout << B << endl;
  	else if( A >= 6 && A <= 12 )
      cout << B/2 << endl;
  	else
      cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int sum =0;
		for (int i=0;i<N;i++) {
			int a= sc.nextInt();
			if (K-a<a) {
				sum = sum + (K-a)*2;
			} else {
				sum = sum + 2*a;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, n;
    cin >> h >> n;
    vi dp(h+1, INF);
    dp[0] = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        rep(j, h) {
            int nj = min(j + a, h);
            chmin(dp[nj], dp[j] + b);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define pb(x)                       push_back(x)
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;
ll n, m;
vector<ll> adj[MAXN];
bool mark[MAXN];
ll dp[MAXN];

ll memoize(ll v){
    if (mark[v])
        return dp[v];
    for (auto u:adj[v]){
        dp[v] = max(dp[v],memoize(u) + 1);
    }
    mark[v] = true;
    return dp[v];
}

int main()
{
    fast_io;
    cin >> n >> m;
    ll a,b;
    for (int i = 1;i <= m;i++){
        cin >> a >> b;
        adj[a].push_back(b);
    }
    ll ans = 0;
    for (int i = 1; i <= n;i++){
        memoize(i);
        ans = max(ans,dp[i]);
    }
    cout << ans;
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll x, y, z;
  cin >> x >> y >> z;

  ll c = 0, sp = z;

  while(1){
    sp += y + z;
    if(sp > x){
      cout << c << endl;
      return 0;
    }
    c++;
  }


  return 0;
}


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

int main() {
  ll a,b,ans=0;
  cin >> a >> b;
  if(a>b) {
  	ans+=a;a--;
  }
  else{
  	ans+=b;b--;
  }
  ans+=max(a,b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll a, b, n, x;
	cin >> a>> b >> n;
	if (n>=(b-1)) x= b -1;
	else x = n;
	cout << (a*x)/b << endl;
	return 0;
}


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

int main() {
  char vowels[] = {'a', 'e', 'i', 'o', 'u'};
  char a;
  cin >> a;
  for (int i = 0; i < sizeof(vowels); i++) {
  	if (vowels[i] == a) {
    	cout << "vowel" << endl;
      	return 0;
    }
  }
  cout << "consonant" << endl;
}


Measured memory_bytes: 256
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
const int N = 11;
vector<array<int, 3>> v[N];
vector<vector<int>> cases;
int n, m, q;
void dfs(int x, int last, vector<int> &v) {
	if (x == n + 1) {
		cases.pb(v);
		return;
	}
	for (int i = last; i <= m; i++) {
		v[x] = i;
		dfs(x + 1, i, v);
	}
}
void solve() {
	cin >> n >> m >> q;
	for (int i = 1; i <= q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		v[b].pb({a, c, d});
	}
	int ans = 0;
	vector<int> d(n + 1);
	dfs(1, 1, d);
	for (auto &it : cases) {
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			for (auto &j : v[i]) {
				if (it[i] - it[j[0]] == j[1]) {
					sum += j[2];
				}
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 13924
def solve():
    from sys import stdin
    INF = float('inf')
    f_i = stdin
    
    while True:
        N, M = map(int, f_i.readline().split())
        if N == 0:
            break
        
        C = tuple(int(f_i.readline()) for i in range(M))
        
        # decode table
        tbl_1 = tuple(tuple(255 if i + c > 255 else 0 if i + c < 0 \
                            else i + c for c in C) for i in range(256))
        
        # tabale of squared difference
        tbl_2 = tuple(tuple((i - j) ** 2 for j in range(256)) \
                      for i in range(256))
        
        dp1 = [INF] * 256
        dp2 = [INF] * 256
        dp1[128] = 0
        
        for i in range(N):
            x = int(f_i.readline())
            tbl_2_x = tbl_2[x]
            for signal, pre_cost in enumerate(dp1):
                for decoded in tbl_1[signal]:
                    new_cost = pre_cost + tbl_2_x[decoded]
                    if new_cost < dp2[decoded]:
                        dp2[decoded] = new_cost
            dp1 = dp2[:]
            dp2 = [INF] * 256
        
        print(min(dp1))

solve()


Measured memory_bytes: 10900
#include<bits/stdc++.h>
using namespace std;
int main(){
    int flag=0,i;
    string s;
    cin>>s;
    for(i=0;s[i]!='\0';i++){
        if(i%2==0){
            if(!(s[i]=='R' || s[i]=='U' || s[i]=='D'))
            {   flag++;
                break;
            }
        }
        else
        {
            if(!(s[i]=='U' || s[i]=='L'|| s[i]=='D' ))
            {
                flag++;
                break;
            }
        }
        
    }
    if(flag==0)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3612