akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

#define loop(i, num)  for (lint i = 0; i < num; i++)
#define l  first
#define r  second
#define lint  long long

using namespace std;

lint n, ans;

vector<lint> upp, mid, low;

int main() {
    
    cin >> n;
    
    upp.resize(n);
    
    mid.resize(n);
    
    low.resize(n);
    
    loop (i, n)  cin >> upp[i];
    
    loop (i, n)  cin >> mid[i];
    
    loop (i, n)  cin >> low[i];
    
    lint up = 0, lw = 0;
    
    sort(upp.begin(), upp.end());
    
    sort(mid.begin(), mid.end());
    
    sort(low.begin(), low.end());
    
    loop (md, n) {
        
        lint x, y;
        
        while (up < n && upp[up] < mid[md])  ++up;
        
        while (lw < n && mid[md] >= low[lw])  ++lw;
        
        x = up;
        
        y = n - lw;
        
        ans += x * y;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}


Measured memory_bytes: 2560
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for A - Still TBD
	var S string
	fmt.Scanf("%s", &S)

	yyyy, _ := strconv.Atoi(S[0:4])
	mm, _ := strconv.Atoi(S[5:7])
	if yyyy <= 2018 {
		fmt.Println("Heisei")
	} else if yyyy == 2019 && mm <= 4 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 1832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int D; cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    int s[D][26];
    rep(i,D) rep(j,26) cin >> s[i][j];
  
  rep(i,D){
    cout << i % 26 + 1 << endl;
  }
}

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

typedef long double ld;

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    ll k;
    cin>>k;
    k--;
    cout<<arr[k]<<endl;
    
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

void Main() {
	string s, t;
	cin >> t >> s;
	int ans = 1000;
	for (int i = 0; i < t.size() - s.size() + 1; i++) {
		int diff = 0;
		for (int j = 0; j < s.size(); j++) {
			if (s[j] == t.substr(i, s.size())[j]) {

			} else {
				diff++;
			}
		}
		if (diff <= ans) {
			ans = diff;
		}
	}
	cout << ans << endl;
}

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

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

namespace _0150
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> sosuu = new List<int>();
            for (int i = 2; i < 10000; i++)
            {
                bool b = true;
                for (int j = 0; j < sosuu.Count; j++)
                {
                    if (i % sosuu[j] == 0)
                    {
                        b = false;
                    }
                }
                if (b)
                {
                    sosuu.Add(i);
                }
            }
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                bool find = true;
                int x = 0;
                for (int i = n; find; i--)
                {
                    if (sosuu.Contains(i) && sosuu.Contains(i - 2))
                    {
                        x = i;
                        find = false;
                    }
                }
                Console.WriteLine((x - 2) + " " + (x));
            }
        }
    }
}

Measured memory_bytes: 9816
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

vector<vector<int>> graph(100001,vector<int>());

int main(){
  int n,k,q;cin >> n >> k >> q;
  int a[n]={};for(int i=0;i<q;i++){
    int ai;cin >> ai;
    a[ai-1] += 1;
  }
  rep{
    if(k-(q-a[i])<=0){
      cout << "No" <<endl;
    }else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 3328
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,a[111111], ans, mn = 11111111111, cnt;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(a[i]<0)cnt++;
    ans+=abs(a[i]);
    mn = min( mn, abs(a[i]) );
  }

  if(cnt%2){
    cout << ans - 2*mn << endl;
  }
  else {
    cout << ans << endl;
  }

return 0;
}
///....


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

using namespace std;

