akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;
int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	k -= a;
	if(k>=0){
		ll v = 0;
		ll oo = max(v, b - k);
		cout << 0 << " " << oo;
	}
	else {
		cout << -k << " " << b;
	}
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main( ){
    const long long mod = 1e9 + 7;
    int n, m;
    scanf("%d %d ", &n, &m);
    char gride[n] [m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            gride[i] [j] = getchar();
        getchar();
    }
    long long dp[n] [m];
    memset(dp, 0, sizeof dp);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(gride[i] [j] == '#')
                continue;
            else if(i == 0 && j == 0)
                dp[i] [j] = 1;
            else if((i == 0 && gride[i] [j - 1] != '#'))
                dp[i] [j] = dp[i] [j - 1];
            else if(j == 0 && gride[i - 1] [j] != '#')
                dp[i] [j] = dp[i - 1] [j];
            else if(i > 0 && j > 0)
                dp[i] [j] = (dp[i - 1] [j] + dp[i] [j - 1]) % mod;
        }
    }
    printf("%lld\n", dp[n - 1] [m - 1]);
    return 0;
}

Measured memory_bytes: 12564
n = gets.split(" ")
w=n[0].to_i
h=n[1].to_i
x=n[2].to_i
y=n[3].to_i
r=n[4].to_i
xmax = w - r
ymax = h - r
if r<=x && x<=xmax && r<=y && y<=ymax
    print "Yes\n"
else
    print "No\n"
end

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

int gcd( int a, int b ) {
	if( a % b == 0 ) return b;
	else			 gcd( b, a % b );
}

