akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  if (n < 1200) cout << "ABC" << endl;
  else if (n < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int n,m,x,y;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		a[x]++;
		a[y]++;
	}
	for(int i=0;i<100005;i++)
	  if(a[i]%2==1){
	  	cout<<"NO"<<endl;
	  	return 0;
	  }
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int s;
char c;
int main()
{
	for(;;)
	{
		for(int i=0;;i++)
		{
			scanf("%c",&c);
			if(i==0&&c=='0')return 0;
			else if(c=='\n')break;
			s+=atoi(&c);
		}
		cout<<s<<endl;
		s=0;
	}
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

int main() {
  using namespace std;
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, l;
  cin >> n >> l;
  vector<pair<int, int>> icicles(n);
  for (int i = 0; i < n; i++) {
    icicles[i].second = i + 1;
    cin >> icicles[i].first;
  }
  vector<long long> time(n + 2);
  sort(rbegin(icicles), rend(icicles));
  for (auto&& ic : icicles) {
    int len, idx;
    tie(len, idx) = ic;
    time[idx] += l - len;
    time[idx - 1] = max<long long>(time[idx], time[idx - 1]);
    time[idx + 1] = max<long long>(time[idx], time[idx + 1]);
  }
  cout << *max_element(std::begin(time) + 1, std::end(time) - 1) << endl;
}

Measured memory_bytes: 4316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int[][] c = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c[i][j] = scan.nextInt();
            }
        }
        int[] A = new int[10];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int x = scan.nextInt();
                if (x == -1) {
                    continue;
                }
                A[x] += 1;
            }
        }
        int[][] d = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                d[i][j] = c[i][j];
            }
        }
        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    d[i][j] = Math.min(d[i][j], d[i][k]+d[k][j]);
                }
            }
        }
        long answer = 0;
        for (int i = 0; i < 10; i++) {
            answer += (long) d[i][1] * A[i];
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 42872
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        int n = stdIn.nextInt();

        if(n%10 == 7 || (n%100)/10 == 7 || n/100 == 7){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35788
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int P = io.nextInt();
		long ans = 0;
		int zero = 0;
		int one = 0;
		for(int i=0;i<N;i++){
			if(io.nextInt()%2==0) zero ++;
			else one ++;
		}
		if(one==0){
			System.out.println((1L<<zero)*((P==0)?1:0));
		}else{
			System.out.println((1L<<zero)*(1L<<(one-1)));
		}
	}

	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 20688
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
const ll INF = (1ll << 60);

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(101010, INF));
    dp[0][0] = 0;
    rep(i, n)
    {
        dp[i + 1] = dp[i];
        rep(j, 101010)
        {

            if (j - v[i] < 0)
            {
                continue;
            }
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        }
    }
    int ans = 0;
    rep(i, 101010)
    {
        if (dp[n][i] <= m)
        {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81024
///                ..:: In The Name Of God ::..
#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define error(x) cerr << #x << " = " << (x) << endl;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n,h,w;
    int ans = 0;
    cin >> n >> h >> w;
    for(int i=0;i<n;i++){
	int a,b;
	cin >> a >> b;
	ans += min(a/h,b/w);
    }
    cout << ans << endl;    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>

bool check(std::vector<std::pair<int, int> > x){
	int y = 0, low;
	for(std::pair<int, int> p : x){
		low = y + p.first;
		if(low < 0){
			return false;
		}
		y += p.second;
	}
	return true;
}

int main(){
	int n;
	int total = 0;
	std::cin >> n;
	std::vector<std::pair<int, int> > left, right;
	//<lowest, y>
	//lowest = 最も低くなる位置
	//y = 最終的な位置

	for(int i=0; i<n; i++){
		std::string s;
		std::cin >> s;
		int y = 0, lowest = 0;
		for(char j : s){
			if(j == '('){
				y++;
			}else{
				y--;
			}
			lowest = std::min(y, lowest);
		}

		if(y > 0){
			left.emplace_back(lowest, y);
		}else{
			right.emplace_back(lowest - y, -y);
		}
		total += y;
	}

	//lowestが大きいものを優先する
	sort(left.rbegin(), left.rend());
	sort(right.rbegin(), right.rend());
	if(check(left) && check(right) && total == 0){
		std::cout << "Yes" << std::endl;
	}else{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 18920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

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

int n;
int arr[200005];

bool can(int i){
	int best=1000000;
	bool val;
	
	rep(x,2,2*n){
		int temp=min(abs(x-1-n),abs(x-n));
		
		if (arr[x-1]<=i && arr[x]<=i){
			if (temp<best){
				best=temp;
				val=true;
			}
		}
		else if(arr[x-1]>i && arr[x]>i){
			if (temp<best){
				best=temp;
				val=false;
			}
		}
	}
	
	if (best!=1000000) return val;
	else return (arr[n]<=i)!=(n%2==0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	rep(x,1,2*n) cin>>arr[x];
	
	//rep(x,1,2*n) cout<<x<<" "<<can(x)<<endl;
	//return 0;
	
	int lo=1,hi=2*n,mi;
	
	while (hi-lo>1){
		mi=hi+lo>>1;
		
		if (can(mi)) hi=mi;
		else lo=mi;
	}
	
	cout<<hi<<endl;
}


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

using namespace std;

int main(void)
{
	int n;
	vector <int> v;
	int res=0;
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

	for(int i=0;i<n;i++)
	{
		int t;
		cin >> t;
		v.push_back(t);
	}

	for(int i=0;i<n;i++)
	{
		int t = v[i];
		while(1)
		{
			if(t%2!=0)
			{
				break;
			}
			t/=2;
			res++;
		}
	}

	cout << res << '\n';

	return 0;

}

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

int main() {
  int n; 
  cin >> n;
  
  bool judge = false;
  vector<char>s(n);
  for(int i=0; i<n; i++){
    cin >> s[i];
   if(s[i]=='Y') judge = true; 
  }
  
  if(judge==true) cout << "Four" << endl;
  else cout << "Three" << endl;
  
  
  
  
}



Measured memory_bytes: 256
n,m = map(int,input().split())
li = []
cnt = 0
for i in range(m):
    a,b = map(int,input().split())
    li.append((a,b))
li = sorted(li,key = lambda x:x[1])
prev = -1
for x in li:
    if(prev > x[0]):
        continue
    else:
        cnt += 1
    prev = x[1]
print(cnt)

Measured memory_bytes: 18972
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  cin>>S;
  if(S=="zyxwvutsrqponmlkjihgfedcba"){
    puts("-1");
    return 0;
  }
  if(S.size()!=26){
    cout<<S;
    vector<bool> A(26,true);
    for(char c:S)A[c-'a']=false;
    for(int i=0;i<26;i++)
      if(A[i]){
        cout<<(char)(i+'a')<<endl;
        return 0;
      }
  }
  int i=24;
  for(;i>=0;i--)
    if(S[i+1]>S[i])break;
  vector<bool> A(26,true);
  for(int j=0;j<i;j++){
    cout<<S[j];
    A[S[j]-'a']=false;
  }
  for(char c=S[i]+1;c<='z';c++){
    if(A[c-'a']){
      cout<<c<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void fc(vector<vector<bool>> &dpx, vector<int> &vx){
  dpx.at(0).at(0) = true;
  rep(i, vx.size()){
    rep(j, dpx.at(i).size()){
      if(dpx.at(i).at(j) == true){
        if(j + vx.at(i) <= 8000) dpx.at(i+1).at(j+vx.at(i)) = true;
        if(0 <= j - vx.at(i)) dpx.at(i+1).at(j-vx.at(i)) = true;
      }
    }
  }
}

int main(){
  string s;
  cin >> s;
  int x, y;
  cin >> x >> y;
  vector<int> vx, vy;
  bool f = false, mode = false;
  int co = 0;
  rep(i, s.size()){
    if(s.at(i) == 'T'){
      f = true;
      if(co != 0){
        if(mode == false) vx.push_back(co);
        else vy.push_back(co);
      }
      mode ^= 1;
      co = 0;
    }else{
      if(f == false){
        x--;
      }else{
        co++;
      }
    }
  }
  if(co != 0){
    if(mode == false) vx.push_back(co);
    else vy.push_back(co);
  }
  x = abs(x); y = abs(y);
  if(x > 8000){
    cout << "No" << endl;
    return 0;
  }
  vector<vector<bool>> dpx(vx.size()+1, vector<bool>(8001, false)), dpy(vy.size()+1, vector<bool>(8001, false));
  fc(dpx, vx); fc(dpy, vy);
  if(dpx.back().at(x) == true && dpy.back().at(y) == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 7756
/*  d  */
#include <bits/stdc++.h>
#define N 200005

using namespace std;

int n;
int a[N], c[N];

inline int read() {
	int x = 0; bool neg = false; char ch = getchar();
	while(!isdigit(ch)) (ch == '-') && (neg = true), ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return neg ? -x : x;
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)
		a[i] = read(), ++c[a[i]];
	long long ans = 0;
	for(int i = 1; i <= n; ++i)
		ans += (c[i] - 1LL) * c[i] / 2;
	for(int i = 1; i <= n; ++i) {
		long long res = ans - c[a[i]] + 1;
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 3712
function main(input) {
    const lines = input.split('\n');

const line0 = lines[0].split('');
const line1 = lines[1].split('');

console.log(line0.reduce((a,c,i)=>{
    if(line0[i] === line1[i]){
        return a + 1
    }
    return a
},0))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

	int n = S.size();
	int num[3] = {0};
	for( int i = 0; i < n; i++ ) {
		if( S[i] == 'a' ) num[0]++;
		else if( S[i] == 'b' ) num[1]++;
		else num[2]++;
	}
	sort( num, num + 3 );
	string ans = "YES";
	if( num[2] - num[1] > 1 || num[1] - num[0] > 1 || num[2] - num[0] > 1 ) ans = "NO";

	cout << ans << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000

int partition(int A[], int p, int r){
  int x = A[r];
  int i = p-1;
  for(int j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      int tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  int tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}

int main(){
  int A[MAX];
  int n, i, q;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  q = partition(A, 0, n-1);

  for(i = 0; i < n; i++){
    if(i >= 1) printf(" ");
    if(i == q) printf("[");
    printf("%d", A[i]);
    if(i == q) printf("]");
  }
  printf("\n");

  return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int a[100010];
vi g[100010];

int dfs(int v) 
{
	int d = g[v].size();

	vi vec;

	for (int x : g[v]) {
		vec.pb(dfs(x));
	}

	sort(ALL(vec));
	int res = d;

	int lb = d-1, ub = N;

	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		bool f = 1;
		multiset<int> st;
		for (int x : vec) {
			st.insert(x);
		}

		rep(i, d) {
			auto it = st.upper_bound(mid - i - 1);
			if (it == st.begin()) {
				f = 0;
				break;
			}
			--it;
			st.erase(it++);
		}
		if (f) ub = mid;
		else lb = mid;
	}
	return ub;
}

int main() {
	cin >> N;
	for (int i = 1; i < N; ++i) {
		cin >> a[i];
		--a[i];
		g[a[i]].pb(i);
	}

	cout << dfs(0) << endl;
	return 0;
}

Measured memory_bytes: 23296
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto T = readln.chomp.split(" ")[1].to!long;
    auto ts = readln.chomp.split(" ").map!(to!int);

    long sum;
    int last = 0;
    foreach (t; ts[1..$]) {
        if (t - last < T)
            sum += (t - last);
        else
            sum += T;
        last = t;
    }

    writeln(sum + T);
}

Measured memory_bytes: 8920
A, B, C, X = map(int, [input() for i in range(4)])

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                count += 1

print(count)

Measured memory_bytes: 3060
N,*A=map(int,open(0).read().split())

colors = [0 for i in range(8)]
tyty = 0

for a in A:
  c = a//400
  if c>=8:
    tyty+=1
  else:
    colors[c]+=1

cNum = 8-colors.count(0)
    
minC = max(cNum,1)
maxC = cNum+tyty

print(minC,maxC)

Measured memory_bytes: 9128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt()-1;
        int B = sc.nextInt()-1;
        int C = sc.nextInt()-1;
        int D = sc.nextInt()-1;
        String S = sc.next();
        if (C < D) {
            int obs = 0;
            for (int i = B; i <= D; i++) {
                if (S.charAt(i) == '#') {
                    obs++;
                } else {
                    obs = 0;
                }
                if (obs == 2) {
                    System.out.println("No");
                    return;
                }
            }
            obs = 0;
            for (int i = A; i <= C; i++) {
                if (S.charAt(i) == '#') {
                    obs++;
                } else {
                    obs = 0;
                }
                if (obs == 2) {
                    System.out.println("No");
                    return;
                }
            }
        } else {
            int obs = 0;
            int safe = 0;
            boolean safety = false;
            for (int i = B; i <= D; i++) {
                if (S.charAt(i) == '#') {
                    obs++;
                    safe = 0;
                } else {
                    safe++;
                    obs = 0;
                }
                if (safe == 3) {
                    safety = true;
                }
                if (obs == 2) {
                    System.out.println("No");
                    return;
                }
            }
            if (S.charAt(B+1) == '.' && S.charAt(B-1) == '.') {
                safety = true;
            } else if (S.charAt(D-1) == '.' && S.charAt(D+1) == '.') {
                safety = true;
            }
            if (!safety) {
                System.out.println("No");
                return;
            }
            obs = 0;
            for (int i = A; i <= C; i++) {
                if (S.charAt(i) == '#') {
                    obs++;
                } else {
                    obs = 0;
                }
                if (obs == 2) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }    
}


Measured memory_bytes: 41676
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 2e5+5, OO = 0x3f3f3f3f;
//int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Directio
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class AAtCoDeerAtCoDeerAndPaintCans {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a, b, c; in >> a >> b >> c;
        set<int> v;
        v.insert(a);
        v.insert(b);
        v.insert(c);
        out << v.size() << el;
	}
};


int main() {
	AAtCoDeerAtCoDeerAndPaintCans solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
r=lambda:map(int,input().split())
import sys
a,b=r()
s=input()
if s[a]!='-':
  print("No")
  sys.exit(0)

d='0123456789'
for i in range(len(s)):
  if i==a: continue
  if s[i] not in d:
    print("No")
    sys.exit(0)
    
print("Yes")
    

Measured memory_bytes: 3060
from collections import deque

N = int(input())
S = [input() for _ in range(N)]

E = [[] for _ in range(N)]
for i, s in enumerate(S):
    for j in range(N):
        if s[j] == "1":
            E[i].append(j)
            E[j].append(i)

def solve(a):
    rank = [-1] * N
    rank[a] = 0

    Q = deque([a])
    while Q:
        v = Q.popleft()
        r = rank[v]
        for u in E[v]:

            if rank[u] == -1:
                rank[u] = r + 1
                Q.append(u)

            elif rank[u] == r:
                return -2

    return max(rank)


print(max(solve(i) for i in range(N)) + 1)

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i,n){
    ll ai;
    cin >> ai;
    if(ai==ans+1) ans++;
  }
  if(ans==0) ans = -1;
  else ans = n-ans;
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>a;
    vector<int>b;
    vector<int>c;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        a.push_back(t);
    }
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        b.push_back(t);
    }
    for(int i=0;i<n-1;i++){
        int t;
        cin>>t;
        c.push_back(t);
    }
    int ans=0;
    int lst=-1;
    for(int i=0;i<n;i++){
        int ind=a[i]-1;
        ans+=b[ind];
        if(ind-1==lst&&ind!=0)
            ans+=c[ind-1];
        lst=ind;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
   int n,k;
   cin >> n >> k;
   vector<vector<int>> ds(n);
	rep(i,n){
		int t,d;
		cin >> t >> d;
		--t;
		ds[t].push_back(d);
	}
	vector<int> y1,y0;
	rep(i,n){
		if (ds[i].size() == 0) continue;
		sort(ds[i].begin(), ds[i].end());
		y1.push_back(ds[i].back());
		ds[i].pop_back();
		y0.insert(y0.end(),ds[i].begin(),ds[i].end());
	}
	sort(y1.rbegin(),y1.rend());
	sort(y0.rbegin(),y0.rend());
	int Y = max(1, k - int(y0.size()));
	ll ans = 0;
	ll X = 0;
	rep(i,Y)X+=y1[i];
	rep(i,k-Y)X+=y0[i];
	ans = max(ans,X+(ll)Y*Y);
	while(1){
		++Y;
		if(Y>k || Y > y1.size())break;
		X = 0;
		rep(i,Y)X+=y1[i];
		rep(i,k-Y)X+=y0[i];
		ans = max(ans,X+(ll)Y*Y);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  int a,b,k;cin>>a>>b>>k;
  repd(i,a,b+1){
    if((i-a)<k||(b-i)<k){
      cout << i << endl;
    }
  }
}


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int h, w;

char g[505][505];
int c[505][505];
int ex, ey;

int fl(int l, int r, int b, int t) {
    int lgx = max(l, ex-r);
    int rgx = min(w-r, l+ex+1);
    int lgy = max(b, ey-t);
    int rgy = min(h-t, b+ey+1);

    if (lgx <= rgx && lgy <= rgy && lgx <= l+ex && l+ex < rgx) {
        lgx = l+ex;
        rgx = lgx+1;
        return c[rgy][rgx] - c[rgy][lgx] - c[lgy][rgx] + c[lgy][lgx];
    } else {
        return 0;
    }
}
int fr(int l, int r, int b, int t) {
    int lgx = max(l, ex-r);
    int rgx = min(w-r, l+ex+1);
    int lgy = max(b, ey-t);
    int rgy = min(h-t, b+ey+1);

    if (lgx <= rgx && lgy <= rgy && lgx <= ex-r && ex-r < rgx) {
        lgx = ex-r;
        rgx = lgx+1;
        return c[rgy][rgx] - c[rgy][lgx] - c[lgy][rgx] + c[lgy][lgx];
    } else {
        return 0;
    }
}
int fb(int l, int r, int b, int t) {
    int lgx = max(l, ex-r);
    int rgx = min(w-r, l+ex+1);
    int lgy = max(b, ey-t);
    int rgy = min(h-t, b+ey+1);

    if (lgx <= rgx && lgy <= rgy && lgy <= b+ey && b+ey < rgy) {
        lgy = b+ey;
        rgy = lgy+1;
        return c[rgy][rgx] - c[rgy][lgx] - c[lgy][rgx] + c[lgy][lgx];
    } else {
        return 0;
    }
}
int ft(int l, int r, int b, int t) {
    int lgx = max(l, ex-r);
    int rgx = min(w-r, l+ex+1);
    int lgy = max(b, ey-t);
    int rgy = min(h-t, b+ey+1);

    if (lgx <= rgx && lgy <= rgy && lgy <= ey-t && ey-t < rgy) {
        lgy = ey-t;
        rgy = lgy+1;
        return c[rgy][rgx] - c[rgy][lgx] - c[lgy][rgx] + c[lgy][lgx];
    } else {
        return 0;
    }
}
int dp[102*101/2][102*101/2];

int ind[101][101];

int &dpc(int l, int r, int b, int t) {
    return dp[ind[l][r]][ind[b][t]];
}

int main() {
    scanf("%d %d", &h, &w);
    FO(y,0,h) scanf(" %s", g[y]);
    FO(y,0,h) FO(x,0,w) {
        c[y+1][x+1] = g[y][x] == 'o' ? 1 : 0;
        c[y+1][x+1] += c[y][x+1] + c[y+1][x] - c[y][x];
        if (g[y][x] == 'E') {
            ex = x;
            ey = y;
        }
    }

    int cind = 0;
    FO(i,0,101) FO(j,0,101) if (i+j <= 100) {
        ind[i][j] = cind++;
    }

    int ans = 0;
    FO(l,0,w+1) FO(r,0,w+1-l) {
        FO(b,0,h+1) FO(t,0,h+1-b) {
            int &res = dpc(l,r,b,t);
            res = 0;
            if (l) res = max(res, dpc(l-1,r,b,t) + fl(l,r,b,t));
            //printf("dp[%d][%d][%d][%d]=%d\n", l, r, b, t, res);
            if (r) res = max(res, dpc(l,r-1,b,t) + fr(l,r,b,t));
            //printf("dp[%d][%d][%d][%d]=%d\n", l, r, b, t, res);
            if (b) res = max(res, dpc(l,r,b-1,t) + fb(l,r,b,t));
            //printf("dp[%d][%d][%d][%d]=%d\n", l, r, b, t, res);
            if (t) res = max(res, dpc(l,r,b,t-1) + ft(l,r,b,t));
            //printf("dp[%d][%d][%d][%d]=%d\n", l, r, b, t, res);

            ans = max(ans, res);
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 104192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N;

    scanf("%d", &N);

    while (N > 0)
    {
        if (N % 10 == 7)
        {
            printf("Yes");
            return 0;
        }
        N /= 10;
    }
    printf("No");
}



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

using namespace std;

int main(){
    string s;
    cin>>s;
    vector<int> hoge(2);
    for(auto a:s){
        hoge.at(a-'0')++;
    }
    
    cout<<s.size() - abs(hoge.at(0)-hoge.at(1))<<endl;
    
    return 0;
}

Measured memory_bytes: 512
import sys

n, m = map(int, sys.stdin.readline().split())
g = [[int(x) for x in sys.stdin.readline().split()[1:]] for _ in range(n)]

def main():
    res = set(range(1, m+1))
    for a in g:
        res &= set(a)
    
    return len(res)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LONG_LONG_MAX;
const int MAX_P = 55555+1;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    
    int N,T;
    cin >> N >> T;
    vint A(N);
    repeat(i, N){
        cin >> A[i];
    }
    vint minA(A),profit(N,0);
    int maxprofit=0;
    int cnt=1;
    repeat(i, N-1){
        minA[i+1] = min(minA[i],A[i+1]);
        profit[i+1] = A[i+1] - minA[i+1];
        if(maxprofit<profit[i+1]){
            maxprofit = profit[i+1];
            cnt=1;
        }else if(maxprofit == profit[i+1]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 1408
from collections import deque
def main():
    n, d, a = map(int, input().split())
    m = [list(map(int, input().split())) for _ in range(n)]
    m.sort()
    r = 1
    d *= 2
    q=deque([])
    for i in range(n):
        while r < n and m[i][0] + d >= m[r][0]:
            r += 1
        m[i].append(r)
        m[i][1] = (m[i][1] + a - 1) // a
    res = 0
    tdamage = 0
    for i in range(n):
        while q and q[0][0] <= i:
            minus = q.popleft()
            tdamage -= minus[1]
        m[i][1] -= tdamage
        if m[i][1] > 0:
            res += m[i][1]
            tdamage += m[i][1]
            q.append([m[i][2],m[i][1]])
    print(res)
main()

Measured memory_bytes: 87384
//by tzupengwang™
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n ;
ll x ;
ll a[ 2005 ] ;

void init() {
  scanf( "%d%lld" , &n , &x ) ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    scanf( "%lld" , &a[ i ] ) ;
  }
}

ll mn[ 2005 ][ 2005 ] ;

void process() {
  ll ans = 0 ;
  for ( int i = 1 ; i <= n ; i ++ ) {
    mn[ 0 ][ i ] = a[ i ] ;
    ans += a[ i ] ;
  }
  for ( int i = 1 ; i <= n ; i ++ ) {
    for ( int j = 1 ; j <= n ; j ++ ) {
      int nid = j + n - i ;
      while ( nid > n ) nid -= n ;
      mn[ i ][ j ] = min( mn[ i - 1 ][ j ] , a[ nid ] ) ;
    }
    ll tans = (ll)i * x ;
    for ( int j = 1 ; j <= n ; j ++ )
      tans += mn[ i ][ j ] ;
    ans = min( ans , tans ) ;
  }
  printf( "%lld\n" , ans ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123;
int n, a[N], b[N], p[N], f[N];

void upd(int x, int y) {
	for (; x <= 2 * n; x |= (x + 1))
		f[x] += y;
}

int getsum(int x) {
	int res = 0;
	for (; x >= 0; x = (x & (x + 1)) - 1)
		res += f[x];
	return res;
}

ll get(int x) {
	for (int i = 1; i <= n; i++) {
		if (a[i] <= x) b[i] = 1;
		else b[i] = -1;
	}
	upd(n, 1);
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		p[i] = p[i - 1] + b[i];
		res += getsum(p[i] + n - 1);
		upd(p[i] + n, 1);
	}
	upd(n, -1);
	for (int i = 1; i <= n; i++)
		upd(p[i] + n, -1);
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int l = 0, r = 1e9 + 123;
	ll k = (ll)n * (n + 1) / 2;
	while (l < r - 1) {
		int mid = l + r >> 1;
		if (get(mid) >= k / 2 + 1)
			r = mid;
		else
			l = mid;
	}
	cout << r;
}


Measured memory_bytes: 5616
#include <iostream>

using namespace std;


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

   long i;
   long result;

   result = 0;
   for (i=1;i<=N;i++) {
     if ((i % 3)  && (i%5))
     {
        result += i;
      //  cerr << i << " ";
      }
   }

   cout << result << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    LL n;
    cin >> n;
    VLL b(n);
    REP(i,0,n-1) cin >> b[i];
    int ans = b[0] + b[n-2];
    REP(i,0,n-2) ans += min(b[i],b[i+1]);
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#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 VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll sets = n / (a + b), res = sets * a, pos = (a + b) * sets;
    if (pos + a >= n) res += n - pos;
    else res += a;

    cout << res << endl;
    return 0;
}

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

vector<int> v[100000];
bool used[100000];
int endpoint = 0;
int maxx = 0;

int dfs(int cur) {
    used[cur] = true;
    if (v[cur].size() == 1) endpoint++;
    vector<int> w = {0, 0};
    for (int i = 0; i < v[cur].size(); i++) {
        if (!used[v[cur][i]]) {
            int to = v[cur][i];
            w.push_back(dfs(to));
        }
    }
    sort(w.rbegin(), w.rend());
    maxx = max(maxx, (v[cur].size() == 2) + w[0] + w[1]);
    return (v[cur].size() == 2) + w[0];
}

int main() {
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    memset(used, 0, sizeof(used));
    dfs(0);
    cout << maxx + endpoint << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
constexpr int MOD = 1000000007;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

const int MAX = 2000000; // 問題によって変更する(パスカルの三角形の段数、nCkのnの最大)
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll comb(ll n, ll k) {
  ll ret = 1;
  for (int i = 0; i < k; i++) {
    ret *= (n - i);
    ret %= MOD;
    ret *= inv[i + 1];
    ret %= MOD;
  }

  return ret % MOD;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  ll total = modpow(2, n, MOD);
  total--;

  COMinit();
  ll ans = total + MOD - comb(n, a);
  ans %= MOD;
  ans = ans + MOD - comb(n, b);

  cout << ans % MOD << ln;

  return 0;
}

Measured memory_bytes: 47104
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

map<int, int> mp;

int pos;
int now;
bool flag;

void add(int a) {
  //debug(a); debugln(pos);
  if (a > pos) {
    pos = a;
  } else {
    if (a < pos) {
      auto it = mp.begin();
      while (it != mp.end()) {
        if (it->first < -a) {
          mp.erase(it++);
        } else {
          break;
        }
      }
    }

    pos = a;
    mp[-a]++;
    while (mp[-a] >= now) {
      if (a > 1) {
        mp.erase(-a);
        a--;
        mp[-a]++;
      } else {
        flag = false;
        return;
      }
    }
    if (mp[-a] == 0) {
      mp.erase(-a);
    }
  }
}

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

  int N; cin >> N;
  vector<int> A(N);
  now = 0;
  flag = true;
  rep(i, N) {
    cin >> A.at(i);
    if (flag && A.at(i) > now) {
      now = A.at(i);    
    } else {
      flag = false;
    }
  }

  if (flag) {
    cout << 1 << endl;
    return 0;
  }

  int sup = N;
  int min = 1;
  while (min < sup-1) {
    now = (sup+min)/2;
    mp.clear();
    pos = 0;
    flag = true;
    rep(i, N) {
      int a = A.at(i);
      add(a);
      if (!flag) break;
    }
    if (!flag) {
      debug(now);debugln("failed");
      min = now;
    } else {
      debug(now);debugln("succeeded");
      sup = now;
    }
  }  
  cout << sup << endl;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;

    if ((int)c >=97 && (int) c <= 122)

    if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' )

    cout << "vowel";

    else
        cout << "consonant";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    ll n,w,u,v;
    cin>>n>>w;
    ll dp[n+1][w+1];
    for(ll i=0;i<=n;i++)
        dp[i][0] = 0;
    for(ll i=0;i<=w;i++)
        dp[0][i] = 0;
    
    for(ll i=1;i<=n;i++){
        cin>>u>>v;
        for(ll j=1;j<=w;j++){
            if(u>j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], v + dp[i-1][j-u]);
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}

Measured memory_bytes: 79232
N = int(input())
n= str(N)
cnt = 0
c=[[0]*10 for _ in range(10)]
for i in range(1,N+1):
  i = str(i)
  a = int(i[0])
  b = int(i[-1])
  c[a][b]+=1
ans = 0
for i in range(1,10):
  for j in range(1,10):
    ans +=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
# 整数の入力
N = int(input())
ans = 0

def dfs(num, use7, use5, use3):
    if num > N:
        return 0
    else:
        ret = 0
        if use7 == True and use5 == True and use3 == True:
            ret += 1
            #print(num)

        ret += dfs(num*10+7, True, use5, use3)
        ret += dfs(num*10+5, use7, True, use3)
        ret += dfs(num*10+3, use7, use5, True)

    return ret



print(dfs(0, False, False, False))


Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll m=1e9+7;

int main(){
    int n,a,c[100010]={0}; 
    ll d[100010];
    d[0]=1;
    for(int i=0;i<100002;i++) d[i+1]=d[i]*2%m;
    cin>>n;
    int f=(n%2?0:1);
    for(int i=0;i<n;i++){ 
        cin>>a; 
        c[a]++;
    }
    int k; 
    for(k=f;k<n;k+=2){ 
        if(!k){ if(!c[k]) break;} 
        else {if(c[k]!=2) break; }
    }
    if(k!=n+1) { cout<<0<<endl; return 0;}
    cout<<d[n/2]<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
 
int main()
{
  int d, n;
  cin >> d >> n;
  int k = 1;
  for(int i = 0; i < d; i++){
    k *= 100;
  }
  if(n != 100){
    cout << n * k << endl;
  }
  else{
    cout << 101 * k << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
   char s[2000005];
   scanf("%s",s+1);
   int l=strlen(s+1);
   int n=l;
   for(int i=1;i<l;i++)
   {
       if(s[i]!=s[i+1])
       {
           n=min(n,max(i,l-i));
       }
   }
   cout<<n<<endl;
    return 0;
}


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

int main() {
  float T, A, h, tmp;
  int N, city;
  cin >> N >> T >> A;
  
  float t = 1e9;
  for(int i=1; i<=N; i++) {
    cin >> h;
    tmp = abs(A-(T-h*0.006));
    if(t>tmp) {
      t = tmp;
      city = i;
    }
  }
  
  cout << city << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        string[] a = Console.ReadLine().Split();
        int[] b = new int[a.Length];
        for(int i = 0; i < a.Length; i++)
        {
            b[i] = int.Parse(a[i]);
        }
        Array.Sort(b);
        Array.Reverse(b);
        for(int i = 0; i < a.Length-1; i++)
        {
            Console.Write(b[i]+" ");
        } 
        Console.WriteLine(b[a.Length-1]);
    }
}

Measured memory_bytes: 9120
#include <stdio.h>

long a[200200];
int 
main(){
	long N;
		
	scanf("%ld",&N);
	long int i,j;
	long int tmp;
	
	for(i=0;i<N;i++){
		scanf("%ld",&a[i]);
	}
	tmp=1;
	for(i=0;i<N;i++){
		
		if(tmp == a[i]){			
			tmp++;
		}
	}

	if(tmp==1)printf("-1\n");
	else{
		printf("%ld\n",N-(tmp-1));
		
	}

 return 0;
}

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

using namespace std;

#define ll long long

#define DEBUG (1)


int main()
{
  ll X = 0;

  cin >> X;

  for(ll i = -1000; i <= 1000; i++){
    for(ll j = -1000; j <= 1000; j++){
      ll tmp = (ll)(pow(i,5)-pow(j,5));
      if(tmp == X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }

}


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

int bubbleSort(int A[], int N) {
  int sw = 0;
  bool flag = 1;
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = N - 1; j >= 1; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for (int i=0; i<N; i++) cin>>A[i];

  sw = bubbleSort(A, N);

  for (int i=0; i<N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}



Measured memory_bytes: 3116