int main() {
  long N;
  cin >> N;
  string res;
  while (N > 0) {
    int r = (N - 1) % 26;
    res += 'a' + r;
    N = (N - r) / 26;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T,p,R;
    cin >> T >> p >> R;
    while(T != 0){
        vector<pair<int,pair<int,int>>> G(T);
        for(int i=0; i<T; i++){
            G[i].second.second = i;
        }
        vector<vector<int>> cnt(T,vector<int> (p,0));
        for(int i=0; i<R; i++){
            int tid,pid,time;
            string message;
            cin >> tid >> pid >> time >> message;
            tid--;
            pid--;
            if(cnt[tid][pid] == -1) continue;
            if(message == "CORRECT"){
                G[tid].first--;
                G[tid].second.first += time+1200*cnt[tid][pid];
                cnt[tid][pid] = -1;
            }else{
                cnt[tid][pid]++;
            }
        }
        sort(G.begin(),G.end());
        for(int i=0; i<T; i++){
            cout << G[i].second.second+1 << " " << -G[i].first << " " << G[i].second.first << endl;
        }
        cin >> T >> p >> R;
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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()
{
	ll N;
	cin >> N;
	FOR(k, 1, 1000) {
		if (2 * N == k * (k-1)) {
			vector<vector<ll>> ans(k);
			REP(i, k-1) {
				ans[0].push_back(((i+2)*(i+1))/2);
			}
			FOR(i, 1, k) {
				REPR(j, i) {
					ans[i].push_back(ans[0][i-1]-j);
				}
				FOR(j, i, k-1) {
					ans[i].push_back(ans[i].back()+j);
				}
			}
			PRINT("Yes");
			PRINT(k);
			REP(i, k) {
				cout << k-1 << " ";
				REP(j, k-1) {
					cout << ans[i][j] << " ";
				}
				cout << endl;
			}
			return 0;
		}
	}
	PRINT("No");
	return 0;
}




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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main(){
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(void) {
	// in
	int n, m;
	std::cin >> n >> m;
	std::vector<int> a(n), b(m), c(m);
	std::vector<std::pair<int, int>> cards(n+m);
	for(int i = 0; i < n; ++i) std::cin >> a[i];
	for(int i = 0; i < m; ++i) std::cin >> b[i] >> c[i];
	
	for(int i = 0; i < n; ++i) cards[i] = std::make_pair(a[i], 1);
	for(int i = 0; i < m; ++i) cards[n+i] = std::make_pair(c[i], b[i]);

	// sort
	std::sort(cards.begin(), cards.end(), [](std::pair<int, int> &lhs, std::pair<int, int> &rhs) { return lhs.first > rhs.first; });

	// sum
	long long sum_cards = 0;
	int n_cards = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < cards[i].second; ++j) {
			n_cards += 1;
			sum_cards += cards[i].first;
			if(n_cards >= n) goto _loop_end;
		}
	}

	_loop_end:
	std::cout << sum_cards << std::endl;

	return 0;
}


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

int main() {
  int num;
  int cnt = 1;
  int all = 0;
  cin >> num;
  
  vector<int> vec(num);
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  for(int i = 0; i < num; i++){
    if(vec.at(i) % 2 == 0){
      cnt *= 2;
    }else{
      cnt *= 1;
    }
  }
  all = pow(3, num);

  cout << all -cnt;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	int i,a,b;
	rep(i,7){
	scanf("%d%d",&a,&b);
	printf("%d\n",a-b);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

int main(void){
   int N,i,j,a[100],v,minj,cnt=0,kari;
   scanf("%d",&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;
		}
		
			kari=a[i];
			a[i]=a[minj];
			a[minj]=kari;
			if(i!=minj)
			cnt++;
	}
	
	 for(j=0;j<N;j++){
printf("%d",a[j]);
while(j!=N-1){
putchar(' ');
break;
}
}

putchar('\n');
printf("%d\n",cnt);


	return 0;
}


Measured memory_bytes: 1932
n=int(input())
l=sorted(list(map(int,input().split())),reverse=1)
from collections import Counter as co
d=co(l)
ans=0
for i in l:
    x=pow(2,i.bit_length())-i

    if d[i]>0 and x in d and d[x]>0:
        if x!=i:d[x]-=1;ans+=1;d[i]-=1
        elif d[i]>=2:d[i]-=2;ans+=1
print(ans)

Measured memory_bytes: 33216
N = int(input())
maximum = 1
for k in range(1,N+1):
  if k*(k-1)//2 < N <= k*(k+1)//2:
    maximum = k
    break
while N > 0:
  for j in range(maximum,0,-1):
    if N-j >= 0:
      print(j)
      N = N-j

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

using namespace std;

typedef long long ll;

const int N = 5e3 + 10;
const ll oo = 1e16;

int n;
ll a[N];
vector<int> adj[N];
ll dp[N][2][N], tmp[2][N], sz[N];

void dfs(int u, int par){
    dp[u][0][0] = (a[u] > 0);
    dp[u][1][0] = a[u];
    sz[u] = 1;
    for(int v: adj[u]) if(v != par) {
        dfs(v, u);
        fill(tmp[0], tmp[0] + n, 0);
        fill(tmp[1], tmp[1] + n, oo);
        for(int k = sz[u] - 1; k >= 0; k--)
            for(int l = sz[v] - 1; l >= 0; l--){
                if(dp[u][0][k] && dp[v][1][l]<0)
                    tmp[0][k + l + 1] = 1;
                if(dp[u][0][k] && dp[v][0][l])
                    tmp[0][k + l]=1;
                if(dp[u][1][k] < oo && dp[v][0][l])
                    tmp[1][k + l + 1] = min(tmp[1][k + l + 1], dp[u][1][k]);
                if(dp[u][1][k] < oo && dp[v][1][l] < oo)
                    tmp[1][k + l] = min(tmp[1][k + l], dp[u][1][k] + dp[v][1][l]);
            }
        sz[u] += sz[v];
        swap(dp[u], tmp);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(0, -1);
    for(int i = 0; i < n; i++)
        if(dp[0][0][i] || dp[0][1][i] < 0) {
            cout << i;
            return 0;
        }
}


Measured memory_bytes: 392704
def qsort(lst):
    if len(lst) == 0:
        return lst

    n = lst[0]

    l = []
    r = []

    for x in lst[1:]:
        if x < n:
            l.append(x)
        else:
            r.append(x)

    return qsort(l) + [n] + qsort(r)

nums = qsort(list(map(int, input().split())))

print(' '.join(map(str, nums)))



Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a,b;
		Scanner scan = new Scanner(System.in);

		while ((scan.hasNext())) {

			a = Integer.parseInt(scan.next());
			b = Integer.parseInt(scan.next());

			System.out.println(a + b);

		}
	}
}

Measured memory_bytes: 11000
n, m = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()

BC = []
for _ in range(m):
    b, c = map(int, input().split())
    BC.append([b, c])

BC.sort(key=lambda x : x[1], reverse=True)
D = []
i = 0
count = 0
while (len(D) < n) and (len(BC) > i) :
    D.append(BC[i][1])
    count += 1
    if count == BC[i][0]:
        count = 0
        i += 1
        
j = 0
while (len(D) > j) and (A[j] <= D[j]) :
    A[j] = D[j]
    j += 1
    
print(sum(A))

Measured memory_bytes: 25532
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));

		String s;
		try {
			s = br.readLine();

			StringTokenizer st;

			while (s != null) {
				st = new StringTokenizer(s);
				int p = Integer.parseInt(st
						.nextToken()) + Integer
								.parseInt(st
										.nextToken());

				System.out.println((int) Math
						.log10(p)
						+ 1);
				s = br.readLine();

			}

		} catch (IOException e) {
			System.exit(0);
		}

	}
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int a[n][m], b[m][l];
    long ans[n][l];
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            ans[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                ans[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j!=l-1){
               printf("%ld ",ans[i][j]);
            }else{
               printf("%ld\n",ans[i][j]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;

const int k = 50;
vector<vector<char>> g(k * 2, vector<char>(k * 2, '#'));
int a, b;

void stod()
{
    REP(i,k) {
        REP(j,k) {
            if (a == 0)
                return;

            g[i * 2][j * 2] = '.';
            a--;
        }
    }
}

void dtos()
{
    REP(i,k) {
        REP(j,k) {
            if (b == 0)
                return;

            g[i * 2 + k + 1][j * 2] = '#';
            b--;
        }
    }
}

int main()
{
    REP(i,k) {
        REP(j,k * 2) {
            g[k + i][j] = '.';
        }
    }

    cin>>a>>b;
    a--; b--;

    stod();
    dtos();

    cout<<k * 2<<" "<<k * 2<<endl;
    REP(i,k * 2) {
        REP(j,k * 2) {
            cout<<g[i][j];
        }
        nextline;
    }

    return 0;
}


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

typedef long double ld;
int n, c, m;
int f[305][35], l[10];
ld ans;

template <class T>
inline T Max(T x, T y) {return x > y ? x : y;}
template <class T>
inline T Min(T x, T y) {return x < y ? x : y;}

int main()
{
	scanf("%d%d", &n, &c);	
	m = n * c;
	for (int i = 0; i < n; ++i)
		scanf("%d", &l[i]);
	std::sort(l, l + n);

	int res = 1;
	for (int i = 1; i < n; ++i)
		res *= i;
	ld tmp = res;
	for (int i = 1; i < n; ++i)
		tmp *= (ld)c;
	const int C = 1 << n - 1;
	for (int i = 1; i <= res; ++i)
	{
		for (int j = 0; j <= m; ++j)
			for (int s = 0; s < C; ++s)
				f[j][s] = 0;
		f[l[n - 1] * n][0] = 1;
		for (int j = 1; j <= m; ++j)
			if (j % n > 0)
			{
				int x = j % n - 1;
				for (int s = 0; s < C; ++s)
					if (!(1 << x & s))
						for (int k = j; k <= m; ++k)
							if (f[k][s])
								f[Min(m, Max(k, j + l[x] * n))][1 << x | s] += f[k][s];
			}
		std::next_permutation(l, l + n - 1);
		ans += (ld)f[m][C - 1] / tmp;
	}
	printf("%.16Lf\n", ans);
}

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

int main() {
  int a;
  cin >> a;
  if (a < 1200) {
    cout << "ABC" << endl;
  } else if (a >= 2800) {
    cout << "AGC" << endl;
  } else {
    cout << "ARC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
var
  t,i,j,k:longint;
  a:array[1..3] of longint;
begin
  read(a[1],a[2],a[3]);
  for i:=1 to 2 do
    for j:=i+1 to 3 do
      if a[j]<a[i] then
        begin
        t:=a[i]; a[i]:=a[j]; a[j]:=t;
        end;
    if a[2]-a[1]<>a[3]-a[2] then write('NO')
                            else write('YES');
end.

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 100, INF = 1e9 + 10, MOD = 1e9 + 7;

vector<ll> vec, ans, cur;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<vector<ll>> graph;
vector<ll> a, b;

void input() {
    ll n, l;
    cin >> n;
    a.resize(n);
    b.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
}

void rand_test() {
    
}

ll sol() {
    ll xr = 0;
    for (int i = 29; i >= 1; i--) {
        ll curPw = (1ll << i);
        for (auto &cur : a) cur &= (curPw - 1);
        for (auto &cur : b) cur &= (curPw - 1);
        sort(b.begin(), b.end());
        ll curC = 0, t = curPw / 2;
        if (i == 1) {
            cout << "";
        }
        for (auto cur : a) {
            int l1, r1, l2, r2;
            int l = -1, r = b.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if ((cur + b[mid]) >= t) {
                    r = mid;
                }
                else {
                    l = mid;
                }
            }

            l1 = r;

            l = -1, r = b.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if ((cur + b[mid]) >= 2 * t) {
                    r = mid;
                }
                else {
                    l = mid;
                }
            }

            r1 = r;

            curC += (r1 - l1);

            l = -1, r = b.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if ((cur + b[mid]) >= 3 * t) {
                    r = mid;
                }
                else {
                    l = mid;
                }
            }

            l2 = r;

            l = -1, r = b.size();
            while (r - l > 1) {
                int mid = (l + r) / 2;
                if ((cur + b[mid]) >= 4 * t) {
                    r = mid;
                }
                else {
                    l = mid;
                }
            }

            r2 = r;

            curC += r2 - l2;
        }

        curC %= 2;
        xr |= (1ll << (i - 1)) * curC;
    }

    return xr;
}

ll brute() {
    ll xr = 0;
    for (int i = 0; i < a.size(); i++) {
        for (int j = 0; j < b.size(); j++) xr ^= (a[i] + b[j]);
    }

    return xr;
}
int main()
{
    fastInp;

    ll t;
    t = 1;

    while (t--) {
        input();
        cout << sol();
    }

    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    sort(ALL(a));
    ll ans=0;
    rep(i,0,n-2)rep(j,i+1,n-1)rep(k,j+1,n){
        if(a[i]-a[j]<a[k]&&a[k]<a[i]+a[j])ans++;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 
#define ALL(a)  (a).begin(),(a).end()



using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  long long a,b;
  cin>>a>>b;
  if(a<=0&&b>=0){
    cout<<"Zero"<<endl;
  }else{
    if(a>0){
      cout<<"Positive"<<endl;
    }else{
      if((b-a+1)%2==0){
        cout<<"Positive"<<endl;
      }else{
        cout<<"Negative"<<endl;
      }
    }
  }

}





Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for(int i = 0; i < s.length(); i++) {
      if(s.charAt(i) == '0') {
        ans += "0";
      } else if(s.charAt(i) == '1') {
        ans += "1";
      } else {
        if(!ans.equals("")) {
          ans = ans.substring(0, ans.length() - 1);
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {

		int[] rank = new int[3];
		for (int i = 0; i < 10; i++) {
			int v = readInt();
			for (int j = 0; j < rank.length; j++) {
				if (v > rank[j]) {
					int pre = rank[j];
					rank[j] = v;
					v = pre;
				}
			}

		}
		for (int i = 0; i < 3; i++) {
			System.out.println(rank[i]);
		}

	}

	private final static BufferedReader br = new BufferedReader(
			new InputStreamReader(System.in));

	private static int readInt() throws IOException {
		return Integer.parseInt(br.readLine(), 10);
	}

}

Measured memory_bytes: 9352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func NewScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func NewWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func ScanStr(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan string failed")
	}
	return s.Text()
}

func ScanInt(s *bufio.Scanner) int {
	return int(ScanInt64(s))
}

func ScanInt64(s *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(ScanStr(s), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	s := NewScanner()
	w := NewWriter()
	defer w.Flush()

	a := ScanInt(s)
	op := ScanStr(s)
	b := ScanInt(s)
	if op == "+" {
		fmt.Fprintln(w, a + b)
	} else {
		fmt.Fprintln(w, a - b)
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define VMAX 10000

int main(){
	int *A,*B;
	int C[VMAX + 1];
	int n, i,j;
	scanf("%d", &n);
	A = new int[n+1];
	B = new int[n+1];
	for (i = 0; i <= VMAX; i++){
		C[i] = 0;
	}
	for (int i = 0; i < n; i++){
		scanf("%d", &j);
		A[i + 1] = j;
		C[A[i + 1]]++;
	}

	for (i = 1; i <= VMAX; i++){
		C[i] += C[i - 1];
	}

	for (i = n; i > 0; i--){
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}


	for (int i = 1; i <= n; i++){
		if (i > 1)printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");
	delete[] A;
	delete[] B;
	return 0;
}

Measured memory_bytes: 17940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int N,C[500],S[500],F[500];
int main ()
{
scanf("%d",&N);
for(int i=0;i<N-1;i++)scanf("%d%d%d",&C[i],&S[i],&F[i]); for(int i=0;i<N;i++)
{
int t=0;
for(int j=i;j<N-1;j++) {
if(t<S[j])t=S[j]; else if(t%F[j]==0); else t=t+F[j]-t%F[j]; t+=C[j];
} printf("%d\n",t);
}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
typedef pair<double, int> P;
const LL MOD = 1000000007LL;
LL dp[1010][1001];
LL fact[1001];
LL inv[1001];
LL inv_fact[1001];
LL mod_pow(LL a, LL n) {
	if (n == 0) return 1;
	if (n % 2 == 0) {
		LL tmp = mod_pow(a, n / 2);
		return (tmp*tmp) % MOD;
	}
	else {
		return (a*mod_pow(a, n - 1)) % MOD;
	}
}
LL comb(LL n, LL k) {
	if (k > n) return 0;
	LL ans = fact[n];
	ans = (ans*inv_fact[k]) % MOD;
	ans = (ans*inv_fact[n - k]) % MOD;
	return ans;
}
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	fact[0] = 1;
	inv_fact[0] = 1;
	REP(i, 1, N + 1) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv[i] = mod_pow(i, MOD - 2);
		inv_fact[i] = (inv_fact[i - 1] * inv[i]) % MOD;
	}
	dp[A][N] = 1;
	REP(i, A, B + 1) {
		rep(j, N + 1) {
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
			if (j < i*C) continue;
			LL tmp = inv_fact[C - 1];
			for (int k = 0; k <= C-2; k++) {
				tmp = (tmp*comb(j - i*k, i)) % MOD;
			}
			for (int k = C; k <= D&&i*k <= j; k++) {
				tmp = (tmp*comb(j - i*(k - 1), i)) % MOD;
				tmp = (tmp*inv[k]) % MOD;
				LL add = (dp[i][j] * tmp) % MOD;
				dp[i + 1][j - i*k] = (dp[i + 1][j - i*k] + add) % MOD;
			}
		}
	}
	cout << dp[B + 1][0] << endl;
}

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

using namespace std;


int main()
{

     int a,b,c,d;
      cin>>a>>b>>c>>d;

      int r=d-a;
      int sum=0;
      if(r>0)
        sum=a;
      else
      {
           sum=d;
           cout<<sum<<endl;
           return 0;
      }

      r=a+b;

      r=d-r;

      if(r>0)
        sum=sum-r;
      cout<<sum<<endl;






        return 0;


}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a[2][100];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 2)FOR(j, 0, n) cin >> a[i][j];
  FOR(i, 1, n) a[0][i] += a[0][i-1];
  FORR(i, n-2, 0) a[1][i] += a[1][i+1];
  int ans = 0;
  FOR(i, 0, n) maxs(ans, a[0][i] + a[1][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=20005,INF=1<<30;
int dp[MAX][256];


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,M;cin>>N>>M;
        if(N+M==0) break;
        
        vector<int> A(M),B(N);
        for(int i=0;i<M;i++) cin>>A[i];
        for(int i=0;i<N;i++) cin>>B[i];
        
        for(int i=0;i<MAX;i++){
            for(int j=0;j<256;j++){
                dp[i][j]=INF;
            }
        }
        dp[0][128]=0;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<256;j++){
                for(int k=0;k<M;k++){
                    int to=j+A[k];
                    if(to>255) to=255;
                    if(to<0) to=0;
                    
                    dp[i+1][to]=min(dp[i+1][to],dp[i][j]+(to-B[i])*(to-B[i]));
                }
            }
        }
        
        int ans=INF;
        
        for(int j=0;j<256;j++){
            ans=min(ans,dp[N][j]);
        }
        
        cout<<ans<<endl;
    }
}




Measured memory_bytes: 23208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Zahyo p[] = new Zahyo[n];
		for (int i = 0; i < n; i++) {
			p[i] = new Zahyo(i, sc.nextInt(), sc.nextInt());
		}
		double totalLength = 0;
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				totalLength += length(p[i], p[j]);
			}
		}
		totalLength = totalLength * 2 * factorial(n - 1);
		double aveLength = totalLength / factorial(n);
		System.out.println(aveLength);

		sc.close();
	}

	private static double factorial(int i) {
		if (i <= 2) {
			return i;
		} else {
			return i * factorial(i - 1);
		}
	}

	private static double length(Zahyo p1, Zahyo p2) {
		double len = 0;
		len = Math.sqrt(Math.pow((p1.x - p2.x), 2) + Math.pow((p1.y - p2.y), 2));
		return len;
	}

	static class Zahyo {
		int id;
		int x;
		int y;

		public Zahyo(int id, int x, int y) {
			this.id = id;
			this.x = x;
			this.y = y;
		}
	}

}


