akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<map>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    string s;
    cin>>s;
    map<char,bool> alpha;

    if(s=="zyxwvutsrqponmlkjihgfedcba")
    {
        cout<<-1<<endl;
        return 0;
    }
    rep(i,s.size())
    {
        alpha[s[i]] = true;
    }
    for (char c = 'a'; c <= 'z'; c++)
    {
        if(alpha[c]==false)
        {
            s += c;
            cout << s << endl;
            return 0;
        }
        
    }
    string o =s;
    if(next_permutation(s.begin(),s.end()))
    {
        rep(j,s.size())
        {
            if(s[j]==o[j]) cout<<s[j];

            else
            {
                cout<<s[j]<<endl;;
                
                return 0;
            }
            
        }
        cout<<s<<endl;
        return 0;

    }


    cout<<-1<<endl;
    

}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
        vector<int> B(N);

    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        B.at(i) = A.at(i);
    }

    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());

    for(int i = 0; i < N; i++){
        if(B.at(i) == A.at(0))cout << A.at(1)<<endl;
        else cout << A.at(0) <<endl;
    }


}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string s, t;
    cin >> s >> t;
    int N = s.size();
    vector<int> ID1(N), ID2(N);
    map<int, int> id1, id2;
    int nowid1 = 1, nowid2 = 1;
    for (int i = 0; i < N; i++) {
        if (!id1[s[i]]) {
            id1[s[i]] = nowid1++;
        }
        ID1[i] = id1[s[i]];
    }
    for (int i = 0; i < N; i++) {
        if (!id2[t[i]]) {
            id2[t[i]] = nowid2++;
        }
        ID2[i] = id2[t[i]];
    }
    for (int i = 0; i < N; i++) {
        if (ID1[i] != ID2[i]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2452
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
	  bool[] s = new bool[31];
	  for (int i = 0; i < 28; i++)
	  {
	    s[cin.nextInt()] = true;
	  }
	  for (int i = 1; i < 31; i++)
	  {
	    if (!s[i])
	    {
	      Console.WriteLine(i);
	    }
	  }
		return 0;
	}

}

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++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

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

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

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

}

Measured memory_bytes: 5612
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;




int main(int argc, char* argv[])
{
    int n, m;
    scanf("%d%d", &n, &m);

    vector<vector<int> > z(n), w(n);
    vector<int> cnt(n);
    int i;
    for(i=0; i<n+m-1; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        z[a-1].push_back(b-1);    // par->child
        w[b-1].push_back(a-1);    // child->par
        cnt[b-1]++;
    }

    vector<int> topo(n);
    set<int> ss;
    for(i=0; i<n; i++) {
        if(cnt[i]==0) ss.insert(i);
    }
    int count=0;
    while(!ss.empty()) {
        auto it=ss.begin();
        topo[*it]=count;
        count++;

        int m;
        for(m=0; m<(int)z[*it].size(); m++) {
            cnt[z[*it][m]]--;
            if(cnt[z[*it][m]]==0) ss.insert(z[*it][m]);
        }
        ss.erase(it);
    }
    if(count!=n) return 12;

    for(i=0; i<n; i++) {
        int max=-1;
        int maxk=-1;
        int k;
        for(k=0; k<(int)w[i].size(); k++) {
            if(max<topo[w[i][k]]) {
                max=topo[w[i][k]];
                maxk=w[i][k];
            }
        }
        printf("%d\n", maxk+1);
    }

    return 0;
}


Measured memory_bytes: 14456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long  ans=10000000000;
  long long  sum=0;
  long long  A;
  cin >> N ;
  for(int i = 0; i < N; i++){
    cin >> A;
    sum=0;
    while(A % 2 ==0) {
      sum++;
      A /= 2;
    }
    if (sum <= ans ) ans = sum;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  double t, x;
  cin >> t >> x;
  double ans = t / x;

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


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

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}
int main(void)
{
 ll n, x, y, h, ansx, ansy, ansh;
 cin >> n;
 vector<ll> X(n), Y(n), H(n);
 RAP(i, n){
   cin >> X[i] >> Y[i] >> H[i];
 }
 bool flag = true, checkflag;
 RAP(i, n){
   if(H[i] != 0){
     flag = false;
     h = H[i];
     x = X[i];
     y = Y[i];
     break;
   }
 }
 RAP(i, 101){
     RAP(j, 101){
       checkflag = true;
       ansx = i;
       ansy = j;
       ansh = h + abs(x-i) + abs(y-j);
       RAP(check, n){
         if(H[check] != max(ll(0), ansh - abs(X[check]-ansx) - abs(Y[check]-ansy))){
           checkflag = false;
         }
       }
       if(checkflag){
         cout << ansx << " " << ansy << " " << ansh << endl;
         return 0;
       }
     }
   }
 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    string fa="Alice";
    if(a==b){
        fa="Draw";
    }
    else if(b==1||a!=1&&a<b){
        fa="Bob";
    }
    cout<<fa<<endl;     
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,0,4){
    if(s[i] == '-')ans--;
    else ans++;
  }
  cout << ans << endl;
}

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

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

  vector<vector<int>> G(N, vector<int>(N, 1e9));
  vector<vector<int>> V(M, vector<int>(3));
  for (int i = 0, a, b, c; cin >> a >> b >> c; i++) {
    G.at(--a).at(--b) = c;
    G.at(b).at(a) = c;
    V.at(i).at(0) = a;
    V.at(i).at(1) = b;
    V.at(i).at(2) = c;
  }
  for (int i = 0; i < N; i++) {
    G.at(i).at(i) = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i) + G.at(i).at(k));
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    int a = V.at(i).at(0);
    int b = V.at(i).at(1);
    int c = V.at(i).at(2);
    if (G.at(a).at(b) < c) cnt++;
  }
  cout << cnt << "\n";
}

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

