akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// head

const int MAXN = 100000 + 5;
int A, B, M;
int a[MAXN], b[MAXN], c[MAXN];
int x[MAXN], y[MAXN];

int main()
{
	ios::sync_with_stdio(false);
#ifdef RG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> A >> B >> M;
	int mina = INT_MAX;
	int minb = INT_MAX;
	rep(i, 0, A) {
		cin >> a[i];
		mina = min(mina, a[i]);
	}
	rep(i, 0, B) {
		cin >> b[i];
		minb = min(minb, b[i]);
	}
	rep(i, 0, M) cin >> x[i]>>y[i]>>c[i];

	int minans = mina + minb;
	rep(i, 0, M) {
		minans = min(a[x[i]-1] + b[y[i]-1] - c[i], minans);
	}
	cout << minans << endl;

	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static List<Integer> link[];
    public static int[] d;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        link = new ArrayList[N];
        for (int i=0; i<N; i++) {
            link[i] = new ArrayList<Integer>();
        }
        
        for (int i=0; i<N-1; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            link[a-1].add(b-1);
            link[b-1].add(a-1);
        }
        d = new int[N];
        for (int i=0; i<N; i++) d[i] = -1;
        dfs(0,0);
        // for (int i=0; i<N; i++) {
        //     System.out.println(d[i]);
        // }
        int maxD = -1;
        int maxI = -1;
        for(int i=0; i<N; i++) {
            if(maxD < d[i]) {
                maxD = d[i];
                maxI = i;
            }
        }
        for (int i=0; i<N; i++) d[i] = -1;
        dfs(maxI,0);
        for(int i=0; i<N; i++) {
            if(maxD < d[i]) {
                maxD = d[i];
            }
        }
        int longest = maxD+1;
        if(longest%3 == 2) {
            System.out.println("Second");
        } else {
            System.out.println("First");
        }
 


    }
    public static void dfs(int s, int value){
        d[s] = value;
        for (Integer w : link[s]) {
            if(d[w] != -1) continue;
            dfs(w, value+1);
        }

    }

}

Measured memory_bytes: 151352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 
int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,i,x,k;

sfl(n);

ll a[n+1];
f(i,0,n){
sfl(x);
a[x]=i+1;
}
f(i,1,n+1)cout<<a[i]<<" ";
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

Measured memory_bytes: 1536
def func(x)
    if x % 2 == 0
        return (x / 2) | 0
    else
        return 3 * x + 1
    end
end
def main
    a = []
    a << gets.chomp.to_i
    count = 0
    while true
        x = a[count]
        n = func(x)
        if a.include?(n)
            puts count + 2
            exit
        end
        a << n
        count += 1
    end
end

main

Measured memory_bytes: 1788
c[999],i,j,r;main(A,a,C){for(scanf("%*d%d%d%d",&A,&a,&C);~scanf("%d",c+i++););for(qsort(c,i,4,"\x8b\6+\7\xc3");r=fmax(r,C/A),i--;C+=c[j++])A+=a;i=!printf("%d\n",r);}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

