akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
/*
 * 
 */
int main(int argc, char** argv) {

    
    int n;
    scanf("%d",&n);
    int A[n];
    int p, key, lc = 3, rc = 4;
    for(int i = 0; i < n; i++){
       
        scanf("%d",&A[i]);

    }
    
    for(int i = 0; i < n; i++){
        
        if(i == 0){
            printf("node %d: key = %d, left key = %d, right key = %d, \n", i+1 , A[i], A[i+1], A[i+2]);
            continue;
        }
        
        else
        {
            printf("node %d: key = %d, parent key = %d, ",i+1 , A[i], A[(i-1)/2] );
            if(lc < n)printf("left key = %d, ",A[lc]);
            if(rc < n)printf("right key = %d, ",A[rc]);
            lc = lc + 2;
            rc = rc + 2;
            printf("\n");
          
        }
    }
        
    return 0;
}



Measured memory_bytes: 2040
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 

ll n, a, b, c, d;

vector <pair<ll, ll > > gg;
map<ll, ll> dp;

ll go (ll n) {
	if(n == 0) return 0;
	if(n == 1) return d;
	if(dp.count(n)) return dp[n];
	ll &res = dp[n];
	res = INF;
	if(n < res / d) res = n * d;

	for (auto it : gg) {
		ll l = n / it.first;
		ll r = (n+it.first-1) / it.first;
		r *= it.first;
		l *= it.first;

		res = min(res, go(l / it.first) + it.second + llabs(n-l) * d);
		res = min(res, go(r / it.first) + it.second + llabs(n-r) * d);
	}
	
	return res;
}

int main () {
	SpeedForce;
	setIO();
	
	int T;
	cin >> T;
	while(T--) {
		cin >> n >> a >> b >> c >> d;
		dp.clear();
		gg = {{2, a}, {3, b}, {5, c}};

		cout << go(n) << '\n';
	}

	return Accepted;
}

// B...a

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

