akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first #define se second
using namespace std; typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18, mod = 7 + 1e9;

int n, a[MAXN], d[MAXN], f[MAXN], l[MAXN], r[MAXN], top = 0;

void update(int i, int val){
    for (; i <= n; i += i & -i) f[i] = max (f[i], val);
}

int get(int l, int r){
    int res = 0;
    while (r >= l){
        if (r - (r & -r) >= l){
            res = max (res, f[r]);
            r -= r & -r;
        }
        else {
            res = max (res, a[r]);
            r--;
        }
    }
    return res;
}

int bs1(int hi, int i){
    int lo = 1, val = a[i], pre = hi;
    while (lo < hi){
        int mid = (lo + hi) / 2;
        if (get(mid, pre - 1) < a[i]) hi = mid;
        else lo = mid + 1;
    }
    return hi;
}

int bs2(int lo, int i){
    int hi = n, pre = lo;
    while (lo < hi){
        int mid = (lo + hi + 1) / 2;
        if (get(pre + 1, mid) < a[i]) lo = mid;
        else hi = mid - 1;
    }
    return lo;
}

int main(){
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin),freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++) update(i, a[i]);

    int top = 0;
    for (int i = 1; i <= n; i++){
        while (top > 0 && a[d[top]] <= a[i]) top--;
        l[i] = d[top] + 1;
        d[++top] = i;
    }

    top = 0, d[top] = n + 1;
    for (int i = n; i >= 1; i--){
        while (top > 0 && a[d[top]] <= a[i]) top--;
        r[i] = d[top] - 1;
        d[++top] = i;
    }

    long long ans = 0;

   // cerr << get(1, 2);

    for (int i = 1; i <= n; i++){
        int pos1 = l[i] - 1, pos2 = r[i] + 1;
        int pos3 = bs1(pos1, i), pos4 = bs2(pos2, i);

    //    cerr << i << ' ' << l[i] << ' ' << r[i] << ' ' << pos3 << ' ' << pos4 << '\n';

        int num = 0;

        if (pos3 > 0 && pos3 < l[i]) ans += 1ll * a[i] * (l[i] - pos3) * (r[i] - i + 1);

        if (pos4 <= n && pos4 > r[i]) ans += 1ll * a[i] * (pos4 - r[i]) * (i - l[i] + 1);

        if (pos3 > 0 && pos3 < l[i]) num += (l[i] - pos3) * (r[i] - i + 1);

        if (pos4 <= n && pos4 > r[i]) num += (pos4 - l[i]) * (i - r[i] + 1);

   //     ans += 1ll * a[i] * ((l[i] - pos3) * (r[i] - i + 1) + (pos4 - l[i]) * (i - l[i] + 1));
   //     cout << a[i] << ' ' << num << '\n';
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 5468
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
	
	int a = 0;
	int tas = 0;;
	int q;
	int i;
	int z;
	int j = 0;
	int b = 0;
	
	String Bun = scan.nextLine();
	String Miz = scan.nextLine();
	
	Bun = Bun + Bun;
	
	char[] bun = Bun.toCharArray();
	char[] miz = Miz.toCharArray();
		
	for(q=0; q<miz.length; q++){
	}
		
	for(z=0; z<bun.length; z++){
	}
		
	int x = z - q;
	
	for(i=0; i<x; i++){
		if(bun[i]==miz[j]){
			for(j=0; j<=q; j++){
				if(bun[i+j]!=miz[j])	{
					tas = 0;
					j = 0;
					break;				}
				tas++;	
				if(tas==q){
				a = 1;
				b = 1;
				break;     }}
		}
		if(b==1){
			break;}
	}
		if(a==1){	
			System.out.println("Yes");}
		else{
			System.out.println("No");}
	}
}


