akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import copy

H, W, K = map(int, input().split())

row = []
for _ in range(H):
    C, = map(str, input().split())
    row.append(list(C))

ans = 0
for i in range(2**H):
    tmp = copy.deepcopy(row)

    i_list = list(map(int, list(format(i, 'b'))))
    for ii, il in enumerate(i_list[::-1]):
        if il==1:
            for w in range(W):
                tmp[-1-ii][w] = 'r'

    for j in range(2**W):
        tmp2 = copy.deepcopy(tmp)
        j_list = list(map(int, list(format(j, 'b'))))
        for jj, jl in enumerate(j_list[::-1]):
            if jl==1:
                for h in range(H):
                    tmp2[h][-1-jj] = 'r'


        count = sum([t.count('#') for t in tmp2])
        if count==K:
            ans += 1

print(ans)


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

inline int64 count4_2(int64 n, int64 k) {
  if(n > k) return (0);
  return (1);
}

int main() {
  int N, K;
  cin >> N >> K;
  cout << count4_2(N, K) << endl;
}







Measured memory_bytes: 3148
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {
    int N, M;
    cin>>N>>M;
    int p[M];
    string S[M];
    for(int i=0;i<M;++i){
        cin>>p[i]>>S[i];
    }
    map<int, int> acnum;
    map<int, int> wanum;
    int ac=0, wa=0;
    for(int i=0;i<M;++i){
        if((acnum[p[i]]==0) & (S[i]=="WA")){
            wanum[p[i]]++;
        }
        else if((acnum[p[i]]==0) & (S[i]=="AC")){
            ac++;
            acnum[p[i]]++;
        }
    }
    for(int i=1;i<=N;++i){
        if(acnum[i]>0)wa+=wanum[i];
    }
    cout<<ac<<" "<<wa<<endl;
}


