akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
const int N = 2e5+1;
vi pos[26];
vii a;
vi mid;
int bit[N];
void update(int id,int val)	{for(;id<N;id+=id&-id)	bit[id]+=val;}
int find(int id)
{
	int res=0;
	for(;id>0;id-=id&-id)	res += bit[id];
	return res;
}
int main()
{
	int i,n;
	string s;
	cin >> s;
	n = s.size();
	for(i=0;i<n;i++)
	{
		pos[s[i]-'a'].push_back(i);
	}
	for(i=0;i<26;i++)
	{
		int l=0,r=pos[i].size()-1;
		while(l<r)
		{
			a.push_back(ii(pos[i][l],pos[i][r]));
			l++;r--;	
		}
		if(l==r)	mid.push_back(pos[i][l]);
	}
	if(mid.size()>1)	
	{
		printf("-1");
		return 0;
	}
	ll ans = 0ll;
	if(mid.size()==1)
	{
		for(auto j : a)
		{
			if(mid[0]<j.first)	ans++;
			if(mid[0]>j.second)	ans++;
		}
	}
	sort(a.begin(),a.end());
	for(auto j : a)
	{
		ans += find(j.first)+find(j.second);
		update(j.second,1);
	}
	printf("%lld",ans);
}


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

int main(){
  char b, c[128];
  c['A'] = 'T';
  c['T'] = 'A';
  c['C'] = 'G';
  c['G'] = 'C';
  cin >> b;
  cout << c[(int)b] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,i,j,n,*A,count=0,minj;
  scanf("%d",&N);
  A=(int*)malloc(sizeof(int)*N);
  for(i=0;i<N;i++)
      scanf("%d",&A[i]);
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){

	minj=j;
      }
    }
    if(i!=minj)
    count++;
      n=A[i];
      A[i]=A[minj];
      A[minj]=n;}
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i<N-1)
      printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#include<math.h>
main(){

  int i,g,d,H[10];

  while(1){

    if(scanf("%d",&g) == EOF){
      break;
    }

    d=512;
    for(i=0;i<=9;i++){
      H[i]=0;
    }

    for(i=9;i>=0;i--){

      if(g>=d){
	g -= d;
	H[i]=1;
      }

      if(g==0){
	break;
      }

      d /= 2;

    }

    for(i=0;i<=9;i++){
      if(H[i]==1){
	printf("%.f",pow(2,i));
	i++;
	break;
      }
    }

    for(;i<=9;i++){
      if(H[i]==1){
	printf(" %.f",pow(2,i));
      }
    }
    
    printf("\n");
    
  }

  return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
    using namespace std;
	
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		int n;
		cin>>n;
		cout<<1000*(n/500)+((n%500)/5)*5<<"\n";
		return 0;
    }

