akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
using namespace std;

const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const int MOD = 998244353;

int v[N];
void solve() {
    int n;
    cin >> n;
    int x = 0;
    for (int i=0;i<n;++i) {
        cin >> v[i];
        x ^= v[i];
    }
    for (int i=0;i<n;++i) {
        cout << (v[i] ^ x) << " ";
    }
    cout << '\n';
} 

int main() {
    FASTIO;
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
string ABC = "ABC";
bool solve(string s)
{
    while(1)
    {
        if(s == ABC) return true;
        if(s.size() <= 3) return false;
        char ch = 'B';
        if(s.substr(0, 3) == "ABC") ch = 'A';
        else if(s.substr(s.size() - 3) == "ABC") ch = 'C';
        int cnt = 0;
        string t = ""; t += ch;
        for(int i = 0; i < s.size()- 2; i++)
        {
            if(s.substr(i, 3) == "ABC")
            {
                s.replace(i, 3, t);
                cnt++;
            }
        }
        if(cnt == 0 || cnt != count(s.begin(), s.end(), ch)) break;
    }
    return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << (solve(s) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3232
n,k=map(int,input().split())
ab=[list(map(int, input().split())) for i in range(n)]
ab.sort()
count=0
ans=ab[0][0]
for i in range(n):
    if count+ab[i][1]<k:
        count+=ab[i][1]
    elif 0<=k-count<=ab[i][1]:
        ans=ab[i][0]
        break
print(ans)

Measured memory_bytes: 27872
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2)cout << "Borys" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int minc = 1001;

		for(int i=0; i<N; i++){
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(t<=T){
				if(c<minc){
					minc=c;
                }
            }
        }
		if(minc==1001){
			System.out.println("TLE");
        }else{
			System.out.println(minc);
        }
	}
}


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

