akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

bool f(int a[],int n){
	for(int i=0;i<n-1;i++){
		if(a[i]>a[i+1]) return false;
	}
	return true;
}

int main(){
	int N;
	cin >> N;
	int p[N];
	in(p,N);
	
	int a[N];
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			Rep(k,N) a[k]=p[k];
			swap(a[i],a[j]);
			if(f(a,N)){
				cout << "YES";
				return 0;
			}
		}
	}
	cout << "NO";
}
		

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

// dp[i][j]:=s[i]まで見たときにjが書かれている回数
long long dp[210][100010];
int main(){
    long long n,x; cin>>n>>x;
    long long s[n]; rep(i,n) cin>>s[i];
    sort(s,s+n); reverse(s,s+n);
    dp[0][x]=1;
    for(long long i=0;i<n;i++){
        for(long long j=0;j<=x;j++){
            (dp[i+1][j%s[i]]+=dp[i][j])%=MOD;
            (dp[i+1][j]+=dp[i][j]*(n-i-1)%MOD)%=MOD;
        }
    }
    long long ans=0;
    for(long long i=0;i<=x;i++){
        ans+=dp[n][i]*i;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 157184
A, B, N = list(map(int, input().split()))
# for i in range(1, N+1):
#     print("i: ", i)
#     print("{} - {} * {}".format(str(A*i/B), str(A), str(i/B)))
#     res = (A*i // B) - A * (i // B)
#     print("result: ", res)
res = (A*N // B) - A * (N // B)
if N >= B:
    t = N // B * B - 1
    tmp = (A*t // B) - A * (t // B)
    res = max(res, tmp)
print(res)

Measured memory_bytes: 61788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int a,b,c;
cin >> a >> b >> c;
if((a+b+c) >= 22) cout << "bust" << endl; else cout << "win" << endl;

//////////////////////////////////////////////////////
return 0;}

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

int B[102][102];
bool maze = false;

void DFS(int Y, int X, int YG, int XG, int C)
{
  if(B[Y][X]!=C || C==0)
    return;

  if(Y==YG && X==XG)
    maze = true;

  B[Y][X] = 0;

  DFS(Y-1, X  , YG, XG, C);
  DFS(Y  , X+1, YG, XG, C);
  DFS(Y+1, X  , YG, XG, C);
  DFS(Y  , X-1, YG, XG, C);
}

int main()
{
  while(true){
    int w, h;
    cin >> w >> h;

    if(w==0 && h==0)
      break;

    int xs, ys, xg, yg, n;
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;

    for(int y=0; y<=h; y++){
      for(int x=0; x<=w; x++){
	B[y][x] = 0;
      }
    }

    for(int i=0; i<n; i++){
      int c, d, x, y;
      cin >> c >> d >> x >> y;
      if(d==0){
	B[y  ][x  ] = c;
	B[y  ][x+1] = c;
	B[y  ][x+2] = c;
	B[y  ][x+3] = c;
	B[y+1][x  ] = c;
	B[y+1][x+1] = c;
	B[y+1][x+2] = c;
	B[y+1][x+3] = c;
      }
      else{
       	B[y  ][x  ] = c;
	B[y+1][x  ] = c;
	B[y+2][x  ] = c;
	B[y+3][x  ] = c;
	B[y  ][x+1] = c;
	B[y+1][x+1] = c;
	B[y+2][x+1] = c;
	B[y+3][x+1] = c;
      }
    }

    maze = false;

    DFS(ys, xs, yg, xg, B[ys][xs]);

    if(maze){
      cout << "OK" << endl;
    }
    else{
      cout << "NG" << endl;
    }
  }

  return 0;
}



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

int main(){
    int s;
    cin >> s;
    int r = s/100;
    int f = s%100;
    if (1 <= r && r <= 12){
        if(1 <= f && f <= 12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else {
        if(1 <= f && f <= 12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
// Brijesh Panara (201601074)
// DAIICT (India)
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> > 
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"   "<<#y<<" : "<<y<<"  "<<#z<<" : "<<z<<endl;

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define READ freopen("input.txt","r",stdin);
#define WRITE freopen("output.txt","w",stdout);
#define RANDOM srand(time(NULL));

#define MOD 1000000007
#define NAX 1000005
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN


ll solve()
{
    ll m1,d1;
    ll m2,d2;
    cin>>m1>>d1;
    cin>>m2>>d2;
    
    ll a[] = {31,28,31,30,31,30,31,31,30,31,30,31};
    m1--;

    if(a[m1]==d1)
        cout<<1<<"\n";
    else
        cout<<0<<"\n";

    return 0;
}


int main()
{
    FAST;
    
    ll t=1;
    // cin>>t;
    
    while(t--!=0)
    {
        ll stat = solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int sx = stdIn.nextInt();
		int sy = stdIn.nextInt();
		
		int tx = stdIn.nextInt();
		int ty = stdIn.nextInt();
		
		StringBuilder sb = new StringBuilder();
		
		for(int i=sy; i<ty ; i++) {
			sb.append('U');
		}
		for(int i=sx; i<tx ; i++) {
			sb.append('R');
		}
		for(int i=ty; i>sy ; i--) {
			sb.append('D');
		}
		for(int i=tx; i>sx ; i--) {
			sb.append('L');
		}
		sb.append('L');
		
		
		for(int i=sy; i<ty+1 ; i++) {
			sb.append('U');
		}
		for(int i=sx-1; i<tx ; i++) {
			sb.append('R');
		}
		sb.append('D');
		sb.append('R');
		for(int i=ty; i>sy-1 ; i--) {
			sb.append('D');
		}
		for(int i=tx+1; i>sx ; i--) {
			sb.append('L');
		}
		sb.append('U');
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21716
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	n := scanInt()
	g := scanInt()
	for i := 0; i < n-1; i++ {
		a := scanInt()
		g = gcd(g, a)
	}
	fmt.Println(g)
}


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

using namespace std;

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

  int X;
  cin >> X;
 	
  	if (X < 30) {
    	cout << "No" << endl;
    }

  else { 
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,k;
int main(){
	cin>>n>>k;

	ll w=n%k,d=abs(k-n%k);
	ll ans=min(w,d);
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int tmp;
    int c = 0;
    for(int i=0;i<N;i++){
        cin >> tmp;
        if(tmp >= K) c++;
    }

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

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

#define ll long long
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
//    ll a,b;
//    cin >> a >> b;
//    if (a == b) cout << "Impossible" << endl;
//    else cout << "Possible" << endl;
    ll n    ;
    cin >> n;
    ll a[n + 1];
    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
//    sort(a + 1, a + n + 1);
    ll sum2 = 0;
    ll answ = 1e18;
    for (ll i = 1; i <= n-1; i++){
        sum2 += a[i];
        sum -= a[i];
        answ = min(answ,abs(sum2-sum));
    }
    cout << answ << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<bool>> d(H, vector<bool>(W, false));
    REP(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        switch (a) {
        case 1:
            REP(i, x) {
                REP(h, H) {
                    d[h][i] = true;
                }
            }
            break;
        case 2:
            REP(i, W - x ) {
                REP(h, H) {
                    d[h][W - i - 1] = true;
                }
            }
            break;
        case 3:
            REP(i, y) {
                REP(w, W) {
                    d[i][w] = true;
                }
            }
            break;
        case 4:
            REP(i, H - y ) {
                REP(w, W) {
                    d[H - i - 1][w] = true;
                }
            }
            break;
        }
    }

    int ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (!d[i][j])ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int a, b;

	cin >> a >> b;

	cout << a * b << ' ' << (a + b) * 2 << endl;


	return 0;
}



Measured memory_bytes: 3100
#define DEBUG 0
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 6/15/2019, 8:15:49 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return mint(0) - *this; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int main()
{
  // init();
  int N, K;
  cin >> N >> K;
  if (K == 1)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << N - K << endl;
  }
}

Measured memory_bytes: 23680
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int K = fs.nextInt();
        int N = fs.nextInt();
        int[] arr = new int[N];
        int[] dist = new int[N];

        for (int i = 0; i < N; ++i) {
            arr[i] = fs.nextInt();
        }

        for (int i = 0; i < N; ++i) {
            if (i == N-1) {
                dist[i] = K - arr[i] + arr[0];
            }
            else {
                dist[i] = arr[i+1] - arr[i];
            }
        }
        Arrays.sort(dist);

        int ans = 0;
        for (int i = 0; i < N-1; ++i) {
            ans += dist[i];
        }

        System.out.println(ans);
    }
}

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

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

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

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

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

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

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




Measured memory_bytes: 38080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int res = n * 800;
	int sol = n / 15 * 200;
	cout << res - sol << endl;
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N; cin >> N;
  int x = 100000;
  VI ws(N), order(N), nxt(N);
  REP(i,N){
	cin >> ws[i];
	order[i] = ws[i];
	x = min(x, ws[i]);
  }
  SORT(order);
  REP(i,N) REP(j,N){
	if(order[i] == ws[j])
	  nxt[j] = i;
  }

  int ans = 0;
  vector<bool> used(N, false);
  for(int i=0;i<N;++i){
	if(used[i]) continue;
	int cur = i, n = 0, m = ws[i], sum = 0;
	while(!used[cur]){
	  used[cur] = true;
	  ++n;
	  m = min(m, ws[cur]);
	  sum += ws[cur];
	  cur = nxt[cur];
	}
	ans += min((n-2)*m+sum, (n+1)*x+m+sum);
  }

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

Measured memory_bytes: 1228
//
// Created by Hideaki Imamura on 2020-03-07.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b)  {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  divUp(T a, T b)   {return ((a+b-1)/b);}
template<typename T> inline bool isEven(T a)       {return (!(a&1)? true : false );}

int main(){
    double d, t, s;
    cin >> d >> t >> s;

    cout << (d/s <= t? "Yes" : "No");
    return 0;
}
/*

*/


Measured memory_bytes: 3720
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int W = sc.nextInt();
			int H = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();

			if ((x - r < 0 || x + r > W) || (y + r < 0 || y + r > H)) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}


Measured memory_bytes: 26296
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int K, Q; cin >> K >> Q;
    vll a_(K); for(auto& e : a_) cin >> e;

    rep(_, Q){
        ll n, X, mod; cin >> n >> X >> mod;
        ll res = n - 1;
        X %= mod;

        vll a = a_;
        ll sum = 0LL;
        int nzero = 0;
        for(auto& e : a){
            e %= mod;
            if(e == 0LL) nzero++;
            sum += e;
        }

        n--;
        ll nloop = n / K;
        ll s_all = X + nloop * sum;
        ll cnt = nloop * nzero + s_all / mod;

        n %= K;
        ll pre = s_all % mod;

        rep(i, n){
            ll cur = (pre + a[i]) % mod;
            if(pre >= cur){
                cnt++;
            }
            pre = cur;
        }

        cout << res - cnt << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.at(0) == 'R') {
        if (s.at(1) == 'R') {
            if (s.at(2) == 'R') {
                cout << 3;
            } else {
                cout << 2;
            }
        } else {
            cout << 1;
        }
    } else if (s.at(1) == 'R') {
        if (s.at(2) == 'R') {
            cout << 2;
        } else {
            cout << 1;
        }
    } else if (s.at(2) == 'R') {
        cout << 1;
    } else {
        cout << 0;
    }
}


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

#define chmax(a, b) a = max(a, b);

long long dp[3005][3005][4];

int main()
{
	int r, c, n;
	cin >> r >> c >> n;
	vector<vector<int>> d(3000, vector<int>(3000));
	for(int i = 0; i < n; i++) {
		int h, w, v;
		cin >> h >> w >> v;
		d[h - 1][w - 1] = v;
	}
	for(int i = 0; i < r; i++) {
		for(int j = 0; j < c; j++) {
			for(int k = 2; k >= 0; k--) {
				chmax(dp[i][j][k + 1], dp[i][j][k] + d[i][j]);
			}
			for(int k = 0; k < 4; k++) {
				chmax(dp[i + 1][j][0], dp[i][j][k]);
				chmax(dp[i][j + 1][k], dp[i][j][k]);
			}
		}
	}
	long long ans = 0;
	for(int i = 0; i < 4; i++) chmax(ans, dp[r - 1][c - 1][i]);
	cout << ans << endl;
    return 0;
}


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

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    priority_queue<int> pq;
    int a[n];
    int sumpos = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > 0) sumpos += a[i];
    }
    int lp = 0;
    int rp = 0;
    int cur = 0;
    for (int i = 0; i < k; i++) {
        cur += a[rp];
        if (a[rp] > 0) sumpos -= a[rp];
        rp++;
    }
    int best = cur + sumpos;
    while (rp != n) {
        cur += a[rp];
        if (a[rp] > 0) sumpos -= a[rp];
        rp++;
        cur -= a[lp];
        if (a[lp] > 0) sumpos += a[lp];
        lp++;
        if (cur+sumpos > best) {
            best = cur+sumpos;
        }
        if (sumpos > best) {
            best = sumpos;
        }
    }
    cout << max(best, (int)0) << '\n';
}
/*

 */

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1][3],dp[n+1][3];

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

    dp[1][0] = a[1][0];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];

    for(int i=2;i<=n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<'\n';
}