Measured memory_bytes: 256
/**
 *   author: sahushivam
 *   created: 01 February 2019  22:39:19
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff

void optimizeIO(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}
ll *dp=new ll[100005];
int main(){
    optimizeIO();
    ll N,W;
    cin>>N>>W;
    int *v=new int[N];
    ll *w=new ll[N];
    REP(i,0,100005)dp[i]=INF;
    //cout<<dp[1000];
    dp[0]=0;
    REP(i,0,N) cin>>w[i]>>v[i];
    for(int i=0;i<N;i++)
    {
      for(int j=100005;j>=0;j--)
      {
        if(j>=v[i])
        {
          dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
      }
    }
    RREP(i, 100001, 0){
        if( dp[i] <= W ){
            cout << i << endl;
            return 0;
        }
    }
return 0;
}

Measured memory_bytes: 1024
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#define INF 0x3f3f3f3f
#define NO 100005
#define MO 100005
typedef long long ll;
//by Oliver
using namespace std;
ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int n, m, p[NO], cnt[NO];
struct node
{
	int pre, y, pos;
	string ID;
}city[NO];
//variable

bool cmp1(node i, node j)
{
	return i.y < j.y;
}
bool cmp2(node i, node j)
{
	return i.pos < j.pos;
}
void init()
{
	m = read(), n = read();
	for (int i = 1; i <= n; i++)
		city[i].pre = read(), city[i].y = read(), city[i].pos = i;
	sort(city + 1, city + n + 1, cmp1);
}
string tos(int x)
{
	string ans, k;
	for (int i = 1; i <= 6; i++)
		k += x % 10 + '0', x /= 10;
	for (int i = 5; i >= 0; i--)
		ans += k[i];
	return ans;
}
//functions

int main()
{
	init();
	for (int i = 1; i <= n; i++)
	{
		string s1 = tos(city[i].pre), s2 = tos(++cnt[city[i].pre]);
		city[i].ID = s1 + s2;
	}
	sort(city + 1, city + n + 1, cmp2);
	for (int i = 1; i <= n; i++)
		cout << city[i].ID << endl;
	return 0;
}
//main


Measured memory_bytes: 12032
#!/usr/bin/python3

import random, math, fractions

def lcm(a, b):
    return (a // fractions.gcd(a, b)) * b

def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

def primes(n):
    lst = []
    for i in range(2, n + 1):
        if is_prime(i):
            lst.append(i)
    return lst

n = int(input())

a = [[None for j in range(n)] for i in range(n)]

lst = [(i,j) for i in range(n) for j in range(n - 1, -1, -1)]

used = set()
pr = primes(10 ** 4)

off = 0
while pr[off] < n + 3:
    off += 1

for (i, j) in lst:
    if (i + j) % 2 == 0:
        A = (i + j) // 2
        B = n + (i - j) // 2
        a[i][j] = (A + 1) * (pr[off + B])
        if a[i][j] in used:
            print(101, a[i][j])
            raise ValueError()
        used.add(a[i][j])
        
for (i, j) in lst:
    if (i + j) % 2 == 0:
        continue
    
    val = 1
    for (ip, jp) in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
        if 0 <= ip < n and 0 <= jp < n and a[ip][jp] != None:
            val = lcm(val, a[ip][jp])

    if val >= 5 * 10 ** 14:
        print("ERR", val)
        raise ValueError()
    
    res = val + 1
    while res in used:
        k = random.randint(1, (10 ** 15 - 1) // val)
        res = k * val + 1

    a[i][j] = res
    used.add(res)

for i in range(n):
    print(" ".join(map(str, a[i])))


Measured memory_bytes: 49296
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int q;
    cin >> q;
    vector<int> b(q),c(q);
    rep(i,q)cin >> b[i] >> c[i];
    vector<int>cnt(100005);
    ll ans = 0;
    rep(i,n){
        cnt[a[i]]++;
        ans += a[i];
    }
    rep(i,q){
        ll minus = (ll)b[i]*cnt[b[i]];
        ll add = (ll)c[i]*cnt[b[i]];
        cnt[c[i]] += cnt[b[i]];
        cnt[b[i]] = 0;
        ans = ans + add - minus;
        cout << ans << endl;
    }

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 4832
mod = 998244353
n=int(input())
d=[int(i) for i in input().split()]
ans=[0]*n
for i in d:
    ans[i]+=1
f=mod
for i in ans:
    if f==0 and i>0:
        print(0)
        exit()
    f=min(f,i)
if d.count(0)!=1 or d[0]!=0:
    print(0)
    exit()
cnt=1
if ans[2]==0:
    print(1)
    exit()
for i in range(1,n):
    if ans[i]==0:
        break
    cnt=cnt*pow(ans[i-1],ans[i],mod)%mod
 
print(cnt%mod)

Measured memory_bytes: 53676
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	cin >> a;
	int cnt = 0;
	range(i, 1, n - 1) {
		if (a[i - 1] < a[i] and a[i] < a[i + 1]) cnt++;
		if (a[i - 1] > a[i] and a[i] > a[i + 1]) cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string s;
    string t;
    cin >> s >> t;
    int k = s.size();
    int count = 0;
    for (int i = 0; i < k; i++)
    {
        if (s[i] != t[i])
        {
            count++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
template<class T, class U> bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }

vector<bool> sieve_of_atkin(int N){
    vector<bool> isprime(N + 1);
    const int sqrtN = sqrt(N);
    int n;
    for(int z = 1; z <= 5; z += 4) for(int y = z; y <= sqrtN; y += 6){
        for(int x = 1; x <= sqrtN && (n = 4*x*x+y*y) <= N; ++x) isprime[n] = !isprime[n];
        for(int x = y+1; x <= sqrtN && (n = 3*x*x-y*y) <= N; x += 2) isprime[n] = !isprime[n];
    }
    for(int z = 2; z <= 4; z += 2) for(int y = z; y <= sqrtN; y += 6){
        for(int x = 1; x <= sqrtN && (n = 3*x*x+y*y) <= N; x += 2) isprime[n] = !isprime[n];
        for(int x = y+1; x <= sqrtN && (n = 3*x*x-y*y) <= N; x += 2) isprime[n] = !isprime[n];
    }
    for(int y = 3; y <= sqrtN; y += 6) for(int z = 1; z <= 2; ++z){
        for(int x = z; x <= sqrtN && (n = 4*x*x+y*y) <= N; x += 3) isprime[n] = !isprime[n];
    }
    for(int n = 5; n <= sqrtN; ++n) if(isprime[n]) for(int k = n*n; k <= N; k+=n*n) isprime[k] = false;
    isprime[2] = isprime[3] = true;
    return isprime;
}
vector<int> primes(int N){
    auto isprime = sieve_of_atkin(N);
    vector<int> ans;
    for(int i = 2; i <= N; i++) if(isprime[i]) ans.push_back(i);
    return ans;
}

int main(){
    const int MAX = 1000000;
    const auto P = primes(MAX);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int& i : a) cin >> i;
    
    if(reduce(a.begin(), a.end(), 0, gcd<int, int>) != 1) return puts("not coprime") & 0;
    
    vector<int> divisor_count(MAX + 1);
    for(int i : a) divisor_count[i]++;
    
    // 素因数ゼータ変換 ( primes(MAX).size() 次元累積和 )
    for(int p : P) for(int i = MAX / p; i; i--) divisor_count[i] += divisor_count[i * p];
    
    for(int p : P) if(divisor_count[p] >= 2) return puts("setwise coprime") & 0;
    puts("pairwise coprime");
}


Measured memory_bytes: 11604
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	string S;
	cin>>S;
	int s = 0;
	int t = 0;
	REP(i, S.size()) {
		if(S[i] == 'S') ++s;
		if(S[i] == 'T') {
			if(s == 0) ++t;
			else --s;
		}
	}
	cout<<s + t<<endl;
}


Measured memory_bytes: 644
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=br.readLine();
        String[] T;
        int c=0;
        while(true){
        	T=br.readLine().split(" ");
        	if(T[0].equals("END_OF_TEXT")) break;
        	for(String str : T){
              if(str.equalsIgnoreCase(W)) c++;
            }
        }
        System.out.println(c);
	}
}

Measured memory_bytes: 24264
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

a,b = list(map(int, stdin.readline().rstrip().split()))
print(max(a+b,a-b,a*b))


Measured memory_bytes: 38768
#include <stdio.h>
int main(void) {
	int i, j, H, W;
	while (scanf("%d %d", &H, &W) != EOF) {
		if(H == 0 && W == 0) {
		break;
		}
		for (i = 1; i <= H; i++) {
			for (j = 1; j <= W; j++) {
				printf("#");
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2104
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  std::map<std::string, std::string> m = {
    {"Sunny", "Cloudy"}, {"Cloudy", "Rainy"}, {"Rainy", "Sunny"}
  };
  std::string s; std::cin >> s;
  std::cout << m[s] << std::endl;
}


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

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

  int N;
  string S;
  cin >> N;
  map<string, int> poll;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(poll.count(S)){
      poll.at(S) = poll.at(S) + 1;
    } else{
      poll[S] = 1;
    }
  }
  int max = 0;
  for(auto x: poll){
    auto value = x.second;
    if(value > max){
      max = value;
    }
  }
  for(auto x: poll){
    auto key = x.first;
    auto value = x.second;
    if(value == max){
      cout << key <<endl;
    }
  }
}


Measured memory_bytes: 23808
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1

j = -2
mymax = 1   
for i in range(0, N):
    tmp = GCD(l_list[i], r_list[j])
    if tmp > mymax: mymax = tmp 
    j -= 1
print(mymax)

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    vector<int> v(n);
    cin >> n;
    rep(i, n)
    {
        cin >> v[i];
    }
    int sum1, sum2;
    int ans = inf;
    for (int i = 1; i <= n-1;i++){
        sum1 = 0;
        sum2 = 0;
        for (int j = 0; j < i; j++)
        {
            sum1 += v[j];
        }
        for (int k = n - 1; k >= i;k--){
            sum2 += v[k];
        }
        if(ans>max(sum1,sum2)-min(sum1,sum2)){
            ans = max(sum1, sum2) - min(sum1, sum2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 33024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   float n;
   cin >> n;
   out(ceil(n/2)/n);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
int k;
bool flag[101];

int main(void){
	cin >> s;
	scanf("%d",&k);
	ll ans=0;
	for(int i=0;i+1<s.size();i++){
		if(s[i]==s[i+1] && !flag[i] && !flag[i+1]){
			flag[i+1]=true;
			ans++;
		}
	}
	if(k>1){
		if(s.size()==1){
			ans=k/2;
		}else if(s[0]!=s[s.size()-1] || flag[s.size()-1]){
			ans=ans*k;
		}else{
			memset(flag,false,sizeof(flag));
			flag[0]=true;
			ll ans2=1;
			for(int i=0;i+1<s.size();i++){
				if(s[i]==s[i+1] && !flag[i] && !flag[i+1]){
					flag[i+1]=true;
					ans2++;
				}
			}
			//printf("%lld %lld\n",ans,ans2);
			if(!flag[s.size()-1]){
				ans+=ans2*(k-1);
			}else{
				ll cal=k/2LL;
				ll ans3=cal*(ans+ans2);
				if(k%2==1){
					ans+=ans3;
				}else{
					ans=ans3;
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC\n";
    else cout << "ABC\n";
    return 0;
} 

Measured memory_bytes: 3620
import java.util.*;



class Main
    {
        public static void main(String args[]) {
            Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n];
            int count = 0;
            for(int i = 0; i < n; i++) {
                a[i] = in.nextInt();
                if(a[i] >= k) count++;
            }
            System.out.println(count);
        }
    }


Measured memory_bytes: 51832
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  int n,k;
  string s;
  cin >> n >> k;
  cin >> s;
  
  vector<int> num;
  if(s[0]=='0') num.push_back(0);
  for(int i=0; i < s.size();){
    int j = i;
    while(j<s.size() && s[j]==s[i]) j++;
    num.push_back(j-i);
    i = j;
  }
  if(s.back()=='0') num.push_back(0);
  
  vector<int> sum(num.size()+1, 0);
  REP(i,num.size()){
    sum[i+1] = sum[i] + num[i];
  }
  
  int ans = 0;
  for(int left=0; left<sum.size(); left+=2){
    int right = left + 2*k + 1;
    if(right>sum.size()-1) right = sum.size() -1;
    ans = max(ans, sum[right]-sum[left]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1272
N=int(input())
a = list(map(int, input().split()))
isend = False
for i in range(N):
    if a[i]%2 ==0:
        if a[i]%3 == 0 or a[i]%5==0:
            pass
        else:
            isend= True
            break


if isend:
    print("DENIED")

else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std; 

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> d, sum;
    int zero = 0, one = 0;
    bool f,f2; // zero?
    f = S[0] == '0' ? true : false;
    f2 = f;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '0') {
            if (!f) {
                d.push_back(one);
                one = 0;
                f = true;
            }
            zero++;
        }
        else {
            if (f) {
                d.push_back(zero);
                zero = 0;
                f = false;
            }
            one++;
        }
    }
    if (zero > 0) {
        d.push_back(zero);
    }
    else if (one > 0) {
        d.push_back(one);
    }
    int wa = 0;
    //sum[i]:d[0]～d[i]までの和
    for (int i = 0; i < (int)d.size(); i++)
    {
        wa += d[i];
        sum.push_back(wa);
    }

    if (!f2) {
        if ((int)sum.size() <= 2 * K + 1) {
            cout << sum[(int)sum.size() - 1] << endl;
            return 0;
        }   
        int m;
        int k = 0;
        for (; k < (int)sum.size() - 2 * K; k += 2)
        {
            if (k == 0) {
                m = sum[2 * K];
            }
            else {
                m = max(m, sum[2 * K + k] - sum[k - 1]);
            }
        }
        m = max(m, sum[(int)sum.size() - 1] - sum[k - 1]);
        cout << m << endl;
    }
    else {
        if ((int)sum.size() <= 2 * K) {
            cout << sum[(int)sum.size() - 1] << endl;
            return 0;
        }
        int m;
        int k = 1;
        m = sum[2 * K-1];
        for (; k < (int)sum.size() - 2 * K; k += 2)
        {
            m = max(m, sum[2 * K + k] - sum[k - 1]);
        }
        m = max(m, sum[(int)sum.size() - 1] - sum[k - 1]);
        cout << m << endl;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <cmath>

//a^n mod p
//n > 0
//#include <cmath>
long long modpow(long long a, long long n, long long p) {
  a %= p;
  if (a == 0) return 0;
  if (a == 1) return 1;
  long long b = 1, cnt = 0;
  while (b < p && cnt < n) {
    b *= a;
    cnt++;
  }
  if (b < p) return b;
  b %= p;
  return modpow(b, n / cnt, p) * (long long)pow(a, n % cnt) % p;
}

//モジュラ逆数
long long modinv(long long n, long long p) {
  long long a = p, u = 1, v = 0;
  while (a) {
    long long t = n / a;
    n -= t * a;
    std::swap(n, a);
    u -= t * v;
    std::swap(u, v);
  }
  u %= p;
  if (u < 0) u += p;
  return u;
}

int main() {
  long long n, a, b, p = 1e9 + 7;
  std::cin >> n >> a >> b;
  long long ans = modpow(2, n, p) - 1;

  long long x = 1, y = 1;
  for (long long i = 0; i < std::min(a, n - a); i++) {
    x *= n - i;
    x %= p;
  }
  for (long long i = 0; i < std::min(a, n - a); i++) {
    x *= modinv(i + 1, p);
    x %= p;
  }
  for (long long i = 0; i < std::min(b, n - b); i++) {
    y *= n - i;
    y %= p;
  }
  for (long long i = 0; i < std::min(b, n - b); i++) {
    y *= modinv(i + 1, p);
    y %= p;
  }

  ans -= x + y;
  while (ans < 0) ans += p;
  std::cout << ans << std::endl;
}

Measured memory_bytes: 384
y = "Yay!"
n = ":("
a = int(input().strip())
b = int(input().strip())
c = int(input().strip())
d = int(input().strip())
e = int(input().strip())
k = int(input().strip())

if abs(a - e) > k:
        ans = n
else:
        ans = y
print(ans)


Measured memory_bytes: 38256
N,M,C = map(int,input().split())
b = [int(i) for i in input().split()]
a = []
ret = 0
for i in range(N):
    a.append([int(j) for j in input().split()])

for i in range(N):
    s = 0
    for j in range(M):
        s += a[i][j] * b[j]
    if s + C > 0:
        ret += 1
print(ret)

Measured memory_bytes: 3064
#ifndef BZ
#pragma GCC optimize "-O3"

#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n;
ll a[1200];
int en[1200];
ll sm[2];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i) {
		if (a[i] > 0)
			sm[i % 2] += a[i];
	}
	if (sm[0] == 0 && sm[1] == 0) {
		int pos = max_element(a, a + n) - a;
		vector<int> vv;
		for (int i = n - 1; i > pos; --i)
			vv.push_back(i);
		for (int i = 0; i < pos; ++i)
			vv.push_back(0);
		cout << a[pos] << "\n";
		cout << vv.size() << "\n";
		for (int i: vv)
			cout << i + 1 << "\n";
		return 0;
	}
	if (sm[0] > sm[1]) {
		for (int i = 0; i < n; i += 2)
			if (a[i] > 0)
				en[i] = 1;
	}
	else {
		for (int i = 1; i < n; i += 2)
			if (a[i] > 0)
				en[i] = 1;
	}
	vector<int> vv;
	int now = 0;
	while (now < n) {
		if (!en[now]) {
			vv.push_back(0);
			now += 1;
			continue;
		}
		else {
			if (now + 1 == n)
				break;
			else if (now + 2 == n) {
				vv.push_back(1);
				break;
			}
			else if (en[now + 2]) {
				vv.push_back(1);
				now += 2;
			}
			else if (now + 3 != n) {
				vv.push_back(2);
				now += 2;
				en[now] = 1;
			}
			else {
				vv.push_back(2);
				vv.push_back(1);
				break;
			}
		}
	}
	cout << max(sm[0], sm[1]) << "\n";
	cout << vv.size() << "\n";
	for (int i: vv)
		cout << i + 1 << "\n";
	return 0;
}




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

int main(){
    int s;  cin >> s;
    vector<int> a;
    a.push_back(s);
    ll ans=0;
    for(int i=1;; i++){
        if(s%2==0)  s/=2;
        else  s = 3*s+1;
        auto itr = find(a.begin(), a.end(), s);
        if(itr!=a.end()){
            ans = i+1;   break; 
        } 
        a.push_back(s);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if a + b <= c*2:
    print(x*a + y*b)
elif x >= y:
    print(min(x*2*c, y*2*c + (x-y)*a))
else:
    print(min(y*2*c, x*2*c + (y-x)*b))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define MP 1000001
using namespace std;
bool p[MP],a[MP];
int main(){
	for(int i=2;i*i<MP;i++)if(!p[i])for(int j=i+i;j<MP;j+=i)p[j]=1;p[0]=p[1]=1;
	int c[30],n,x,ans;
	while(cin>>n>>x,n){
		fill(a,a+x+1,0);
		rep(i,n)cin>>c[i];
		ans=0,a[0]=1;
		rep(i,x+1)rep(j,n)if(i>=c[j]&&a[i-c[j]]){
			a[i]=1; if(!p[i])ans=i;
		}
		if(ans)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}

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

  
int main() {
  int N,K;
  cin >>N>>K;
  vector<int> v(N);
  rep(i,N)cin>>v[i];
  sort(v.begin(),v.end(),greater<int>());
  int sum=0;
  rep(i,K)sum+=v[i];
  

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vector<bool> is_prime(100001, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= 100000; i++) {
        if (is_prime[i]) {
            for (int j=2*i; j <= 100000; j += i) {
                is_prime[j] = false;
            }
        }
    }
    
    vector<int> ans(100001, 0);
    for (int i = 1; i <= 100000; i += 2) {
        if (is_prime[i] && is_prime[(i+1)/2]) ans[i] += 1;
    }
    for (int i = 1; i <= 100000; ++i) {
        ans[i] += ans[i-1];
    }

    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }
    
}

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

using i64 = long long int;

const i64 MAX = 10000000000000000 + 1000;

int main(){
    i64 k;
    cin >> k;

    for(i64 n=2;n<=50;++n){
        if(n-1+k/n > MAX)continue;
        i64 diff = k % n;
        cout << n << endl;
        for(int i=0;i<n;++i){
            cout << (n-1+k/n) + (diff > 0 ? 1 : -(k%n));
            diff--;
            if(i == n-1)cout << endl;
            else cout << " ";
        }
        break;
    }

    return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2000000007
#define infll 1e18
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;
typedef long double ld;

const int N = 1000002;

int n,a[N];


int main(int argc, const char * argv[]) {
    
    int ans = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        scanf("%d",&a[i]);
        while (!(a[i]&1)) ++ans, a[i]>>=1;
    }
    
    printf("%d\n",ans);
    return 0;
}

/*
 
 3 3
 2 1 1 1 3 1
 2 2 1 2 3 2
 2 3 1 3 3 4
 
 
 5 1
 2 1 1 3 3 1
 

 */





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

