akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    VS a(3);
    REP(i,3){
        cin >> a[i];
    }
    FOR(i, 1, 3) {
        if (a[i - 1][SZ(a[i-1]) - 1] != a[i][0]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
    int a, b, r1,rem;
    double r2;
    cin >> a >> b;
    r1 = a / b;
    rem = a % b;
    r2 = 1.0 * a / b;
    cout << r1 << " " << rem << " ";
    printf("%.8lf\n", r2);
    return 0;
    
}

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

using namespace std;
using namespace boost;

void dfs(const vector<vector<pair<int, int>>>& links, vector<int>& color, int v, int64_t value) {
    if (color[v] != -1) {
        return;
    }

    color[v] = value % 2;
    for (const auto& link : links[v]) {
        dfs(links, color, link.first, value + link.second);
    }
}

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

    vector<vector<pair<int, int>>> links(n);
    for (auto _ : irange(0, n - 1)) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        links[u].emplace_back(v, w);
        links[v].emplace_back(u, w);
    }

    vector<int> color(n, -1);
    dfs(links, color, 0, 0);

    for (auto c : color) {
        cout << c << endl;
    }
}

Measured memory_bytes: 8192
#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint n, x;
llint dp[3005][6005];
llint cnt[3005];

const int FACT_MAX = 3005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n >> x;
	make_fact();
	
	dp[0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 2*n; j++){
			for(int k = 1; k <= 2; k++){
				if(j+k <= 2*n){
					dp[i+1][j+k] += dp[i][j];
					dp[i+1][j+k] %= mod;
				}
			}
		}
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < x; j++){
			cnt[i] += dp[i][j], cnt[i] %= mod;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++){
			if(2*j-i <= 0) continue;
			if((x-1)-2*(i-j) <= 0) continue;
			if((x-1)-2*(i-j) >= 2*(2*j-i)) continue;
			cnt[i] += dp[2*j-i][(x-1)-2*(i-j)];
			cnt[i] %= mod;
		}
		if(x % 2 && 2*i > x) cnt[i]++, cnt[i] %= mod;
	}
	
	llint ans = 0;
	for(int i = 0; i <= n; i++){
		ans += cnt[i] * comb(n, i) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 141184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int main() {
  int V, E;
  cin >> V >> E;

  ll d[V][V];
  REP(i, V) {
    REP(j, V) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = INF;
      }
    }
  }

  REP(i, E) {
    int s, t;
    cin >> s >> t;
    cin >> d[s][t];
  }

  FOR(k, 0, V) {
    FOR(s, 0, V) {
      FOR(t, 0, V) {
        if (d[s][k] == INF || d[k][t] == INF) continue;
        d[s][t] = min(d[s][t], d[s][k] + d[k][t]);
      }
    }
  }

  int negative_cycle = 0;
  REP(i, V) {
    if (d[i][i] < 0) {
      negative_cycle = 1;
      break;
    }
  }

  if (negative_cycle) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    REP(s, V) {
      REP(t, V) {
        if (t) cout << " ";

        if (d[s][t] == INF) {
          cout << "INF";
        } else {
          cout << d[s][t];
        }
      }
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3172
X = int(input())

num = 0
for i in range(1, X + 1):
    if i**2 < X:
        num = i

ans = 1
for i in range(1, num + 1):
    for j in range(2, num + 1):
        x = i**j
        if x > X:
            break

        if ans < x:
            ans = x

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n;
  while(n = getInt()){
    REP(i,n){
      int pm = getInt();
      int pe = getInt();
      int pj = getInt();
      
      int sum = pm + pe + pj;
      
      if((pm == 100 || pe == 100 || pj == 100) ||
	 (pm + pe >= 180) || (sum >= 240)){
	puts("A");
      }else if((sum >= 210) || 
	       (sum >= 150 && (pm >= 80 || pe >= 80))){
	puts("B");
      }else{
	puts("C");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <cstddef>
#include<set>
#include<stack>
#include <deque>
#include<queue>
#include<utility>
#include<vector>
#include<map>
#include<cmath>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#define  ll  long long
#define ull unsigned long long
#define  sl(a)  scanf("%lld",&a)
#define  si(a)  scanf("%d",&a)
#define mem(n,m) memset(n,m,sizeof(n))
#define PI acos(-1)
#define pb    push_back
#define pf    push_front
#define vll   vector<ll>
#define pll   pair<ll,ll>
#define mp  make_pair
#define vpll vector< pair <ll,ll> >
#define vplpll vector<pair<ll,pair<ll,ll> > >
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S(X) ( (X) * (X) )
#define forab(i, a, b) for(i = a; i <= b; i++)
#define forn(i, n) for(i = 0; i < n; i++)
#define print(a,b) printf("Case %lld: %lld\n",a,b)
using namespace std;
ll powd(ll a,ll b){if(b==1){return a;}if(b%2==1){return powd(a,b-1)*a;}else{ll x=powd(a,b/2); return x*x;}}
ll powm(ll a,ll b,ll m){if(b==0){return 1;}if(b==1){return a%m;}if(b%2==1){return ((powm(a,b-1,m)%m)*(a%m))%m;}else{ll x=powm(a,b/2,m); return ((x%m)*(x%m))%m;}}
ll gcd(ll a,ll b){if(a==0){return b;}return gcd(b,a%b);}
ll a[300006],b[300006],r[300006],c[300005];
int main()
{
    ll h,w,u;
    sl(h);
    sl(w);
    sl(u);
    ll mar=0,mac=0;
    map<pair<ll,ll>,ll>pt;
    for(ll i=0;i<u;i++)
    {
        sl(a[i]);
        sl(b[i]);
        pt[{a[i],b[i]}]=1;
        r[a[i]]++;
        mar=max(r[a[i]],mar);
        c[b[i]]++;
        mac=max(mac,c[b[i]]);
    }
    //cout<<mar<<" "<<mac<<endl;
    mem(a,0);
    mem(b,0);
    ll m=0,n=0;
    for(ll i=1;i<=h;i++)
    {
        if(r[i]==mar)
        {
            a[m]=i;
            m++;
        }
    }
    for(ll i=1;i<=w;i++)
    {
        if(c[i]==mac)
        {
            b[n]=i;
            n++;
        }
    }
    if(m*n>300000)
    {
        cout<<mar+mac<<endl;
    }
    else
    {
        for(ll i=0;i<m;i++)
        {
            for(ll j=0;j<n;j++)
            {
                if(pt[{a[i],b[j]}]!=1)
                    {
                        cout<<mar+mac<<endl;
                        return 0;
                    }
            }
        }
        cout<<mar+mac-1<<endl;
    }
    return 0;
}


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

int main(){
    int n,m,i,j;
    cin>>n>>m;
    char a[n][m];
    int dp[n][m];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>a[i][j];
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(i=1;i<n;i++){
        if(a[i][0]!='#'){
            dp[i][0]=dp[i-1][0];
        }
    }
    for(i=1;i<m;i++){
        if(a[0][i]!='#'){
            dp[0][i]=dp[0][i-1];
        }
    }
    for(i=1;i<n;i++){
        for(j=1;j<m;j++){
            if(a[i][j]!='#'){
                if(a[i-1][j]!='#'){
                    dp[i][j]+=dp[i-1][j];
                }
                if(a[i][j-1]!='#'){
                    dp[i][j]+=dp[i][j-1];
                }
                dp[i][j]%=1000000007;
            }
        }
    }
    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 5120
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int cost[15];
int a[15][15];
int n,m,lim;
int ans=0x3f3f3f3f;
int b[15];
inline bool check()
{
	for(int i=1;i<=m;++i)
		if(b[i]<lim)
			return false;
	return true;
}
inline void dfs(int dep,int sum)
{
	if(dep>n)
	{
		if(check())
			ans=min(ans,sum);
		return;
	}
	dfs(dep+1,sum);
	for(int i=1;i<=m;++i)
		b[i]+=a[dep][i];
	dfs(dep+1,sum+cost[dep]);
	for(int i=1;i<=m;++i)
		b[i]-=a[dep][i];
	return;
}
signed main(void)
{
	cin>>n>>m>>lim;
	for(int i=1;i<=n;++i)
	{
		cin>>cost[i];
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	}
	dfs(1,0);
	if(ans==0x3f3f3f3f)
		cout<<-1<<endl;
	else
		cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    while(1) {
        int n;
        int a[5001] = {0};
        long int ans = -10000000;
        cin >> n;
        if(n == 0) break;

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

        for(int i=0; i<n; i++) {
            long int sum = 0;
            for(int j=i; j<n; j++) {
                sum += a[j];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  std::vector<int> a(n);
  for(auto&& e: a) {
    cin>>e;
  }
  std::vector<int> b=a;
  sort(b.begin(), b.end());
  std::map<int, int> map;
  for(auto&& e: b) {
    map[e]=map.size()-1;
  }

  for (int i = 0; i < n; ++i)
  {
    b[i]=abs(map[a[i]]-i);
  }
  int cnt=0;
  for(auto&& e: b) {
    if(e%2==1){
      cnt++;
    }
  }
  cout<<cnt/2;
}

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

int main() {
  int K,A,B;
  cin>>K>>A>>B;
  int x=A/K;
  int y=B/K;
  if(x==y){
    if(A==A/K*K){
      cout<<"OK"<<endl;
    }
    else{
    cout<<"NG"<<endl;
  }
  }
  else{
    cout<<"OK"<<endl;
  }
}

Measured memory_bytes: 3632
#%%
import sys
sys.setrecursionlimit(100000)

def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())

    g = [[] for _ in range(N-1)]
    for i in range(N-1):
        a, b = map(int, input().split())
        g[a-1].append((b-1, i))

    ans = [[None] for _ in range(N-1)]

    def dfs(v0, c0):
        c = 1
        for v1, e in g[v0]:
            if c==c0:
                c += 1
            ans[e] = c
            if v1 < N-1:
                dfs(v1, c)
            c += 1

    dfs(0, 0)

    print(max(ans))
    for c in ans:
        print(c)



# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc146","d",main)


Measured memory_bytes: 88204
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename F>
void forComb(int n, int k, F f)
{
    int comb = (1 << k) - 1;
    while (comb < (1 << n)) {
        f(comb);

        int x = comb & -comb;
        int y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }
}

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

    vector<int> a(5, 0);
    rep(i, n)
    {
        string s;
        cin >> s;
        switch (s[0]) {
        case 'M':
            a[0]++;
            break;
        case 'A':
            a[1]++;
            break;
        case 'R':
            a[2]++;
            break;
        case 'C':
            a[3]++;
            break;
        case 'H':
            a[4]++;
            break;
        default:
            break;
        }
    }

    int64_t result = 0;
    forComb(5, 3, [&](int comb) {
        int64_t c = 1;
        rep(i, 5)
        {
            if (((comb >> i) & 1) != 0) {
                c *= a[i];
            }
        }
        result += c;
    });
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
    int b = sc.nextInt();
    System.out.println(a*b);
//    String a = sc.next();  // input String
  }
}

Measured memory_bytes: 35792
#include<iostream>
int x[100];

using namespace std;
int count(int step){
  int ret = 0;
  if(step < 0)return 0;
  if(step == 0)return 1;
  if(x[step] > 0)return x[step];
  for(int i = 1;i <= 3;i++){
    ret += count(step - i);
  }
  return x[step] = ret;
}

int main(){
  int n;
  while(cin >> n && n > 0){
    cout << ((count(n)+9) / 10 + 364)/365 << endl;
  }
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i).first >> A.at(i).second;
    }
    sort(A.begin(), A.end());
    int rest=M;
    ll money=0;
    for(int i=0; i<N; i++){
        if(A.at(i).second>rest){
            money+=rest*A.at(i).first;
            break;
        }
        else{
            money+=A.at(i).second*A.at(i).first;
            rest-=A.at(i).second;
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 1792
import java.util.*;
import static java.util.Arrays.*;

public class Main {
	static int W,H;
	static char[][] room;
	static Scanner sc = new Scanner(System.in);
	
	static boolean read() {
		H = sc.nextInt(); W = sc.nextInt();
		if(W == 0 && H == 0) return false;
		room = new char[H][W];
		for(int i = 0; i < H; i++) {
			room[i] = sc.next().toCharArray();
		}
		return true;
	}
	
	static String solve() {
		boolean[][] visited = new boolean[H][W];
		for(int i = 0; i < H; i++) fill(visited[i], false);
		int x = 0, y = 0;
		
		while(true) {
			
			if(visited[y][x]) return "LOOP";
			
			visited[y][x] = true;
			char tile = room[y][x];
			if(tile == '>') {
				x++;
			} else if(tile == '<') {
				x--;
			} else if(tile == 'v') {
				y++;
			} else if(tile == '^') {
				y--;
			} else {
				break;
			}
		}
		
		return "" + x + " " + y;
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
const int N = 5010, mod = 1e9 + 7;
int n, x, y, dp[N][N], siz[N], tmp[N], g[N];
vector<int> G[N];
void dfs(int u, int fa) {
    siz[u] = 1; 
    dp[u][1] = 1;
    for(auto v : G[u]) {
        if(v == fa) continue;
        dfs(v, u);
        for(int i = 1; i <= siz[u] + siz[v]; ++i) tmp[i] = 0;
        for(int i = 1; i <= siz[u]; ++i)
            for(int j = 0; j <= siz[v]; ++j)
                (tmp[i + j] += 1ll * dp[u][i] * dp[v][j] % mod) %= mod;
        siz[u] += siz[v];
        for(int i = 1; i <= siz[u]; ++i) dp[u][i] = tmp[i];
    }
    for(int i = 2; i <= siz[u]; i += 2)
        (dp[u][0] += 1ll * dp[u][i] * g[i] % mod) %= mod;
    if(fa) dp[u][0] = mod - dp[u][0];
}
int main() {
    scanf("%d", &n);
    for(int i = 1; i < n; ++i) {
        scanf("%d %d", &x, &y);
        G[x].push_back(y); 
        G[y].push_back(x);
    }
    g[0] = 1;
    for(int i = 2; i <= n; i += 2)
        g[i] = 1ll * g[i - 2] * (i - 1) % mod;
    dfs(1, 0);
    printf("%d\n", dp[1][0]);
    return 0;
}


Measured memory_bytes: 58612
#include<iostream>
#include<string>
using namespace std;
int main(){
	int x,y;
	while(true){
		cin>>x>>y;
		if(x==0&&y==0)break;
		if(x>y){
			cout<<y<<" "<<x<<endl;
		}else{
			cout<<x<<" "<<y<<endl;
		}
	}
}



Measured memory_bytes: 2976
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>
#include <ext/rope>

#define F1(x,y,z) for(int x=y;x<z;x++)
#define F2(x,y,z) for(int x=y;x<=z;x++)
#define F3(x,y,z) for(int x=y;x>z;x--)
#define F4(x,y,z) for(int x=y;x>=z;x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 1500
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;
using namespace __gnu_cxx;

char x[MAX];
int n,k;

int main(){
	scanf("%s%d",x,&k);
	n=strlen(x);
	F1(a,0,n)if(k>=('z'-x[a]+1)%26)k-=('z'-x[a]+1)%26,x[a]='a';
	x[n-1]='a'+(x[n-1]-'a'+k%26)%26;
	printf("%s\n",x);
	#ifdef LOCAL_PROJECT
	system("pause");
	#endif
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

int n, m;
vector<int> h;
vector<vector<int>> adj;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    h.assign(n, 0);
    adj.assign(n, vector<int>());
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int res = 0;
    for(int i = 0; i < n; ++i){
        int mx = 0;
        for(auto j : adj[i]){
            mx = max(mx, h[j]);
        }
        if(h[i] > mx){
            res++;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 8736
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
//#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

const int N = 1000 + 1;
long long  g[N][N];

void solve(){
  	int n, m;
  	scanf("%d %d", &n, &m);
  	for(int i = 0; i < n; i++){
	 for(int j = 0; j < n; j++){
		if (i == j) g[i][j] = 0;
		else g[i][j] = -1e18; 
	  }	
    }
    for(int i = 0; i < m; i++){
	  int x, y, cost;
	  scanf("%d%d%d", &x, &y, &cost);
	  x--, y--;
	  g[x][y] = cost;	
    }
   for(int k = 0; k < n; k++){
	  for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			g[i][j] = max(g[i][j], g[i][k] + g[k][j]);
		  }  
		}  
	 }
	if (g[0][0] > 0) printf("inf");
	else printf("%lld\n", g[0][n - 1]);
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
using namespace std;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
typedef pair<ll, ll>P;
typedef vector<int>vec;
ll inf = -1;
ll mod = pow(10, 9) + 7;

vec prime_factor(int n){
	vec res;
	for(int i=2;i*i<=n;i++){
		int cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		if(cnt!=0){
			res.push_back(cnt);
		}
	}
	if(n!=1){
		res.push_back(1);
	}
	return res;
}

long modpow(long a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		//pが偶数の時
		int halfP = p / 2;
		long half = modpow(a, halfP);
		//a^(p/2) をhalfとして、half*halfを計算
		return half * half % mod;
	}
	else {
		//pが奇数の時は、
		//pを偶数にするために1減らす
		return a * modpow(a, p - 1) % mod;
	}
}
long calcComb(int a, int b) {
	if (b > a - b) return calcComb(a, a - b);
 
 
	long ansMul = 1;
	long ansDiv = 1;
	for (int i = 0; i < b; i++)
	{
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	//ansMul / ansDivをやりたい
	//ansDivの逆元を使って求めよう！
 
	long ans = ansMul * modpow(ansDiv, mod - 2) % mod;
	return ans;
}

int main() {
	int n, m; cin >> n >> m;
	vec num;
	num = prime_factor(m);
	ll ans = 1;
	for (int i = 0; i < num.size(); i++) {
		ans *= calcComb(num[i] + n-1, num[i]);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int Partition(int *A,int p,int r){
  int i,x,j,tmp;
  x = A[r];
   
  i = p-1;
  for(j = p;j <= r-1;j++){
    if(A[j] <= x){
      i = i + 1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}


int main(void){
  int n,i,A[100000],p;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  p=Partition(&A[0],0,n-1);
  printf("%d",A[0]);
  for(i=1;i<n;i++)
    if(i==p)
      printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 996
#include <stdio.h>
#include <stdlib.h>

int main() {
	char a[4096];
	int i, l;
	fgets(a, 4096, stdin);
	// Counting string length
	for(l=0;;l++) {
		if (a[l]=='\0') break;
	}
	// Ignore NULL
	l--;
	
	for(i=0;i<l;i++) {
		// If small capital
		if ( ('a'<=a[i])&&(a[i]<='z') ) {
			a[i] = a[i] - 'a' + 'A';
		}
	}
	printf("%s",a);
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[0] << c[0] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	vll cnt(100001,0) ;
	ll n ; cin >> n ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		cnt.at(a)++ ;
	}
	ll sub = 0 ;
	ll two = 0 ;
	for(int i=0;i<cnt.size();i++){
		if(cnt.at(i)>1){
			if(cnt.at(i)&1){
				sub += cnt.at(i)/2 ;
			}else{
				sub += cnt.at(i)/2-1 ;
				two++ ;
			}
		}
	}
	sub += (two+1)/2 ;
	cout << n-sub*2 << endl ;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#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())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k,n;
    cin >> n >> k;
    vector<int> arr(n);
    F0R(i,n)
        cin >> arr[i];
    SORT(arr);
    int tot=0;
    F0R(i,k)
        tot+=arr[i];
    cout << tot;

    return 0;
}


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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 100003

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

  vector<int> vp;

  for(int i=0;i<3*n;i++)
  {
  	int x;
  	scan(x);
  	vp.pb(x);
  }

  sort(vp.begin(),vp.end());

  lli res = 0;

  for(int i=vp.size()-2,cnt=1;cnt<=n;i-=2,cnt++)
  {
  	res += (lli)vp[i];
  }

  cout<<res;
  return 0;
}


void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

Measured memory_bytes: 2548
#include<stdio.h>
#include<string.h>
int main(){
  int i;
  int c=0;
  char s[101];
  while(scanf("%s",s)!=-1){
    for(i=0;i<strlen(s)/2;i++)
      if(s[i]!=s[strlen(s)-i-1])
	break;
    if(i==strlen(s)/2)
      c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main() {

  int a,i;
  int flag=0;
  long sum=0;
    
  scanf("%d",&a);

  for(i=1;i<=a;i++) {
    if(i%3==0&&i%5==0) {
        flag+=1;
    }
      
    if(i%3==0) {
        flag+=1;
    }
      
    if(i%5==0) {
        flag+=1;
    }
      
    if(flag==0) {
        sum+=i;
    }
      
    flag=0;
  }

  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


int n;
const int N=1e5+10;
int a[N][3],dp[N][4];

int rec(int ind,int p) {
    if(ind==n)
        return 0;
    int &cur=dp[ind][p+1];
    if(cur!=-1)return cur;
    int ans=0;
    ans=max({ans,(p!=0)*(a[ind][0]+rec(ind+1,0)),(p!=1)*(a[ind][1]+rec(ind+1,1)),(p!=2)*(a[ind][2]+rec(ind+1,2))});
    return cur=ans;
}

void solve(){
    cin >> n;
    for(int i=0;i<n;++i)
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1;i<n;++i) {
        dp[i][0] = a[i][0] + max(dp[i-1][1] , dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][2] , dp[i-1][0]);
        dp[i][2] = a[i][2] + max(dp[i-1][1] , dp[i-1][0]);
    }
    cout << max({dp[n-1][0] , dp[n-1][1] , dp[n-1][2]}) << "\n";
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  vector<vector<bool> > F(n, vector<bool>(10, false));
  rep(i, n){
    rep(j, 10){
      int f; cin >> f;
      if(f == 1) F[i][j] = true;
    }
  }

  vector<vector<int> > P(n, vector<int>(11));
  rep(i, n){
    rep(j, 11){
      cin >> P[i][j];
    }
  }

  int ans = -1001001001;
  REP(tmp, 1, 1<<10){
    bitset<10> s(tmp);
    int sum = 0;
    rep(i, n){
      int cnt = 0;
      rep(j, 10){
        if(s.test(j) && F[i][j]) cnt++;
      }
      sum += P[i][cnt];
    }
    chmax(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

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

int n,x,y,z;
multiset<LL> s;
struct node
{
	LL a,b,c;
}a[100048];
LL f[100048],g[100048];

bool cmp(node x,node y)
{
	return x.a-x.b<y.a-y.b;
}

int main ()
{
	int i,j;
	scanf("%d%d%d",&x,&y,&z);
	n=x+y+z;
	LL ans=0;
	for (i=1;i<=n;i++) 
	{
		scanf("%I64d%I64d%I64d",&a[i].a,&a[i].b,&a[i].c);
		ans+=a[i].c;a[i].a-=a[i].c;a[i].b-=a[i].c;
	}
	sort(a+1,a+n+1,cmp);
	//for (i=1;i<=n;i++) cout<<a[i].a<<' '<<a[i].b<<endl;
	LL sum=0;
	for (i=1;i<=n;i++)
	{
		sum+=a[i].b;
		s.insert(a[i].b);
		if (s.size()>y)
		{
			sum-=*s.begin();
			s.erase(s.begin());
		}
		//cout<<*(--s.end())<<"#"<<endl;
		//sum+=*(--s.end());
		f[i]=sum;
	}
	s.clear();sum=0;
	for (i=n;i>=1;i--)
	{
		sum+=a[i].a;
		s.insert(a[i].a);
		if (s.size()>x)
		{
			sum-=*s.begin();
			s.erase(s.begin());
		}
		//sum+=*(--s.end());
		g[i]=sum;
	}
	/*for (i=1;i<=n;i++) cout<<f[i]<<endl;
	cout<<"_________________"<<endl;
	for (i=n;i>=1;i--) cout<<g[i]<<endl;
	cout<<"_________________"<<endl;*/
	LL res=-1;
	for (i=y;i<=n-x;i++) res=max(res,ans+f[i]+g[i+1]);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  double x, y;
  coor cur(0, 0);
  coor dir(1, 0);
  double pi = atan(1) * 4;
  while (scanf(" %lf,%lf ", &x, &y) == 2) {
    //printf("%.3lf\n%.3lf\n", cur.real(), cur.imag());
    if (abs(x) < EPS && abs(y) < EPS) {break;}
    cur += coor(x * dir.real(), x * dir.imag());
    double Arg = arg(dir) + (y / 180) * pi;
    dir = coor(cos(Arg), sin(Arg));
  }
  printf("%d\n%d\n", (int)cur.imag(), (int)cur.real());
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int sum = 0;

        sum = n%500;


        if(sum<=a){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 21716
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, K; long long L;
	cin >> N >> K >> L;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	int l = 0, r = N + 5;
	while (r - l > 1) {
		int m = (l + r) >> 1;
		vector<int> c(N);
		for (int i = 0; i < N; ++i) {
			if (A[i] <= m) c[i] = 1;
		}
		vector<int> cs(N + 1);
		for (int i = 0; i < N; ++i) {
			cs[i + 1] = cs[i] + c[i];
		}
		long long ans = 0;
		for (int i = 0; i < N; ++i) {
			int ptr = lower_bound(cs.begin(), cs.end(), K + cs[i]) - cs.begin();
			ans += (N + 1) - ptr;
		}
		if (ans < L) l = m;
		else r = m;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 5188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    double T,X;
    cin>>T>>X;
    cout<<fixed<<setprecision(10)<<T/X;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    ll h, w, n;
    cin >> h >> w >> n;
    vll ca(h + 1), cb(w + 1);
    map<pll, ll> m;
    fo(i, n){
        ll a, b;
        cin >> a >> b;
        m[{a,b}] = 1;
        ca[a]++, cb[b]++;
    }
    ll mxa = 0,mxb = 0,x = 0,y = 0;
    foa(i, 1, h + 1){
        if(mxa < ca[i]){
            x = i;
            mxa = ca[i];
        }
    }
    foa(i, 1, w + 1){
        if(mxb < cb[i]){
            y = i;
            mxb = cb[i];
        }
    }
    vll vh,vw;
    foa(i, 1, h + 1){
        if(mxa == ca[i])vh.pb(i);
    }
    foa(i, 1, w + 1){
        if(mxb == cb[i])vw.pb(i);
    }
    ll f = 1;
    for(ll &i :  vh){
        for(ll &j :  vw){
            if(!m[{i, j}]){
                f = 0;
                break;
            }
        }
    }
    cout << mxa + mxb - f << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 49996
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		if (sc.next().equals("H")) {
			System.out.println(sc.next().equals("H") ? "H" : "D");
		} else {
			System.out.println(sc.next().equals("H") ? "D" : "H");
		}
	}
}


Measured memory_bytes: 21588
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

struct Cell {
  i64 Size;
  i64 Cost;

  Cell() : Cell(0, 0) {}
  Cell(i64 size, i64 cost) :
    Size(size), Cost(cost) {}

  Cell& operator+=(const Cell& rhs) {
    Size += rhs.Size;
    Cost += rhs.Cost + Size;

    return *this;
  }
  friend Cell operator+(Cell lhs, const Cell& rhs) {
    lhs += rhs;
    return lhs;
  }

  friend bool operator<(const Cell& l, const Cell& r) {
    return l.Cost < r.Cost;
  }
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  vector<i64> a(N);
  F0R(i, N) {
    cin >> a[i];
  }

  // dp[i][j] := i+1 匹スライムを1つにするときの、合計サイズと最小コスト
  vector<vector<Cell>> dp(N, vector<Cell>(0));

  dp[0].reserve(N);
  F0R(i, N) {
    dp[0].emplace_back(a[i], 0);
  }

  FOR(i, 1, N) {
    dp[i].reserve(N - i);

    // i+1 匹を1つにする場合をそれぞれ計算
    F0R(j, N - i) {

      Cell cmin = { 0, INT64_MAX };

      // 1匹 + i匹、2匹 + i-1匹、3匹 + i-2匹...
      F0R(k, i) {
        Cell c = dp[k][j] + dp[i-1-k][j+1+k];
        if (c < cmin) cmin = c;
      }
      
      dp[i].push_back(cmin);

      //cout << dp[i][j].Size << "," << dp[i][j].Cost << ' ';
    }
    //cout << newl;
  }

  cout << dp[N - 1][0].Cost;
}
#endif


Measured memory_bytes: 1536
n = int(input())
length = [[]*3]*n
for i in range(n):
    length[i] = input().split()

for i in range(n):
    
    if int(length[i][0])**2 == int(length[i][1])**2 + int(length[i][2])**2:
        print("YES")
        continue

    if int(length[i][1])**2 == int(length[i][2])**2 + int(length[i][0])**2:
        print("YES")
        continue

    if int(length[i][2])**2 == int(length[i][0])**2 + int(length[i][1])**2:
        print("YES")
        continue
    
    print("NO")


Measured memory_bytes: 5812
A, B, C, K = map(int, input().split())

# a = 0a + b + c
# b = 0b + a + c
# c = 0c + a + b
# a - b = - a + b

# a = 2a + b + c
# b = 2b + a + c
# c = 2c + a + b
# a - b = 2a + b + c - 2b - a - c = a - b

# a = 2a + 3b + 3c
# b = 2b + 3a + 3c
# c = 2c + 3a + 3b
# a - b = 2a + 3b + 3c - 2b - 3a - 3c =  - a + b

if abs(A - B) > 1e18:
    print("Unfair")
elif K % 2 == 0:
    print(A - B)
else:
    print(B - A)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int a, b;
string s;
int ans = 10000000;
int main() {
	cin >> s;
	int n = s.size();
	ans = n;
	for(int i = 0; i < n - 1; i++) {
		if(s[i] != s[i + 1])
			ans = min(ans, max(i + 1, n - i - 1));
	}
	cout << ans;
}

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

int main() {
    int x, h;
    while (cin >> x >> h, (x || h)) {
        double area = x * x + 2.0 * x * sqrt(h * h + x * x / 4.0);
        cout.precision(6);
        cout << fixed << area << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

typedef long long ll;

int main()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#はっきり言ってあまり良い手とは言えないが思いつかなければ仕方ない。+N後の要素を参照させる。
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
#入力
N = int(input())
ls = list(input())
#アルファベットに対応する番号を取得
countlist = [None for _ in range(len(ls))]
for i in range(len(ls)):
  for j in range(26):
    if ls[i] == alphabet[j]:
      countlist[i] = j
#カウントリストに「N文字」分を加える
for i in range(len(countlist)):
  countlist[i] += N
#番号に対応するアルファベットを取得
anslist = [None for _ in range(len(ls))]
for i in range(len(anslist)):
  anslist[i] = alphabet[countlist[i]]
#結果。リスト内要素を結合して表示
ans = ''.join(anslist)
print(ans)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int a[30];
int b[30];
int dp[31][1<<16];
int main() {
	int n,c;
	while(scanf("%d %d",&n,&c),n) {
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		memset(dp,-1,sizeof(dp));
		for(int i=0;i<n;i++) {
			for(int j=0;j<16;j++) {
				int x;
				scanf("%d",&x);
				if(x) a[i]|=(1<<j);
			}
		}
		for(int i=0;i<c;i++) {
			for(int j=0;j<16;j++) {
				int x;
				scanf("%d",&x);
				if(x) b[i]|=(1<<j);
			}
		}
		dp[0][0]=0;
		for(int i=0;i<n;i++) {
			for(int bit=0;bit<(1<<16);bit++) {
				if(dp[i][bit]==-1) continue;
				int Bit=bit|a[i];
				dp[i+1][Bit]=max(dp[i+1][Bit],dp[i][bit]);
				for(int j=0;j<c;j++) {
					int poyo=Bit&b[j];
					int cnt=0;
					for(int k=0;k<16;k++) if(poyo&(1<<k)) cnt++;
					dp[i+1][Bit&(~b[j])]=max(dp[i+1][Bit&(~b[j])],dp[i][bit]+cnt);
				}
			}
		}
		int ans=0;
		for(int bit=0;bit<(1<<16);bit++) {
			ans=max(ans,dp[n][bit]);
		}
		printf("%d\n",ans);
	}
}

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

int main(){
    int n,m; cin >> n >> m;
    vector<pair<int,int>> student(n),checkpoint(m);
    rep(i,n){
        cin >> student[i].first >> student[i].second;
    }
    rep(i,m){
        cin >> checkpoint[i].first >> checkpoint[i].second;
    }

    rep(i,n){
        int ans = 0;
        int min_dis = 1000000000;
        rep(j,m){
            int dis = abs(student[i].first-checkpoint[j].first) + abs(student[i].second-checkpoint[j].second);
            if(min_dis > dis){
                ans = j+1;
                min_dis = dis;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    string t;cin >> t;
    ll a,b; cin >> a >> b;
    string u;cin >> u;
    if(u == s)a--;
    if(u == t)b--;

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
struct UnionFind {
  /*
  UnionFind uf(x)で初期化
  root(x) xの根を返す
  unite(x,y) xとyを同一の根にする
  same(x,y) xとyの根が同一ならtrue
  size(x)　集合の大きさを返す*/
  vector<int> d;
  UnionFind(int n) : d(n, -1) {}
  int root(int x) {  // xの根を返す
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x);  // xとyを連結する
    y = root(y);
    if (x == y) return 0;
    if ((d[x] > d[y])) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  int size(int x) { return -d[root(x)]; }
};
int main() {
  ll N, M;
  cin >> N >> M;
  UnionFind uf(N);
  REP(i, M) {
    ll a, b;
    cin >> a >> b, a--, b--;
    uf.unite(a, b);
  }
  unordered_map<ll, ll> up{};
  REP(i, N) { up[uf.root(i)]++; }
  ll ans = -1;
  for (auto s : up) {
    ans = max(ans, s.second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12240