akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

enum:char{
	WALL='#',ME='@',PANEL='w',CONTAINER='c',EMPTY='.',ESCAPE='E'
};
constexpr int di[]={-1,1,0,0},dj[]={0,0,-1,1};

string encode(const vs& grid,int i,int j)
{
	int h=grid.size(),w=grid[0].size();
	string res;
	repi(k,1,h-1) res+=grid[k].substr(1,w-2);
	res[(i-1)*(w-2)+j-1]=ME;
	return res;
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		int gi=-1,gj=-1;
		deque<tuple<vs,int,int,int>> dq;
		{
			vs grid(h);
			rep(i,h) cin>>grid[i];
			rep(i,h) rep(j,w) if(grid[i][j]==ESCAPE){
				gi=i,gj=j;
				grid[i][j]=EMPTY;
			}
			rep(i,h) rep(j,w) if(grid[i][j]==ME){
				grid[i][j]=EMPTY;
				dq.emplace_back(grid,i,j,0);
			}
		}
		
		int res=-1;
		set<string> vis;
		while(dq.size()){
			vs cur; int ci,cj,ct; tie(cur,ci,cj,ct)=dq.front(); dq.pop_front();
			if(!vis.insert(encode(cur,ci,cj)).second) continue;
			
			if(ci==gi && cj==gj){
				res=ct;
				break;
			}
			
			rep(k,4){
				int ni=ci+di[k],nj=cj+dj[k];
				if(cur[ni][nj]==WALL || cur[ni][nj]==PANEL) continue;
				if(cur[ni][nj]==CONTAINER){
					int i=ni+di[k],j=nj+dj[k];
					for(;;i+=di[k],j+=dj[k]){
						if(cur[i][j]==EMPTY) continue;
						if(cur[i][j]==PANEL) break;
						if(cur[i][j]==WALL || cur[i][j]==CONTAINER){
							i-=di[k],j-=dj[k];
							break;
						}
					}
					if(i==ni && j==nj) continue;
					vs next=cur;
					next[ni][nj]=EMPTY;
					next[i][j]=next[i][j]==PANEL?EMPTY:CONTAINER;
					dq.emplace_front(move(next),ci,cj,ct);
				}
				else
					dq.emplace_back(cur,ni,nj,ct+1);
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 10076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	ll n, x, m;
	cin >> n >> x >> m;
    vector<int> id(m, -1);
    vector<int> a;
    int len = 0;
    ll tot = 0;
    while (id[x] == -1) {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = (x*x)%m;
    }

    int c = len - id[x];
    ll s = 0;
    for (int i = id[x]; i < len; ++i) s += a[i];

    ll ans = 0;
    if (n <= len) {
        rep(i,n) ans += a[i];
    } else {
        ans += tot;
        n -= len;
        ans += s*(n/c);
        n %= c;
        rep(i,n) ans += a[id[x]+i];
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3980
/*
Powered by 0736TuT
Code + Music + Games = Life
*/

#include<iostream>
#include<cstdio>
#define MAXN 110

typedef long long qwq;

using namespace std;

int scan(int *buf_tar)
{
    char buf_c=0; bool is_rev=0;
    while(buf_c!='-'&&(buf_c<'0'||buf_c>'9')) {buf_c=getchar(); if(buf_c==EOF) return EOF;}
    if(buf_c=='-') is_rev=1,buf_c=getchar();
    *buf_tar=0;
    while(buf_c>='0'&&buf_c<='9') {*buf_tar*=10; *buf_tar+=buf_c-'0'; buf_c=getchar();}
    if(is_rev) *buf_tar=-*buf_tar;
    return 0;
}

int n,Max;
int v[MAXN],w[MAXN];
int f[10010];

int main()
{
    scan(&n); scan(&Max);
    for(int i=1;i<=n;i++) {scan(&v[i]); scan(&w[i]);}
    for(int i=1;i<=n;i++) for(int j=Max;j>=w[i];j--) if(f[j]<f[j-w[i]]+v[i]) f[j]=f[j-w[i]]+v[i];
    printf("%d\n",f[Max]);
    return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;

int n,k,mi = 0x3f3f3f3f;
int a[105];
int dp[100005];

int main(){
	scanf("%d %d",&n,&k);
	for(int i = 1;i <= n;i ++){
		scanf("%d",&a[i]);
		mi = min(mi,a[i]);
	}
	for(int i = 0;i < mi;i ++) dp[i] = -1;
	for(int i = mi;i <= k;i ++){
		int mi = 1;
		for(int j = 1;j <= n;j ++){
			if(i - a[j] >= 0) mi = min(mi,dp[i - a[j]]);
		}
		if(mi == -1) dp[i] = 1;
		else dp[i] = -1;
	}
	if(dp[k] == 1) printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 640
from heapq import heappush, heappop

h, w = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]

nums = []
for _ in range(h):
    nums += [int(i) for i in input().split()]


def dijkstra(s=1, c=c):
    INF = float('inf')

    d = {i: INF for i in range(10)}
    d[-1] = 0
    d[s] = 0

    queue = []
    heappush(queue, (0, s))

    while queue:
        di, v = heappop(queue)
        for i in range(10):
            dtmp = d[v] + c[i][v]
            if dtmp < d[i]:
                d[i] = dtmp
                heappush(queue, (dtmp, i))

    return d


magic = dijkstra()
answer = sum(magic[i] for i in nums)
print(answer)


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


template<typename T>
struct CumulativeSum2D {
    vector<vector<T>> dat;
    CumulativeSum2D() = default;
    CumulativeSum2D(const vector<vector<T>>& v){
        int h = v.size(), w = v[0].size();
        dat.resize(h+1);
        for(int i = 0;i < h+1;i++) dat[i].resize(w+1);
        for(int i = 0;i < h;i++) for(int j = 0;j < w;j++) dat[i+1][j+1] = dat[i+1][j]+dat[i][j+1]-dat[i][j]+v[i][j];
    }
    //[x1, x2)×[y1, y2)
    inline T query(int x1, int x2, int y1, int y2) const {
        return dat[y2][x2]-dat[y2][x1]-dat[y1][x2]+dat[y1][x1];
    }
};


int H, W, K;
CumulativeSum2D<int> s;


int msum(int x1, int x2, int bit){
    int m = 0;
    int pre = 0;
    rep(i, 0, H-1) if((bit>>i)&1) chmax(m, s.query(x1, x2, pre, i+1)), pre = i+1;
    return max(m, s.query(x1, x2, pre, H));
}


signed main(){
    cin >> H >> W >> K;
    vector<vector<int>> v(H, vector<int>(W));
    rep(i, 0, H){
        string S;
        cin >> S;
        rep(j, 0, W) v[i][j] = S[j]-'0';
    }

    s = CumulativeSum2D<int>(v);

    int ans = INF;
    rep(i, 0, 1<<(H-1)){
        int c = __builtin_popcount(i);
        int pre = 0;
        while(pre < W){
            int l = pre+1, r = W+1;
            while(r-l > 1){
                int m = l+(r-l)/2;
                if(msum(pre, m, i) <= K) l = m;
                else r = m;
            }
            if(msum(pre, l, i) <= K) c++;
            else { c = INF; break; }
            pre = l;
        }
        chmin(ans, c-1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define fs first
#define sc second

int main(){
    int N, T;
    cin >> N >> T;
    pair<int, int> p[N];
    for(int i = 0; i < N; i++) cin >> p[i].fs >> p[i].sc;
    sort(p, p + N);

    int dp[10000];
    fill(dp, dp + 10000, 0);
    dp[0] = 1;
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = T - 1; j >= 0; j--){
            if(dp[j] != 0){
                dp[j + p[i].fs] = max(dp[j + p[i].fs], dp[j] + p[i].sc);
            }
        }
    }

    for(int i = 0; i < 10000; i++) ans = max(ans, dp[i] - 1);

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


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	ll res=numeric_limits<ll>::max();
	for(int i=0,j=k-1;j<n;++i,++j)
		res=min(res,min(abs(a[i]),abs(a[j]))+abs(a[i]-a[j]));
	cout<<res<<'\n';
}



Measured memory_bytes: 3988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	int f = max(a, max(b, max(c, max(d, e))));
	int g = min(a, min(b, min(c, min(d, e))));
	if (f - g > k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'A'){
      cnt++;
    }
  }
  if(cnt == 3 || cnt == 0){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

/*
動作確認
*/


class Program
{

	//Main
	static void Main(string[] args)
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());

		//バケツ（順に、 AC, WA, TLE, RE）
		int[] bucket = new int[4];

		//読み込む
		for(int i=0; i<N; i++){
			string S = Console.ReadLine();
			if(S == "AC"){
				bucket[0] ++;
			}
			else if(S == "WA"){
				bucket[1] ++;
			}
			else if(S == "TLE"){
				bucket[2] ++;
			}
			else{
				bucket[3] ++;
			}
		}

		Console.WriteLine("AC x {0}",bucket[0]);
		Console.WriteLine("WA x {0}",bucket[1]);
		Console.WriteLine("TLE x {0}",bucket[2]);
		Console.WriteLine("RE x {0}",bucket[3]);
	}
}



Measured memory_bytes: 20784
import Data.List
main = do
 ss<-getLine
 t<-getLine
 let ls = length ss
 let lt = length t
 let candi = [f ss t k| k<-[0..ls-lt]]
 let candi2 = filter (g ss) candi
 putStrLn $ if null candi2 then "UNRESTORABLE" else head $ sort $ map h candi2
 
f x y k = (take k x) ++ y ++ (drop (k + length y) x)
g [] [] = True
g (x:xs) (y:ys) = ((x == y) || (x == '?')) && g xs ys
h [] = []
h (x:xs)
    |x=='?' = 'a':(h xs)
    |otherwise = x:(h xs)


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
void solve(){
  int n,k,d,r; cin >> n >> k;
  int A[n+1]={0};
  for(int i=0;i<k;i++){
     cin>>d;
     for(int i=0;i<d;i++){
        cin>>r;
        A[r]++;
     }
  }
  int c=0;
  for(int i=1;i<=n;i++){
    if(A[i]==0)
       c++;
  }
  cout<<c;

}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


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

int main()
{
	int n;
	scanf("%d",&n);
	ll ans = 0;
	for(int i = 1 ; i <= n ; i++)
	{
		for(int j = 1 ; j <= n ; j++)
		{
			for(int k=  1 ; k <= n ; k++)
			{
				ans += __gcd(i,__gcd(k,j));
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

ll d[2222][2222];

void Main() {
  ll n,s,t;
  cin >> n >> s >> t;
  s--,t--;
  vector<ll> v[n];
  rep(i,n-1) {
    v[i].pb(i+1);
    v[i+1].pb(i);
  }
  v[s].pb(t);
  v[t].pb(s);
  rep(k,n) {
    fill(d[k],d[k]+n,MAX);
    d[k][k]=0;
    queue<int> que;
    que.push(k);
    while(!que.empty()) {
      int x=que.front();que.pop();
      rep(i,v[x].size()) {
        int y=v[x][i];
        if(d[k][y]==MAX) {
          d[k][y]=d[k][x]+1;
          que.push(y);
        }
      }
    }
  }
  ll c[n];
  mem(c);
  rep(i,n) {
    REP(j,i+1,n) c[d[i][j]]++;
  }
  REP(i,1,n) pr(c[i]);
}

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


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

int main() {
  int N,K;
  cin >> N >> K;
 
  
  vector<int> trick(N);
  
  for (int i = 0;i < K;i++){
  int d;
  cin >> d;
  vector<int> treat(d);
  for(int j = 0;j < d;j++){
    cin >> treat.at(j);
  }
  for(int j = 0;j < d;j++){
    int k = treat.at(j) - 1;
    trick.at(k) = 1;
  }
  }
  
  
  int count = 0;
  
  for (int i = 0;i < N;i++){
    if (trick.at(i) == 0){
      count++;
    }
  }
  
  cout << count << endl;
  
  
}


Measured memory_bytes: 3604
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


int main(){

    int N;
    cin >> N;
    vll A(N);
    ll mx = 0;
    ll cnt1 = 0;
    REP(i, N){
        cin >> A[i];
        if (A[i] == 1) cnt1++;
        chmax(mx, A[i]);
    }

    if(cnt1 == 1){
        cout << 1 << endl;
        return 0;
    } else if (cnt1 > 1){
        cout << 0 << endl;
        return 0;
    }

    vll B(mx + 1, 0);
    for (ll a: A){
        ll i = a;
        while(i <= mx){
            B[i]++;
            i += a;
        }
    }

    ll ans = 0;
    for (ll a: A){
        if (B[a] == 1) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12608
//     . .. ... .... ..... be name khoda ..... .... ... .. .     \\

#include <bits/stdc++.h>
using namespace std;

inline int in() { int x; scanf("%d", &x); return x; }
const int N = 2002;

string get(int i)
{
	cout << i << endl;
	fflush(stdout);
	string x;
	cin >> x;
	if(x == "Vacant")
		exit(0);
	return x;
}

int main()
{
	int n;
	cin >> n;
	int L = 0, R = n;
	string first = get(0);
	string last = get(n - 1);
	while(1)
	{
		assert((R - L) % 2);
		int mid = (R+L)/2;
		if((mid - L) % 2 && R - L > 3)
			mid++;
		string midString = get(mid);
		if(midString == first)
			L = mid;
		else
			R = mid + 1;
	}
}


Measured memory_bytes: 852
package main

import (
    "fmt"
)

func back(b []int) ([]int, bool) {
    if len(b) == 1 {
        if b[0] == 1 {
            return []int{1}, true
        } else {
            return []int{}, false
        }
    }
    for i := len(b) - 1; i >= 0; i-- {
        v := b[i]
        if i + 1 == v {
            var procedure []int
            var is_able bool
            if i == 0 {
                procedure, is_able = back(b[1:])
            } else {
                procedure, is_able = back(append(b[:i], b[i + 1:]...))
            }
            if is_able {
                return append(procedure, v), true
            } else {
                return []int{}, false
            }
        }
    }
    return []int{}, false
}

func main() {
    N := scanInt()
    b := scanInts(N)
    procedure, is_able := back(b)
    if is_able {
        for _, v := range procedure {
            fmt.Println(v)
        }
    } else {
        fmt.Println(-1)
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

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

int main() {
    int n, m;
    cin >> n;
    map<int, int> d;
    rep(i,n) {
        int di;
        cin >> di;
        if (!d.count(di)) d[di] = 1;
        else d.at(di)++;
    }
    cin >> m;
    rep(i,m) {
        int ti;
        cin >> ti;
        if (d.count(ti) && 0 < d.at(ti)) d.at(ti)--;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 13036
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
typedef pair<double,double> pdd;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}


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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;

    int a[n];
    inp_arr(a,n);

    int maxi = a[0];

    int ans = 1;
    for(int i=1;i<n;++i) {
        int f = 0;
        for(int j=0;j<i;++j) {
            if(a[j] > a[i]) {
                f = 1;
                break;
            }
        }
        if(!f)
            ++ans;
    }   

    cout<<ans;


    return 0;
}

Measured memory_bytes: 256
//A
#include <iostream>
using namespace std;
int R;
int main(){
  cin >> R;
  if(R < 1200){
    cout << "ABC"  << endl;
  }else if (R < 2800) {
    cout << "ARC" << endl;
  }else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	long long cnt,b[N],c[N];
	cnt = 0;
	for (int i = 0; i < N; i++) {
		b[i] = a[i];
		c[i] = 0;
		while (b[i] % 2 == 0) {
			cnt++;
			c[i]++;
			b[i] = b[i] / 2;
		}
	}
	if (cnt == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << cnt << endl;
	//for (int i = 0; i < N; i++) {
	//	b[i] = a[i];
	//	while (a[i] % 2 == 0) {
	//		cnt++;
	//		b[i] = b[i] / 2;
	//	}
	//}
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<double, double> PD;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

vector<PD> cli(double a, double b, double c, PD c1) {
  double l = a * a + b * b, k = a * c1.fi + b * c1.se + c, d = l - k * k;
  vector<PD> v;
  if (d > 0) {
    double ds = sqrt(d), apl = a / l, bpl = b / l;
    double xc = c1.fi - apl * k, xd = bpl * ds, yc = c1.se - bpl * k, yd = apl * ds;
    v.pb(PD(xc - xd, yc + yd)), v.pb(PD(xc + xd, yc - yd));
  } else if (d == 0) {
    v.pb(PD(c1.fi - a * k / l, c1.se - b * k / l));
  }
  return v;
}

vector<PD> cci(PD c1, PD c2) {
  double a = c1.fi - c2.fi, b = c1.se - c2.se;
  return cli(2.0 * a, 2.0 * b, 0 - a * (c1.fi + c2.fi) - b * (c1.se + c2.se), c1);
}

bool dist(PD p1, PD p2) {
  return (pow(p1.fi - p2.fi, 2.0) + pow(p1.se - p2.se, 2.0)) <= 1.0 + 1e-7;
}

int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    vector<PD> v(n);
    rep(i, n) cin >> v[i].fi >> v[i].se;

    int maxi = 1;
    rep(i, n - 1)repl(j, i + 1, n) {
      vector<PD> p = cci(v[i], v[j]);
      rep(k, p.size()) {
        int cnt = 0;
        rep(l, n) {
          if (dist(p[k], v[l])) cnt++;
        }
        maxch(maxi, cnt);
      }
    }

    cout << maxi << endl;
  }

  return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

bool can_change_a(char ch, int count) {
  int num = 26 - (ch - 'a');
  // cout << "num" << num << "k" << count << endl;
  if (num > count) {
    return false;
  } else {
    return true;
  }
}

int main() {
  string s;
  int k;

  cin >> s >> k;

  REP(i, s.size()) {
    if (s[i] == 'a') continue;
    if (can_change_a(s[i], k)) {
      k -= 26 - (s[i] - 'a');
      s[i] = 'a';
    }
  }

  k = k % 26;
  s[s.size() - 1] = s[s.size() - 1] + k;

  ANS(s);

  return 0;
}


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

int main(void){

  long long int min_h=INT32_MAX, N, K, h[100000];

  cin >> N >> K;
  for(int i=0; i<N; i++)
    cin >> h[i];
  sort(h, h+N);

  for(int i=0; i<N-K+1; i++)
    if(h[i+K-1]-h[i] < min_h) min_h = h[i+K-1]-h[i];

  cout << min_h << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int a[111111],b[111111],c[111111];
int main()
{
	int n=io::F(); 
	for(register int i=1;i<=n;++i)a[i]=io::F();
	for(register int i=1;i<=n;++i)b[i]=io::F();
	for(register int i=1;i<=n;++i)c[i]=io::F();
	std::sort(a+1,a+n+1);
	std::sort(b+1,b+n+1);
	std::sort(c+1,c+n+1);
	long long ans=0;
	for(register int i=1;i<=n;++i)
	{
		int c1=std::lower_bound(a+1,a+n+1,b[i])-a-1;
		int c2=n+c-std::upper_bound(c+1,c+n+1,b[i])+1;
		ans+=(long long)c1*c2;
	}
	printf("%lld\n",ans);
	return 0;
}



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

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[n];
    for(int i=0;i<n;i++)
    	dp[i]=INT_MAX;
    dp[0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=i&&j<=k;j++){
         
		dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
	}
    
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll a[N];
  ll sum=0;
  for(ll i=0;i<N;i++){
    cin >> a[i];
    sum ^= a[i];
  }
  for(ll i=0;i<N;i++){
    cout << ll(sum ^ a[i]) << endl;
  }
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll n, k;
  cin >> n >> k;

  if (n == k || n == 0) {
    puts("0");
    return 0;
  }

  ll ans = n;

  if (n > k) {
    n -= (n/k) * k;
  }

  chmin(ans, n);

  for (int i = 0; i < 100; i++) {
    n = abs(n - k);
    chmin(ans, n);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = []
res = []

for i in range(N):
    S = input()
    L.append(S)

L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Measured memory_bytes: 120668
N = int(input())

x = []
u = []

for i in range(N):
    X, U = input().split()
    x.append(float(X))
    u.append(U)

s = 0

for i in range(N):
    if u[i] == "JPY":
        s += x[i]
    elif u[i] == "BTC":
        s += x[i] * 380000

print(s)


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

struct Card{
  char c;
  int n;
};

bool IsStable(Card A1[], Card A2[],int n) {
  for (int i = 0; i < n; i++) if (A1[i].c != A2[i].c) return false;
  return true;
}

void Marge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  static Card L[100001], R[100001];
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].n = 1000000001; R[n2].n = 1000000001;

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i].n <= R[j].n) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void MargeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    MargeSort(A, left, mid);
    MargeSort(A, mid, right);
    Marge(A, left, mid, right);
  }
}

int Partition(Card A[], int p, int r) {
  int x = A[r].n;
  int i = p - 1;

  for (int j = p; j < r; j++) {
    if (A[j].n <= x) {
      i++;
      Card swap = A[i]; A[i] = A[j]; A[j] = swap;
    }
  }
  Card swap = A[i + 1]; A[i + 1] = A[r]; A[r] = swap;

  return i + 1;
}

void QuickSort(Card A[], int p, int r) {
  if (p < r) {
    int q = Partition(A, p, r);
    QuickSort(A, p, q - 1);
    QuickSort(A, q + 1, r);
  }
}

int main() {
  int n; cin >> n;
  static Card A1[100000], A2[100000]; for (int i = 0; i < n; i++) cin >> A1[i].c >> A1[i].n;
  for (int i = 0; i < n; i++) A2[i] = A1[i];

  QuickSort(A1, 0, n - 1);
  MargeSort(A2, 0, n);

  bool s = IsStable(A1, A2, n);

  if (s) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  for (int i = 0; i < n; i++) cout << A1[i].c << " " << A1[i].n << endl;

  return 0;
}


Measured memory_bytes: 5428
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e18;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if(c%gcd(a,b)==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  for(int i = 1; ; i++){
    if(i * i > n){
      cout << (i - 1) * (i - 1) << endl;
      return;
    }
  }

  cout << ans << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

int dp[55][55][55];
int ar[55];
int n;

int serc(int x, int l, int r) {
  if (x == n) {
    return 1000000;
  }
  int &ret = dp[x][l][r];
  if (ret != -1) {
    return ret;
  }
  ret = 0;

  // ambil ke kanan
  ret = max(ret, min(serc(x + 1, l, x), min(ar[x] - ar[r], 24 - ar[l] - ar[x])));

  // ambil ke kiri
  ret = max(ret, min(serc(x + 1, x, r), min(ar[x] - ar[l], 24 - ar[r] - ar[x])));
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
  n++;
  sort(ar, ar + n);
  printf("%d\n", min(max(serc(2, 0, 1), serc(2, 1, 0)), ar[1] - ar[0]));
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1'000'000'007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n, m;
	cin >> n >> m;
	vecb is_not_broken(n + 1, true);
	for (size_t i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		is_not_broken[tmp] = false;
	}
	vecll dp(n + 1, 0);
	dp[0] = 1;
	if (is_not_broken[1])
		dp[1] = 1;
	for (size_t i = 2; i <= n; i++)
	{
		if (is_not_broken[i - 1])
			dp[i] += dp[i - 1];
		if (is_not_broken[i - 2])
			dp[i] += dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() 
{
	int i, j;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
        			cout << i << 'x' << j << '=' << i * j << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3056
from __future__ import division
import math

a, b, C = map(int, raw_input().split())
S = a * b * math.sin(math.radians(C)) / 2
c = math.sqrt((a**2 + b**2 -2*a*b*math.cos(math.radians(C))))
L = a + b + c
h = b * math.sin(math.radians(C))

for i in S, L, h:
    print "{:.5f}".format(i)

Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool flag = true;
  while (a > 0 || c > 0) {
    c -= b;
    if (c <= 0) break;
    a -= d;
    if (a <= 0) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> nums(n);
  for (int i = 0; i < n; i++){
    cin >> nums.at(i);
  }
  int swap = 0;
  for (int i = 0; i < nums.size(); i++){
    if (i + 1 != nums[i]){
      if (i + 1 != nums[nums[i] - 1]){
        cout << "NO" << endl;
        return 0;
      }else{
        iter_swap(&nums[i], &nums[nums[i] - 1]);
        swap += 1;
      }
    }
  }

  if (swap == 0 || swap == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  // vector<int> a = {1,2,3,4,5};
  // iter_swap(&a[1], &a[3]);
  // for (int i = 0; i < a.size(); i++){
  //   /* code */
  //   if (i == a.size() - 1){
  //     cout << a[i] << endl;
  //     break;
  //   }
    
  //   cout << a[i] << " ";
  // }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int str1 = scan.nextInt();
		int str2 = scan.nextInt();
		System.out.println(str1 * str2 + " " + (str1 * 2 + str2 * 2));
	}
}

Measured memory_bytes: 17160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const long long mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        int f = 0,l = 0;
        for(int j = 0; j < 2; j++){
            string s; cin >> s;
            for(int k = 0; k < s.size(); k++){
                int tmp = 1;
                if(s[k] > '0' && s[k] <= '9'){
                    tmp = s[k] - '0';
                    if(s[k+1] == 'm' && k+1 < s.size()) tmp *= 1000;
                    if(s[k+1] == 'c' && k+1 < s.size()) tmp *= 100;
                    if(s[k+1] == 'x' && k+1 < s.size()) tmp *= 10;
                    if(s[k+1] == 'i' && k+1 < s.size()) tmp *= 1;
                    if(j==0) {f += tmp;}
                    else {l += tmp;}
                    k++;
                }else{
                    if(s[k] == 'm') tmp *= 1000;
                    if(s[k] == 'c') tmp *= 100;
                    if(s[k] == 'x') tmp *= 10;
                    if(s[k] == 'i') tmp *= 1;
                    if(j==0) {f += tmp;}
                    else {l += tmp;}
                }
            }
        }
        int sum = l+f;
        string ans;
        if(sum >= 2000){
            ans += ('0' + (sum / 1000));
            ans += 'm';
            sum %= 1000;
        }else if(sum >= 1000){
            ans += 'm';
            sum %= 1000;
        }
        if(sum >= 200){
            ans += ('0' + (sum/100));
            ans += 'c';
            sum %= 100;
        }else if(sum >= 100){
            ans += 'c';
            sum %= 100;
        }
        if(sum >= 20){
            ans += ('0' + (sum/10));
            ans += 'x';
            sum %= 10;
        }else if(sum >= 10){
            ans +=  'x';
            sum %= 10;
        }
        if(sum >= 2){
            ans += ('0'+sum);
            ans += 'i';
        }else if(sum >= 1){
            ans += 'i';
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
#include <iostream>

using namespace std;
using llong = long long;

llong A[5000];
llong P[5001];
int main(){
  int n;
  while(cin >> n&&n>0){
    for(int i=0;i<n;++i){
      cin >> A[i];
    }

    for(int i=1;i<=n;++i){
      P[i] = P[i-1] + A[i-1];
    }

    llong maxsum = -1000000000000;
    for(int i=0;i<n;++i){
      for(int j=i+1;j<=n;++j){
        if(P[j]-P[i]>maxsum){
          maxsum = P[j] - P[i];
        }
      }
    }
    cout << maxsum << endl;
  }
  return 0;
}

Measured memory_bytes: 3000
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion


#include <stdio.h>

#include<stdio.h>

static char s[200001][11];

int main(void)
{
	int  n, i, j = 1;

	i_cin(n);
	for (i = 0; i < n; i++) {
		s_cin(s[i]);
	}

	printf("\n");
	
	
	qsort(s, n, sizeof(s[0]), s_asorts);

	for (i = 1; i < n; i++) {
		if (!strcmp(s[i],s[i - 1])) continue; 
		j++;
	}
	i_cout(j);
	
	return 0;
}



Measured memory_bytes: 5740
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int dp[N], a[N], n, k;

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        dp[i] = 1e9;
    }
    
    dp[0] = dp[1] = 0;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= k; j++){
            if(j > i - 1)break;
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
            
        }
    }
    printf("%d\n", dp[n]);
}

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

using namespace std;

int main(){
	int n,d;
	cin >> n >> d;
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int x,y; cin >> x >> y;
		if( 1ll * d *  d >= 1ll * x * x + 1ll * y * y) ++cnt;
	}
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3644
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto x = readln.chomp.split.to!(int[]);
  if (x[0]+x[1]<x[2]) {
    writeln("No");
  } else {
    writeln("Yes");
  }
}


Measured memory_bytes: 256
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair< int, pair<int, int> >
#define plpll pair< ll, pair<ll, ll> >

const int maxn = 2005;
vector <int> aj[maxn];
int h[maxn];

void clr(){
    for(int i = 0; i < maxn; i ++)
        h[i] = -1;
}

void dfs(int v){
    for(int i = 0; i < SZ(aj[v]); i ++){
        int u = aj[v][i];
        if(h[u] == -1){
            h[u] = h[v] + 1;
            dfs(u);
        }
    }
    return;
}

int32_t main(){
    int n, k, ans = 2005;
    cin >>n >>k;
    for(int i = 0; i < n - 1; i ++){
        int u, v;
        cin >>u >>v;
        u --;
        v --;
        aj[u].pb(v);
        aj[v].pb(u);
    }
    if(k & 1){
        for(int v = 0; v < n; v ++){
            for(int j = 0; j < SZ(aj[v]); j ++){
                clr();
                int u = aj[v][j];
                h[u] = 0;
                h[v] = 0;
                dfs(u);
                dfs(v);
                int cn = 0;
                for(int i = 0; i < n; i ++){
                    if(h[i] > k/ 2)
                        cn ++;
                }
                xmin(ans, cn);
            }
        }
    }
    else{
        for(int i = 0; i < n; i ++){
            clr();
            h[i] = 0;
            dfs(i);
            int cn = 0;
            for(int j = 0; j < n; j ++){
                if(h[j] > k/ 2)
                    cn ++;
            }
            xmin(ans, cn);
        }
    }
    cout <<ans <<endl;
    return false;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int i, x;
	
	i = 0;
	while(i < 10000) {
	    scanf("%d", &x);
	    if(x == 0) {
	        break;
	    }
	    else {
	        printf("Case %d: %d\n", i + 1, x);
	        i++;
	    }
	}
	return 0;
}



Measured memory_bytes: 1968