int main(){

    int h,w;

    while(1){
        cin >> h >> w;
        if((h==0)&&(w==0)) break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){

                if(i==0 || i == h-1) cout << "#" ; 
                else if(j==0 || j == w-1) cout << "#" ;
                else cout << "." ;
            }
            cout << endl;
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 3100
def is_mm(target):
    n = int(target)
    return 1 <= n <= 12


def get_result(first2_is_mm, last2_is_mm):
    if first2_is_mm and last2_is_mm:
        return "AMBIGUOUS"
    if not first2_is_mm and not last2_is_mm:
        return "NA"
    if first2_is_mm:
        return "MMYY"
    return "YYMM"


s = str(input())
first2, last2 = ((i + j) for (i, j) in zip(s[::2], s[1::2]))
print(get_result(is_mm(first2), is_mm(last2)))


Measured memory_bytes: 3060
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const ll MOD = 1000000007;
ll n, k, ans = 1;
vector<ll> a, b;

int main() {Tie
    cin >> n >> k;
    for(ll i = 0, tmp; i < n; i++) {
        cin >> tmp;
        if(tmp >= 0)
            a.pb(tmp);
        else
            b.pb(tmp);
    }
    sort(ALL(a));
    sort(ALL(b));
    if(a.empty() || (a.back() == 0 && k % 2 == 0 && b.size() >= k)) {
        if(k % 2 == 1)
            reverse(ALL(b));
        for(int i = 0; i < k; i++)
            ans = ans * abs(b[i]) % MOD;
        if(k % 2 == 1)
            ans = (-ans + MOD) % MOD;
    } else if(b.empty()) {
        reverse(ALL(a));
        for(int i = 0; i < k; i++)
            ans = ans * a[i] % MOD;
    } else if(a.back() == 0) {
        ans = 0;
    } else {
        if(k & 1)
            ans = a.back(), a.pop_back();
        reverse(ALL(b));
        for(int i = k & 1; i < k; i += 2) {
            if(b.size() > 1 && (a.size() < 2 || b[b.size() - 1] * b[b.size() - 2] >= a[a.size() - 1] * a[a.size() - 2]))
                ans = ans * abs(b[b.size() - 1]) % MOD * abs(b[b.size() - 2]) % MOD, b.pop_back(), b.pop_back();
            else if(a.size() > 1)
                ans = ans * a[a.size() - 1] % MOD * a[a.size() - 2] % MOD, a.pop_back(), a.pop_back();
            else if(!a.empty() && !b.empty())
                ans = ans * a[a.size() - 1] % MOD * abs(b[b.size() - 1]) % MOD, ans = (-ans + MOD) % MOD, a.pop_back(), b.pop_back();
            else
                while(1);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int b = 0;
  string s;
  cin >> s;
  const char *p = s.c_str();
  while (*p != '\0') {
    if (*p == '1') {
      ++b;
    }
    ++p;
  }
  cout << b << endl;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $n);

$aa = fgets(STDIN);
$a = explode(' ', $aa);

foreach ($a as &$value) {
    $value = (int) $value;
}
unset($value);

$count = 0;
foreach($a as $key => $value) {
  if(isOdd($key + 1) && isOdd($value)) {
    $count++;
  }
}
echo $count;

function isOdd($num) {
  if($num % 2) {
    return true;
  } else {
    return false;
  }
}

Measured memory_bytes: 16124
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    string s; cin>>s;

    vector<int> rsum(n+1, 0), gsum(n+1, 0), bsum(n+1, 0);
    for(int i=0; i<n; i++){
        rsum[i+1] = rsum[i];
        gsum[i+1] = gsum[i];
        bsum[i+1] = bsum[i];
        if(s[i] == 'R') rsum[i+1]++;
        if(s[i] == 'G') gsum[i+1]++;
        if(s[i] == 'B') bsum[i+1]++;
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+2; j<n; j++){
            if((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')){
                ll rcur = rsum[j+1] - rsum[i];
                if((j - i) % 2 == 0){
                    if(s[(j+i)/2] == 'R') rcur--;
                }
                ans += rcur;
                //continue;
            }

            if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
                ll gcur = gsum[j+1] - gsum[i];
                if((j - i) % 2 == 0){
                    if(s[(j+i)/2] == 'G') gcur--;
                }
                ans += gcur;
                //continue;
            }

            if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
                ll bcur = bsum[j+1] - bsum[i];
                if((j - i) % 2 == 0){
                    if(s[(j+i)/2] == 'B') bcur--;
                }
                ans += bcur;
                //continue;
            }

            //cout << i << " " << j << " " << ans << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

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

class R implements Comparable<R> {
  String name;
  int score;
  int id;
  
  R(String name, int score, int id) {
    this.name = name;
    this.score = score;
    this.id = id;
  }
  
  public int compareTo(R r) {
    if (this.name.compareTo(r.name) != 0) {
      return this.name.compareTo(r.name);
    }
    return - this.score + r.score;
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    R[] rs = new R[n];
    for (int i = 0; i < n; i++) {
      String name = reader.next();
      int score = reader.nextInt();
      rs[i] = new R(name, score, i+1);
    }
    Arrays.sort(rs);
    for (R r : rs) {
      out.println(r.id);
    }
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public int[] nextIntArray(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLongArray(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
}

class Algorithm {
  private static void swap(Object[] list, int a, int b) {
    Object tmp = list[a];
    list[a] = list[b];
    list[b] = tmp;
  }
  
  public static <T extends Comparable<? super T>> boolean nextPermutation(T[] ts) {
    int rightMostAscendingOrderIndex = ts.length - 2;
    while (rightMostAscendingOrderIndex >= 0 &&
        ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostAscendingOrderIndex + 1]) >= 0) {
      rightMostAscendingOrderIndex--;
    }
    if (rightMostAscendingOrderIndex < 0) {
      return false;
    }
    
    int rightMostGreatorIndex = ts.length - 1;
    while (ts[rightMostAscendingOrderIndex].compareTo(ts[rightMostGreatorIndex]) >= 0) {
      rightMostGreatorIndex--;
    }
    
    swap(ts, rightMostAscendingOrderIndex, rightMostGreatorIndex);
    for (int i = 0; i < (ts.length - rightMostAscendingOrderIndex - 1) / 2; i++) {
      swap(ts, rightMostAscendingOrderIndex + 1 + i, ts.length - 1 - i);
    }
    return true;
  }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int f(int x){
	int res=0;
	while(x%2==0){
		x/=2;
		res++;
	}
	return res;
}

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}

int main(){
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	rep(i,n) cin>>a[i];

	rep(i,n) a[i]/=2;

	int t=f(a[0]);
	rep(i,n){
		if(f(a[i])!=t){
			cout<<0<<endl;
			return 0;
		}
		a[i]>>=t;
	}
	m>>=t;
	
	ll l=1;
	rep(i,n){
		l=lcm(l,a[i]);
		if(l>m){
			cout<<0<<endl;
			return 0;
		}
	}

	m/=l;
	int ans=(m+1)/2;
	cout<<ans<<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  ll n;
  cin>>n;
  v(ll) h(n+1);
  rrep(i,n) cin>>h[i];
  v(ll) dp(n+1);
  dp[2]=abs(h[2]-h[1]);
  for(ll i=3;i<=n;i++){
    dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
    mins(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<dp[n]<<endl;
}    


Measured memory_bytes: 4844
//C 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int raw[100000][10],dp[100000][10];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin >> n;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= 3;j++)cin >> raw[i][j];
	}
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= 3;j++){
			for(int k = 1;k <= 3;k++)if(k != j){
				dp[i][j] = max(dp[i-1][k],dp[i][j]);
			}
			dp[i][j] += raw[i][j];
		}
	}
	cout << max({dp[n][1],dp[n][2],dp[n][3]});
	return 0;
}

Measured memory_bytes: 11508
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,i,a[100005];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++)a[i]+=a[i-1];
	for(i=n-1;i>0&&a[i]*2>=a[i+1]-a[i];i--);
	printf("%d\n",n-i);	
	return 0;
}

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