signed main() {
	int n;
	while( cin >> n ) {
		int cnt = 0;
		REP( i, 10 ) {
			REP( j, 10 ) {
				REP( k, 10 ) {
					REP( l, 10 ) {
						if( n == i + j + k + l ) cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
	}
}



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

int main()
{
	long long int l, r;
	cin >> l >> r;
	if(r - l > 2019){
		cout << 0 << endl;
	}else{
		long long int ans = 2019;
		for(long long int i = l; i < r; ++i){
			for(long long int j = i + 1; j <= r; ++j){
				ans = min(ans, (i * j) % 2019);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    int n = s.size();
    if (n & 1) {
        std::cout << "No" << std::endl;
        return 0;
    }
    for (int i = 0; i < n - 1; i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
    return 0;
}


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long double ll;

const int max_n = 100111, inf = 1000111222;

vector<ll> r, l, u, d;
vector<ll> rr, lll, uu, dd;
vector<pair<ll, ll>> pt;
vector<char> dir;
int n;

ll lx = inf, rx = -inf;
ll dy = inf, uy = -inf;

pair<ll, ll> gett(pair<ll, ll> p, char d, ll t) {
    if (d == 'U') {
        p.S += t;
    }
    if (d == 'D') {
        p.S -= t;
    }
    if (d == 'L') {
        p.F -= t;
    }
    if (d == 'R') {
        p.F += t;
    }
    return p;
}

ll ANS = 1e18;

void calc(ll t) {
    if (t < 0) return;
    ll U = uy, D = dy;
    ll R = rx, L = lx;
    for (x : l) {
        R = max(R, x - t);
        L = min(L, x - t);
    }
    for (x : r) {
        R = max(R, x + t);
        L = min(L, x + t);
    }
    for (y : d) {
        U = max(U, y - t);
        D = min(D, y - t);
    }
    for (y : u) {
        U = max(U, y + t);
        D = min(D, y + t);
    }
    ANS = min(ANS, (R - L) * (U - D));
}

void upd_time(ll t) {
    int DELTA = 10;
    for (ll ct = t - DELTA; ct <= t + DELTA; ct += 0.5) {
        calc(ct);
    }
}

void check_meetline() {
    for (x : l) {
        upd_time(x - rx);
        upd_time(x - lx);
    }
    for (x : r) {
        upd_time(rx - x);
        upd_time(lx - x);
    }
    for (y : d) {
        upd_time(y - uy);
        upd_time(y - dy);
    }
    for (y : u) {
        upd_time(uy - y);
        upd_time(dy - y);
    }
    for (x1 : l) {
        for (x2 : r) {
            upd_time((x1 - x2) / 2);
        }
    }
    for (x1 : d) {
        for (x2 : u) {
            upd_time((x1 - x2) / 2);
        }
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        char d;
        cin >> x >> y >> d;
        pt.PB(MP(x, y));
        dir.PB(d);
        if (d == 'U' || d == 'D') {
            lx = min(lx, x);
            rx = max(rx, x);
        }
        if (d == 'L' || d == 'R') {
            dy = min(dy, y);
            uy = max(uy, y);
        }
        if (d == 'L') {
            lll.PB(x);
        }
        if (d == 'R') {
            rr.PB(x);
        }
        if (d == 'U') {
            uu.PB(y);
        }
        if (d == 'D') {
            dd.PB(y);
        }
    }
    sort(lll.begin(), lll.end());
    sort(rr.begin(), rr.end());
    sort(uu.begin(), uu.end());
    sort(dd.begin(), dd.end());
    if (lll.size() < 2) {
        l = lll;
    } else {
        l.PB(lll[0]);
        l.PB(lll.back());
    }
    if (rr.size() < 2) {
        r = rr;
    } else {
        r.PB(rr[0]);
        r.PB(rr.back());
    }
    if (dd.size() < 2) {
        d = dd;
    } else {
        d.PB(dd[0]);
        d.PB(dd.back());
    }
    if (uu.size() < 2) {
        u = uu;
    } else {
        u.PB(uu[0]);
        u.PB(uu.back());
    }


    upd_time(0);
    check_meetline();
    cout << fixed << setprecision(10) << ANS << endl;

    return 0;
}




Measured memory_bytes: 8412
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9 + 7;

ll ans=2;

void dfs(int p,int x,vector<vector<int>>& adj,vector<vector<ll>>& dp)
{
		dp[x][0]=dp[x][1]=1;
	
		for(int i=0;i<adj[x].size();i++)
		{
			if(adj[x][i]==p)
				continue;
			dfs(x,adj[x][i],adj,dp);
			dp[x][1]=(dp[x][1]*dp[adj[x][i]][0])%mod;
			dp[x][0]=(dp[x][0]*(dp[adj[x][i]][0]+dp[adj[x][i]][1])%mod)%mod;
			// ans=max(ans,(dp[x][1]+dp[x][0])%mod);
		}
}


int main()
{
	
	int n;
	cin>>n;
	int x,y;
	vector<vector<int>>adj(n+1);
	vector<vector<ll>>dp;    // 0 white 1 black
	

	for(int i=0;i<=n+1;i++)
		dp.push_back({0,0});

	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	dfs(1,1,adj,dp);
	cout<<(dp[1][0]+dp[1][1])%mod;
}
	




Measured memory_bytes: 20960
import sys
from collections import deque, Counter
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    a = list(IL())
    C = Counter(a)
    m = sum(a)
    q = I()
    s = []
    for rep in range(q):
        b,c = IL()
        if b in C:
            m += (c-b)*C[b]
            C[c] += C[b]
            C[b] = 0
        s.append(m)
    for rep in s:
        print(rep)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 88688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    ll tot=0;
    rep(i,n)tot^=v[i];
    rep(i,n){
        ll t=tot^v[i];
        cout << t <<" " ;
    }
    cout << endl;
}

Measured memory_bytes: 4676
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		TreeMap<String,List<Integer>> t = new TreeMap<String,List<Integer>>();
		while( sc.hasNext() ) {
			String key = sc.next();
			List<Integer> l;
			if ( t.containsKey(key) )
				l = t.get(key);
			else
				l = new ArrayList<Integer>();
			l.add(sc.nextInt());
			t.put(key,l);
		}
		Iterator<String> it = t.keySet().iterator();
		while (it.hasNext()) {
			Object o = it.next();
			List<Integer> l = t.get(o);
			System.out.println(o);
			Collections.sort(l);
			int i;
			for ( i = 0; i < t.get(o).size()-1; i++ )
				System.out.print(l.get(i)+" ");
			System.out.println(l.get(i));
		}
	}
}

Measured memory_bytes: 12000
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  char a, b;
  cin >> a >> b;
  cout << (a=='D' ? (b!='H' ? 'H' : 'D')
                  : (b=='H' ? 'H' : 'D')) << endl;
}

Measured memory_bytes: 256
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100001
#define X first
#define Y second
#define MOD 1000000007
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll t,n,i,j;
int main()
{
    fastio;
    ll k;
    cin>>n>>k;
    vector <ll > v(n+1);
    fr(i,1,n+1)
        cin>>v[i];
    ll dp[MAXN]={0};
    dp[1]=0;
    ll a;
    fr(i,2,k+1){
        a=INT_MAX;
        fr(j,1,i){
            a=min(a,dp[j]+abs(v[i]-v[j]));
            //cout<<i<<" "<<a<<endl;
        }
        dp[i]=a;
    }

    fr(i,k+1,n+1){
        a=INT_MAX;
        fr(j,i-k,i){
            a=min(a,dp[j]+abs(v[i]-v[j]));
        }
        dp[i]=a;
    }
   /* fr(i,1,n+1)
        cout<<dp[i]<<" ";
    cout<<endl;
   */ cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
min=0
N=[]
for i in range(5):
    n=int(input())
    N.append([n,(n-1)%10])
N.sort(key=lambda x:x[1])
time=0
for i in range(4):
    time+=(-N[i+1][0]//10)*-10
print(time+N[0][0])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int N=sc.nextInt();
				int M=sc.nextInt();
				if(N+M==0) break;
				int[] p=new int[M+1];
				for(int i=0; i<N; i++) {
					int d=sc.nextInt();
					int v=sc.nextInt();
					p[d]=Math.max(v, p[d]);
				}
				int sum=0;
				for(int i=1; i<=M; i++) {
					sum+=p[i];
				}
				System.out.println(sum);
			}
			
			
		}
		
	}
}



Measured memory_bytes: 34828
#include <iostream>
#include <string>
using namespace std;
int main(void){
char str[4];
cin>>str;
int d=0,e=0,f=0;
if(str[1]=='a'||str[0]=='a'||str[2]=='a') d=1;
if(str[1]=='b'||str[0]=='b'||str[2]=='b') e=1;
if(str[1]=='c'||str[0]=='c'||str[2]=='c') f=1;
if(d==1&&e==1&&f==1) cout<<"Yes";
else cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{	
	int k;
	string s;
	cin >> s >> k;

	rep(i, s.size()) {
		if (i == s.size()-1 && k > 0) {
			s[i] = 'a' + (s[i] - 'a' + k)%26;
		}
		else if (s[i] != 'a' && ('z'-s[i]) < k) {
			k -= ('z' - s[i] )+ 1;
			s[i] = 'a';
		}
	}
	cout << s << endl;
	return	0;
}




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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  long long a, b, x, h;
  cin >> a >> b >> x;
  if (a == 0) {
    cout << b / x + 1 << endl;
  } else {
    cout << b / x - (a - 1) / x << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 10000000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 55
#define ls (k << 1)
#define rs (k << 1 | 1)
#define M 260
int q, ans;
char s[N];
inline int abs (int x) {return x < 0 ? -x : x;}
int main ()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    ans = 233333333;
    fo (i, 3, len)
    {
        int now = (s[i - 2] - 48) * 100 + (s[i - 1] - 48) * 10 + (s[i] - 48);
        ans = std::min(ans, abs(now - 753));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=one_int()

temp = factorization(N)
temp = sorted(temp, key= lambda x: x[0])

# temp = [[2,9]]



output_set = []
output = [ output_set + [t[0]]*t[1] for t in temp ]

count = 0
for i in output:
    temp = len(i)
    sums = 0
    for t in range(1,temp+1):
        sums += t
        if temp >= sums:
            count += 1

if N==1:
    print(0)
else:
    print(count)

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

#define long long long // for codeforces

vector<long> goods = {2,8};
map<long,int> memo;

int dfs(long val){
  if (memo.count(val)) return memo[val];
  int ans = -1;
  for(auto v : goods){
    if(v > val) break;
    if(v == val) {
      ans = max(ans, 1);
    }
    if(val%v==0){
      int r = dfs(val/v);
      if(r > 0) ans = max(ans, r + 1);
    }
  }
  return memo[val] = ans;
}

bool isgood(long x){
  while(x>0){
    if(x%10 !=2 && x%10 != 8) return false;
    x /= 10;
  }
  return true;
}

int main(){
  rep(_,9){
    int s = goods.size();
    rep(i,s) if (goods[i] * 10 <= 1000000000){
      goods.pb(goods[i]*10 + 2);
      goods.pb(goods[i]*10 + 8);
    }
  }

  long v;
  cin>>v;

  int ans = dfs(v);
  if(isgood(v)) ans = max(ans, 1);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3348
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)*}
    };
}

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: i32,
        h: i32,
        w: i32,
        boards: [(i32, i32); n]
    }

    let mut result:i32 = 0;
    for (a, b) in boards {
        if (a >= h) & (b >= w) {
            result += 1;
        }
    }
    println!("{}", result);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    set<ll> S;
    map<ll, ll> a;
    rep(i, 0, n) {
      ll x; cin >> x;
      a[x]++;
      S.insert(x);
    }
    ll abs = 0, fr = 0, se = 0;
    fore(x, S) {
      if (a[x] >= 4) {
        abs = x;
      }
      if (a[x] >= 2) {
        se = fr;
        fr = x;
      }
    }
    cout << max(abs * abs, fr * se) << endl;
    return 0;
}