int dp[3000][3000];
int main() {
  int n, t;
  cin>>n>>t;
  pair<int, int> ab[n];
  for (int i=0; i<n; i++) cin>>ab[i].first>>ab[i].second;
  sort(ab, ab + n);
  for (int j=0; j<t; j++) {
    if (j < ab[0].first) {
      dp[0][j] = 0;
    } else {
      dp[0][j] = ab[0].second;
    }
  }
  for (int i=1; i<n; i++) {
    dp[i][0] = 0;
    for (int j=1; j<t; j++) {
      dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
      if (j >= ab[i].first) {
        dp[i][j] = max(dp[i-1][j-ab[i].first] + ab[i].second, dp[i][j]);
      }
    }
  }
  int ans = 0;
  for (int i=0; i<n-1; i++) {
    ans = max(dp[i][t-1] + ab[i+1].second, ans);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 35456
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string n;
	cin >> n;
	if(n[0] == '7' || n[1] == '7' || n[2] == '7') {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
from collections import Counter

def solve():
    N = int(input())
    c = Counter([input() for _ in range(N)])
    cnt = -1
    ans = []
    for i in c.most_common():
        if cnt == -1:
            cnt = i[1]
            ans.append(i[0])
        elif cnt == i[1]:
            ans.append(i[0])
        else:
            break
    for a in sorted(ans):
        print(a)
    
if __name__ == "__main__":
    solve()

Measured memory_bytes: 147640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
//#define _GLIBCXX_DEBUG

signed main() {
  int N, M, X; cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N) {
    cin >> C[i];
    rep(j, M) cin >> A[i][j];
  }

  int ans = 1000000000;
  
  int x = 1;
  bitset<12> b = x;
  
  while(x <= (2<<N)) {
    vector<int> S(M, 0);
    int c = 0;
    rep(i, N) {
      if(b.test(i)) {
        rep(j, M) S[j] += A[i][j];
        c += C[i];
      }
    }
    bool k = true;
    rep(j, M) if(S[j] < X) k = false;
    if(k) ans = min(ans, c);
    
    
    x++;
    b = x;
  }
  
  
  


  if(ans == 1000000000) cout << -1 << endl;
  else cout << ans << endl;

}

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

using namespace std;

int dp(int N, int K) {
	if (N == 1) return 0;
	int idx = dp(N-1, K);
	return (K + idx) % N;
}
int solve(int N, int K, int M) {
	if (N == 1) return 0;
	return (dp(N-1, K) + M + 1) % N;
}

int main() {
	int N, K, M;
	while ( cin >> N >> K >> M, N || K || M ) {
		--M;
		cout << solve(N, K, M)+1 << endl;
	}
}

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

int main()
{
  string s;
  int n;
  cin >> n;
  cin >> s;
  int ans = 0;
  rep(i,n - 2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep (i,N) cin >> A.at(i);
    rep (i,N) A.at(i)--;
    map<ll,ll> roop;
    ll now = 0,cnt = 0,two = 0,three = 0;
    roop[now] = 1;
    bool hoge = true;
    while(true) {
        if (cnt == K) {
            cout << now + 1 << endl;
            return 0;
        }
        now = A.at(now);
        roop[now]++;
        cnt++;
        if (roop[now] == 2 && hoge) {
            two = cnt;
            hoge = false;
        }
        if (roop[now] == 3) {
            three = cnt;
            break;
        }
    }
    ll mod = (K - two) % (three - two);
    rep (i,mod) {
        now = A.at(now);
    }
    cout << now + 1 << endl;
    return 0;
}

Measured memory_bytes: 14776
class Point {
  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  print() {
    console.log(this.x.toFixed(8) + ' ' + this.y.toFixed(8));
  }
}

(function main(){
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
  let p1 = new Point(0, 0);
  let p2 = new Point(100, 0);
  p1.print();
  kock(n, p1, p2);
  p2.print();
})();

function kock(n, p1, p2) {
  const sin60 = Math.sin(60 * Math.PI / 180);
  const cos60 = Math.cos(60 * Math.PI / 180);
  function innerFunc(n, p1, p2) {
    if (!n) return;
    xDiff = p2.x - p1.x;
    yDiff = p2.y - p1.y;
    let s = new Point(p1.x + xDiff / 3, p1.y + yDiff / 3);
    let t = new Point(s.x + xDiff / 3, s.y + yDiff / 3);
    let u = new Point((t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x,
        (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y);
    kock(n-1, p1, s);
    s.print();
    kock(n-1, s, u);
    u.print();
    kock(n-1, u, t);
    t.print();
    kock(n-1, t, p2);
  }
  // kock = innerFunc;
  innerFunc(n, p1, p2);
}



Measured memory_bytes: 20984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  vi a(m);
  vi b(m);
  rep(i, m){
    ll x,y;
    cin>>x>>y;
    x--;y--;
    a[i]=x;
    b[i]=y;
  }
  rep(i,m){
    UnionFind tree(n+1);//初期化
    bool z = false;
    rep(j, m){
      if (j == i){//i番目の橋をつなげない
        continue;
      }
      tree.unite(a[j],b[j]);
    }
    rep(j, n - 1){
      if (!tree.same(0,j+1)){//一つでも根が違う橋があればans++
        z = true;
      }
    }
    if(z){
      ans++;
    }
  }
  print(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);

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

    vector<vector<int>> dp(k + 1, vector<int>(2));
    dp[0][0] = 1;
    dp[0][1] = 0;

    for (int i = 1; i <= k; ++i)
    {
        // for taro
        dp[i][0] = 1;
        for (int x : a)
            if (i - x >= 0 and dp[i - x][1] == 0)
                dp[i][0] = 0;
        //for jiro
        dp[i][1] = 0;
        for (int x : a)
            if (i - x >= 0 and dp[i - x][0] == 1)
                dp[i][1] = 1;
    }

    if (dp[k][0] == 0)
        cout << "First";
    else
        cout << "Second";
    cout << endl;

    return 0;
}

Measured memory_bytes: 8728
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	string s;
	cin>>s;
	s += 'R';
	int N = s.size();
	vector<int> result(N,0);
	int mode = 1;
	int l = 0;
	//int r = 0;
	for(int i=0; i<N; i++)
	{
		if(mode == 0)
		{
			//Lが続いている
			//次のRまで走査
			if(s[i] == 'R')
			{
				int chain = i-l;
				//cout<<chain<<endl;
				result[l] += chain /2+ chain%2;
				result[l-1] += chain/2 ;
				l=i;
				mode=1;
			}
		}
		else
		{
			//Rが続いている
			//次のLまで走査
			if(s[i] == 'L')
			{
				int chain = i-l;
				//cout<<chain<<endl;
				result[i] += chain /2 ;
				result[i-1] += chain/2 + chain%2;
				l=i;
				mode=0;
			}
		}
	}
	for(int i=0;i<N-1; i++)
	{
		cout<<result[i]<<" ";
	}
	return 0;
}

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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0LL);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<long long> i_p_Ai(N, 0LL);
    vector<long long> j_m_Aj(N, 0LL);
    for (long long i = 0; i < N; ++i) {
        i_p_Ai[i] = i + 1LL + A[i];
        j_m_Aj[i] = i + 1LL - A[i];
    }
    map<long long, vector<long long> > valueIndexes;
    for (long long i = 0; i < N; ++i) {
        if (valueIndexes.count(j_m_Aj[i]) == 0) {
            valueIndexes.insert(make_pair(j_m_Aj[i], vector<long long>()));
        }
        valueIndexes[j_m_Aj[i]].push_back(i);
    }

    long long ans = 0;
    for (long long i = 0; i < N; ++i) {
        if (valueIndexes.count(i_p_Ai[i]) == 0) {
            continue;
        }
        const vector<long long>& indexes = valueIndexes[i_p_Ai[i]];
        auto iter = upper_bound(indexes.begin(), indexes.end(), i);

        ans += distance(iter, indexes.end());
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 28164
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <map>
#define ll long long
using namespace std;

#define MOD 1000000007

class Solve
{
private:
	int h, w;
	unordered_map<char, ll> um;
public:
	Solve(){
		cin >> h >> w;
		for (ll i = 0; i < h; ++i)
		{
			for (ll j = 0; j < w; ++j)
			{
				char tmp;
				cin >> tmp;
				um[tmp]++;
			}
		}
	}

	void exec(){
		if(h % 2 == 0 && w % 2 == 0) {
			for(auto itr : um) {
				if (itr.second % 4  != 0) {
					cout << "No" << endl;
					return;
				}
			}
			cout << "Yes" << endl;
		}else if(h % 2 == 1 && w % 2 == 1) {
			ll cnt4 = 0;
			ll cnt2 = 0;
			ll cnt1 = 0;
			for(auto itr : um) {
				if (itr.second % 4  == 0) {
					cnt4 += itr.second / 4;
				} else if(itr.second % 2 == 0){
					cnt2 += 1;
					cnt4 += itr.second / 4;
				} else {
					if(cnt1 != 0) {
						cout << "No" << endl;
						return;
					}
					cnt1 += 1;
					itr.second--;
					if (itr.second % 4  == 0) {
						cnt4 += itr.second / 4;
					} else if(itr.second % 2 == 0){
						cnt2 += 1;
						cnt4 += itr.second / 4;
					}
				}
			}
			if(cnt1 == 1 && cnt4 >= (h/2) * (w/2) && 2 * (cnt4 - (h/2) * (w/2)) + cnt2 >= (h/2) + (w/2)) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		} else {
			if(h % 2 == 1) swap(h, w);
			ll cnt4 = 0;
			ll cnt2 = 0;
			for(auto itr : um) {
				if (itr.second % 4  == 0) {
					cnt4 += itr.second / 4;
				} else if(itr.second % 2 == 0){
					cnt2 += 1;
					cnt4 += itr.second / 4;
				} else {
					cout << "No" << endl;
					return;
				}
			}

			if(cnt4 >= (h/2) * (w/2) && 2 * (cnt4 - (h/2) * (w/2)) + cnt2 >= (h/2)) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}

	}
};

int main(){
	Solve solver = Solve();
	solver.exec();
}


Measured memory_bytes: 256
function main()
    s,t=sread(),sread()
    ls,lt=length(s),length(t)
    ans=1<<32
    for i in 1:ls-lt+1
        res=0
        for j in 1:lt
            if s[i+j-1]!=t[j]
                res+=1
            end
        end
        ans=min(ans,res)
    end
    println(ans)
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=parse.(ty,sreads())
main()

Measured memory_bytes: 158928
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.0001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n, flag = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2) flag = true;
	}
	if (flag) cout << "first" << endl;
	else cout << "second" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    string ans = "No";
    rep(i, 0, s.size()-1) {
        if (s[i] == 'A' && s[i+1] == 'C') ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	while (true) {
		int n;
		cin >> n;

		if (n == 0) {
			break;
		}

		int w, h;
		cin >> w >> h;

		vector<vector<bool>> grid(h, vector<bool>(w, false));

		for (int i = 0; i < n; i++) {
			int x, y;
			cin >> x >> y;
			grid[y - 1][x - 1] = true;
		}

		int s, t;
		cin >> s >> t;

		int ans = 0;

		for (int i = 0; i < h - t + 1; i++) {
			for (int j = 0; j < w - s + 1; j++) {
				int count = 0;

				for (int y = 0; y < t; y++) {
					for (int x = 0; x < s; x++) {
						if (grid[i + y][j + x] == true) {
							count++;
						}
					}
				}

				ans = max(ans, count);
			}
		}
		
		cout << ans << endl;
	}

	return 0;
}

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

typedef long long ll;

int main(){
    string S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    cin >> N;
    string T;
    cin >> T;
    for(auto x: T){
        auto itr = find(S.begin(), S.end(), x);
        int dist = distance(S.begin(), itr);
        dist += N;
        dist %= 26;
        cout << S[dist];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 100000000
using namespace std;
typedef long long ll;

int W, A[100000];
int d, limit[100000];

int main(void) {
  cin >> W;
  REP(i, 0, W) cin >> A[i];

  REP(i, 0, W) limit[i] = 0;

  d = 0;
  REP(i, 0, W) {
    if(A[i] == 0) d = INF;
    if(A[i] < 0) d = min(d, -A[i]);
    if(A[i] > 0) limit[i] = max(limit[i], d);
    if(d > 0) d--;
  }

  d = 0;
  REP(j, 0, W) {
    int i = W - j - 1;
    if(A[i] == 0) d = INF;
    if(A[i] < 0) d = min(d, -A[i]);
    if(A[i] > 0) limit[i] = max(limit[i], d);
    if(d > 0) d--;
  }

  ll ans = 0;
  REP(i, 0, W) if(A[i] > 0) ans += min(A[i], limit[i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3856
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] Input = Console.ReadLine().Split(' ');
        int A = int.Parse(Input[0]);
        int B = int.Parse(Input[1]);
        string[] Input2 = Console.ReadLine().Split(' ');

        int[] P = new int[N];
        
        for (int i = 0; i < N; i++)
        {
            P[i] = int.Parse(Input2[i]);
        }
        //入力完了

        int cntQ1 = 0;
        int cntQ2 = 0;
        int cntQ3 = 0;

        //それぞれ数調べる
        for (int i = 0; i < N; i++)
        {
            if (P[i] <= A)
            {
                cntQ1++;
            }
            else if (P[i] <= B)
            {
                cntQ2++;
            }
            else
            {
                cntQ3++;
            }
        }

        int tmp = cntQ1 > cntQ2 ? cntQ2 : cntQ1;
        tmp = cntQ3 > tmp ? tmp : cntQ3;

        Console.WriteLine(tmp);
    }
}

Measured memory_bytes: 11092
l,r=map(int,input().split())
if r//2019-(l-1)//2019>0:
    print(0)
else:
    m=20000
    for i in range(l,r):
        for j in range(i+1,r+1):
            if m>(i*j)%2019:
                m=(i*j)%2019
    print(m)


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

using namespace std;
int x[200000];
int n,c,k;
int main()
{
    cin>>n>>c>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];
    }
    sort(x+1,x+1+n);
    int num=1;
    int cnt=1;
    int ans=x[1]+k;
    for(int i=2;i<=n;i++)
    {
        if(ans>=x[i]&&num+1<=c)
        {
            num++;
            //cout<<x[i]<<"A"<<" "<<num<<endl;
        }
        else
        {
           // cout<<x[i]<<endl;
            cnt++;
            ans=x[i]+k;
            num=1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    long h = nextLong();
    int n = nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i] = nextInt();
    }

    Arrays.sort(a);

    for(int i=(n-1);i>=0;i--){
      h -= a[i];
    }

    if(h<=0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 48956
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    ll N, K;
    cin >> N >> K;
    if ((N + 1) / 2 >= K) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var N = o.getValue(0);
    var As = o.getArray(1);
    var Bs = o.getArray(2);
    var Cs = o.getArray(3);

    var result = 0;
    for(var i = 0; N > i; i++) {
        var index = As[i] - 1;
        result += Bs[index];
        if (i > 0 && As[i - 1] === As[i] - 1) result += Cs[index - 1]
    }

    return result;
}

Measured memory_bytes: 21064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()){
			int n = scan.nextInt();
			Integer s[] = new Integer[n+1];

			for(int i = 2; i <= n; i++){
				if(s[i] == null && i%i == 0){
					s[i] = 1;
					
					for(int j = 2; i*j <= n; j++){
						s[i*j] = 0;
					}
				}
			}
			
			//count
			int count = 0;
			for(int i = 2; i <= n; i ++){
				if(s[i] == 1) count++;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 16000
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

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

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int R[110], C[110];

// [i, j) ???????????????????????°????°?
int dp[110][110];

signed main() {
    cin >> N;
    rep(i,0,N) cin >> R[i] >> C[i];
    repq(i,0,N) {
        repq(j,0,N) {
            if(i < j && j-i != 1) {
                dp[i][j] = dp[i][j-1] + R[i] * R[j-1] * C[j-1];
                // printf("dp[%lld][%lld] = %lld\n", i, j, dp[i][j]);
            }
        }
    }

    repq(i,3,N) {
        rep(j,0,N-i+1) {
            rep(k,j+1,j+i) {
                chmin(dp[j][j+i], 
                      dp[j][k] + dp[k][j+i] + R[j] * R[k] * C[j+i-1]);
            }
        }
    }
    cout << dp[0][N] << endl;
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 1e5+123;
int h[N];

void solve() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		int a; scanf("%d", &a);
		++h[a];
	}
	int c = 0;
	for (int i = n = 0; i < N; ++i) {
		if (!h[i]) continue;
		if (h[i]%2) ++n;
		else ++c;
	}
	printf("%d", n+c-c%2);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <sstream> //string stream its useful!
#include<string>
#include<iostream>
#include<utility> //pair
#include <vector> // vector
#include <algorithm>    // swap,sort,binary_search
#include <functional>   // std::greater
#include <map> //map
#include<set> //set
#include<queue> //queue
#include<list> //list
#include<cmath>
#include<numeric>
#include<cassert>
#include <iomanip> //cout<<setprecision
#include <regex>

typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll W = 1000000007;
// tuple にすれば回るんじゃないかな。


using namespace std;
void omajinai() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(15);
    //freopen("txt.csv","r",stdin);
}



static function<ll(ll,ll)> sumfunc = [](ll l1,ll l2)->ll{return l1 + l2;};
class UF{
public:
    vector<ll> v;
    vector<ll> v2;
    function<ll(ll,ll)> func;
    UF(long t,function<ll(ll,ll)> func){
        v = vector<ll>(t);
        v2 = vector<ll>(t);
        for(int i = 0; i<v.size();i++) v[i] = i;
        this->func = func;
    }
    long getunion(long t){
        if(v[t] == t) return t;
        v[t] = getunion(v[t]);
        return v[t];
    }
    void unite(pair<long,long> p){
        long a = getunion(p.first), b = getunion(p.second);
        if(a>b) swap(a,b);
        v[b] = a;
        v2[a] = func(v2[b],v2[a]);
    }
    long sizeofunion(){
        long sum = 0;
        for(int i = 0 ; i<v.size();i++) if(v[i] == i ) sum++;
        return sum;
    }
};

class Main{
public:
    
    int M,N;
    vector<vector<int> > c;
    Main(){
        cin>>N>>M;
        c = vector<vector<int> >(N+1,vector<int>(N+1,0));
        REP(i,M){
            int j,k;
            cin>>j>>k;
            c[j][k] = 1; c[k][j] = 1;
        }
    }
    
    void run(){
        int ans = 0;
        queue<pair<long,int> > q;
        q.push(make_pair(1<<1,1));
        while(!q.empty()){
            pair<long,int> p = q.front();
            q.pop();
            FOR(i,1,N+1){
                if( !(p.first&(1<<i)) && c[p.second][i] == 1){
                    q.push(make_pair(p.first + (1<<i),i));
                    if(p.first + (1<<i) == (1<<(N+1))-2) ans++;
                }
            }
        }
        cout<<ans<<endl;
        return;
    }
};

int main(){
    omajinai();
    Main().run();
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;
const int OBSTACLE = -INF;
const int DIFF = 100;
int field[200][200];

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

bool in_field(int x, int y){
    return 0<=x && x<200 & 0<=y && y<200;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T, N;
    while(cin>>T>>N, T|N){
        for(int i=0; i<200; i++)
            for(int j=0; j<200; j++)
                field[i][j] = INF;
        int x, y;
        while(N--){
            cin >> x >> y;
            field[x+DIFF][y+DIFF] = OBSTACLE;
        }
        int sx, sy;
        cin >> sx >> sy;
        
        queue<pair<int, int>> que;
        field[sx+DIFF][sy+DIFF] = 0;
        que.push(make_pair(sx+DIFF, sy+DIFF));
        
        while(!que.empty()){
            auto p = que.front(); que.pop();
            int x = p.first, y = p.second;
            
            for(int i=0; i<6; i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(in_field(nx, ny) && field[nx][ny] == INF){
                    field[nx][ny] = field[x][y] + 1;
                    que.push(make_pair(nx, ny));
                }
            }
        }
        
        int ans = 0;
        for(int i=0; i<200; i++)
            for(int j=0; j<200; j++)
                ans += (0<=field[i][j] && field[i][j]<=T);
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    int X, Y;
    cin >> X >> Y;

    COMinit();
    ll ans = 0;
    if ((2 * X - Y) % 3 == 0) {
        int b = (2 * X - Y) / 3;
        int a = X - 2 * b;
        // cout << a << " " << b << endl;
        if (b >= 0 && a >= 0) {
            ans = COM(a + b, b);
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  
  if (N % 2 == 0){
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0){
        if (A.at(i) != i+1){
          cout << 0 << endl;
          return 0;
        }
      }
      else {
        if (A.at(i) != i){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  else {
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0){
        if (A.at(i) != i){
          cout << 0 << endl;
          return 0;
        }
      }
      else {
        if (A.at(i) != i+1){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  
  int ans = 1;
  for (int i = 0; i < N/2; i++) {
    ans *= 2;
    ans %= 1000000007;
  }
  cout << ans << endl;
}
      
        
        

    

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

int main() {
	int n, a, b, c, d;
	int sum_a = 0; int sum_b = 0;
	int sum_c = 0; int sum_d = 0;
	cin >> n >> a >> b >> c >> d;
	while (sum_a < n) { sum_a += a; sum_b += b; }
	while (sum_c < n) { sum_c += c; sum_d += d; }
	if (sum_b < sum_d) cout << sum_b << endl;
	else cout << sum_d << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    ll N, A, B; cin >> N >> A >> B;
    ll ans = 0;
    vector<int> X(N); rv(X);
    for (int i = 1; i < N; i++) {
        ans += min((X[i] - X[i-1]) * A, B); 
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(__,v.size()){rep(_,v[__].size())cout<<" "<<v[__][_];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen

signed main(){
	int n;
	cin>>n;
	vi h(40);
	int x=0;
	rep(i,n){
		int a;
		cin>>a;
		x^=a;
		rep(j,40)if(a&1<<j){
			h[j]++;
			break;
		}
	}
	if(!x){
		cout<<0<<endl;
		return 0;
	}
	int co=0,H=true;
	rep(i,40){
		if((x>>i&1)-(x>>(i+1)&1)){
			co++;
			if(h[i]==0)H=false;
		}
	}
	if(!H)cout<<-1<<endl;
	else cout<<co<<endl;
}














Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
    ArrayList<Integer>a=new ArrayList<Integer>();
    ArrayList<Integer>b=new ArrayList<Integer>();
	Scanner sc=new Scanner(System.in);

	int n=sc.nextInt();
	int i;
	for( i=0;i<3*n;i++)
	{
	a.add(sc.nextInt());	
	}
	Collections.sort(a,Collections.reverseOrder());
	long sum=0,k=1;
	
	for(i=0;i<3*n;i++)
	{
		if(k<=n && i%2!=0)
		{
			sum+=a.get(i);
			k++;
		}
		if(k>n)
			break;
	}
	
	System.out.println(sum);
	
	
	}

}


Measured memory_bytes: 94432
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

aida = []
for i in range(len(x)-1):
    a = x[i]
    b = x[i + 1]
    sa = b - a
    aida.append(sa)

if n == 1:
    print(x[-1]-x[0])
else:
    sum_ = sum(sorted(aida)[:-n+1])
    print(sum_)


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

ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
string s;
cin>>s;
int ans=INT_MAX;
for(char c='a';c<='z';c++){
    int left=-1,res=0;
    for(int i=0;i<=s.size();i++){
     if(i==s.size())res=max(res,i-left-1);
    else{
        if(s.at(i)==c){
            res=max(res,i-left-1);
            left=i;
        }
    }
    }
    ans=min(res,ans);
}
cout<<ans<<endl;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

string s;
int dp[505][505];

bool dfs(int l, int r) {
	//cout << "DFS " << l << " " << r << " " << s.substr(l, r - l) << endl;
	if (dp[l][r] != -1) return (bool)dp[l][r];
	if (l == r) return true;

	dp[l][r] = 0;

	if (s[l] == 'm' && s[r - 1] == 'w') {
		for (int i = l + 1; i < r - 1; i++) {
			if (s[i] == 'e') {
				dp[l][r] |= dfs(l + 1, i) && dfs(i + 1, r - 1);
			}
		}
	}

	return dp[l][r];
}

int main() {
	rep(i, 0, 505) rep(j, 0, 505) dp[i][j] = -1;

	cin >> s;
	cout << (dfs(0, (int)s.length()) ? "Cat" : "Rabbit") << endl;
}



Measured memory_bytes: 4188
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n,sz;
int a[MAXN];

int solve() {
	if(n==1) return 0;
	if(sz==n) return 1;
	return (n-1+sz-2)/(sz-1);
}

void run() {
	scanf("%d%d",&n,&sz); REP(i,n) scanf("%d",&a[i]);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
    long L , R;
    cin >> L;
    cin >> R;
    int min= 2020;
    long c;

    if(R-L >= 2018) cout << 0;
    else{
        for(long i = L; i<R; i++){
            for(long j =i+1; j<=R; j++){
                c = (i*j)%2019;
                if(c < min) min = c;
            }
        }
        cout << min << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256