akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	
	int a,b;
	
	
	scanf("%d %d",&a,&b);
	
	if(a%3==0 || b%3==0 || (a+b)%3==0){
		printf("Possible\n");
	}
	
	else{
		printf("Impossible\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    double tmp;
    cin>>tmp;
    double tmpp=tmp/3;
    printf("%.8f",tmpp*tmpp*tmpp);
}

Measured memory_bytes: 256
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        double n = io.r<double>();
        io.w((n * n * Math.PI).ToString() + " " + (2 * n * Math.PI).ToString());
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

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

int main() {
int N;
cin>>N;
string S;
cin>>S;
int count=0;
for(int i=0; i<N-2; i++){
 if(S.at(i)=='A'&& S.at(i+1)=='B'&&S.at(i+2)=='C'){
count+=1;
}
}
cout<<count<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> ill;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<ill> vill;

const int MaxX = 5000;
const int MaxN = 2000;
const ll LongInf = 1e16;


bool failed;
vll adj[MaxN + 5];
ll w[MaxN + 5];
ll n, a;


ill dfs(int u, int par) {

    if (adj[u].size() == 1 && adj[u][0] == par)
        return mp(w[u], 0);

    ll sub_w = 0;
    bool can[MaxX + 5] = {};
    can[0] = true;
    
    for (auto v : adj[u]) {

        if (v == par) continue;

        ill x = dfs(v, u);
        sub_w += x.ff + x.ss;

        for (int j = MaxX; j >= 0; j--) {
            if (can[j]) {
                can[j] = false;
                if (j + x.ff <= MaxX) can[x.ff + j] = true;
                if (j + x.ss <= MaxX) can[x.ss + j] = true;
            }
        }
    }

    for (int i = w[u]; i >= 0; i--)
        if (can[i])
            return mp(w[u], sub_w - i);
    
    failed = true;
    return mp(LongInf, LongInf);
}


int main() {

    iostream::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;
    for (int i = 2; i <= n; i++) {
        cin >> a;
        adj[i].pb(a);
        adj[a].pb(i);
    }

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

    dfs(1, -1);

    if (!failed) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

int main() {
    int A,B;
    scanf("%d %d", &A,&B);
    if(1 <= A && A <= 9 && 1 <= B && B <=9){
        printf("%d", A * B);
    }else{
        printf("%d", -1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>

double Heron(double,double,double);

int main(){
	double x[4],y[4];
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])!=EOF){
		double l01 = sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
		double l02 = sqrt((x[2]-x[0])*(x[2]-x[0])+(y[2]-y[0])*(y[2]-y[0]));
		double l03 = sqrt((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0]));
		double l12 = sqrt((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
		double l13 = sqrt((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3]));
		double l23 = sqrt((x[3]-x[2])*(x[3]-x[2])+(y[3]-y[2])*(y[3]-y[2]));
		if(fabs((Heron(l01, l12, l02)+Heron(l02, l23, l03))-(Heron(l13, l01, l03)+Heron(l13, l12, l23)))<1){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
}

double Heron(double a,double b,double c){
	double s=(a+b+c)/2;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, r;
	cin >> n >> r;
	int sum = 0;
	int w = 1;
	while (n >= r) {
		n /= r;
		++w;
	}
	cout << w;
}

Measured memory_bytes: 256
A,B,K=map(int,input().split())
div=list()
if B < A:
    tmp=A
    A=B
    B=tmp

for i in range(1,B+1):
    if A%i==0 and B%i==0:
        div.append(i)
div.sort(reverse=True)
print(div[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> // include pb_ds

using namespace std;
using namespace __gnu_pbds; // namespace for pb_ds

/* short forms */
#define Accelerate                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mt make_tuple
#define cld(x, y) (((x) / (y)) + ((x) % (y) != 0)) //integer ceil division
#define tc(tt) \
    int tt;    \
    cin >> tt; \
    for (int _tt = 0; _tt < tt; _tt++) // testcase
#define all(cont) (cont).begin(), (cont).end()
#define sz(cont) (int)(cont).size()
#define endl '\n'
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl //print with precision
#define dbg(x) cerr << #x << "is" << (x) << endl
#define leadzero(a) __builtin_clz(a)      // count leading zeroes
#define trailzero(a) __builtin_ctz(a)     // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)

/* constants */
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-9;

/* typedefs */
typedef pair<int,int> pii;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;
typedef priority_queue<int, vector<int> > max_heap;
typedef tree<int,null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> 
    indexed_set; // integer set with indexing / pb_ds

int dig(int n) {
    int cnt=0;
    while(n>0) {
        cnt++;
        n /= 10;
    }
    return cnt;
}

/* main program */
int main() {
    Accelerate;
    int n;
    cin >> n;
    int res = 0;
    for(int i=1;i<=n;i++) {
        if(dig(i)%2) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	a, b, c, k= IN()
	#s = input()
	if k <= a:
		return k
	elif k <= a+b:
		return a
	else:
		m = k - a - b
		return a - m
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9236
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int x, y;

    scanf("%d%d", &x, &y);

    if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10){
        if(y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else if(x == 4 || x == 6 || x == 9){
        if(y == 6 || y == 9 || y == 11){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }

    return 0;
}

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

#define MAX_N 10000000

int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1]; // is_prime[i]がtrueならiは素数
// n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return p;
}
long long Q;
long long l[100009];
long long r[100009];


/*
 *範囲の和を取得
 */
//区間[l, r)
struct segtree {
	vector<long long> data;
	long long n;
	segtree(long long nin){
		n = pow( 2, ceil( log(nin) / log(2) ) );
		long long size = 2 * n - 1;
		this->data.resize(size, 0);
	}

	//API for update val
	void update(long long idx, long long val){
		update(idx, val, 0, 0, n);
	}

	long long update(long long idx, long long val, long long node_id, long long left, long long right){
		//if query idx is within range return val
		if( !( left <= idx && idx < right ) ){
			return data[node_id];
		}
		if( left + 1 < right ) {
			//when node range is not 1, get update children val and update node data
			long long mid = (left + right) / 2 ;
			long long L = update(idx, val, 2 * node_id + 1, left, mid);
			long long R = update(idx, val, 2 * node_id + 2, mid, right);
			data[node_id] = L + R;
		} else {
			//when node range is 1, update node data
			data[node_id] = data[node_id] + val;
		}
		return data[node_id];
	}

	//API for get value of [l, r)
	long long get(long long l, long long r){
		return get(l, r, 0, 0, n);
	}

	/*
	 *internaly used function
	 *query_l: query left range
	 *query_r: query right range
	 *node_id: node id of
	 *node_l:  node left range
	 *node_r:  node right range
	 */
	long long get(long long query_l, long long query_r, long long node_id, long long node_l, long long node_r){
		//query range is outside of node range: return INF
		if( query_r <= node_l || node_r <= query_l ){
			return 0;
		}
		//query range is within node range: return node val
		if( query_l <= node_l && node_r <= query_r ){
			return data[node_id];
		}
		long long mid = (node_l + node_r) / 2;
		long long L = get(query_l, query_r, 2 * node_id + 1, node_l, mid);
		long long R = get(query_l, query_r, 2 * node_id + 2, mid, node_r);
		return L + R;
	}
};

int main(){
	cin >> Q;
	for(long long i = 0; i < Q; i++){
		cin >> l[i] >> r[i];
	}

	sieve(100100);


	segtree sg(100100);

	for(long long i = 0; i < 100100; i++){
		if(i%2 == 1 && is_prime[i] && is_prime[(i+1)/2])
			sg.update(i, 1);
	}

	for(long long i = 0; i < Q; i++){
		cout << sg.get(l[i], r[i] + 1) << endl;
	}
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}

int main()
{
    ciosup;
    int n;
    cin >> n;
    vector<double> v(n);
    vecin(v);
    sort(v.begin(), v.end());
    ll ans = 0;
    REP(i, n-1)
    {
        v[i + 1] = (v[i] + v[i + 1]) / 2.;
    }
    cout << v[n - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll vis[100005];
main()
{
    ll n;
    cin>>n;
    vi v,ans;
    ll k=0;
    while(n--)
    {
        ll a;
        cin>>a;
        k^=a;
        v.pb(a);
    }
    lop0(v.size())
    {
        ll x=v[i]^k;
        ans.pb(x);
    }
    lop0(ans.size()) cout<<ans[i]<<" ";

}




Measured memory_bytes: 7876
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

const int INF=1e9;
int n,last,x,sum;

int main() {
	scanf("%d",&n);
	last=INF;
	for (int i=1;i<n;i++) {
		scanf("%d",&x);
		sum+=std::min(x,last);
		last=x;
	}
	sum+=x;
	printf("%d\n",sum);
	return 0;
}

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

using namespace std;

int main()
{
	string s;
	int n,m;
	cin>>n>>m;

	if(n == 1 and m == 0)
	{
		cout<<0;
		return 0;
	}

	for(int i=0; i<n; i++)
		s+= '#';

	for(int i=0; i<m; i++)
	{
		int ind;
		char c;

		cin>>ind>>c;

		if(s[ind - 1]  == '#')
			s[ind - 1] = c;
		else if(s[ind - 1] != c)
		{
			cout<<-1<<endl;
			return 0;
		}
	}

	if(s[0] == '0' and n>=2)
	{
		cout<<-1<<endl;
		return 0;
	}

	if(s[0] == '#') s[0] = '1';

	for(int i=0; i<n; i++)
    {
        if(s[i] == '#') s[i] = '0';
    }

    cout<<s<<endl;

}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 5001;

void solve() {
	int n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No");
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int main()
{
	int n, b, f, r, v, room[4][3][10];
	std::cin >> n;
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 3; k++) {
			for (int l = 0; l < 10; l++) {
				room[j][k][l] = 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		std::cin >> b >> f >> r >> v;
		room[b - 1][f - 1][r - 1] += v;
	}
	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 3; k++) {
			for (int l = 0; l < 10; l++) {
				std::cout << " " << room[j][k][l];
			}
		std::cout << std::endl;
		}
		if(j < 3)std::cout << "####################" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,a;
cin>>n>>a;
if(n%500<=a)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        String n = scanner.next();
        System.out.println(n.charAt(0) - 49 + (n.length() - 1) * 9 + (n.substring(1).matches("9*") ? 1 : 0));
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){
  int N,a,b,c,d;
  int S[37];
  for(a=0;a<37;a++) S[a]=0;

  for(a=0;a<=9;a++)
    for(b=0;b<=9;b++)
      for(c=0;c<=9;c++)
        for(d=0;d<=9;d++)
          S[a+b+c+d]++;

  while(scanf("%d\n",&N)!=EOF){
    if(N>36) printf("%d\n",0);
    else printf("%d\n",S[N]);
  }
  return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_037
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] aArray = ReadInts();
            int[] bArray = ReadInts();
            Queue<int> queue = new Queue<int>();
            for(int i = 0; i < n; i++)
            {
                int prev = (i + n - 1) % n;
                int next = (i + 1) % n;
                if (bArray[i] - bArray[prev] -bArray[next] >= aArray[i])
                {
                    queue.Enqueue(i);
                }
            }
            long cnt = 0;
            while (queue.Count > 0)
            {
                int i = queue.Dequeue();
                int prev = (i + n - 1) % n;
                int next = (i + 1) % n;
                int tmpCnt = (bArray[i] - Max(bArray[prev], bArray[next]))
                    / (bArray[prev] + bArray[next]);
                if ((bArray[i] - Max(bArray[prev], bArray[next]))
                    % (bArray[prev] + bArray[next]) > 0) tmpCnt++;
                tmpCnt = Min(tmpCnt, 
                    (bArray[i] - aArray[i]) / (bArray[prev] + bArray[next]));
                bArray[i] -= (bArray[prev] + bArray[next]) * tmpCnt;
                cnt += tmpCnt;

                int prev2 = (prev + n - 1) % n;
                int next2 = (next + 1) % n;
                if (bArray[prev] - bArray[prev2] - bArray[i] >= aArray[prev])
                {
                    queue.Enqueue(prev);
                }
                if (bArray[next] - bArray[i] - bArray[next2] >= aArray[next])
                {
                    queue.Enqueue(next);
                }
            }

            for(int i = 0; i < n; i++)
            {
                if (aArray[i] != bArray[i])
                {
                    WriteLine(-1);
                    return;
                }
            }
            WriteLine(cnt);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 45540
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    //static final long MOD = 998244353L;
    static final int INF = 50000000;
    static final int NINF = -500000000;
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        long N = sc.nl();
        pw.println((power(10,N,MOD)-2*power(9,N,MOD)+power(8,N,MOD)+10*MOD)%MOD);
        pw.close();
    }
    
    //Fast exponentiation (x^y mod m)
    public static long power(long x, long y, long m) {
      long ans = 1;
      x %= m;
      while (y > 0) {
        if((y&1)==1)
          ans = (ans * x) % m;
        y /= 2;
        x = (x * x) % m;
      }
      return ans;
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32828
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

void Main()
{
	ll w = 3, h = 3;
	vec<vec<ll>> A(w, vec<ll>(h));
	rep(i, 3)
		rep(j, 3)
	{
		cin >> A[i][j];
	}

	ll N;
	cin >> N;
	vec<ll> b(N);
	rep(i, N)
	{
		cin >> b[i];
		rep(j, 3)
			rep(k, 3)
		{
			if (A[k][j] == b[i])
			{
				A[k][j] = 0;
			}
		}
	}

	bool ret = false;
	rep(i, 3)
	{
		if (A[i][0] == A[i][1] && A[i][1] == A[i][2])
			ret = true;
	}
	rep(i, 3)
	{
		if (A[0][i] == A[1][i] && A[1][i] == A[2][i])
			ret = true;
	}
	if (A[0][0] == A[1][1] && A[1][1] == A[2][2])
		ret = true;
	if (A[2][0] == A[1][1] && A[1][1] == A[0][2])
		ret = true;

	cout << (ret ? "Yes" : "No");
}

/*****/

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

	//std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000005
 
ll n, ans, tw, la, fi;
string s[100005];
 
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        for (int j = 0; j < s[i].size() - 1; j++){
            if (s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
        }
        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') tw++;
        else if (s[i][0] == 'B') fi++;
        else if (s[i][s[i].size() - 1] == 'A') la++;
    }
    ans += min(fi, la);
    ll v = min(fi, la);
    ll _fi = fi, _la = la;
    fi -= v, la -= v;
    if (tw > 0){
        ans += tw - 1;
        if (fi > 0) ans++;
        if (la > 0) ans++;
        if (fi == 0 && la == 0 && tw > 1 && _fi > 0 && _la > 0) ans++;
    }
    cout << ans;
    return 0;
}

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

int main() {
  int x, y, r;

  cin >> x >> y;
  if (x < y) swap(x, y);

  while (y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  cout << x << endl;

  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, ans = INF, num = 0;
    string s;

    cin >> n >> s;
    rep(i, 0, n)
    {
        if (i == 0)
            continue;
        if (s[i] == 'E')
            num++;
    }
    ans = num;
    rep(i, 1, n)
    {
        num += (s[i - 1] == 'W');
        num -= (s[i] == 'E');
        ans = min(ans, num);
    }
    cout << ans << endl;
}


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

typedef long long ll;

int main() {
    int A , B;
    cin >> A >> B;
    int X = 1;
    int T = 0;
    while (B > X) {
        X += (A - 1);
        T++;
    }
    cout << T << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ConsoleApplication3
{


    class Program
    {
        static void sort(string[] matrix)
        {
            int i, j, key = 0;
            for (i = 1; i < matrix.Length; i++)
            {
                key = Int32.Parse(matrix[i]);
                j = i - 1;
                while (j >= 0 && Int32.Parse(matrix[j]) > key)
                {
                    matrix[j + 1] = matrix[j];
                    j--;
                }
                matrix[j + 1] = key.ToString();
            }
        }

    

        static void Main(string[] args)
        {
            int S,T = 0;
            var result = new List<string>(); 

            String Data = Console.ReadLine();
            S = Int32.Parse(Data);
            string[] Smatrix ;
            Data = Console.ReadLine();
            Smatrix = Data.Split(' ');

            Data = Console.ReadLine();
            T = Int32.Parse(Data);
            string[] Qmatrix;
            Data = Console.ReadLine();
            Qmatrix = Data.Split(' ');

            /*
            StreamReader sr = new StreamReader("c:\\temp\\in.txt", Encoding.GetEncoding("Shift_JIS"));
            string data = sr.ReadLine();
            S = Int32.Parse(data);
            data =sr.ReadLine();
            string[] Smatrix;
            Smatrix = data.Split(' ');
            data = sr.ReadLine();
            T = Int32.Parse(data);
            data = sr.ReadLine();
            string[] Qmatrix;
            Qmatrix = data.Split(' ');
            */
             
            sort(Qmatrix);
            int position = 0;
            for (int loop = 0; loop < Qmatrix.Length; loop++)
            {
                while (Int32.Parse(Qmatrix[loop]) > Int32.Parse(Smatrix[position]))
                {
                    if (position == S - 1)
                        break;
                    position++;
                }
                if (Int32.Parse(Qmatrix[loop]) == Int32.Parse(Smatrix[position]))
                {
                        result.Add(Qmatrix[loop]);
                }
            }
            Console.WriteLine(result.Count);

        }
    }
}



Measured memory_bytes: 27800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n,"");
  rep(i,n) cin >> s.at(i);

  sort(all(s));
  int max = 1;
  int k = 0;
  int m = 0;
  vector<string> b(n,"a");
  rep(i,n) {
    m = upper_bound(all(s),s.at(i)) - (s.begin() + i);

    if(max < m) {
      max = m;
      k = 0;
      b.at(k) = s.at(i);
      k++;
    } else if(max == m) {
      b.at(k) = s.at(i);
      k++;
    }
  }
  rep(i,k) cout << b.at(i) << endl;

  return 0;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;

// 入力
long long N, M;

int main(void) {
    cin >> N >> M;

    long long num;
    if (2 * N > M) {
        num = M / 2;
    } else {
        num = N;
        M = M - 2 * N;
        num += M / 4;
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m, X, Y;
    cin >> n >> m >> X >> Y;
    int x[n], y[m];
    rep(i, n)   cin >> x[i];
    rep(i, m)   cin >> y[i];
    
    int xmax = -1000;
    rep(i, n){
        xmax = max(xmax, x[i]);
    }
    int ymin = 1000;
    rep(i, m){
        ymin = min(ymin, y[i]);
    }
    
    FOR_EQ(Z, X + 1, Y){
        if(xmax < Z && Z <= ymin){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int pat[20][100001];
int main()
{
	int num;
	scanf("%d", &num);
	vector<int>vec;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		vec.push_back(z);
	}
	int gen;
	scanf("%d", &gen);
	for (int i = 0; i < num; i++)
	{
		int upp = upper_bound(vec.begin(), vec.end(), vec[i] + gen) - vec.begin() - 1;
		pat[0][i] = upp;
	}
	for (int i = 1; i < 20; i++)
	{
		for (int j = 0; j < num; j++)
		{
			pat[i][j] = pat[i - 1][pat[i - 1][j]];
		}
	}
	int query;
	scanf("%d", &query);
	for (int q = 0; q < query; q++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		if (za > zb)swap(za, zb);
		int ans = 0;
		for (int i = 19; i >= 0; i--)
		{
			if (pat[i][za] < zb)
			{
				za = pat[i][za];
				ans += 1 << i;
			}
		}
		printf("%d\n", ans + 1);
	}
}

Measured memory_bytes: 9080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

#define int long long

using namespace std;

void Main()
{
	int n, a, b;
	cin >> n >> a >> b;

	int count = 0;
	int ans = 0;

	ans += n / (a + b) * a;
	n %= a + b;
	if (n > a) {
		ans += a;
	}
	else {
		ans += n;
	}

	cout << ans << endl;
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int i;
	char c[1002]={0};

	scanf("%s", c);

	for(i=0; i<1001; i++){
		if(c[i] == 0)
			break;
		if(c[i] <= 'C')
			c[i] += 26;
		c[i] = c[i] - 3;
	}
	printf("%s\n", c);

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int m,n,i,j,hantei;
  cin >> m >> n;
  char a[m][n];
  for(i=0;i<m;i++){
    hantei=0;
    for(j=0;j<n;j++){
      cin >> a[i][j];
      if(a[i][j]=='#'){
        hantei++;
      }
    }
    if(hantei==0){
      for(j=0;j<n;j++){
        a[i][j]=0;
      }
    }
  }
  for(i=0;i<n;i++){
    hantei=0;
    for(j=0;j<m;j++){
      if(a[j][i]=='#'){
        hantei++;
      }
    }
    if(hantei==0){
      for(j=0;j<m;j++){
        a[j][i]*=2;
      }
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      if(a[i][j]=='.'||a[i][j]=='#'){
        cout<<a[i][j];
      }
    }
    if(a[i][n-1]!=0){
      cout << endl;
    }
  }
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);

void solve(){
    string a, b; cin >> a >> b;
    int i, j, k, l, r; 
    int ca = 0, cb = 0;
    for0(i, 0, a.length()){
        ca = ca * 10 + (a[i] - '0');
    }
    for0(i, 0, b.length()){
        if(b[i] >= '0' && b[i] <= '9'){
            cb = cb * 10 + (b[i] - '0');
        }
    }
    //cout << ca << ' ' << cb << ' ';
    int ans = ca * cb; //cout << ans << ' ';
    ans /= 100; cout << ans;
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}

Measured memory_bytes: 3628
n, *D = map(int, open(0).read().split())
s = 0
for d1, d2 in zip(D[::2], D[1::2]):
    if d1==d2:
        s += 1
    else:
        s = 0
    if s >= 3:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9172
#include <stdio.h>

int main(void) {
	int m,n;
	while(scanf("%d%d",&m,&n)==2 && (m!=0 || n!=0)) {
		static const char *tani[18] = {
			"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan",
			"Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"
		};
		int keisan[18]={1};
		int i;
		for(i=0;i<n;i++) {
			int carry=0;
			int j;
			for(j=0;j<18;j++) {
				keisan[j]=keisan[j]*m+carry;
				carry=keisan[j]/10000;
				keisan[j]%=10000;
			}
		}
		for(i=17;i>=0;i--) {
			if(keisan[i]>0)printf("%d%s",keisan[i],tani[i]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include<cctype>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
	fastIO
  char ch;
  cin>>ch;
  if(isupper(ch))
    cout<<'A'<<endl;
  else
    cout<<'a'<<endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;



int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	ini(n);
	ini(n1);
	map<int,int>map1;
	FOR(i,0,n1){
		ini(x);
		ini(x1);
		if(x == 1 or x == n){map1[x1]++;}
		if(x1 == 1 or x1 == n){map1[x]++;}
	}
	for(auto x:map1){
		if(x.second == 2){
			out("POSSIBLE");
			return 0;
		}
	}
	out("IMPOSSIBLE");













	return 0;
}


Measured memory_bytes: 12800
// 素数判定
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cassert>

#include<vector>
#include<queue>
#include<set>

using namespace std;

const int MAX_N = 10000;

int PrimeNumberDetermination(int size, int num[]);

int main(void)
{
	int n, num[MAX_N + 1];

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> num[i];
	}

	printf("%d\n", PrimeNumberDetermination(n, &num[0]));

	return 0;
 }

// 素数の数を数える関数
int PrimeNumberDetermination(int size, int num[])
{
	int count = 0;
	bool searchFlag = false;

	for(int i = 0; i < size; i++)
	{
		searchFlag = false;
		int target = num[i];

		if( target == 2 )
		{
			count++;
			continue;
		}

		if( target % 2 == 0 )
		{
			// 偶数
			continue;
		}

		int tmpNum = 3;
		int targetRootNum = (int)sqrt( (double)target ) + 1;

		// 素数を求めるには, targetのルートの数の範囲までを求めれば十分
		while( tmpNum <= targetRootNum )
		{
			if( target % tmpNum == 0 )
			{
				searchFlag = true;
				break;
			}

			// 奇数のみで検討をしていく
			tmpNum += 2;
		}

		if( searchFlag == false )
		{
			count++;
		}
	}

	return count;
}



Measured memory_bytes: 3252
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, Q;
    string S;
    cin >> N >> Q >> S;
    vector<ll> l(Q), r(Q);
    for (ll i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
    }

    vector<ll> sum(N, 0);
    for (ll i = 1; i < N; i++) {
        if (S[i] == 'C' && S[i - 1] == 'A') {
            sum[i]++;
        }
    }

    for (ll i = 1; i < N; i++) {
        sum[i] += sum[i - 1];
    }

    for (ll i = 0; i < Q; i++) {
        cout << sum[r[i] - 1] - sum[l[i] - 1] << endl;
    }
}

Measured memory_bytes: 3456
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> arr(n);
    F0R(i,n)
        cin >> arr[i];
    vector<int> ind;
    F0R(i,n-1)
    {
        if(arr[i]>arr[i+1])
            ind.pb(i);
    }
    if(ind.size()==0)
    {
        cout << "YES";
        return 0;
    }
    if(ind.size()==1)
    {
        int temp = arr[ind[0]];
        arr[ind[0]]=arr[ind[0]+1];
        arr[ind[0]+1]=temp;
    }
    else
    {
        int temp=arr[ind[0]];
        arr[ind[0]]=arr[ind[1]+1];
        arr[ind[1]+1]=temp;
    }
    F0R(i,n-1)
    {
        if(arr[i]>arr[i+1])
        {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
h=list(map(int,input().split()))
for i in range(n-1):
  if h[i]-h[i+1]>1:
    print('No')
    sys.exit()
  if h[i]-h[i+1]==1:
    for j in range(i+1,n-1):
      if h[j+1]>h[j]:
        break
      if h[j+1]<h[j]:
        print('No')
        sys.exit()
    
print('Yes')
        
        
        
        
        
        
        


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline void Checkmax( R &A , R B ) { if( A < B ) A = B ; }
template < class R > inline void Checkmin( R &A , R B ) { if( A > B ) A = B ; }
const int MaxN = 100000 + 10 ;
int N , A[MaxN] ;
int main() {
	Readin( N ) ;
	for(register int i = 0 ; ++i <= N ; )
		Readin( A[i] ) ;
	sort( A + 1 , A + 1 + N ) ;
	reverse( A + 1 , A + 1 + N ) ;
	for(register int i = 0 ; ++i <= N ; )
		if( A[i+1] < i+1 ) {
			register int k ; for( k = i ; A[++k] == i ; ) ;
			return not printf( "%s\n" , ( ( ( A[i] - i ) | ( k - i + 1 ) ) & 1 ) ? "First" : "Second" ) ;
		}
}

Measured memory_bytes: 640
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool prime[1000000]; 

int main() {
    long long int n,k,r,s,p,sum=0,i;
    char temp;
    string s1;
    vector<char> v;
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>s1;
    for(i=0;i<s1.size();i++)
    {
        if(i==0)
        {
            if(s1[i]=='r')
            {
            sum+=p;
            v.push_back('p');
            }
            else if(s1[i]=='s')
            {
            sum+=r;
            v.push_back('r');
            }
            else
            {
            sum+=s;
            v.push_back('s');
            }
        }
        else
        {
            if(i-k>=0)
            {
              
              
              if(s1[i]=='r')
            {
            temp='p';
            }
            else if(s1[i]=='s')
            {
            temp='r';
            }
            else
            {
           temp='s';
            }
            if(v[i-k]!=temp)
            {
                if(temp=='r')
                {
                sum+=r;
                v.push_back('r');
                }
                else if(temp=='p')
                {
                    sum+=p;
                     v.push_back('p');
                }
                else
                {
                    sum+=s;
                     v.push_back('s');
                }
            }
            else
            v.push_back('#');
            }
            else
            {
                if(s1[i]=='r')
            {
            sum+=p;
            v.push_back('p');
            }
            else if(s1[i]=='s')
            {
            sum+=r;
            v.push_back('r');
            }
            else
            {
            sum+=s;
            v.push_back('s');
            }
            }
        }
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 640
N=int(input())
CSF=[]
for i in range(1,N):
  a,b,c=map(int,input().split())
  CSF.append([a,b,c])

for i in range(0,N-1):
  ans=CSF[i][0]+CSF[i][1]
  for j in range(i+1,N-1):
    if ans<=CSF[j][1]:
      ans=CSF[j][1]
    elif ans%CSF[j][2]==0:
      pass
    else:
      ans+=CSF[j][2]-ans%CSF[j][2]
    ans+=CSF[j][0]
  print(ans)

print(0)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
	int n;
	cin >> n;
	vector<int> s(n + 1), l(n + 1), p(n + 1);
	for (int i = 1; i <= n; i++) cin >> s[i] >> l[i] >> p[i];
	int m;
	cin >> m;
	vector<int> w(m + 1);
	for (int i = 1; i <= m; i++) cin >> w[i];

	vector<vector<int>> dp(400, vector<int>(400, 0));
	vector<int> ans(m + 1);

	for (int k = 1; k <= m; k++) {
		int MAX = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w[k]; j++) {

				if (j >= s[i]) {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - s[i]] + p[i]);
				}
				else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}

		for (int i = 1; i <= w[k]; i++) {
			MAX = max(MAX, dp[n][i]);
		}

		if (MAX == 0) {
			cout << -1 << endl;
			return 0;
		}

		ans[k] = MAX;
	}

	for (int i = 1; i <= m; i++) {
		cout << ans[i] << endl;
	}
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define INF 1e9

int n;
vi opp;
vector<bool> seen;
vi weight;

int dfs(int v){
    if (weight[v]!=-1) return weight[v];
    if (seen[v] && weight[v]==-1) return INF;
    int u = opp[v];
    seen[v]=seen[u]=true;
    int wv,wu;
    if (v%(n-1)==0) wv=1; else wv=dfs(v-1)+1;
    if (u%(n-1)==0) wu=1; else wu=dfs(u-1)+1;
    weight[v]=weight[u]=max(wv,wu);
    return weight[v];
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int N = n*(n-1);
    vector<vi> a(n, vi(n-1));
    vector<vi> rev(n, vi(n));
    rep(i,n)rep(j,n-1){
        cin>>a[i][j]; a[i][j]--;
        rev[i][a[i][j]] = j;
    }
    opp.resize(N);
    rep(i,n)rep(j,n-1){
        int id = (n-1)*i+j;
        opp[id] = (n-1)*a[i][j]+rev[a[i][j]][i];
    }
    weight.resize(N,-1);
    seen.resize(N,false);
    int ans=0;
    rep(i,N) chmax(ans,dfs(i));
    cout<<((INF>ans)?ans:-1)<<"\n";
    return 0;
}


Measured memory_bytes: 16256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 5010;

int n, f[N][N], ans;
char s[N];

int main()
{
	scanf("%d%s", &n, s + 1);
	
	for (int i = n; i >= 1; --i)
	{
		for (int j = n; j > i; --j)
		{
			if (s[i] == s[j]) f[i][j] = min(f[i + 1][j + 1] + 1, j - i);
			ans = max(ans, f[i][j]);
		}
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 96768