akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;

int lcs(string s,string t)
{
  int c[1005][1005];
  int m=s.size(),n=t.size(),len=0;

  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int i=0;i<=n;i++) c[0][i]=0;


  for(int i=1;i<=m;i++)
  {
    for(int j=1;j<=n;j++)
    {
      if(s.at(i-1)==t.at(j-1)) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);

      len=max(len,c[i][j]);
    }
  }

  return len;
}

int main()
{
  int q;
  cin>>q;
  string s,t;
  for(int i=0;i<q;i++)
  {
    cin>>s>>t;
    cout<<lcs(s,t)<<endl;
  }
}



Measured memory_bytes: 7064
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
 
 
#define ll long long int
#define ld long double
 
#define fr first
#define se second
 
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
 
 
#define pb push_back
#define mp make_pair
 
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))
#define easm(a, b) (a + b - 1) /b 
 
#define PI 3.141592653589793238
 
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

#define min(x, y) x < y ? x : y

//bool valid(int i, int j){return i >= 0 && i < n && j >= 0 && j < m;}

int n;
ll k; 
map<int, ll>m;

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //clock_t z = clock();
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    int a, b;
    cin >> a >> b;
    m[a] += 1ll*b;
  }
  for(auto i : m){
    k -= min(i.se, k);
    if(k == 0)
      return cout << i.fr << endl, 0;
  }
  //debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz size()
#define ft front
#define pu push
#define ty empty
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int m5=100042;
int main(void)
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<int>r;
	vector<int>w;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='W')
		{
			w.pb(i);
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			r.pb(i);
		}
	}	
	int ans=0;
	int m=min(r.sz,w.sz);
	for(int i=0;i<m;i++)
	{
		if(w[i]<r[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4656
#include<stdio.h>
#include<string.h>
int main(){
  char s[1010],t[1010];
  scanf("%s %s",s,t);
  int i,j,k,l=strlen(s);
  for(i=0;i<2;i++){
    k=-1;
    for(j=i;j<l;j+=2){//printf("%c ",s[j]);
      for(k++;t[k]-s[j];k++){
	if(t[k]==0)goto NEXT;
      }
    }
    printf("Yes\n");
    return 0;
  NEXT:;
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 524
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();

    int[] A = new int[N+2];

    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextInt();
    }

    sc.close();

    int all = 0;

    for (int i = 0; i <= N; i++) {
      all += Math.abs(A[i]-A[i+1]);
    }

    for (int i = 1; i <= N; i++) {
      int cost = 0;
      cost = all + Math.abs(A[i-1]-A[i+1]) - Math.abs(A[i-1]-A[i]) - Math.abs(A[i]-A[i+1]);
      System.out.println(cost);
    } 

  }

}

Measured memory_bytes: 63612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		List<Integer> nums = new ArrayList<Integer>();
		for(int i = 0; i < 5; i++) {
			nums.add(scanner.nextInt());
			if(nums.get(i) == 0) {
				System.out.println(i + 1);
				break;
			}
		}
		scanner.close();
	}
}

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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}

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

	int x, y, z; cin >> x >> y >> z;
	int n = x+y+z;
	vector<vi> a(n, vi(3));
	ll ans = 0;
	FOR (i, 0, n-1) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
		a[i][0] -= a[i][2];
		a[i][1] -= a[i][2];
		ans += a[i][2];
	}
	sort(all(a), [](const vi& X, const vi &Y) {
		return X[0] > Y[0];
	});
	
	vector<ll> L(n, -1e18), R(n, -1e18);

	priority_queue<ll, vector<ll>, greater<ll>> pq;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		ll now = a[i][0] - a[i][1];
		if (pq.size() == x) L[i] = sum;
		if (pq.size() < x) pq.push(now), sum += now;
		else {
			if (now > pq.top()) {
				sum += now - pq.top();
				pq.pop();
				pq.push(now);
			}
		}
	}
	while (!pq.empty()) pq.pop();
	multiset<ll> s;
	map<ll, int> mp;
	sum = 0;
	for (int i = 0; i < n; ++i) s.insert(a[i][1]), sum += a[i][1];
	
	for (int i = 0; i < n; ++i) {
		int reqd = y-(i-x);
		if (!mp[a[i][1]]) {
			s.erase(s.find(a[i][1]));
			sum -= a[i][1];
		} else --mp[a[i][1]];
		while ((!s.empty()) && s.size() > reqd) {
			sum -= *s.begin();
			mp[*s.begin()]++;
			s.erase(s.begin());
		}
		if (s.size() == reqd) R[i] = sum;
	}
	sum = 0;
	ll mx = -5e18;
	for (int i = 0; i < n; ++i) {
		mx = max(mx, L[i]+R[i]+sum);
		sum += a[i][1];
	}
	ans += mx;
	cout << ans << "\n";
	
	return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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 n, m, x, c[22], a[22][22];