Measured memory_bytes: 26280
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) A>B? A:B;
#define MIN(A,B) A<B? A:B;
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",1110-n);
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    int n, ans;
    cin>>n;
    if(n%2==0){
        cout << n << endl;
    } else {
        cout << n*2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define llint long long
#define mod 1000000007
#define inf (llint)1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
llint dp[55][55][2505];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	if(m % 2){
		cout << 0 << endl;
		return 0;
	}
	m /= 2;
	
	for(int i = 1; i <= n+1; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= m; k++){
				dp[i][j][k] = 0;
			}
		}
	}
	dp[1][0][0] = 1;
	
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= m; k++){
				if(j > 0 && k+j-1 <= m) (dp[i+1][j-1][k+j-1] += dp[i][j][k] * j%mod*j % mod) %= mod;
				if(k+j <= m && i > 1 && i < n && j > 0) (dp[i+1][j][k+j] += dp[i][j][k] * j % mod * 2 % mod) %= mod;
				if(j < n && k+j+1 <= m) (dp[i+1][j+1][k+j+1] += dp[i][j][k]) %= mod;
				if(k+j <= m) (dp[i+1][j][k+j] += dp[i][j][k]) %= mod;
			}
		}
	}
	
	/*for(int i = 1; i <= n+1; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= m; k++){
				cout << dp[i][j][k] << " ";
			}cout << endl;
		}
		cout << endl;
	}*/
	
	cout << dp[n+1][0][m] % mod << endl;
	
	return 0;
}

Measured memory_bytes: 56192
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  long long k;
  cin >> k;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int crr = s[i] - '0';
    if (crr == 1) {
      cnt++;
      if (cnt == k) {
        cout << 1 << '\n';
        return 0;
      }
    } else {
      cout << crr << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
inline void Fail(){
	printf("0");
	exit(0);
}

const int maxn=100005;
int n,m,cnt[2];
bool ok=true;
vector<int>edge[maxn];
int vis[maxn];

void dfs(int x,int col){
	if(vis[x]!=-1){
		if(vis[x]!=col)ok=false;
		return;
	}
	vis[x]=col;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		dfs(y,col^1);
	}
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	memset(vis,-1,sizeof(vis));
	dfs(1,1);
	if(ok){
		REP(i,n)cnt[vis[i]]++;
		printf("%lld",1LL*cnt[0]*cnt[1]-m);
	}
	else{
		printf("%lld",1LL*n*(n-1)/2LL-m);
	}
	return 0;
}

Measured memory_bytes: 6912
#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>;

template <class _T> inline bool chmax (_T& a,_T b){if(a<b){a=b;return true;}return false;}
template <class _T> inline bool chmin (_T& a,_T b){if(a>b){a=b;return true;}return false;}
const int inf = 2147483647;
const long long INF = 1LL << 60;
const int MAX_N = 11000;
const int MAX_W = 10100;
ll mod = 1000000007;
ll MOD = 998244353;

int main(void){
    ll n;cin >> n;
    ll x,m;cin >> x >> m;
    vector<ll> v;
    ll sum = 0;
    vector<bool> table(m+1,false);

    for(int i=0;i<n;i++){
        
        if(x==0){ 
            cout << sum << endl;
            return 0;
        }
        if(table[x]){
            ll pos,tmp_sum=0;
            for(int j=0;j<v.size();j++){
                if(v[j]==x){
                    pos = j;
                    break;
                } 
                tmp_sum += v[j];
            }
            sum = (sum-tmp_sum)*((n-pos)/(v.size()-pos));
            sum += tmp_sum;
            for(ll j=0;j<(n-pos)%(v.size()-pos);j++){
                sum += v[pos+j];
            }
            break;
        }
        sum += x;
        v.push_back(x);
        table[x] = true;
        x = x*x;
        x %= m;
    }
      cout << sum << endl;
    return 0;
}

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

typedef long long ll;

const int SIZ = 1<<18;
int n;
int p[200010];

struct SEG{
	int s[2*SIZ];
	int t[2*SIZ];
	void init(){
		for(int i = 0 ; i < n ; i ++){
			s[i+SIZ-1] = p[i];
			t[i+SIZ-1] = p[i];
		}
		for(int i = n ; i < SIZ ; i ++){
			s[i+SIZ-1] = n;
			t[i+SIZ-1] = -1;
		}
		for(int i = SIZ-2 ; i >= 0 ; i --){
			s[i] = min(s[2*i+1],s[2*i+2]);
			t[i] = max(t[2*i+1],t[2*i+2]);
		}
	}
	pair<int,int> query(int a,int b,int k,int l,int r){
		if(b <= l || r <= a){
			return pair<int,int>(n,-1);
		}
		if(a <= l && r <= b){
			return pair<int,int>(s[k],t[k]);
		}
		pair<int,int> chl = query(a,b,2*k+1,l,(l+r)/2);
		pair<int,int> chr = query(a,b,2*k+2,(l+r)/2,r);
		pair<int,int> ret;
		ret.first = min( chl.first , chr.first );
		ret.second = max( chl.second , chr.second );
		return ret;
	}
}seg;

