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

int main( void )
{
    int r, g, b;
    cin >> r >> g >> b;
    if ( ( g * 10 + b ) % 4 == 0 )
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/10 19:17:00 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

int main()
{
	string s="CODEFESTIVAL2016";
    string s1;
    cin>>s1;
    int ans=0;
    for (int j=0;j<16;++j)
        if (s[j]!=s1[j]) ++ans;
    cout<<ans<<endl;
	return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<typename T> vector<T> make_v(size_t N,T init){return vector<T>(N,init);}
template<typename... T> auto make_v(size_t N,T... t){return vector<decltype(make_v(t...))>(N,make_v(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}


//Digit Sum
long long Digit_Sum(long long N, long long K) {
    long long sum = 0;
    for (; N > 0; N /= K) sum += N % K;
    return sum;
}

int main() {
	int N; cin >> N;
	V<V<ll>> a(N,V<ll>(N));
	REP(i,N) REP(j,N) cin >> a[i][j];
	V<ll> cost(1<<N);
	for(int i = 0; i < (1<<N); ++i){
		for(int j = 0; j < N; ++j){
			for(int k = j + 1; k < N; ++k){
				if((i & (1<<j)) && (i & (1<<k))) cost[i] += a[j][k]; 
			}
		}
	}
	auto dp = cost;
	for(int i = 0; i < (1<<N) - 1; ++i){
		V<int> b;
		for(int j = 0; j < N; ++j) if( !(i & (1<<j)) ) b.push_back(j);
		int M = b.size();
		for(int j = 0; j < (1<<M); ++j){
			int x = 0;
			for(int k = 0; k < M; ++k) if(j & (1<<k)) x ^= (1 << b[k]);
			chmax(dp[i ^ x], dp[i] + cost[x]);
		}
	}
	cout << dp[(1<<N) - 1] << endl;
	return 0;
}


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

using namespace std;

int main(){
  int n,m; cin >> n >> m;
  vector<pair<int,int>> p(m);
  for(int i=0;i<m;i++){
    cin >> p[i].first >> p[i].second;
  }
  int s=0;
  int t=n;
  for(int i=0;i<m;i++){
    s=max(s,p[i].first);
    t=min(t,p[i].second);
  }
  int ans=max(t-s+1,0);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int min(int a, int b){
    if( a < b ){
        return a;
    }
    else {
        return b;
    }
}

int main(){
    char c[100000];
    char tmp;
    cin >> c;
    int countA = 0;
    int cc = 0;
    for(int i = 0 ; c[i] != NULL; i++){
        if(i % 2){
            if(c[i] == '0'){
                countA++;
            }
        }
        else{
            if(c[i] == '1'){
                countA++;
            }
        }
        cc++;
    }
    int countB = cc - countA ;
    // cout << countA << " " << countB<< endl;
    cout << min(countA, countB) << endl;
    // int countB =  - countA;
    // int t = si ^ m;

    // 
    // for(int i = 0 ; i < s.size(); i++){
    //     if(t & 1){
    //         countA++;
    //         t = t >> 1;
    //     }
    //     else {
    //         t = t >> 1;
    //     }
    // }

    // t = si ^ (~m);
    // int countB = 0;
    // for(int i = 0 ; i < s.size(); i++){
    //     if(t & 1){
    //         countB++;
    //         t = t >> 1;
    //     }
    //     else {
    //         t = t >> 1;
    //     }
    // }
    
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>

using namespace std;

const int N = 200010;
#define rg register int
typedef long long ll;

int n, last, now;
char s[N];
ll ans;

int main() 
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
    for(rg i = n; i; i--)
    {
        if(s[i] == 'A')
        {
            if(!last)ans += now;
            else now = 0;
            last = 0;
        }
        else if(s[i] == 'B')
        {
            if(last == 1)now++;
            else now = 0;
            last = 0;
        }
        else
        {
            if(last == 1)now = 0;
            last = 1;
        }
    }
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main(){
	int k;
	cin >> k;
	int ev = k / 2;
	int od = k - ev;
	cout << ev * od << endl;
}

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}
int dp[1001][1001];



void solve(){
	int n,m;
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        if(a[i][0]=='#') dp[i][0]=0;
        else dp[i][0]=dp[i-1][0];
    }
    for(int i=1;i<m;i++){
        if(a[0][i]=='#') dp[0][i]=0;
        else dp[0][i]=dp[0][i-1];
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]!='#') dp[i][j]=(dp[i][j-1] + dp[i-1][j])%mod;
        }
    }
    cout<<dp[n-1][m-1]<<endl;
    // for(int i=0;i<n;i++){
    //     for(int j=0;j<m;j++){
    //         cout<<dp[i][j];
    //     }
    //     cout<<endl;
    // }
}
    

int32_t main()
{
    //FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}


Measured memory_bytes: 12424
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

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

	int n, w;
	while(cin >> n >> w, n + w) {
		int m = 0;
		int cnt[20] = { 0 };
		for(int i = 0; i < n; i++) {
			int v;
			cin >> v;
			cnt[v / w]++;
			m = max(m, v / w);
		}

		int h = *max_element(cnt, cnt + m + 1);
		double ans = 0.01;
		for(int i = 0; i <= m; i++) {
			ans += (double)(m - i) / m * cnt[i] / h;
		}
		cout << setprecision(15) << ans << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	int a[100005];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int p=0,pmax=0;
	for(int i=0;i<n-1;i++){
		if(a[i]>=a[i+1]){
			p++;
		}
		else{
			p=0;
			
		}
		if(p>pmax){
			pmax=p;
		}
	}
	cout<<pmax;
} 

Measured memory_bytes: 768
use proconio::input;
use proconio::marker::{Chars, Isize1};
use std::collections::{HashSet, VecDeque};

#[allow(non_snake_case)]
fn main() {
    input! {
        H: isize,
        W: isize,
        ch: Isize1,
        cw: Isize1,
        dh: Isize1,
        dw: Isize1,
        S: [Chars; H]
    }
    let mut set = HashSet::new();
    let mut deque = VecDeque::new();

    deque.push_front((ch, cw, 0));
    while let Some((y, x, d)) = deque.pop_front() {
        // 終了条件
        if y == dh && x == dw {
            println!("{}", d);
            return;
        }

        if set.contains(&(y, x)) {
            continue;
        }
        set.insert((y, x));

        for dx in -2..=2isize {
            for dy in -2..=2isize {
                // 中心は除外
                if dx == 0 && dy == 0 {
                    continue;
                }
                // 座標決め
                let h = y + dy;
                let w = x + dx;

                // 範囲外は除外
                if h < 0 || H <= h || w < 0 || W <= w {
                    continue;
                }

                // 移動可能でなければ除外
                if S[h as usize][w as usize] != '.' {
                    continue;
                }
                if dx.abs() + dy.abs() == 1 {
                    if !set.contains(&(h, w)) {
                        deque.push_front((h, w, d));
                    }
                } else {
                    if !set.contains(&(h, w)) {
                        deque.push_back((h, w, d + 1));
                    }
                }
            }
        }
    }

    println!("-1");
}


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

using namespace std;

int n,x, t;
int main()
{
	string s;
	cin>>s;
	int num =s.size();
	int ans=0;
	for(int i=0;i<num;i++){
		ans+=s[i]-'0';
	}
	if(ans%9==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

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

int main()
{
	int N;

	cin >> N;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	long long s = 0;
	for( int i = 0; i < N; i++ ) {
		s += A[i];
	}
	long long x0 = s;
	for( int i = 1; i < N; i += 2 ) {
		x0 -= A[i] * 2;
	}

	cout << x0 << endl;
	for( int i = 1; i < N; i++ ) {
		long long x1 = A[i - 1] * 2 - x0;
		cout << x1 << endl;
		x0 = x1;
	}
}


Measured memory_bytes: 2048
#include <cstdio>
     
    int main() 
    {
      int a, b;
      std::scanf("%d %d", &a, &b);
      
      if (b % a == 0){
        printf("%d\n", a + b);
      }
      else {
            printf("%d\n", b-a);
      }
    	return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
typedef pair<int,pii>piii;
bool cmp(const piii&a,const piii&b){return a.F>b.F;}
vector<pair<int,pii> >v;
int ans[2],n;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		v.pb(mp(a+b,mp(a,b)));
	}
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<n;i++){
		if(i%2==0)ans[0]+=v[i].S.F;
		// cout<<v[i].S.F<<endl;
		else ans[1]+=v[i].S.S;
		// cout<<-v[i].S.S<<endl;
	}
	cout<<ans[0]-ans[1]<<endl;
	return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main()
{int N; cin >> N; int ans = 0;
 for(int i = 1 ; i <= N; i += 2){
   int cnt = 0;//初期化
   int c = (int)sqrt((double) i);//iの約数の個数を調べる
   for(int j = 1; j <= c; j++){//200以下の奇平方数が条件を満たさないことは容易に示せる
     if( i % j == 0){ cnt++;}  }//従って、√iまでの約数の個数を調べ、それを２倍すれば良い
   if( cnt == 4){ ans++;}}
 
 cout << ans << endl;
 
 return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
#define SZ(v) ((int)(v).size())
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPF(i, a, b) for (int i = (a); i <= (b); ++i)
#define REPD(i, a, b) for (int i = (a); i >= (b); --i)
const int maxint = -1u>>1;
const int BIG = 20;
const int SMALL = 19;
const int Y = 1000;
const int M = 1;
const int D = 1;

int n;
int year, month, day;

bool isYear(int year) {
    return year % 3 == 0;
}

bool isMonth(int month) {
    return month % 2 == 1;
}

int work() {
    int res = 0;
    if (year == Y) {
        if (month == M) {
            res = day - D;
        } 
    } else {
        if (isYear(year) || isMonth(month)) {
            res += BIG - day + 1;
        } else {
            res += SMALL - day + 1;
        }
        //printf("res: %d\n", res);
        for (int i = month + 1; i <= 10; ++i) {
            if (isYear(year) || isMonth(i)) res += BIG;
            else res += SMALL;
        }
        //printf("res: %d\n", res);
        for (int i = year + 1; i < 1000; ++i) {
            if (isYear(i)) res += 200;
            else res += 195;
        }
        //printf("res: %d\n", res);
    }
    return res;
}

int main() {
    scanf("%d", &n);
    while (n--) {
        scanf("%d%d%d", &year, &month, &day);
        int ans = work();
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

ll dp[2010][2010];
int main() {
    /*cin.tie(0);
    ios::sync_with_stdio(false);*/

    int n, m;
    cin >> n >> m;
    VI s(n), t(m);
    dp[0][0] = 1;
    FOR(i, 0, n) {
        cin >> s[i];
        dp[i + 1][0] = 1;
    }
    FOR(i, 0, m) {
        cin >> t[i];
        dp[0][i + 1] = 1;
    }

    FOR(i, 0, n)FOR(j, 0, m) {
        if (s[i] != t[j])dp[i + 1][j + 1] -= dp[i][j];
        dp[i + 1][j + 1] += dp[i][j + 1];
        dp[i + 1][j + 1] += dp[i + 1][j];
        dp[i + 1][j + 1] = (dp[i + 1][j + 1] + mod) % mod;
    }

    cout << dp[n][m] << "\n";
}

Measured memory_bytes: 31616
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int X=sc.nextInt();
        int lc=0,rc=0;
        for(int i=1;i<=M;i++){
            if(sc.nextInt()<X){
                lc++;
            }else{
                rc++;
            }
        }
        System.out.println(Math.min(lc,rc));
    }
}



Measured memory_bytes: 21972
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        if(k == x){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<string>v;
long long n,m;
long long bfs(long long p,long long q){
    queue<pair<long long,pair<long long,long long> > >qu;
    qu.push({0,{p,q}});

    long long res=0,a,b,c;
    long long vis[50][50];
    memset(vis,-1,sizeof(vis));
    vis[p][q]=0;
    while(qu.size()>0){
        pair<long long,pair<long long,long long> > gg =qu.front();
        qu.pop();
        a=gg.second.first;
        b=gg.second.second;
        c=gg.first;
        res=max(c,res);
        if(a>0&&(vis[a-1][b]>c+1||vis[a-1][b]==-1)&&v[a-1][b]=='.'){
            vis[a-1][b]=c+1;
            qu.push({c+1,{a-1,b}});
        }
        if(a<n-1&&(vis[a+1][b]>c+1||vis[a+1][b]==-1)&&v[a+1][b]=='.'){
            vis[a+1][b]=c+1;
            qu.push({c+1,{a+1,b}});
        }
        if(b>0&&(vis[a][b-1]>c+1||vis[a][b-1]==-1)&&v[a][b-1]=='.'){
            vis[a][b-1]=c+1;
            qu.push({c+1,{a,b-1}});
        }
        if(b<m-1&&(vis[a][b+1]>c+1||vis[a][b+1]==-1)&&v[a][b+1]=='.'){
            vis[a][b+1]=c+1;
            qu.push({c+1,{a,b+1}});
        }
    }

    return res;

}
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g=0,ans=0,k,i,j,t,p,q;
    cin>>n>>m;
    string s;
    for(i=0;i<n;i++){
        cin>>s;
        v.push_back(s);

    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(v[i][j]=='.')ans=max(ans,bfs(i,j));
        }
        //cout<<endl;
    }
    cout<<ans<<'\n';
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector <int> ticket(4);
  ticket.at(0) = N/1000;
  ticket.at(1) = N%1000/100;
  ticket.at(2) = N%1000%100/10;
  ticket.at(3) = N%1000%100%10;
  
  for (int tmp=0; tmp < (1 << 3); tmp++){
    bitset <3> s(tmp);
    int sum=ticket.at(0);
    for (int i=0; i<3; i++){
      if (s.test(i)){
        sum += ticket.at(3-i);
      }else{
        sum -= ticket.at(3-i);
      }
    }
    if(sum == 7){
      cout << ticket.at(0);
      for (int i=2; i>=0; i--){
        if(s.test(i)){
          cout << "+";
        }else{
          cout << "-";
        }
        cout << ticket.at(3-i);
      }
      cout << "=" << 7 << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio>
#include <map>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;
map<int,int> mp;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n , L , R; cin >> n >> L >> R; --R;
	For(i, 1, n) {
		int x; cin >> x;
		if (x < L || x > R) mp[x];
	}
	cout << sz(mp) << endl;

	return 0;

}			

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t a,v,b,w,t,d,vd;
  cin>>a>>v>>b>>w>>t;
  if(w>=v) cout<<"NO"<<endl;
  else{
    d=max(a-b,b-a);
    vd=v-w;
    if((d+vd-1)/vd<=t) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3636
h,w,m=map(int,input().split())
bomb=[list(map(int,input().split())) for i in range(m)]

num_h = [0] * (h+1)
num_w = [0] * (w+1)
bomb_set = set()
for hi,wi in bomb:
  num_h[hi] += 1
  num_w[wi] += 1
  bomb_set.add((hi,wi))
  
max_h = max(num_h)
max_w = max(num_w)
max_hs = [k for k,v in enumerate(num_h) if v == max_h]
max_ws = [k for k,v in enumerate(num_w) if v == max_w]

result = max_h + max_w
for i in max_hs:
  for j in max_ws:
    if (i,j) not in bomb_set:
      print(result)
      exit(0)
print(result-1)


Measured memory_bytes: 119056
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
const int BUF = 1005;


int N, K;
int val[BUF];


void read() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> val[i];
}


void work() {
    sort(val, val + N);
    cout << accumulate(val, val + K, 0) << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n ; cin >> n;
	vector<int> A(n);
	rep(i,n) cin >> A[i];
	SORT(A);

	ll ans = 0 ;
	ll bef = -1 ;
	rep(i,n){	
		if(bef != A[i] ){
			ans ++;
			bef = A[i];
		}else{
			ans --;
			bef = -1;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

int main()
{
  int n;
  scanf("%d", &n);
  int d[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", d + i);
  }
  std::sort(d, d + n);
  printf("%d\n", d[n / 2] - d[n / 2 - 1]);
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N, M;
  cin >> N >> M;
  int p[M];
  string S[M];
  rep(i,M) cin >> p[i] >> S[i];

  int ac = 0, pn = 0;
  map<int, bool> ac_mp;
  map<int, int> wa_mp;
  rep(i,M) {
    ac_mp[p[i]] = false;
    wa_mp[p[i]] = 0;
  }
  rep(i,M) {
    if (ac_mp[p[i]]) {
      continue;
    }

    if (S[i] == "AC") {
      ac++;
      ac_mp[p[i]] = true;
      pn += wa_mp[p[i]];
    } else {
      wa_mp[p[i]] += 1;
    }
  }
  
  cout << ac << " " << pn << endl;
  return 0;
}


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

#define ll long long
#define pb push_back
#define int ll

const int maxn = 2e5 + 20;

int w[maxn];

ll dp[maxn] , h[maxn];

vector<int> adj[maxn] , shit[maxn];

bool cmpdp(int v , int u)
{
	return dp[v] < dp[u];
}

bool cmph(int v , int u)
{
	return h[v] < h[u];
}

void dfs(int v , ll x)
{
	shit[v].clear();
	if(adj[v].empty())
	{
		dp[v] = 0;
		shit[v] = {v};
		return;
	}

	for(auto u : adj[v])
		dfs(u , x);

	int L = adj[v][0] , R = adj[v][1];

	vector<pair<int , int> > tmp;
	for(int _ = 0; _ < 2; _++)
	{
		swap(L , R);
		sort(shit[L].begin() , shit[L].end() , cmpdp);
		reverse(shit[L].begin() , shit[L].end());
		sort(shit[R].begin() , shit[R].end() , cmph);

		int pt = 0;
		ll mn = 1e18;

		for(auto u : shit[L])
		{
			while(pt < (int)shit[R].size() && h[shit[R][pt]] - h[v] + dp[u] + w[L] <= x)
				mn = min(mn , dp[shit[R][pt]] + w[R]) , pt++;

			if(pt)
				tmp.pb({mn , u});
		}
	}

	for(auto x : tmp)
		shit[v].pb(x.second) , dp[x.second] = x.first;

	sort(shit[v].begin() , shit[v].end() , cmpdp);

	vector<int> del;
	for(int i = 0; i < (int)shit[v].size(); i++)
	{
		int j = i , mn = shit[v][i];
		while(j < (int)shit[v].size() && dp[shit[v][j]] == dp[shit[v][i]])
		{
			if(h[shit[v][j]] < h[mn])
				mn = shit[v][j];
			j++;
		}
		del.pb(mn);
		i = j - 1;
	}
	shit[v] = del;
}

bool check(ll x)
{
	dfs(0 , x);
	return !shit[0].empty();
}

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

	int n;
	cin >> n;

	for(int i = 1; i < n; i++)
	{
		int p;
		cin >> p >> w[i];
		p--;

		adj[p].pb(i);
		h[i] = h[p] + w[i];
	}

	ll l = -1 , r = 1e11;

	while(r - l > 1)
	{
		ll m = (l + r) / 2;
		if(check(m))
			r = m;
		else
			l = m;
	}

	cout << r << endl;
}
























Measured memory_bytes: 34048
#include<iostream>
#include<cmath>
#include<stdio.h>

using namespace std;


int main(){


  double x1,x2,y1,y2;

  cin >> x1 >> y1 >> x2 >> y2;

  double result = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

  printf("%.8f\n",result);

  return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<utility>

int main(){
  	static bool sieve[1000001];
  	long long n,p;
  	std::cin >> n >> p;
  	long long c = 2;
  	bool end = false;
  	long long nfact=0;
  	long long ans=1;
  	if(n==1){
      	std::cout << p << "\n";
      	return 0;
    }
  	while(p>1&&c<1000001&&!end){
      	nfact=0;
      	while(p%c==0){
          	nfact++;
          	p/=c;
        }
      	for(int i=0;i<((nfact-nfact%n)/n);i++){
          	ans*=c;
        }
      	for(int i=c*2;i<1000001;i+=c){
          	sieve[i] = true;
        }
      	for(int i=c+1;i<1000001;i++){
          	if(!sieve[i]){
              	c=i;
              	break;
            }
          	if(i==1000000)end=true;
        }
    }
  	std::cout << ans << "\n";
  	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    
    string s;cin>>s;
    rep(i,0,11){
        cout<<s[i];
        if(i==3)cout<<" ";
    }cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
S = input()
# シミュレーションでいい気がする
# aで埋めるのに最小手数, bで埋めるのに最小手数, ...
ans = 10**9  # これを最小にしたい
alphabet = []
for i in range(26):
    alphabet.append(chr(ord("a")+i))
# print(alphabet)   # 全てのアルファベットが揃った
hoge = set(S)
for character in alphabet:  # characterで埋めることを考える
    if character not in hoge:
        continue
    tmp = 0
    copy_s = list(S).copy()
    # print(copy_s)
    # このcopy_sの文字を減らしていくことを考える
    while set(copy_s) != set(character):
        copy_s_dash = []
        for i in range(len(copy_s)-1):
            if copy_s[i] == character or copy_s[i+1] == character:
                copy_s_dash.append(character)
            else:
                copy_s_dash.append("?")
        # print(copy_s_dash)
        copy_s = copy_s_dash.copy()
    ans = min(ans, len(S)-len(copy_s))
print(ans)


Measured memory_bytes: 3064
#include<iostream>

using namespace std;
int main()
{
  int a,b;
  int sum = 0;
  
  cin >> a >> b;
  
  if (a > b)
  {
    sum += a;
    a--;
  }
  else
  {
    sum += b;
    b--;
  }
    
  if (a > b)
  {
    sum += a;
    a--;
  }
  else
  {
    sum += b;
    b--;
  }
  
  cout << sum ;
   
    return 0;
}

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


char buf[200003];
string s;

int im[26][200003];

char stk[200002];
int ss;
inline void dfs(int b, int len){
	if (b == INT_MAX){
		stk[ss] = '\0';
		printf("%s\n", stk);
		exit(0);
	}
	if (len == 0){
		return;
	}
	b++;
	for (int i = 0; i < 26; i++){
		stk[ss] = i + 'a';
		ss++;
		dfs(im[i][b], len - 1);
		ss--;
	}
}

int dp[200003];

int main(){
	scanf("%s", buf);
	s = buf;
	for (int i = 0; i < 26; i++){
		for (int j = 0; j < 200003; j++){
			im[i][j] = INT_MAX;
		}
	}
	for (int i = 0; i < s.size(); i++){
		im[s[i] - 'a'][i] = i;
	}
	for (int i = 0; i < 26; i++){
		for (int j = 200001; j >= 0; j--){
			im[i][j] = min(im[i][j + 1], im[i][j]);
		}
	}
	dp[s.size()] = 1;
	for (int i = s.size() - 1; i >= 0; i--){
		bool ok = false;
		for (int j = 0; j < 26; j++){
			if (im[j][i] == INT_MAX){
				ok = true;
			}
		}
		if (ok == true){
			dp[i] = 1;
			continue;
		}
		dp[i] = INT_MAX;
		for (int j = 0; j < 26; j++){
			if (im[j][i] != INT_MAX){
				dp[i] = min(dp[i], 1 + dp[im[j][i]+1]);
			}
		}
	}
	int cur = 0;
	while (1){
		int mint = INT_MAX;
		int id = 0;
		int id2;
		for (int i = 0; i < 26; i++){
			if (im[i][cur] == INT_MAX){
				stk[ss] = i+'a';
				ss++;
				stk[ss + 1] = '\0';
				printf("%s\n", stk);
				return 0;
			}
			if (mint>dp[im[i][cur] + 1]){
				mint = dp[im[i][cur] + 1];
				id = im[i][cur] + 1;
				id2 = i;
			}
		}
		stk[ss] = id2 + 'a';
		ss++;
		cur = id;
	}
	int len = 0;
	set<char> S;
	for (int i = 0; i < s.size(); i++){
		S.insert(s[i]);
		if (S.size() == 26){
			stk[ss] = 'a';
			ss++;
			cur = 0;
			S.clear();
		}
	}
	stk[ss] = cur + 'a';
	ss++;
	printf("%s\n", stk);
	return 0;
}

Measured memory_bytes: 21760
using System;
using System.Linq;

namespace _1125
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int[,] kaki = new int[x[0],x[1]];
                for (int i = 0; i < n; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    kaki[a[0] - 1,a[1] - 1] = 1;
                }
                int[] get = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int ret = 0;
                for (int i = 0; i <= x[0] - get[0]; i++)
                {
                    for (int j = 0; j <= x[1] - get[1]; j++)
                    {
                        int now = 0;
                        for (int k = 0; k < get[0]; k++)
                        {
                            for (int l = 0; l < get[1]; l++)
                            {
                                now += kaki[i + k,j + l];
                            }
                        }
                        ret = Math.Max(ret,now);
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9764
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	string A,B,C;
	cin>>A>>B>>C;
	
	if(A.substr(A.size()-1,1)!=B.substr(0,1))cout<<"NO\n";
	else if(B.substr(B.size()-1	,1)!=C.substr(0,1))cout<<"NO\n";
	else cout<<"YES";
	
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        rcv: [(Usize1, Usize1, i64); k],
    }
    let mut m = vec![vec![0; w]; h];
    for (r, c, v) in rcv {
        m[r][c] = v;
    }
    let mut dp = vec![vec![vec![0; 3 + 2]; w + 1]; h + 1];

    use std::cmp::max;
    for i in 0..h {
        for j in 0..w {
            for k in 0..=3 {
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                if k != 3 {
                    dp[i][j + 1][k + 1] = max(dp[i][j + 1][k], dp[i][j][k] + m[i][j]);
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k] + m[i][j]);
                }
            }
        }
    }

    let mut r = 0;
    r = max(r, *dp[h][w - 1][0..=3].iter().max().unwrap());
    r = max(r, *dp[h - 1][w][0..=3].iter().max().unwrap());
    r = max(r, *dp[h][w][0..=3].iter().max().unwrap());
    println!("{}", r);
}


Measured memory_bytes: 708980
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
ll vis[100005],z;
ll outdegree[100005];

void dfs(ll nd)
{
    if(vis[nd])
    return;
    if(ve[nd].size()==0){
        outdegree[nd]=0;
        return;
    }
    vis[nd]=1;
    for(auto next:ve[nd]){
        dfs(next);
        outdegree[nd]=max(outdegree[nd],outdegree[next]+1);
    }
}

void solve()
{
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=0,r=0,p=0,q=0,x=0,y=0,z=0,flag=0,sum=0;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        ve[x].push_back(y);
    }
    for(i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
    
    for(i=1;i<=n;i++)
    z=max(z,outdegree[i]);
    
    cout<<z<<endl;
    
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

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

int main(){
 long long int a,b[200010],c[200010];
  
  cin >> a;
  
  for(int i=0;i<a;i++)
    cin >> b[i];
  
  
  for(int i=0;i<a;i++){
    c[i] = b[i];
  }
  
  
  sort(b,b+a);
  
  
 
    if(b[(a/2)-1] == b[(a/2)]){
      for(int i=0;i<a;i++){
      cout << b[(a/2)-1] << endl;
      }
    }
  
  
    else{
      for(int i=0;i<a;i++){
      if(c[i] <= b[(a/2)-1]){
        
        cout << b[(a/2)] << endl;
      }
      
      else{
        cout << b[(a/2)-1] << endl;
      }
        
      }
    
  }
}
      
  
  
  
    


Measured memory_bytes: 5376
#include<stdio.h>
#include<math.h>
int main()
{
	int x,a,b;
	while(scanf("%d%d%d",&x,&a,&b)!=EOF) {
		int xa=abs(x-a);
		int xb=abs(x-b);
		if(xa<xb) printf("A\n");
		else printf("B\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  constexpr int lim = 3000;
  int x, y, z, k; cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  REP(i, x) cin >> a[i];
  REP(i, y) cin >> b[i];
  REP(i, z) cin >> c[i];

  vector<ll> ab;
  REP(i, x)REP(j, y){
    ab.emplace_back(a[i] + b[j]);
  }

  sort(ab.begin(), ab.end(), greater<ll>());
  sort(c.begin(), c.end(), greater<ll>());

  vector<ll> ans;
  REP(i, min(x*y, lim+1))REP(j, min(z, lim+1)){
    ans.emplace_back(ab[i] + c[j]);
  }

  sort(ans.begin(), ans.end(), greater<ll>());

  REP(i, k) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 43240
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;

int main(){
   int k;
   auto abc = vector<int>(3,0);
   cin >> abc[0] >> abc[1] >> abc[2];
   cin >> k;

   auto it = vector<int>::iterator();
   for (int i = 0; i < k; i++)
   {
      it = max_element(abc.begin(),abc.end());
      *it*=2;
   }
   
   cout << accumulate(abc.begin(),abc.end(),0);

}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
    IOS int t = 1;
    //cin >> t;
    while (t--)
    {
      int n,k;
      cin>>n>>k;
      int ans=0;
      int a[n];
      for(int i=0;i<n;i++) cin>>a[i];
      sort(a,a+n);
      for(int i=0;i<k;i++){
          ans+=a[i];
      }
  cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 3660
#if 2
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>


#define in std::cin
#define out std::cout

int32_t N;
struct B {
	int32_t x, y, r;
};
inline double DIFF(const B& b1, const B& b2) {
	double x = b1.x - b2.x;
	double y = b1.y - b2.y;
	return std::max(0.0, std::sqrt(x*x + y*y) - (b1.r + b2.r));
}
B b_s[1010];

double graph[1002][1002];

//ダイクストラ
double D[1002];
constexpr double INF = std::numeric_limits<double>::infinity();
void dijkstra(int s)
{
	using P = std::pair<double, int>;//cost pos
	std::priority_queue<P, std::vector<P>, std::greater<>> que;
	std::fill(std::begin(D), std::end(D), INF);
	D[s] = 0;
	que.emplace(0, s);
	while (!que.empty())
	{
		auto p = que.top(); que.pop();
		if (D[p.second] < p.first) { continue; }
		for (int32_t to = 0; to < N; ++to)
		{
			auto cost = p.first + graph[p.second][to];
			if (cost < D[to]) {
				D[to] = cost;
				que.emplace(D[to], to);
			}
		}
		//for (const auto& e : graph[v])
		//{
		//	d[e.to] = min(d[e.to], e.cost);
		//}
	}
}
int main()
{
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> b_s[0].x >> b_s[0].y; b_s[0].r = 0;
	in >> b_s[1].x >> b_s[1].y; b_s[1].r = 0;
	in >> N;
	N += 2;
	for (int32_t i = 2; i < N; ++i)
	{
		in >> b_s[i].x >> b_s[i].y >> b_s[i].r;
	}
	//グラフ生成
	for (int32_t i = 0; i < N; ++i)
	{
		for (int32_t j = 0; j < i; ++j)
		{
			graph[i][j] = graph[j][i] = DIFF(b_s[i], b_s[j]);
		}
		graph[i][i] = INF;
	}

	//ダイクストラ
	dijkstra(0);

	out<< std::fixed << std::setprecision(9) << D[1] << std::endl;

	return 0;
}
#endif


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

int main() {
  int N;
  cin >> N;
  ll A[200010] = {0};
  ll B[200010];
  
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    A[B[i]]++;
  }

  
  ll sum = 0;

  // N個のときの総数
  for (int i = 1; i <= N; i++) {
      sum += A[i] * (A[i] - 1) / 2;
  }
  
  // for文でそれぞれi個目のボールがなかったときに引くべき数
  for (int i = 0; i < N; i++) {
    sum -= A[B[i]] -1;
    cout << sum << endl;
    sum += A[B[i]] -1;
  }
  
  
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define s(x)	cin>>x
#define p(x)	cout<<x<<"\n"
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpi;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef long double ld;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  ll n,k;
  cin>>n>>k;
  ll arr[n];
  ll maxv=0;
  fo(i,n){cin>>arr[i];
  maxv=max(maxv,arr[i]);
  }
  ll start=1,end=maxv;
  ll res;
  while(start<=end)
  { //if(start==end)
    //{res=start;break;}
     ll m=(start+end)/2;
    ll co=0;
    fo(i,n)
    co=co+((arr[i]-1)/m);
    if(co<=k)
    {res=m;end=m-1;}
    else
    start=m+1;
    //else
    //{res=m;break;}
    //res=m;
  }
  p(res);
  
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

int main() {
  int m,n;cin>>m>>n;
  int ans=0,cnt=0;
  map<int,int> ac,wa;
  rep(i,n){
    int p;string s;cin>>p>>s;
    if(s=="WA")wa[p]++;
    else {
      if(ac[p]==0){
        ans++;
        cnt+=wa[p];
        ac[p]++;
      }
    }
  }
  cout<<ans<<" "<<cnt<<endl;
}

Measured memory_bytes: 12908
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A + 1):
  if a * 500 <= X <= a * 500 + B * 100 + C * 50:
    for b in range(B + 1):
      if a * 500 + b * 100 <= X <= a * 500 + b * 100 + C * 50:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

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

using namespace std;
int main()
{
	long a,b,c,k,ans;
	cin >> a>>b>>c >> k;
	if (a>=k){
		ans=k;
	}else if(a+b>=k){
		ans=a;
	}else{
		ans=a-(k-(a+b));
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3120
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
a = int(input())
if a == 1:
    print(0)
    exit()
a = factorization(a)
ans = 0
for i in range(len(a)):
    check = 3
    j = 1
    while True:
        if a[i][1] < check:
            ans += j
            break
        else:
            j += 1
            check += j + 1
print(ans)

Measured memory_bytes: 9492
#include <iostream>
#include <vector>
using namespace std;
int a[60],b[60],c[60],d[60],ans = 0,n,m,q;
void dfs(vector<int> &v){
    int i;
    if(v.size()<n){
        int k = v.back();
        for(i=k;i<=m;i++){
            v.push_back(i);
            dfs(v);
            v.pop_back();
        }
    }else{
        int val = 0;
        for(i=0;i<q;i++){
            if(v[b[i]] - v[a[i]]==c[i]) val += d[i]; 
        }
        ans = max(ans,val);
    }
}

vector<int> v;
int main(){
    int i;
    cin >> n >> m >> q;
    for(i=0;i<q;i++){
        cin >> a[i] >>  b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    v.push_back(1);
    dfs(v);
    cout << ans << endl;
}

Measured memory_bytes: 3608
N, K = map(int, input().split())

mod = 10**9+7
ans = 0

for i in range(K, N+2):
    min = i*(i - 1)/2
    max = (N + (N-i+1)) * (N - (N- i + 1)+1)/2
    ans += (max - min + 1)
print(int(ans%mod))

Measured memory_bytes: 9056
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;
long long INF = 1000000009;
int main()
{
	int n, m, c;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int sum = 0;
	int counter = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			sum += (a[i][j] * b[j]);
		}
		sum += c;
		if (sum > 0) counter++;
		sum = 0;
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
import Control.Applicative

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getInteger :: IO Integer
getInteger = (\a -> read a :: Integer) <$> getLine

changeStr :: String -> String -> String
changeStr "" res = res
changeStr ('1':input) res = changeStr input $ '1' : res
changeStr ('0':input) res = changeStr input $ '0' : res
changeStr ('B':input) "" = changeStr input ""
changeStr ('B':input) (_:res) = changeStr input res

main = do
    putStrLn =<< reverse <$> (changeStr <$> getLine <*> (return "" :: IO String))


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define MAX_N 1000

using namespace std;

long long divisor[MAX_N + 1];

void decompositPrime(int n) {
  int nn = n;
  int a = 2;
  while(nn >= a * a) {
    if(nn % a == 0) {
      divisor[a]++;
      nn /= a;
    }
    else {
      a++;
    }
  }
  divisor[nn]++;
}

int main(void) {
  int n;
  cin >> n;

  for(int i = 0; i < MAX_N + 1; i++) {
    divisor[i] = 0;
  }

  for(int i = 2; i <= n; i++) {
    decompositPrime(i);
  }
  long long count = 1;
  for(int i = 2; i <= n; i++) {
    count *= divisor[i] + 1;
    count %= 1000000007;
  }
  cout << count << endl;
}

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

using namespace std;

const int inf = 1<<25;

int main()
{
  int W; cin >> W;
  vector<int> a(W), b(W, 0);
  for(int i = 0; i < W; i++) cin >> a[i];
  int cap = 0;
  for(int i = 0; i < W; i++) {
    cap--;
    if(a[i] == 0) cap = inf;
    else if(a[i] < 0) cap = min(cap, -a[i]);
    b[i] = max(cap, b[i]);
  }
  cap = 0;
  for(int i = W-1; i >= 0; i--) {
    cap--;
    if(a[i] == 0) cap = inf;
    else if(a[i] < 0) cap = min(cap, -a[i]);
    b[i] = max(cap, b[i]);
  }
  int ans = 0;
  for(int i = 0; i < W; i++) {
    if(a[i] > 0) ans += min(a[i], b[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <string>

class rect {
public:
    int H;
    int W;
    rect(int H_, int W_)
        : H(H_)
        , W(W_)
    {
    }
};

void printRect(int height, int width) {
    for(int h = 0; h < height; h++){
        for(int w = 0; w < width; w++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
}

int main(int argc, char* argv[]){
    std::vector<rect> list;
    int H, W;
    while(true) {
       scanf("%d %d", &H, &W);
       if(H == 0 && W == 0) break;
       list.push_back(rect(H,W));
    }

    for(auto each: list) {
        printRect(each.H, each.W);
    }
}


Measured memory_bytes: 2560