Measured memory_bytes: 2560
while True:
    a,b=map(int, input().split())
    if a == 0 and b == 0:
        break
    if a == 1:
        print("#" * b + "\n")
    elif a == 2:
        print(("#" * b + "\n") * a)
    else:
        print("#" * b)
        print((("#" + "." * (b-2) + "#\n") * (a-2))[0:-1])
        print("#" * b + "\n")

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

int main(){
    //int start=5,n=10,i,p,output;
    char a;
	cin>> a;
	if(int(a)>=65 && int(a)<=90){
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
	}
    //cout<<int(a);
    

    

    
       
        }
    


    





Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

ll modexp(ll a, ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
		res = ((res%MOD) * (a%MOD))%MOD;
		a = ((a%MOD) * (a%MOD))%MOD;
		n >>= 1;	
	}
	return res;
}

void solve(int T)
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	arr[i] = modexp(k/i, n);
	ll rx = 0;
	for(ll i=k;i>0;i--)
	{
		for(ll j=2*i;j<=k;j+=i)
		arr[i] = ((arr[i]%MOD) - (arr[j]%MOD) + MOD)%MOD;
		rx = ((rx%MOD) + (((i%MOD) * (arr[i]%MOD))%MOD))%MOD;	
	}
	cout<<rx<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	//cin>>T;
	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 4452
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void insS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		int v = data[i];
		int j = i - 1;
		while (j >= 0 && data[j] > v){
			data[j + 1] = data[j];
			j--;
		}
		data[j + 1] = v;
		print(data);
	}
}