int main(){
	int k;
	scanf("%d%d",&n,&k);
	for(int i = 0 ; i < n ; i ++){
		scanf("%d",&p[i]);
	}
	seg.init();
	
	static int a[200010];
	for(int i = 0 ; i+1 < n ; i ++){
		if(p[i] < p[i+1])a[i] = 1;
		else a[i] = 0;
	}
	/*for(int i = 0 ; i < n ; i ++){
		cout << a[i] << " " ;
	}
	cout << endl;*/
	for(int i = 0 ; i+1 < n ; i ++){
		a[i+1] += a[i];
	}
	/*for(int i = 0 ; i < n ; i ++){
		cout << a[i] << " " ;
	}
	cout << endl;*/
	
	int ret = n-k+1;
	int cnt = 0;
	for(int i = 0 ; i+k < n ; i ++){
		pair<int,int> pp = seg.query(i,i+k+1,0,0,SIZ);
		if(p[i] == pp.first && p[i+k] == pp.second)ret --;
		else if((i==0 && a[k-2] == k-1) || (i>0 && a[i+k-2]-a[i-1] == k-1)){
			//cout << i << endl;
			cnt ++;
		}
	}
	//cout << ret << " " << cnt << endl;
	if(a[n-2]-a[n-k-1] == k-1)cnt ++;
	//cout << ret << " " << cnt << endl;
	if(cnt > 1)ret -= cnt-1;
	cout << ret << endl;
}

Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int n = S.length();
		StringBuilder st = new StringBuilder("x");
		for (int x = 1; x < n; x++) {
			st.append("x");
		}
		System.out.println(st);
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100010;
int n,a[3][maxn];
long long f[3][maxn];
int main()
{
	scanf("%d",&n);
	for(int t=0;t<=2;t++)
	{
		for(int i=1;i<=n;i++)
			scanf("%d",&a[t][i]);
		sort(a[t]+1,a[t]+n+1);
	}
	for(int i=1;i<=n;i++)
		f[0][i]=i;
	for(int t=1;t<=2;t++)
		for(int i=1;i<=n;i++)
			f[t][i]=f[t][i-1]+f[t-1][lower_bound(a[t-1]+1,a[t-1]+n+1,a[t][i])-a[t-1]-1];
	printf("%lld",f[2][n]);			
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<list>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

ll rep(int n) {
	ll a = 1;
	for (int i = 1; i <= n; i++) {
		a = a * i % MOD;
	}
	return a;
}


int main() {
	int n, m;
	cin >> n >> m;
	if (abs(n - m) >= 2) { //|n-m|>1は並べられない
		cout << 0 << endl;
		return 0;
	}

	int a = 1, b = 1;
	a = rep(n);
	b = rep(m);

	ll ans = 0;
	if (abs(n - m) == 1) { //(n+1=m)or(n=m+1)
		ans = (a*(b % MOD)) % MOD;
	}
	else { //(n=m)
		ans = (a * (b * 2 % MOD)) % MOD;
	}

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

Measured memory_bytes: 256
#include <iostream>
int main() {
    int a, b;
    std::cin >> a >> b;
    if (a > b) {
        std::cout << "a > b" << std::endl;
    } else if (a < b) {
        std::cout << "a < b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }
}



Measured memory_bytes: 3104
#include<iostream>
#include<math.h>
#include<string>

using namespace std;

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

  cin >> s;

  for(int i=0; i<s.length(); i++){
    if(s[i] == '0' || s[i] == '1'){
      ans.push_back(s[i]);
    }
    else if(s[i] == 'B' && ans.length()>0){
      ans.pop_back();
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
from collections import deque
def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def bfs():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue

        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            bfscount.append(count)

    return max(bfscount)

q = deque()
h,w=map(int,input().split())
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))
ans=[]
bfscount=[]
for i in range(h):
    for j in range(w):
        if c[i][j]==".":
            q.append([i,j,0])
            ans.append(bfs())
            finished = set()
            bfscount=[]
print(max(ans))


Measured memory_bytes: 50524
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;


int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += --a[i];
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){

  string S;
  cin>>S;
  string check;
  int num=0;
  int A=0;
  int B=0;
  int ans=0;
  for(int i=0;i<=(int)(S.length()-3);i++){
  
    check=S.substr(i,3);
    //cout<<check<<" ";
    num=stoi(check);
    //cout<<num<<endl;
    A=num-753;
    if(A<0)A*=-1;
    B=ans-753;
    if(B<0)B*=-1;
    if(A<B)ans=num;
  }
  int trueans=ans-753;
  if(trueans<0)trueans*=-1;
  cout<<trueans;
  return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

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(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    set<pair<int,int>> ans;
    rep(i,N){
        for(int j = i+1; j < N; j++){
            ans.insert({i+1,j+1});
        }
    }
    for(int i = 1; i <= N/2; i++){
        if(N % 2 == 0) ans.erase({i, N-i+1});
        else ans.erase({i,N-i});
    }
    cout << ans.size() << endl;
    vector<pair<int,int>> v(ans.begin(), ans.end());
    for(auto e: ans){
        cout << e.first << ' ' << e.second << endl;
    }
}

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

int main(void)
{
	int n, W, MIN = 100001, sum = 0, p = 0, pp, cost = 0, k = 0, min = 100001;
	cin >> n;
	vector<int> box, list;
	vector<bool> mark;
	for (int i = 0; i < n; i++) {
		cin >> W;
		box.push_back(W);
		list.push_back(W);
		mark.push_back(false);
		if (W < MIN)
			MIN = W;
	}
	sort(list.begin(), list.end());
	while (p < n) {
		if (mark[p] == false) {
			sum = 0;
			k = 0;
			min = 100001;
			pp = p;
			while (mark[pp] == false) {
				mark[pp] = true;
				sum += box[pp];
				k++;
				if (box[pp] < min)
					min = box[pp];
				pp = find(list.begin(), list.end(), box[pp]) - list.begin();
			}
			if (sum + (k - 2) * min > sum + min + (k + 1) * MIN)
				cost += sum + min + (k + 1) * MIN;
			else
				cost += sum + (k - 2) * min;
			p++;
		}
		else
			p++;
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if(a == 1)ans+=300000;
  else if(a == 2)ans+=200000;
  else if(a == 3)ans+=100000;
  if(b == 1)ans+=300000;
  else if(b == 2)ans+=200000;
  else if(b == 3)ans+=100000;
  if(a == 1 && b == 1)ans+=400000;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
s = input()
y = int(s[:4])
m = int(s[5:7])
d = int(s[8:10])

if (y<2019) | ((y==2019)&(m<4)) | ((y==2019)&(m==4)&(d<=30)):
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()      scanf("")
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,n);
  int a[112345]={};
  int i;
  rep(i,n)
    cin>>a[i];
  int bf=0;
  int sum=0;
  rep(i,n)
    {
      if(a[i]==i+1)
	if(bf==1)
	  bf=0;
	else
	  {
	    bf=1;
	    sum++;
	  }
      else
	bf=0;
    }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int h,w;
	cin >> h >> w;

	int a[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> a[i][j];
		}
	}

	vector<P> ans[h*w];
	P left;
	bool ki=false;
	int num=0;
	int hnum=0;
	int s=0;
	for(int i=0;i<h;i++){
		int j,end,d;
		if(i%2 == 0){
			d=1;
			j=0;
			end=w-1;
		}else{
			d=-1;
			j=w-1;
			end=0;
		}
		for(;j*d<=end;j+=d){
			if(ki){
				ans[hnum].push_back(P(i,j));
				if(a[i][j]%2 == 1) {
					num++;
					s+=ans[hnum].size()-1;
					hnum++;
					ki=false;
				}
			}else if(a[i][j]%2 == 1){
				num++;
				ans[hnum].push_back(P(i,j));
				ki=true;
			}
		}
	}
	cout << s << "\n";

	for(int i=0;i<hnum;i++){
		for(int j=0;j<ans[i].size()-1;j++){
			cout << ans[i][j].first+1 << " " << ans[i][j].second+1 << " " << ans[i][j+1].first+1 << " " << ans[i][j+1].second+1 << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 12800
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var T = input[0].split(" ")[1]-0;
  var ans = "TLE";
  for(var i=1;i<=N;i++){
    var c = input[i].split(" ")[0]-0;
    var t = input[i].split(" ")[1]-0;
    if(T>=t){
      if(ans=="TLE") ans = c;
      else ans = Math.min(ans,c);
    }
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int len = 1;
    int n; cin >> n;
    int res = 0;
    int next = 10;
    for (int i = 1; i <= n; i++) {
        if (i == next) {
            len++;
            next *= 10;
        }
        if (len & 1) {
            res++;
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>

#include<math.h>

#include<stdio.h>

#include<string.h>

#include<vector>

#include<algorithm>



typedef long long ll;

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

#define rep1(i, n) for(int i=1; i < (int)(n); i++)

#define all(x) (x).begin(),(x).end()

#define fill(x,y) memset(x,y,sizeof(x))

#define debug1(i) cout << i << '\n'

#define debug2(i,j) cout << i << j << '\n'

#define MAX 1<<20



using namespace std;


long long N, M, L;
long long p[MAX], q[MAX];
double d, e, f, g, h;
vector<long long > vec1, vec2;

int main() {

	cin >> N >> M >> L;

	cout << min(M/N, L);
}

Measured memory_bytes: 764
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pc putchar
#define RG register
#define gc getchar
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');
	if(x>=10)write(x/10);
	putchar(x%10+'0');
}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define y1 ________y1
#define int ll
#define N 1000005
#define M 4000005
struct Edge{
	int to,nxt,cap;
	Edge(){}
	Edge(int to,int nxt,int cap):to(to),nxt(nxt),cap(cap){};
}edge[M*2];
int first[N],cur[N],nume;
void Addedge(int a,int b,int c){
	edge[nume] = Edge(b,first[a],c);first[a] = nume++;
	edge[nume] = Edge(a,first[b],0);first[b] = nume++;
}
int q[N],dis[N],S,T,n,m,tot;
bool bfs(){
	int front,rear;
	front = rear = 0;
	memset(dis,-1,sizeof(dis));
	q[rear++] = T;dis[T] = 1;
	while(front < rear){
		int u = q[front++];
		for(int e=first[u];~e;e=edge[e].nxt){
			int v=edge[e].to;
			if(edge[e^1].cap && dis[v]==-1){
				dis[v] = dis[u] + 1;
				q[rear++] = v;
			}
		}
	}
	return dis[S] != -1;
}
int dfs(int u,int flow){
	if(u==T) return flow;
	int used = 0,d;
	for(int &e = cur[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(dis[u] == dis[v] + 1 && edge[e].cap && (d = dfs(v,min(flow-used,edge[e].cap)))){
			edge[e].cap -= d;
			edge[e^1].cap += d;
			used += d;
		}
		if(used == flow) break;
	}
	if(!used) dis[u] = -1;
	return used;
}
int dinic(){
	ll ans = 0;
	while(bfs()){
		Rep(i,1,tot) cur[i] = first[i];
		ans += dfs(S,inf);
	}
	return ans;
}
int id[N],Id[N],x[N];
vector<int> g[N];
signed main(){
	mem(first,-1);nume = 0;
	n = read();
	tot = 0;
	S = ++tot;
	T = ++tot;
	Rep(i,2,n){
		id[i] = ++tot;
		Addedge(id[i],T,1);
	}
	Rep(i,1,n-1){
		Id[i] = ++tot;
		Addedge(S,Id[i],1);
		//v[i] . resize(read());
		int t = read();
		rep(j,0,t){
			int t = read();
			if(t != 1) Addedge(Id[i],id[t],1);
			g[t] . push_back(i);
		}
	}
	if(dinic() != n-1){
		puts("-1");
		return 0;
	}
	Rep(i,1,n-1){
		int u = Id[i];
		for(int e=first[u];~e;e=edge[e].nxt){
			if(e%2==0 && !edge[e].cap){
//				printf("{%d %d}\n",u,edge[e].to);
				x[i] = edge[e].to - 1;
			}//完美，简直太棒了呀 
		}
	}
	queue<int> Q;
	static int vis[N],y[N];
	Q.push(1);vis[1]=true;
	while(!Q.empty()){
		int u = Q.front();Q.pop();
		for(auto v:g[u]){
		//	printf("{%d)\n",x[v]);
			if(!vis[x[v]]){
				vis[x[v]] = u;
				Q.push(x[v]);
				y[v] = u;
//				printf("%d %d\n",u,x[v]);
			}
		}
	}
	Rep(i,1,n-1){
		write(x[i]),pc(' '),write(y[i]),pc('\n');
	}
}


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

int main(){
  int N,K,i;
  cin >>N>>K;
  i = N%2;
  if(i==1){
    N = (N-i)/2+1;
  }
  else{
    N=N/2;
  }
  if(N>=K){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int N, T;
	
	cin >> N >> T;
	vector<pair<int, int>>d(N);
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		d[i] = make_pair(a, b);
	}
	sort(All(d));
	int ans = 0;
	rep(i, N) {
		if (d[i].second <= T) {
			ans = d[i].first;
			break;
		}
	}
	if(ans>0)cout << ans;
	else cout << "TLE";
	ed;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int a,b,q;
  cin >> a >> b >> q;
  long* s = new long[100000];
  long* t = new long[100000];
  long* x = new long[100000];
  for(int i=0;i<a;i++) cin >> s[i];
  for(int i=0;i<b;i++) cin >> t[i];
  for(int i=0;i<q;i++) cin >> x[i];

  for(int i=0;i<q;i++){
    long xi = x[i];

    int sa,tb;
    int bb=-1,ee=a;
    while(ee-bb>1){
      int mid = (bb+ee)/2;
      if(s[mid]<xi){
        bb = mid;
      } else {
        ee = mid;
      }
    }
    sa = bb;
    bb=-1,ee=b;
    while(ee-bb>1){
      int mid = (bb+ee)/2;
      if(t[mid]<xi){
        bb = mid;
      } else {
        ee = mid;
      }
    }
    tb = bb;

    long ans=1000000000000000000;

    if(sa!=-1 && tb!=-1){
      ans = min(xi-min(s[sa],t[tb]),ans);
    }
    if(sa!=-1 && tb!=b-1){
      ans = min(ans,xi-s[sa] + t[tb+1]-xi + min(xi-s[sa],t[tb+1]-xi));
    }
    if(sa!=a-1 && tb!=-1){
      ans = min(ans,xi-t[tb] + s[sa+1]-xi + min(xi-t[tb],s[sa+1]-xi));
    }
    if(sa!=a-1&&tb!=b-1){
      ans = min(ans,max(s[sa+1],t[tb+1])-xi);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		
		if (500 * K >= X) {
			System.out.println("Yes");
		} else {
			System.out.println("No");

		}

	}
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll k;
  cin >> k;
  vector<ll> a(k);
  REP(i, k) cin >> a[i];

  ll lb = 2, ub = 2;
  for(int i=k-1; i>=0; --i) {
    // lb <= x <= ub で xがa[i]の倍数
    ll low = ceil(lb, a[i]) * a[i];
    ll high = ub / a[i] * a[i];
    if(low > ub || high < lb) {
      cout << -1 << endl;
      return 0;
    }
    lb = low;
    ub = high + a[i] - 1;
  }
  cout << lb << " " << ub << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A>C&&C>B){
    cout<<"Yes"<<endl;
  }
  else if(B>C&&C>A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int S,W; cin >> S >> W;
    cout << (S <= W ? "unsafe" : "safe") << ln;
}

Measured memory_bytes: 3652
N, D = map(int,input().split())

X = []
for _ in range(N):
    X_i = list(map(int,input().split()))
    X.append(X_i)

ans = 0
for i in range(N):
    for j in range(i+1,N):
        dist = 0
        for d in range(D):
            dist += (X[i][d] - X[j][d]) ** 2

        for k in range(1000):
            if dist == k**2:
                ans += 1

print(ans)
        


Measured memory_bytes: 9192
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
aPoint = 0
bPoint = 0
for i in range(0, n, 2) :
    aPoint += a[i]
for i in range(1, n, 2) :
    bPoint += a[i]
print(aPoint - bPoint)

Measured memory_bytes: 3060
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    string s;
    string t;
    int a;
    int b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s==u){
        a--;
    }else if(t==u){
        b--;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  static class Restaurant {
    public int id;
    public String city;
    public int rating;

    public Restaurant(int id, String city, int rating) {
      this.id = id;
      this.city = city;
      this.rating = rating;
    }
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    Restaurant[] rs = new Restaurant[n];

    for (int i = 0; i < n; ++i) {
      String s = sc.next();
      int p = sc.nextInt();
      rs[i] = new Restaurant(i + 1, s, p);
    }

    for (Restaurant r : mergeSort(rs))
      System.out.println(r.id);
  }

  public static Restaurant[] mergeSort(Restaurant[] a) {
    if (a.length <= 1)
      return a;

    int mid = a.length / 2;
    Restaurant[] left = new Restaurant[mid];
    Restaurant[] right = new Restaurant[a.length - mid];

    for (int i = 0; i < mid; ++i)
      left[i] = a[i];

    for (int i = mid; i < a.length; ++i)
      right[i - mid] = a[i];

    return merge(mergeSort(left), mergeSort(right));
  }

  public static Restaurant[] merge (Restaurant[] l, Restaurant[] r) {
    Restaurant[] merged = new Restaurant[l.length + r.length];

    int i = 0, j = 0, k = 0;
    while (i < l.length && j < r.length) {
      if (l[i].city.compareTo(r[j].city) < 0 || l[i].city.equals(r[j].city) && l[i].rating >= r[j].rating)
        merged[k++] = l[i++];
      else
        merged[k++] = r[j++];
    }

    while (i < l.length)
      merged[k++] = l[i++];
    while (j < r.length)
      merged[k++] = r[j++];

    return merged;
  }
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;

int main(){
	int n; cin >> n;
	vector<pi> v;
	rep(it, 2) rep(i, n){
		int a; cin >> a;
		v.pb(pi(a, it ? 1 : -1));
	}
	sort(all(v));
	
	int sum = 0;
	ll ans = 1;
	for(pi p : v){
		if(sum > 0 && p.second < 0 || sum < 0 && p.second > 0) (ans *= abs(sum)) %= mod;
		sum += p.second;
	}
	cout << ans << endl;
	
	return 0;
}


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

typedef long long ll;

const int N = 100 + 5, V = 1e5 + 5;

int n, w;
ll wt[N], v[N], dp[N][V];
// minimum weight to get v of value

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> w;
  for(int i = 1; i <= n; i++) cin >> wt[i] >> v[i];
  memset(dp, 63, sizeof dp);
  dp[1][0] = 0;
  dp[1][v[1]] = wt[1];
  for(int i = 2; i <= n; i++) {
    for(int j = 0; j < V; j++) {
      if(j - v[i] >= 0) dp[i][j] = dp[i-1][j-v[i]] + wt[i];
      dp[i][j] = min(dp[i][j], dp[i-1][j]);
    }
  }

  int mx = 0;
  for(int j = 0; j < V; j++) if(dp[n][j] <= w) mx = max(mx, j);
  cout << mx << "\n";
}


Measured memory_bytes: 82304
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int st[19][(1<<19)];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<(1<<n);i++)
	{
		cin>>st[n][i];
	}
	for(int i = n - 1; i >= 0; i--)
	{
		for(int j = 0; j < (1<<i); j++)
		{
			int l = j*2; int r = j*2+1;
			if(st[i+1][l]==st[i+1][r]) st[i][j] = st[i+1][l];
			else st[i][j] = abs(st[i+1][l]-st[i+1][r]);
		}
	}
	cout<<st[0][0]<<'\n';
}


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

int main(){
  vector<char> K={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  int N;
  cin >> N;
  string S;
  cin >> S;
  int L=S.size();
  vector<int> Si(L);
  for(int i=0; i<L; i++){
    for(int j=0; j<26; j++){
      if(S.at(i)==K.at(j)){
        Si.at(i)=j;
        Si.at(i)+=N;
        if(Si.at(i)>=26){
          Si.at(i)-=26;
        }
      }
    }
  }
  for(int i=0; i<L; i++){
    cout << K.at(Si.at(i));
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

// auto mod int

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

ll mod_pow(ll x,ll n,ll mod){
  if(n==0)return 1;
  ll res=mod_pow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}

mint choose(int n,int a) {
    mint x=1,y=1;
    rep(i,a) {
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}

int main() {

    int n,a,b;
    cin >> n >> a >> b;

    mint ans=mint(2).pow(n);
    ans-=1;
    ans-=choose(n,a);
    ans-=choose(n,b);

    cout<<ans.x<<endl;

 
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c=0;
  string s;
  cin>>s;
  int i=0,j=s.length()-1;
  while(i<=j)
  {
    if(s[i]!=s[j])
      c++;
    i++;j--;
  }
    cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
using namespace std;



int main(){
    int N; cin >> N;
    vector<int> A(N);
    float ans = 0;
    for (int i = 0; i < N ; i++){
        cin >> A[i];
        ans += (float) 1/A[i];
    }
    cout << (float) 1/ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

H,W,K=map(int,input().split())
b=[]
for i in range(H):
    _=input()
    temp=_.replace('#','1').replace('.','0')
    b.append(list(map(int,temp)))

area=np.array(b)

ans=0

for h in range (2**H):
    select_H=[] #削除する行の組合わせを取得

    for i in range (H):
        if (h>>i) & 1==1:
            select_H.append(1)
        else:
            select_H.append(0)
    sHarr=np.array(select_H)
    delsHarr=np.where(sHarr==1) #削除する行のindexを取得
    area_afterDelsH=np.delete(area,delsHarr,axis=0) #エリアから行を削除する。
            # 以下、行が削除された各パターンについて、列を削除していく。

    for w in range (2**W):
        select_W=[] #削除する列の組合わせを取得
        for j in range (W):
            if (w>>j) &1 ==1:
                select_W.append(1)
            else:
                select_W.append(0)
        sWarr=np.array(select_W)
        delsWarr=np.where(sWarr==1) #削除する列のindexを取得
        area_afterDelsHsW=np.delete(area_afterDelsH,delsWarr,axis=1)

        if np.sum(area_afterDelsHsW)==K:
            ans+=1

print(ans)

Measured memory_bytes: 26972
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	constexpr int MAX = 3100;
	int N, S;
	int ans = 0;
	vector<int> A;
	vector<int> dp(MAX);
	vector<int> dp2(MAX);
	
	cin>>N>>S;
	
	A.resize(N);
	// dp.resize(MAX):
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	dp2[0] = 1;
	
	for(int i = 0; i < N; i++){
		vector<int> next(MAX);
		
		// cout<<endl<<"i = "<<i<<endl;
		
		for(int k = 0; k < MAX; k++){
			next[k] += dp[k];
			next[k] %= MOD;
			if(k+A[i] < MAX){
				next[k+A[i]] += dp[k];
				next[k+A[i]] %= MOD;
			}
		}
		
		next[A[i]] += (i+1);
		next[A[i]] %= MOD;
		
		for(int j = 0; j < MAX; j++){
			dp[j] = next[j];
			
			// cout<<"j = "<<j<<" dp = "<<dp[j]<<" "<<dp2[j]<<endl;
			if(j == S){
				ans += dp[j];
				ans %= MOD;
			}
		}
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

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

    for(int i=0; i<N-1; i++)
        cin >> B[i];

    A[0] = B[0];
    A[N-1] = B[N-2];
    for(int i=1; i<=N-2; i++)
        A[i] = min(B[i-1], B[i]);

    int sm = 0;
    for(int i=0; i<N; i++)
        sm += A[i];

    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 256
from math import *

a, b, h, m = map(int, input().split())

hr_ang = 0.5 #0.5 deg/min
m_ang = 6 #6 deg/min

t = 60*h + m

hr_ang = radians((hr_ang*t)%360)
m_ang = radians((m_ang*t)%360)

hr_cmp = (a*sin(hr_ang), a*cos(hr_ang))
mn_cmp = (b*sin(m_ang), b*cos(m_ang))
v = (hr_cmp[0]-mn_cmp[0], hr_cmp[1]-mn_cmp[1])

print(sqrt(v[0]**2 + v[1]**2))


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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " <<  x << " " <<  y << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
void error(const char* str) {
	puts(str);
	exit(0);
}
int main()
{
	string s[4] = {"AC", "WA", "TLE", "RE"};
	map<string, int> mp;
	int n;
	cin >> n;
	rep(i, 0, n) {
		string t;
		cin >> t;
		mp[t]++;
	}
	rep(i, 0, 4) {
		printf("%s x %d\n", s[i].c_str(), mp[s[i]]);
	}
	return 0;
}


Measured memory_bytes: 3728
n = int(input())
s = input()
num = s.count("R")*s.count("G")*s.count("B")
cnt = 0
for i in range(n):
        for j in range(i+1,n):
            if 0 <= 2*j-i < n:
                if s[i] != s[j] and s[j] != s[2*j-i] and s[2*j-i] != s[i]:
                    #print(s[i],s[j],s[2*j-i],i,j,2*j-i)
                    cnt += 1
print(num - cnt)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B;
cin >> A >> B;
if (A == B) cout << "Draw" << endl;
else if (A == 1) cout << "Alice" << endl;
else if (B == 1 || B > A) cout << "Bob" << endl;
else if (A > B) cout << "Alice" << endl;

return 0;
}

Measured memory_bytes: 256