int main() {
    int N,W; cin >> N >> W;
    vector<int> w(N);
    vector<int> v(N);
    for(int i = 0; i < N; i ++) cin >> w[i] >> v[i];
    vector<vector<long long>> dp(N+1, vector<long long>(W+1));
    for(int i = 0; i < N; i ++) {
        for(int sumw = 0; sumw <= W; sumw ++) {
            if(sumw-w[i]>=0) dp[i+1][sumw] = max(dp[i+1][sumw], dp[i][sumw-w[i]]+v[i]);
            dp[i+1][sumw] = max(dp[i+1][sumw], dp[i][sumw]);
        }
    }
    cout << dp[N][W] << endl;
}

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


int main(void) {
    
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    v[0]--;
    for(int i=1;i<n;i++){
        if(v[i-1]<v[i])v[i]--;
    }
    rep(i,n-1){
        if(v[i]>v[i+1]){
            fin("No");
            return 0;
        }
    }
    fin("Yes");
}


Measured memory_bytes: 640
import re
import copy

def accept_input():
    H, W = map(int, input().split())
    S = []
    for _ in range(H):
        S.append(input())
    return H,W,S

def process(s):
    if s == "#":
        return 1
    else:
        return 0
H,W,S = accept_input()
arr1 = [(-1,-1),(-1,0),(-1,1),(1,-1),(1,0),(1,1),(0,1),(0,-1)]
arr = [(-1,0),(1,0),(0,1),(0,-1)]
new_S = copy.deepcopy(S)
g = 0
b = 0
for i in range(H):
    for j in range(W):
        if new_S[i][j] == "#":
            bl = 0
            for idou in arr:
                if i+idou[0] == -1 or i+idou[0] == H:
                    continue
                elif j+idou[1] == -1 or j+idou[1] == W:
                    continue
                else:
                    if new_S[i+idou[0]][j+idou[1]] == "#":
                        bl = 1
            if bl != 1:
                b = 1
                break
    if b == 1:
        break
