akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int x, a, b, c;

	cin >> a >> b >> c >> x;

	int cnt = 0;
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) cnt++;
			}
		}
	}

	cout << cnt << endl;



	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  int h[1000000];
  int cot=0;
  cin >>n>>k;
  for(int i=0;i<n;++i)cin >> h[i];
  for(int i=0;i<n;++i){
    if(h[i]>=k)++cot;
  }
  cout << cot;
}

Measured memory_bytes: 2304
#include <iostream>

int main(int argc, char const *argv[])
{
    int A,B,K;
    std::cin>> A>>B>>K;
    int i;
    for( i = A < B ? A : B; K != 0; i--)
        if(A%i == 0 && B%i==0) K--;
    std::cout<<i+1<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    int n,m;
    cin>>n>>m;
    vvi v(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    rep(i,n){
        fin(v[i].size());
    }

        
}

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

int main() {
    int n,w;
    cin >> n >> w;
    vector<int> weight;
    vector<ll> value;
    for(int i=0; i<n; i++){
        ll a,b;
        cin >> a >> b;
        weight.push_back(a);
        value.push_back(b);
    }
    vector<vector<ll>> dp (n+1,vector<ll>(w+1));
    for(int i=0; i<n; i++){
        for(int j=0; j<w+1; j++){
            if(j - weight.at(i) >= 0){
                dp.at(i+1).at(j) = max(dp.at(i+1).at(j),dp.at(i).at(j-weight.at(i)) + value.at(i));
            }
            dp.at(i+1).at(j) = max(dp.at(i+1).at(j),dp.at(i).at(j));
        }
    }
    cout << dp.at(n).at(w);
}

Measured memory_bytes: 80256
using System;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
            int count =0;
            int zoromeCount = 0;
            while (true)
            { 
                
                string line = Console.ReadLine();
                // 読み込める文字列が無くなった
                if (line == null)
                {                 
                    break;
                }

                //初回はスキップ
                if (count==0)
                {count++;
                    continue;
                }

                //ゾロ目判定
                if (line[0] == line[2])
                {
                    zoromeCount += 1;
                }
                else
                {
                    zoromeCount = 0;
                }

                //ゾロ目３回連続以上で終了
                if (zoromeCount>=3)
                {
                    break;
                }

                
            }

            if (zoromeCount>=3)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");

            }
count++;
        }
    }
}


Measured memory_bytes: 25852
n=int(input())
ba,a,b,ab=0,0,0,0
for i in range(n):
    s=input()
    if s[0]=='B' and s[-1]=='A':
        ba+=1
    elif s[0]=='B':
        b+=1
    elif s[-1]=='A':
        a+=1
    for i in range(len(s)-1):
        if s[i]=='A' and s[i+1]=='B':
            ab+=1
if a==b and a==0 and ba!=0:
	ba-=1
print(min(a,b)+ba+ab)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {


	while (1) {
		int n, x;
		cin >> n >> x;
		if (!n && !x) break;

		int cnt = 0;
		//int a, b, c;

		for (int i = 1; i <= n; i++) {
			for (int j = i+1; j <= n; j++) {
				for (int l = j+1; l <= n; l++) {
					if (i + j + l == x) {
						cnt++; 
					}
				}
			}
		}
		cout << cnt << endl;
	}

	
	return 0;
}


Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, a[200007], res;