Measured memory_bytes: 15488
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
	string s;
	gets(s)
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<vector<ll>> v(10, vector<ll>(10,0));

  for(int i = 1; i <= N; i++){
    string now = to_string(i);
    int h = now[0] - '0';
    int t = now[now.size()-1] - '0';
    v[h][t]++;
  }
  ll ans = 0;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      ans += v[i][j] * v[j][i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
using namespace std;
 
int main(){
  // 入力
  int K, S;
  int count = 0;

  cin >> K; // X, Y, Zの最大値
  cin >> S; // 和
 
  // 全探索 計算量K^2
  for (int X = 0; X < K + 1; ++X) {
    for (int Y = 0; Y < K + 1; ++Y) {
      // 0 <= S - X - Y <= Kならカウンターを+1
      if (0 <= S - X - Y && S - X - Y <= K) ++count;
    }
  }
  // 出力
  cout << count << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> town(N);
  for (int i = 0; i < M; i++) {
    int j, k;
    cin >> j >> k;
    town[j - 1]++;
    town[k - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << town[i] << endl;
}

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

using namespace std;

int main()
{
    int N, m;
    
    scanf("%d %d", &N, &m);
    
    int s[1024] = {0};
    
    for (int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        s[a]++;
        s[b]--;
    }
    
    int ans = 0;
    for (int i = 0; i <= N;){
        if (s[i] == 0){
            ans++;
            i++;
        }
        else {
            int rui = 0;
            int tmp = 0;
            while (rui + s[i] != 0){
                rui += s[i];
                tmp++;
                i++;
            }
            i++;
            ans += 3 * tmp + 1;
        }
    }
    
    printf("%d\n", ans);
    
    return (0);
}

Measured memory_bytes: 1192
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if (n == 1){
      System.out.println("Hello World");
    }else{
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(a+b);
    }
  }
}


Measured memory_bytes: 35536
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll dp[100005][13];

int main(){
  string s;
  cin >> s;
  int n=s.length();
  dp[0][0]=1;
  rep(i, n){
    rep(j, 13){
      if(s[i]=='?'){
        rep(k, 10){
          dp[i+1][(j*10+k)%13]+=dp[i][j];
          dp[i+1][(j*10+k)%13]%=mod;
        }
      } else {
        int si=s[i]-'0';
        dp[i+1][(j*10+si)%13]+=dp[i][j];
        dp[i+1][(j*10+si)%13]%=mod;
      }
    }
  }
  cout << dp[n][5] << endl;
  return 0;
}


Measured memory_bytes: 13908
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((lli)(a));i<=((lli)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli n, a, b, c , d; cin >> n >> a >> b >> c >> d;
	lli m = b - a;
	n--;
	reg(k, 0, n) if(k*(c+d) - n*d <= m && m <= k*(c+d) - n*c){
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;


int main(){
  ll ans = 0;
  vector<ll> cp(3);
  rep(i,3) cin >> cp[i];
  ll cp3; cin >> cp3;
  cp[0] *= 4; cp[1] *= 2; 
  int N; cin >> N; 
  sort(all(cp));  

  if(cp[0]*2 <= cp3) ans = cp[0]*N;
  else if(N%2 == 0) ans = (N/2)*cp3;
  else ans = (N-1)/2*cp3 + cp[0];
         
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3592
local mfl = math.floor
local n, m = io.read("*n", "*n")
local imos = {}
for i = 1, m + 1 do
  imos[i] = 0
end
for i_n = 1, n do
  local l, r = io.read("*n", "*n")
  if l == r then
    local lim = math.ceil(math.sqrt(r))
    for i = 1, lim do
      if r % i == 0 then
        local z = mfl(r / i)
        if i <= z then
          imos[i] = imos[i] + 1
          imos[i + 1] = imos[i + 1] - 1
          if i ~= z then
            imos[z] = imos[z] + 1
            imos[z + 1] = imos[z + 1] - 1
          end
        end
      end
    end
  else
    l = l - 1
    imos[1] = imos[1] + 1
    imos[r + 1] = imos[r + 1] - 1
    for i = 1, r do
      local rlim2 = mfl(r / (i + 1))
      local llim = mfl(l / i)
      if rlim2 < llim then
        imos[rlim2 + 1] = imos[rlim2 + 1] - 1
        imos[llim + 1] = imos[llim + 1] + 1
      else
        if llim <=  r - l then
          break
        else
          for j = r - l + 1, llim do
            local ld, rd = mfl(l / j), mfl(r / j)
            if ld == rd then
              imos[j] = imos[j] - 1
              imos[j + 1] = imos[j + 1] + 1
            end
          end
          break
        end
      end
    end
  end
end
for i = 2, m do
  imos[i] = imos[i] + imos[i - 1]
end
imos[m + 1] = nil
print(table.concat(imos, "\n"))


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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> f(H);
    set<int> r,c;
    rep(i,H) {
        cin >> f.at(i);
        bool x = 1;
        rep(j,W)
            if(f.at(i).at(j) == '#')
                x = 0;
        if(x)
            c.insert(i);
    }
    
    rep(i,W) {
        bool x = 1;
        rep(j,H)
            if(f.at(j).at(i) == '#')
                x = 0;
        if(x)
            r.insert(i);
    }

    rep(i,H) {
        if(c.count(i))
            continue;
        rep(j,W)
            if(!r.count(j))
                cout << f.at(i).at(j);
        cout << endl;
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    vector<mint> cw(w);
    cw[0]=mint(1);
    mint y = mint(h-a-1);
    for(ll i=1;i<w;++i){
        cw[i] = cw[i-1]*(mint(i)+y)/(mint(i));
    }
    y = mint(a-1);
    vector<mint> ch(w-b);
    ch[0] = mint(1);
    for(ll i=1;i<w-b;++i){
        ch[i]=ch[i-1]*(mint(i)+y)/(mint(i));
    }
    mint ans = mint(0);
    REP(i,w-b){
        ans += cw[w-1-i]*ch[i];
    }
    cout << ans.x << endl;
    return 0;
}

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

int main(){

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if((0 <= x - r && x + r <= W) && (0 <= y - r && y + r <= H)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
	long long N,M; cin >> N >> M;
	vector<long long> P(M+10),Y(M+10);
	vector<vector<long long>> d(N+10);
	for(long long i=0; i<M; i++){
		cin >> P[i] >> Y[i];
		d[P[i]].push_back(Y[i]);
	}
	for(long long i=0; i<N; i++){
		sort(d[i+1].begin(),d[i+1].end());
	}
	for(long long i=0; i<M; i++){
		long long x=lower_bound(d[P[i]].begin(),d[P[i]].end(),Y[i])-d[P[i]].begin()+1;
		printf("%06lld%06lld\n",P[i],x);
	}
	return 0;
	}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if( H == 0 & W ==  0 ) break;
        for( int i = 0; i < H; i++){
            for( int j = 0; j < W; j++){
                if ( i == 0 || i == H-1 || j == 0 || j == W-1 ) 
                  cout<<"#";
                else 
                  cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3112
#include <vector>
#include <iostream>
using namespace std;
int n, m, dp[1122][189][15]; bool prime[1121]; vector<int> p;
int main() {
	for (int i = 2; i <= 1120; i++) prime[i] = true;
	for (int i = 2; i * i <= 1120; i++) {
		if (!prime[i]) continue;
		for (int j = i * i; j <= 1120; j += i) prime[j] = false;
	}
	for (int i = 2; i <= 1120; i++) {
		if (prime[i]) p.push_back(i);
	}
	while (cin >> n >> m, n + m) {
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= p.size(); j++) {
				for (int k = 0; k <= m; k++) dp[i][j][k] = 0;
			}
		}
		dp[0][0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= p.size() && i - p[j - 1] >= 0; j++) {
				for (int k = 1; k <= m; k++) {
					for (int l = 0; l < j; l++) dp[i][j][k] += dp[i - p[j - 1]][l][k - 1];
				}
			}
		}
		int ret = 0;
		for (int i = 1; i <= p.size(); i++) ret += dp[n][i][m];
		cout << ret << endl;
	}
}

Measured memory_bytes: 15472
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

constexpr int mod = 1000000007;

// modをとった積を返す
inline
int multiple(int a, int b){return (static_cast<long long>(a) * b) % mod;}

vector<int> prime_numbers = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};

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

    const int P = prime_numbers.size();
    vector<int> factors(P, 0);
    for (int i = 2; i <= N; ++i){
        int num = i;
        for (int p = 0; num >= prime_numbers[p] && p < P; ++p){
            auto& prime = prime_numbers[p];
            if (num % prime) continue;
            do {
                ++factors[p];
                num /= prime;
            } while (num % prime == 0);
        }
    }
    int result = 1;
    for (auto& elem : factors){
        if (elem >= 1) result = multiple(result, elem + 1);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    bool p=false;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(n==i*j){
                p=true;
                break;
            }
        }
    }
    if(p) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int p,q;
    p=n*(n-1)/2;
    q=m*(m-1)/2;
    cout<<p+q<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[4005];
struct Object {
  int r,g,b;
}cnt[4005];
int main() {
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) {
    cnt[i].r=cnt[i].g=cnt[i].b=0;
  }
  for(int i=1;i<=n;i++) {
    char x;
    cin>>x;
    if(x=='R') {
      a[i]=1;
    }
    if(x=='G') {
      a[i]=2;
    }
    if(x=='B') {
      a[i]=3;
    }
    for(int j=1;j<i;j++) {
      if(a[i]==1) {
        cnt[j].r++;          
      }
      if(a[i]==2) {
        cnt[j].g++;
      }
      if(a[i]==3) {
        cnt[j].b++;
      }
    }
  }
  long long x=0;
  for(int i=1;i<=n;i++) {
    for(int j=i+1;j<=n;j++) {
      int dis=j-i;
      int w=6-a[i]-a[j];
      if(w==a[i] || w==a[j] || a[i]==a[j]) {
      	continue;
	  }
      if(w==1) {
        if(dis+j<=n && a[dis+j]==1) {
        	x+=cnt[j].r-1;
      	}else {
        	x+=cnt[j].r;
      	}
      }
      if(w==2) {
        if(dis+j<=n && a[dis+j]==2) {
        	x+=cnt[j].g-1;
      	}else {
        	x+=cnt[j].g;
      	}
      }
      if(w==3) {
        if(dis+j<=n && a[dis+j]==3) {
        	x+=cnt[j].b-1;
      	}else {
        	x+=cnt[j].b;
      	}
      }
    }
  }
  cout<<x;
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
  #include<string>
  using namespace std;
  
  int main(){
    string s;
    cin >> s;
    auto count = 0;
    for(auto i = 0; i < s.size(); i++){
      if(s[i] == '1') count++;
    }
    cout << count << "\n";
    return 0;
  }

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
  int c;
  if (a < b) {
    a+=b;
    b=a-b;
    a-=b;
  }
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}


int main(){
  int n;
  scanf("%d", &n);
  int a[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  int ans = a[0];
  for(i=1;i<n;i++){
    ans = gcd(ans, a[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  tmp = input[1].split(" ");
  p = new Array(n).fill(0);
  for(i=0;i<n;i++){
    p[i]=parseInt(tmp[i]);
  }
  var ans=0;
  for(i=0;i<n;i++){
    if(p[i]==i+1&&i!=n-1){
      var x=p[i];
      p[i]=p[i+1];
      p[i+1]=x;
      ans++;
    }else if(p[i]==i+1){
      ans++;
    }
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, M;
    cin >> N >> M;

    if(N % 2 != 0 || N == 4) {
        // 真ん中から割って割り当てる
        int cur1 = N / 2;
        int cur2 = cur1 + 1;
        REP(i, M) {
            printf("%lld %lld\n", cur1, cur2);
            cur1--;
            cur2++;
        }
    }
    else {
        // 空ける間隔で偶奇に分けて詰めていく
        // 偶数(奇数)間隔から
        int lb = 1;
        int rb = lb + M;
        while(lb < rb) {
            printf("%lld %lld\n", lb, rb);
            lb++;
            rb--;
        }
        // 奇数(偶数)間隔
        lb = M + 2;
        rb = lb + M - 1;
        while(lb < rb) {
            printf("%lld %lld\n", lb, rb);
            lb++;
            rb--;
        }
    }

    return 0;
}


Measured memory_bytes: 3736
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        mp[as[i]]++;
    }

    if (mp.size() == 1)
    {
        cout << (mp[0] == n ? "Yes" : "No") << endl;
    }
    else if (mp.size() == 2)
    {
        int x = 0;
        for (auto &p : mp)
        {
            if (p.first)
                x = p.second;
        }
        cout << (2 * mp[0] == x ? "Yes" : "No") << endl;
    }
    else if (mp.size() == 3)
    {
        set<int> s;
        int x = 0;
        for (auto &p : mp)
        {
            s.insert(p.second);
            x ^= p.first;
        }
        cout << ((x == 0 && s.size() == 1) ? "Yes" : "No") << endl;
    }
    else
    {
        cout << "No\n";
    }
}

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


Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, K, ans = 0, R = 1, count;
	string S;
	cin >> N >> K >> S;
	count = (S[0] == '0');
	for (int L = 0; L < N; L++) {
		if (L != 0 && S[L] == '1' && S[L - 1] == '0') count--;
		while (R < N) {
			if (S[R] == S[R - 1] || S[R] == '1') R++;
			else if (count < K) count++, R++;
			else break;
		}
		ans = max(ans, R - L);
	}
	cout << ans;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

vector<pii> v;
set<pii> s;
int x[57],y[57];
int n;

int32_t main()
{
    IOS
    cin>>n;
    for (int i=1;i<=n;i++) cin>>x[i]>>y[i];
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
    {
        int xx=x[j]-x[i],yy=y[j]-y[i];
        if (xx==0&&yy<=0) yy=-yy;
        else if (xx<0) xx=-xx,yy=-yy;
        s.insert(mkp(xx,yy));
        v.pb(mkp(xx,yy));
    }
    sort(all(v));
    int ans=0;
    for (pii i:s)
    {
        int tmp=upper_bound(all(v),i)-lower_bound(all(v),i);
        ans=max(ans,tmp);
    }
    cout<<n-ans<<endl;
}



Measured memory_bytes: 384
#![allow(unused_imports)]
#![allow(dead_code)]

use itertools::Itertools;
use num::Integer;
use num::PrimInt;
use proconio::input;
use std::collections::*;

fn main() {
    input! {
        d:usize,
        c:[i32;26],
        s:[[i32;26];d],
    }
    let mut last = vec![0; 26];
    let ans: Vec<usize> = (0..d)
        .map(|i| {
            let choice = (0..26)
                .max_by_key(|&x| {
                    let happiness: i32 = (0..26)
                        .map(|y| {
                            if y == x {
                                s[i][y]
                            } else {
                                -c[y] * (i as i32 - last[y])
                            }
                        })
                        .sum();
                    happiness
                })
                .unwrap();
            last[choice] = i as i32;
            choice
        })
        .collect();
    for c in ans {
        println!("{}", c + 1);
    }
}

Measured memory_bytes: 2284
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#define ll long long
#define dd double
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	string s;
	ll n, m;
	cin >> n >> m;
	cin >> s;
	s[m - 1] = s[m - 1] + 32;
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
const int maxn=5e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}

int t,n,m,k;
int main(){
    scanf("%d",&n);
    if(n%10==7||(n/10%10==7)||(n/100%10==7)) puts("Yes");
    else puts("No");

    return 0;
}




//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


Measured memory_bytes: 3656
import sys

def win(A, c):
    if A[1] == A[2] == A[3] == c or A[4] == A[5] == A[6] == c or A[7] == A[8] == A[9] == c:
        return True
    elif A[1] == A[4] == A[7] == c or A[2] == A[5] == A[8] == c or A[3] == A[6] == A[9] == c:
        return True
    elif A[1] == A[5] == A[9] == c or A[3] == A[5] == A[7] == c:
        return True
    else:
        return False

for line in sys.stdin:
    A = ['d']
    for c in line:
        A.append(c)
    if win(A, 'o'):
        print 'o'
    elif win(A, 'x'):
        print 'x'
    else:
        print 'd'

Measured memory_bytes: 6260
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

string s[200000];
int dp[200000][2];
int main(){
	int n;cin>>n;
	int ans=0;
	int c1=0,c2=0,c3=0;
	rep(i,n){
		cin>>s[i];
		for(int j=0;j+1<s[i].size();j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B')ans++;
		}
		if(s[i].front()=='B'&&s[i].back()=='A')c3++;
		else if(s[i].front()=='B')c2++;
		else if(s[i].back()=='A')c1++;
	}
	ans+=min(c1,c2);
	ans+=max(0,c3-1);
	if(c3&&(c1||c2))ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    double ans = 0;
    rep(i, 0, n)
    {
        string tmp, x;
        cin >> tmp >> x;
        if (x == "JPY")
            ans += stod(tmp);
        else
            ans += stod(tmp) * 380000;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3784
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int k = cin.Int();
			int r = cin.Int();
			int s = cin.Int();
			int p = cin.Int();
			string t = cin.Next();

			char[] gg = new char[n];
			long ans = 0;
			for (int i = 0; i < n; i++) {
				if (i < k) {
					if (t[i] == 'r') {
						ans += p;
						gg[i] = 'p';
					} else if (t[i] == 's') {
						ans += r;
						gg[i] = 'r';
					} else {
						ans += s;
						gg[i] = 's';
					}
				} else {
					if (t[i] == 'r') {
						if (gg[i - k] == 'p') {
							if (i + k >= n) {
								gg[i] = 'r';
							} else {
								gg[i] = t[i + k];
							}
						} else {
							ans += p;
							gg[i] = 'p';
						}
					} else if (t[i] == 's') {
						if (gg[i - k] == 'r') {
							if (i + k >= n) {
								gg[i] = 's';
							} else {
								gg[i] = t[i + k];
							}
						} else {
							ans += r;
							gg[i] = 'r';
						}
					} else {
						if (gg[i - k] == 's') {
							if (i + k >= n) {
								gg[i] = 'p';
							} else {
								gg[i] = t[i + k];
							}
						} else {
							ans += s;
							gg[i] = 's';
						}
					}
				}
			}

			Console.WriteLine(ans);
		}

	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11872
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

typedef vector<vector <int>> Graph;

//単一点最短経路問題 + 最短経路(を3で割り切れる値しかみなさない)
//閉路ありので注意する

Graph G;


ll solve() {
    int N,M;
    cin >> N >> M;
    G.assign(N, vector<int>());

    for(int i = 0; i < M; ++i)
    {
        int u,v;
        cin >> u >> v;
        --u;--v;
        G[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    --s;--t;
    
    //sからの最短経路
    vector <vector<int> > dist(N, vector<int>(3, -1));

    dist[s][0] = 0;
    int parity = 0;


    queue <pair<int,int>> que;
    que.push({s, parity});

    while(!que.empty())
    {
        auto cur_p = que.front();
        que.pop();
        parity = cur_p.second;
        for(auto np: G[cur_p.first])
        {
            int pa = (parity + 1) % 3;
            if(dist[np][pa] == -1)
            {
                dist[np][pa] = dist[cur_p.first][parity] + 1;
                que.push({np, pa});
            }
        }
    }


    ll res = dist[t][0] / 3;
    if(dist[t][0] == -1)res = -1;

    return res;
}

int main()
{
    cout << solve() << endl;
}


Measured memory_bytes: 11136
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,c,d;
    cin >> a >> b >> c >>d ;
    cout << max(a*b,c*d)<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    const Args = args[0].split(' ')
    const N = parseInt(Args[0], 10)
    const M = parseInt(Args[1], 10)

    var ans = [];
    var temp_ans = [];
    for(var i = 1; i <= M; i++) {
        ans.push(i);
    }

    for(var i = 1; i <= N; i++) {
        anketo = args[i].split(' ').map(Number);
        anketo.shift();
        temp_ans = isLike(ans, anketo);
        ans = temp_ans.slice();
    }
    console.log(ans.length)

}

const isLike = (arrayA, arrayB) => {
    var sukisukidaisuki = []
    arrayA.concat(arrayB).forEach(element => {
        if (arrayA.indexOf(element) !== -1 && arrayB.indexOf(element) !== -1) {
            if(sukisukidaisuki.indexOf(element) === -1) {
                sukisukidaisuki.push(element);
            }
        }
    })

    return sukisukidaisuki;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

int bit[200001];
int n;
int sum(int a){
  int ret = 0;
  for(int x = a; x > 0; x -= x & -x){
    ret += bit[x];
  }
  return ret;
}
void add(int a, int w){
  for(int x = a; x <= n; x += x & -x){
    bit[x] += w;
  }
}

int main(){

  int a;
  cin >> n;
  vector<p> v;
  for(int i = 0; i < n; i++){
    cin >> a;
    v.push_back(p(a, i+1));
  }
  memset(bit, 0, sizeof(bit));
  sort(v.begin(), v.end());
  long long cnt = 0;
  for(int i = 0; i < n; i++){
    cnt += i - sum(v[i].second);
    add(v[i].second, 1);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 5364
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			final int n = Integer.parseInt(reader.readLine());
			final int[] list = new int[n];
			for (int i = 0; i < n; i++) {
				list[i] = Integer.parseInt(reader.readLine());
			}
			reader.close();
			
			System.out.println(String.valueOf(countPrime(list)));
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public static int countPrime(final int[] list) {
		int count = 0;
		
		for (int num : list) {
			if (isPrime(num)) count++;
		}
		return count;
	}
	
	public static boolean isPrime(final int num) {
		boolean isPrime;
		
		if (num < 2) {
			isPrime = false;
			
		} else if (num == 2) {
			isPrime = true;
			
		} else if (num % 2 == 0) { 
			isPrime = false;
			
		} else {
			isPrime = true;
			
			final int end = (int)Math.pow(num, 0.5);
			for (int i = 3; i <= end; i += 2) {
				if (num % i == 0) {
					isPrime = false;
					break;
				}
			}
		}
		return isPrime;
	}
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << "\n";
        return 0;
    }
    long long ans = (h / 2) * w;
    ans += (h % 2) * (w + 1) / 2;
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >>N;
  vector<int> V(N);
  vector<int> C(N);
  rep(i, N) cin >> V[i];
  rep(i, N) cin >> C[i];
  vector<int> vec(N);
  int sum = 0;
  rep(i, N) {
    vec[i] = V[i]-C[i];
    if (vec[i] > 0) sum += vec[i];
  }

  cout << sum << endl;
  
  
  return 0;
}


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

using namespace std;

#define lld long long int
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);	cout.tie(0);

/* 											CODE:-									*/
														


void IMPLEMENT_CODE(){
	
	char s[3001], t[3001];
	cin>>s>>t;

	int l1 = strlen(s);
	int l2 = strlen(t);

	int dp[l1+1][l2+1];

	int l = 0;

	for(int i=0; i<=l1; i++){
		for(int j=0; j<=l2; j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s[i-1] == t[j-1])
				dp[i][j] = dp[i-1][j-1] + 1;
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	l = dp[l1][l2];
	//cout<<l<<endl;

	char ans[l];
	ans[l] = '\0';
	int i=l1, j=l2;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans[--l] = s[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j] > dp[i][j-1])
			i--;
		else
			j--;
	}
	cout<<ans<<endl;
}



int main(){
	
	FASTIO;

	IMPLEMENT_CODE();

	return 0;

}


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

#define sq(x) ((x)*(x))

int main() {
  
  int n;
  while(cin >> n && (n != -1)) {
    long double xl = 1.0, r, x, y;
    long double th = 0.0;
    n--;
    while(n--) {
      r = sqrt(sq(xl)+1);
      th += acos(xl/r);
      x = r*cos(th), y = r*sin(th);
      xl = r;
    }
    
    
    printf("%Lf\n%Lf\n", x, y);
  }
  
  return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

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

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

    string s;
    std::cin >> s;

    pair<int, int> ans(-1, -1);
    if(s.size() == 2 && s[0] == s[1]) {
        ans = make_pair(1, 2);
    }
    else {
        REP(i, s.size() - 2) {
            if(s[i] == s[i + 1] ||
               s[i + 1] == s[i + 2] ||
               s[i] == s[i + 2]) {
                ans = make_pair(i + 1, i + 3);
                break;
            }
        }
    }

    std::cout << ans.first
              << " "
              << ans.second
              << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    string s,t;
    cin>>s>>t;
    t+=s;
    cout<<t<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;
int x;

int main(){
  cin >> N;
  cin >> x;
  if(x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  if(x < N) {
    for(int i = 2; i < N; i++) {
      if(i == x) continue;
      cout << i << endl;
    }
    cout << N << endl;
    cout << x << endl;
    cout << 1 << endl;
    for(int i = N + 1; i < 2 * N; i++){
      cout << i << endl;
    }
  } else {
    for(int i = 1; i < N - 1; i++) {
      cout << i << endl;
    }
    cout << 2 * N - 1 << endl;
    cout << x << endl;
    cout << N - 1 << endl;
    for(int i = N; i < 2 * N - 1 ; i++) {
      if(i == x) continue;
      cout << i << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1536
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
using namespace std;

int main() {
  /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
  string num;
  cin >> num;

  if (num.find("7") != string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}




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

int main()
{
      int A,B;
      cin>>A;
      cin>>B;    
       
	  if(A%3==0)
       {
                cout<<"Possible";
                 return 0;
       }
       else if(B%3==0)
       {
                cout<<"Possible";
                 return 0;
        }
        else if((A+B)%3==0)
       {
                 cout<<"Possible";
                 return 0;
        }
      
       cout<<"Impossible";
       return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a%2 == 0 || b%2 == 0) {
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#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>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
typedef long long ll;
using namespace std;

int main() {
	string s; cin >> s;
	cout << s[0] << (s.size() - 2) << s[s.size() - 1] << endl;
}	


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;


int n, q;
vector<int> to[200005];
int sum[200005];
LL ans[200005];
LL add = 0;


void dfs(int curr, int from=-1) {
    add += sum[curr];
    ans[curr] = add;
    for (auto next: to[curr]) {
        if (next != from) {
            dfs(next, curr);
        }
    }
    add -= sum[curr];
}


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

    cin >> n >> q;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        sum[p] += x;
    }
    dfs(1);

    for (int i = 1; i <= n; ++i) cout << ans[i] << ' ';
    cout << endl;

    return 0;
}


Measured memory_bytes: 29308
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

ll ans = 0;
P calc(int i) {
  int a = i % 10;
  int b=0;
  while (0<i) {
    b = i;
    i /= 10;
  }
  return P(a, b);
}
int main() {
  ll N;
  cin >> N;
  map<P, int> A;
  for (int i=1; i <= N; i++) {
    A[calc(i)]++;
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    P a = calc(i);
    P b(a.second, a.first);
    ans += A[b];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636