akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
    IOS;
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    REP(i,n){
        cin >> v[i];
    }
    ll res = 0;
    ll t = min(n,k);
    REP(i,t+1){
        REP(j,t+1-i){
            priority_queue<ll,vector<ll>,greater<ll>> pq;
            ll temp = 0;
            REP(l,i){
                temp+=v[l];
                pq.push(v[l]);
            }
            REP(l,j){
                temp+=v[n-1-l];
                pq.push(v[n-1-l]);
            }
            for(int l=0;l<(k-(i+j));++l){
                if(pq.empty()){
                    break;
                }
                ll po = pq.top();
                if(po>0){
                    break;
                }
                temp-=po;
                pq.pop();
            }
            
            chmax(res,temp);
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
package main

import (
        "bufio"
        "fmt"
        "math"
        "os"
)

func solution(x, y int) int {
        memo := make([]int, 0)
        hi := 0
        for i := 1; hi <= y; i++ {
                hi = x * int(math.Pow(2, float64(i)-1))
                memo = append(memo, hi)
        }
        return len(memo) - 1
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var x, y int
        fmt.Fscan(r, &x, &y)
        fmt.Println(solution(x, y))
}

Measured memory_bytes: 1856
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>

using namespace std;

int main(){
  int n,m,r,l;
  int l_max = 0, r_min = 1000000;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    cin >> l >> r;
    if(l_max < l) l_max = l;
    if(r_min > r) r_min = r;
  }

  if(l_max > r_min) cout << 0;
  else cout << r_min - l_max + 1;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int N;
ll K, ans = 0;
ll a[(int)2e5 + 1] = {0};
map<ll, int> mp;

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= N; i++) {
        a[i] = (a[i] - i + K) % K;
    }
    // init window
    for (int i = 0; i <= N; i++) {
        if (i >= K) {
            mp[a[i - K]]--;
        }
        ans += mp[a[i]];
        mp[a[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>vec(3);
    cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
    sort(vec.begin(), vec.end());
    cout<<vec.at(0)<<' '<<vec.at(1)<<' '<<vec.at(2)<<endl;
}


Measured memory_bytes: 3156
package main

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

type Edge struct {
    cost int
    id1 int
    id2 int
}

type Point struct {
    x int
    y int
    id int
}

type Sortable struct {
    arr []interface{}
    comp CompFunc
}

type CompFunc func(p, q interface{}) bool

func (st Sortable) Len() int {
    return len(st.arr)
}

func (st Sortable) Swap(i, j int) {
    st.arr[i], st.arr[j] = st.arr[j], st.arr[i]
}

func (st Sortable) Less(i, j int) bool {
    p, q := st.arr[i], st.arr[j]
    return st.comp(p, q)
}

func find(x int, parent []int) int {
    if x == parent[x] {
        return x
    }
    parent[x] = find(parent[x], parent)
    return parent[x]
}


/* input */
var sc = bufio.NewScanner(os.Stdin)
func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

func main() {
    var pointSorter Sortable
    var edgeSorter Sortable
    var parent []int
    sc.Split(bufio.ScanWords)
    n := readInt()
    for i := 0; i < n; i++ {
        pointSorter.arr = append(pointSorter.arr, &Point{x:readInt(), y:readInt(), id:i})
    }
    compX := func(p, q interface{}) bool {
        return p.(*Point).x < q.(*Point).x
    }
    compY := func(p, q interface{}) bool {
        return p.(*Point).y < q.(*Point).y
    }
    compE := func(p, q interface{}) bool {
        return p.(*Edge).cost < q.(*Edge).cost
    }
    pointSorter.comp = compX
    sort.Sort(pointSorter)
    for i := 0; i < n - 1; i++ {
        p1 := pointSorter.arr[i].(*Point)
        p2 := pointSorter.arr[i + 1].(*Point)
        edgeSorter.arr = append(edgeSorter.arr, &Edge{p2.x - p1.x, p1.id, p2.id})
    }
    pointSorter.comp = compY
    sort.Sort(pointSorter)
    for i := 0; i < n - 1; i++ {
        p1 := pointSorter.arr[i].(*Point)
        p2 := pointSorter.arr[i + 1].(*Point)
        edgeSorter.arr = append(edgeSorter.arr, &Edge{p2.y - p1.y, p1.id, p2.id})
    }

    edgeSorter.comp = compE
    sort.Sort(edgeSorter)
    for i := 0; i < n; i++ {
        parent = append(parent, i)
    }
    
    ans := 0
    for _, edge := range edgeSorter.arr {
        p1, p2 := find(edge.(*Edge).id1, parent), find(edge.(*Edge).id2, parent)
        if p1 != p2 {
            parent[p1] = p2
            ans += edge.(*Edge).cost
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 38912
import math
K = int(input())

ans = 0
a = 0
b = 0
c = 0
for i in range(1, K + 1):
    a += i

for i in range(1, K):
    for j in range(i + 1, K + 1):
        b += math.gcd(i, j) * 6

for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            x = math.gcd(i, j)
            c += math.gcd(x, k) * 6
ans = a + b + c
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
const int dx[]={0,0,-1,1,-1,-1,1,1};
const int dy[]={-1,1,0,0,-1,1,-1,1};
using namespace std;
int n,k,a[5005];
bitset<5005> sum;
bool judge(int x)
{
	if(a[x]>=k)
		return 1;
	sum.reset();
	sum[0]=1;
	for(int i=1;i<=n;i++)
		if(i!=x)
			sum|=sum<<a[i];
	for(int i=k-1;i>=k-a[x];i--)
		if(sum[i])
			return true;
	return false;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int l=0,r=n+1;
	while(l<r)
	{
		int m=(l+r)>>1;
		if(judge(m))
			r=m;
		else	
			l=m+1;
	}
	cout<<l-1;
	return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,k=map(int,input().split())
mod=10**9+7
memo=[pow(k//i,n,mod) for i in range(1,k+1)] #gcdが1~kになる場合をメモする
for i in range(k-1,-1,-1):
    x=make_divisors(i+1)
    for j in x:
        if j!=i+1:
            memo[j-1]-=memo[i]
ans=0
for i in range(k):
    ans+=(memo[i]*(i+1))
    ans%=mod
print(ans)

Measured memory_bytes: 74028
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d,sum;
	scanf("%d %d",&a,&b);
	c=b-a;
	sum=c*(c+1)/2;
	d=sum-b;
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
#define N 100005 

ll arr[N] , brr[N] , n , Arr[N] ; 

int main(){
	cin>>n ; 

	for(int i=1;i<=n+1;i++){
		cin>>arr[i] ; 
		Arr[i] = arr[i] ; 
	}

	for(int i=1;i<=n;i++){
		cin>>brr[i] ; 
		//cout<<brr[i]<<endl;
	}

	ll ans = 0 , pre = 0 ;

	for(int i=1;i<=n;i++){
		arr[i] = max(0LL , arr[i] - pre) ; 
		pre = max(0LL , brr[i] - arr[i]) ; 
		arr[i] = max(0LL , arr[i] - brr[i]) ; 
    }

    arr[n+1] = max(0LL , arr[n+1] - pre) ; 

    for(int i=1;i<=n+1;i++){
    	//cout<<arr[i]<<e
    	ans += Arr[i] - arr[i] ; 
    } 

    cout<<ans<<"\n" ;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main() {
	string S;
	cin>>S;
	for(int i=0;i<S.length();i++){
		if(S[i]=='9'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,M,K;

ll mo=1000000007;
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

ll modpow(ll a, ll n) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;
	
	return p*modpow(q,mo-2)%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	
	ll ret=0;
	FOR(i,N) {
		ll d=1LL*i*(i+1)/2%mo;
		d=d*M%mo*M%mo;
		ret+=d;
	}
	FOR(i,M) {
		ll d=1LL*i*(i+1)/2%mo;
		d=d*N%mo*N%mo;
		ret+=d;
	}
	
	cout<<ret%mo*comb(N*M-2,K-2)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
ll a[100000];
ll dp[18][100000];
int main() {
	int n;cin >> n;
	rep(i, n)cin >> a[i];
	ll l;cin >> l;
	rep(i, n) {
		int k = upper_bound(a, a + n, a[i] + l) - a;k--;
		dp[0][i] = k;
	}
	Rep(i, 1, 18) {
		rep(j, n) {
			dp[i][j] = dp[i - 1][dp[i - 1][j]];
		}
	}
	int q;cin >> q;
	rep(aaa, q) {
		int s, t;cin >> s >> t;s--;t--;
		if (s > t)swap(s, t);
		int out = 0;
		while (s < t) {
			rep(j, 18) {
				if (dp[j][s] >= t) {
					if (j > 0) {
						out += 1 << (j - 1);
						s = dp[j - 1][s];
					}
					else {
						out++;
						s = t;
					}
					break;
				}
			}
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 15616
a=int(input())
b=[0]+[int(input()) for i in range(a)]
c=1
d=0
e=[False for i in range(a+1)]
while c!=2:
  e[c]=True
  d+=1
  c=b[c]
  if (e[c]):
    d=-1
    break

print(d)

Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<int, int>;
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; }

ll n, aa, bb;

int main() {
    cin >> n >> aa >> bb;
    vector<ll> X(n, 0);
    for(int i = 0; i < n; ++i) cin >> X.at(i);

    vector<ll> XX(n, 0);
    for(int i = 0; i < n-1; ++i) {
        XX.at(i) = aa * (X.at(i+1)-X.at(i));
    }

    ll ans = 0;
    for(int i = 0; i < n-1; ++i) {
        ans += min(XX.at(i), bb);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),i,a[]=new int[n+1];

        for(i=2;i<=n;i++)
        for(int j=i;j<=n;j+=i)
        a[j]++;
        long ans=0;
        for(i=1;i<=n;i++)
        ans+=1l*i*(a[i]+1);
        System.out.print(ans);
    }
}


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

int main()
{
	int N;
	string s;
    bool flag = false;

	cin >> N;
	for(int i=0;i<N;i++){
		cin >> s;
		if(s == "Y"){
			flag = true;	
        }
	}
    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
 
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
 
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}    
          
          
          
        
        
        

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

using namespace std;

int main(){
    int N;
    cin >> N;
    long long P = 0;
    int temp = 0;
    int mymax = 0;
    for ( int i = 0; i < N; i ++ ){
        long long H;
        cin >> H;
        if ( H <= P ){
            temp ++;
        }
        else{
            mymax = max( temp, mymax );
            temp = 0;
        }
        P = H;
    }
    mymax = max( temp, mymax );
    cout << mymax;
}


Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n = ri()
a = rli()
b = []

if(n%2 == 1):
    for i in range(0,n,2)[::-1]:
        b.append(a[i])
    for i in range(1,n,2):
        b.append(a[i])
else:
    for i in range(1,n+1,2)[::-1]:
        b.append(a[i])
    for i in range(0,n,2):
        b.append(a[i])
print(" ".join(list(map(str, b))))


Measured memory_bytes: 29328
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
int main()
{
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll  a[n+1];
    for(ll i=1;i<=n;i++)
        {
            cin>>a[i];


        }
    for(int i=1;i<=n-k;i++)
      {
          if(a[i+k]>a[i])
              cout<<"Yes"<<endl;
          else
            cout<<"No"<<endl;
      }

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif

//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;

const int N=1e5+6;

vector<int> g[2*N];
ll qan1[2*N],qan2[2*N];
bool col[2*N];
void dfs(int v,int comp){
    if (v>N) qan1[comp]++;
    else qan2[comp]++;
    col[v]=true;
    trav(to,g[v]){
        if (!col[to])dfs(to,comp);
    }
}

int main(){
    fastio;
    srng;
    int m;
    cin>>m;
    FOR(i,m){
        int a,b;
        cin>>a>>b;
        a+=N;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int cmp=1;
    ll ans=0;
    FOR(i,2*N){
        if (!col[i]){
            dfs(i,cmp);
            ans+=qan1[cmp]*qan2[cmp];
            cmp++;
        }
    }
    cout<<ans-m<<endl;
    return 0;
}


Measured memory_bytes: 13056
from collections import Counter, defaultdict

def main():
    num = int(input())
    data_teki = list(map(int, input().split()))
    data_mikata = list(map(int, input().split()))

    ans = min(data_mikata[-1], data_teki[-1])
    nokori = data_mikata[-1] - ans
    for i in range(num)[::-1]:
        if i == 0:
            taoseru = nokori
        else:
            taoseru = nokori + data_mikata[i - 1]
        taosu  = min(data_teki[i], taoseru)
        ans += taosu
        nokori = min(data_mikata[i - 1], taoseru - taosu)
        # print(ans, nokori)

    print(ans)







if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); (i)++)
#define all(x) (x).begin(), (x).end()
#define sqr(x) (x)*(x)
#define CEIL(a,b) ((a)+(b)-1) /(b)

typedef long long ll;
const int INF = 1001001001;

void sort_second(vector<pair<ll, ll>> &A, int N); //A:array of pair, N:size of array
ll a_n(ll a, ll n); // a^n

int main() {
    int n, m, ok = 0, pe = 0;
    cin >> n >> m;
    int a[100005][2]; // a[p][0] = 0,1 : p問目が解けているか, a[p][1] = int : 間違い数
    rep(i, 100005) rep(j, 2) a[i][j] = 0;
    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA" && a[p-1][0] == 0) a[p-1][1]++;
        else if(s == "AC" && a[p-1][0] == 0) a[p-1][0] = 1;
    }
    rep(i, n) {
        if(a[i][0] == 1) {
            ok++;
            pe += a[i][1];
        }
    }

    cout << ok << ' ' << pe << endl;

    return 0;
}

void sort_second(vector<pair<ll, ll>> &A, int N) {
    rep(i, N) swap(A.at(i).first, A.at(i).second);
    sort(all(A));
    rep(i, N) swap(A.at(i).first, A.at(i).second);
}
ll a_n(ll a, ll n) { 
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return ret * a_n(a, n-count) ;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long N = scan.nextLong();
			int min = Integer.MAX_VALUE;
			for(Long key:enum_div(N)) {
				String A = String.valueOf(key);
				String B= String.valueOf(N/key);
				if(min>Math.max(A.length(), B.length()))
					min=Math.max(A.length(), B.length());
				
				
			}
			
			System.out.println(min);
			
			
			
			
		}
		
		
	}
	
	
	private static ArrayList<Long> enum_div(long n){//数字１〜ｎまでの約数を全部Allaylistに詰め込むメソッド
		ArrayList<Long> ret = new ArrayList<Long>();
		for(long i = 1;i*i<=n;i++) {
			if(n%i==0) {
				ret.add(i);
				if(i*i!=n){
					ret.add(n/i);
				}
			}
		}
		
		//ただここまでだと格納した約数はソートされてない
		
		Collections.sort(ret);//int型、Sting型くらいの格納した奴ならコレクションクラスのソートが使える。
		//ソートしてからcollections.reverseつかえば降順にもできる
		return ret;
		
		
		
	}
		

}


Measured memory_bytes: 21844
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

const int N=1e5+10;
vector <int> E[N];
int color[N],cnt[3];

int main(){
   	ios_base::sync_with_stdio(false);
    queue <int> que;
    int n,x,y;
    cin>>n;
    for(int i=1;i<n;i++){ 
        cin>>x>>y;
        E[x].push_back(y);
        E[y].push_back(x);
    }
    color[1]=1,color[n]=2;//标记颜色 
    que.push(1);//1点先手 
    que.push(n);//n点后手 
    while(!que.empty()){
        int tmp=que.front();
        que.pop();
        cnt[color[tmp]]++;//记录标记颜色的数量
    //遍历相邻的所有点,因为把对手堵住后这些点还是需要染色的.  
        for(int i=0;i<E[tmp].size();i++){
            int v=E[tmp][i];
            if(color[v]) continue;
            color[v]=color[tmp];
            que.push(v);
        }
    }
    //因为1点先手,所以数量相同的时候,1点会输. 
    if(cnt[2]>=cnt[1]) cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
    return 0;
}

Measured memory_bytes: 6272
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
cnt = 0
botton = 1
ans = 'false'
while cnt <= n:
    if botton == 2:
        ans = 'true'
        break
    botton = a[botton-1]
    cnt += 1
if ans == 'false':
    print(-1)
else:
    print(cnt)

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

string concat(string a, string b) {
  return a + b;
}

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> x(N);
  for(int i = 0; i < N; i++){
      string str;
      int p;
      cin >> str >> p;
      x.at(i) = make_tuple(str, 100-p, i);
  }
  sort(x.begin(), x.end());
  for(int i = 0; i < N; i++){
      cout << get<2>(x.at(i))+1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll m = 0;
    rep(i, n){
        ll a; cin >> a;
        while(a%2 == 0){
            a /= 2;
            ++m;
        }
    }
    cout << m;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
'''
以下、方針
・Aから、各要素の出現回数を取得する。
・出現回数から、組み合わせを計算する。
'''
uni,cou=np.unique(A,return_counts=True)

# print(uni)
# print(cou)
dic0={}
dic1={}
dic={} #回答用

com=[]
for i in range(len(cou)):
    c=cou[i]*(cou[i]-1)//2
    dic0[uni[i]]=cou[i]
    dic1[uni[i]]=c
    com.append(c)
    dic.setdefault(uni[i])

# print(com)
totalcombination=sum(com)

# print(com)
# print(dic1)

'''
以下方針
・Aから数字を取得
・その数字に対応する組み合わせを減らす。
・その数字の出現回数を1減らした状態の組み合わせの数を足す。
'''

for j in range (N):
    n=A[j] #nはAの数列の数字
    if dic[n]==None:
        e=(dic0[n]-1)*(dic0[n]-2)//2
        t=totalcombination-dic1[n]+e
        dic[n]=t
        print(t)
    else:
        print(dic[n])

Measured memory_bytes: 76348
#include<bits/stdc++.h>
namespace ZDY{
    #define res register
    #define ri res ll
    #define ll long long
    #define db double
    #define sht short
    #define il inline
    #define MB template <class T>
    #define Fur(i,x,y) for(ri i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(ri i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fl(i,x) for(ri i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define inf 21474836473
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdin)
    #define l2(n) (ceil(log2(n)))
    MB il T ABS(T x){return x>0?x:-x;}
    MB il T MAX(T x,T y){return x>y?x:y;}
    MB il T MIN(T x,T y){return x<y?x:y;}
    MB il T GCD(T x,T y){return y?GCD(y,x%y):x;}
    //#define gc() getchar()
    il char gc(){static char buf[1000000],*s,*t;return s==t?(((t=(s=buf)+fread(buf,1,1000000,stdin))==s)?-1:*s++) : *s++;}
    il int gi(){int x=0,f=0;char c=gc();while(c<'0'||'9'<c){if(c=='-')f=!f;c=gc();}while('0'<=c&&c<='9'){x=x*10+c-48;c=gc();}return f?(-x):x;}
}using namespace ZDY;using namespace std;
#define N 20001
int main(){
    int n=gi();n=25-n;
    printf("Christmas");
    while(n--)printf(" Eve");
}

Measured memory_bytes: 256
program prob6
    implicit none
    character(11) :: s
    integer(8) :: L
    integer(8) :: n, tmp, pre, a
    integer(8) :: ans
    integer(8) :: i, j

    read(*,*) s
    L = len_trim(s)

    n = 2 ** (L-1)

    ans = 0
    do i = 0, n-1
        tmp = 0
        pre = 0
        do j = 0, L-2
            if(btest(i, j)) then
                read(s(pre+1:j+1),*) a
                tmp = tmp + a
                pre = j+1
            end if
        end do
        read(s(pre+1:L),*) a
        tmp = tmp + a
        ans = ans + tmp
    end do

    write(*,*) ans

    stop
contains
end program prob6

Measured memory_bytes: 2708
#include<iostream>
#include<numeric>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int fact[1080000];
Int revfact[1080000];
Int rev[1080000];
Int n, x, y, c, w;
void init(){
  Int m = MOD;
  fact[0] = 1;
  revfact[0] = 1;
  rev[0] = 0;
  rev[1] = 1;
  for(Int i = 1;i < 1080000;i++){
    fact[i] = fact[i-1] * i % m;
    if(i>1)rev[i] = MOD / i * (MOD-rev[MOD % i]) % MOD;
    revfact[i] = revfact[i-1] * rev[i] % MOD;
  }
}

Int nCk(Int n, Int k){
  if(n < k)return 0;
  return fact[n] * revfact[n-k] % MOD * revfact[k] % MOD;
}



Int calc(vector<Int> cnt){
  Int sum = accumulate(cnt.begin(), cnt.end(), 0);
  Int res = fact[sum];
  for(Int c:cnt){
    res *= revfact[c];
    res %= MOD;
  }
  return res;
}
vector<Int> color[216000];
Int minl[216000], minr[216000];
int main(){
  init();
  cin >> n >> x >> y;
  for(Int i = 0;i < n;i++){
    cin >> c >> w;c--;
    color[c].push_back(w);
  }
  for(Int i = 0;i < n;i++)sort(color[i].begin(), color[i].end());
  for(Int i = 0;i < n;i++){
    if(i == 0){
      minl[i] = LINF;
      continue;
    }
    minl[i] = minl[i-1];
    if(i > 0 && !color[i-1].empty())minl[i] = min(minl[i], color[i-1][0]);
  }
  for(Int i = n-1;i >= 0;i--){
    if(i == n-1){
      minr[i] = LINF;
      continue;
    }
    minr[i] = minr[i+1];
    if(i != n-1 && !color[i+1].empty())minr[i] = min(minr[i], color[i+1][0]);
  }
  vector<Int> moves;
  for(Int i = 0;i < n;i++){
    Int othermin = min(minl[i], minr[i]);
    Int move = 0;
    for(Int w:color[i]){
      if(othermin + w <= y || othermin + color[i][0] <= y && color[i][0] + w <= x){
	move++;
      }
    }
    if(move){
      moves.push_back(move);
      //      cout << i+1 << " " << move << " " << color[i][0]<< " " << color[i][move-1] << " " << color[i][min(move, (Int)color[i].size() - 1)] << endl;
    }
  }
  cout << calc(moves) << endl;
  return 0;
}

Measured memory_bytes: 40440
/*C - Guess The Number*/
#include <bits/stdc++.h>

using namespace std;

int main(){
	
	int can = true;
	int lines;
	int valor;
	int tam;
	int pos;

	cin >> tam >> lines;
	vector <int> number(tam, -1);

	if(tam == 1 and lines == 0)
		number[0] = 0;
	else{

		for (int i = 0; i < lines; ++i)
		{
			cin >> pos >> valor;

			pos--;
			
			if(number[pos] == -1)
				number[pos] = valor;
			else 
				if(number[pos] != valor)
					can = false;
		}

		if(number[0] == 0 and tam != 1)
			can = false;
		
		for (int i = 0; i < tam; ++i)
		{
			if(number[0] == -1)
				number[0] = 1;
			
			if(number[i] == -1)
				number[i] = 0;

		}


	}


	if(can)
		for (int i = 0; i < tam; ++i)
			cout << number[i];
	else
			cout << "-1";
	
		
	return 0;
}

Measured memory_bytes: 256
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pf          push_front
#define endl    '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
  ios
  ll n,i,j;
  cin>>n;
  ll c[n+1],s[n+1],f[n+1];
  for(i=0;i<n-1;i++)
    cin>>c[i]>>s[i]>>f[i];
  for(i=0;i<n;i++)
  {
    ll t=0;
    for(j=i;j<n-1;j++)
    {   
      ll tt=s[j];
      while(t>tt)tt+=f[j];
      t=tt;
      t+=c[j];
    }
    cout<<t<<"\n";
  }
  return 0;
}

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

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main(void){
    // Your code here!
    int i, n, A[10000+1], q, key, sum = 0;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) sum++;
    }
    printf("%d\n", sum);
    return 0;
}



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

int main(){
    int n, x;        // n1 + n2 + n3 == x    

    // processing inputs
    while(1){
        cin >> n >> x;
        if(n==0 && x==0) break;
        else{
            int num = 0;
            for(int i=1; i<n-1; i++){
                for(int j=i+1; j<n; j++){
                    for(int k=j+1; k<n+1; k++){
                        if(i+j+k==x) num+=1;
                    }
                }
            }
            cout<<num<<endl;
        }
    }
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
    string a, b,c;
    getline(cin,a);
    b=" "+a+" ";
    c=" "+a+" ";
    for(int k=0;(k=a.find(b,k))>=0;k+=c.size()-1)
       a.replace(k,b.size(),c);
    cout<<"2018/0";
    cout<<a.substr(6,a.size()-1);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int k[110];

int main()
{
	while (1) {
		int n; cin>>n;
		if (n==0) break;
		memset(k,0,sizeof(k));
		rep(i,0,n) cin >> k[i];
		string s; cin>>s;

		int j = 0;
		rep(i,0,len(s)) {
			int x=0;
			if (s[i] <= 'Z') x = s[i]-'A'+26;
			else x = s[i]-'a';
			//cout << x << endl;

			x = (x + 52 - k[j]) % 52;
			if (x <= 25) s[i] = 'a'+x;
			else s[i] = 'A'+(x-26);
			j++;
			if (j==n) j=0;
		}
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    rep(i,h){
        cin>>s[i];
    }
    bool ok=true;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                bool black=false;
                for(int x=i-1; x<=i+1; ++x){
                    for(int y=j-1; y<=j+1; ++y){
                        if(x+y-(i+j)==2||x+y-(i+j)==0||x+y-(i+j)==-2)continue;
                        if(x<0||x>=h||y<0||y>=w)continue;
                        if(s[x][y]=='#')black=true;
                    }
                }
                if(black==false)ok=false;
            }
        }
    }
    cout<<(ok==true?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

SIZE = 10001
max = max(A)

C = [0] * SIZE
B = [None]* n
for i in range(len(A)):
    C[A[i]] += 1

for i in range(1,len(C)):
    C[i] = C[i-1] + C[i]

for x in A[::-1]:
    B[C[x]-1] = x
    C[x] -= 1

B = list(map(str,B))
print(" ".join(B))




Measured memory_bytes: 241828
#include <stdio.h>

int min(int a, int b)
{
	if (a <= b){
		return (a);
	}
	return (b);
}

int Chain(int b[10000], int n)
{
	int i, j;
	int count;
	int color;
	int a[10000];
	
	for (i = 0; i < n; i++){
		a[i] = b[i];
	}
	
	for (i = 0; i < n - 4; i++){
		if (a[i] != 0 && a[i] == a[i + 1] && a[i] == a[i + 2] && a[i] == a[i + 3]){
			#if 0
			printf("-----\n");
			for (j = 0; j < n; j++){
				printf("%d\n", a[j]);
			}
			printf("-----\n");
			#endif
			
			count = 0;
			color = a[i];
			
			for (j = i; a[j] == color; j++){
				a[j] = 0;
				count++;
			}
			
			for (j = 0; i + j + count < 10000; j++){
				a[i + j] = a[i + j + count];
				a[i + j + count] = 0;
			}
			
			#if 0
			printf("-----\n");
			for (j = 0; j < n; j++){
				printf("%d\n", a[j]);
			}
			printf("-----\n");
			getch();
			#endif
			
			i = 0;
		}
		
	}
	
	count = 0;
	while (a[count] != 0){
		count++;
	}
	
	if (count == 4 && a[0] == a[1] && a[0] == a[2] && a[0] == a[3]){
		return (0);
	}
	
	return (count);
}

int main(void)
{
	int n;
	int i, j;
	int a[10000];
	int ans;
	int color;
	
	while (1){
		for (i = 0; i < 10000; i++){
			a[i] = 0;
		}
		
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		ans = n;
		
		for (i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		
		for (i = 0; i < n - 4; i++){
			int count[3] = {0, 0, 0};
			for (j = i; j < i + 4; j++){
				if (a[j] - 1 >= 0){
					count[a[j] - 1]++;
				}
			}
			
			color = 0;
			for (j = 0; j < 3; j++){
				if (count[j] >= 3){
					color = j + 1;
					break;
				}
			}
			
			if (color != 0){
				for (j = i; j < i + 4; j++){
					int buf;
					buf = a[j];
					a[j] = color;
					ans = min(ans, Chain(a, n));
					a[j] = buf;
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 672
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll x,n; cin>>x>>n;
  vector<ll> a(1000,0);
  for(int i=0;i<n;i++){
    int temp; cin>>temp;
    a[temp]++;
  }
  ll mn=1000000000000, ck=-1;
  for(ll i=-100;i<200;i++){
    if(i>=0&&a[i])continue;
    if(abs(i-x)<=mn){
      mn=abs(i-x);
      ck=i;
    }
  }
  for(ll i=-100;i<200;i++){
    if(i>=0&&a[i])continue;
    if(abs(i-x)==mn)
      ck=min(ck,i);
  }
  cout<<ck<<"\n";
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n,k;cin >> n >> k;
    vi a(n);
    cin >> a;

    for(int i=k;i<n;++i){
        if(a[i-k] < a[i]){
            // ok
            cout << "Yes\n";
        }else{
            // ng
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 4052
n=int(input())
a=list(map(int,input().split()))

def shou(a):
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return -1
    return 1

f=0
for i in range(n):
    for j in range(n):
        tmp=a[i]
        a[i]=a[j]
        a[j]=tmp
        if shou(a)==1:
            f=1
        tmp=a[i]
        a[i]=a[j]
        a[j]=tmp
if f>0:
    print('YES')
else:
    print('NO')
    


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll m, d;

	cin >> m >> d;

	ll ans = 0;

	FOR(i, 1, m + 1) {
		FOR(j, 22, d + 1) {
			if (j % 10 < 2) {
				continue;
			}
			else {
				ll x = (j / 10) * (j % 10);
				if (x == i) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_H 300
#define MAX_W 300
#define MAX_D (MAX_H * MAX_W)
#define MAX_Q 100000
using namespace std;

typedef pair< int, int > pii;

int h, w, d;
int a[MAX_H][MAX_W];
int q;
int l[MAX_Q], r[MAX_Q];

int cost(pii p1, pii p2){
  return abs(p1.first - p2.first) + 
    abs(p1.second - p2.second);
}

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

  cin >> h >> w >> d;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
      --a[i][j];
    }
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> l[i] >> r[i];
    --l[i]; --r[i];
  }

  pii s[MAX_H * MAX_W];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      s[a[i][j]] = make_pair(j, i);
    }
  }

  int c[d][(MAX_H * MAX_W) / d + 1];
  for(int i = 0; i < d; i++){
    c[i][0] = 0;
    for(int j = 1; i + d * j < MAX_H * MAX_W; j++){
      c[i][j] = c[i][j - 1] + 
        cost(s[i + (j - 1) * d], s[i + j * d]);
    }
  }

  string buf;
  for(int i = 0; i < q; i++){
    int start = l[i] % d;
    int ans = c[start][r[i] / d] - c[start][l[i] / d];
    buf += to_string(ans) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"OK"<<endl;else cout<<"NG"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int k,a,b;cin>>k>>a>>b;
  int c=0;
  Rep(i,a,b+1){
    if(i%k==0) c++;
  }
  
  Ans(c>0);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define lli long long int 
#define MOD 1000000007
#define fi(i,a,n) for(lli i = a; i < n; i++)
#define fd(i,a,n) for(lli i = a; i > n; i--)
#define fv(i,a) for(auto i:a)
#define pb push_back
#define mp make_pair


int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout<<fixed<<setprecision(10);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
lli t=1;
//cin>>t;
while(t--)
{
	string s;
	cin>>s;
	if(s.back()!='s')
		s.push_back('s');
	else
		s+="es";
	cout<<s;
}
return 0;
}

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

using namespace std;

const int N = 26;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int D;
  cin >> D;
  vector<int> C(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  vector<vector<int>> S(D, vector<int>(N));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < N; j++) {
      cin >> S[i][j];
    }
  }

  int score = 0;
  vector<int> last_day(N, 0);
  for (int d = 0; d < D; d++) {
    int pos = 0, new_score = 0;
    for (int i = 0; i < N; i++) {
      int ns = 0;
      for (int j = 0; j < N; j++) {
        if (i == j) {
          ns += S[d][j];
        } else {
          ns -= C[j] * (d - last_day[j]);
        }
      }
      if (chmax(new_score, ns)) {
        pos = i;
      }
    }
    last_day[pos] = d;
    score += S[d][pos];
    for (int i = 0; i < N; i++) {
      score -= C[i] * (d - last_day[i]);
    }
    cout << pos + 1 << '\n';
  }
  return 0;
}


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

int gcd(int x, int y){
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n ; i++) cin >> a[i];
  vector<int> l(n), r(n);
  for (int i = 0; i < n-1; i++) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 1;i--) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  for (int i = 0; i < n; i++){
    ans = max(ans, gcd(l[i],r[i]));
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll k,sum = 0;
    cin >> k;
    rep1(i, k)rep1(j, k)rep1(m, k){
        sum += gcd(i, gcd(j, m));
    }
    pf(sum);
    return 0;
}



Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=1000000;
		boolean p[]=new boolean[N+1];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=2;i*i<=N;i++)
		{
			if(!p[i])
				continue;
			for(int j=i+i;j<=N;j+=i)
				p[j]=false;
		}
		for(;;)
		{
			int a=in.nextInt(),b=in.nextInt(),n=in.nextInt();
			if((a|b|n)==0)
				return;
			int c=0;
			for(;;)
			{
				if(p[a])
					c++;	
				if(c==n)
				{
					System.out.println(a);
					break;
				}
				a+=b;
			}
		}
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int l = 0, r = n;
  while (l < r) {
    int c = (l + r) / 2;
    if (a[c] >= k) {
      r = c;
      continue;
    }
    bool dp[k] = {};
    dp[0] = true;
    for (int i = 0; i < n; i++) {
      if (i == c) continue;
      for (int j = k-1; j >= 0; j--) {
        if (j + a[i] < k && dp[j]) dp[j + a[i]] = true;
      }
    }
    bool flag = false;
    for (int i = k-a[c]; i < k; i++) {
      if (dp[i]) flag = true;
    }
    if (flag) r = c;
    else l = c + 1;
  }
  cout << r << endl;
}

Measured memory_bytes: 256