int main(){
  ll n;//intだとエラー
  cin>>n;
  ll ans=0;
  rep(i,n) ans+=i;
  //1%2=1,2%3=2,,,(n-1)%n=n-1,n%1=0となって1からn-1までの総和が答

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n";
#define nec cout<<"\n";continue; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007; 

int main()
{
    io();
	string s="7";
	li c=1;
	li n;
	cin>>n;
	if(n%2==0 || n%5==0)
	{
		cout<<-1;
	}
	else
	{
		li x=0,i;
		for(i=1;;i++)
		{
	       	x=x*10+7;  
		    x=x%n;
		    if(x==0)break;
		}
		cout<<i;
	}
}

Measured memory_bytes: 3628
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

c = Counter(A)
c = sorted(c.items(), key=lambda x:x[0], reverse=True)
d = []
for a in c:
    # print(a)
    if a[1] >= 2:
        d.append(a)
# print(d)
d = sorted(d, key=lambda x:x[0], reverse=True)
squ = 0
for y in d:
    # print(y)
    if y[1] >= 4:
        squ = (y[0] ** 2)
    
    break
ans = squ

if len(d) >= 2:
    
    
# if len(d) >= 2:
    ans = (max(d[0][0] * d[1][0], ans))


print(ans)

Measured memory_bytes: 23992
#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 <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, count[26] = {0};
	long long ans = 1;
	string s;

	cin >> n >> s;

	for (int i = 0; i < s.size(); ++i) {
		count[s[i]-'a']++;
	}

	for (int i = 0; i < 26; ++i) {
		ans = (ans * (count[i] + 1)) % MOD;
	}

	ans--;

	if (ans < 0) {
		ans += MOD;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N; cin >> N;
	int now=0, ans=0;
	for(int i=0; i<N; ++i){
	    int h; cin >> h;
	    if(now<=h){
	        ++ans;
	        now=h;
	    }
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  int ans = 0;
  rep(ch,1<<h)rep(cw,1<<w) { 
    int cnt = 0;
    rep(v0,h)rep(w0,w) {
      if(ch>>v0&1) continue;
      if(cw>>w0&1) continue;
      if(c[v0][w0] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int h,n,sum,x;
  cin >> h >> n;
  for(int i = 0; i < n; i++){
    cin >> x;
    sum += x;
  }
  if(h<=sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N);
  vi cnt(1001 , 0);
  vi v(N); in(v);
  rep(i,N) {cnt[ v[i] ]++;}
  vi ruiseki(1001 , 0);
  rep1(i,1000) ruiseki[i] = ruiseki[i-1] + cnt[i];
  ll ans = 0;
  //trc(ruiseki);
  rep(x,N) rep(y,N){
    if(x == y) continue;
    int i = v[x] , j = v[y];
    if(i > j) swap(i , j);
    ll k = ruiseki[ min(1000,j+i-1) ] - ruiseki[j-i];
    if(j-i+1 <= i && i <= min(1000,j+i-1)) k--;
    if(j-i+1 <= j && j <= min(1000,j+i-1)) k--;
    if(k) trc(i,j,k);
    ans += 1LL * k;
  }
  trc(ans);
  out(ans / 6);


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int L;
    int R;
    int d;

    cin >> L >> R >> d;

    cout << (R/d) - (L-1)/d << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ipair = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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 int INF = 1001001001;

int main(){
  int N;
  cin >> N;
  if(N%10 == 3){
    cout << "bon" << endl;
  }else if(N%10==0 || N%10==1 || N%10== 6 || N%10==8){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }


  return 0;
}


Measured memory_bytes: 3636
n = 5
l = []
for i in range(n):
    l.append(int(input()))
k = int(input())
f = True
for i in range(n - 1):
    for j in range(i, n):
        if l[j] - l[i] > k:
            f = False
if f:
    print('Yay!')
else:
    print(':(')


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


int main() {
    int N; cin >> N;
    map<int, int> M;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        M[x]++;
    }
    ll ans = 0;
    for(auto m : M){
        if(m.first != m.second) {
            if(m.first < m.second) ans += m.second - m.first;
            else ans += m.second;
        }
    }
    cout << ans << endl;




}

Measured memory_bytes: 4736
#include <stdio.h>
#include <string.h>
int main(void)
{
    char s[210000];
    scanf("%s",s);
    int n=(int)strlen(s);
    int A=0;
    int Z=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            A=i;
            break;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='Z'){
            Z=i;
            break;
        }
    }
    printf("%d\n",Z-A+1);
    return 0;
}


Measured memory_bytes: 384
import sys

coins = [500,100,50,10,5,1]

for i in sys.stdin:
    if int(i) == 0:
        break

    n =1000-int(i)
    cnt = 0

    while n != 0:
        for i in range(len(coins)):
            if n >= coins[i]:
                n = n-coins[i]
                break
        cnt += 1

    print(cnt)

Measured memory_bytes: 7600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
#include <map>
using namespace std;

class UnionFind{
    public:
        vector<int> Parent;
        UnionFind(int N){
            Parent = vector<int>(N, -1);
        }
        int root(int A){
            if(Parent[A]<0){
                return A;
            }
            return Parent[A]=root(Parent[A]);
        }
        int size(int A){
            return -Parent[root(A)];
        }
        bool connect(int A, int B){
            A = root(A);
            B = root(B);
            if(A==B){
                return false;
            }
            if(size(A) < size(B)){
                swap(A, B);
            }
            Parent[A]+=Parent[B];
            Parent[B]=A;
            return true;
        }
};

int main()
{
    int N, K, L;
    cin >> N >> K >> L;

    vector<pair<int, int> > pairs(N);//pair(parent, parent)

    UnionFind Uni_a(N);
    for(int i=0; i<K; i++){
        int p,q;
        cin >> p >> q;
        p--;
        q--;
        Uni_a.connect(p,q);
    }

    UnionFind Uni_b(N);
    for(int i=0; i<L; i++){
        int p,q;
        cin >> p >> q;
        p--;
        q--;
        Uni_b.connect(p,q);
    }
    
    for(int i=0; i<N; i++){
        pairs[i]=make_pair(Uni_a.root(i), Uni_b.root(i));
    }

    sort(pairs.begin(), pairs.end());
    for(int i=0; i<N; i++){
        pair<int, int> p=make_pair(Uni_a.root(i), Uni_b.root(i));
        int ans=distance(lower_bound(pairs.begin(), pairs.end(), p), upper_bound(pairs.begin(), pairs.end(), p));
        cout << ans << ' ';
    }
    cout << endl;
    
    return 0;
}


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


int main(){
    int n;cin >>n;
    int max_count = 0;
    int ans = 1;
    for(int i=0;i<n;i++){
        int count =0;
        int num = i+1;
        while(num%2==0){
            count++;
            num = num/2;
        }
        if(max_count < count){
            max_count = count;
            ans = i+1;
        }
    }

    printf("%d",ans);

}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((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 SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll a, b;

    cin >> a >> b;
	
  	ll ans = max(0LL, a - 2*b);
  
    cout << setprecision(20) << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) cin >> X[i];
  int res = 10000000;
  for (int i = 1; i <= 100; i++) {
    int tmp = 0;
    for (int j = 0; j < N; j++) {
      int effort = (i-X[j])*(i-X[j]);
      tmp += effort;
    }
    if (res > tmp) res = tmp;
  }
  cout << res;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())

lst = [[0] * (10) for _ in range(10)]

for i in range(1, N + 1):
    s = str(i)
    x = int(s[0])
    y = int(s[-1])
    lst[x][y] += 1

ans = 0
for i in range(1, N + 1):
    s = str(i)
    x = int(s[0])
    y = int(s[-1])
    ans += lst[y][x]

print (ans)
# for tmp in lst:
#     print (tmp)


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

const int M = 512;

int main(void){
    for(int w; cin >> w; cout << endl)
        for(int a = 1, c = 0; a <= M; a *= 2)
            if(a & w) cout << (c ? " ":"") << a, c = 1;

    return 0;
}

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

int main() {
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << k / 2 * k / 2 << "\n";
  } else {
    cout << k / 2 * (k / 2 + 1) << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>

#define div 1000000000+7

typedef long long ll;

using namespace std;


int main(){
    string s1, s2, s3;
    string result;
    cin >> s1 >> s2 >> s3;
    result.push_back(s1[0]);
    result.push_back(s2[0]);
    result.push_back(s3[0]);
    transform(result.begin(), result.end(), result.begin(), ::toupper);
    cout << result << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int x,y,s;
	while (cin >> x >> y >> s && x!=0){
		int maximum = 0;
		for (int i=1; i<s; i++){
			for (int j=1; j<s; j++){
				if ((i*(100+x))/100+(j*(100+x))/100==s && ((i*(100+y))/100+(j*(100+y))/100)>maximum){
					maximum=((i*(100+y))/100+(j*(100+y))/100);
				}
			}
		}
		cout << maximum << endl;
	}
}

Measured memory_bytes: 3052
#include <stdio.h>

long long int f(int n)
{
    if (n == 0) {
        return 1;
    }
    return n * f(n - 1);
}

int main(void)
{
    int n;
    
    scanf("%d", &n);
    printf("%lld\n", f(n));
    return 0;
}

Measured memory_bytes: 592
#include <float.h>
#include <iostream>
#include <string>
using namespace std;
int main() {
  string S;
  string T;
  cin >> S >> T;
  int ans;
  if (S[0] == T[0]) {
    ans += 1;
  }
  if (S[1] == T[1]) {
    ans += 1;
  }
  if (S[2] == T[2]) {
    ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
k=int(input())
l=[]


for _ in range(k):
  l.append(list(map(int, input().split())))
import itertools
for s in itertools.permutations(range(8)):
  t=[]
  for _ in range(8):
    t.append(([s[_], _]))
  for z in l:
    if not (z in t):
      break
  else:
    #print(t)
    for a in range(7):
      for b in range(a+1, 8): # 2つの点を探してのループ
        if abs(t[a][0]-t[b][0])==abs(t[a][1]-t[b][1]):
          break
      else:
        continue
      break
    else:
      tt=sorted(t)
      #print(sorted(t))
      for _ in range(8):
        if tt[_][1]==0:
          print("Q.......")
        else:
          print("."*tt[_][1]+"Q"+"."*(7-tt[_][1]))
    continue
    
  




Measured memory_bytes: 5644
n,k= map(int,input().split())
s = input()

l = [["",1]]
for c in s:
    if c!=l[-1][0]:
        l.append([c,1])
    else:
        l[-1][1]+=1
      
l.pop(0)
cnt0 = 0
dp = []
z = []
for i in range(len(l)):
    if l[i][0] == '0':
        cnt0 += 1
        z.append((i,l[i][1]))
#print(z)
if len(z)==0:
    print(n)
    exit(0)
for i in range(cnt0):
    idx,cnt = z[i]
    currcnt = 0
    if idx-1>=0:
        currcnt += l[idx-1][1]
    if i >0:
        currcnt += dp[-1][1]
    currcnt+=cnt
    dp.append((idx,currcnt))
#print(dp) 
res = 0

for i in range(len(dp)):
    tmp = 0
    if i-k>=0:
        tmp = dp[i][1]-dp[i-k][1]
    else:
        tmp = dp[i][1]
    if dp[i][0]+1<len(l):
        tmp += l[dp[i][0]+1][1]
    res = max(res,tmp)
print(res) 



Measured memory_bytes: 23752
#include <iostream>
#include <string>
using namespace std;
int main()
{
	
  string a,b;
  int ans=0;
  
  cin>>a>>b;
  
  for(int i=0;i<a.size();i++) if(a[i]!=b[i]) ans++;
  cout<<ans<<endl;
}
  


Measured memory_bytes: 3928
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;


struct Node{
    int key;
    Node *parent, *right, *left;
};

Node *root, *NIL;


void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x!=NIL){
        y = x;
        if(x->key > z->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;
    if(y==NIL) root = z;
    else {
        if(y->key > z->key) y->left = z;
        else y->right = z;
    }
}

void preorder(Node *u){
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void postorder(Node *u){
    if(u==NIL) return;
    postorder(u->right);
    postorder(u->left);
    printf(" %d", u->key);
}

Node *find_k(int k){
    Node *x = root;
    while(x!=NIL && x->key!=k){
        if(k < x->key) x = x->left;
        else if(k > x->key) x = x->right;
    }
    return x;
}

void findprint(Node *x){
    if(x==NIL) printf("no\n");
    else printf("yes\n");
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int k;
        string str;
        cin>>str;
        if(str=="insert"){
            scanf("%d", &k);
            insert(k);
        }
        else if(str=="find"){
            scanf("%d", &k);
            //cout<<endl;
            findprint(find_k(k));
        }
        else{
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    }
}




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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  long long n,a,b,ans;
  
  cin >> n >> a >> b;
  ans = a*(n/(a+b));
  n %= (a+b);
  ans += MIN(n,a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut ans = 0;
    for i in 1..(n + 1) {
        if i % 3 == 0 || i % 5 == 0 {
            continue;
        }
        ans += i;
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

//bool cmp(pair<ll,ll>a,pair<ll,ll>b){
//	return abs(a.ff+a.ss)<abs(b.ff+b.ss);
//}

int main()
{
    boost;
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
	boost;
	int n; cin>>n;
	vector<pair<ll,ll> >v(n);
	ll maxi1=-1e9,mini1=1e15;
	ll maxi2=-1e9,mini2=1e15;
	for1(0,n,1){ cin>>v[i].ff>>v[i].ss; 
		maxi1=max(maxi1,v[i].ff+v[i].ss);
		mini1=min(mini1,v[i].ff+v[i].ss);
		maxi2=max(maxi2,v[i].ff-v[i].ss);
		mini2=min(mini2,v[i].ff-v[i].ss);
	}
	ll ans=max(maxi1-mini1,maxi2-mini2);
	//sort(all(v),cmp);
	//ll ans=abs(v[n-1].ff+v[n-1].ss)-abs(v[0].ff+v[0].ss);
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 6368
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  char c[6];
  for(int i=0; i<6;i++){
    c[i] = s[i];
  }
  if(c[2]==c[3] && c[4]==c[5]){
    cout << "Yes";
  }else{
    cout << "No";
  }
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
    ll n,k,ans=0;
    cin>>n>>k;
    vector <ll> has(n+5,0);
    while(k--)
    {
        ll p,q;
        cin>>p;
        for(ll i=0;i<p;i++)
        {
            cin>>q;
            has[q]++;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        if(has[i]==0)
        ans++;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  a -= 1;
  ll lcm = (c * d) / gcd(c, d);
  ll bc = b / c;
  ll bd = b / d;
  ll blcm = b / lcm;
  ll ans = b - (bc + bd - blcm);

  ll ac = a / c;
  ll ad = a / d;
  ll alcm = a / lcm;
  ans -= (a - (ac + ad - alcm));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/agc008/tasks/agc008_a
#include <bits/stdc++.h>
using namespace std;

int f(int x, int y) {
    if(x<=y) return y-x;
    else return 2+x-y;
}
int main() {
    int x,y;cin>>x>>y;
    int ans = f(x,y);
    ans = min(ans, f(-x,y)+1);
    ans = min(ans, f(x,-y)+1);
    ans = min(ans, f(-x,-y)+2);
    cout<<ans<<"\n";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int h,w,m;
int a,b;
int x[300010],y[300010];
map<pair<int,int> ,bool> inv;
vector<int> v;
vector<int> t;
int main(){
	cin>>h>>w>>m;
	int mx=0,mx2=0;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		x[a]++;
		y[b]++;
		mx=max(mx,x[a]);
		mx2=max(mx2,y[b]);
		inv[make_pair(a,b)]=1;
	}
	for(int i=1;i<=h;i++){
		if(x[i]==mx){
			v.push_back(i);
		}
	}
	for(int i=1;i<=w;i++){
		if(y[i]==mx2){
			t.push_back(i);
		}
	}
	for(int i=0;i<v.size();i++){
		for(int j=0;j<t.size();j++){
			if(!inv[make_pair(v[i],t[j])]){
				cout<<mx+mx2<<endl;
				return 0;
			}
		}
	}
	cout<<mx+mx2-1<<endl;
	return 0;
}

Measured memory_bytes: 28516
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long a[51][51];

int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld %ld", &h, &w);
    
    long i, j;
    for(i=0; i<h; i++) {
        char str[51]={0};
        scanf("%s", str);
        for(j=0; j<w; j++) {
            a[i][j]=(str[j]=='#'? 1: 0);
        }
    }

    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            if(a[i][j]) {
                if((i>0 && a[i-1][j]) || (i<h-1 && a[i+1][j]) || (j>0 && a[i][j-1]) || (j<w-1 && a[i][j+1])) {
                    ;
                }
                else {
                    printf("No\n");
                    return 0;
                }
            }
        }
    }

    printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for(ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<typename S, typename T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<typename S, typename T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T> bool print_(const T& a) {
    cout << a;
    return true;
}
template <typename T> bool print_(const vector<T> &vec) {
    for(auto &a : vec) {
        cout << a;
        if(&a != &vec.back()) cout << " ";
    }
    return false;
}
template <typename T> bool print_(const vector<vector<T>>& vv) {
    for(auto &v : vv) {
        for(auto &a : v) {
            cout << a;
            if(&a != &v.back()) cout << " ";
        }
        if(&v != &vv.back()) cout << "\n";
    }
    return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail> 
void print(Head &&head, Tail &&... tail) {
    bool f = print_(head);
    if(sizeof...(tail) != 0) cout << (f ? " " : "\n");
    print(forward<Tail>(tail)...);
}
#pragma endregion

// {10, 3, 1, -5, 1} -> {3, 2, 1, 0, 1}
template<typename T>
vector<T> CoordinateCompression(const vector<T> &x){
    int n = x.size();
    vector<T> y = x, ret(n);
    sort(y.begin(), y.end());
    y.erase(unique(y.begin(), y.end()), y.end());
    for(int i = 0; i < n; i++) {
        ret[i] = lower_bound(y.begin(), y.end(), x[i]) - y.begin();
    }
    return ret;
}
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    a = CoordinateCompression(a);
    ll ans = 0;
    for(int i = 0; i < n; i += 2){
        if(a[i]%2!=0) ans++;
    }
    print(ans);
}


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

using namespace std;

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

int main() {
    int n, t, i, cnt = 0, minValue = 1999999999;
    long long sum = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> t;
        cnt += t < 0;
        minValue = min(minValue, abs(t));
        sum = sum + abs(t);
    }
    if (cnt % 2 == 0) {
        cout << sum;
    }
    else {
        cout << sum - (2 * minValue);
    }

    return 0;
}

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

int main() {
  
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else if(s == "Rainy") cout << "Sunny" << endl;
  //Sunny, Cloudy, Rainy
}

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

int main() {
  string s;
  cin >> s;
  map<string, int> dict;
  dict["SUN"] = 7;
  dict["MON"] = 6;
  dict["TUE"] = 5;
  dict["WED"] = 4;
  dict["THU"] = 3;
  dict["FRI"] = 2;
  dict["SAT"] = 1;
  cout << dict[s] << endl;
}


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

int keta(long long n)
{
	for(int i = 0; ;){
		i += 1;
		if(n < 10) return i;
		n /= 10;
	}
}

int main()
{
	long long n;
	int min = INT_MAX;
	cin >> n;
	for(long long i = 1; n/i >= i; i++){
		if(n % i == 0){
			int k = keta(n/i);
			min = (min > k ? k : min);
			if(keta(i) == k) break;
		}
	}
	cout << min << endl;
	return 0;
}


Measured memory_bytes: 256