akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
signed main(){
	string s;
	cin>>s;
	int a,c=0;
	cin>>a;
	f(i,26){
		vector<int> v={};
		int b=0;
		f(j,s.size()){
			if(s[j]=='a'+i)v.push_back(j);
		}
		if(v.size()-b){
			b=v.size();
			c++;
			if(a==c) cout<<s[v[0]]<<endl;
			f(j,26){
				f(k,b){
					if(v[k]<s.size()-1&&s[v[k]+1]=='a'+j)v.push_back(v[k]+1);
				}
				if(v.size()-b){
					v.erase(v.begin(),v.begin()+b);
					b=v.size();
					c++;
					if(a==c) cout<<s.substr(v[0]-1,2)<<endl;
					f(k,26){
						f(l,b){
							if(v[l]<s.size()-1&&s[v[l]+1]=='a'+k)v.push_back(v[l]+1);
						}
						if(v.size()-b){
							v.erase(v.begin(),v.begin()+b);
							b=v.size();
							c++;
							if(a==c)cout<<s.substr(v[0]-2,3)<<endl;
							f(l,26){
								f(d,b){
									if(v[d]<s.size()-1&&s[v[d]+1]=='a'+l)v.push_back(v[d]+1);
								}
								if(v.size()-b){
									v.erase(v.begin(),v.begin()+b);
									b=v.size();
									c++;
									if(a==c)cout<<s.substr(v[0]-3,4)<<endl;
									f(d,26){
										f(e,b){
											if(v[e]<s.size()-1&&s[v[e]+1]=='a'+d)v.push_back(v[e]+1);
										}
										if(v.size()-b){
											v.erase(v.begin(),v.begin()+b);
											b=v.size();
											c++;
											if(a==c)cout<<s.substr(v[0]-4,5)<<endl;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int p[500][500], r[500][500], b[500][500];

int main() {
    int h, w;
    cin >> h >> w;
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            p[i][j] = (s[j] == '#');
            r[i][j] = p[i][j];
            b[i][j] = p[i][j];
        }
    }

    REP(i,h){
        if (i%2 == 1)
            FOR(j,1,w-2) b[i][j] = 1;
        else
            FOR(j,1,w-2) r[i][j] = 1;
    }
    REP(i,h){
        r[i][0] = 1;
        b[i][w-1] = 1;
    }

    map<int, char> m;
    m[0] = '.';
    m[1] = '#';
    REP(i,h){
        REP(j,w){
            cout << m[r[i][j]];
        }
        cout << endl;
    }
    cout << endl;
    REP(i,h){
        REP(j,w){
            cout << m[b[i][j]];
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 3712
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

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

	public static void solve() {
  		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		
		out.println((a <= c && c <= b) ? "Yes" : "No");
		out.flush();
	}

	static class Pair{
		int a,b;
		public Pair(int a, int b){
			this.a = a;
			this.b = b;
		}
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int i, a, b;

int main() {
    while (1) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;
        if (a > b) {
            a ^= b, b ^= a, a ^= b;
        }
        printf("%d %d\n", a, b);
    }
}


Measured memory_bytes: 1988
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * (n[0]+1)
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)


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

  char a,b;
  cin >> a >> b;
  if (a == 'H'){
   if (b == 'H'){
  cout << "H" << endl;
  }
   else{
  cout << "D" << endl;
  }
  }
  else{
     if (b == 'H'){
  cout << "D" << endl;
  }
   else{
  cout << "H" << endl;
  }
  }

return 0;
}

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

int main() {
	int a, b, c, n;
	cin >> a >> b >> c >> n;
	int cnt = 0;
	for(int i = 0; i * a <= n; ++ i) for(int j = 0; j * b <= n - i * a; ++ j) {
		int l = n - i * a - j * b;
		if(l % c == 0) ++ cnt;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String str = scanner.next();
        int min = 300000;
        int[] integer1 = new int[n+1];
        int[] integer2 = new int[n+1];
        integer1[0]=0;
        integer2[0]=0;
        for (int i=0;i<n;i++){
            if (str.charAt(i)=='W'){
                integer1[i+1]=integer1[i]+1;
                integer2[i+1]=integer2[i];
            }else {
                integer2[i+1]=integer2[i]+1;
                integer1[i+1]=integer1[i];
            }
        }
        for (int i=0;i<n;i++){
            min = Math.min(min,integer1[i]-integer1[0]+integer2[n]-integer2[i+1]);
        }
        System.out.println(min);
    }
}


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
ll mods = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    //print(fixed << setprecision(10));
    
    ll a,b,c,k;
    cin >> a >> b >> c >> k;

    if(a>=k) print(k);
    else if(a+b>=k) print(a);
    else print(a-(k-a-b));

    return 0;
}

Measured memory_bytes: 3652
import sys

n, q = map(int, sys.stdin.readline().split())
s = sys.stdin.readline()

mlist = [0] * q
for i in range(q):
    mlist[i] = list([int(i) for i in sys.stdin.readline().split()])

elist = [0] * (n+1)

for i in range(n - 1):
    tmp = s[i:i+2]
    if 'AC' in tmp:
        elist[i + 2] = elist[i+1] + 1
    else:
        elist[i + 2] = elist[i+1]

for i in range(q):
    l, r = mlist[i]
    print(elist[r] - elist[l])


Measured memory_bytes: 24420
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long long mod =1e9+7;


int main(){
  int ans=0,num;
  
  cin >> num;
  ans = sqrt(num);
  cout << ans*ans << endl;

    return 0;
}
 

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

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define mod 998244353
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
const ll sz = 2e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

void solve(){
    string s;
    cin >> s;
    if(s[0] - '0' == 1 && s[1] - '0' < 3 or (s[0] == '0' && s[1] != '0')){
        if(s[2] - '0' == 1 && s[3] - '0' < 3 or (s[2] == '0' && s[3] != '0')){
            cout << "AMBIGUOUS\n";
        }
        else cout << "MMYY\n";
    }
    else if(s[2] - '0' == 1 && s[3] - '0' < 3 or (s[2] == '0' && s[3] != '0')){
        if(s[0] - '0' == 1 && s[1] - '0' < 3 or (s[0] == '0' && s[1] != '0')){
            cout << "AMBIGUOUS\n";
        }
        else cout << "YYMM\n";
    }
    else cout << "NA\n";


    return;
}

int main(){
    FIO;
    int t = 1;
    while(t--){
        solve();
    }
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL K;
  cin >> K;

  vector<vector<PII>> G(K);
  REP(i,K) G[i].EB((i+1)%K, 1);
  REP(i,K) G[i].EB(i*10%K, 0);

  VI dist(K, 1e9);
  deque<int> dq;
  dq.push_back(1);
  dist[1] = 1;
  while(!dq.empty()){
	int u = dq.front();
	dq.pop_front();
	for(auto& e: G[u]){
	  if(dist[e.FF] <= e.SS + dist[u]) continue;
	  else if(e.SS == 0){
		dist[e.FF] = dist[u];
		dq.push_front(e.FF);
	  }
	  else{
		dist[e.FF] = dist[u] + 1;
		dq.push_back(e.FF);
	  }
	}
  }
  cout << dist[0] << endl;
  
  return 0;
}


Measured memory_bytes: 6272
#include <vector>
#include <algorithm>
#include <iostream>

int SelectionSort( std::vector<int>& data )
{
  int cnt = 0;

  for( auto it = data.begin(); it != data.end(); ++it ) {
    auto mini_it = std::min_element(it, data.end());
    if ( it != mini_it ) {
      cnt++;
      std::swap(*it, *mini_it);
    }
  }

  return cnt;
}

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> data(N);

  for(int i = 0; i < data.size(); ++i)
    std::cin >> data.at(i);

  int num = SelectionSort(data);

  std::cout << data.at(0);
  for(int i = 1; i < data.size(); ++i)
    std::cout << " " << data.at(i);
  std::cout << std::endl;

  std::cout << num << std::endl;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll ans = -INF;
    chmax(ans, a*c);
    chmax(ans, a*d);
    chmax(ans, b*c);
    chmax(ans, b*d);

    cout << ans << endl;
    


    return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 1000000000 + 7;

int N, M;
int S[2010];
int T[2010];

int dp[2010][2010][2];
int rec(int a, int b, int c){
    if(dp[a][b][c] >= 0) return dp[a][b][c];
    ll res = 0;
    if(a == N){
        if(c == 0) res++;
    }
    else if(c == 0){
        // ここで取るかどうか決める
        (res += rec(a, b, 1)) %= mod;
        (res += rec(a + 1, b, 0)) %= mod;
    }
    else if(c == 1){
        if(b == M){
            res = 0;
        }
        else{
            // bを進めるか、取るかで場合分け
            (res += rec(a, b + 1, c)) %= mod;
            if(S[a] == T[b])
                (res += rec(a + 1, b + 1, 0)) %= mod;
        }
    }
    return dp[a][b][c] = res % mod;
}


int main(){

    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> S[i];
    for(int i = 0; i < M; i++) cin >> T[i];
    memset(dp, -1, sizeof(dp));
    cout << rec(0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 32128
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    int c = 0;
    int s; s = N;
    while(N!=0)
    {
        N/=10;
        c++;
    }
    N = s;
    if(c == 5 )
    {
        N-=9999;
        N+=909;
    }
    if(c == 6)
    {
        printf("90909\n"); return 0;
    }
    if(c == 4)
    {
        printf("909\n"); return 0;
    }
    if(c == 3)
    {
        N-=90;
    }
    if(c == 2)
    {
        printf("9\n"); return 0;
    }
    printf("%d\n",N);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
    int dpX[4001][16010] = {};
    int dpY[4001][16010] = {};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    S.push_back('T');
    int x, y;
    cin >> x >> y;
    int firstx = 0;
    vector<int> numX;
    vector<int> numY;
    int cntF = 0;
    int cntT = 0;
    rep(i, S.length()) {
        if (S[i] == 'F') cntF++;
        if (S[i] == 'T') { 
            if (cntF == 0) {
                // 何も行わない
            } else if (cntT == 0) {
                firstx = cntF;
            } else if (cntT % 2 == 0) {
                numX.push_back(cntF);
            } else {
                numY.push_back(cntF);
            }
            cntF = 0;
            cntT++;
        }
    }
    //int dpX[numX.size()+1][9010] = {};
    //int dpY[numY.size()+1][9010] = {};
    dpX[0][8005+firstx] = 1; 
    dpY[0][8005] = 1;
    for (int i = 1; i <= numX.size(); i++) {
        for(int j = 8001; j >= -8001; j--) {
            if(dpX[i-1][j+8005] == 1) {
                //printf("numX[%d] = %d\n",i, numX[i]);
                //printf("dpX[%d][%d] = 1\n", i, j+4005+numX[i-1]);
                //printf("dpX[%d][%d] = 1\n", i, j+4005-numX[i-1]);
                dpX[i][j+8005+numX[i-1]] = 1;
                dpX[i][j+8005-numX[i-1]] = 1;
            } 
        }
    }
    for (int i = 1; i <= numY.size(); i++) {
        for(int j = 8001; j >= -8001; j--) {
            if(dpY[i-1][j+8005] == 1) {
                dpY[i][j+8005+numY[i-1]] = 1;
                dpY[i][j+8005-numY[i-1]] = 1;
            }
        }
    }
    //dump(numX.size());
    //dump(dpX[1][4003]);
    if (dpX[numX.size()][x+8005] && dpY[numY.size()][y+8005]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    /*
    cout << "X0:" << firstx << endl;
    rep(i, numX.size()) {
        cout << "X" << i+1 << ":" <<numX[i] << endl;
    }


    rep(i, numY.size()) {
        cout << "Y" << i << ":" <<numY[i] << endl;
    }
    //*/


    return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

const int MAX_N = 200000;

int N, K, A[100][MAX_N + 1];

int main() {
    cin >> N >> K;
    K = min(K, 99);
    REP(i, N) cin >> A[0][i];
    REP(i, K) {
        REP(j, N) {
            int l = max(0, j - A[i][j]);
            int r = min(N, j + A[i][j] + 1);
            A[i+1][l]++;
            A[i+1][r]--;
        }
        FOR(j, 1, N) {
            A[i+1][j] += A[i+1][j-1];
        } 
    }
    REP(i, N) {
        printf("%d", A[K][i]);
        if (i == N-1) printf("\n");
        else printf(" ");
    }
    return 0;
}

Measured memory_bytes: 81776
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 998244353;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}

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

    init();

    ll n, a, b, k;
    cin>>n>>a>>b>>k;
    ll ans = 0;
    for (ll i = 0; i<=n; i++) if ((i * a<=k) && ((k - i*a)%b == 0) && ((k-i*a)/b<=n))
    {
        ans = add(ans, mul(C(n, i), C(n, (k-i*a)/b)));
    }
    cout<<ans;

}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    vector<int> a(4);
    rep(i,4)cin >> a[i];
    sort(all(a));
    if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int color;
  if(a==b){
    if(a==c){
      color=1;
    }else{
      color=2;
    }
  }else{
    if(a==c){
      color=2;
    }else{
      if(b==c){
        color=2;
      }else{
        color=3;
      }
    }
  }
  cout << color << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    int d, a;
    rep(i,k){
        cin >> d;
        rep(j,d){
            cin >> a;
            a--;
            vec.at(a)++;
        }
    }
    
    int cnt = 0;
    rep(i,vec.size()){
        if(vec.at(i) == 0) cnt++;
    }
    dunk(cnt);
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
using namespace std;

int		main(void)
{
	int n, x;

	cin >> n >> x;
	vector<int> d(n);

	for (int i = 0; i < n; i++)
		cin >> d[i];
	int sum = 0;

	for (int i = 0; i < n; i++)
		sum += d[i];
	sort(all(d));
	cout << (n + (x - sum) / d[0]) << endl;
}


Measured memory_bytes: 256
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i] == False:
            continue
            
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
            
    return [i for i in range(n+1) if is_prime[i]]

while True:
    try:
        n = int(input())
        print(len(primes(n)))
    except:
        break


Measured memory_bytes: 16816
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int x, y;

void input() {
  cin >> x >> y;
}

void solve() {
  cout << x + (y/2) << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


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

int main() {
	long long N, X, M;
	cin >> N >> X >> M;
	
	
	long long A[100001];
	
	long long sum = X;
	long long Ai = X, Ai1;
	A[1] = X;
	
	for(long long i = 1; i < N; i++) {
		Ai1 = (Ai * Ai) % M;
		//cout << Ai1;

		Ai = Ai1;
		A[i + 1] = Ai1;
		for(int j = 1; j <= i; j++) {
			if(A[j] == Ai1) {
				// 区間を求める
				long long start = j;
				long long end   = i;
				long long period = i - j + 1;
				
				// 残り区間長さ
				long long sur = (N - i - 1) % period;
				long long div = (N - i - 1) / period;
				
				long long ssum = 0;
				long long ssum2 = 0;
				for(int k = start; k <= end; k++) {
					ssum += A[k];
				}
				for(int k = start; k <= start + sur; k++) {
					ssum2 += A[k];
				}
				// sum肉緩和を加算
				sum += ssum * div;
				sum += ssum2;
				// 端数処理
				//i = N - sur;
				cout << sum << endl;
				return 0;
			}
		}
				sum += Ai1;
	}
	
	cout << sum << endl;
	
	return 0;
}

//1000000000000001

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,w;
    cin>>n>>w;
    long long W[n+1],V[n+1], dp[w+1]={0};

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

    for(int i=1; i <= n; i++)
        for(int j=w; j>=W[i]; j--)
            dp[j] = max(dp[j], V[i] + dp[j-W[i]]);
    cout<<dp[w]<<'\n';
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#import <atcoder/all>
using namespace std;
int T, n, m, a, b;
class FastIO
{
    static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
    char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
    char tmp_s[20];

public:
    FastIO()
    {
        fread(rdata, 1, rdata_sz, stdin);
        rb = rdata;
        wb = wdata;
    }
    ~FastIO()
    {
        fwrite(wdata, 1, wb - wdata, stdout);
    }

    template <typename T>
    inline void read(T &x)
    {
        bool neg = false;
        x = 0;
        while ((*rb < '0' || *rb > '9') && *rb != '-')
            ++rb;
        if (*rb == '-')
        {
            neg = true;
            ++rb;
        }
        while ('0' <= *rb && *rb <= '9')
        {
            x = 10 * x + (*rb - '0');
            ++rb;
        }
        if (neg)
            x = -x;
    }

#define pc(x) *(wb++) = x
    template <typename T>
    inline void write(T x)
    {
        if (x == 0)
        {
            pc('0');
            pc('\n');
            return;
        }
        if (x < 0)
        {
            pc('-');
            x = -x;
        }
        char *t = tmp_s;
        while (x)
        {
            T y = x / 10;
            *(t++) = (x - y * 10) + '0';
            x = y;
        }
        while (t != tmp_s)
            pc(*(--t));
        pc('\n');
    }
#undef pc
};
int main()
{
    FastIO io;
    io.read(T);
    for (int i = 0; i < T; i++)
    {
        io.read(n);
        io.read(m);
        io.read(a);
        io.read(b);
        io.write(atcoder::floor_sum(n, m, a, b));
    }
}

Measured memory_bytes: 7372
n = int(input())
a = list(map(int, input().split()))
 
ans = 1
u = False
d = False
for i in range(1, n):
    if u:
        if a[i] < a[i - 1]:
            u = False
            ans += 1
    elif d:
        if a[i] > a[i - 1]:
            d = False
            ans += 1
    else:
        if a[i] > a[i - 1]:
            u = True
        elif a[i] < a[i - 1]:
            d = True
print(ans)

Measured memory_bytes: 20208
#include <stdio.h>

void pv(double ax, double ay, double bx, double by, 
        double px, double py, double ans[]);

int main(void)
{
    double ax, ay, bx, by;
    int n, i;
    double tmpx, tmpy;
    double ans[2];

    scanf("%lf%lf%lf%lf%d", &ax, &ay, &bx, &by, &n);

    for (i = 0; i < n; i++) {
        scanf("%lf%lf", &tmpx, &tmpy);
        pv(ax, ay, bx, by, tmpx, tmpy, ans);
        printf("%.10lf %.10lf\n", ans[0], ans[1]);
    }
    return 0;
}

void pv(double ax, double ay, double bx, double by, 
        double px, double py, double ans[]) {
    //*find the projection point ans of p onto a,b *//
    double x1 = bx-ax, x2 = px-ax, y1 = by-ay, y2 = py-ay;
    ans[0] = 1.0 * (x1*x2+y1*y2)/(x1*x1+y1*y1)*x1 + ax;
    ans[1] = 1.0 * (x1*x2+y1*y2)/(x1*x1+y1*y1)*y1 + ay;
}

Measured memory_bytes: 664
// comment
// 처음 행동 기준으로 x+1 x x-1 가 됐다면 x 의 위치가 바뀌지않고, x+1 는 절대 x 를 넘지 못함.
// 작은 문제로 나누기. 위 성질을 이용해서 왼쪽으로 간 애들끼리 순서 유지, 오른쪽으로 간 애들끼리 순서 유지 성질 찾아야했음.

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e5 + 100;

int N, Nr[MAX_N];
int Cnt[MAX_N];
bool isCanInterval(int s, int e) {
	for(int i=s; i<=e; i++) Cnt[Nr[i]]++;
	bool isAllOne = true;
	for(int i=s; i<=e; i++) if(Cnt[i] != 1) isAllOne = false;
	if(not isAllOne) return false;
	vector<int> list[2];
	for(int i=s; i<=e; i+=2) {
		if(Nr[i] < i) list[0].push_back(Nr[i]);
		else list[1].push_back(Nr[i]);
	}
	bool isIncrease = true;
	for(int k=0; k<2; k++) {
		for(int i=0; i+1<SZ(list[k]); i++) {
			isIncrease &= (list[k][i] < list[k][i+1]);
		}
	}
	return isIncrease;
}
bool isCan() {
	for(int s=1, e=1; s<=N; s=e+1) {
		if (Nr[s] == s) {
			e=s;
			continue;
		}
		e=s;
		while(e+2 <= N && Nr[e+1] == e+1 && Nr[e+2] != e+2) e+=2;
		if(e == s) return false;
		if(not isCanInterval(s, e)) return false;
	}
	return true;
}

int main() {
	cin >> N;
	for(int i=1; i<=N; i++) scanf("%d", &Nr[i]);

	if(isCan()) puts("Yes"); else puts("No");
	return 0;
}


Measured memory_bytes: 6752
N = int(input())
Vlist = list(map(int, input().split()))
Clist = list(map(int, input().split()))
V_Clist = [Vlist[i] - Clist[i] for i in range(N)]
ret = 0
for vc in V_Clist:
    if vc > 0:
        ret += vc
print(ret)

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

int main() {

  int count=0;
  string S; cin>>S;

  if(S=="SUN"){count=7;}
  else if (S=="MON"){count =6;}
  else if(S== "TUE"){count = 5;}
  else if (S=="WED"){count =4;}
    else if (S=="THU"){count =3;}
    else if (S=="FRI"){count =2;}
    else if (S=="SAT"){count =1;}
  
	cout<<count<<endl;
}


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

int main(void)
{
    long N;
    cin >> N;
    long long x=1;
    int c=1;
    long long N_=N;
    while (true)
    {
        if (N_-x*26<=0){
            break;
        }
        x*=26;
        c++;
        N_-=x;
    }
    string S;
    N=N_-1;
    while (c>0)
    {
        int a=N%26;
        S=(char)('a'+a)+S;
        N/=26;
        c--;
    }
    cout << S << endl;
}

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

int main()
{
	long long n;
	cin >> n;
  
  long long ans=0;
	if (n%2==0) {
		n/=2;
		while (n!=0) {
			ans+=n/5;
			n/=5;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 9212
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=2005;
int a[N];
int main()
{
	int n=ri(),z=ri(),w=ri(),i;
	for(i=1;i<=n;i++)	a[i]=ri();
	wi(max(abs(w-a[n]),n>=2?abs(a[n]-a[n-1]):-1));
	return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    int robota = 0;
    int robotb = k;
    int counter = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (((x - robota) * 2) > ((k - x) * 2))
        {
            counter += ((k - x) * 2);
        }
        else
        {
            counter += ((x - robota) * 2);
        }
    }
    cout << counter;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include<vector>
#include<string.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int n,r;
    while(cin>>n>>r,n,r){;
        int card[60];
        for(int i=0;i<60;i++){
            card[i]=n-i;
        }
        for(int i=0;i<r;i++){
            int p,c;
            cin>>p>>c;
            vector<int>C;
            for(int j=0;j<c;j++){
                C.push_back(card[p-1+j]);
            }
            int j;
            for(j=c+p-2;j>=c-1;j--){
                card[j]=card[j-c];
            }
            for(int k=0;k<c;k++){
                card[k]=C[k];
            }
        }
        cout<<card[0]<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int ans=0,n,k;
	cin>>n>>k;
	n-=2;
	if(n>=11)
	{
		ans+=n/11*5;
		n%=11;
	}
	for(int i=1;i<=5;i++)
		for(int j=1;j<=n;j++)
			if((63*j+9*i+9)%11==k)ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
string S;
  cin >>S;
int size=S.size();
  int sum=0;
  int M=0;
  
  for(int i=0;i<size;i++){
	if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='C'||S.at(i)=='G'){
  		sum+=1;
}
    else{
      if(M<sum){
        M=sum;
        sum=0;
      }
  }
  } 
 cout<<max(M,sum)<<endl; 
}


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

using namespace std;
int main(){
    long n,m;cin>>n>>m;
    map<long,long> most;
    map<long,long> high;
    rep(i,n){
        long h; cin>>h;
        high[i] = h;
        most[i] = 1;
    }
    rep(i,m){
        long a,b;
        cin >> a >> b;
        a--;b--;
        if(high[a] > high[b]) most[b]=-1;
        else if(high[b] > high[a])  most[a]=-1;
        else {most[b]=-1;most[a]=-1;}
    }
    long ans=0;
    rep(i,n){
        if(most[i]==1){
            ans++;
        }
    }
    cout << ans<<endl;
    return 0;
}

Measured memory_bytes: 16128
#include<cstdio>
#include<cctype>
#include<iostream>

using namespace std;

int main()
{
	char ch;
	int cnt[26] = {};

	while (cin >> ch){
		ch = tolower(ch);
		if (isalpha(ch)){
			cnt[ch - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++){
		printf("%c : %d\n", i + 'a', cnt[i]);
	}

	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <list>
#include <algorithm>
#include <list>
#include <numeric>
using namespace std;

int main()
{
    list<int> l;
    int n, num;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        l.push_back(num);
    }
    int q, b, e;
    cin >> q;
    for (int j = 0; j < q; j++)
    {
        list<int>::iterator first = l.begin();
        list<int>::iterator last = first;
        cin >> b >> e;
        while (b != 0)
        {
            b--;
            first++;
        }
        while (e != 0)
        {
            e--;
            last++;
        }
        reverse(first, last);
    }

    list<int>::iterator itr = l.begin();
    cout << *itr++;
    for (; itr != l.end(); itr++)
    {
        cout << " "<< *itr;
    }
    
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[]args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String line = null;
		while((line=reader.readLine()) != null){
			String[]splitLine = line.split(" ");
			if(Integer.parseInt(splitLine[0])%2 == 0 || Integer.parseInt(splitLine[1])%2==0){
				System.out.println("Even");
			}
			else{
				System.out.println("Odd");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int L;
  cin >> L;
  double ans;
  ans = (double)L / 3.0 * L / 3.0 * L / 3.0;
  printf("%.8f\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10000];
int n;
long long ans;
int main() {
  scanf("%d",&n);
  for(int i=1;i<=n;++i) scanf("%d",&a[i]);
  for(int i=1;i<=n;++i) {
  	for(int j=i+1;j<=n;++j) ans += (long long)(a[i] * a[j]);
  }
  printf("%lld",ans);
  return 0;
}

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

int main() {
	int check = 0;
	do {
		string word;
		cin >> word;
		if (!(word[0] == '-')) {
			int m;
			cin >> m;
			int h;
			for (int i = 0; i < m; ++i) {
				cin >> h;
				string left = word.substr(0, h);
				string right = word.substr(h, word.size() - h);
				word = right + left;
			}
			cout << word << endl;
		}
		else {
			check = 1;
		}

	} while (check == 0);
	return 0;
}

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

int main(){
	int n;
	int a[1111];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

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

#define N 1010
#define LL long long
int a[N];
LL b[N];
vector<LL> v;

int main()
{
    int i, j, n, k;
    scanf("%d %d", &n, &k);
    b[0] = 0;
    for(i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        b[i] = b[i-1] + a[i];	// 累加和 
    }
    
    LL sum;
    for(i=1; i<=n; i++)
    {
        for(j=i; j<=n; j++)
        {
        	// 所有的和添加到数组v中 
            sum = b[j] - b[i - 1];	
            v.push_back(sum);
        }
    }
    
    LL res = 0;
    for(i=40; i>=0; i--)
    {
        sum = res | (LL)pow(2, i);
    	int cnt = 0;
        for(j=0; j < n*(n+1)/2; j++)
        {
        	if((v[j] & sum) == sum)
            	cnt++;
		}
        if(cnt >= k)
            res += (LL)pow(2, i);
    }
    
    printf("%lld\n", res);
    
    return 0;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int N = (int)S.size();
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    int j = N - i - 1;
    if (S[i] != S[j]) ans ++;
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3632
N = gets.to_i
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i).sort
C = gets.split.map(&:to_i).sort

dp = Array.new(3) { Array.new(N, 0) }

A.each_with_index do |a, i|
  bi = B.bsearch_index { |x| x > a }

  dp[1][bi] += 1 if bi
end

sum = 0

N.times do |i|
  sum += dp[1][i]
  dp[1][i] = sum
end

B.each_with_index do |b, i|
  ci = C.bsearch_index { |x| x > b }

  dp[2][ci] += dp[1][i] if ci
end

sum = 0

N.times do |i|
  sum += dp[2][i]
  dp[2][i] = sum
end

puts dp[2].inject(:+)


Measured memory_bytes: 26224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(), a.end());
  int ans = 0;
  FOR(i,0,2){
    ans += abs(a[i+1] - a[i]);
  }
  cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >>N ;
	int a[N];
	int flag=0;
	REP(i,N){std::cin >> a[i];if((i+1)!=a[i]) flag++;}
	if (flag==0||flag==2){std::cout << "YES" << std::endl;}
	else std::cout << "NO"<< std::endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <array>

int main() {
  uint32_t ans = 0;
  for (size_t i = 0; i < 5; i++)
  {
    uint32_t x = 0;
    std::cin >> x;
    if(x == 0) ans = i+1;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3548
//#include <bits/stdc++.h>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define ll long long
#define repeat(i,a,b) \
	for(int i=(a),i##end=(b);i<i##end;i++)
ll a[200010],treemax[800010],treemin[800010],yx[200010];
ll n,x,m,ans=0;

void build(int x,int l,int r){
	if(l==r){
		treemin[x]=treemax[x]=a[l];
		return;
	}
	int lc=x*2,rc=x*2+1,m=(l+r)/2;
	build(lc,l,m);
	build(rc,m+1,r);
	treemin[x]=min(treemin[lc],treemin[rc]);
	treemax[x]=max(treemax[lc],treemax[rc]);
}
int chaxunmin(int al,int ar,int x,int l,int r){
	al=max(al,l);
	ar=min(ar,r);
	if(al>ar)return 2147483647;
	if(al==l && ar==r)return treemin[x];
	int lc=x<<1,rc=(x<<1)^1,m=(l+r)/2;
	return min(chaxunmin(al,ar,lc,l,m),
	           chaxunmin(al,ar,rc,m+1,r));
}
int chaxunmax(int al,int ar,int x,int l,int r){
	al=max(al,l);
	ar=min(ar,r);
	if(al>ar)return 0;
	if(al==l && ar==r)return treemax[x];
	int lc=x<<1,rc=(x<<1)^1,m=(l+r)/2;
	return max(chaxunmax(al,ar,lc,l,m),
	           chaxunmax(al,ar,rc,m+1,r));
}

int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    scanf("%d%d",&n,&m);
    repeat(i,0,n)
        scanf("%d",a+i+1);
    build(1,1,n);
    
    repeat(i,1,n)
    if(a[i]<a[i+1]){
    	yx[i+1]=yx[i];
    }
    else
    	yx[i+1]=yx[i]+1;
    /*
    repeat(i,1,n+1)
    	cout<<yx[i]<<' ';
    cout<<endl;
    */
    bool yxchance=0;
    for(int i=1;i<=n-m+1;i++){
    	if(yx[i]==yx[i+m-1]){
    		//cout<<':'<<i<<endl;
    		if(!yxchance){
    			yxchance=1;
    		}
    		else ans++;
    	}
    	else if(i!=n-m+1){
    		if(
			chaxunmin(i,i+m-1,1,1,n)==a[i]
			&& chaxunmax(i+1,i+m,1,1,n)==a[i+m])
				ans++;
		}
    }
    cout<<n-m+1-ans<<endl;
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	i64 ans = 0, c = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'B') continue;
		ans += i - c++;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<cstdio>
typedef long long ll;
using namespace std;

int a[55];
int sum[55];
ll dp[55][2505];

int main()
{
    int n,A;
    scanf("%d%d",&n,&A);
    for(int i=1;i<=n;i++) 
	{
	scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i];
	}
    dp[0][0]=1;
    for(int k=1;k<=n;k++){
        for(int i=k;i>=1;i--){
            for(int j=sum[k];j>=a[k];j--){
                dp[i][j]+=dp[i-1][j-a[k]];
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans+=dp[i][i*A];
    printf("%lld\n",ans);
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
 
  int ans=0;

  for (int i = 0; i < N-2; i++) {
    if(a.at(i+2)>a.at(i+1)&&a.at(i)<a.at(i+1)){
      ans++;
    }
    else if(a.at(i+2)<a.at(i+1)&&a.at(i)>a.at(i+1)){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int miny=1001,maxx=-1001;
	for(int i=0;i<n;i++){
		int tmp;cin>>tmp;
		maxx=max(tmp,maxx);
	}
	for(int i=0;i<m;i++){
		int tmp;cin>>tmp;
		miny=min(tmp,miny);
	}
	for(int z=maxx+1;z<=miny;z++){
	    if(x<z && z<=y){
	        cout<<"No War"<<endl;
	        return 0;
	    }
	}
	cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int ma = X, mi = Y;
    rep(i, N) {
        int x;
        cin >> x;
        ma = max(x, ma);
    }
    rep(i, M) {
        int y;
        cin >> y;
        mi = min(y, mi);
    }
    if(mi <= ma) {
        cout << "War" << endl;
    } else {
        cout << "No War" << endl;
    }

    return 0;
}

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


int main() {
	
	string s,s2;
	cin >> s;
	char last = 'G';
	while (!s.empty()){
		if(s.back() == last) s.pop_back();
		else {
			last = s.back();
			s2.push_back(s.back());
			s.pop_back();
		}
	}
	cout << s2.length() -1 ;
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i, H) cin >> A[i];
    bool ans = true;
    rep(h, H) rep(w, W) {
        if(A[h][w] == '#') {
            bool ok = false;
            rep(i, 4) {
                if(h + dy[i] >= 0 &&  h + dy[i] < H && w + dx[i] >= 0 &&  w + dx[i] < W && A[h + dy[i]][w + dx[i]] == '#') ok = true;
            }
            if(!ok) {
                ans = false;
            }
        }
    }
    output(ans ? "Yes" : "No");
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);
#define Accepted 0
using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const double eps = 1e-10;
const double pi = acos(-1);
int T, cases, n, m;

int main()
{
    IOS;
    string s;
    cin >> n >> s;
    int a = 0, b = 0;
    for(int i = 0; i < n; i++)if(s[i] == 'R')a++;else b++;
    if(a > b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return Accepted;
}


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

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

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


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

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

	cin>>d;
	if(d==25)
		cout<<"Christmas";
	else if(d==24)
		cout<<"Christmas Eve";
	else if(d==23)
		cout<<"Christmas Eve Eve";
	else if(d==22)
		cout<<"Christmas Eve Eve Eve";
	return 0;
}

Measured memory_bytes: 256