int main() {
  int N, K, ans;
  cin >> N >> K;
  ans = 1;
  for (int i = 0; i < N; i++) {
     int mul, add;
     mul = ans * 2;
     add = ans + K;
     if (mul >= add) {
       ans = add;
     }
     else {
       ans = mul;
     }
  }
  cout << ans;
}


Measured memory_bytes: 3572
let input_int_array n =
  Array.init n (fun _ -> Scanf.scanf "%d " (fun v -> v))
  
let () =
  let ar = input_int_array 3
  in Array.sort Pervasives.compare ar;
  let a,b,c = match ar with
    | [|a;b;c|] -> a,b,c
    | _ -> failwith ""
  in
  let rec f0 a b c = match (a mod 2, b mod 2, c mod 2) with
    | 0,0,0 | 1,1,1 ->
      (c-a)/2 + (c-b)/2
    | 0,0,1 | 1,1,0 ->
      (b-a)/2 + c-b (*a,b,c=>b,b,c*)
    | 0,1,0 | 1,0,1 ->
      (c+1-b)/2 + f0 a c (c+1) (*a,b,c=>a,c,(c+1)*)
    | 0,1,1 | 1,0,0 ->
      (c+1-a)/2 + f0 b c (c+1) (*a,b,c=>b,c,(c+1)*)
    | _ -> failwith ""
  in
  f0 a b c |> string_of_int |> print_endline


Measured memory_bytes: 512
N, M = map(int, input().split())
a = list()

answer = 0
for i in range(N):
    a.append(list(map(int, input().split())))

for i in range(M + 1):
    count = 0
    for j in range(N):
        if i in a[j][1:]:
            count += 1
    if count == N:
        answer += 1

print(answer)

Measured memory_bytes: 3064
N, M = gets.split.map(&:to_i)
ab = []
M.times do |i|
    ab[i] = gets.split.map(&:to_i)
end
ab.sort_by!{|arr| arr[1]}

ans = 0
last = -1
ab.each do |a, b|
    if last <= a
        ans += 1
        last = b
    end
end
puts ans

Measured memory_bytes: 12664
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#include "Union_Find.h"
int N;
string S[50];
int A[50][26];