Measured memory_bytes: 11264
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private final static long MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] W = new int[N];
		sc.fill(W);
		
		long left = W[0];
		long right = Arrays.stream(W).sum() - left;
		long min  = (left> right) ? left- right : right -left;
		for(int i = 1; i < W.length;i++) {
			left += W[i];
			right -= W[i];
			min = Math.min(min, (left> right) ? left- right : right -left);
			debug(left,right);
		}
		
		System.out.println(min);
	}
	
	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 27604
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int ans = 0;// ??¨????????????????¨?????????????
		String s[] = new String[3];
		Scanner scan = new Scanner(System.in);

		while(true){//??\???????????£????????°?????????????????????
			for(int i = 0; i < s.length; i++){ //i???s??????????????°????°??????????
				s[i] = scan.next();
			}
			int a = Integer.parseInt(s[0]);//?¨????????????¨????????°??????int
			String op = s[1];			   //????????????String?????????
			int b = Integer.parseInt(s[2]);//?¨????????????¨????????°??????int
			if(op.equals("?")){//??????\???????????????????????°????????????
				break;
			}else if(op.equals("+")){//?????????????????????
				ans=a+b;
				System.out.println(ans);
			}else if(op.equals("-")){
				ans=a-b;
				System.out.println(ans);
			}else if(op.equals("*")){
				ans=a*b;
				System.out.println(ans);
			}else if(op.equals("/")){
				ans=a/b;
				System.out.println(ans);
			}
		}//------------------------------------while
		scan.close();
	}
}