if b == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9948
N = int(input())
S = list(map(int,input().split()))

def marge(l,r):
    count = 0
    conq = []
    i = 0
    j = 0
    k = len(l) + len(r)
    l.append(float('inf'))
    r.append(float('inf'))
    for o in range(k):
        if l[i] <= r[j]:
            conq.append(l[i])
            i += 1
        else:
            conq.append(r[j])
            j += 1
        count += 1
    return conq,count
           
def margeSort(s):
    n = len(s)
    if n == 1:
        return s,0
    else:
        L, cnt_L = margeSort(s[:n//2])
        R,cnt_R = margeSort(s[n//2:])
        s,cnt = marge(L,R)         
    return s,cnt+cnt_R+cnt_L
S,count = margeSort(S)
print(*S)
print(count)


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

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;;
  vector<int>x(n);
  vector<int>y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  int x_max = x[0];
  int y_min = y[0];
  bool OK = false;
  for (int i = X+1; i <= (Y); ++i){
    if(x[0] < i && i <= y[0]) {
      OK =true;
      break;
    }
  }
  if(OK) puts("No War");
  else puts("War");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   
   int n;
   cin>>n;
   vector<int> a(n,0);
   vector<int> b(n,0);
   ll sa=0,sb=0;
   rep(i,n){
      cin>>a[i];
      sa+=a[i];
   }
   rep(i,n){
      cin>>b[i];
      sb+=b[i];
   }
   ll ans=max(sa,sb);
   rep(i,n){
      ll kari=sb;
      rep(j,i-1){
         kari-=b[j];
      }
      rep(j,i){
         kari+=a[j];
      }
      if(i==0) kari+=a[0];
      ans=max(kari,ans);
   }

   cout<<ans;
return 0;
}



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

int search(int key){
  for(int i=0;i<V.size();i++){
    if(V[i] == key) return -1;
  }
  return 1;
}

int main(void){
  int n, x;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x;
    if(search(x) == 1) V.push_back(x);
  }
  cout << V.size() << endl;
}


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

struct ac{
    int x, y;
}a[55], d[55];

int cmp1(ac b, ac c)
{
    return b.x < c.x;
}

int cmp2(ac b, ac c)
{
    return b.y<c.y;
}

int sl(int x1,int y1,int x2,int y2,int i)
{
    int xl = min(x1, x2), xr = max(x1, x2);
    int yl = min(y1, y2), yr = max(y1, y2);
    if(a[i].x >= xl && a[i].x <= xr && a[i].y >= yl && a[i].y <= yr)
    {
        return 1;
    }
    return 0;
}

int main()
{
    ll maxx = 1ll*10e9*10e9*4+2;
    int n, k1;
    cin >> n >> k1;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i].x >> a[i].y;
        d[i].x = a[i].x, d[i].y = a[i].y;
    }
    sort(a+1, a+1+n,cmp1);
    sort(d+1, d+n+1,cmp2);
    for(int i = 1; i <= n; i++)
    {
        for(int j = i+1; j <= n; j++)
        {
            for(int k = 1; k <= n; k++)
            {
                for(int l = k+1; l <= n; l++)
                {
                    int flag = 0;
                    for(int u = 1; u <= n; u++)
                    {
                        if(sl(a[i].x,d[k].y,a[j].x,d[l].y,u))
                        {
                            flag++;
                        }
                    }
                    if(flag >= k1)
                    {
                        maxx = min(maxx, (ll)abs(1ll*a[i].x-1ll*a[j].x)*abs(1ll*d[k].y-1ll*d[l].y));
                    }
                }
            }
        }

    }
   cout << maxx << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
p = [int(i) for i in input().split()]
graph = [[] for _ in range(N+1)]
group = [0]*(N+1)
ans = 0
for _ in range(M):
    x, y = (int(i) for i in input().split())
    graph[x].append(y)
    graph[y].append(x)
for i, num in enumerate(p, 1):
    space = [i]
    for point in space:
        if group[point]:
            continue
        group[point] = i
        space.extend(graph[point])
    ans += (group[num] == group[i])
print(ans)

Measured memory_bytes: 28900
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

ll a[100010];
int main(){
    int n,q,tmp;
    ll sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&tmp);
        a[tmp]++;
        sum+=(ll)tmp;
    }
    scanf("%d",&q);

    ll b,c;
    while(q--){
        scanf("%lld%lld",&b,&c);
        sum+=a[b]*(c-b);
        a[c]+=a[b],a[b]=0;
        printf("%lld\n",sum);
    }
}