void solve() {
  int n;
  cin >> n;
  vi64 a(n), b(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  if (n & 1) {
    sort(all(a));
    sort(all(b));
    i64 ans = b[n/2] - a[n/2] + 1;
    cout << ans << endl;
  } else {
    rep(i, n) a[i] *= 2, b[i] *= 2;
    sort(all(a));
    sort(all(b));
    i64 ans = (b[n/2]+b[n/2-1])/2 - (a[n/2]+a[n/2-1])/2 + 1;
    cout << ans << endl;
  }
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int A, B;
    cin >> A >> B;
    if(1 <= A && A <= 9 && 1 <= B && B <= 9) {
        printf("%lld\n", A * B);
    }
    else {
        printf("-1\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int bubbleSort(int A[],int N) {
	int sw = 0;
	bool flag = 1;
	for(int i=0; flag; i++) {
		flag = 0;
		for(int j=N-1; j>=i+1; j--) {
			if(A[j] < A[j-1]) {
				swap(A[j], A[j-1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw;
}

int main(void) {
	int A[100], N, sw;
	cin >> N;
	for(int i=0;i<N; i++) cin >> A[i];

	sw = bubbleSort(A,N);

	for(int i = 0; i < N; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < 4; ++i){
        vector<bool> is_wolf(n);
        is_wolf.at(0) = i % 2;
        is_wolf.at(1) = i / 2;
        for(int j = 2; j < n; ++j){
            if(is_wolf.at(j - 1)){
                if(s.at(j - 1) != 'o'){
                    is_wolf.at(j) = is_wolf.at(j - 2);
                }else{
                    is_wolf.at(j) = !is_wolf.at(j - 2);
                }
            }else{
                if(s.at(j - 1) == 'o'){
                    is_wolf.at(j) = is_wolf.at(j - 2);
                }else{
                    is_wolf.at(j) = !is_wolf.at(j - 2);
                }
            }
        }

        bool is_ok = true;
        for(int j = 0; j < 2; ++j){
            bool is_same = (s.at((n - 1 + j) % n) == 'o');
            if(is_wolf.at((n - 1 + j) % n)){
                is_same = !is_same;
            }
            if(is_same){
                if(is_wolf.at(n - 2 + j) != is_wolf.at(j)){
                    is_ok = false;
                }
            }else{
                if(is_wolf.at(n - 2 + j) == is_wolf.at(j)){
                    is_ok = false;
                }
            }
        }
        if(!is_ok){
            continue;
        }

        for(bool b : is_wolf){
            if(b){
                cout << 'W';
            }else{
                cout << 'S';
            }
        }
        cout << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


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

typedef long long ll;


int main(){

    ll n; cin >> n;


    // for(ll i = 2; i <= sqrt(n); i++){
    //     if(n % i == 0){
    //         if((n/i) * i == n){
    //             cout << (i-1) + (n/i - 1) << endl;
    //             return 0;
    //         }
    //     }
    // }

    for(ll i = sqrt(n); i > 1; i--){
        if(n % i == 0){
            if((n/i) * i == n){
                cout << i + n/i - 2 << endl;
                return 0;
            }
        }
    }

    cout << n - 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
main()
{
	int c=0,k,s;
	std::cin>>k>>s;
	for(int i=0;i<=k;i++)
		for(int j=0;j<=k;j++)
			if(s-i-j>=0&&s-i-j<=k)c++;
	std::cout<<c<<"\n";
}


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

int main(void) {

	char aContest[4];
	//文字列を入力
	scanf("%s", &aContest);
	//入力される文字列に応じた文字列を表示
	if (strcmp(aContest, "ABC") == 0) {
		printf("\nARC\n");
	}
	else if (strcmp(aContest, "ARC" )== 0) {
		printf("\nABC\n");
	}else{}

	return 0;
}

Measured memory_bytes: 1992
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=INF;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  FOR(i,-100,101){
    int cost = 0;
    REP(j,n){
      cost += pow(i-A[j],2);
    }
    z = min(z,cost);
  }
  OUT(z);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	
	bool f[s.size()]={};
	rep(i,0,s.size())
		if( s[i] == 'p' )
			f[i] = 1;
	
	int sg=0,sp=0;
	int p=0;

	rep(i,0,s.size()){
		if( !f[i] && sp < sg ){
			p++;
			sp++;
		}
		else if( !f[i] ){
			sg++;
		}
		else if( f[i] && sp < sg ){
			sp++;
		}
		else{
			sg++;
			p--;
		}

		//cout << "p:" << p << "sp:" << sp << "sg:" << sg << endl;
	}

	P(p);

	ret 0;
}

Measured memory_bytes: 512
x = int(input())

if x <= 11:
    if x <= 6:
        print(1)
    else:
        print(2)
        
else:
    rot = x//11
    mod = x%11
    if mod > 6:
        print(2*rot + 2)
        quit()
    if mod > 0:
        print(2*rot + 1)
        quit()
    print(2*rot)

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

int  main()
{
	string a,b,c; cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] <<endl;
	return (0);
}

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

int main(){
  int N;
  double M;
  cin >> N >> M;
  
  vector<int> vote(N);
  double sum = 0;
  for (int i=0; i<N; i++){
    cin >> vote.at(i);
    sum += vote.at(i);
  }
  //cout << sum << endl;
  
  sort(vote.begin(),vote.end());
  reverse(vote.begin(),vote.end());
  
  double q = sum/(4*M);
  //cout << fixed << setprecision(3);
  //cout << q << endl;
  
  if(vote.at(M-1) < q){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

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

ll N, K;
vector<ll> A;

void input() {
    cin >> N >> K;
    A.resize(N);
    for (auto& a : A) cin >> a;
    //    N = 3, K = 7;
    //    A = {1, 6, 3};
}

void solve() {
    ll x = 0;
    for (ll n = 39; n >= 0; n--) {
        ll bitcnt = 0;
        for (auto a : A)
            if (a >> n & 1)
                bitcnt++;
        if (bitcnt < (N+1)/2) {
            if ((x ^ (1ull << n)) <= K) {
                x ^= 1ull << n;
            }
        }
    }
    ll ans = 0;
    for (auto a : A)
        ans += x ^ a;
    cout << ans << endl;
}

int main() {
    input();
    
    solve();
    
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#define MAX(A, B) (A)>(B)?(A):(B)
int main()
{
  int a,b,c,k;
  int max;
  int sum;
  scanf("%d%d%d%*c",&a,&b,&c);
  scanf("%d%*c",&k);
  max = MAX(a, MAX(b, c));
  sum = a + b + c + (max<<k) - max;
  
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
a=input()
b=int(input())
while b>0:
    tmp=input().split(" ")
    if tmp[0]=="replace":
        a=a[:int(tmp[1])]+tmp[3]+a[int(tmp[2])+1:]
    if tmp[0]=="reverse":
        tmp2="".join(list(a)[int(tmp[1]):int(tmp[2])+1])[::-1]
        a=a[:int(tmp[1])]+tmp2+a[int(tmp[2])+1:]
    if tmp[0]=="print":
        print(a[int(tmp[1]):int(tmp[2])+1])
    b-=1


Measured memory_bytes: 5616
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;
    if (d2 == 1) cout << '1' << endl;
    else cout << '0' << endl;
    return 0;
}



Measured memory_bytes: 888
import numpy
d = int(input())
c = list(map(int,input().split()))
s = [0]*d
for i in range(d):
    s[i] = list(map(int,input().split()))
k = [1]*26
for i in range(d):
    if d%36 == 0:
        k = [1]*26
    x = sum(k)
    if 26 - x > d%36:
        q = 0
        for i in range(26):
            if k[i] == 1:
                q = i
                break
    else:
        q = numpy.argmax(s[i])
    print(q+1)
    k[q] = 0

Measured memory_bytes: 27512
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    vll cnt(1000001);
    for(ll i = 0; i < n; i++) cnt[a[i]]++;
    for(ll i = 1; i <= 1000000; i++) {
        if(cnt[i] == 0) continue;
        for(ll j = 2; i*j <= 1000000; j++) cnt[i*j] = 0;
        if(cnt[i] > 1) cnt[i] = 0;
    }
    ll ans = 0;
    for(ll i = 1; i <= 1000000; i++) {
        if(cnt[i] != 0) ans++;
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 12636
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int n;
	cin >> n;
	int ct=0;
	for(int i=1; i<=n; i++) {
		int x;
		cin >> x;
		if (x != i) ct++;
	}
	if (ct <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
import bisect
N, M, K = map(int,input().split())
ls_a = list(map(int,input().split()))
ls_b = list(map(int,input().split()))

A = [0] * (N+1)
B = [0] * (M+1)
for i in range(N):
  A[i+1] = A[i] + ls_a[i]
for i in range(M):
  B[i+1] = B[i] + ls_b[i]
  
ans = 0
for i in range(N+1):
  if A[i] <= K:
    x = bisect.bisect(B,K-A[i])
    ans = max(ans, i+x-1)
print(ans)

Measured memory_bytes: 110604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    char r, g, b; cin >> r >> g >> b;
    int r_ = 100*(r-'0');
    int g_ = 10*(g-'0');
    int b_ = b-'0';
    int x = r_+g_+b_;
    if (x % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

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

  /* 文字列の結果を格納 */
  std::vector<std::pair<std::string, char> > res; /* 文字列, 文字列中の文字の最大値 a~j, 0~9に対応 */

  /* 長さ1の標準形aを代入 */
  res.push_back(std::pair<std::string, char>("a", 'a'));

  /* n-1回繰り返す */
  while (--n) {

    /* 仮の結果 */
    std::vector<std::pair<std::string, char> > res_tmp;

    for (auto p : res) {
      std::string s = p.first; // 現在の文字列
      char mx = p.second;       // 文字列中の最大値

      /* 現在のlen(標準形)+1の長さの標準形を作る */
      for (char c = 'a'; c <= mx + 1; ++c) {
        std::string s_tmp = s + c; 
        char mx_tmp = std::max(c, mx); // mx以上 
        res_tmp.push_back(std::pair<std::string, char>(s_tmp, mx_tmp));
      }
    } 

    res = res_tmp;
  }

  /* 昇順でソート */
  std::sort(res.begin(), res.end());
  
  for (auto p : res) {
    std::cout << p.first << std::endl;
  }

  return 0;
}


Measured memory_bytes: 13152
#include <iostream>
#include <string>
#include <cmath>

#include <list>
#include <queue>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main(void)
{
    int n;
    int L[100];
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> L[i];
    }
    int count=0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1; k<n; k++) {
                if (L[i]!=L[j] && L[j]!=L[k] &&L[k]!=L[i] && L[i]+L[j]>L[k] && L[j]+L[k]>L[i] && L[k]+L[i]>L[j]) count++;
            }
        }
    }
    cout<<count;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e17
#define mx 2*1000000+5
using namespace std;
const ll int p=1e9+7;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll int n,i,j,k,l,sum,z,ans,temp;
    vector<ll int>v;
    cin>>n;
    v.resize(n);
    for(i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end(),greater<ll int>());
    sum=0;temp=2;i=0;z=2;
    while(1){
        if(temp==2){
            sum+=v[0];
            //cout<<v[0]<<endl;
            i++;
            temp++;
            if(temp==n+1) break;
            continue;
        }
        sum+=v[i];
        //cout<<v[i]<<endl;
        temp++;
        if(temp==n+1) break;
        sum+=v[i];
        temp++;
        //cout<<v[i]<<endl;
        i++;
        if(temp==n+1) break;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4792
#include <stdio.h>
#include <math.h>

int main(void)
{
  int n,i,j,ans,no,cou;

  for(;;){
    scanf("%d", &n);
    if(!n) break;
    if(n==1){
      printf("2\n"); continue;
    }

    ans=2; no=0; cou=1;
    for(i=3;cou<n;i+=2){
      for(j=3;j<sqrt(i)+1;j++){
	if(i%j==0){
	  no=1; break;
	}
      }
      if(!no){
	ans+=i; cou++;
      }
      no=0;
    }
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 600
#include<bits/stdc++.h>
 using namespace std;
 #define REP(i, c) for(int i = 0; i < (int)c; i++)
 const int INF = 1000000000; 

 int main() {
 int N;
 cin >> N;
  vector<int> X(N);
 REP(i, N) cin >> X[i];
 int ans = INF;
 for(int i = 1; i <= 100; i++) { 
 int cost = 0;
 REP(j, N) cost += (X[j] - i) * (X[j] - i);
 ans = min(ans, cost);
 }
 cout << ans << endl;
 return 0;
 }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int n;
    cin >> n;

    for(int i = 1;i < n + 1000;i++){
        if((int)(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vll a(x),b(y),c(z);
    REP(i,x) cin >> a[i];
    REP(i,y) cin >> b[i];
    REP(i,z) cin >> c[i];
    vll ab(x*y);
    REP(i,x){
        REP(j,y){
            ab[y*i+j] = a[i]+b[j];
        }
    }
    sort(rALL(ab));
    ll xy = min(x*y,k);
    vll abc(xy*z);
    REP(i,xy){
        REP(j,z){
            abc[z*i+j] = ab[i]+c[j];
        }
    }
    sort(rALL(abc));
    REP(i,k){
        cout << abc[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 31616
#include<iostream>
using namespace std;
int main(){
	int X;
	cin>>X;
	for(long long int i=-1000;i<=1000;i++){
		for(long long int j=i;j<=1000;j++){
			if(j*j*j*j*j-i*i*i*i*i==X){
				cout<<j<<" "<<i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(M);
  i64 sum = 0;
  rep(i,0,M) {
    cin >> A[i];
    sum += A[i];
  }
  if(N < sum) {
    cout << -1 << endl;
  }
  else {
    cout << N - sum << endl;
  }
}


Measured memory_bytes: 3712
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	ll x, y;
	cin >> x >> y;
	if(abs(x-y)<=(ll)1) cout << "Brown" << endl;
	else cout << "Alice" << endl;

	return 0;
}


Measured memory_bytes: 256
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 1005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll dp[MAX][MAX];
char ch[MAX][MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int h, w;

    cin>>h>>w;

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin>>ch[i][j];
        }
    }

    for(int i = 1; i <= h; i++){
        if(ch[i][1] == '#'){
            break;
        }
        else
            dp[i][1] = 1;
    }
    for(int i = 1; i <= w; i++){
        if(ch[1][i] == '#')
            break;
        dp[1][i] = 1;
    }
    dp[1][1] = 0;
    for(int i = 2; i <= h; i++){
        for(int j = 2; j <= w; j++){
            if(ch[i][j] == '#')
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
        }
    }
    
    cout<<dp[h][w]<<endl;


    return 0;
}


Measured memory_bytes: 9088
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;

int main() {
	int64_t A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int64_t val = numeric_limits<int64_t>::max();
	int64_t Z = min(X, Y);
	val = (A * X) + (B * Y);
	val = min(C * 2 * max(X, Y), val);
	val = min((Z * C * 2) + (A * (X - Z)) + (B * (Y - Z)), val);
	cout << val;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=""
for f,t in [["S","S"],["S","W"],["W","S"],["W","W"]]:
  ss=f+(n-2)*"X"+t
  ss=list(ss)
  ok=True
  for i in range(n-1):
    if s[i]=="o":
      if ss[i]=="S":
        if ss[i-1]=="S":
          ss[i+1]="S"
        else:
          ss[i+1]="W"
      elif ss[i]=="W":
        if ss[i-1]=="S":
          ss[i+1]="W"
        else:
          ss[i+1]="S"
    elif s[i]=="x":
      if ss[i]=="S":
        if ss[i-1]=="S":
          ss[i+1]="W"
        else:
          ss[i+1]="S"
      elif ss[i]=="W":
        if ss[i-1]=="S":
          ss[i+1]="S"
        else:
          ss[i+1]="W"
  for i in range(n):
    if i==n-1:
      if s[i]=="o":
        if ss[i]=="S":
          if ss[i-1]==ss[0]:
            pass
          else:
            ok=False
            break
        elif ss[i]=="W":
          if ss[i-1]!=ss[0]:
            pass
          else:
            ok=False
            break
      elif s[i]=="x":
        if ss[i]=="S":
          if ss[i-1]!=ss[0]:
            pass
          else:
            ok=False
            break
        elif ss[i]=="W":
          if ss[i-1]==ss[0]:
            pass
          else:
            ok=False
            break
      continue
    if s[i]=="o":
      if ss[i]=="S":
        if ss[i-1]==ss[i+1]:
          pass
        else:
          ok=False
          break
      elif ss[i]=="W":
        if ss[i-1]!=ss[i+1]:
          pass
        else:
          ok=False
          break
    elif s[i]=="x":
      if ss[i]=="S":
        if ss[i-1]!=ss[i+1]:
          pass
        else:
          ok=False
          break
      elif ss[i]=="W":
        if ss[i-1]==ss[i+1]:
          pass
        else:
          ok=False
          break
      
  if ok:
    for si in ss:
      ans+=si
    print(ans)
    exit(0)
print(-1)





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


int main(){
    long long int N,K,ans,an;
    cin >> N >> K;
    if(N>K){
        an = N%K;
        if( an <= K/2){
            ans =an;
        }else if(an > K/2){
            ans =K-an;
        }
    }else{
        if(N>K/2){
            ans = K-N;
        }else{
            ans = N;
        }
    }

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

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

using namespace std;
typedef long long int ll;
ll N,K;

ll x[55];
ll y[55];


bool f(ll a,ll b, ll c, ll d){

  ll count = 0;
  
  for(ll i=0;i<N;i++){
    if(a<=x[i]&&
       x[i]<=b&&
       c<=y[i]&&
       y[i]<=d){
      count++;
    }
  }
  return count >=K;
}



int main() {

  cin>>N>>K;
  for( ll i = 0;i<N;i++)cin>>x[i]>>y[i];

  ll ret = 0x7fffffffffffffff;

  for( ll i=0;i<N;i++){
    for( ll j=0;j<N;j++){
      for( ll k=0;k<N;k++){
        for( ll l=0;l<N;l++){
          ll minx = min( min(x[i], x[j]), min(x[k], x[l]));
          ll maxx = max( max(x[i], x[j]), max(x[k], x[l]));
          ll miny = min( min(y[i], y[j]), min(y[k], y[l]));
          ll maxy = max( max(y[i], y[j]), max(y[k], y[l]));
          if(f(minx,maxx,miny,maxy)){

            ret = min(ret, (maxx-minx) * (maxy - miny));
          }
        }
      }
    }
  }
  
  cout << ret<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;
int main(void){
    int R[MAX], n;
    
    cin >>  n;
    for ( int i = 0; i < n; i++ ) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    
    for ( int i = 1; i < n; i++ ) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}



Measured memory_bytes: 3860
while True:
    H, W = map(int, input().split())
    if W == 0 and H == 0:
        break
    else:
        for i in range(H):
            if i == 0 or i + 1 == H:
                print('#' * W)
            else:
                print('#' + "." * (W - 2) + '#')
        print()

Measured memory_bytes: 7616
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l: usize = sc.read();

    let mut r = 0;
    while (1 << (r + 1)) <= l {
        r += 1;
    }

    let n = r + 1;
    let mut graph = vec![vec![]; n];
    for i in 0..r {
        graph[i].push((i + 1, 1 << i));
        graph[i].push((i + 1, 0));
    }

    let sum = (1 << r) - 1;
    let mut upper = l;
    for i in (0..(n - 1)).rev() {
        let to_i = (1 << i) - 1;
        if upper >= to_i + 1 {
            let new_edge = upper - to_i - 1;
            if new_edge > sum {
                // add paths [new_edge, new_edge+1, ..., l-1]
                graph[i].push((n - 1, new_edge));
                upper = new_edge;
            }
        }
    }

    println!("{} {}", n, graph.iter().map(|e| e.len()).sum::<usize>());

    for (from, to, w) in graph
        .into_iter()
        .enumerate()
        .flat_map(|(i, e)| e.into_iter().map(move |(to, w)| (i, to, w)))
    {
        println!("{} {} {}", from + 1, to + 1, w);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    cnt = 0
    for i in range(len(s)):
        if s[i] != s[-i-1]:
            cnt += 1
    print(cnt // 2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        cout << "Bad";
    }
    else
    {
        cout << "Good";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
#define ALL(a)  (a).begin(),(a).end()

int main(){
    int n ;
    cin >> n ;
    if(n%10 == 3 ) cout << "bon" << endl;
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6|| n%10 == 8 ) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3624
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, (list(ns()))))
    K = ni()
    for i in range(K):
        if S[i] != 1:
            print(S[i])
            return
    print(1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9072
#include <iostream>
#include<vector>
using namespace std;
 
int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int f = 0, res = 1;
	for (int i = 1; i < N; i++) {
		if (A[i] > A[i - 1]) {
			if (f > 0) {
				;
			}
			else if (f < 0) {
				f = 0;
				res++;
			}
			else {
				f = 1;
			}
		}
		else if (A[i] == A[i - 1]) {
			;
		}
		else {
			if (f > 0) {
				f = 0;
				res++;
			}
			else if (f < 0) {
				;
			}
			else {
				f = -1;
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  bool flag = true;
  for(int i = 0; i < S.size(); i++){
    if(S[i] != T[i]){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,c,k,t[100111],ans;
int main()
{
	get3(n,c,k);
	for(int i=1;i<=n;i++)get1(t[i]);
	sort(t+1,t+n+1);
	int tot=0,mx=0;
	for(int i=1;i<=n;i++)
	{
		if(tot==c||mx<t[i])
		{
			mx=t[i]+k;
			tot=0;
			ans++;
		}
		tot++;
	}
	printendl(ans);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);

	int n, m;
	cin >> n >> m;

	vector<int> num(26, 0);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			++num[s[j] - 'a'];
		}
	}

	int num4 = 0, num2 = 0, num1 = 0;
	for (int i = 0; i < 26; ++i) {
		if (num[i] % 4 == 0) {
			++num4;
		} else if (num[i] % 2 == 0) {
			++num2;
		} else {
			++num1;
		}
	}

	if ((n * m) % 2 != 0) {
		if (num1 != 1) {
			cout << "No" << endl;
			return 0;
		}
		if (num2 * 2 > n + m - 2) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		return 0;
	}

	if (num1 != 0) {
		cout << "No" << endl;
		return 0;
	}

	if (n % 2 != 0 || m % 2 != 0) {
		int even = (n % 2 == 0 ? n : m);
		if (num2 * 2 > even) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
		return 0;
	}

	if (num2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007
int main(void){
  int n,m,i;
  long long int sum = 1;
  int a[100000];
  int asum[100000]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    asum[a[i]]++;
  }
  for(i=0;i<n;i++){
    if(n%2 == 0 && (asum[i] != 0 && asum[i] != 2)){
      printf("0");
      return 0;
    }else if(n%2 == 1 && (asum[0] != 1 || (i != 0 && asum[i] != 0 && asum[i] != 2))){
      printf("0");
      return 0;
    }else if(asum[i] == 2){
      sum = ((sum % MOD)*2)%MOD;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 896
/*
          Life before Death
          Strength before Weakness
          Journey before Destination
    */
    
    #include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(ll i=a;i<n;i++)
    #define per(i,n,a) for (ll i=n;i>a;i--)
    #define te ll t; std::cin >> t; while(t--)
    #define SZ 100011
    //#define M_PI  3.141592653589793238462643383279502884L
    /*------Just DO IT--------------------------------------*/

    int solve(){
      ll n,h,w;
      cin >>n>>w>>h;
      ll ans = (n-w+1)*(n-h+1);
      cout<<ans<<endl;
    } 
    
   int main() {
       fastio
       solve();
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  long tmp = a;
  if(a<b){
    a = b;
    b = tmp;
  }
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
int main(){
  int n;
  long k;
  cin >> n >> k;
  vector<long>a(n);
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long gcdd = a[0];
  long maxx = a[0];
  for(i=1;i<n;i++){
    gcdd = gcd(gcdd,a[i]);
    if(maxx < a[i])maxx = a[i];
  }
  if(k%gcdd == 0 && k<=maxx)cout<<"POSSIBLE"<<endl;
  else cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;
//最大公約数

int gcd(ll a,ll b){
   ll ans;
   for(int i=1;i<=min(a,b);i++){
      if(a%i==0&&b%i==0) ans=i;
   }
   return ans;
}

int main(){
   ll a,b; cin>>a>>b;
   ll gc=gcd(a,b);
   ll gca=a/gc;
   ll gcb=b/gc;
   ll ans=gc*gca*gcb;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>

using namespace std;

int main(void){
     int w[30];
     int line;
     int n;
     int a1,b1;
     for(int i = 0;i<30;i++){
	  w[i] = i+1;
     }
     cin >> line;
     cin >> n;
//     for(int i=0;i<line;i++){
//	  cout << w[i] << endl;
//     }
//     cout << endl;

     for(int i=0;i<n;i++){
	  scanf("%d,%d",&a1,&b1);
	  int m = w[a1-1];
	  w[a1-1] = w[b1-1];
	  w[b1-1] = m;
//	  for(int i=0;i<line;i++){
//	       cout << w[i] << endl;
//	  }
//	  cout << endl;
     }

     for(int i=0;i<line;i++){
	  cout << w[i] << endl;
     }
     return 0;
}

Measured memory_bytes: 0
#学生，チェックポイント
n, m = map(int, input().split())
#学生の位置
students = [list(map(int, input().split())) for i in range(n)]
#ポイントの位置
points = [list(map(int, input().split())) for i in range(m)]

for i in range(n): #生徒
    for j in range(m): #チェックポイント
        dist = abs(students[i][0]-points[j][0]) + abs(students[i][1]-points[j][1])
        if j < 1:
            min_dist = dist
            min_id = j + 1
        else:
            if min_dist > dist:
                min_dist = dist
                min_id = j + 1
    print(int(min_id))


Measured memory_bytes: 3064
N,K=map(int,input().split())
A=list(map(int,input().split()))

b=[0]*40
for a in A:
    for k in range(40):
        if a&(1<<k):
            b[k]+=1

x=0
for k in range(39,-1,-1):
    if x+(1<<k)>K:
        continue
    if b[k]<(N+1)//2:
        x+=(1<<k)
ans=0
for a in A:
    ans+=x^a

print(ans)


Measured memory_bytes: 69264
/*
 * Author: ylx
 * Lang: c++
 * Prog: agc030F
 */
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
    char s;
    int k=0,base=1;
    while ((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if (s==EOF) exit(0);
    if (s=='-') base=-1,s=getchar();
    while (isdigit(s)) k=k*10+(s^'0'),s=getchar();
    return k*base;
}
inline void write(ll x)
{
    static char cnt,num[20];cnt=0;
    if (!x)
    {
        putchar('0');
        return;
    }
    for (;x;x/=10) num[++cnt]=x%10;
    for (;cnt;putchar(num[cnt--]+48));
}
const ll mod=1e9+7;
const int maxn=610;
ll dp[2][maxn][maxn];
int n,a[maxn];
int vis[maxn];
int cnt;
ll ans;
void Mod(ll &x)
{
    if (x<0) x+=mod;
    if (x>=mod) x%=mod;
}
int main()
{
#ifdef ylx
    freopen("agc030F.in","r",stdin);
    freopen("agc030F.out","w",stdout);
#endif
    n=read();
    ans=1;
    for (int i=1;i<=n+n;i++) 
    {
        a[i]=read();
        if (a[i]!=-1) a[i]=n+n+1-a[i];
    }
    for (int i=1;i<=n+n;i+=2)
    {
        if (a[i]!=-1&&a[i+1]!=-1)
        {
            vis[a[i]]=vis[a[i+1]]=2;
        } else
        {
            if (a[i]!=-1) vis[a[i]]=1; else //没匹配
                if (a[i+1]!=-1) vis[a[i+1]]=1; else  cnt++;
        }
    }   
    for (int i=1;i<=cnt;i++) ans=ans*i%mod;
    dp[0][0][0]=1;
    for (int i=1,now;i<=n+n;i++)
    {
        now=i&1;
        memset(dp[now],0,sizeof(dp[now]));

        if (vis[i]==2) 
        {
            for (int j=0;j<=n;j++)
                for (int k=0;k<=n;k++) dp[now][j][k]=dp[now^1][j][k];
            continue;
        }
        if (vis[i]==1)
        {
            for (int j=0;j<=n;j++)
            {
                for (int k=0;k<=n;k++)
                {
                    Mod(dp[now][j][k]+=dp[now^1][j+1][k]%mod);
                    if (k) Mod(dp[now][j][k]+=dp[now^1][j][k-1]);
                }
            }
        } else
        {
            for (int j=0;j<=n;j++)
            {
                for (int k=0;k<=n;k++)
                {
                    if (j) Mod(dp[now][j][k]+=dp[now^1][j-1][k]);
                    Mod(dp[now][j][k]+=dp[now^1][j+1][k]);
                    Mod(dp[now][j][k]+=dp[now^1][j][k+1]*(k+1)%mod);
                }
            }
        }
    }
    ans=ans*dp[(n+n)&1][0][0]%mod;
    cout<<ans;
    return 0;
}
//2019年 01月 11日 星期五 20:54:41 CST

Measured memory_bytes: 6144