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

int H, W;
vector<string> s;

int main() {
  cin >> H >> W;
  s = vector<string>(H);
  for (int i=0; i<H; i++)
    cin >> s.at(i);
  vector<vector<int>> dw;
  vector<vector<int>> dh;
  for (int i = 0; i < H; i++) {
    vector<int> cw = vector<int>();
    int count = 0;
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
          cw.push_back(0);
      }
      else if (j == 0 || s[i][j - 1] == '#') {
        count = 0;
        for (int k = j; k < W; k++) {
          if (s[i][k] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        cw.push_back(count);
      }
      else {
        cw.push_back(count);
      }
    }
    dw.push_back(cw);
  }
  for (int j = 0; j < W; j++) {
    vector<int> ch = vector<int>();
    int count = 0;
    for (int i = 0; i < H; i++) {
      if (s[i][j] == '#') {
        ch.push_back(0);
      }
      else if (i == 0 || s[i - 1][j] == '#') {
        count = 0;
        for (int k = i; k < H; k++) {
          if (s[k][j] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        ch.push_back(count);
      }
      else {
        ch.push_back(count);
      }
    }
    dh.push_back(ch);
  }
  int max = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int sum = dw[i][j] + dh[j][i];
      if (max < sum) {
        max = sum;
      }
    }
  }
  cout << max - 1 << endl;
}


Measured memory_bytes: 35840
##### 解けた #####

s=input()
t=input()

sp="".join(sorted(s)) # sを並び替えて一番最初の文字列
tp="".join(list(reversed(sorted(t)))) # tを並び替えて一番最後の文字列

if sp<tp: # 目標を達成できるなら
    print("Yes")
else: # 達成できないなら
    print("No")

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

typedef struct{
  char name[11];
  int t;
}Que;

int main(void){
  Que qu[1000000];
  int i,n,q;
  scanf("%d %d",&n ,&q);
  int c=n;
  int s=1;
  int e=0;
  for(i=1;i<=n;i++){
    scanf("%s %d",qu[i].name ,&qu[i].t);}
  while (c>0){
    if (qu[s].t<=q){
      e += qu[s].t;
      printf("%s %d\n",qu[s].name ,e);
      s++;
      c--;
    }
    else{
      e += q;
      qu[s+c].t = (qu[s].t)-q;
      strcat(qu[s+c].name,qu[s].name);
      s++;
    }
  }
  return 0;
}



Measured memory_bytes: 4684
# abc141_a.py
# https://atcoder.jp/contests/abc141/tasks/abc141_a

# A - Weather Prediction /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 100点

# 問題文
# 高橋君の住む町の天気は、一日ごとに晴れ(Sunny)、くもり(Cloudy)、雨(Rainy)、晴れ、くもり、雨、… と周期的に変化します。
# 今日の天気を表す文字列 Sが与えられるので、明日の天気を予測してください。

# 制約
#     Sは Sunny, Cloudy, Rainy のいずれかである

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# 明日の天気を入力と同じ形式で出力せよ。

# 入力例 1
# Sunny

# 出力例 1
# Cloudy

# 高橋くんの住む町では、晴れの日の次の日の天気はくもりです。

# 入力例 2
# Rainy

# 出力例 2
# Sunny


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if S == 'Sunny':
        result = 'Cloudy'
    if S == 'Cloudy':
        result = 'Rainy'
    if S == 'Rainy':
        result = 'Sunny'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['Sunny']
        lines_export = ['Cloudy']
    if pattern == 2:
        lines_input = ['Rainy']
        lines_export = ['Sunny']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;