Measured memory_bytes: 4540
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long


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

    int r; cin >> r;
    cout << r*r;
 
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N,M,ans[9901];
  scanf("%d",&N);
  if(N%2==1){
    printf("%d\n",(N-1)*(N-1)/2);
    for(int i=1;i<=N-1;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j!=N){printf("%d %d\n",i,j);}
      }
    }
  }else{
    printf("%d\n",(N-2)*N/2);
    for(int i=1;i<=N-1;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j!=N+1){printf("%d %d\n",i,j);}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        List<Integer> c = Arrays.asList(3, 5, 7);
        out.println(c.contains(a) ? "YES" : "NO");
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


Measured memory_bytes: 19284
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

N = parseInt(readline())
A = parseMap(split(readline()))

dict = Dict{Int,Int}()
memo = Dict{Int,Int}()

for a in A
    if a in keys(dict)
        dict[a] += 1
    else
        dict[a] = 1

    end
end

base_ans = 1
#println(dict)
for i in values(dict)
    base_ans += (i^2 - i) ÷ 2
end
#println(base_ans)
#println()
for a in A
    if a in keys(memo)
        println(memo[a])
    else
        ans = base_ans - dict[a] 
        memo[a] = ans
        println(ans)
    end
end

Measured memory_bytes: 217620
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {


    string s;cin>>s;int count =0;
    for(int i=0;i<3;++i)
    {
    	if(s[i]==s[i+1])
    		count++;

    }if(count>=1)
    	cout<<"Bad"<<endl;
    else
    	cout<<"Good"<<endl;






    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define INF (1<<30)
#define MIN(a,b) (a<b? a:b)
long long p[101], memo[101][101], n;

void MCM(void){
	int i,j,k,len;
	for(i=1;i<=n;i++)memo[i][i]=0;

	for(len=2;len<=n;len++){
		for(i=1; i<=n-len+1; i++){
			j=i+len-1;
			memo[i][j]=INF;

			for(k=i; k<j; k++){
				memo[i][j]=MIN(memo[i][j],memo[i][k]+memo[k+1][j]+(p[i-1]*p[j]*p[k]));
			}
		}
	}
}

int main(){
	int i;	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lli%lli",&p[i],&p[i+1]);
	}
	MCM();
	printf("%lli\n",memo[1][n]);

	return 0;
}



Measured memory_bytes: 2132
#include <stdio.h>
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(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 i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);
    return 0;
}


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

