akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
from collections import defaultdict, deque, Counter
import sys
from bisect import bisect_left
import heapq
import math

sys.setrecursionlimit(1000000000)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]

l.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        t = l[i] + l[j]
        idx = bisect_left(l,t)
        ans += max(0,idx-j-1)

print(ans)


Measured memory_bytes: 3564
import itertools
import math

(n, d) = map(int, input().split())
l = [0] * n
for i in range(n):
    l[i] = list(map(int, input().split()))

ans = 0
for (i, j) in itertools.combinations(range(n), 2):
    leng = 0
    for k in range(d):
        leng += (l[i][k] - l[j][k]) ** 2
    if math.sqrt(leng) % 1 == 0:
        ans += 1
print(ans)


Measured memory_bytes: 3064
N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for j in range(M)]

G = [[] for i in range(N)]
for i in range(M):
    a, b = ab[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

def rec(v, memo):
    if memo.count(-1) == 1:
        return 1

    memo[v] = 1

    count = 0
    for next_v in G[v]:
        if memo[next_v] == -1:
            count += rec(next_v, memo)

    memo[v] = -1
    return count

memo = [-1 for i in range(N)]
print(rec(0, memo))

Measured memory_bytes: 3064
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = [0] * (N+1)
now = 1
p = []
f = False

for i in range(K):
    if L[now] == 1:
        f = True
        break
    p.append(now)
    L[now] = 1
    now = A[now-1]

if f:
    for i in range(len(p)):
        if p[i] == now:
            ans = p[i + (K - i) % len(p[i:])]
            break
else:
    ans = now

print(ans)

Measured memory_bytes: 32228
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B;
    cin>>A>>B;

    cout<<max({A+B,A-B,A*B});

}


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

string check(string str) {
  string str2;
  if('A'<=str[0] && str[0] <='Z') {
    str2 +=  str[0] +32;
    for(int i=1;i<str.size();i++) {
      if('A' <=str[i] && str[i] <= 'Z') {
	str2 += '_';
	str2 += str[i] + 32;
      }
      else str2  += str[i];
    }
    return str2;
  }

  
  for(int i=0;i<str.size();i++)
    if(str[i] == '_') return str;

  for(int i=0;i<str.size();i++) {
    if('A'<=str[i] && str[i] <='Z') {
      str2 += '_';
      str2 += str[i] + 32;
    }
    else str2 += str[i];
  }

  return str2;

}

int main() {

  while(1) {
    string str;
    cin >> str;
    string ch;
    cin >> ch;
    if(ch == "X") break;
    
    str= check(str);
    //    cout << str << endl;

    if(ch == "D") cout << str << endl;
    
else if(ch == "L") {
      cout << str[0];
      for(int i=1;i<str.size();i++) {
	if(str[i] == '_') {
	  i++;
	  str[i] -= 32;
	  cout << str[i];
	}
	else cout << str[i];
      }
      cout << endl;
    }
    else if(ch == "U"){
      str[0] -= 32;
      cout << str[0];
      for(int i=1;i<str.size();i++) {
	if(str[i] == '_') {
	  i++;
	  str[i] -= 32;
	  cout << str[i];
	}
	else {
	  cout << str[i];
	}
      }
      cout << endl;
    }

  }

  return 0;
}

Measured memory_bytes: 1196
# sys.stdin.readline()
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l=list(map(int,input().split()))
    l2 = [(1+i)/2 for i in l]
    kitai=sum(l2[0:k])
    tmp = kitai
    for idx in range(n)[:n - k]:
        tmp -= l2[idx]
        tmp += l2[idx+k]
        if (kitai < tmp):
           kitai = tmp
    print(kitai)
main()

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

uint_fast64_t N, t, a, b;