//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
//komennto C+udekaijo
//conbination n!/r!(n-r)!
class UnionFind{
	public:
	vector<int> parent;
	vector<int> rank;
	vector<int> size;
	UnionFind(signed n){
		parent.reserve(n);
		rank.reserve(n);
		size.reserve(n);
		rep(i,n){
			parent[i]=i;
			rank[i]=0;
			size[i]=1;
		}
	}
	signed find(signed x){
		//keiroassyuku
		if(parent[x]==x){
			return x;
		}else{
			return parent[x]=find(parent[x]);
		}
	}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			size[y]+=size[x];
			size[x]=size[y];
			parent[x]=y;
		}else{
			size[x]+=size[y];
			size[y]=size[x];
			parent[y]=x;
			if(rank[x]==rank[y])rank[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
	int sizeis(int x){return size[find(x)];}
};

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,c;
	cin>>n>>m>>c;
	vector<int> b(m);
	rep(i,m)cin>>b[i];
	vector< vector<int> > a(n,vector<int>(m));
	rep(i,n)rep(j,m)cin>>a[i][j];
	int sum=0;
	int ans=0;
	rep(i,n){
		rep(j,m){
			sum+=a[i][j]*b[j];
		}
		sum+=c;
		if(sum>0)ans++;
		sum=0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//?´???°??????
bool isPrime(int x) {
	if (x < 2)return 0;
	else if (x == 2)return 1;
	if (x % 2 == 0)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++) {
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
	}
}

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

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

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)

