akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
ll dp[100009];
vector<ll> v[100009];

ll fun(ll x)
{
	if(dp[x]!=-1)
		return dp[x];
	else 
	{
		ll mx=0;
		for(auto j:v[x])
			mx=max(mx,fun(j));
		dp[x]=mx;
		if(!v[x].empty())
			dp[x]++;
		return dp[x];
	}
}

int main()
{ 
fast;

	ll n,m,x,y;
	cin>>n>>m;

	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		x--,y--;
		v[x].pb(y);
	}

	memset(dp,-1,sizeof(dp));
	
	for(ll i=0;i<n;i++)
		fun(i);

	cout<<*max_element(dp,dp+n);
}


Measured memory_bytes: 9216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	
    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	int n = sc.nextInt();

        	int sum = 0;
        	for ( int base = 0, i = 0; i < n; i++ ) {
        		if(i == 0) {
        			base = sc.nextInt();
        			sum++;
        		} else {
        			int b = sc.nextInt();
        			if(base <= b) {
        				sum++;
        				base = b;
        			}
        		}
        	}
        	
        	
        	
            System.out.println(sum);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>

using namespace std;

void ans(long long N, long long X,long long &pate) {
    //cout << pate << endl;
    if (N == 1) {
        if (X <= 0) return;
        else if (X >= 5) pate += 3;
        else  pate+= X - 1;       
    }
    else {
        if (X <= 0)return;
        if (X < pow(2, N + 1) - 1)
            ans(N - 1, X - 1,pate);
        else {
            pate += pow(2, N);
            ans(N - 1, X - (pow(2, N + 1) - 1),pate);
        }
    }
}
int main() {
    long long N, X;
    cin >> N >> X;
    long long pate = 0;

    ans(N, X, pate);
    cout << pate << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	unsigned i, n, cnt,f;
	while (scanf("%u", &n), n != 0) {
		cnt = 0,f=5;
		while (1) {
			if(f<=n)cnt += n / f;
			else break;
			f *= 5;
		}
		printf("%u\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 608
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    maxA = max(A)
    if maxA == 1:
        print('pairwise coprime')
        return
    prime = [i if i % 2 != 0 else 2 for i in range(maxA+1)]
    f = [False] * (maxA+1)
    for i in range(3, int(maxA**.5)+1):
        if prime[i] != i:
            continue
        p = i * 2
        while p <= maxA:
            if prime[p] == p:
                prime[p] = i
            p += i

    def gcd(x, y):
        if y == 0:
            return x
        return gcd(y, x % y)

    setwise_coprime = A[0]
    for An in A[1:]:
        setwise_coprime = gcd(setwise_coprime, An)
        if setwise_coprime == 1:
            break
    # print(prime)
    for An in A:
        if An == 1:
            continue
        # print('An = {}'.format(An))
        not_pairwise_coprime = False
        while prime[An] != An:
            # print('prime[An]={}, f[prime[An]]={}'.format(prime[An], f[prime[An]]))
            if f[prime[An]]:
                not_pairwise_coprime = True
                break
            f[prime[An]] = True
            prime_An = prime[An]
            while An % prime_An == 0:
                An //= prime_An
        else:
            if An != 1:
                if f[An]:
                    not_pairwise_coprime = True
                else:
                    f[An] = True
        if not_pairwise_coprime:
            break
        # print(f)
    else:
        print('pairwise coprime')
        return
    if setwise_coprime == 1:
        print('setwise coprime')
    else:
        print('not coprime')

if __name__ == '__main__':
    main()

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

int main() {

  int N;
  cin >> N;

  int sum=0;
  int wk=N;
  while(wk > 0){
      sum += wk%10;
      wk/=10;
  }

  if(N%sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;
int main()
{
    long long n,m, sum = 0;
    cin >> n >> m;
    while(m--){
        long long c;
        cin >> c;
        sum+=c;
    }
    if(sum<n) cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 256
a, b, c = gets.split.map(&:to_i)
count = 0
until a == b && b == c
  count += 1 
  a, b, c = [a, b, c].sort
  if a + 2 <= c
    a += 2
  else
    a += 1
    b += 1
  end
end
puts count

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,w,z;
    cin>>n>>z>>w;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    if(n==1){
        cout<<abs(a[0]-w)<<endl;return 0;
    }
    cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w))<<endl;
}


Measured memory_bytes: 256
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000000
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
void solve()
{
    ll a[5];ll x;
    for(ll i=0;i<5;i++)
    {
        cin>>a[i];
        if(!a[i])x=i+1;
    }
    cout<<x<<endl;
}

signed main()
{
   Need_for_speed(activated);

//satisfy
//    {
//  solve();
//   }

    solve();
    
    return 0;
}


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

int main()
{
	char s[5];
	string list[10];
	bool flag = true;
	
	list[0] = "* = ****";
	list[1] = "* =* ***";
	list[2] = "* =** **";
	list[3] = "* =*** *";
	list[4] = "* =**** ";
	list[5] = " *= ****";
	list[6] = " *=* ***";
	list[7] = " *=** **";
	list[8] = " *=*** *";
	list[9] = " *=**** ";
	
	while(scanf("%s", s) != EOF){
		if(!flag) puts("");
		string str = s;
		int len = str.size();
		string num;
		for(int i = 0; i < 5 - len; i++){
			num += "0";
		}
		num += str;
		
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 5; j++){
				cout << list[num[j] - '0'][i];
			}
			puts("");
		}
		flag = false;
	}
	
	return(0);
}

Measured memory_bytes: 1192
import numpy as np

n, k = map(int, input().split())
a = list(map(int, input().split()))

a_2 = a.copy()
a_2.extend(a)

lst_1 = [0 for i in range(n)]
for i in range(n):
    for j in range(i+1, n):
        if a[i] > a[j]:
            lst_1[i] += 1

lst_2 = [0 for i in range(n)]
for i in range(n):
    for j in range(i+1, 2*n):
        if a[i] > a_2[j]:
            lst_2[i] += 1

arr1 = np.array(lst_1)
arr2 = np.array(lst_2)
arr2 = arr2 - arr1
sum1 = sum(arr1)
sum2 = sum(arr2)
ans = ((sum1*k) % (10**9+7) + (sum2 * (((k-1) * k // 2) % (10**9+7)))) % (10**9+7)

print(ans)

Measured memory_bytes: 21544
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N,H, n,m , M, K,a;

vector<ll> v;
int main(){
    cin >> N;
    vector<ll> h(N+1);
    vector<ll> dp(N+1);
    for(ll i = 1; i <= N; ++i){
        ll he; cin >>he; h[i] = he;
    }
    dp[0] = 1e12;
    dp[1] = 0;
    for(int i = 2;  i <= N; ++i){
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }
    cout << dp[N];
    return 0;

}



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

int dx[4];
int dy[4];
int f[4][4];

int dfs(int x, int y)
{
	int ret=0;
	//cout << x << " " << y << endl;

	if(x==0 && y==4)
	{
		return 1;
	}

	for(int i=0; i<4; i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];

		if(0<=nx && nx<=3 && 0<=ny && ny<=3)
		{
			if(f[nx][ny]) continue;
			f[nx][ny] = 1;
			f[x][y]=1;

			int t=y*4+x+1;
			for(; t<16; t++)
			{
				if(f[t%4][t/4]==0) break;
			}
			ret += dfs(t%4,t/4);
			f[x][y]=0;
			f[nx][ny] = 0;
		}
	}

	return ret;
}

int main()
{
	while(cin >> dx[0])
	{
		if(dx[0]>4) break;
		
		cin >> dy[0];
		for(int i=1; i<4; i++)
		{
			cin >> dx[i] >> dy[i];
		}

		memset(f,0,sizeof(f));
		cout << dfs(0,0) << endl;
	}
}

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

int main()
{
    string num;

    cin>>num;
    int len = num.size();

    for(int i=0;i<len;i++)
    {
        if(num[i] == '7')
        {
            cout<<"Yes\n";
            return 0;
        }
    }

    cout<<"No\n";
    return 0;
}


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

using namespace std;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if (A==B && A!=C){
        cout << "Yes";
    }else if (A!=B && A==C){
        cout << "Yes";
    }else if (B==C && B!=A){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


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

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

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

    vector<int> data(n + 1);

    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }
    data.at(n) = x;

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

	vector<int> delta(n);
	for (int i = 0; i < n; i++) {
		delta.at(i) = data.at(i + 1) - data.at(i);
	}

    int num;
    if (delta.size() == 1){
        num = delta.at(0);
    }
    else{
        num = gcd(delta.at(0), delta.at(1));
	    for (int i = 2; i < n; i++) {
	    	num = gcd(num, delta.at(i));
	    }
    }
	
	cout << num << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm> // sort
#include <utility> // pair
#include <cfloat> // DBL_MAX

typedef long long ll;
using namespace std;

int main(){
  ll N,C,K;
  cin >> N >> C >> K;

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

  sort(ts.begin(), ts.end());
  int fst = *ts.begin();
  int mem = 0;
  int ans = 1;
  for(int i=0; i<N; i++){
    if(mem == C || ts[i]-fst > K){ // next bus
      fst = ts[i];
      mem = 0;
      ans += 1;
    }

    mem+=1;
  }

  cout << ans << 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 REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    int a=n/100;
    int b=n%100;
    if(1<=a && a<=12 && 1<=b && b<=12) cout << "AMBIGUOUS\n";
    else if(1<=a && a<=12) cout << "MMYY\n";
    else if(1<=b && b<=12) cout << "YYMM\n";
    else cout << "NA\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};

signed main() {
  string s;cin>>s;int ans;
  bool nnn = true;
  repd(i,1,s.length()){
    if(s[i] != '9')nnn = false;
  }
  
  ans = 9 * (s.length() - 1);
  ans += s[0] - '0' - 1;
  if(nnn)ans++;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<vector<int> > DP (M+1,vector<int> ((1<<N)+1,INF));
  for (int i = 0; i < 1; i++)
  {
    DP[i][0] = 0;
  }

  for (int i = 0; i < M; i++)
  {
    int A,B,KEY=0;
    cin>>A>>B;
    for (int j = 0; j < B; j++)
    {
      int C;
      cin>>C;
      KEY |= (1<<(C-1));
    }
    
    for (int b = 0; b < 1<<N; b++)
    {
      int nb = b|KEY;
      DP[i+1][nb] = min(min(DP[i][nb],DP[i][b]+A),DP[i+1][nb]);
    // if(DP[i+1][nb] != INF)DEBUG(DP[i+1][nb]);
      // if(b == 13)DEBUG(DP[i][b]);
    }
    
        for (int b = 0; b < 1<<N; b++)
    {
      DP[i+1][b] = min(DP[i][b],DP[i+1][b]);

    }
    
    

  }

      // DEBUG(DP);
      if(DP[M][(1<<N) -1] >= INF)
      {
        cout<<-1<<endl;
        return;
      } 
    cout<<DP[M][(1<<N) -1]<<endl;

  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 32384
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
ll m,n;
int a[100010];
string s; 
int main()
{
	cin>>m>>n;
	rep(i,m) cin>>a[i];
	sort(a,a+m);
	ll ans=0;
	rep(i,n) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3628
// bool使えたのでぼくは天才(ちがう)
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string>s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  bool b = true;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) b = false;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    if (s[i].at(s[i].size() - 1) != s[i + 1].at(0)) b = false;
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1 = 1, x2 = 2, x3 = 3, x4 = 4, x5 = 5;
  cin >> x1;
  cin >> x2;
  cin >> x3;
  cin >> x4;
  cin >> x5;
  
  if (x1 == 0){
    cout << "1" << endl;
  }
  else if (x2 == 0){
    cout << "2" << endl;
  }
  else if (x3 == 0){
    cout << "3" << endl;
  }
  else if (x4 == 0){
    cout << "4" << endl;
  }
  else if (x5 == 0){
    cout << "5" << endl;
  }
}

Measured memory_bytes: 3568
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n;
vector <int> by_sum, by_diff;
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    int x, y;
    for (int i=1; i<=n; i++) {
        cin>>x>>y;
        by_sum.push_back(x+y);
        by_diff.push_back(x-y);
    }
    sort(by_sum.begin(), by_sum.end());
    sort(by_diff.begin(), by_diff.end());
    cout<<max(by_sum[n-1] - by_sum[0], by_diff[n-1] - by_diff[0]);
    
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: https://www.codeforces.com/profile/low_
// ...or linkedIn: https://www.linkedin.com/in/daniel-to-83045a19a/
// I use VS Code. Here's a JSON format for my template: https://pastebin.com/xH2yRdwx


Measured memory_bytes: 6676
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,p[51];
	int d=0;
	scan(N);
	rep(i,N){
		scan(p[i]);
		if(p[i]!=i+1) d++;
	}
	if(d<=2) prin("YES");
	else prin("NO");
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# Nの入力
n = int(input())
# スペース区切りの整数の入力
a = sorted(list(map(float, input().split())))
value = a[0]
#value = a.get(0)
for i, e in enumerate(a):
	if i > 0:
		value = (value + e)/2
print(value)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



int main() {
    int dp[5][5][4] = {};
    string d = "RDLU";
    array<int, 4> dy{0, 1, 0, -1}, dx{1, 0, -1, 0};
    for (int i = 0; i < 9; ++i) {
        string s;
        cin >> s;
        if(i&1){
            for (int j = 0; j < 5; ++j) {
                if(s[j] == '1'){
                    dp[i/2][j][1] = dp[i/2+1][j][3] = 1;
                }
            }
        }else {
            for (int j = 0; j < 4; ++j) {
                if(s[j] == '1'){
                    dp[i/2][j][0] = dp[i/2][j+1][2] = 1;
                }
            }
        }
    }
    int y = 0, x = 0, cur = 0, started = 0;
    for (int i = 0; !started || y || x; ++i) {
        if(dp[y][x][(cur+3)&3]){
            cur = (cur+3)&3;
            cout << d[cur];
            y += dy[cur], x += dx[cur];
        } else if(dp[y][x][cur]){
            started = 1;
            cout << d[cur];
            y += dy[cur]; x += dx[cur];
        }else cur = (cur+1)&3;
    }
    puts("");
    return 0;
}


Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int L,R;
  cin >> L >> R;
  int L_,R_;
  for(int i=1;i<N;i++){
    if(M==1){
      break;
    }
    cin >> L_ >> R_;
    if(L<L_){
      L = L_;
    }
    if(R_<R){
      R = R_;
    }
  }
  int count = 0;
  for(int i=1;i<=N;i++){
    if(L<=i && i<=R){
       count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s.size()>9||s.size()<5) {
    cout<<"NO";
    return 0;
  }
  string tmp;
  for(int i=0;i<s.size();i++){
    if(s[i]!='A'){
      tmp.push_back(s[i]);
    }
    if(i==s.size()-1);
    else if((s[i]=='K'||s[i]=='I'||s[i]=='A')&&s[i+1]=='A'){
      cout<<"NO";
      return 0;
    }
  }
  cout<<(tmp=="KIHBR"?"YES":"NO");
} 

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int res[n];
  if (n % 2) {
    for (int i = 0; i < n; i++) {
      if (i % 2) res[n / 2 + i / 2 + 1] = a[i];
      else res[n / 2 - i / 2] = a[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i % 2) res[n / 2 - i / 2 - 1] = a[i];
      else res[n / 2 + i / 2] = a[i];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << " ";
  }
  cout << "" << "\n";
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int i;
  vector<int> x(s.size(), 1);
  for(i = 0; i < s.size() - 2; i++){
    if(s.at(i) == 'R' && s.at(i + 1) == 'R'){
      x.at(i + 2) += x.at(i);
      x.at(i) = 0;
    }
  }
  for(i = s.size() - 1; i > 1; i--){
    if(s.at(i) == 'L' && s.at(i - 1) == 'L'){
      x.at(i - 2) += x.at(i);
      x.at(i) = 0;
    }
  }
  
  for(i = 0; i < s.size(); i++) cout << x.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int b[m];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    sort(b,b+m);
    bool flag=false;
    for(int i=x+1;i<=y;i++){
        if(i>a[n-1] && i<=b[0]){
            flag=true;
        }
    }
    if(flag){
        cout << "No War" << endl;
    }
    else cout << "War" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int v[100000],cnt[100000];
int main()
{
    long long int n,m,i,j,t,k;
    scanf("%lld%lld",&n,&m);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&k);
        for(j=0;j<k;j++)
        {
            scanf("%lld",&v[j]);
            cnt[v[j]]++;
        }
    }
    t=0;
    for(i=1;i<=m;i++)
    {
        if(cnt[i]==n)
        {
            t++;
        }
    }
    printf("%lld\n",t);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

int dp[50][4];
int main() {
	while (1) {
		int n; cin >> n;
		if (!n)break;
		vector<pair<int, int>>bals;
		vector<int>ps, ts;
		bals.push_back(make_pair(0, 0));
		for (int i = 0; i < n; ++i) {
			int p, t; cin >> p >> t;
			bals.push_back(make_pair(p, t));
		}
		sort(bals.begin(), bals.end(), [](const pair<int, int>&l, const pair<int, int>&r) {return l.second < r.second; });
		for (int i = 0; i < bals.size(); ++i) {
			ps.push_back(bals[i].first);
			ts.push_back(bals[i].second);
		}
		for (int i = 0; i < 50; ++i) {
			for (int j = 0; j < 4; ++j) {
				dp[i][j] = 99999999;
			}
		}
		dp[0][0] = 0;
		int ans = 99999999;
		for (int i = 0; i < n; ++i) {
			int shodis = abs(ps[i + 1] - ps[i]);
			int time = ts[i + 1] - ts[i];
			bool ok = false;
			for (int j = 0; j < 4; ++j) {
				if (dp[i][j] == 99999999)continue;
				if (j != 3) {
					if (time >= shodis*(j + 1)) {
						dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + shodis);
						ok = true;
					}
				}
				if (time >= ps[i] * (j + 1) + ps[i + 1]) {
					dp[i + 1][1] = min(dp[i + 1][1], dp[i][j] + ps[i]+ps[i+1]);
					ok = true;
				}
			}
			if (!ok) {
				ans = i+1;
				break;
			}
		}
		if (ans!=99999999) {
			cout << "NG " << ans << endl;
		}
		else {
			for (int i = 0; i < 4; ++i) {
				ans = min(ans, dp[n][i] + ps[n]);
			}
			cout << "OK " << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3056
N=int(input())
p=list(map(int,input().split()))
li=[]
for i in range(N):
    if p[i] == i+1:
        pass
    else:
        li.append([p[i],i+1])
if li == []:
    print('YES')
elif len(li) == 2:
    if li[0][0] == li[1][1]:
        print('YES')
    else:
        print('NO')
else:
    print('NO')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(b<=a&&k>=1){
		k--;
		b*=2;
	}
	if(b<=a){
		cout<<"No";
		return 0;
	}
	while(c<=b&&k>=1){
		k--;
		c*=2;
	}
	if(c<=b){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	string s;
	cin >> s;
	int n = s.size();
	bool ok = true;
	for (int i = 0;i < n;++i) {
		if (i % 2 == 1) {
			ok &= (s[i] != 'R');
		}
		else {
			ok &= (s[i] != 'L');
		}
	}
	cout << (ok ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
using ld = long double;

int const sigma = 26;
int const modulo = 1000000007;
int frec[1 + sigma];

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++)
    frec[s[i] - 'a']++;
  int result = 1;
  for(int i = 0; i < sigma; i++)
    result = 1LL * result * (frec[i] + 1) % modulo;
  cout << result - 1;
  return 0;
}


Measured memory_bytes: 512
s=input()
N=len(s)
t=input()
M=len(t)

alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
def al(str):
    return alphabetlist.index(str)+1

dp=[[0 for i in range(0,M+1)] for i in range(0,N+1)]

for i in range(0,N):
    for j in range(0,M):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            if dp[i+1][j]>dp[i][j+1]:
                dp[i+1][j+1]=dp[i+1][j]
            else:
                dp[i+1][j+1]=dp[i][j+1]

ans=[]
i=N
j=M
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans.append(s[i-1])
        i-=1
        j-=1

ans=ans[::-1]
print(''.join(ans))

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	char a;
	cin >> a;
	int x = a  + 1;
	a = (char)x;
	
	cout << a;
}



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

int x,y,a,b,c,ar[nmax],ag[nmax],ac[nmax],pos=-1;
long long cont;
vector<int>v;

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

    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++) cin>>ar[i];
    for(int i=0;i<b;i++) cin>>ag[i];
    for(int i=0;i<c;i++) cin>>ac[i];
    sort(ar,ar+a);
    sort(ag,ag+b);
    sort(ac,ac+c);
    for(int i=a-1;x>0;i--){
        v.push_back(ar[i]);
        cont+=ar[i];
        x--;
    }
    for(int i=b-1;y>0;i--){
        v.push_back(ag[i]);
        cont+=ag[i];
        y--;
    }
    sort(v.begin(),v.end());
    bool bul=0;
    for(int i=c-1;i>=0;i--){
        bul=0;
        for(int j=pos+1;j<v.size();j++){
            if(ac[i]>v[j]){
                bul=1;
                cont-=v[j];
                v[j]=ac[i];
                cont+=v[j];
                pos=j;
                break;
            }
        }
        if(bul==0){
           //for(auto k: v) cout<<k<<" ";
            break;
        }
    }
    cout<<cont;
}


Measured memory_bytes: 2552
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,n;
    
    scanf("%d",&n);
    
    for(i=1;i<=n;i++){
        if(i % 3 == 0 || i % 10 == 3 || i/10 % 10 == 3 || i/100 % 10 == 3 || i/1000 % 10 == 3){
            printf(" ");
            printf("%d",i);
        }
    }
    
    printf("\n");
    return 0;
}


Measured memory_bytes: 2076
#include <iostream>

using namespace std;
 
int main(){
  int N;
  int d[50];
  int sum = 0;
  cin >> N;
  
  for(int i = 0;i < N;i++){
    cin >> d[i];
  }
  
  for(int i = 0;i < N-1;i++){
    for(int j = i + 1;j < N;j++){
      sum += d[i] * d[j];
    }
  }
  
  cout << sum;
  
}

Measured memory_bytes: 256
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n:usize,
        d:[usize;n],
    }
    let set: HashSet<usize> = d.into_iter().collect();
    println!("{}", set.len());
}


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

int main() {
  string s;
  string t;
  cin>>s>>t;
  int n=s.size();
  string ans="Yes";
  for(int i=0;i<n;i++){
    if(s[i]!=t[i]) ans="No";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(int argc, char* argv[]) {
  int N, K;
  cin >> N >> K;

  map<int, int> m;
  for (int i = 0; i < K; ++i) {
    int d;
    cin >> d;
    for (int j = 0; j < d; ++j) {
      int tmp;
      cin >> tmp;
      if (m.find(tmp) == m.end())
        m[tmp] = 0;
      ++m[tmp];
    }
  }


  int ret = 0;
  for (int i = 0; i < N; ++i) {
    if (m.find(i + 1) == m.end())
      ++ret;
  }

  cout << ret << endl;

  return 0;
}

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

public class Main {
    private static final int MAX_COLOR = 8;
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String strArr[] = br.readLine().split(" ");
            int colArr[] = new int[MAX_COLOR + 1];
            for (int i = 0; i < n; i++) {
                int tmp = Integer.parseInt(strArr[i]);
                if (tmp >= 1 && tmp <= 399) {
                    colArr[0]++;
                } else if (tmp >= 400 && tmp <= 799) {
                    colArr[1]++;
                } else if (tmp >= 800 && tmp <= 1199) {
                    colArr[2]++;
                } else if (tmp >= 1200 && tmp <= 1599) {
                    colArr[3]++;
                } else if (tmp >= 1600 && tmp <= 1999) {
                    colArr[4]++;
                } else if (tmp >= 2000 && tmp <= 2399) {
                    colArr[5]++;
                } else if (tmp >= 2400 && tmp <= 2799) {
                    colArr[6]++;
                } else if (tmp >= 2800 && tmp <= 3199) {
                    colArr[7]++;
                } else {
                    colArr[8]++;
                }
            }
            int min = 0;
            for (int i = 0; i < MAX_COLOR; i++) {
                if (colArr[i] > 0) {
                    min++;
                }
            }
            int max = 0;
            if (colArr[8] > 0) {
                if (min == 0) {
                    min++;
                    max = colArr[8];
                } else {
                    max = colArr[8] + min;
                }
            } else {
                max = min;
            }
            System.out.println(min + " " + max);
       } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1e9 + 7;


int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        p[i] = P(x, y);
    }

    vector<double> d(n, 0);
    rep(i, n) {
        auto a = p[i];
        rep(j, n) {
            if (i == n) continue;
            auto b = p[j];
            int l = a.first - b.first;
            int r = a.second - b.second;
            double distance = sqrt(l * l + r * r);
            d[i] += distance;
        }
        d[i] /= n;
    }
    double ans = accumulate(d.begin(), d.end(), 0.0);
    printf("%.10f\n", ans);


}



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

template <typename Weight>
class max_flow {
	struct edge {
		int to, rev; Weight cap;
		edge(int t, Weight c, int r) : to(t), rev(r), cap(c) {}
	};
	vector<vector<edge>> G;
	vector<int> level;
	vector<size_t> iter;
	const Weight inf;
	void bfs(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (size_t i = 0; i < G[v].size(); i++) {
				edge &e = G[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	Weight dfs(int v, int t, Weight f) {
		if (v == t) return f;
		for (size_t &i = iter[v]; i < G[v].size(); i++) {
			edge &e = G[v][i];
			edge &re = G[e.to][e.rev];
			if (re.cap > 0 && level[v] > level[e.to]) {
				Weight d = dfs(e.to, t, min(f, re.cap));
				if (d > 0) {
					re.cap -= d;
					e.cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	max_flow(int n, Weight inf_) : G(n), level(n), iter(n), inf(inf_) {}
	void add(int a, int b, Weight cap) {
		G[a].emplace_back(b, cap, G[b].size());
		G[b].emplace_back(a, (Weight)0, G[a].size() - 1);
	}
	Weight dinic(int s, int t) {
		Weight flow = 0;
		while (bfs(s), level[t] >= 0) {
			fill(iter.begin(), iter.end(), 0);
			while (true) {
				Weight f = dfs(t, s, inf);
				if (f <= 0) break;
				flow += f;
			}
		}
		return flow;
	}
};

const ll INF = 1e15;

const ll MAX = 1e9;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	max_flow<ll> mf(N + 2, INF);
	int s = N, t = N + 1;
	for (int i = 0; i < N; i++) {
		mf.add(s, i, MAX);
		mf.add(i, t, MAX - a[i]);
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) if ((j + 1) % (i + 1) == 0) {
			mf.add(j, i, INF);
		}
	}
	cout << (MAX * N - mf.dinic(s, t)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)
    vector<ll>ar;
  bool check(ll i,ll n){
    if(abs(i-n)<=1)return true;
    for(ll ii=n-1; ii>i; ii--)if(ar[ii]<ar[ii-1])
      cout<<ar[ii]<<" ";
    cout<<endl;
    return true;
  }

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

     }
   

Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    int A=0,B=0,T=0;
    cin >> A >> B >> T;
    cout << T/A*B << endl;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(sys.stdin.readline())
    del s[len(s)-1]
    l = len(s) + 1
    ans = [0] * l

    tmp = 1
    for i in range(len(s)):
        if s[i] == "<":
            ans[i + 1] = tmp
            tmp += 1
        else:
            tmp = 1

    tmp = 1
    for i in range((len(s)) - 1, -1,-1):
        if s[i] == ">":
            ans[i] = max(ans[i], tmp)
            tmp += 1
        else:
            tmp = 1

    print(sum(ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 29016
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

typedef long long int ll;
typedef pair<int,int> P;

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//



int main(){
        ll n,k;
        cin >> n >> k;
        vector<P> p(n);
        for(ll i = 0; i < n; i++) cin >> p[i].first >> p[i].second;

        sort(all(p));

        ll cnt = 0;
        for(ll i = 0; i < n; i++){
                cnt += p[i].second;
                if(cnt >= k){
                        cout << p[i].first << endl;
                        return 0;
                }
        }

}







Measured memory_bytes: 1024
NL = list(map(int, input().split()))

N = NL[0]
L = NL[1]

tasteSUM = 0
tasteABS = 2000

for i in range(N):
    taste= L + (i + 1) - 1

    tasteSUM+=taste

    if abs(taste) < abs(tasteABS):
        tasteABS = taste


tasteSUM = tasteSUM - tasteABS

print(tasteSUM)


# if L<0 and (abs(N) < abs(L)):
#     for i in range(N):
#         if i == N-1:
#             continue
#         else:
#             taste += L + (i + 1) - 1
#
# elif L < 0:
#     for i in range(N):
#         taste += L+(i+1)-1
#
#
# else:
#     for i in range(N):
#         if i == 0:
#             continue
#         else:
#             taste += L+(i+1)-1


# print(taste)




Measured memory_bytes: 3060