int main () {
    fastIO;
    cin >> n;
    for(li i = 1; i <= n; i ++) cin >> a[i];

    for(li i = n; i; i --) {
        for(li j = 2; j*i <= n; j++) {
            a[i]^=a[i*j];
        }
        res += a[i];
    }
    cout << res << "\n";
    for(li i = 1; i <= n; i ++) if(a[i]) cout << i << " ";
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#define mod (1000000007)
using namespace std;
long long ans=1;
string s1,s2;
int n;
void dfs(int x,int used)
{
	if(x==n) return;
	if(x==0)
	{
		if(s1[0]==s2[0]) {ans=3;dfs(1,1);}
		else {ans=6;dfs(2,2);}
		return;
	}
	if(s1[x]==s2[x])
	{
		ans*=(3-used);ans%=mod;
		dfs(x+1,1);
	}
	else
	{
		if(used==1) ans*=2;
		else ans*=3;
		ans%=mod;
		dfs(x+2,2);
	}
}
int main()
{
	cin>>n;
	cin>>s1;
	cin>>s2;
	dfs(0,0);
	printf("%lld\n",ans);
	return 0;
}

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

int n,q,nx,qx,a=0;
int x[10001];
int main(){
    cin >>n;
    for(int i=0;i<n;i++) cin >>x[i];
    cin >>q;
    for(int i=0;i<q;i++){
        cin>>nx;
        x[n]=nx;
        for(qx=0;x[qx]!=nx;qx++);
            if(qx!=n) a++;
    }
    cout << a <<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

void upd(int &x, int y) {
	x = std::min(x, y);
}

int input() {
	int n;
	std::cin >> n;
	return n;
}

int main() {
	int n, m;
	std::cin >> n >> m;

	static int g[15][15];
	for (int i = 0; i < m; i++) {
		int u = input() - 1;
		int v = input() - 1;
		int w = input();
		g[u][v] = w;
		g[v][u] = w;
	}

	static int dp[1 << 15][15];
	for (int i = 0; i < 1 << 15; i++) {
		for (int j = 0; j < 15; j++) {
			dp[i][j] = 1e9;
		}
	}

	for (int i = 0; i < 1 << n; i++) {
		if ((i >> 0 & 1) && (~i >> (n - 1) & 1)) {
			dp[i][0] = 0;
		}
	}

	static int score[1 << 15][15];

	for (int i = 0; i < 1 << n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if ((i >> k & 1) && g[j][k] != 0) {
					score[i][j] += g[j][k];
				}
			}
		}
	}

	int ls[15];

	for (int i = 0; i < 1 << n; i++) {
		int k = ((1 << n) - 1) ^ i;
		int j = k;
		do {
			int cost = 0;
			for (int u = 0; u < n; u++) {
				if ((i >> u & 1)) {
					cost += score[j][u];
				}
			}

			int ptr = 0;
			for (int u = 0; u < n; u++) {
				if (j >> u & 1) {
					ls[ptr++] = u;
				}
			}

			for (int u = 0; u < n; u++) {
				if ((~i >> u & 1)) continue;
				for (int p = 0; p < ptr; p++) {
					int v = ls[p];
					if ((j >> v & 1) && g[u][v] != 0) {
						upd(dp[i | j][v], dp[i][u] - g[u][v] + cost);
					}
				}
			}
			j = (j - 1) & k;
		} while (j != 0);
	}

	std::cout << dp[(1 << n) - 1][n - 1] << std::endl;
}


Measured memory_bytes: 4224
n = int(input())
list_H = list(map(int, input().split()))
max_value = max(list_H)
list_K = [[0]*n for _ in range(max_value)]
for i in range(max_value):
    l = list_K[i]
    for j in range(n):
        if list_H[j] > i:
            l[j] = 1

ans = []
for i in range(len(list_K)):
    cnt = 0
    l = list_K[i]
    l.append(0)
    for j in range(n):
        if l[j] == 1 and l[j+1] == 0:
            cnt += 1
    ans.append(cnt)