int main(){
	int n; cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; ++i) cin >> data[i];
	insS(data);

	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,m,x,y;
	int o,p,co;
	cin>>n>>m>>x>>y;
	int a[n],b[m];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int j=0;j<m;j++){
		cin>>b[j];
	}
	for(int k=x+1;k<y+1;k++){
		o=0;
		p=0;
		co=0;
		for(int l=0;l<n;l++){
			
			if(a[l]<k){
				o++;
			}
			else{
				break;
			}
		}
		if(o==n){
			co++;
		}
		for(int z=0;z<m;z++){
			if(b[z]>=k){
				p++;
			}
			else{
				break;
			}
		}
		if(p==m){
			co++;
		}
		if(co==2){
			cout<<"No War"<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int n, k;
  cin >> n >> k;
  if(n % k){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int r;
int c;

int n;

#define MAX 100002
vector<pair<int,int> > v[MAX];

vector<pair<int,long long int> > V[MAX];

long long int num[MAX];
long long int f[MAX];

vector<int> vis;

int main(){
	cin >> r >> c;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		x--;
		y--;
		v[x].push_back(make_pair(y, z));
	}
	for (int i = 0; i < r; i++){
		sort(v[i].begin(), v[i].end());
		for (int j = 0; j + 1 < v[i].size(); j++){
			V[v[i][j].first].push_back(make_pair(v[i][j + 1].first, v[i][j + 1].second - v[i][j].second) );
			V[v[i][j+1].first].push_back(make_pair(v[i][j].first, v[i][j].second - v[i][j + 1].second));
		}
	}
	for (int i = 0; i < c; i++){
		num[i] = LLONG_MIN;
	}
	for (int i = 0; i < c; i++){
		if (num[i] == LLONG_MIN){
			num[i] = 0;
			queue<int> q;
			q.push(i);
			vis.clear();
			while (!q.empty()){
				int b = q.front();
				q.pop();
				vis.push_back(b);
				for (int j = 0; j < V[b].size(); j++){
					int go = V[b][j].first;
					long long int want = num[b] + V[b][j].second;
					if (num[go] == LLONG_MIN){
						num[go] = want;
						q.push(go);
						continue;
					}
					if (num[go] != want){
						puts("No");
						return 0;
					}
				}
			}
			long long int VAL = LLONG_MAX;
			for (int j = 0; j < vis.size(); j++){
				VAL = min(VAL, num[vis[j]]);
			}
			for (int j = 0; j < vis.size(); j++){
				f[vis[j]] = VAL;
			}
		}
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < v[i].size(); j++){
			int y = v[i][j].first;
			if (f[y] + (v[i][j].second - num[y])<0){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 11008
using System;

class Prog{
    static void Main(){
        int k = 0;
        var n = int.Parse(Console.ReadLine());
        int[] ls = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        for(int i = 1;i < ls.Length-1;i++){
            if(ls[i-1]<ls[i] && ls[i]<ls[i+1]){
                k++;
            }else if(ls[i+1]<ls[i] && ls[i]<ls[i-1]){
                k++;
            }
        }
        Console.WriteLine(k);
    }
}

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

int main(){
	int n;
	cin>>n;
	for (int i = 1;i <= n;i++){
		if (i % 3 == 0 || i % 10 == 3 || (i - (100 * (i / 100))) / 10 == 3 || (i - (1000 * (i / 1000))) / 100 == 3 || i / 1000 == 3){
			cout<<" "<<i;
		}
	}
		cout<<endl;

	return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    vector<pair<long long, int>> T(N);
    for (int i=0;i<N;i++){
        cin >> A[i] >> B[i];
        T[i].first = A[i] + B[i];
        T[i].second = i;
    }
    sort(T.begin(), T.end());
    reverse(T.begin(), T.end());
    long long cnt = 0;
    for (int i=0;i<N;i++){
        if (i % 2 == 0)
            cnt += A[T[i].second];
        else
            cnt -= B[T[i].second];
    }
    cout << cnt << endl;
    return 0;
 
}

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

int main(){
    int n;
    cin >> n;
    int P[n], Q[n];
    for(int i = 0; i < n; i++){
        cin >> P[i];
        Q[i] = P[i];
    }
    sort(P, P+n);
    int count = 0;
    for(int i = 0; i < n; i++){
        if(P[i] != Q[i]){
            count += 1;
        }
    }
    if(count > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

#define NIL -1

using namespace std;

class NODE {
public:
	int key, p = NIL, right = NIL, left = NIL;
	NODE(int key) {
		this->key = key;
	}
};

vector<NODE> T;
int root = NIL;

void insert(int z) {
	int y = NIL, x = root;
	while (x != NIL) {
		y = x;
		if (T[z].key < T[x].key) x = T[x].left;
		else x = T[x].right;
	}
	T[z].p = y;
	if (y == NIL) { root = z; }
	else if (T[z].key < T[y].key) { T[y].left = z; }
	else T[y].right = z;
}

void find(int k) {
	int x = root;
	bool t = false;
	while (x != NIL) {
		if (k == T[x].key) { t = true; break; }
		else if (k < T[x].key) x = T[x].left;
		else x = T[x].right;
	}
	if (t == true) cout << "yes" << endl;
	else cout << "no" << endl;
}

void In(int a) {
	if (a != NIL) {
		In(T[a].left);
		cout << " " << T[a].key;
		In(T[a].right);
	}
}

void Pre(int a) {
	if (a != NIL) {
		cout << " " << T[a].key;
		Pre(T[a].left);
		Pre(T[a].right);
	}
}


int main() {
	string cmd;
	int m, cnt = 0, key;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> key;
			NODE z(key);
			T.push_back(z);
			insert(cnt);
			cnt++;
		}

		else if (cmd == "find") {
			cin >> key;
			find(key);
		}

		else if (cmd == "print") {
			In(root); cout << endl;
			Pre(root); cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 11292
/*
    When you are not practicing someone else is,
    and the day u meet them u will Lose.

    So, all you need is Practice, Practice and Practice.
*/
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
/**********************************************************************************/



const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>a>>b>>c>>d;
    
    
    
    
    cout<<max({b*d,a*d,a*c,b*c})  <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt(),w=s.nextInt(),k=s.nextInt();
		char[][] f=new char[h][w];
		int[][] r=new int[h][w];

		for(int i=0;i<h;++i)
			s.next().getChars(0,w,f[i],0);

		{
			int c=1;
			for(int i=0;i<h;++i){
				int begin=w;
				boolean exist=false;
				for(int j=0;j<w;++j){
					if(f[i][j]=='#'){
						exist=true;
						begin=Math.min(begin,j);
						r[i][j]=c++;
					}else if(j>0){
						r[i][j]=r[i][j-1];
					}
				}
				if(exist){
					for(int j=begin-1;j>=0;--j){
						r[i][j]=r[i][j+1];
					}
				}
			}

			for(int j=0;j<w;++j){
				for(int i=1;i<h;++i){
					if(r[i][j]==0)
						r[i][j]=r[i-1][j];
				}
				for(int i=h-2;i>=0;--i){
					if(r[i][j]==0)
						r[i][j]=r[i+1][j];
				}
			}
		}

		for(int[]o:r) {
			StringJoiner sj=new StringJoiner(" ");
			for(int i:o)
				sj.add(""+i);
			System.err.println(sj);
			System.out.println(sj);
		}
	}
}


Measured memory_bytes: 44608
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#ifndef STOPIT
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;
#else
#define debug 0;
#endif

template<typename T>
inline T gcd (T a, T b)
{
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  if (a < b) std::swap(a, b);
  while (b)
  {
    a %= b;
    std::swap(a, b);
  }
  return a;
}

inline auto factor(lint x) {
  lint ret = 0;
  for (lint p = 2; p * p <= x; p++) {
    lint m = 0;
    for (; x % p == 0; m++)
      { x /= p; }
    if (m > 0)
      { ret++; }
  }
  if (1 < x)
    { ret++; }
  return ret;
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint a, b; std::cin >> a >> b;
  lint g = gcd(a, b);
  lint ret = factor(g) + 1;
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var L, R int
	fmt.Scan(&L, &R)
	if R-L >= 2018 {
		fmt.Println(0)
		return
	}
	ans := 2019
	for i := L; i < R; i++ {
		for j := i + 1; j <= R; j++ {
			ans = Min(ans, i*j%2019)
		}
	}
	fmt.Println(ans)
}
func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}

Measured memory_bytes: 512
l=[0]*200
200.times do |i|
  j=1
  while (i+1)*j<201
    l[(i+1)*j-1]+=1
    j+=1
  end
end
c=0
gets.to_i.times do |i|
  c+=1 if i.even? && l[i]==8
end
p c

Measured memory_bytes: 1788
num=int(input())
line=list(map(int,input().split()))
n=0
a=0
for i in range(50):
    for i in range(num):
        if line[i]%2==1:
            n+=1
            #print(n)
    if n==0:
         for i in range(num):
             line[i]=(line[i]//2)
         a+=1
    elif n!=0:
        #print(True)
        break
    #print(line)
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
#include <iomanip>
#define int long long
#define rep(i,n) for(int i=0 ; i < (n) ; ++i)
using namespace std;
double kyori(int a,int b,int c,int d,int r1,int r2){
    double temp =0;
    temp = sqrt((a-c)*(a-c)+(b-d)*(b-d))-(double)r1-(double)r2;
    if(temp>0)return temp;
    return 0;
}
double G[1005][1005];
signed main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int n;
    cin >> n;
    vector<int>x(n+2),y(n+2),r(n+2);
    rep(i,n){
        cin >> x[i] >> y[i] >> r[i];
    }
    x[n] = a,y[n] = b,r[n] = 0;
    x[n+1] = c,y[n+1] = d,r[n+1] = 0;
    rep(i,n+2){
        rep(j,n+2){
            G[i][j] = kyori(x[i],y[i],x[j],y[j],r[i],r[j]);
        }
    }
    rep(k,n+2)rep(i,n+2)rep(j,n+2)G[i][j] = min(G[i][j],G[i][k]+G[k][j]);
    printf("%.10lf\n",G[n][n+1]);
}

Measured memory_bytes: 8192
s = input()
print("AMBIGUOUS" if int((s[:2]))>0 and int((s[:2]))<13 and int(s[2:])>0 and int(s[2:])<13 else "YYMM" if int(s[2:])<13 and s[2:]!="00" else "MMYY"if int(s[:2])<13 and s[:2]!="00" else "NA")

Measured memory_bytes: 3060