int main(){
    scanf("%llu", &N);
    t = (static_cast<uint_fast64_t>(sqrt(8 * N + 1) + 0.0001) - 1) / 2;
    if(N != t * (t + 1) / 2)return 0 & puts("No");
    puts("Yes");
    vector<vector<uint_fast64_t>> tap(t + 1);
    for(size_t i = 0; i < N; ++i){
        tap[a].push_back(i + 1);
        tap[a + b + 1].push_back(i + 1);
        ++a;
        if(a + b + 1 > t){
            a = 0;
            ++b;
        }
    }
    cout << t + 1;
    for(auto i : tap){
        cout << endl << t;
        for(auto j : i){
            cout << " " << j;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3200
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i;
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<vector<int>> adj;
vector<int> d;
bool loop = false;

void dfs(int n=0, int p=-1) {
  for (auto x: adj[n]) {
    if (x==p) continue;
    if (d[x]==d[n]) loop = true;
    if (d[x]==-1) {
      d[x] = !d[n];
      dfs(x,n);
    }
  }
}

int main() {
  ll N, M; cin >> N >> M;
  adj.resize(N); d.resize(N,-1); d[0] = 0;
  rep(i,M) {
    int A, B; cin >> A >> B; A--; B--;
    adj[A].push_back(B);
    adj[B].push_back(A);
  }
  dfs();

  ll result = 0;
  if (loop) result = N*(N-1)/2 - M;
  else {
    ll odd = 0, even = 0;
    rep(i,N) {
      if (d[i]%2) odd++;
      else even++;
    }
    result = odd*even - M;
  }
  // debug(d.begin(),d.end());
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6656
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    map<int,int>mmp;
    bool pd=0;
    for(int i=0;i<n;i++){
        int v=vec[i];
        for(int j=2;j*j<=v;j++){
            int gun=0;
            while(v%j==0) {
                gun++;
                v/=j;
            }
            if(gun){
                if(mmp[j]){
                    pd=1;
                }
                else mmp[j]=1;
            }

        }
        if(v>1){
            if(mmp[v]){
                pd=1;
            }
            else mmp[v]=1;
        }
    }
    if(!pd){
        cout << "pairwise coprime\n";
    }
    else{
        int gc=vec[0];
        for(int i=1;i<n;i++){
            gc=gcd(gc,vec[i]);
        }
        if(gc==1){
            cout << "setwise coprime\n";
        }
        else{
            cout << "not coprime\n";
        }
    }

    return 0;
}
///Alhamdulillah


Measured memory_bytes: 15724
#include <bits/stdc++.h>
//			#include <ext/pb_ds/assoc_container.hpp>
//			#include <ext/pb_ds/tree_policy.hpp>

			using ll = long long;
			using ld = long double;
			#define rep(i, a, n) for(ll i = (a); i < (n); i++)
			#define per(i, a, n) for(ll i = (n-1); i >= (a); i--)
			#define F first
			#define S second
			#define endl "\n"
			#define all(x) begin(x),end(x)
			#define maxx(a, b) a = max(a, b)
			#define minn(a, b) a = min(a, b)
			#define db(x) cerr<<#x<<" = "<<x<<endl
			#define N 1111111
			#define mod 1000000007
			#define rt return
			#define inf 1234567891123456789ll

			using namespace std;
//			random_device rd;
//			mt19937 mt(rd());
//			using namespace __gnu_pbds;
//
//			typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

			#define error(args...){string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

			void err(istream_iterator<string> it) {}
			template<typename T, typename... Args>
			void err(istream_iterator<string> it, T a, Args... args)
			{
				cerr<<*it<<" = "<<a<<endl;
				err(++it, args...);
			}

			ll modlaber(ll a, ll m = mod)
			{
				rt ((a+m)%m+m)%m;
			}

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

				int x,n; cin>>x>>n;
				set<int> s;
				rep(i,0,n)
				{
					int j; cin>>j;
					s.emplace(j);
				}
				int ans = 10000;
				rep(i,-10000,10000)
					if(!s.count(i) && abs(x-i) < abs(ans-x))
						ans = i;

				cout<<ans;

				rt 0;
			}





















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

int main(){
    string s;
    cin >> s;
    int n = 0;
    for(int i=0; i< 4; ++i){
        if(s[i] == '+'){
            n ++;
        }
        if(s[i] == '-'){
            n --;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int a[5]; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int ans = 0, sub = 10;
	rep(i, 0, 5)sub = min(sub, (a[i]-1) % 10);
	sub++;
	bool flag = true;
	rep(i, 0, 5) {
		if (sub == a[i] % 10&&(flag)) {
			ans += a[i]; flag = false;
		}
		else ans += ((a[i] + 9) / 10) * 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(XXX) XXX
#else
#define DEBUG_CAT
#endif
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
int rint();char rch();long long rlong();
vector<int> a,b;
const int mn=50;
ll dd[mn+1][mn+1];
void fail() {
  printf("-1\n"); exit(0);
}
bool go(ll moves) {
  int n=a.size();
  for (int i=0;i<n;i++) {
    ll z=1LL<<a[i];
    for (int d=mn;d>=1;d--) {
      if (moves&(1LL<<d)) {
        for (int x=mn;x>=0;x--) {
          if (z&(1LL<<x)) {
            z|=dd[x][d];
          }
        }
      }
    }
    if (0==(z&(1LL<<b[i]))) return false;
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  for (int x=0;x<=mn;x++) {
    for (int y=1;y<=mn;y++) dd[x][y]=1LL<<(x%y);
  }
  int n; cin>>n; a.resize(n); b.resize(n);
  for (int i=0;i<n;i++) cin>>a[i];
  for (int i=0;i<n;i++) cin>>b[i];
  ll moves=(1LL<<(mn+1))-2;
  if (!go(moves)) fail();
  for (int x=mn;x>=1;x--) {
    ll good=moves^(1LL<<x);
    if (go(good)) moves=good;
  }
  printf("%lld\n",moves);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
#define pb push_back
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	ll sum;
	sum=a+b+c;
	ll val;
	val=max(a,max(b,c));
	sum-=val;
	for(int i=1;i<=k;i++)
		val*=2;
	sum+=val;
	cout<<sum;
	return 0;
}

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

int N, H;
struct Jigsaw {
    int a, b, c, d;
};
vector<Jigsaw> jig;
vector<vector<int> > adj;
vector<vector<int> > adj2;
vector<int> ind, outd;

int mn, mx;
vector<int> vis;

void dfs(int u) {
    vis[u] = 1;
    mn = min(mn, ind[u] - outd[u]);
    mx = max(mx, ind[u] - outd[u]);
    for(int i = 0; i < adj2[u].size(); i++) {
        int v = adj2[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}

int main() {
    scanf("%d %d", &N, &H);

    jig.resize(N);

    for(int i = 0; i < N; i++) {
        scanf("%d %d %d %d", &jig[i].a, &jig[i].b, &jig[i].c, &jig[i].d);
    }

    adj.resize(2*H + 1);
    adj2.resize(2*H + 1);

    for(int i = 0; i < N; i++) {
        adj[ (jig[i].c? jig[i].c : H + jig[i].a) ].push_back( (jig[i].d? H + jig[i].d : jig[i].b) );

        adj2[ (jig[i].c? jig[i].c : H + jig[i].a) ].push_back( (jig[i].d? H + jig[i].d : jig[i].b) );
        adj2[ (jig[i].d? H + jig[i].d : jig[i].b) ].push_back( (jig[i].c? jig[i].c : H + jig[i].a) );
    }

    ind = vector<int>(2*H + 1, 0);
    outd = vector<int>(2*H + 1, 0);

    for(int i = 0; i < 2*H + 1; i++) {
        for(int j = 0; j < adj[i].size(); j++) {
            int k = adj[i][j];

            outd[i]++;
            ind[k]++;
        }
    }

    for(int i = 0; i < H; i++) {
        if(ind[i] < outd[i]) {
            printf("NO");
            return 0;
        }
    }
    for(int i = H + 1; i <= 2*H; i++) {
        if(ind[i] > outd[i]) {
            printf("NO");
            return 0;
        }
    }

    vis = vector<int>(2*H + 1, 0);
    for(int i = 0; i < 2*H + 1; i++) if(!vis[i] && adj[i].size()) {
        mn = mx = 0;
        dfs(i);
        if(mn == 0 && mx == 0) {
            printf("NO");
            return 0;
        }
    }

    printf("YES");
}


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

using namespace std;

int main(){
	// coin probabability
	int n;
	cin >> n;
	cout << fixed;
	cout << setprecision(10);
	vector<double> a(n);

	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	vector<vector<double>> dp (n+1, (vector<double> (n+1, 0.0)));
	dp[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(j ==0 )
				dp[i][j] = dp[i-1][j]*(1-a[i-1]);
			else
				dp[i][j] = dp[i-1][j]*(1-a[i-1]) + dp[i-1][j-1]*(a[i-1]);
		}
	}
	double ans = 0.0;
	for(int i=n;i>(n/2);i--)
		ans += dp[n][i];
	cout << ans << endl;
	return 0;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

bool reversecompare(int a, int b)
{
  return a > b;
}

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

  int N, A;

  cin >> N >> A;

  if (N%500 > A) cout << "No";
  else cout << "Yes";
  cout << endl;

  return 0;
}

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

int main(void) {
    int N;
    cin >> N;
    ll A[N];
    ll res=0;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N-1; i++) {
        for(int j=i; j<N; j++) {
            res = max(res,abs(A[i] - A[j]));
        }
    }
    cout << res << endl;
    return 0;
}


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

const int MAX_N=100000;
int n,a[MAX_N]={};

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	long long int sum=1,t=0;
	sort(a,a+n);
	for(int i=0;i<n-1;i++){
		if(a[(n-1)-i]==a[(n-1)-(i+1)]){
			sum*=a[(n-1)-i];
			i++;
			t++;
		}
		if(t==2) break;
	}
	cout << (t==2?sum:0) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

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

int main(){
  int n;
  cin >>n;
  ll ans = 1;
  rep(i,n){
    ll x;
    cin >>x;
    ans = ans/gcd(ans,x)*x;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string L;
	cin >> L;

	vector<vector<lint>> dp(L.size() + 1, vector<lint>(2));
	dp[0][0] = 1;

	for (int i = 0; i < L.size(); i++) {
		if (L[i] == '0') {
			dp[i + 1][0] += dp[i][0];
			dp[i + 1][1] += dp[i][1] * 3 % MOD;
		}
		else {
			dp[i + 1][0] += dp[i][0] * 2 % MOD;
			dp[i + 1][1] += (dp[i][0] + dp[i][1] * 3) % MOD; 
		}
	}

	cout << (dp[L.size()][0] + dp[L.size()][1]) % MOD << "\n";

	return 0;
}

Measured memory_bytes: 5840
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int inp, sum = 0, x = 0;
	REP(i ,5){
		cin >> inp;
		if(inp % 10 == 0) sum += inp;
		else {
			sum += (inp/10 + 1)*10;
			x = max(x, (inp/10 + 1)*10 - inp);
		}
	}
	cout << sum - x << endl;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    rbl,gbl,bbl,n = LI()
    rmx = n//rbl
    ans = 0
    
    for r in range(rmx+1):
        gmx = (n-rbl*r)//gbl
        for g in range(gmx+1):
            reminder = n - (rbl*r+gbl*g)
            if reminder%bbl == 0:
                ans += 1
    
    print(ans)
main()            


Measured memory_bytes: 86492
// AOJ本を参考に(ほとんどコピー)
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    stack<int> S1;
    stack< pair<int , int> > S2;
    char ch;
    int sum = 0;
    for(int i = 0; cin >> ch; i++){
        if(ch == '\\'){
            S1.push(i);
        }else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop(); // \の位置
            sum += i-j;
            int a = i-j; // 今入力された/から対応する\までの距離＝面積
            
            // 今新しくできた水たまりが過去の水たまりを包含している場合、以下のwhileループで再計算する
            while(S2.size() > 0 && S2.top().first > j){
                a += S2.top().second; 
                S2.pop(); // 包含された水たまりの面積を今の水たまりに加え、スタックS2から削除
            }
            S2.push(make_pair(j,a));
        }
    }

    vector<int> ans;
    while(S2.size() > 0){
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3164
from math import factorial
from itertools import permutations

def eratosthenes(n):
 is_p=[1]*n
 p_list=[]

 is_p[0]=0
 is_p[1]=0

 for i in range(2,n):
  if is_p[i]:
   p_list.append(i)
   for j in range(i*i,n,i):
    is_p[j] = 0

 return is_p, p_list

n=int(input())
np=factorial(n)

lim=10**2+1
is_p, p_list=eratosthenes(lim)

ans=[]
for s,t,u in permutations(p_list,3):
  num1=(s**4)*(t**4)*(u**2)
  num2=(s**14)*(t**4)
  num3=(s**24)*(t**2)
  num4=s**74
  for z in [num1,num2,num3,num4]:
    if np%z==0:
      ans.append(z)

print(len(set(ans)))

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> result(N);
    for (int road=0; road < M; road++) {
        int X = 0, Y = 0;
        cin >> X >> Y;
        result[X-1] += 1;
        result[Y-1] += 1;
    }
    for (int each=0; each < N; each++) {
        cout << result[each] << endl;
    }
}

Measured memory_bytes: 3632
// #define DEBUG

#include <bits/stdc++.h>
#define x first
#define y second
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define out(t, a) copy(all(a), ostream_iterator<t>(cout, " ")); cout << "\n";
#define int long long

using namespace std;

void set_program() {
	#ifdef DEBUG
		freopen ("test.in", "r", stdin);
		freopen ("test.out", "w", stdout);
		// freopen ("test.in", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pt;

const int ALF = 26;
const int LOGN = 20;
const int MOD = 998244353;
const int INF = 1e9;
const int MAXN = 1e5;

void solve() {
	int n;
	cin >> n;
	cout << n / 500 * 1000 + (n % 500) / 5 * 5 << "\n";
}

signed main() {
	set_program();
	int t;
	#ifdef DEBUG
		// cin >> t;
		t = 1;
	#else
		// cin >> t;
		t = 1;
	#endif
	for (int num_test = 1; num_test <= t; ++num_test) {
		solve();
		cout << "\n";
	}
 	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
ll p[100];
void po()
{
    ll i,j;
    p[0]=1;
    for(i=1;i<=34;i++)
    {
        p[i]=p[i-1]*2;
        //dbgg(p[i]);
    }
}
int main()
{
    ll a,b=0,c=0,d,e,f,g,i,j;
    cin>>a;
    po();
    map<ll,ll>mp,np;
    for(i=0;i<a;i++){cin>>arr[i];mp[arr[i]]++;np[arr[i]]++;}
    sort(arr,arr+a);
    for(i=0;i<a;i++)
    {
        if(mp[arr[i]]==0)continue;
        mp[arr[i]]--;
        for(j=0;j<34;j++)
        {
            d=p[j]-arr[i];
            //if(arr[i]==3)dbgg(d);
            if(d>0&&mp[d]>0)
            {
                mp[d]--;
                b++;
                break;
            }

        }
    }
    for(i=a-1;i>=0;i--)
    {
        if(np[arr[i]]==0)continue;
        np[arr[i]]--;
        for(j=0;j<34;j++)
        {
            d=p[j]-arr[i];
            if(d>0&&np[d]>0)
            {
                np[d]--;
                c++;
                break;
            }

        }
    }
    cout<<max(b,c)<<endl;
    return 0;
}



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

int main()
{
  LL n,D;
  LL sum=0;
  cin >> D >> n;

  for(LL i=0,d=0;d <= n;i+=pow(100,D),d++){
    sum = i;
  }
  if(D == 0 && n == 100){
    cout << 101 << endl;
  }
  else if(D == 1 && n == 100){
    cout << 10100 << endl;
  }
  else if(D == 2 && n == 100){
    cout << 1010000 << endl;
  }
  else cout << sum << endl;
  return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String line;
		double max=0,min=0;
		double mountain;
		boolean first = false;
		
		while(true){
			line = br.readLine();
			if(line == null || line.isEmpty()){
				break;
			}
			mountain = Double.parseDouble(line);
			if(first){
				if(max < mountain){
					max = mountain;
				}
				if(min > mountain){
					min = mountain;
				}
			}else{
				max = mountain;
				min = mountain;
				first = true;
			}
		}
		
		mountain = Math.ceil((max - min)*10)/10;
		System.out.println(mountain);
	}
}

Measured memory_bytes: 16920
lmax = [0]
lmin = [0]
tmin = 0
tmax = 0
for i in range(0,40):
    if i % 2 == 1:
        tmin -= 2**i
    else:
        tmax += 2**i
    lmax.append(tmax)
    lmin.append(tmin)

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

    print(int(base(n,35)))

def base(n,a):
    if a == 0:
        if n == 1:
            return '1'
        else:
            return "0"
    if n >lmax[a] or n <lmin[a]:
        return '1'+base(n-(-2)**a,a-1)
    else:
        return '0'+base(n,a-1)

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s;
  ll ans=0,c=0;
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')c++;
    else c=0;
    ans=max(ans,c);
  }
  printf("%lld",ans);
}

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

int main()
{
  i64 n;
  string s;
  cin >> n >> s;
  vector<i64> l(n + 1), r(n + 1);
  for (i64 i = 0; i < n; i++)
    l[i + 1] = (l[i] | (1 << (s[i] - '0')));
  for (i64 i = n; 0 < i; i--)
    r[i - 1] = (r[i] | (1 << (s[i - 1] - '0')));
  set<i64> cnt[10];
  for (i64 i = 0; i < n; i++)
  {
    for (i64 j = 0; j < 10; j++)
      if (l[i] & (1 << j))
        for (i64 k = 0; k < 10; k++)
          if (r[i + 1] & (1 << k))
            cnt[s[i] - '0'].insert(j * 10 + k);
  }
  i64 ans = 0;
  for (i64 i = 0; i < 10; i++)
    ans += cnt[i].size();
  cout << ans << endl;
  return 0;
}


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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=2e3+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;

int n,m;
string a[N];

int Left[N][N],Right[N][N],up[N][N],down[N][N];
int main()
{	
	
 	
 	cin>>n>>m;

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

 	

 	for(int i=0;i<n;i++){
 		int lefft=0;
 		for(int j=0;j<m;j++){
 			if(a[i][j]=='#')lefft=0;
 			else Left[i][j]=lefft++;
 		}
 	}

 	for(int j=0;j<m;j++){
 		int upp=0;
 		for(int i=0;i<n;i++){
 			if(a[i][j]=='#')upp=0;
 			else up[i][j]=upp++;
 		}
 	}



 	for(int j=0;j<m;j++){
 		int dowwn=0;
 		for(int i=n-1;i>=0;i--){
 			if(a[i][j]=='#')dowwn=0;
 			else down[i][j]=dowwn++;
 		}
 	}



 	for(int i=n-1;i>=0;i--){
 		int Rightt=0;
 		for(int j=m-1;j>=0;j--){
 			if(a[i][j]=='#')Rightt=0;
 			else Right[i][j]=Rightt++;
 		}
 	}

 	int ans = 0;

 	for(int i=0;i<n;i++){
 		for(int j=0;j<m;j++){
 			if(a[i][j]!='#'){
 				ans = max(ans,up[i][j]+down[i][j]+Left[i][j]+Right[i][j]+1);
 			}
 		}
 	}


 	cout<<ans<<"\n";


}

Measured memory_bytes: 67072
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	ll a, b;
	cin >> a >> b;
	ll ans;
	ans = a + b;
	chmax(ans, a - b);
	chmax(ans, a * b);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	int k, s;
	cin >> k >> s;
	int x, y, z, n;
	for (x = 0; x <= k; x++) {
		for (y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z >= 0 && z <= k)n++;
			}
		}
	cout << n;
}


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

////////////////////
// Ford-Fulkerson //
////////////////////

class MaxFlow {
private:
	using vi64 = std::vector<int64_t>;
	using Matrix = std::vector<vi64>;

	std::vector<bool> visited_;
	Matrix graph_;
	const int source_, sink_;

	int64_t findPath(const int node_i, const int64_t flow)
	{
		if (node_i == sink_) return flow;
		visited_[node_i] = true;
		for (int next_i{}; next_i < (int)graph_.size(); next_i++)
		{
			if (!graph_[node_i][next_i] || visited_[next_i]) continue;
			const int64_t additional_flow{findPath(next_i, std::min(flow, graph_[node_i][next_i]))};
			if (!additional_flow) continue;

			graph_[node_i][next_i] -= additional_flow;
			graph_[next_i][node_i] += additional_flow;
			return additional_flow;
		}
		return 0;
	}
public:
	MaxFlow(const int node_num, const int source, const int sink)
		: graph_(node_num, vi64(node_num)), visited_(node_num), source_(source), sink_(sink){}
	void addEdge(const int from, const int to, const int64_t flow)
	{
		graph_[from][to] += flow;
	}
	int64_t operator()()
	{
		int64_t flow_sum{};
		while (true)
		{
			std::fill(visited_.begin(),visited_.end(), false);
			int64_t additional_flow{findPath(source_, LLONG_MAX)};
			if (!additional_flow) break;
			flow_sum += additional_flow;
		}
		return flow_sum;
	}
};

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> a(N + 1);
	int64_t ans{};
	for (int i{1}; i <= N; i++)
	{
		scanf("%lld", &a[i]);
		if (a[i] >= 0)
			ans += a[i];
	}
	std::vector<int64_t> lossTable(N + 1);
	MaxFlow maxFlow(N + 2, 0, N + 1);
	for (int i{N}; i > 0; i--)
	{
		for (int j{2 * i}; j <= N; j += i)
			maxFlow.addEdge(j, i, 1ll << 50);
		if (a[i] >= 0)
		{
			maxFlow.addEdge(0, i, a[i]);
			maxFlow.addEdge(i, N + 1, 0);
		}
		else
		{
			maxFlow.addEdge(0, i, 0);
			maxFlow.addEdge(i, N + 1, -a[i]);
		}
	}
	ans -= maxFlow();
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 384
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

def solve(i):
    global N, C, K, T
    left = C - 1
    if i == N - 1:
        return i
    if left == 0:
        return i
    for j in range(i + 1, N):
        # print(T[i], i, j)
        if T[i] + K < T[j]:
            return j - 1
        else:
            left -= 1
        if left == 0 or j == N - 1:
            return j

buses = 0
start = -1
for i in range(N):
    if start < i:
        start = solve(i)
        buses += 1

print(buses)

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

signed main(void)
{
	int n; cin >> n;
	int ctr_l, ctr_r;
	vector<int> d(n);

	rep(i, n) cin >> d[i];
	sort(d.begin(), d.end());
	ctr_l = d.at(d.size() / 2 - 1); 
	ctr_r = d.at(d.size() / 2);
	cout << ctr_r -  ctr_l << endl;
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<string>
#include<memory>
#include<cmath>
#include<algorithm>
#include<vector>
double min_double(double a,double  b){
    if(a<b) return a;
    else return b;
}
void swap(int *x,int *y){
    int tmp;
    tmp=*x;
    *x=*y;  
    *y=tmp;
}
int gcd(int a,int b){
    if(a<b) swap(&a,&b);
    if(b<1) return -1;

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

int main(){
    int N;
    std::cin>>N;
    std::vector<long> height(N);
    long max=0;
    for(int i=0;i<N;i++) {
        std::cin>>height[i];
        if(max-height[i]>1){
            std::cout<<"No"<<std::endl;
            return 0;
        }
        if(height[i]>max) max=height[i];
    }
/*
    if(N==1){
        std::cout<<"Yes"<<std::endl;
        return 0;
    }
    
    for(int i=0;i<N;i++){
        if(height[i+1]<height[i]){
            if(height[i]-height[i+1]==1)height[i]--;
            else{
                //std::cout<<i<<std::endl;
                std::cout<<"No"<<std::endl;
                return 0;
            }
        }
    }
    */
    std::cout<<"Yes"<<std::endl;

    return 0;
}



Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string b;
  cin>>b;
  int leng=0;
  int cnt=0;
  for(int i=0;i<b.size();i++){
   if(b.at(i)=='A'||b.at(i)=='T'||b.at(i)=='C'||b.at(i)=='G'){
     cnt++;
   }else if(leng<cnt){
     leng=cnt;
     cnt=0;
   }
  }
  if(cnt!=0&&leng<cnt)
    leng=cnt;
  cout<<leng<<endl;
}

Measured memory_bytes: 256
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def is_palindrome(s):
    l = 0
    r = len(s) - 1

    while l < r:
        if s[l] != s[r]:
            return False
        l += 1
        r -= 1

    return True

def main():
    s = input()
    n = len(s)
    print(('No', 'Yes')[(is_palindrome(s) and is_palindrome(s[:n//2]) and is_palindrome(s[n//2+1:]))])

main()


Measured memory_bytes: 38256
#include<stdio.h>
int main(){
  int n,i,a,c[100]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a<400)c[0]=1;
    else if(a<800)c[1]=1;
    else if(a<1200)c[2]=1;
    else if(a<1600)c[3]=1;
    else if(a<2000)c[4]=1;
    else if(a<2400)c[5]=1;
    else if(a<2800)c[6]=1;
    else if(a<3200)c[7]=1;
    else c[8]++;
  }
  int ans=0;
  for(i=0;i<8;i++){
    ans+=c[i];
  }
  int min=ans==0?1:ans;
  ans+=c[8];
  printf("%d %d\n",min,ans);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
  int H,W,m,hmax=0,wmax=0;
  
  scanf("%d %d %d",&H,&W,&m);
  
  int hbomb[H+1],h[m+1],wbomb[W+1],w[m+1];
  
  for(int i=1;i<=H;i++){
    hbomb[i]=0;
  }
  
  for(int i=1;i<=W;i++){
    wbomb[i]=0;
  }
  
  for(int i=1;i<=m;i++){
    scanf("%d %d",&h[i],&w[i]);
    hbomb[h[i]]+=1;
    wbomb[w[i]]+=1;
  }
  
  for(int i=1;i<=H;i++){
    if(hmax<hbomb[i]){
      hmax=hbomb[i];
    }
  }
  
  for(int i=1;i<=W;i++){
    if(wmax<wbomb[i]){
      wmax=wbomb[i];
    }
  }
  
  int hbox[H+1],wbox[W+1];
  int hcount=0,wcount=0,count=0;
  
  for(int i=1;i<=H;i++){
    if(hbomb[i]==hmax){
      hbox[i]=1;
      hcount+=1;
    }
    else{hbox[i]=0;}
  }
  
  for(int i=1;i<=W;i++){
    if(wbomb[i]==wmax){
      wbox[i]=1;
      wcount+=1;
    }
    else{
      wbox[i]=0;
    }
  }
  
  for(int i=1;i<=m;i++){
    if(hbox[h[i]]==1 && wbox[w[i]]==1){
      count+=1;
    }
  }
  
  if(count==hcount*wcount){
    printf("%d",hmax+wmax-1);
    return 0;
  }
  else{
    printf("%d",hmax+wmax);
    return 0;
  }
}

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


int main(void){
	int n;
	scanf("%d", &n);
	int in;
	double ans = 0;
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		ans += 1.0 / in;
	}
	printf("%lf\n", 1.0 / ans);
	return 0;
}


Measured memory_bytes: 2176
H, W = map(int, input().split())

INPUT = [list(input()) for i in range(H)]
OUTPUT = INPUT.copy()

for i in range(H):
    for j in range(W):
        if INPUT[i][j] == '#':
            OUTPUT[i][j] = '#'
            continue
        else:
            OUTPUT[i][j] = 0
            for I in (i-1, i, i+1):
                if (I < 0 or H <= I):
                    continue
                for J in (j-1, j, j+1):
                    if (J < 0 or W <= J):
                        continue
                    if INPUT[I][J] == '#':
                        OUTPUT[i][j] += 1


for i in range(H):
    print(''.join(map(str, OUTPUT[i])))


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0044
{
    public class Program

    {
        public static void Main(string[] args)
        {

            List<int> primes = new List<int>(25000);
            for (int i = 2 ; i <= 50100 ; i++) if (IsPrime(i)) primes.Add(i);

            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                int n = int.Parse(line);
                Console.WriteLine("{0} {1}", primes.Where(x => x < n).Max(), primes.Where(x => x > n).Min());
            }
        }

        /// <summary>
        ///素数判定
        /// </summary>
        public static bool IsPrime(long number)
        {
            long boundary = (long)Math.Floor(Math.Sqrt(number));

            if (number == 1) return false;
            if (number == 2) return true;
            if (number % 2 == 0) return false;

            for (long i = 2 ; i <= boundary ; ++i)
            {
                if (number % i == 0) return false;
            }
            return true;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

using namespace std ;

#define N 100010
#define ll long long

int n , a[ N ] , x ;
ll ans = 0 ;

int main() {
	scanf( "%d%d" , &n , &x ) ;
	for( int i = 1 ; i <= n ; i ++ )
		scanf( "%d" , &a[ i ] ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		if( a[ i ] + a[ i + 1 ] > x ) {
			ans += 1ll * ( a[ i ] + a[ i + 1 ] - x ) ;
			a[ i + 1 ] -= ( a[ i ] + a[ i + 1 ] - x ) ;
		}
	}
	printf( "%lld\n" , ans ) ;
	return 0 ;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int INF=INT_MAX-1;

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


    string s;
    cin >> s;

    if((s[2]==s[3] && s[4]==s[5]))
        cout <<  "Yes\n" ;
    else
        cout <<  "No\n";
    return 0;
}

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

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<int> town(n + 1, 0);

    rep(i, m) {
        cin >> a >> b;
        if(a == b) town.at(a)++;
        else {
            town.at(a)++;
            town.at(b)++;
        }
    }
    rep(i, n) {
        cout << town.at(i + 1) << endl;
    }
}


Measured memory_bytes: 3592
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    string s;
    cin >> s;
    int ans = 0;
    REP(i,ceil(s.size()/2)){
        if(s[i] != s[s.size()-1-i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

int n;
vector<pair<int, int>> ar;
vector<pair<int, int>> l;
vector<pair<int, int>> r;

int dp[N];


int solve(int index) {
    if (index == n) {
        return 0;
    }
    if (dp[index] != -1) return dp[index];
    int ans;
    auto nx = lower_bound(l.begin(), l.end(), make_pair(ar[index].first - ar[index].second, index + 1));
    if (nx != l.end()){
        ans = solve((*nx).second);
    } else {
        ans = solve(n);
    }

    int k = ar[index].first + ar[index].second;
    auto ptr = lower_bound(l.begin(), l.end(), make_pair(k, index + 1));
    if (ptr != l.end()){
        ans = max(ans, 1 + solve((*ptr).second));
    } else {
        ans = max(ans, 1 + solve(n));
    }
    return dp[index] = ans;
}

integer main(){
    ios_base::sync_with_stdio(false);

    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        ar.push_back({a, b});
    }
    sort(ar.begin(), ar.end());
    for (int i = 0; i < n; i++){
        l.push_back({ar[i].first - ar[i].second, i});
        r.push_back({ar[i].first + ar[i].second, i});
    }
    sort(l.begin(), l.end());
    cout << solve(0) << endl;

}


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

int main(){
  int K, S;
  cin >> K >> S;
  int res = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      if(K >= S - x - y && S - x - y >= 0)res++;
    }
  }
  cout << res << endl;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  
  if(a.at(0) == b.at(2) && a.at(1) == b.at(1) && a.at(2) == b.at(0)){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	auto are = new int[10][10];
	foreach (line; stdin.byLine) {
		auto a = line.split(",").map!(to!int);
		auto x = a[0];
		auto y = a[1];
		auto size = a[2];
		
		are[x][y]++;
		if (x-1 >= 0) are[x-1][y]++;
		if (x+1 < 10) are[x+1][y]++;
		if (y-1 >= 0) are[x][y-1]++;
		if (y+1 < 10) are[x][y+1]++;
		if (size == 1) continue;

		if (x-1 >= 0 && y-1 >= 0) are[x-1][y-1]++;
		if (x-1 >= 0 && y+1 < 10) are[x-1][y+1]++;
		if (x+1 < 10 && y-1 >= 0) are[x+1][y-1]++;
		if (x+1 < 10 && y+1 < 10) are[x+1][y+1]++;
		if (size == 2) continue;

		if (x-2 >= 0) are[x-2][y]++;
		if (x+2 < 10) are[x+2][y]++;
		if (y-2 >= 0) are[x][y-2]++;
		if (y+2 < 10) are[x][y+2]++;		 
	}

	int cnt, dmax;
	foreach (i; 0..10) {
		cnt += are[i].array.count(0);
		dmax = max(are[i].reduce!(max), dmax);
	}

	cnt.writeln;
	dmax.writeln;
}

Measured memory_bytes: 1112
#include <stdio.h>

int main(void){
 
  int a,b,c;
  int ans;
  
	scanf("%d %d %d", &a, &b, &c);
	ans = c-(a-b);
	if(ans < 0) ans = 0;
	
  	printf("%d\n", ans);
 
  return 0;
}


Measured memory_bytes: 128