void solve(){
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++){
		cin >> c[i];
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	
	i64 mi = LINF;
	for(int i = 0; i < (1<<n); i++){
		i64 b[22] = {};
		i64 cnt = 0;
		for(int j = 0; j < n; j++){
			if(i>>j&1){
				for(int k = 0; k < m; k++){
					b[k] += a[j][k];
				}
				cnt += c[j];
			}
		}
		bool ok = 1;
		for(int j = 0; j < m; j++){
			if(b[j] >= x) continue;
			ok = 0;
			break;
		}
		if(ok) chmin(mi,cnt);
	}
	if(mi == LINF) cout << -1 << endl;
	else cout << mi << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3668
import fractions #fractionsに変更用
import random

A, B = list(map(int, input().split()))
C = fractions.gcd(A,B)
cnt = 1
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

def is_prime(n):
    if n == 2: return True
    if n == 1 or n & 1 == 0: return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True

D = make_divisors(C)
for i in D:
    if is_prime(i) == True:
        cnt += 1
print(cnt)

Measured memory_bytes: 68200
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int chain[10002];

int ccount(int a, int b, int cnt){
	if (chain[a] != chain[b])return cnt;
	int len = 0;
	int i, j;
	for (i = a; i >= 0 && chain[a] == chain[i]; i--, len++);
	for (j = b; j < n&&chain[b] == chain[j]; j++, len++);
	if (len < 4)return cnt;
	if (i == -1 || j == n)return cnt + len;
	return ccount(i, j, cnt + len);
}

int main(){
	while (true){
		scanf("%d", &n);
		if (!n)return 0;
		int ans = 0;
		for (int i = 0; i < n; i++)scanf("%d", &chain[i]);
		for (int i = 0; i < n; i++){
			char def = chain[i];
			for (int j = 1; j <= 3; j++){
				chain[i] = j;
				int s, g, cnt = 1;
				for (s = i - 1; s >= 0 && chain[s] == chain[i]; s--, cnt++);
				for (g = i + 1; g < n&&chain[g] == chain[i]; g++, cnt++);
				if (cnt >= 4){
					if (s == -1 || g == n)ans = max(cnt, ans);
					else ans = max(ccount(s, g, cnt), ans);
				}
			}
			chain[i] = def;
		}
		printf("%d\n", n - ans);
	}
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool loop(string s){
	if(SIZE(s)%2) return false;
	bool b=true;
	for(ll i=0;i<SIZE(s)/2;++i){
		if(s[i]!=s[(SIZE(s)+1)/2+i]) b=false;
	}
	return b;
}

int main()
{
	ll n,m,sum=0,tmp=INF;
	cin >> n >> m;
	for(ll i=m;i<m+n;++i){
		sum+=i;
		if(abs(i)<abs(tmp)) tmp=i;
	}
	cout << sum-tmp << endl;
    return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
l = []

for i in range(A, min(B, A+K)):
  l.append(i)
for i in range(max(A, B-K+1), B+1):
  l.append(i)

l = list(set(l))
l.sort()
for i in l:
  print(i)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int n,m;
	string a,b;
	vector <int> v;
	cin>>m>>n;
	if(n>=m){
		cout<<m<<endl;
	}
	else{
		cout<<m-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long int N,K;
	cin>>N>>K;
	unsigned long long int n;
	n=N%K;
	if(n>K/2){
		cout<<K*((N/K)+1)-N<<endl;
	}
	else{
		cout<<n<<endl;
	}
	return 0;
	
}


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

int main() {
    lint n, a, b;
    cin >> n >> a >> b;
    lint ans;
    if ((b - a) % 2 == 0) {
        ans = (b - a) / 2;
    } else {
        lint c = min(a - 1, n - b);
        ans = c + 1 + (b - a - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int a,b,c,d,e,f,g,h;
	scanf("%d %d %d",&a,&b,&c);
	d=abs(a-b);
	e=abs(b-c);
	f=abs(c-a);
	h=d;
	if (h<=e)
	{
		h=e;
	}
	if (h<=f)
	{
		h=f;
	}
	g=d+e+f-h;
	printf("%d\n",g);
}


Measured memory_bytes: 128
#include <stdio.h>

int n, q;
int binarySearch(int *, int); 

int main(){

  int S[100000], T[50000];
  int i, count=0;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%d", &T[i]);
    if(binarySearch(S, T[i]) == 1) count++;
  }

  printf("%d\n", count);

  return 0;
}

int binarySearch(int *A, int key){
  int right, left, mid;

  left = 0;
  right = n;

  while(left < right){
    mid = (left + right)/2;

    if(key == A[mid]) return 1;

    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;

  }
    return 0;
}

Measured memory_bytes: 1184
IDENTIFICATION DIVISION.
PROGRAM-ID. A-DoubleHelix.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 B      PIC X.
01 ENKI   PIC X(4) VALUE 'ACGT'.
01 I      PIC 9.
 
PROCEDURE DIVISION.
  ACCEPT B.

  PERFORM VARYING I FROM 1 BY 1
    UNTIL (I > 4) OR (B = ENKI(I:1))
  END-PERFORM.

  DISPLAY ENKI(5 - I:1).

  STOP RUN.


Measured memory_bytes: 636
#include<stdio.h>
int main(){
	int a[5],i,g=0,t=0,p=0;
	
	while(1){
		scanf("%d",&a[0]);
		if(a[0] == 0) break;
		else if(a[0] == 1) g++;
		else if(a[0] == 2) t++;
		else if(a[0] == 3) p++;
		for(i=1;i<5;i++){
			scanf("%d",&a[i]);
			if(a[i] == 1) g++;
			else if(a[i] == 2) t++;
			else if(a[i] == 3) p++;
		}
		if(g > 0 && t > 0 && p > 0 || g ==5 || t ==5 || p ==5){
			for(i=0;i<5;i++){
				printf("3\n");
			}
			g = 0;
			p = 0;
			t = 0;
		}
		else{
			if(g == 0){
				for(i=0;i<5;i++){
					if(a[i] == 2) printf("1\n");
					if(a[i] == 3) printf("2\n");
				}
			}
			else if(t == 0){
				for(i=0;i<5;i++){
					if(a[i] == 3) printf("1\n");
					if(a[i] == 1) printf("2\n");
				}
			}
			if(p == 0){
				for(i=0;i<5;i++){
					if(a[i] == 1) printf("1\n");
					if(a[i] == 2) printf("2\n");
				}
			}
			
			g = 0;
			p = 0;
			t = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 584
import sys

s = int(input())

ans = 1
al = [s]
while True:
    ans += 1
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    if s not in al:
        al.append(s)
    else:
        print(ans)
        sys.exit()
        

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

using namespace std;

int main(){
	int nums[3];
	
	for(int i = 0; i < 3; i++){
		cin >> nums[i];
	}
	
	for(int i = 0; i < 3; i++){
		int min = 100001;
		int min_index = 10;
		for(int j = 0; j < 3; j++){
			if(min > nums[j]){
				min = nums[j];
				min_index = j;
			}
		}
		nums[min_index] = 100001;
		if(i == 2) cout << min;
		else cout << min << " ";
	}
	
	cout << endl;
	
}


Measured memory_bytes: 3072
#include <iostream>

using namespace std;

void fix(unsigned long & LC, unsigned long & LA, unsigned long RT, unsigned long RA);

int main () {

    unsigned long N, T, A, CT, CA;
    cin >> N;

    cin >> CT >> CA;

    while (--N > 0) {
        cin >> T >> A;
        fix(CT, CA, T, A);
    }

    cout << CT + CA << endl;

    return 0;
}

void fix(unsigned long & LT, unsigned long & LA, unsigned long RT, unsigned long RA) {
    unsigned long mt = LT/RT, ma = LA/RA;
    if (LT % RT != 0) mt++;
    if (LA % RA != 0) ma++;
    unsigned long m = mt > ma ? mt : ma;
    
    LT = m * RT;
    LA = m * RA;
}


Measured memory_bytes: 256
const MOD: i64 = 1_000_000_007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut c = vec![0; n + 2];
    let mut t = 0;
    for i in 0..n + 1 {
        t += i;
        c[i + 1] = t;
    }

    let mut m : i64 = 0;
    for i in k..n + 2 {
        let min = c[i];
        let max = c[n + 1] - c[n + 1 - i];
        m += (max - min + 1) as i64;
        m %= MOD;
    }

    println!("{}", m);
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w,k;
	int ans=0;
	cin >> h >> w>>k;
	vector<string>c(h);
	rep(i,h){
		cin>>c[i];
	}
	int cnt=0;
	rep(bit1,1<<h){
		rep(bit2,1<<w){
			cnt=0;
			rep(i,h){
				rep(j,w){
					if((bit1 & 1<<i) and (bit2 & 1<<j) and c[i][j]=='#'){
						cnt++;
					}
				}
			}
			if(cnt==k){
				ans++;
		//		clog<<bitset<6>(bit1)<<" "<<bitset<6>(bit2)<<endl;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int N; cin>>N;
    cout<<N*(N-1)/2<<endl;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))

sX = sorted(X)
small_median = sX[N//2-1]
large_median = sX[N//2]

for i in range(N):
  if X[i] <= small_median:
    print(large_median)
  else:
    print(small_median)


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

int main(){
  int n; cin >> n;
  set< int > s;
  int count = 1;
  s.insert(n);
  while(1){
   if(n%2){
     n = (3*n) + 1;
     if(s.count(n) > 0){
       cout << count + 1 << '\n';
       return 0;
     }
     else s.insert(n);
   }
   else{
     n = n/2;
     if(s.count(n) > 0){
	  cout << count + 1 << '\n';
      return 0;
     }
     else s.insert(n);
   }
   count++;
  }
  return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll n; cin>>n;
	cout<<n*(n-1)/2<<"\n";
	return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi 3.1415926535
# define eps 1e-4
# define MOD 112233
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=55;
//Code begin...

int num[N][30], ans[30];
char s[N];

int main ()
{
    int n;
    scanf("%d",&n);
    FOR(i,1,n) {
        scanf("%s",s);
        for (int j=0; s[j]; ++j) ++num[i][s[j]-'a'];
    }
    FOR(i,0,25) ans[i]=INF;
    FOR(i,0,25) {
        FOR(j,1,n) ans[i]=min(ans[i],num[j][i]);
        FOR(j,1,ans[i]) putchar('a'+i);
    }
    putchar('\n');
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, k;
string s;
vi comp(100005, 0);

bool check(int sz){
	rep(i, n - sz + 1){
		//we are looking at [i, i + sz)
		int num = comp[i + sz - 1] - (!i ? 0 : comp[i - 1]); //the number of 0 components
		if(i && (s[i - 1] == '0' && s[i] == '0')) num++;
		if(num <= k) return 1;
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> k;
	cin >> s;
	int sz = 0;
	rep(i, n){
		if(i) comp[i] = comp[i - 1];
		if(s[i] == '0'){
			if(!sz) sz = 1, comp[i]++;
			else sz++;
		}
		else{
			if(sz) sz = 0;
		}
	}
	//do prefix sums on the number of 0 components
	//it is monotonic, if we can get n, we can get n - 1
	int l = 0, r = n;
	while(l < r){
		int mid = (l + r + 1) / 2;
		if(check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main()
{
int n;
string s;
cin >> n >> s;

bool p = true;

if(n%2 == 1) p = false;
else{
    rep(i,n/2){
        if(s[i] != s[n/2+i] ) p = false;
    }
}

if(p) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}

ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}

bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll dp[100000 + 5];

ll solv(ll n,vvl &graph) {
	if (dp[n] != 0)return dp[n];
	if (graph[n].size() == 0) {
		dp[n] = 1; return 1;
	}
	//printf("%lld\n", n);
	vl kari(graph[n].size());
	rep(i,0,kari.size()) {
		kari[i] = solv(graph[n][i], graph);
	}
	sort(kari.begin(), kari.end(),sortreverse);
	ll res = 0;
	rep(i, 0, kari.size()) {
		res = max(res, i + 1 + kari[i]);
	}
	dp[n] = res;
	return res;
}

int main() {
	ll n;
	cin >> n;
	vl a(n,0);
	vvl graph(n);
	rep(i, 0, n - 1) {
		cin >> a[i];
		graph[a[i] - 1].push_back(i + 1);
		//graph[i + 1].push_back(a[i] - 1);
	}
	ll ans = solv(0, graph);
	printf("%lld\n", ans - 1);
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n){
        cin >> p.at(i);
        p.at(i)--;
    }

    vector<ll> a(n);
    REP(i, n){
        a.at(i) = 1 + i * n;
    }
    vector<ll> b(a);
    reverse(ALL(b));

    for(ll i = 1; i < n; ++i){
        const ll pi = p.at(i);
        const ll pj = p.at(i - 1);
        ll abi = a.at(pi) + b.at(pi);
        ll abj = a.at(pj) + b.at(pj);
        if(abj >= abi){
            a.at(pi) += abj - abi + 1;
        }
    }

    REP(i, n){
        cout << a.at(i);
        if(i + 1 < n){ cout << ' '; }
    }
    cout << endl;

    REP(i, n){
        cout << b.at(i);
        if(i + 1 < n){ cout << ' '; }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1152
n=int(input())
S=list(map(int, input().split()))
q=int(input())
T=list(map(int, input().split()))
cnt=0

S.sort()
for i in range(n):
    for j in range(q):
        if S[i]==T[j]:
            if S[i-1]!=S[i]:
                cnt+=1
print(cnt)


Measured memory_bytes: 6324
#include<bits/stdc++.h>
#define ll long long
#define MOD 1e9+7;

using namespace std;
int fact(ll x){
    if(x<=1){
        return 1ll;
    }else{
        return x*fact(x-1ll);
    }
}
void swap(ll &a,ll &b){
    ll temp=a;
    a=b;
    b=temp;
}
ll gcd(ll a,ll b){
    while(b){
        a%=b;
        swap(a,b);
    }
    return a;
}

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


int main(){
    int N,M;
    cin>>N>>M;
    vector<int> vt(N,0);
    for(int i=0;i<N;i++){
        cin>>vt[i];
    }
    int ans=1;
    for(int i=0;i<vt.size();i++){
        ans=lcm(ans,vt[i]/2);
    }
    //cout<<ans<<endl;
    int count=0;
    for(int i=0;i<N;i++){
        if((ans/(vt[i]/2))%2==0){
            cout<<0<<endl;
            return 0;
        }
    }
    //for(int i=ans;i<=M;i++){
        //if((i/ans)%2==1&&(i%ans==0)){
        //    count++;
        //}
        count=(M)/ans;
        if(count%2==0){
            cout<<count/2<<endl;
        }else{
            cout<<count/2+1<<endl;
        }
    //}
    //cout<<count<<endl;


    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner

fun main() {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val l = IntArray(n){scn.nextInt()}.also { it.sort() }
	var cnt = 0
	for (i in l.indices){
		val li = l[i]
		for (j in i+1..l.lastIndex){
			val lj = l[j]
			if (li==lj) continue
			for (k in j+1..l.lastIndex){
				val lk = l[k]
				if (li==lk || lj==lk) continue
				if (li+lj>lk) cnt++
			}
		}
	}
	println(cnt)
}


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

#define th M_PI * 60.0 / 180.0

typedef struct point {
  double x, y;
} p;

void koch(int n, p a, p b) {
  if (n == 0) return;
  p s, t, u;
  s.x = (2 * a.x + 1 * b.x) / 3;
  s.y = (2 * a.y + 1 * b.y) / 3;
  t.x = (1 * a.x + 2 * b.x) / 3;
  t.y = (1 * a.y + 2 * b.y) / 3;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8lf %.8lf\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8lf %.8lf\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8lf %.8lf\n", t.x, t.y);
  koch(n - 1, t, b);
}

int main() {
  int n;
  p a, b;
  scanf("%d", &n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8lf %.8lf\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8lf %.8lf\n", b.x, b.y);

  return 0;
}



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

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

  if(a < b){
    cout <<"a < b" <<"\n";
 }
  else if(a == b){
    cout <<"a == b" <<"\n";
 }
  else if(a >= b){
    cout <<"a > b" <<"\n";
 }
 
  return 0;
}

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

int main()
{
    int k;
    cin >> k;
    int a,b;
    cin >> a >> b;
    int tmp = k;
    while(tmp <= b){
        //cout << tmp << endl;
        if(tmp >= a && tmp <= b){
            cout << "OK" << endl;
            return 0;
        }
        tmp += k;
    }
    cout << "NG" << endl;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int h, w;
char field[110][110];
int ans[110][110];

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

  for(int i = 1; i <= h; i++){

    int cloud = -1;

    for(int j = 1; j <= w; j++){
      if(field[i][j] == 'c'){
	cloud = 0;
      }
      
      ans[i][j] = cloud;

      if(cloud != -1){
	cloud++;
      }
    }
  }

  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      cout << ans[i][j];

      if(j < w){
	cout << " ";
      }
      else{
	cout << endl;
      }
    }
  }
    
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    array<bool, 10> v{};

    for (auto _ : irange(0, 4)) {
        int n;
        cin >> n;
        v[n] = true;
    }

    cout << ((v[1] && v[9] && v[7] && v[4]) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>//region #include <cp_helper>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
#define vii vector<ii>
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define pin(n) in(n.first) >> n.second
#define vin(a, n) for (ll i=0; i<n; ++i) in(a[i])
#define viin(a, n) for (ll i=0; i<n; ++i) in2(a[i].first, a[i].second);
#define out(n) cout << n
#define outs(n) out(n) << ' '
#define outn(n) out(n) << '\n'
#define out2(n, m) cout << n << ' ' << m
#define out2s(n, m) out2(n, m) << ' '
#define out2n(n, m) out2(n, m) << '\n'
#define pout(n) out2(n.first, n.second)
#define pouts(n) pout(n) << ' '
#define poutn(n) pout(n) << '\n'
#define vout(a) for (auto i : a) outs(i)
#define viout(a) for (auto i : a) out2n(i.first, i.second)
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for (ll i=0; i<n; ++i)
#define foris(i, a, b) for (ll i=a; i<b; ++i)
#define ford(i, n) for (ll i=n-1; i>=0; --i)
#define fords(i, a, b) for (ll i=a; i>=b; --i)
#define forr(i, a) for (auto i : a)
const int mod = (int)(1e9) + 7;
//endregion

int n, arr[100005], c, mc;

int main() {
    io();
    in(n);
    vin(arr, n);
    fori (i, n-1) {
        if (arr[i] >= arr[i+1]) c++;
        else c = 0;
        mc = max(mc, c);
    }
    out(mc);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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;}

string burger;
ll rec(ll N, ll X) {
  if(N==0) return 1;
  ll len = (1LL<<(N+1)) - 3;
  ll num = (1LL<<N) - 1;
  if(X==1) return 0;
  if(X<=len+1) return rec(N-1, X-1);
  if(X==len+2) return num+1;
  if(X<=(len+1)*2) return num+1+rec(N-1,X-len-2);
  return num*2+1;
}

int main() {
  ll N, X; cin >> N >> X;
  cout << rec(N, X) << endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  return true;
}

char tmp[100];

int ask(int x) {
  printf("%d\n", x);
  fflush(stdout);
  scanf("%s", tmp);
  if (tmp[0] == 'V') {
    return -1;
  } else if (tmp[0] == 'M') {
    return 0;
  } else if (tmp[0] == 'F') {
    return 1;
  } else {
    assert(false);
  }
}

void solve() {
  int lval = ask(0);
  if (lval == -1) {
    return;
  }
  int rval = ask(n - 1);
  if (rval == -1) {
    return;
  }
  assert(lval != rval);
  int l = 0, r = n - 1;
  while (true) {
    int m = (l + r) / 2;
    int mval = ask(m);
    if (mval == -1) {
      return;
    }
    if ((mval ^ (m & 1)) == (lval ^ (l & 1))) {
      l = m;
      lval = mval;
    } else {
      r = m;
      rval = mval;
    }
  }
}

int main() {
  precalc();
  read();
  solve();
#ifdef DEBUG
  eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(void){
    int n,i, buf;
    cin >> n;
    vector<int> vec1(MAX), vec2(MAX);
    for(i=0; i<MAX; i++){
        vec1.at(i) = 0;
        vec2.at(i) = 0;
    }
    for(i=0; i<n; i++){
        cin >> buf;
        if(i%2 == 0){
            vec1.at(buf-1)++;
        }else{
            vec2.at(buf-1)++;
        }
    }
    int m1 = 0, m2 = 0;
    for(i=0; i<MAX; i++){
        if(vec1.at(i) > vec1.at(m1)){
            m1 = i;
        }if(vec2.at(i) > vec2.at(m2)){
            m2 = i;
        }
    }
    
    sort(vec1.begin(), vec1.end());
    sort(vec2.begin(), vec2.end());
    reverse(vec1.begin(), vec1.end());
    reverse(vec2.begin(), vec2.end());
    
    int ans;
    if(m1 != m2){
        ans = n-vec1.at(0)-vec2.at(0);
    }else{
        ans = min(n-vec1.at(1)-vec2.at(0), n-vec1.at(0)-vec2.at(1));
    }
    cout << ans << endl;
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

const int MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];

ll comb(ll v) { return v * (v - 1) / 2; }

int main() {
  map<ll, ll> m;

  ll N;
  scanf("%lld", &N);

  vll list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    m[v]++;

    list[i] = v;
  }

  ll all = 0;
  auto ite = m.begin();
  for (; ite != end(m); ite++) {
    ll k = (*ite).first;
    ll v = (*ite).second;
    if (v >= 2) {
      all += comb(v);
    }
  }

  for (ll i = 0; i < N; i++) {
    ll n = list[i];
    ll count = m[n];

    ll a = all;
    if (count >= 2) {
      a = a - comb(count) + comb(count - 1);
    }

    cout << a << endl;
  }
}


Measured memory_bytes: 9160
import sys
import copy

def solve(N: int, A: "List[List[int]]"):
    B = copy.deepcopy(A)
    for start_node in range(0,N):
        for end_node in range(start_node+1,N):
            min_dist = 10**12
            for transit in range(N):
                if transit == start_node or transit == end_node:
                    continue
                min_dist = min(min_dist,A[start_node][transit]+A[transit][end_node])

            ## impossible
            if A[start_node][end_node] > min_dist:
                print(-1)
                return 
            elif A[start_node][end_node] == min_dist:
                B[start_node][end_node] = 0
            else:
                continue
    answer =0
    for i in range(N):
        for j in range(i+1,N):
            answer+=B[i][j]
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57436
(defmacro dotimes-unroll ((var count size &optional result) &body body)
  "DOTIMES macro with loop-unrolling by SIZE."
  (let ((whole (gensym))
        (_count (gensym)))
    (check-type var symbol)
    (check-type size (integer 1 #.most-positive-fixnum))
    `(block ,whole
       (let ((,_count ,count)
             (,var 0))
         (declare ((integer 0 #.most-positive-fixnum) ,var ,_count))
         (loop
           (when (> ,var (- ,_count ,size))
             (do ((,var ,var (1+ ,var)))
                 ((>= ,var ,_count)
                  (return-from ,whole ,result))
               ,@body))
           ,@(loop for i from 0 below size
                   collect `(locally ,@body (setq ,var (+ ,var 1)))))))))

(defun main ()
  (declare (optimize (speed 3) (safety 0)))
  (let* ((n (read))
         (res 0))
    (declare ((unsigned-byte 62) res)
             (uint32 n))
    (dotimes-unroll (i n 20)
      (incf res i))
    (princ res)
    (terpri)))

#-swank (main)


Measured memory_bytes: 20196
while True:
    l = input().split()
    a = int(l[0])
    b = int(l[2])
    op = l[1]
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        if b == 0:
            break
        print(a//b)
    else:
        break
    


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

#define eb emplace_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using Vi = vector<int>;

void run() {
	ll a, b;
	cin >> a >> b;
	cout << (a*b) << endl;
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    double st = clock();

    int t = 1;
    // cin >> t;

    while(t--) {
        run();
    }

    cerr << "\n" << "time = " << (clock() - st) / CLOCKS_PER_SEC << "\n";
    return 0;
}

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

using namespace std;

const int MAXN = 1e5 + 5, inf = 1e9;

struct Robot {
    int x, l;
};

int base = 1, Tree[2 * 1024 * 1024], dp[MAXN][2];
Robot robot[MAXN];
map<int, int> sc;

void chTree(int node, int v) {
    node += base;
    Tree[node] = max(Tree[node], v);
    while (node /= 2) {
        Tree[node] = max(Tree[2 * node], Tree[2 * node + 1]);
    }
}

int read(int l, int r) {
    l += base;
    r += base;
    int res = max(Tree[l], Tree[r]);
    while (l / 2 != r / 2) {
        if (l % 2 == 0) {
            res = max(res, Tree[l + 1]);
        }
        if (r % 2 == 1) {
            res = max(res, Tree[r - 1]);
        }
        l /= 2;
        r /= 2;
    }
    return res;
}

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> robot[i].x >> robot[i].l;
        sc[robot[i].x - robot[i].l];
        sc[robot[i].x + robot[i].l];
        sc[robot[i].x];
    }

    int id = 0;
    for (auto &it : sc) {
        it.second = id++;
    }

    while (base < id) {
        base *= 2;
    }

    sort(robot + 1, robot + n + 1, [](auto a, auto b) {
        return a.x - a.l < b.x - b.l;
    });

    for (int i = 1; i <= n; ++i) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
        dp[i][1] = read(0, sc[robot[i].x - robot[i].l]) + 1;
        chTree(sc[robot[i].x + robot[i].l], dp[i][1]);
    }
    cout << max(dp[n][0], dp[n][1]) << "\n";
}


Measured memory_bytes: 20352
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt(),B = sc.nextInt();

		if(A > (B * 2)) {
			System.out.println(A - (B * 2));
		}else {
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string in; cin >> in;
	int K; cin >> K;
	set<string> s;
	rep(i, in.size()){
		string t;
		rep(j, 5) if(i + j < in.size()){
			t += in[i + j];
			s.insert(t);
		}
	}
	for(auto i : s){
		if(--K == 0){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1664