bool solve(){
    int N; cin >> N;
    string X; cin >> X;
    int D; cin >> D;
    string XX = X;

    for(int i = 0; i < (int)X.size() and D > 0; i++){
        if(X[i] == '0'){
            X[i] = '1';
            D--;
        }
    }
    for(int i = X.size() - 1; i >= 0 and D > 0; i--){
        if(XX[i] == '1'){
            X[i] = '0';
            D--;
        }
    }

    cout << X << endl;
    
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a.at(i);
  int mn=1e9;
  for(int i=-100;i<=100;i++){
    int sum=0;
    rep(j,n){
      sum+=(i-a.at(j))*(i-a.at(j));
    }
    mn=min(mn,sum);
  }
  cout<<mn;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
string S;
ll N, M;
vector<string>A;


int main() {
    cin >> N;
    int C0, C1, C2, C3;
    C0 = C1 = C2 = C3 = 0;
    rep(i,N) {
        cin >> S;
        if (S=="AC") {
            C0++;
        }
        else if (S == "WA") {
            C1++;
        }
        else if (S == "TLE") {
            C2++;
        }
        else {
            C3++;
        }
    }
    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector<int> g[1005];

int main() {
  int n,m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].push_back(b);
  }

  vector<int> ans(n+1);
  int M = ans.size();
  
  for(int s = 0; s < n; s++) {
    vector<int> dist(n,-1);
    vector<int> prev(n,-1);
    queue<int> q;
    dist[s] = 0;
    q.push(s);
    while(!q.empty()) {
      int v = q.front();
      q.pop();
      for(int i = 0; i < g[v].size(); i++) {
	int u = g[v][i];
	if(dist[u] != -1) continue;
	dist[u] = dist[v] + 1;
	prev[u] = v;
	q.push(u);
      }
    }

    for(int t = 0; t < n; t++) {
      if(t == s || dist[t] == -1) continue;
      for(int i = 0; i < g[t].size(); i++) {
	int u = g[t][i];
	if(u == s) {
	  vector<int> tmp;
	  tmp.push_back(s);
	  int v = t;
	  while(v != s) {
	    tmp.push_back(v);
	    v = prev[v];
	  }
	  if(M > tmp.size()) {
	    M = tmp.size();
	    ans = tmp;
	  }
	}
      }
    }
  }

  if(M == n + 1) {
    cout << -1 << endl;
    return 0;
  }
  else {
    cout << M << endl;
    for(int i = 0; i < ans.size(); i++) {
      cout << ans[i] + 1 << endl;
    }
  }
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
char f[9][9];
int main()
{
	for(int i=0;i<8;i++)
	{
		for(int j=0;j<8;j++)
		{
			cin >> f[i][j];
		}
	}
	cout << 90 << endl;
	for(int j=0;j<8;j++)
	{
		for(int i=7;i>=0;i--)
		{
			cout << f[i][j];
		}
		cout << endl;
	}
	cout << 180 << endl;
	for(int i=7;i>=0;i--)
	{
		for(int j=7;j>=0;j--)
		{
			cout << f[i][j];
		}
		cout << endl;
	}
	cout << 270 << endl;
	for(int j=7;j>=0;j--)
	{
		for(int i=0;i<8;i++)
		{
			cout << f[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1140
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	prices := strings.Split(sc.Text(), " ")
 	for i := 0;i < len(prices) - 1;i++ {
		for j := len(prices) - 1; j > 0; j-- {
			fastPrice,_ := strconv.Atoi(prices[i])
			lastPrice,_ := strconv.Atoi(prices[j])
			if fastPrice > lastPrice{
				t := prices[i]
				prices[i] = prices[j]
				prices[j] = t
			}
		}
	}
	fastPrice,_ := strconv.Atoi(prices[0])
	lastPrice,_ := strconv.Atoi(prices[1])
	total := fastPrice + lastPrice
	result := strconv.Itoa(total)
	fmt.Printf(result)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n, m;cin >> n >> m;
	vector<pair<int,int>> oriv(m);
	vector<vector<int>> M(n,vector<int>(n));
	rep(i,n)
		rep(j,n)
		{
			M[i][j]=0;
		}


	rep(i,m)
	{
		int foo,fooo;cin >> foo >> fooo;
		oriv[i]=make_pair(foo-1,fooo-1);
		M[foo-1][fooo-1] =1;
		M[fooo-1][foo-1] =1;
	}


	vector<int> color(n);
	rep(i,n)color[i]=0;
	stack<int> S;
	int c = 0;

	rep(iii,m)
	{
		int x=oriv[iii].first, y = oriv[iii].second;
		//cout<<x<<':'<<y<<endl;
		M[x][y]=0;
		M[y][x]=0;
		rep(i,n)color[i]=0;
		S.push(0);
		color[0]=1;
		while(!S.empty())
		{
			int now=S.top();
			color[now]=1;
			int v = -1;
			rep(i,n)
			{
				if(M[now][i]==1&&color[i]==0){S.push(i);v=i;break;}
			}
			//cout<<iii<<':'<<v<<endl;
			if(v==-1)
			{
				S.pop();
			}

		}
		rep(i,n)
			if(color[i]==0)
			{
				c++;
				break;
			}

		M[x][y]=1;
		M[y][x]=1;
	}

	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
ll h[100005];
ll dp[100005];
ll solve(int idx){
	if(idx == n - 1) return 0;
	if(dp[idx] != -1) return dp[idx];
	ll val = INT_MAX;
	if(idx < n - 2){
		 val = min(val,abs(h[idx]-h[idx+2]) + solve(idx+2));
	}
	val = min(val,abs(h[idx]-h[idx+1])+solve(idx+1));
	dp[idx] = val;
	return val;
}
void reset(){
	for(int i = 0; i < 100005; i++) dp[i] = -1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	reset();
	for(int i = 0; i < n ; i++) cin >> h[i];
	cout << solve(0);
	return 0;
}


Measured memory_bytes: 4224
from math import factorial
a, b = [int(i) for i in input().split()]
if abs(a-b) > 1:
    print(0)
elif a == b:
    print((2 * factorial(a) * factorial(b)) % (10 ** 9 + 7))
else:
    print((factorial(max(a, b)) * factorial(min(a, b))) % (10 ** 9 + 7))

Measured memory_bytes: 11144
def main():
  import sys
  b=sys.stdin.buffer
  h,w=map(int,b.readline().split())
  x=w+1
  s=[c>>3for c in b.read()]
  dp=[10000]*h*x
  dp[0]=5-s[0]
  for i in range(1,w):
    dp[i]=dp[i-1]+(s[i-1]^s[i])
  for i in range(x,h*x,x):
    l=i-x
    dp[i]=dp[l]+(s[l]^s[i])
    for j in range(1,w):
      k=i+j
      sk=s[k]
      l=k-1
      t=dp[l]+(s[l]^sk)
      l=k-x
      u=dp[l]+(s[l]^sk)
      if t>u:t=u
      dp[k]=t
  print(dp[-2]+1>>1)
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

/* a と b の最小公倍数を求める */
long long LCM(long long a, long long b)
{
    long long g = GCD(a, b);
    return a / g * b;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;

    int ans = 0;
    REP(a, N)
    {
        REP(b, N)
        {
            REP(c, N)
            {
                ans += GCD(GCD(a + 1, b + 1), c + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y,b,p,price;
  cin>>n;
  for(int i=1;i<=n;++i){
    cin>>x>>y>>b>>p;
    price=x*b+y*p;
    if(b>=5&&p>=2) price=price*4/5;
    if(b<5) b=5;
    if(p<2) p=2;
    cout<<min(price,(x*b+y*p)*4/5)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 2-1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int main() {
	int n;
	while (cin >> n, n) {
		vector < pair<double, string >> crop(n);
		REP(i, n) {
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			crop[i].second= l;
			double income= m*f*s-p;
			double time = a + b + c+ m*(d + e);
			crop[i].first =- income / time;
		}
		sort(ALL(crop));
		REP(i, n)
			cout << crop[i].second << endl;
		cout<<"#"<<endl;




	}




}

Measured memory_bytes: 3024
n,m,x,y = map(int,input().split())
listx = list(map(int,input().split()))
listy = list(map(int,input().split()))

listx.sort()
listy.sort()

if max(listx[n-1],x) < min(listy[0],y):
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A).most_common()

kl1 = sorted([k for k, v in c if v >= 2], reverse=True)
kl2 = sorted([k for k, v in c if v >= 4], reverse=True)
if len(kl1) < 2:
  print(0 if not kl2 else kl2[0] ** 2)
else:
  print(kl1[0] * kl1[1] if not kl2 else max(kl1[0] * kl1[1], kl2[0] ** 2))

Measured memory_bytes: 26584
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}

func main() {
  t := make([]int, 3)
  for i := 0; i < 3; i++ {
    fmt.Scan(&t[i])
  }
  fmt.Println(sumInt(t...) - maxInt(t...))
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#include <random>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll a[100100];
bool b[100100];
int main(){
  cin >> N;
  rep(i,N){
    cin >> a[i];
    if(a[i] == i+1) b[i] = true;
    else b[i] = false;
  }
  ll ans = 0;
  rep(i,N){
    if(b[i]){
      ans++;
      b[i+1] = false;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	m := len(a) + 1
	ans := 0
	for _, ai := range a {
		if m >= ai {
			ans++
			m = ai
		}
	}

	fmt.Fprintln(stdout, ans)
}


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

int main(void){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int o1_w = 100*A;
    int o2_w = 100*B;
    int o3_s = C;
    int o4_s = D;
    double max_c = 0;
    int max_m = 0;
    int max_s = 0;
    for(int o1=0; o1*o1_w<=F; o1++){
        int m1 = o1*o1_w;
        for(int o2=0; m1+o2*o2_w<=F; o2++){
            int m2 = m1+o2*o2_w;
            for(int o3=0; m2+o3*o3_s<=F; o3++){
                int m3 = m2+o3*o3_s;
                for(int o4=0; m3+o4*o4_s<=F; o4++){
                    int a = o1*o1_w + o2*o2_w;
                    int b = o3*o3_s + o4*o4_s;
                    double c = 100.0*b/(a+b);
                    if(c > 100.0*E/(100.0+E)){
                        continue;
                    }
                    if(c >= max_c){
                        max_m = a+b;
                        max_s = b;
                        max_c = c;
                    }
                }
            }
        }
    }
    cout << max_m << ' ' << max_s;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 5e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;
char mp[17][17];
int n,m,k;
bool check(int x,int y){
	int res = 0;
	for(int i = 0;i < n;++i){
		for(int j = 0;j < m;++j){
			if((x & (1 << i)) || (y & (1 << j))) continue;
			if(mp[i][j] == '#') res++;
		}
	}
	return res == k;
}
int main(){
    scanf("%d %d %d",&n,&m,&k);
    for(int i = 0;i < n;++i)
		scanf("%s",mp[i]);	
	int ans = 0;
	for(int i = 0;i < (1 << n);++i){
		for(int j = 0;j < (1 << m);++j){
			if(check(i,j)) ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3832
import java.util.Scanner;

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

			String s = sc.next();
			
			//R...RL...Lのブロックに分離してそれぞれごとに集計すればよい
			//RRRLLの場合(start = 0, sep = 3, len=5)
			//00320
			//RRRRLの場合(start = 0, sep = 4, len=5)
			//00023
			//RRRLの場合 (start = 0, sep = 3, len=4)
			//0022
			
			char L = 'L';
			char R = 'R';
			
			char[] sArray = (s + "T").toCharArray();
			int[] result = new int[s.length()];
			
			int start = 0;
			int sep = 0;
			boolean isRight = true;
			for(int i = 0 ; i < sArray.length ; i++ ) {
				if ( isRight ) {
					if ( sArray[i] == R ) {
						//continue
					}
					else {
						//divider
						isRight = false;
						sep = i;
						continue;
					}
				}
				else {
					if ( sArray[i] == L ) {
						//continue
					}
					else {
						//termination, so count it
						int blockLen = i - start;
						
						if ( blockLen % 2 == 0 ) {
							result[sep-1] = blockLen / 2;
							result[sep] = blockLen / 2;
						}
						else {
							int gap = sep - start;
							result[sep-1] = (blockLen / 2) + gap % 2;
							result[sep] = (blockLen / 2) + (gap+1) % 2;
						}
						
						start = i;
						isRight = true;
					}
				}
			}
			
			for(int i = 0 ; i < result.length ; i++ ) {
				System.out.print(result[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 47956
#include <stdio.h>
#include <string.h>
int main(){
	int students[100005], n, temp, nfirst = 0;
	memset(students, -1, sizeof students);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i){
		scanf("%d", &temp);
		students[temp-1] = i+1;
	}
	for (int i = 0; i < n; ++i){
		if (nfirst){
			printf(" ");
		}else nfirst = 1;
		printf("%d", students[i]);
	}
	printf("\n");
	return 0;
}

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

const ll MOD = 998244353;
ll multip(ll x, ll y) { return (x*y)%MOD; }

int main() {
  int n; scanf("%d", &n);
  vector<int> a(n+1, 0);
  rep(i, n) {
    int x;
    scanf("%d", &x);
    if ((i==0)&&(x!=0)) a[n]++;
    a[x]++;
  }
  if ((a[0]!=1)||(a[n]==1)) {
    printf("0\n");
    return 0;
  }
  while (a[n]==0) n--;
  ll ans=1;
  rep(i, n) {
    rep(j, a[i+1]) ans=multip(ans, a[i]);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 640
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
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); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, m;
vector<pair<LL, LL>> v;
LL a, b;
int main(){
    cin >> n >> m;
    REP(i, n){
        cin >> a >> b;
        v.emplace_back(make_pair(a, b));
    }
    sort(ALL(v));
    LL ans = 0;
    int cnt = 0;
    REP(i, (int)v.size()){
        if(cnt == m)continue;
        if(cnt + v[i].second <= m){
            ans += v[i].first*v[i].second;
            cnt += v[i].second;
        }else{
            ans += v[i].first*(m - cnt);
            cnt += (m - cnt);
        }
    }
    cout << ans << endl;
}

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

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
	return x * f;
}

const int N = 110;
int a[N];
int s[N];

int main() {
	int n = read(), x = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	for (int i = 2; i <= n + 1; i++) {
		s[i] = s[i - 1] + a[i - 1];
		if (s[i] > x) { printf("%d\n", i - 1); return 0;}
	}
	printf("%d\n", n + 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

void binary(int n, int roop, bool *arr){
  rep(i, roop){
    if(n != 0){
      arr[i] = n%2;
      n /= 2;
    }
    else
      arr[i] = 0;
  }
}


int main(){
  int N, M;
  cin >> N >> M;
  int k[N];
  vector<vector<int> > s(M);
  int tmp;
  rep(i, M){
    cin >> k[i];
    rep(j, k[i]){
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  int p[M];
  rep(i, M)
    cin >> p[i];
  //


  
  int ans = 0;
  bool sw[N];
  rep(i, pow(2, N) ){
    int light = 0;
    binary(i, N, sw);

    rep(j, M){
      int count = 0;
      rep(k, s[j].size() ){
	if(sw[s[j][k]-1] == true)
	  count++;
      }
      if(count%2 == p[j])
	light++;
    }
    if(light == M)
      ans++;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    auto ans = (a - 1) * (b - 1);
    co(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static InputReader in;
    static PrintWriter out;

    public static void main(String[] args) {
        in = new InputReader(); //use it for input
        out = new PrintWriter(System.out); //use it for output
        solve();
        out.close();
    }

    static final int MOD = (int) 1e9 + 7;
    static ArrayList <Integer> g[];
    static long dp[][];

    static void solve() {
        int n = in.nextInt();

        g = new ArrayList[n];
        dp = new long[n][2];

        for(int i = 0; i < n; i++)
            g[i] = new ArrayList<>();

        for(int i = 0; i < n - 1; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            x--; y--;

            g[x].add(y);
            g[y].add(x);
        }

        dfs(0, -1);

        out.println((dp[0][0] + dp[0][1]) % MOD);
    }

    static void dfs(int u, int p) {
        dp[u][0] = dp[u][1] = 1;

        for(int v : g[u]) {
            if(v != p) {
                dfs(v, u);

                dp[u][0] = dp[u][0] * dp[v][1] % MOD;

                long s = (dp[v][0] + dp[v][1]) % MOD;
                dp[u][1] = dp[u][1] * s % MOD;
            }
        }
    }
}

class InputReader {
    BufferedReader rd;
    StringTokenizer tk;

    InputReader() {
        rd = new BufferedReader(new InputStreamReader(System.in), 32768);
    }

    public String readLine() {
        try {
            return rd.readLine();
        } catch (IOException e) {
            throw new RuntimeException();
        }
    }

    public String read() {
        while (tk == null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(readLine());
        }

        return tk.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(read());
    }

    public long nextLong() {
        return Long.parseLong(read());
    }

    public double nextDouble() {
        return Double.parseDouble(read());
    }
}

Measured memory_bytes: 76880
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>


#define MOD 1000000007
#define INTMAX 0x7fffffff
#define INTMIN 0x80000000
#define LLMAX 0x7fffffffffffffffLL
#define LLMIN 0x8000000000000000LL

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

using namespace std;
using ll = long long;

int main(){
    vector<int> v;

    int N;
    cin >> N;

    int A;
    for (int i = 0; i < N; ++i) {
        cin >> A;
        auto it = lower_bound(v.begin(), v.end(), A);
        if (it != v.end() && *it == A) {
            //cout << "erase " << A << endl;
            v.erase(it);
        } else {
            //cout << "insert " << A << endl;
            v.insert(it, A);
        }
        //for (int vi : v) {
        //    cout << vi << ", ";
        //}
        //cout << endl;
    }

    cout << v.size() << endl;
}

Measured memory_bytes: 892
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int MOD = 1e9 + 7;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	vector<ll> sm(n + 10, 0LL);
	sm[0] = 0;
	repn(i, 1, n + 5) sm[i] = (ll)(sm[i - 1] + i);
	for(ll i = k; i <= n + 1; i++){
		ll mn = (i * (i - 1)) / 2;
		ll mx = sm[n] - (((n - i) >= 0) ? sm[n - i] : 0);
		(ans += mx - mn + 1) %= MOD;
	}
	cout << ans % MOD << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int N;
int x[200002];
int a,b,c;
int main(){
  /*
  cin >> N;
  for(int i=0;i<N;i++)cin >> x[i];
  sort(x,x+N);
  */
  cin >> a >> b >> c;
  if(a<=c && a+b>=c)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

int main()
{
	//freopen("read.in","r",stdin);
	int x=read();
	for(int i=1;i<=3500;i++)
		for(int j=1;j<=3500;j++)
		{
			int tp=i+j,lw=i*j;
			//cerr << tp << " " << lw << endl;
			if(1ll*lw*4<1ll*tp*x) continue;
			ll ttp=1ll*4*lw-1ll*tp*x;
			ll llw=1ll*lw*x;
			if(ttp==0) continue;
			if(llw%ttp==0)
			{
				cout << i << " " << j << " " << llw/ttp << endl;
				return 0;
			}
		}
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 105
int a[MAXN];
int N;
void get_input() {
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&a[i]);
}

void display_output() {
    printf("%d",a[0]);
    for(int i=1;i<N;i++) {
        printf(" %d",a[i]);
    }
    printf("\n");
}

void solve() {
    int i,j,k;
    display_output();
    for(i=1;i<N;i++) {
        k=a[i];
        for(j=i-1;j>=0;j--) {
            if(a[j]>k) {
                a[j+1]=a[j];
            } else {
                break;
            }
        }
        a[j+1]=k;
        display_output();
    }
}
int main() {
#ifdef debug
    freopen("in.txt","r",stdin);
#endif
    get_input();
    solve();
}

Measured memory_bytes: 2744
#include <stdio.h>

int selectionSort(int *,int);

int main(){
  int i=0;
  int j=0;
  int count=0;
  scanf("%d", &i);
  int A[i];
  for(j=0;j<i;j++){
    scanf("%d",&A[j]);
  }
  count=selectionSort(A,i);
  for(j=0;j<i;j++){
    printf("%d",A[j]);
    if(j!=i-1)printf(" ");
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
  return 0;
}

int selectionSort(int *A,int N){
  int i=0;
  int j=0;
  int count=0;
  int minj=0;
  int swapnumber=0;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      swapnumber=A[i];
      A[i]=A[minj];
      A[minj]=swapnumber;
      count++;
    }
  }
  return count;
}



Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;

int main() {
  string s; cin >> s;
  int x, y; cin >> x >> y;
  int n = s.size();
  int a[10010];
  int j = 0;

  for(int i = 0; i < 10010; ++i) {
    a[i] = 0;
  }

  for(int i = 0; i < n; ++i) {
    if(s[i] == 'T') j++;
    else a[j]++;
  }

  bitset<16001> dpx, dpy;
  dpx = dpy = 1;
  dpx = dpx << 8000;
  dpy = dpy << 8000;
  dpx = dpx << a[0];
  int i = 1;
  while(i < 8000) {
    dpy = (dpy << a[i]) | (dpy >> a[i]);
    i++;
    dpx = (dpx << a[i]) | (dpx >> a[i]);
    i++;
  }

  if(dpx[x+8000] && dpy[y+8000]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
<?php

$stdin = preg_split('//', trim(fgets(STDIN)));

foreach ($stdin as $c) {
    if ('a' <= $c && $c <= 'z') {
        print strtoupper($c);
    } elseif ('A' <= $c && $c <= 'Z') {
        print strtolower($c);
    } else {
        print($c);
    }
}
print "\n";

Measured memory_bytes: 6844
nums = int(input())
ary = list(map(int,input().split()))

#puls no toki
count = 0
sum = ary[0]
if ary[0] < 0 :
    count += abs(ary[0])+1
    sum = 1
elif ary[0] == 0:
    sum = 1
    count += 1

for i in range (1,nums):
    sum += ary[i]

    if i % 2 == 1:
        if sum > 0 :
            count += abs(sum)+1
            sum = -1
        elif sum == 0:
            sum = -1
            count += 1
    elif i % 2 == 0:
        if sum < 0:
            count += abs(sum)+1
            sum  = 1
        elif sum == 0:
            sum = 1
            count += 1

result_plus = count

#minus no toki
count = 0
sum = ary[0]
if ary[0] > 0:
    count += abs(ary[0]) +1
    sum = -1
elif ary[0] == 0:
    sum = -1
    count += 1

for i in range(1,nums):
    sum += ary[i]
    if i % 2 == 1:
        if sum < 0:
            count += abs(sum)+1
            sum = 1
        elif sum == 0:
            count += 1
            sum = 1
    if i % 2 == 0:
        if sum > 0:
            count += abs(sum)+1
            sum = -1
        elif sum == 0:
            count += 1
            sum = -1

result_minus = count

if result_plus > result_minus:
    print(result_minus)
else:
    print(result_plus)

Measured memory_bytes: 14332
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}

		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long ans = 0;
		for (int i = 0; i < n; i++) {
			ans += binarySearch(a, b[i]) * (n - binarySearch(c, b[i] + 1));
		}
		System.out.println(ans);
	}

	// array[i] < targetを満たす最大のiを求める
	public static long binarySearch(int[] array, int target) {
		int l = -1;
		int r = array.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (array[mid] < target)
				l = mid;
			else
				r = mid;
		}
		return r;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}


Measured memory_bytes: 37472
#include <stdio.h>

int main(void)
{
	int S,h,m,s,i;
	
	scanf("%d",&S);
	
	h = S / 3600;
	i = S - h * 3600;
	m = i / 60;
	s = S - h * 3600 - m * 60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
	ll k;
	st s;
	cin >> k >> s;
	if(s.size() <= k) cout << s << endl;
	else{
		st ans = s.substr(0, k);
		ans += "...";
		cout << ans << endl;
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=1001000;
int n;
char s[N],t[N];
deque<int> deq;
int main(){
	cin>>n;
	scanf("%s%s",s+1,t+1);
	int he=0,ta=1,l=n+1,tag=0,ans=0;
	deq.push_back(n+1);
	for(int i=n;i;--i){
		int tmp=l;
		while(l&&(l>i||s[l]!=t[i])) --l;
		if(!l) return puts("-1")&0;
		if(tmp==l){
			while(!deq.empty()&&deq.back()-tag>=i) deq.pop_back();
			deq.push_back(i+tag);
		}
		else{
			++tag;
			if(l!=i) ans=max(ans,(int)deq.size()),deq.push_front(l+tag);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
int a, b, c, k;
cin >> a>> b >> c >> k;
int cnt = 0;
while(b <= a){
    b *= 2;
    cnt++;
}
if(c*pow(2, k-cnt) > b )cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

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

namespace A_FiveAntennas
{
    class Program
    {
        static void Main()
        {
            var a = int.Parse(Console.ReadLine());
            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
            var e = int.Parse(Console.ReadLine());
            var k = int.Parse(Console.ReadLine());
            Console.WriteLine(e - a <= k ? "Yay!" : ":(");
            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s;cin >> s ;
    ll now = 0,ans = 0,ten =1;
    vector<int> rem(2019,0);
    rep(i,s.size()){
        now += ten*(s[s.size()-1-i]-'0');
        now %=2019;
        rem[now]++;
        ten*=10;
        ten%=2019;
    }
    FOR(i,0,2018){
        ans+=rem[i]*(rem[i]-1)/2;
    }
    ans+=rem[0];
    cout << ans << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}
	if (a > b) {
		printf("a > b\n");
	}
	if(a==b) {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 2612