print(sum(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  cout<<x2-(y2-y1)<<" "<<y2+x2-x1<<" "<<x1-(y2-y1)<<" "<<y1+x2-x1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define FOR for(int i=1; i<=n; ++i)

int main() {

    string s;
    cin>>s;

    int n = s.length();

    ll sum = 0LL;

    for(int i=0; i<n; ++i) {
        sum += (s[i] - 48);
    }

    if(sum%9 == 0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
}




Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

char S[10];
int N,i,k;

int main()
{
  cin >> N >> S;
  

  k=0;
  if(N%2==1)
  {
    k=1;
  }
  else
  {
    for(i=0;i<N/2;i++)
    {
      if(S[i]!=S[i+N/2])
      {
        k=1;
      }
    }
  }
  
  if(k==1) cout <<"No";
  else cout <<"Yes";

  
  
 return 0; 
}

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

namespace abc164
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var set = new HashSet<string>();
            for (var i = 0; i < n; ++i)
            {
                var s = Console.ReadLine();
                if (!set.Contains(s))
                {
                    set.Add(s);
                }
            }
            Console.WriteLine(set.Count);
        }
    }
}


Measured memory_bytes: 43092
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;
    deque<int> A(N);
    vector<P> C(M);
    for(int i=0; i<N; ++i) cin >> A[i];
    for(int i=0; i<M; ++i) cin >> C[i].second >> C[i].first;
    sort(begin(A), end(A));
    sort(begin(C), end(C), greater<P>());
    
    long long res = 0;
    int l = 0, r = N - 1;
    for(int i=0; i<M; ++i) {
        int c = C[i].first;
        int b = C[i].second;
        while(l <= r) {
            if(A[r] >= c) {
                res += A[r];
                --r;
            } else {
                break;
            }
        }
        while(b > 0 && l <= r) {
            res += c;
            ++l;
            --b;
        }
        if(r < l) break;
        if(i + 1 == M) {
            for(int i=l; i<=r; ++i) res += A[i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

LLI knapsack_small_weight(int N, int cap, const vector<LLI> &w, const vector<LLI> &v){
  vector<vector<LLI>> dp(N+1, vector<LLI>(cap+1));

  REP(i,N){
    REPE(j,cap){
      chmax(dp[i+1][j], dp[i][j]);
      if(j+w[i]<=cap) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
    }
  }
  
  return dp[N][cap];
}


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

  int N, W; cin >> N >> W;
  vector<LLI> w(N), v(N);
  REP(i,N) cin >> w[i] >> v[i];

  LLI ans = knapsack_small_weight(N,W,w,v);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
int main(){
  int n;
  char *p,s[32];
  while(scanf("%d",&n),n){
    sprintf(s,"%o",n);
    for(p=s;*p;++p)if(*p>'4')*p+=2;else if(*p>'3')*p+=1;
    puts(s);
  }
  return 0;
}

Measured memory_bytes: 620
(defun substAbs (s)
  (abs (- (parse-integer (subseq s 0 3)) 753)))

(defun minSubst (s &optional (mins 10000))
   (if (< 2 (length s))
       (minSubst (subseq s 1 (length s))
                 (min mins (substAbs s)))
       mins))

(format t "~a~%" (minsubst (read-line)))


Measured memory_bytes: 3812
#include <iostream>

using namespace std;

int main(void) {
    int n, h = 0, m = 0, s = 0;
    cin >> n;
    s = n%60;
    m = n/60;
    h = m/60;
    m = m - (h*60);
    cout << h << ":" << m << ":" << s << endl;
}


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

using namespace std;

void usain_bolt()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
}

const int N = 3e3 + 5;

double a[N], dp[N][N];

int main()
{
    usain_bolt();

    int n;

    cin >> n;;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    dp[0][0] = 1.0;
    for(int i = 1; i <= n; ++i) dp[i][0] = dp[i - 1][0] * (1.0 - a[i]);
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= i; ++j) {
            dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1.0 - a[i]);
        }
    }
    double sol = 0;
    for(int i = n / 2 + 1; i <= n; ++i) sol += dp[n][i];
    cout << fixed << setprecision(10) << sol;
    return 0;
}


Measured memory_bytes: 69120
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;

// watch this
//using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 200010;

int main(int argc, char** argv) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#endif

	long long A,B,C;
	cin>>A>>B>>C;
	cout<<B + min(C,B + A + 1)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using ull = unsigned long long;
using namespace std;

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