Measured memory_bytes: 26268
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-12;
struct edge
{
  int to, cost;
  bool operator < (const edge& e) const { return cost < e.cost; }
  bool operator >(const edge& e) const { return cost > e.cost; }
};
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
//int index(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///


int main()
{
  int r, n;
  while (cin >> r >> n, r)
  {
    vector<vector<int>> build(50,vi(50));
    int L = 25 - r, R = 25 + r;

    REP(i, n)
    {
      int l, r, h;
      cin >> l >> r >> h;
      l += 25; r += 25;

      FOR(i, l, r)
      {
        REP(j, h) build[i][j] = 1;
      }
    }

    double ans = INF;
    FOR(i, L + 1, R)
    {
      int j;
      for (j = 0;; j++)
      {
        if (build[i][j] != 1 || build[i-1][j] != 1) break;
      }
      double k = abs(i - 25);
      double tmp = sqrt(r*r - k*k);
      tmp = r - tmp;
      //cout << j - tmp << endl;
      ans = chmin(ans, max(j+tmp, 0.0));
    }
    cout << D10 << ans << endl;
  }
  return 0;
}

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

int main()
{
    int F, O, T, i, n, x, a, b, c, d;
    cin >> F >> O >> T;
    vector <int> f, o, t;
    for(i=0;i<F;i++)
    {
        cin >> n;
        f.push_back(n);
    }
    for(i=0;i<O;i++)
    {
        cin >> n;
        o.push_back(n);
    }
    for(i=0;i<T;i++)
    {
        cin >> a >> b >> c;
        d = (f[a-1] + o[b-1]) - c;
        t.push_back(d);
    }
    sort(o.begin(), o.end());
    sort(f.begin(), f.end());
    x = f[0] + o[0];
    sort(t.begin(), t.end());
    if(x<t[0])
    {
        cout << x << endl;
    }
    else
    {
        cout << t[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
struct edge{ll to,cost;};
vector<vector<edge>> graph;
vector<int> d1;
int n,m;
int s,t;
void dijkstra(ll s){
    d1.resize(3*n);
    for(int i=0;i<3*n;i++)d1[i]=INT_MAX;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(int i=0;i<graph[a.se].size();i++){
            edge e=graph[a.se][i];
            if(d1.at(e.to)>d1[a.se]+e.cost){
                d1.at(e.to)=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   cin>>n>>m;
   graph.resize(3*n);
   for(int i=0;i<m;i++){
       int a,b;
       cin>>a>>b;
       a--;b--;
       graph[a].push_back(edge{b+n,1});
       graph[a+n].push_back(edge{b+2*n,1});
       graph[a+2*n].push_back(edge{b,1});
   }
   cin>>s>>t;
   //t=t+2*n;
   s--;t--;
   dijkstra(s);
   if(d1[t]==INT_MAX){
       cout<<-1<<endl;
   }
   else cout<<d1[t]/3<<endl;
}


Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m;
    cin>>n>>m;
    long long a[n]={0};
    long long ans=0;
    long long count[n]={0};

    for(long long i=0;i<m;i++){
        long long s,c;
        cin>>s>>c;
        if(s==1&&c==0&&n!=1){
            ans=1;
            break;
        }
        if(count[s-1]>=1&&a[s-1]!=c){
            ans=1;
            break;
        }
        count[s-1]++;
        a[s-1]=c;
    }
    if(ans==1){
        cout<<-1<<endl;
    }

    else{
    for(long long i=0;i<n;i++){
        if(a[i]!=0){
            cout<<a[i];
        }
        else if(i==0){
            if(n==1){
                cout<<0;
            }
            else{
            cout<<1;}
        }
        else{
            cout<<0;
        }
        if(i==n-1){
            cout<<endl;
        }
    }
}
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// #define int long long
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define INF 2e18;
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define all(x) x.begin(), x.end()
typedef long double f80;

const int N = 1005;
int a[N][N];

int indeg[N * N];

vector<int> g[N * N];
int n;

int get(int i,int j) {
    if(i > j) swap(i, j);
    return (i - 1) * n + j;
}

int dp[N * N];

signed main()
{
   // freopen("inp.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    cin >> n;
    fr(i, 1, n) {
        fr(j, 1, n - 1) {
            cin >> a[i][j];
        }
    }
    fr(i, 1, n) {
        fr(j, 1, n - 2) {
            int idx = get(i, a[i][j]), idx1 = get(i, a[i][j + 1]);
            g[idx].pb(idx1);
            indeg[idx1]++;
        }
    }
    fr(i, 1, get(n - 1, n)) {
        g[0].pb(i);
        indeg[i]++;
    }
    queue<int> q;
    q.push(0);
    dp[0] = 0;
    int ans = 0;
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        ans = max(ans, dp[u]);
        for(int v : g[u]) {
            dp[v] = max(dp[v], dp[u] + 1);
            indeg[v]--;
            if(indeg[v] == 0)
                q.push(v);
        }
    }
    fr(i, 1, get(n - 1, n)) {
        if(indeg[i]) {
            cout << -1;
            return 0;
        }
    }
    cout << ans;
    return 0;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

// small/0, same/1
ll dp[55][2];
ll cnt[55];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  ll n;ll k;cin>>n>>k;
  std::vector<ll> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    for(int j=0;j<50;j++){
      cnt[j]+=(bool)(v[i]&(1ll<<j));
    }
  }

  for(int i=0;i<=51;i++)dp[i][0]=dp[i][1]=-1;
  dp[51][1]=0;

  for(int i=50;i>=0;i--){
    ll p = (1ll<<i);
    if(dp[i+1][0]>=0){
      dp[i][0] = max(dp[i+1][0] + p * cnt[i], dp[i+1][0] + p * (n-cnt[i]));
    }
    if(dp[i+1][1]>=0){
      if(p & k){
        dp[i][1] = dp[i+1][1] + p * (n-cnt[i]);
        dp[i][0] = max(dp[i][0], dp[i+1][1] + p * cnt[i]);
      }else{
        dp[i][1] = dp[i+1][1] + p * cnt[i];
      }
    }
  }

  cout<<max(dp[0][0],dp[0][1])<<endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdin =new Scanner(System.in);
		int a=stdin.nextInt();
		int b=stdin.nextInt();
		int c=stdin.nextInt();

	if(a+b>=c)
		System.out.println("Yes");
	else
		System.out.println("No");
	}
}

Measured memory_bytes: 21972
import java.util.*;
import java.io.*;
public class Main{

 static class Reader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public Reader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
       
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e){ 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt(){ 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong(){ 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble(){ 
            return Double.parseDouble(next()); 
        } 
        
        String nextLine(){ 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 


  
    public static void main(final String [] args)throws IOException{
       Reader sc=new Reader();
       int n=sc.nextInt();
       int [] a=new int[n];
       long sum=0;
       Map<Integer,Integer> map=new HashMap<>();
       for(int i=0;i<n;i++){
           a[i]=sc.nextInt();
           sum+=a[i];
           map.put(a[i],map.getOrDefault(a[i],0)+1);
        }

       int q=sc.nextInt();

       for(int i=0;i<q;i++){
           
           long A=sc.nextInt();
           long B=sc.nextInt();
           long cnt=map.getOrDefault((int)A,0);

           sum=sum-A*cnt;
           sum=sum+B*cnt;
           System.out.println(sum);

           map.put((int)B,map.getOrDefault((int)B,0)+(int)cnt);
           map.put((int)A,0);


       }


    }
}




Measured memory_bytes: 70736
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e6+5;
const int mod = 1e9+7;
using namespace std;

ll a[maxn] = {0,0,1,3,5,9};

void solve() {
	ll n,ans=0; cin >> n;
	for(int i=1; i<=n; i++) {
		ll tmp = ((n+i-1)/i);
		if (tmp - 1 < 0) break;
		ans += tmp-1;
	}
	cout << ans << '\n';
}

int main(int argc, char * argv[]) 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:/Users/Fish_Brother/Desktop/in", "r", stdin);
	//freopen("C:/Users/Fish_Brother/Desktop/out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

    return 0;
}

Measured memory_bytes: 3708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a==b && b==c)System.out.println(1);
		else if(a==b || a==c || b==c)System.out.println(2);
		else System.out.println(3);
	}
}

Measured memory_bytes: 20564
import sys
n,p=map(int,input().split())
s=input()
x=[0 for i in range(p)]
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0: ans+=i+1
    print(ans)

else:
    tmp1=1
    tmp2=0
    for i in range(n-1,-1,-1):
        tmp2=(tmp1*int(s[i])+tmp2)%p
        x[tmp2]+=1
        tmp1=(tmp1*10)%p

    ans+=x[0]
    for i in range(p):
        ans+=x[i]*(x[i]-1)//2
    print(ans)

Measured memory_bytes: 3500
solve :: Int -> Int -> Int -> Int -> [Int] -> [Int] -> String
solve n m x y xs ys =
  let xmax = maximum (x : xs)
      ymin = minimum (y : ys)
  in if xmax < ymin then "No War" else "War"

main = do
  cont <- getContents
  let [line1, line2, line3] = lines cont
      [n,m,x,y] = map read $ words line1
      xs = map read $ words line2
      ys = map read $ words line3
      ans = solve n m x y xs ys
  putStrLn $ ans


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

using namespace std;




int main(){
  
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif


int n;
cin>>n;
vector< long long  > arr(n);


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


}



long long minn = arr[0];
long long total =1000;

for(int i=1;i<n;i++){
  if(arr[i]<minn){
    minn = arr[i];
  }
  else{

    long long temp = (total / minn)*arr[i];
    temp = temp + (total%minn );
    total = temp;
    minn = arr[i];
  }
}

cout<<total<<endl;



}