Measured memory_bytes: 23124
import java.util.Arrays;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> hi(n, 0);
    rep(i, n)
    {
        if (i == 0)
            hi[i] = 0;
        else if (i == 1)
            hi[i] = h[0];
        else
            hi[i] = max(hi[i - 1], h[i - 1]);
    }
    int count = 0;
    rep(i, n)
    {
        if (h[i] >= hi[i])
            count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a=0,b;
  cin>>n;
  b=n;
  while(n>0){
    int s=n%10;
    a+=s;
    n=n/10;
  }
  if(b%a==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
ll h,w;

int main(int argc, char const *argv[]) {
  vector<vl> x;
  for(ll i = 1;i <= 300;i++){
    for(ll j = i+1;j <= 300;j++){
      x.push_back(vl({i*i+j*j,i,j}));
    }
  }
  sort(x.begin(),x.end());
  while(cin >> h >> w){
    if(h == 0 && w == 0) return 0;
    for(ll i = 0;i < x.size();i++){
      if(x[i][1] == h && x[i][2] == w){
        cout << x[i+1][1] << " " << x[i+1][2] << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5184
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern


const int nax = 3e5+2;
int he , w, m;
vector<pair<int,int>> has;
vector<int> h(nax , 0) , v(nax , 0);
set<pair<int,int>> bombs;

signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	 
	cin >> he >> w >> m;
	
	for(int i =0 ; i < m; i++){
		int temp_x , temp_y;
		cin >> temp_x >> temp_y;
		has.pb({temp_x , temp_y});
		bombs.insert({temp_x , temp_y});
		h[temp_x] += 1;
		v[temp_y] += 1;
	}
	
	
	
	int ans = 0;
	
	int val = 0;
	int curr_h = -1; 
	for(int i =0 ; i < nax ; i++){
		if(val < h[i]){
			val = h[i];
			curr_h = i;
		}
	}
	
	for(int i =0 ; i < nax ;i++){
		int destroyed = val + v[i];
		if(bombs.find({curr_h , i}) != bombs.end()){
			destroyed -= 1;
		}
		ans = max(destroyed , ans);
	}
	
	val= 0;
	int curr_y = -1;
	for(int i =0 ; i < nax ; i++){
		if(val < v[i]){
			val = v[i];
			curr_y = i;
		}
	}
	
	
	for(int i =0 ; i < nax ;i++){
		int destroyed = val + h[i];
		if(bombs.find({i , curr_y}) != bombs.end()){
			destroyed -= 1;
		}
		ans = max(destroyed , ans);
	}
	
	cout<<ans;
	 
	return 0;
}


Measured memory_bytes: 32528
import math
from decimal import Decimal, ROUND_HALF_UP
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // math.gcd(x, a[i])
    return x
def gcd(a):
  temp = math.gcd(a[0], a[1])
  for i in a:
    temp = math.gcd(temp,  i)
  return temp
n,m = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
zero = False
count = 0
#a = list(map(lambda x: x // 2, na))
mini = lcm(a)
if len(a) != 1:
  maxi = gcd(a)
else:
  maxi = a[0]
maxi2 = maxi
nibai = 1
while(True):
  if maxi2 % 2 == 0:
    nibai *= 2
    maxi2 //= 2
  else:
    break
for i in a:
  if i % (2 * nibai) == 0:
    zero = True
    break
#print(nibai, maxi, mini)
if not zero:
  t = Decimal(str((m * 2 // mini) / 2))
  #print(t)
  print(t.quantize(Decimal('0'), rounding=ROUND_HALF_UP))
else:
  print(0)

Measured memory_bytes: 20964
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
    int r,c;
    cin >> r >> c;

    // 盤面入力受取 
    vector<string> p(r);
    rep(i,r) {
      cin >> p[i];
    }

  vector<vector<ll>> ans(r,vector<ll>(c,100000000));
  ans[0][0]=0;
  if(p[0][0]=='#')ans[0][0]++;
  rep(i,r){
    rep(j,c){
      if(i>0){
        if(p[i][j]=='#' && p[i-1][j]=='.') ans[i][j]=min(ans[i][j],ans[i-1][j]+1);
        else ans[i][j]=min(ans[i][j],ans[i-1][j]);
      }
      if(j>0){
        if(p[i][j]=='#' && p[i][j-1]=='.') ans[i][j]=min(ans[i][j],ans[i][j-1]+1);
        else ans[i][j]=min(ans[i][j],ans[i][j-1]);
      }
    }
  }


  cout << ans[r-1][c-1] << endl;
}


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

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

    string s, t; cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) cout << "Yes";
    else cout << "No";

    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)


	for x in range(diff+2):
		if X-x not in p:
			print(X-x)
			break
		if X+x not in p:
			print(X+x)
			break
		

Measured memory_bytes: 9196
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
vector <int> Graph[int(1e5 + 5)];
int ans[int(1e5 + 5)];

int main(){
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++){
		int A, B; scanf("%d%d", &A, &B);
		Graph[A].push_back(B);
		Graph[B].push_back(A);
	}

	ans[1] = 1;
	queue <int> que; que.push(1);
	while (!que.empty()){
		int Q  = que.front(); que.pop();
		for (int i = 0; i < Graph[Q].size(); i++){
			int next = Graph[Q][i];
			if (ans[next] != 0) continue;
			que.push(next);
			ans[next] = Q;
		}
	}
	
	for (int i = 2; i <= N; i++){
		if (ans[i] == 0){
			No(); return 0;
		}
	}
	Yes();
	for (int i = 2; i <= N; i++){
		printf("%d\n", ans[i]);
	}

  return 0;
}


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

//#define int long long
using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

const ll B_MAX = 1000000000000;

ll A, B;

void input() {
  scanf("%lld%lld", &A, &B);
}

ll f(ll n){
	if(n%2==0){
		return f(n-1)^n;
	}else{
		if(((n-1)/2)%2==0)return 0;
		else return 1;
	}
}

void solve() {
	if(A==B){
		p(A);
		return;
	}

	ll ans = 0;

	ll fa=f(A-1);
	ll fb=f(B);
	ans=fa^fb;

	printf("%lld\n", ans);
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a;
	int b;
	int menseki;
	int syuu;
	scanf("%d %d",&a,&b);
	menseki = a*b;
	syuu = a * 2 + b * 2;
	printf("%d %d\n", menseki,syuu);
	return 0;
	}

Measured memory_bytes: 596