bool cmp_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void){

    int n;
    cin >> n;

    int d[n];
    FOR(i,0,n)cin >> d[i];

    sort(d, d+n);

    //cout << d[n/2+1] << ":" << d[n/2] << endl;
    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;

	vll a(N + 1);
	repn(i, N) cin >> a[i];

	ll x = 0;
	repn(i, N) x ^= a[i];

	repn(i, N) {
		cout << (x ^ a[i]) << " ";
	}
	cout << endl;
}


Measured memory_bytes: 4820
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] h = new int[n];
        for(int i=0; i<n; i++){
            h[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(h);

        int min = Integer.MAX_VALUE;
        for(int i=0; i<n-k+1; i++){
            min = Math.min(min, h[i+k-1] - h[i]);
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 52140
from collections import defaultdict

red_num = int(input())

str_dict = {}
for i in range(red_num):
    str = input()
    str_dict[str] = str_dict.get(str, 0) + 1

blue_num = int(input())

for i in range(blue_num):
    str = input()
    str_dict[str] = str_dict.get(str, 0) - 1

result = max(str_dict.values())

if result >= 1:
    print(result)
else:
    print(0)

Measured memory_bytes: 3316
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector<int> d(n);
    rep(i, n){
        cin >> d[i];
    }

    SORT(d);

    int ans = d[n / 2] - d[n / 2 - 1];

    cout << ans << endl;

    return 0;
}

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

int main(){
    long long a, b;
    cin >> a >> b;

    if(a == b){
        if(a > 0) printf("Positive\n");
        else if(a == 0) printf("Zero\n");
        else printf("Negative\n");
    }
    else{
        if(a > 0) printf("Positive\n");
        else if(a == 0) printf("Zero\n");
        else if(a < 0 and b >= 0) printf("Zero\n");
        else if(a < 0 and b < 0){
            long long c = b - a + 1;
            if(c % 2 == 0) printf("Positive\n");
            else printf("Negative\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3576
def divisore(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(reverse=True)
    return divisors

n,m=map(int,input().split())
l=divisore(m)
for i in l:
 if m//n>=i:
  print(i)
  exit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{int n;
 cin>>n;
 cout<<a[n-1];
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  string S, T; cin >> S >> T;
  int A = S.size();
  int B = T.size();
  int min_ = 100000000;
  for (int i = 0; i < A - B + 1; i++){
    int count = 0;
    for (int j = 0; j < B; j++){
      if (S[i + j] != T[j]) count++;
    }
    min_ = min(min_, count);
  }
  cout << min_ << endl;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,m;
char s[10];
set<char> cant;

int main()
{
	scanf("%d%d",&n,&m);
	int c;
	for(int i=0;i<m;i++)
	{
		scanf("%d",&c);
		cant.insert(c+'0');
	}
	while(1)
	{
		sprintf(s,"%d",n);
		int can=1;
		for(int i=0;i<strlen(s);i++)
			if(cant.count(s[i]))
				can=0;
		if(can==1)return printf("%d\n",n),0;
		n++;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, k;
    cin >> n >> k;
    vector<pair<ll, int>> dt(n);
    map<int, int> mp;
    rep(i, n) {
        int t;
        ll d;
        cin >> t >> d;
        dt[i] = make_pair(d, t);
    }
    sort(dt.rbegin(), dt.rend());
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
    //priority_queue<pair<ll, int>> que;
    ll sum = 0;
    rep(i, k) {
        if (mp[dt[i].second] > 0) {
            que.push(dt[i]);
        }
        ++mp[dt[i].second];
        sum += dt[i].first;
    }
    ll ans = sum + (ll)(mp.size()) * (ll)(mp.size());
    for (int i = k; i < n; ++i) {
        if (mp[dt[i].second] > 0) continue;
        if(que.empty()) break;
        ll d = que.top().first;
        int t = que.top().second;
        que.pop();
        sum += dt[i].first - d;
        --mp[t];
        ++mp[dt[i].second];
        ans = max(ans, sum + (ll)(mp.size()) * (ll)(mp.size()));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8600
#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 x,y,z;
    cin >> x >> y >> z;
    cout << z << " "<<x <<" "<< y << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define INF (1e18)

int main(){   
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    ll dp[100010][4] = {};
    dp[0][0] = 1;
    rep(i,0,N){
        rep(j,0,4){
            if(S[i] == '?'){
                dp[i+1][j] += 3 * dp[i][j];
                if(j != 0) dp[i+1][j] += dp[i][j-1];
            }else{
                dp[i+1][j] += dp[i][j];
                if(j != 0 && S[i] == "ABC"[j-1]) dp[i+1][j] += dp[i][j-1];
            }
            dp[i+1][j] %= MOD;
        }
    }
    print(dp[N][3]);
}


Measured memory_bytes: 3664
n = int(input())
w=[]
w.append(input())
a = False
for i in range(n-1):
    w.append(input())
    if not(w[i][-1]==w[i+1][0] and sorted(w)==sorted(set(w))):
        print('No')
        a = True
        break
if a==False:
    print('Yes')

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N,A,B; cin>>N>>A>>B;
  vector<ll> X(N); rep(i,N)cin>>X.at(i);
  vector<ll> dp(N,INF);
  dp.at(0)=0;
  rep1(i,N){
    dp.at(i)=dp.at(i-1)+B;
    dp.at(i)=min(dp.at(i),dp.at(i-1)+((X.at(i)-X.at(i-1))*A));
  }
  cout<<dp.at(N-1)<<endl;
}

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

using namespace std;

long MOD = 1000000007;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for(int i=0; i<N; ++i){
        cin>>A[i];
    }
    for(int i=0; i<N; ++i){
        cin>>B[i];
    }
    for(int i=0; i<N; ++i){
        cin>>C[i];
    }
    long ans = B[N-1];
    for(int i=0; i<N-1; ++i){
        ans += B[i];
        cerr<<A[i]<<" "<<A[i+1]<<endl;
        if(A[i] + 1 == A[i+1]){
            ans += C[A[i]-1];
            cerr<<A[i]<<" "<<A[i+1]<<" "<<C[A[i]-1]<<endl;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

const int M = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% M + M) % M) {};
	void operator - () {
		x = (-x % M + M) % M;
	}
	void operator += (const mll& a) {
		if ((x += a.x) >= M) x -= M;
	}
	void operator ++ () {
		*this += 1;
	}
	void operator ++(int) {
		operator++();
	}
	void operator -= (const mll& a) {
		if ((x += M - a.x) >= M) x -= M;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= M;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator - (const mll& a) const {
		mll ans = *this;
		ans -= a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	bool operator < (const mll& a) {
		return this->x < a.x;
	}
	void pow(long long& n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % M;
			xx = xx * xx % M;
			n >>= 1;
		}
	}
	mll inv() {
		long long a = x, b = M, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= M;
		if (u < 0) u += M;
		a = u;
		return mll(a);
	}
};

int main() {
	long long N, K;
	cin >> N >> K;
	mll ans = 0;
	for (int i = K; i <= N + 1; i++) ans += (N + N - i + 1 - i + 1) * i / 2 + 1;
	cout << ans.x << endl;
}


Measured memory_bytes: 3624
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y


def main():
    n = II()
    tt = [MII() for _ in range(n-1)]
    for i in range(n):
        t = 0
        for c, s, f in tt[i:]:
            # 待ち時間の計算
            if t <= s:
                t = s
            elif t%f == 0:
                pass
            else:
                t += f - (t%f)
            # 電車移動時間を加算
            t += c
        print(t)


if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

ll DPX[10010][110];
ll DPY[10010][110];

int main(){
    string K;
    cin >> K;
    int D;
    cin >> D;
    int N = K.size();

    DPX[0][0] = 1;
    REP(i,N){
        int d = K[i] - '0';

        REP(j,D){
            DPX[i+1][(j+d)%D] += DPX[i][j];
            DPX[i+1][(j+d)%D] %= MOD;

            REP(k,10){
                DPY[i+1][(j+k)%D] += DPY[i][j];
                DPY[i+1][(j+k)%D] %= MOD;
            }

            REP(k,d){
                DPY[i+1][(j+k)%D] += DPX[i][j];
                DPY[i+1][(j+k)%D] %= MOD;
            }
        }
    }

    ll ans = 0;
    ans += DPX[N][0];
    ans %= MOD;
    ans += DPY[N][0];
    ans %= MOD;
    ans -= 1;
    ans += MOD;
    ans %= MOD;

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


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> v;
    while(n--){
        int a,b;cin>>a;
        if(a==0){
            cin>>b;
            v.push_back(b);
        }
        if(a==1){
            cin>>b;
            cout<<v[b]<<endl;
        }
        if(a==2)v.pop_back();
    }
    return 0;
}


Measured memory_bytes: 3844
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
using namespace std;
const static int NMAX = 100;
const static int VMAX = 2000;
const static int INF = VMAX + 1;
int n, G[NMAX][NMAX];

// prim's algorithm for Minimum Spanning Tree (MST)
int prim() {
	bool state[NMAX];
	int distance[NMAX];
	for (int i = 0; i < n; i++) {
		state[i] = false;
		distance[i] = INF;
	}
	distance[0] = 0;

	while (true) {
		int u, mincost = INF;
		for (int i = 0; i < n; i++) {
			if (!state[i] && (distance[i] < mincost)) {
				u = i;
				mincost = distance[i];
			}
		}
		if (mincost == INF)	break;
		state[u] = true;

		for (int i = 0; i < n; i++) {
			if (!state[i] && (G[u][i] < distance[i])) {
				distance[i] = G[u][i];
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (distance[i] != INF) sum += distance[i];
	}

	return sum;
}

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> G[i][j];
			if (G[i][j] == -1) G[i][j] = INF;
		}
	}

	cout << prim() << endl;

	return 0;
}


Measured memory_bytes: 3072
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    cin >> n;
    cout << (800*n) -(200 * (n/15) ) << endl; 
    return 0;
}

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

const int INF = 1000000000;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<int> cost(n, INF);
  cost[0] = 0;
  for (int i = 1; i < n; i++) {
    chmin(cost[i], cost[i - 1] + abs(h[i] - h[i - 1]));
    if (i >= 2) {
      chmin(cost[i], cost[i - 2] + abs(h[i] - h[i - 2]));
    }
  }
  cout << cost[n - 1] << '\n';
  return 0;
}

Measured memory_bytes: 1024
def main():

    N = int(input())
    count = [[] for i in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        count[a-1].append(b-1)
        count[b-1].append(a-1)

    max_l = 0
    max_i = -1
    for i in range(N):
        if len(count[i]) > max_l:
            max_l = len(count[i])
            max_i = i

    c = list(map(int, input().split()))
    c.sort(reverse = True)
    # print(c)

    cur = [max_i]
    val = [0 for _ in range(N)]
    i = 0
    val[max_i] = c[i]
    i += 1
    ans = 0
    while cur:
        temp = []
        for j in cur:
            for k in count[j]:
                if val[k] == 0:
                    val[k] = c[i]
                    ans += c[i]
                    i += 1
                    temp.append(k)
        cur = temp

    print(ans)
    print(" ".join(map(str, val)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 50776
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);

        var li = new List<Point>();
        spl   = input.ReadLine().Split(' ');

        for (int i=0; i<m; i++) {
            li.Add(new Point {
                x = int.Parse(spl[i])
            });
        }

        //距離算定
        li.Sort((x, y) => x.x.CompareTo(y.x));

        for(int i=0; i<m; i++) {
            li[i].left = i == 0 ? int.MaxValue : li[i].x - li[i - 1].x;
        }

        //遠い場所優先配置
        li.Sort((x, y) => y.left.CompareTo(x.left));

        for(int i=0; i< Math.Min(n,m); i++) {
            li[i].piece = true;
        }

        var c = 0L;
        foreach(var p in li) {
            if (!p.piece) c += p.left;
        }

        return c;
    }

    class Point
    {
        public int x;
        public int left;
        public bool piece;
    }
}

Measured memory_bytes: 26844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int cnt=0;
	rep(i,n){
		if(a.at(i)!=i+1) cnt++;
	}
	if(cnt==2 || cnt==0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef int ll;
using namespace std;
#define MAXN 30000
#define MOD 1000000007
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v, y;


ll b[200500];
ll a[200500];


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m >> x >> y;
    swap(x, y);
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            cout << 0;
        }
        for (int j = 0; j < m-y; j++) {
            cout << 1;
        }
        cout << "\n";
    }

    for (int i = 0; i < n-x; i++) {
        for (int j = 0; j < y; j++) {
            cout << 1;
        }
        for (int j = 0; j < m-y; j++) {
            cout << 0;
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 1280
#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 n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    if((n-1)%(k-1)!=0)cout<<(n-1)/(k-1)+1<<endl;
    else cout<<(n-1)/(k-1)<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    int a,b;
    cin>>a>>b;
    rep(i,0,10000)
    {
        u=floor((double)i*0.08);
        v=(double)i*0.1;
        if(u==a&&v==b)
        {
            cout<<i;
            return;
        }
    }
    cout<<"-1";
}
 
 
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    string S;
    cin >> S;
    int r = 0, b = 0, len = S.length();
    REP(i, len){
        if(S[i] == '0') r++;
        else b++;
    }
    PRINT(len - abs(r - b));
    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int n = in.nextInt(); 
      int[][][] residents = new int[5][4][11];
      
      for (int i = 1; i <= n; i++) {
        int b = in.nextInt();
        int f = in.nextInt();
        int r = in.nextInt();
        int v = in.nextInt();
        
        residents[b][f][r] += v;
      }
      
      for (int i = 1; i <= 4; i++) {
        for (int j = 1; j <= 3; j++) {
          for (int k = 1; k <= 10; k++) {
            out.print(" " + residents[i][j][k]);
          }
          out.print("\n");
        }
        
        if (i != 4) {
          out.println("####################");
        }
      }
//    End solve()
    }
//    End Solution
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }


  }

}

Measured memory_bytes: 24488
object Main extends App {
  val x = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val a = x(0)
  val b = x(1)
  if (a < b) println("a < b")
  else if (a > b) println("a > b")
  else if (a == b) println("a == b")
}


Measured memory_bytes: 43820
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> v(n);
	vector<int> ww(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> ww[i];
	}
	vector<int> dp(w+1, 0);
	for (int i = 0; i < n; i++) {
		for (int j = w; j >= ww[i]; j--) {
			dp[j] = max(dp[j], dp[j-ww[i]]+v[i]);
		}
	}
	cout << dp[w] << endl;
	return 0;
}

Measured memory_bytes: 1232
n,d = gets.split(' ').map(&:to_i)
x = []
n.times do |a|
        nums = gets.split(' ').map(&:to_i)
        x << nums
end
count = 0
x.combination(2) do |c|
    sum = 0
    (0..d-1).each do |a|
        dis = (c[0][a]-c[1][a])**2
        sum = sum+dis
    end
    str =  Math.sqrt(sum).to_s
    index = str.index('.')
    if str[index+2] == nil
        count += 1
    end
end
puts count

Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>
int main(void){ 
    int N,i,j,k,A[1000];
    scanf("%d",&N);
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            A[10*i+j]=i*j;
        }
    }
    int count=0;
    for(k=11;k<=99;k++){
        if(N==A[k]){
            count++;
        }
    }
    if(count==0){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}

	

Measured memory_bytes: 128