Measured memory_bytes: 3620
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a <= 8 && b<= 8) System.out.println("Yay!");
		else System.out.println(":(");
	 }
}

Measured memory_bytes: 35732
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
ll dp[110][100100];

int main(int argc, char const *argv[]) {
    ll n, W;
    P p[110];
    cin >> n >> W;
    for(int i=1;i<=n;i++){
        cin >> p[i].first >> p[i].second;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<W;j++){
            dp[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        ll w = p[i].first;
        ll v = p[i].second;
        for(int j=0;j<=W;j++){
            dp[i][j]=dp[i-1][j];
            if(w>j) continue;
            chmax(dp[i][j], dp[i-1][j-w]+v);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80128
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	int n;
	cin>>n;
    ll ans = 0;
    for(ll i=1;i<n;i++){
		int ba = 0;
		for(ll l=1,r=n;l<=r;){
			ll mid = (l+r)/2;
			if(i*mid < n)ba = mid,l = mid+1;
			else r = mid-1;
		}
		ans+=ba;
	}
	cout<<ans;
}


Measured memory_bytes: 3588
N,M = map(int,input().split())
l = []
for i in range(M):
	p,y = map(int,input().split())
	l.append([p,y,i])
l.sort()
p = -1
n = 1
for i in range(M):
	if l[i][0] == p:
		n += 1
		l[i][1] = n
	else:
		n = 1
		l[i][1] = n
	p = l[i][0]
for i in range(M):
	l[i][0],l[i][1],l[i][2]=l[i][2],l[i][0],l[i][1]
l.sort()
for i in range(M):
	print('0'*(6-len(str(l[i][1])))+str(l[i][1])+'0'*(6-len(str(l[i][2])))+str(l[i][2]))

Measured memory_bytes: 67608
#include<stdio.h>
int main(void){
    int n,x,ans=0,i,j,k;
    while(1){
        scanf("%d%d",&n,&x);
        if(n==0&&x==0) break;
        for(i=1; i<=n; i++){
            for(j=1; j<=n; j++){
                for(k=1; k<=n; k++){
                    if((i+j+k)==x&&i!=j&&j!=k&&k!=i) ans+=1;
                }
            }
        }
        printf("%d\n",ans/6);
        ans=0;
    }
    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i,H) cin >> A[i];
    map<char,int> mp;
    rep(i,H)rep(j,W){
        mp[A[i][j]]++;
    }
    int p4=0,p2=0,p1=0;
    p4 = (H/2) * (W/2);
    if(H%2==1){
        p2+=W/2;
    }
    if(W%2==1){
        p2+=H/2;
    }
    if(H%2==1&&W%2==1){
        p1=1;
    }
    while(true){
        bool done = false;
        if(p1==1){
            for(char c='a';c<='z';c++){
                if(mp[c]%2==1){
                    mp[c]--;
                    p1=0;
                    done = true;
                    break;
                }
            }
            if(p1==1){
                cout << "No" << endl;
                return 0;
            }
        }
        if(done==false&&p2>0){
            for(char c='a';c<='z';c++){
                if(mp[c]>0&&mp[c]%4==2){
                    mp[c]-=2;
                    p2--;
                    done = true;
                    break;
                }
            }
            if(!done){
                for(char c='a';c<='z';c++){
                    if(mp[c]>0&&mp[c]%4==0){
                        mp[c]-=2;
                        p2--;
                        done=true;
                        break;
                    }
                }
                if(!done){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
        if(done==false&&p4>0){
            for(char c='a';c<='z';c++){
                if(mp[c]>0&&mp[c]%4==0){
                    mp[c]-=4;
                    p4--;
                    done = true;
                    break;
                }
            }
        }
        if(!done){
            cout << "No" << endl;
            return 0;
        }
        if(p1==0&&p2==0&&p4==0){
            bool f = true;
            for(char c='a';c<='z';c++){
                if(mp[c]>0) f=false;
            }
            if(f){
                cout << "Yes" << endl;
                return 0;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

const int nmax = 2e5;

int n;
int v[nmax + 1];

vector<pair<int, int>> s;

bool creste (int val) {
    int cnt = 0;
    while (!s.empty()) {
        if (s.back().first == val) {
        cnt += s.back().second;
        s.pop_back();
        } else
            break;
    }

    if (s.empty())
        return 0;

    pair<int, int> lst = s.back();
    s.pop_back();

    if (lst.second - 1 > 0)
        s.push_back({lst.first, lst.second - 1});
    s.push_back({lst.first + 1, 1});
    if (cnt > 0)
        s.push_back({1, cnt});
    return 1;
}

bool check (int val) {
    s.clear();
    s.push_back({1, v[1]});

    for (int i = 2; i <= n; ++ i) {
        if (v[i - 1] < v[i]) {
            s.push_back({1, v[i] - v[i - 1]});
        } else {
            int aux = v[i - 1];
            while (aux > v[i]) {
                int x = min(aux - v[i], s.back().second);
                aux -= x;

                if (x == s.back().second)
                    s.pop_back();
                else
                    s.back().second -= x;
            }

            if (creste(val) == 0)
                return 0;
        }
    }

    return 1;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(nullptr);
    fin >> n;

    for (int i = 1; i <= n; ++ i)
        fin >> v[i];

    int ans = 1 << 30;
    for (int step = ans; step > 0; step >>= 1) {
        if (ans - step > 0 && check(ans - step)) {
            ans -= step;
        }
    }

    fout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3188
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: usize = s.next().unwrap().parse().unwrap();
	let mut mp = std::collections::BTreeMap::new();
	for _ in 0..n {
		let p = s.next().unwrap().chars().next().unwrap();
		*mp.entry(p).or_insert(0) += 1;
	}
	let mut q = mp.values().cloned().collect::<std::collections::BinaryHeap<_>>();
	let mut ans = 0;
	while q.len() >= k {
		let mut r = (0..k)
		.map(|_| q.pop().unwrap() - 1)
		.filter(|&a| a != 0)
		.collect::<std::collections::BinaryHeap<_>>();
		q.append(&mut r);
		ans += 1;
	}
	println!("{}", ans);
}

Measured memory_bytes: 4352
H,W,A,B = map(int,input().split())
ans = []
for i in range(B):
    a = min(A,W-A)
    ans.append('0'*a + '1'*(W-a))
for i in range(H-B):
    a = min(A,W-A)
    ans.append('1'*a + '0'*(W-a))
print(*ans, sep='\n')

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int d, t, s;
	cin >> d >> t >> s;
	if (t * s >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return (0);
}


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

vector<vector<int>> graph;
vector<bool> seen;
int cnt;

void dfs(int v){
    seen[v] = true;
    cnt++;
    for(int nv : graph[v]){
        if(seen[nv]) continue;
        dfs(nv);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    graph.resize(N);
    seen.assign(N, false);

    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int mx = 0;
    rep(i, N){
        if(!seen[i]){
            cnt = 0;
            dfs(i);
            mx = max(mx, cnt);
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 20336
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
#include "debug.h"
#define input \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#else
#define debug(...) 4
#define input 4
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> a(n);
    for(int &x : a)
        cin >> x;
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(a[i] == a[j])
                    continue;
                if(a[i] == a[k])
                    continue;
                if(a[j] == a[k])
                    continue;
                if(a[i] + a[j] > a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 3656
s = int(input())


num = (s + 2) // 3


mod = 10 ** 9 + 7
N = 2000 + 5
bikkuri = [0] * N
bikkuri[0] = 1
gyaku = [0] * N
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
gyaku[N - 1] = pow(bikkuri[N - 1], mod - 2, mod)
for i in range(N - 1, 0, -1):
    gyaku[i - 1] = (gyaku[i] * i) % mod


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


ans = 0
for i in range(1, num + 1):
    temp = s - 3 * i
    ans += comb(temp + i - 1, i - 1)
    ans %= mod
print(ans % mod)


Measured memory_bytes: 64752
h, w = map(int, input().split())
a = [input() for i in range(h)]

for i in range(h+2):
    for j in range(w+2):
        if(i==0 or i==h+1 or j==0 or j==w+1):
            print("#", end="")
        else:
            print(a[i-1][j-1], end ="")
    print()


Measured memory_bytes: 4340