int main() {
	cin >> N;
	REP(i, 0, N) {
		cin >> S[i];
	}
	REP(i, 0, N) {
		for (char a : S[i]) {
			A[i][a - 'a']++;
		}
	}
	REP(c, 0, 26) {
		int m = INF;
		REP(i, 0, N) {
			m = min(m, A[i][c]);
		}
		REP(i, 0, m) {
			cout << (char)('a' + c);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def max_sum_seq(lis):
    m = 0
    lis = compress(lis)
    l = len(lis)

    max_val = lis[0]
    for i in xrange(0, l):
        for j in xrange(i, l):
            if j == i:
                tmp_val = lis[j]
            else:
                tmp_val = tmp_val + lis[j]
            max_val = max(max_val, tmp_val)
    return max_val

def compress(tmp_lst):
    lim = len(tmp_lst)
    lst = []
    index = 0
    while index < lim:
        tmp = tmp_lst[index]
        index += 1
        while tmp > 0 and index < lim and tmp * tmp_lst[index] > 0:
            tmp += tmp_lst[index]
            index += 1
        lst.append(tmp)
    return lst


while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    lis = []
    for i in range(n):
        lis.append(int(sys.stdin.readline()))
    print max_sum_seq(lis)

Measured memory_bytes: 4452
#import cython

n = int(input())
h = list(map(int, input().split())) + [0]

ans,cnt = 0, sum(h)
while cnt > 0:
    l, r = -1, n
    for num, i in enumerate(h):
        if (l == -1) and (i > 0):
            l = num
        if (l > -1) and (i == 0):
            r = num
            ans += 1
            cnt -= r - l
            for i in range(l, r):
                h[i] -= 1
            break
print(ans)


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

int main(){
	int N;
	cin >> N;
	vector<string> W(N);
	for(auto &i:W)cin >> i;
	
	for(int i=0;i<N-1;i++){
		if(W[i][W[i].size()-1]!=W[i+1][0]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	sort(W.begin(),W.end());
	for(int i=0;i<N-1;i++){
		if(W[i]==W[i+1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

ll N;
using pint = pair<ll, ll>;
vector<pint> mem;
vector<ll> A;

int main() {
  cin >>N;
  mem.resize(N);
  A.resize(N - 1);
  for (int i = 0; i < N - 1; i++) cin >> A[i];
  for (int i = 0; i < N; i++) mem[i].first = i + 1;
  for (int i = 0; i<N-1; i++){
    mem[A[i] - 1].second++;
  }
  for (int i = 0; i < N; i++) cout << mem[i].second << endl;
  return 0;
}

Measured memory_bytes: 12788
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define BLOCK 750
#define mxn 5000001
using namespace std;
struct query{
	int l;
	int r;
	int i;
};
query Q[mxn];
int ar[mxn] , ans[mxn];
int fre[mxn];
int cnt = 0;
bool comp(query a , query b)
{
	if(a.l / BLOCK != b.l/BLOCK)
	return a.l/BLOCK < b.l/BLOCK;
 
	return a.r < b.r;
}
 
void add(int pos)
{
	fre[ar[pos]]++;
	if(fre[ar[pos]] == 1)
	cnt++;
}
 
void remove(int pos)
{
	fre[ar[pos]]--;
	if(fre[ar[pos]] == 0)
	cnt--;
}
 
int main()
{
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
 
 
 
	int n , q; 
	cin>>n >> q;
	for(int i=0;i<n;i++)
	cin>>ar[i];
 
	
	for(int i=0;i<q;i++){
		cin>>Q[i].l>>Q[i].r;
		Q[i].i = i , Q[i].l-- , Q[i].r--;
	}
 
	sort(Q , Q+q , comp);
 
	int ML = 0 , MR = -1;
	for(int i=0;i<q;i++)
	{
		int L = Q[i].l;
		int R = Q[i].r;
 
		while(ML > L)
		ML-- , add(ML);
 
		while(MR < R)
		MR++ , add(MR);
 
		while(ML < L)
		remove(ML) , ML++;
 
		while(MR > R)
		remove(MR) , MR--;
 
		ans[Q[i].i] = cnt;
	}
 
	for(int i=0;i<q;i++)
	cout<<ans[i]<<'\n';
}


Measured memory_bytes: 15492
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
pair<int,int> s[200050];
int main(){
	int n; scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&s[i].first,&s[i].second);
	sort(s+1,s+n+1); long long mx=-1e18,ans=0;
	for(int i=1;i<=n;++i){
		mx=max(mx,0ll-s[i].first-s[i].second);
		ans=max(ans,mx+s[i].first+s[i].second);
	} mx=-1e18;
	for(int i=1;i<=n;++i){
		mx=max(mx,0ll-s[i].first+s[i].second);
		ans=max(ans,mx+s[i].first-s[i].second);
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 5240
// DPL_5_J Count number of ways to put n indistinguishable
// balls into k indistinguishable bins

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  // Approach: number of ways to partition n into k parts
  // = number of ways to partition n, with largest partition having
  // size at most k
  // => Dynamic programming
  vector<vector<int>> C(n + 1, vector<int>(k + 1));
  for (int i = 0; i <= k; ++i)
    C[0][i] = 1; // can partition 0 items exactly one way
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      C[i][j] = C[i][j - 1];
      if (j <= i) {
        C[i][j] += C[i - j][j];
        C[i][j] %= 1000000007;
      }
    }
  }
  cout << C[n][k] << endl;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n;
      cin >> n;
      int a, b, c, d;
      a = n / 1000;
      b = n / 100 - a * 10;
      d = n % 10;
      c = (n % 100 - d) / 10;
      if((a == b && c == b) || (b == c && c == d)) {
        cout << "Yes" << endl;
      }else {
        cout << "No" << endl;
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s, t; cin >> s >> t;
	
	cout << t << s << endl;
	return 0;
}


Measured memory_bytes: 764
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define MOD 1000000007
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rll() {
	long long n;
	scanf("%lld", &n);
	return n;
}

uint64_t buf[80];
void shift_or(int n) {
	int big = n >> 6;
	int small = n & 63;
	if (small) {
		int ismall = 64 - small;
		for (int i = 78 - big; i >= 0; i--) {
			uint64_t cur = buf[i];
			buf[i + big] |= cur << small;
			buf[i + big + 1] |= cur >> ismall;
		}
	} else {
		for (int i = 78 - big; i >= 0; i--)
			buf[i + big] |= buf[i];
	}
}

int main() {
	int n = ri(), k = ri();
	int a[n];
	for (int i = 0; i < n; i++) a[i] = ri();
	
	buf[0] = 1;
	for (int i = n - 1; i >= n / 2; i--) shift_or(a[i]);
	std::set<int> all;
	for (int i = 0; i < k; i++) if (buf[i >> 6] >> (i & 63) & 1) all.insert(i);
	int cnt = 0;
	uint64_t bak[80] = { 0 };
	bak[0] = 1;
	for (int i = 0; i < n; i++) {
		if (i) {
			memcpy(buf, bak, sizeof(buf));
			shift_or(a[i - 1]);
			memcpy(bak, buf, sizeof(buf));
		}
		memcpy(buf, bak, sizeof(buf));
		int min = std::max(0, k - a[i]);
		int max = k;
		if (i >= n / 2) {
			for (int j = i + 1; j < n; j++) shift_or(a[j]);
			for (int j = min; j < max; j++) if (buf[j >> 6] >> (j & 63) & 1) {
				cnt++;
				break;
			}
		} else {
			for (int j = i + 1; j < n / 2; j++) shift_or(a[j]);
			for (int j = 0; j < k; j++) {
				if (buf[j >> 6] >> (j & 63) & 1) {
					auto itr = all.lower_bound(min - j);
					if (itr != all.end() && *itr < max - j) {
						cnt++;
						break;
					}
				}
			}
		}
	}
	std::cout << n - cnt << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <set>

int testcase_ends() {
  char buf[80];
  scanf("%s", buf);
  std::string s = buf;
  std::set<std::string> t;
  for (size_t i = 1; i < s.length(); ++i) {
    std::string s0(s.begin(), s.begin()+i);
    std::string s1(s.begin()+i, s.end());

    std::string r0(s0.rbegin(), s0.rend());
    std::string r1(s1.rbegin(), s1.rend());

    t.insert(s0+s1);
    t.insert(s0+r1);
    t.insert(r0+s1);
    t.insert(r0+r1);
    t.insert(s1+s0);
    t.insert(r1+s0);
    t.insert(s1+r0);
    t.insert(r1+r0);
  }

  printf("%zu\n", t.size());
  return 0;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    testcase_ends();
}



Measured memory_bytes: 2952
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

//using edge = struct{ll from, to;};

int main(){
    ll R, G, B, N; cin >> R >> G >> B >> N;
    ll rc = N / R;
    ll gc = N / G;
    ll ans = 0;
    REP(i, rc+1) REP(j, gc+1){
        ll rem = N - i*R - j*G;
        if(rem < 0 || rem % B != 0) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(x);
    if(x < 1200){
        COUT("ABC");
    }else{
        COUT("ARC");
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int nums = int.Parse(Console.ReadLine());
            List<int> dsf = new List<int>();
    for(int i = 0;i < nums; i++)
            {
                dsf.Add(int.Parse(Console.ReadLine()));
            }
            int max = 0;
        for(int i = 0;i < nums; i++)
            {
                max = (max > dsf[i]) ? max : dsf[i];
            }
            int re = 0;
            bool fl = true;
        foreach(int i in dsf)
            {
                if(i != max || !fl)
                {
                    re += i;
                }
                else
                {
                    re += i / 2;
                    fl = false;
                }
            }
            Console.WriteLine(re);

        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,X,answer = 0;
    cin >> A >> B >> C >> X;
    for(int a = 0; a < A+1; a++){
        for(int b =0; b < B+1; b++){
            for(int c = 0; c < C+1; c++){
                if(500*a+100*b+50*c == X)
                ++answer;
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        string s,t,u;
        cin>>s>>t;
        int a,b;
        cin>>a>>b;
        cin>>u;
        if(u==s)
        cout<<(a-1)<<" "<<b;
        else if(u==t)
        cout<<a<<" "<<b-1;
        // your code goes here
	return 0;
}


Measured memory_bytes: 3540
#include<stdio.h>
int main(){
int m[11],i,j,work;
for(i=0;i<10;i++){
 scanf("%d",&m[i]);
}
for(i=0;i<10;i++){
 for(j=0;j<10;j++){
  if(m[i]>m[j]){
   work=m[i]; m[i]=m[j]; m[j]=work;
   }
  }
 }
for(i=0;i<3;i++){
 printf("%d\n",m[i]);
}
return 0; }

Measured memory_bytes: 2692
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    string s;cin>>s;
    vector<bool> app(26,false);

    for(int i=0;i<s.size();i++){
        app[s[i]-'a']=true;
    }

    for(int i=0;i<26;i++)if(!app[i]){
        cout<<(char)('a'+i)<<endl;
        return 0;
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
a_ = list(map(int, input().split( )))

a = [a_[i]-i-1 for i in range(n)]
a.sort()
##b~a[i]で(n-i)-i減る中央値でよい
##偶奇等適当
b1 = a[n//2-1]
b2 = a[n//2]
ans_1 = [abs(a[i]-b1) for i in range(n)]
ans_2 = [abs(a[i]-b2) for i in range(n)]

ans1 = sum(ans_1)
ans2 = sum(ans_2)
print(min(ans1,ans2))

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

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

    int n = s.length() - 1;

    long long int ans = 0;
    for(int bit=0; bit<(1<<n); bit++){
        long long int count = 0;// result of each pattern

        for(int i=0; i<n+1; i++){
            count += s[i] - '0';

            if(bit & (1<<(n-1-i)) || i == n){
                ans += count;
                count = 0;
            }
            else count *= 10;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	string res="";
	res.pb(s[0]);
	for(ll i=0;i<n;i++){
		if(res.back()!=s[i]){
			res.pb(s[i]);
		}
	}
	cout<<res.size();

}

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

const int N = 4005, M = 1e9+7;
int C[N][N];

int dp[N][N];
int st[N][N], en[N][N];

void pre() {
    for (int i=0; i<N; i++) C[i][0] = C[0][i] = 1;
    for (int i=1; i<N; i++)
        for (int j=1; j<N; j++)
            C[i][j] = (C[i-1][j] + C[i][j-1])%M;
}

int main() {
    pre();
    long long ans = 0;

    int n;
    cin>>n;

    for (int i=1; i<=n; i++) {
        int x, y;
        cin>>x>>y;
        ans = (ans  + M - C[x+x][y+y])%M;

        st[N/2-x][N/2-y] ++;
        en[N/2+x][N/2+y] ++;
    }

    for (int i=1; i<N; i++) {
        for (int j=1; j<N; j++) {
            dp[i][j] = (0LL + dp[i][j-1] + dp[i-1][j] + st[i][j])%M;
            ans = (ans + 1LL * en[i][j] * dp[i][j])%M;
        }
    }

    ans = (ans%M+M)%M;
    if (ans%2)  ans +=M;
    cout<<ans/2<<endl;
}






Measured memory_bytes: 175544
#include<iostream>
using namespace std;
int main(){
	int n,h,w;
	cin >> n >> h >> w;
	int ans=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin >> a >> b;
		if(a>=h && b>=w) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
  cin>>d[i];
  }
   sort(d.begin(),d.end());
  if(d[n/2]-d[n/2-1]>0)cout<<d[n/2]-d[n/2-1]<<endl;
  else cout<<"0"<<endl;
  return 0;
}

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

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

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() {
    int n;
    cin >> n;
    ++n;
    vector<ll> a(n), b(n, 0);
    for (ll& i : a) cin >> i;
    if (n == 1) return cout << (a[0] == 1 ? "1" : "-1"), 0;
    // if (a[0] != 0) return cout << -1, 0;
    b[n - 1] = a[n - 1];
    for (int i = n - 2; i >= 0; --i) b[i] = b[i + 1] + a[i];
    ++a[0];
    vector<ll> dpm(n, 0);
    ll m = 1;
    for (int i = 0; i < n; ++i) {
        // if (0 <= i && i + 1 < n) assert(b[i] - a[i] == b[i + 1]);
        m      = min(m * 2ll, b[i]) - (i?a[i]:b[0]<=1?0:a[i]);
        dpm[i] = m;
        if (m < 0) return cout << "-1\n", 0;
    }
    ll res = 0;
    for (int i = 0; i < n; ++i) res += dpm[i] + a[i];
    cout << res - 1ll << endl;
    return 0;
}

Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const long double PI = acos(-1);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c
#define i4(a, b, c, d) cin>>a>>b>>c>>d
#define fi first
#define se second

ll power(ll a, ll b, ll z = MOD)
{
	ll res = 1;
	a = (a%z);
	while(b)
	{
		if(b&1)
			res = (res*a)%z;
		a = (a*a)%z;
		b = b>>1;
	}
	return res;
}

ll inverse(ll a, ll z = MOD)
{
	return power(a, z-2, z);
}

ll extend(ll a, ll b, ll &x, ll &y)
{
	if(b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll g = extend(b, a%b, x1, y1);
	x = y1;
	y = x1- (a/b)*y1;
	return g;
}

ll mat_power(ll a, ll b, ll c, ll d, ll n, ll z = MOD)
{
	ll a0 = 1, b0 = 0, c0 = 0, d0 = 1;
	while(n)
	{
		if(n&1)
		{
			ll a1 = a0, b1 = b0, c1 = c0, d1 = d0;
			a0 = (a1*a + b1*c)%z;
			b0 = (a1*b + b1*d)%z;
			c0 = (c1*a + d1*c)%z;
			d0 = (c1*b + d1*d)%z;
		}
		ll a1 = a, b1 = b, c1 = c, d1 = d;
		a = (a1*a1 + b1*c1)%z;
		b = (a1*b1 + b1*d1)%z;
		c = (c1*a1 + d1*c1)%z;
		d = (c1*b1 + d1*d1)%z;
		n = n>>1;
	}
	return c0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	i1(x);
	if((x&1) == 0)
		o1(-1);
	else
	{
		if((x%7) == 0)
			x = x/7;
		if((x%3) == 0)
			x = x*9;
		if(x == 1)
		{
			o1(1);
			return 0;
		}
		ll val = 1;
		for(int i=1;i<=x;i++)
		{
			val = (val*10)%x;
			if(val == 1)
			{
				o1(i);
				return 0;
			}
		}
		o1(-1);
	}
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 505 ;
using namespace std ;
int n, m, a[N][N], b[N][N] ; char A[N][N] ;
char o(int x) { return x ? '#' : '.'; }
int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) scanf("%s", A[i] + 1) ;
	rep(i, 1, n) rep(j, 1, m) a[i][j] = b[i][j] = 0 ;
	rep(i, 1, n) rep(j, 1, m) {
		if (j == 1 || ((i & 1) && j < m) || A[i][j] == '#') a[i][j] = 1 ;
		if (j == m || (!(i & 1) && j > 1) || A[i][j] == '#') b[i][j] = 1 ;
	}
	rep(i, 1, n) { rep(j, 1, m) printf("%c", o(a[i][j])) ; printf("\n"); }
	puts(""); rep(i, 1, n) { rep(j, 1, m) printf("%c", o(b[i][j])) ; printf("\n"); }
	return 0 ; 
}

Measured memory_bytes: 2944
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int l,r,mi=2019;
    cin>>l>>r;
    if (r-l>=2019)
        cout<<"0";
    else
    {
        for (int i=l; i<r; i++)
        {
            for(int j=l+1; j<=r; j++)
            {
                if (((i%2019)*(j%2019))%2019<mi)
                    mi=((i%2019)*(j%2019))%2019;
            }
        }
    cout<<mi;
    }
    return 0;
}


Measured memory_bytes: 256
from functools import reduce

N = int(input())
S = input()

MOD = 998244353


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(
                pow(self.x, other.x, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    def __radd__(self, other):
        return ModInt(other + self.x)

    def __rsub__(self, other):
        return ModInt(other - self.x)

    def __rmul__(self, other):
        return ModInt(other * self.x)

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))


# 先頭のボールから順に、割り当て可能な人のうち最もボールを持っている人に割り当てることを繰り返す
def f(s, res, z, r, g, b, rg, gb, br):
    return (
        (
            (res * gb, z, r, g, b, rg, gb - 1, br) if gb else
            (res * g, z, r, g - 1, b, rg + 1, gb, br) if g else
            (res * b, z, r, g, b - 1, rg, gb, br + 1) if b else
            (res * z, z - 1, r + 1, g, b, rg, gb, br)
        ) if s == 'R' else
        (
            (res * br, z, r, g, b, rg, gb, br - 1) if br else
            (res * r, z, r - 1, g, b, rg + 1, gb, br) if r else
            (res * b, z, r, g, b - 1, rg, gb + 1, br) if b else
            (res * z, z - 1, r, g + 1, b, rg, gb, br)
        ) if s == 'G' else
        (
            (res * rg, z, r, g, b, rg - 1, gb, br) if rg else
            (res * r, z, r - 1, g, b, rg, gb, br + 1) if r else
            (res * g, z, r, g - 1, b, rg, gb + 1, br) if g else
            (res * z, z - 1, r, g, b + 1, rg, gb, br)
        )
    )


ans, *_ = reduce(
    lambda acc, s: f(s, *acc),
    S,
    (ModInt(1), N, 0, 0, 0, 0, 0, 0)
)

print(ans)


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

// https://atcoder.jp/contests/abc127/tasks/abc127_b

vector<int> solver(int scale,int minus,int milenium){
    vector<int> result(11,0);
    result.at(0) = milenium;
    for(int j=1;j<=10;j++){
        result.at(j) = (result.at(j-1))*scale-minus;
    }
    return result;
}

int main(void){
    int r,D,x2000;
    vector<int> answer(11,0);
    cin >> r >> D >> x2000;
    answer = solver(r,D,x2000);
    for(int j=1;j<=10;j++){
        cout << answer.at(j) << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]
F=[1]
for i in range(8):
  F.append(F[-1]*(i+1))

a=1
b=1
def num(A,x):
  for i in range(len(A)):
    if A[i]==x:
      return i
N=[int(i) for i in range(1,n+1)]
M=[int(i) for i in range(1,n+1)]
for i in range(n):
  a+=num(N,P[i])*F[n-i-1]
  b+=num(M,Q[i])*F[n-i-1]
  N.remove(P[i])
  M.remove(Q[i])
print(abs(a-b))




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

int main(){

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

    long long int n, w;
    cin >> n >> w;

    vector<pair<long long int, long long int>> weights;

    long long int x, y;
    for(long long int i=1; i<=n; i++){
        cin >> x >> y;
        weights.push_back({x,y});
    }

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

    long long int dp[n+1][w+1];
    for(long long int i=0; i<n; i++) dp[i][0]=0;
    for(long long int j=1; j<=w; j++){
        if(weights[0].first<=j) dp[0][j]=weights[0].second;
        else dp[0][j]=0;
    }
    
    for(long long int i=1; i<n; i++){
        for(long long int capacity=1; capacity<=w; capacity++){
            if(capacity<weights[i].first) dp[i][capacity] = dp[i-1][capacity];
            else{
                dp[i][capacity] = max((weights[i].second + dp[i-1][capacity-weights[i].first]), dp[i-1][capacity]);
            }
        }
    }

    // for(int i=0; i<=n; i++){
    //     for(int j=0; j<=w; j++) cout<<dp[i][j]<<' ';    
    //     cout<<'\n';
    // }

    cout<<dp[n-1][w]<<'\n';

    return 0;
}


Measured memory_bytes: 81736
#include<bits/stdc++.h>
using namespace std;
int main(){
  map < char , int > count;
  string str;
  while(cin>>str){

	for(int i=0; i<(int)str.size(); i++){
	  if(isupper(str[i])){
	    str[i]=tolower(str[i]);
	  }
	}

	for(int i=0; i<(int)str.size();i++){
	  count[str[i]]++;
	}
  }

  for(char ch='a'; ch<='z'; ch++){
	cout<<ch << " : " <<count[ch]<<endl;
  }
  return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);

  vector<int> A(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A.at(i));
    A.at(i)--;
  }

  vector<int> B(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &B.at(i));
  }

  vector<int> C(N - 1, 0);
  for (int i = 0; i < N - 1; i++) {
    scanf("%d", &C.at(i));
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += B.at(A.at(i));
    if (i > 0 && A.at(i) == A.at(i - 1) + 1) {
      ans += C.at(A.at(i - 1));
    }
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=300002;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,a,b,c,d;
      cin>>n>>a>>b>>c>>d;
      a--; b--; c--; d--;
      string s;
      cin>>s;
      for(int i=a;i<=c;i++)
      {
            if(s[i]=='#')
            {
                  if(i!=0)
                  {
                        if(s[i-1]=='#')
                        {
                              cout<<"No\n";
                              return 0;
                        }
                  }
            }
      }
      for(int i=b;i<=d;i++)
      {
            if(s[i]=='#')
            {
                  if(i!=0)
                  {
                        if(s[i-1]=='#')
                        {
                              cout<<"No\n";
                              return 0;
                        }
                  }
            }
      }
      if(d<=c){
      for(int i=b;i<=d;i++)
      {
            if(s[i]=='.')
            {
                  if(i!=0)
                  {
                        if(s[i-1]=='.')
                        {
                              if(i+1<n)
                              {
                                    if(s[i+1]=='.')
                                    {
                                          cout<<"Yes\n";
                                          return 0;
                                    }
                              }
                        }
                  }
            }
      }
      }
      else{
            cout<<"Yes\n";
            return 0;
      }
      cout<<"No\n";
}     


Measured memory_bytes: 592
//23:46
#include <stdio.h>
#include <ctype.h>

char board[52][52];
int W,H;
char S[51];

char dx[] = {0,0,1,1,1,-1,-1,-1};
char dy[] = {-1,1,0,-1,1,0,-1,1};
int main(){
	scanf("%d %d",&H,&W);
	for(int y = 0; y <= H+1 ; y++){board[0][y]=board[W+1][y]='*';}
	for(int x = 0; x <= W+1 ; x++){board[x][0]=board[x][H+1]='*';}
	for(int y = 1; y <= H; y++){ 
		scanf("%s",S);
		for(int x = 1; x <= W; x++){
			board[x][y] = S[x-1];
		}
	}	
	for(int y = 1; y <= H; y++){
		for(int x = 1; x <= W; x++){
			if(board[x][y] == '.'){
				int cnt = 0;
				for(int d = 0; d < 8; d++){
					if(board[x+dx[d]][y+dy[d]]=='#')cnt++;
				}
				board[x][y] = cnt+'0';
			}
		}
	}
	for(int y = 1; y <= H; y++){ 
		for(int x = 1; x <= W; x++){
			printf("%c",board[x][y]);
		}puts("");
	}	
}


Measured memory_bytes: 128
#include<stdio.h>
#define N 100
#define M 2000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int total,A[N][N];
int min();
int main(){
  int i,j;
  scanf("%d",&total);
  for(i=0;i<total;++i){
    for(j=0;j<total;++j){
      scanf("%d",&A[i][j]);
    }
  }
  min();
  return 0;
}
int min(){
  int a=0;
  int k[N],pi[N],color[N];
  int i,saisyo,sum=0;
  for(i=0;i<total;++i){
    k[i]=M;pi[i]=-1;color[i]=WHITE;
  }
  k[a]=0;
  while(1){
    saisyo=M;
    a=-1;
    for(i=0;i<total;++i){
      if(color[i]!=BLACK&&saisyo>k[i]){
        saisyo=k[i];
        a=i;
      }
    }
    if(saisyo==M){
      break;
    }
    color[a]=BLACK;
    for(i=0;i<total;++i){
      if(A[i][a]!=-1){
        if(color[i]!=BLACK&&A[i][a]<k[i]){
          if(k[i]>A[a][i]){
            k[i]=A[a][i];
            pi[i]=a;
            color[i]=GRAY;
          }
        }
      }
    }
  }
  for(i=0;i<total;++i){
    if(pi[i]!=-1){
      sum+=A[i][pi[i]];
    }
  }
  printf("%d\n",sum);
}



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

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

    vector<int64_t> l(n + 1);

    l.at(0) = 2;
    l.at(1) = 1;

    if (n > 1)
    {
        for (int i = 2; i <= n; i++)
        {
            l.at(i) = l.at(i - 1) + l.at(i - 2);
        }
    }

    cout << l.at(n) << endl;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <list>

int main()
{
  std::list<int> l;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    if ((i & 1) == 0) l.emplace_back(a);
    else l.emplace_front(a);
  }
  if ((n & 1) == 0)
  {
    for (auto a : l)
    {
      printf("%d\n", a);
    }
  }
  else
  {
    for (auto it = l.rbegin(); it != l.rend(); ++it)
    {
      printf("%d\n", *it);
    }
  }
  return 0;
}

Measured memory_bytes: 8448
#include <stdio.h>

int main()
{
	int X, Y;
	scanf("%d %d", &X, &Y);
	if (Y >= X * 2 && Y <= X * 4 && Y % 2 == 0) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

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

struct Process{
	string name;
	long t;
};

int main(){
	queue<Process> qu;
	long n, q;
	cin >> n >> q;
	for (long i = 0; i < n; i++){
		string name;
		long t;
		cin >> name >> t;
		Process p;
		p.name = name;
		p.t = t;
		qu.push(p);
	}
	long cl = 0;
	while (qu.empty() == 0){
		Process p;
		p = qu.front();
		if (p.t > q){
			cl += q;
			p.t -= q;
			qu.pop();
			qu.push(p);
		}
		else {
			cl += p.t;
			qu.pop();
			cout << p.name << " " << cl << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define ll long long int
#define int long long
int n,x,y,k=0;
int a[MAXN];
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>x>>y;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(x-j)+1+abs(y-i)))]++;
        }
    }

    for(int i=1;i<n;i++){
        cout<<a[i]/2<<"\n";
    }
    return 0;

}

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

vector<int> G[1111];
int N,M;
int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int c,d;
    cin >> c >> d;
    if( c < d ) G[c].push_back(d);
  }
  int res = 0;
  for(int i=1;i<=N+1;i++){
    int rmax = i;
    if( G[i].empty() ){
      res ++; continue;
    }

    for(int j=0;j<(int)G[i].size();j++) rmax = max( rmax, G[i][j] );
    
    for(int j=i+1;j<rmax;j++){
      for(int k=0;k<(int)G[j].size();k++)
	rmax = max( rmax, G[j][k] );      
    }

    res += (rmax - i)*3;
    i = rmax-1;

  }
  cout << res << endl;
}

Measured memory_bytes: 1248
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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, 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 llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if (a < c && c < b || a > c && c > b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}





}



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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x;
    cin >> x;
    cout << (int)pow(x, 3) << endl;    
    return 0;
}



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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<int> vec;

  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }

    int least = 1001;
    int most = 0;
    int sum = 0;

    rep(i, n)
    {
      int x;
      cin >> x;
      least = min(least, x);
      most = max(most, x);
      sum += x;
    }

    int ave = (sum - least - most) / (n - 2);
    vec.push_back(ave);
  }

  for (auto &&i : vec)
  {
    printf("%d\n", i);
  }
}



Measured memory_bytes: 3088