// the distance functions are in blocks
// forward edges only to future blocks
// backwards edges only to self & immediate predecessor

using ll = long long;

const int MAXN = 600;
int N;
ll A[MAXN][MAXN];

ll backPref[MAXN][MAXN];
ll forwPref[MAXN][MAXN];

ll dp[MAXN][MAXN]; // max value we can save

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (j == i) A[i][j] = 0;
			else cin >> A[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			if (i < j) {
				forwPref[i+1][j+1] = A[i][j];
			} else {
				backPref[i+1][j+1] = A[i][j];
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			forwPref[i+1][j+1] += forwPref[i][j+1] + forwPref[i+1][j] - forwPref[i][j];
			backPref[i+1][j+1] += backPref[i][j+1] + backPref[i+1][j] - backPref[i][j];
		}
	}

	for (int j = 1; j < N; j++) {
		// back [0,j) by [0,j)
		// no forwards
		dp[0][j] = backPref[j][j];
	}
	for (int i = 1; i < N; i++) {
		for (int j = i+1; j <= N; j++) {
			for (int k = 0; k < i; k++) {
				// back [i,j) by [k,j)
				// forwards [0,i) by [i,j)
				dp[i][j] = max(dp[i][j], dp[k][i]
						+ (backPref[j][j] - backPref[i][j] - backPref[j][k] + backPref[i][k])
						+ (forwPref[i][j] - forwPref[0][j] - forwPref[i][i] + forwPref[0][i])
						);
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, dp[i][N]);
	}

	ans = -ans;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j) continue;
			ans += A[i][j];
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 11136