akhauriyash/Code-Regression huggingface dataset:
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL; 																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																							   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

li tab[1000005];
int licznik[1000005];

///////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

void DFS(int v, int p = -1){
	list<int>::iterator it;
	for(it = tab[v].begin(); it != tab[v].end(); it++){
		if(*it == p)
			continue;
		else{
			licznik[*it] += licznik[v];
		}
		DFS(*it, v);
	}
}
/////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < (n-1);i++){
		int v1, v2;
		cin >> v1 >> v2;
		v1--;
		v2--;
		tab[v1].pb(v2);
		tab[v2].pb(v1);
	}
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		--a;
		licznik[a] += b;
	}
	DFS(0);
	
	//cout << "licznik: " << endl;
	for(int i = 0; i < n; i++){
		cout << licznik[i] << " ";
	}

	

	return 0;
}



Measured memory_bytes: 42624
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(b + c <= a){
            System.out.println("0");
        }else{
            System.out.println(b + c - a);
        }
    }
}

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

int main() {
    int64_t X;
    cin >> X;
    int a = X / 500;
    int b = X % 500;
    int c = b / 5;
    cout << 1000 * a + 5 * c << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100003

char buf[MAX];
int n;

string s;

vector<pair<int, int> > v;

vector<int> dif;
int belong[MAX];
int sum[MAX];

inline int root(int b) {
	if (belong[b] == -1) {
		return b;
	}
	belong[b] = root(belong[b]);
	return belong[b];
}
void merge(int a, int b) {
	a = root(a);
	b = root(b);
	if (a == b) {
		return;
	}
	belong[a] = b;
	sum[b] += sum[a];
	if (sum[b] >= 26)sum[b] -= 26;
}

int main() {
	memset(belong, -1, sizeof(belong));
	scanf("%s", buf);
	s = buf;
	cin >> n;
	s.insert(0, "a");
	s.push_back('a');
	for (int i = 0; i + 1 < s.size(); i++) {
		dif.push_back(26+(s[i + 1] - s[i]));
		dif.back() %= 26;
		sum[i] = dif.back();
	}
	for (int i = 0; i < n; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		l--;
		r--;
		merge(l, r + 1);
	}
	int rig = dif.size() - 1;
	for (int i = 0; i < dif.size(); i++) {
		merge(i, rig);
		rig--;
	}
	for (int i = 0; i < dif.size(); i++) {
		if (sum[root(i)] % 26 == 0) {

		}
		else {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 1788
#include<stdio.h>
#include<string.h>
int main ()
{
	int a,c=0;
	char code[30];
	scanf("%s",&code);
	for(a=0;a<strlen(code);a++)
	{
		if(code[a]!=code[a+1])
		{
			c++;
		}
	}
	if(c==strlen(code))
	{
		printf("Good\n");
	}
	else
	{
		printf("Bad\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
if(a<=b){
    cout<<a<<endl;
}
else{
    cout<<a-1<<endl;
}
//system("pause");
return 0;
}

Measured memory_bytes: 256
/*
I am A NOOB.
You CANNOT LEARN Anything from My CODE.
So Just Go please.
Happy Coding.
*/
#include<bits/stdc++.h>
#define PI            	acos(-1)
#define pb 			  	push_back
#define pf 			  	push_front
#define mx(v) 		  	*max_element(v.begin(),v.end())
#define mn(v) 		  	*min_element(v.begin(),v.end())
#define sum(v)		  	accumulate(v.begin(),v.end(),0)
#define uni(v)		  	v.erase(unique(v.begin(),v.end()),v.end());
#define scan(n)		  	scanf("%d",&n);
#define arInput0(ar,n)	for(int i=0;i<n;i++)scan(ar[i]);
#define arInput1(ar,n)	for(int i=1;i<=n;i++)scan(ar[i]);
#define arOut0(ar,n)  	for(int i=0;i<n;i++){printf("%lld ",ar[i]);}
#define arOut1(ar,n)  	for(int i=1;i<=n;i++){printf("%lld ",ar[i]);}
#define gcd(a,b)		__gcd(a,b);
#define lcm(a,b)		(a/(gcd(a,b))*b);
#define all(a)  		a.begin() , a.end()
#define priority_queue  p_q
#define boost 			{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define INF 		  	int(1e18)
#define mem(x,val) 	  	memset(x,val,sizeof(x))
#define io  		  	{freopen("in.txt","r", stdin);freopen("out.txt","w", stdout);}
#define popcount(x)		__builtin_popcount(x)
#define X 			  	first
#define Y 			  	second
#define PII			  	pair<int,int>
typedef long long int 	lli;
typedef unsigned long long int ulli;
using namespace std;


int main() {
	//io;
	boost;
	lli n; cin >> n;
	lli ar[n + 5];
	lli mul = 1;
	lli prevMal = 1;
	lli mxx = 1000000000000000000;
	bool f = true;
	bool z = false;
	/*for (int i = 1; i <= n; i++) {
		cin >> ar[i];
		prevMal = mul;
		mul = mul * ar[i];
		if (ar[i] == 0)z = true;
		if (mul < prevMal) {f = false;}
	}
	if (z)cout << 0 << endl;
	else if (mul > mxx) {cout << -1 << endl;}
	else if (f) {cout << mul << endl;}
	else cout << -1 << endl;*/

	for (int i = 1; i <= n; i++) {
		cin >> ar[i];
		if (ar[i] == 0)z = true;

		double x = log10(ar[i]);
		double z = log10(mul);
		if (x > 18)f = false;
		else {
			if (x + z > 18)f = false;
			else {
				mul = mul * ar[i];
				if (mul > mxx)f = false;
			}
		}

	}
	if (z)cout << 0 << endl;
	else if (f == false)cout << -1 << endl;
	else cout << mul << endl;


}



Measured memory_bytes: 4804
#include<iostream>
#include<stack>
using namespace std;
static const int N = 100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];


int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v])return v;
	}
	return -1;
}

void dfs_visit(int r) {
	for (int i = 0; i < n; i++) nt[i] = 0;

	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;

	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == WHITE) {
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}else {
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}

void dfs() {
	for (int i = 0; i < n; i++) {
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 0;

	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE) dfs_visit(u);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}


int main()
{
	int u, k, v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	dfs();
    return 0;
}

Measured memory_bytes: 3112
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


X, Y, Z = list(map(int, sys.stdin.readline().split()))

X -= Z
X //= (Y + Z)
print(X)


Measured memory_bytes: 13668
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     int sx,sy,tx,ty;
     cin>>sx>>sy>>tx>>ty;
     string ans;
     string u,d,l,r;
     for(int i=0;i<(ty-sy);++i){
           u.push_back('U');
           d.push_back('D');
     }
     for(int i=0;i<(tx-sx);++i){
          l.push_back('L');
          r.push_back('R');
     }
     ans+=u+r+d+l+'D'+r+'R'+u+'U'+'L'+'U'+l+'L'+d+'D'+'R';
     cout<<ans<<endl;

}

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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.size()-1; i++)
    {
        if(s[i]==s[i+1]) {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }

        if(i<s.size()-2 && s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import sys
from bisect import bisect_left

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [(int(a) % K) - 1 for a in input().split()]
    sum_A = [0 for _ in range(N + 1)]

    count = 0
    modK = dict()
    modK[0] = [0]
    for i in range(N):
        sum_A[i + 1] = (sum_A[i] + A[i]) % K
        if sum_A[i+1] not in modK: modK[sum_A[i+1]] = [i + 1]
        else: modK[sum_A[i+1]].append(i+1)
    
    for key in modK: 
        lenK = len(modK[key])
        for i, a in enumerate(modK[key]):
            count += bisect_left(modK[key], a + K, i, lenK) - i - 1

    print(count)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 58648
#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>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;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)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
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=(ll)1e+18+1;
int INF=1e+9+1;
ll A[200001];
ll tasu[200001],hiku[200001];

int main(){
	int N;
	map<ll,ll> kosu;
	ll ans=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
	}
	rep(i,N){
		tasu[i]=i+A[i];
		hiku[i]=i-A[i];
		kosu[hiku[i]]++;
	}
	rep(i,N){
		kosu[hiku[i]]--;
		ans+=kosu[tasu[i]];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 31060
from sys import stdin
from sys import setrecursionlimit
import numpy as np
import math

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
a = list(map(int,stdin.readline().rstrip().split()))

a.sort()
a = np.array(a,dtype=np.int64)

low = 0
hi = 10**9
point = 0

while point <= 100:
    ave = (hi+low)/2
    if np.ceil(a//ave).sum() <= k:
        hi = ave
    else:
        low = ave
    point += 1

print(math.ceil(ave))

Measured memory_bytes: 49308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		for(int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		long max = array[0];
		long min = array[0];
		long sum = array[0];
		for(int i = 1; i < n; i++) {
			if(max < array[i]) {
				max = array[i];
			}
			if(min > array[i]) {
				min = array[i];
			}
			sum += array[i];
		}
		System.out.printf("%d %d %d\n", min, max, sum);
		sc.close();
	}
}



Measured memory_bytes: 41044
#include <stdio.h>
#include <string.h>

int n ;
int s ;
int ans ;
int sum ;
bool vis[12] ;

void init ( ) ;
void DFS ( int source , int k ) ;

int main ( )
{
	while ( scanf ( "%d %d" , &n , &s ) == 2 ) {
		if ( n == 0 && s == 0 ) break ;
		init ( ) ;
		DFS ( 0 , 0 ) ;
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void init ( )
{
	memset ( vis , false , sizeof ( vis ) ) ;
	ans = 0 ;
	sum = 0 ;
}

void DFS ( int source , int k )
{
	if ( source == n ) {
		if ( sum == s ) {
			ans++ ;
		}
		return ;
	}
	for ( int i = k ; i <= 9 ; i++ ) {
		if ( vis[i] == false ) {
			vis[i] = true ;
			sum += i ;
			DFS ( source + 1 , i ) ;
			vis[i] = false ;
			sum -= i ;
		}
	}
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    string S;
    int ans=2; // =2 para que ans não inicie com valor 1

    cin >>S;

    for(int i=0; i<S.size()-1; i++){     
        if (S[i]==S[i+1]){
            ans=1;
            break;
        }
    }
    if (ans==1){
        cout << "Bad";
    } else {
        cout << "Good";
    }
}

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

#define ll long long int
#define loop(a,b,c) for(ll a=b; a<c; a++)
#define eloop(a,b,c) for(ll a=b; a<=c; a++)
#define nl prllf("\n");

using namespace std;

int main(){
    ll T = 1; //cin >> T;
    while(T--){
        ll n; cin >> n; 
      //  vector<ll> v(n);
        ll t = n;
        bool flag = false;
        while(t){
            int d = t % 10;
            if(d==7){
                flag = true;
                break;
            }
            t = t /10;

        }
        if(flag)cout <<"Yes" << endl;
        else cout <<"No" << endl;
        


        
        
        

    }
}
/*

*/

Measured memory_bytes: 3636
#include<stdio.h>
#include<math.h>
int h, m, s, S;
int main(){
    scanf("%d", &S);
    h = S / 3600;
    m = fmod(S,3600) / 60;
    s = fmod(fmod(S, 3600), 60);
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long fA = 0;
    long ans = 0;
    for (int cnt = 0; cnt < n; cnt++) {
      long a = Long.parseLong(sc.next());
      long dai = 0;
      if (fA > a) {
        dai = (fA - a);
        ans += dai;
      }
      fA = a + dai;
    }
    System.out.println(ans + "");
    sc.close();
  }
}

Measured memory_bytes: 58592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	auto solve = [&](string s){
		int N = s.size();
		int res = 0;
		rep1(i,N-1) if(s[i] == s[i-1]){
			s[i] = '>';
			res++;
		}
		return res;
	};
	
	string s;ll K;
	cin >> s >> K;
	if(K%2 == 0){
		ll a2 = solve(s+s);
		ll a4 = solve(s+s+s+s);
		cout << a2 + (a4-a2) * (K-2)/2;
	}else{
		ll a1 = solve(s);
		ll a3 = solve(s+s+s);
		cout << a1 + (a3-a1) * (K-1)/2;
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e18;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 061 D / Link: http://abc061.contest.atcoder.jp/tasks/abc061_d  ----- */

struct Edge {
	int to; LL cost;
	Edge(int t, LL c = 0) : to(t), cost(c)
	{}
	bool operator>(const Edge& rhs) const {
		return cost > rhs.cost;
	}
	bool operator<(const Edge& rhs) const {
		return cost < rhs.cost;
	}

};
using Graph = vector< vector<Edge> >;

bool BellmanFord(const Graph& G, vector<LL>& d, int s) {
	const int V = G.size();
	for (int i = 0; i < V; ++i)
		d[i] = LINF;
	d[s] = 0;

	for (int lp = 0; lp <= V; ++lp) {
		for (int i = 0; i < V; ++i) {
			for (const auto& e : G[i]) {
				if (d[i] != LINF && d[e.to] > d[i] + e.cost) {
					d[e.to] = d[i] + e.cost;
					if (lp == V && e.to == V - 1)return true;
				}
			}
		}
	}
	return false;
}

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

	LL N, M; cin >> N >> M;
	Graph G(N);
	FOR(i, 0, M) {
		LL a, b, c; cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(Edge(b, -c));
	}
	VL dist(N);
	bool find_loop = BellmanFord(G, dist, 0);
	if (find_loop) {
		cout << "inf" << endl;
	}
	else {
		cout << -dist.back() << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[114514];
int main(){
    int n;
    cin>>n;
    int sum=0;
    int sam=0;
    for(int j=0;j<n;j++){
        cin>>a[j];
    }
    for(int i=0;i<n;i++){
        if(a[i]%4==0){
            sum++;
        }
        else if(a[i]%2==0){
            sam++;
        }
    }
    if(n%2==1){
        if(sum==(n-1)/2){
            cout<<"Yes"<<endl;
        }
        else if(sum*2+sam>=n){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        if(sum*2+sam>=n){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

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

#define REP(i,n) for(ll i=0 ; i<ll(n) ; i++)
#define ALL(x) x.begin(),x.end()

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

    int l;
    vector<int> ls(n);
    REP(i,n) cin >> ls[i];

    sort(ALL(ls));
    ll ans = 0;
    for( int i = 0 ; i < n-2 ; i++ ){
        for ( int j = i+1 ; j < n-1 ; j++ ){
            ll cnt = 0;
            cnt = lower_bound(ls.begin()+j+1, ls.end(), ls[i]+ls[j]) - (ls.begin()+j+1);
            ans += cnt;
        }
    }
    cout << ans << endl;

}

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

#define MOD 1000000007LL

long long dp[110][101010];

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	
	dp[0][0]=1;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=K;j++){
			dp[i+1][j]+=dp[i][j];
			dp[i+1][min(j+a[i],K)+1]-=dp[i][j];
		}
		for(int j=0;j<K;j++){
			dp[i+1][j+1]+=dp[i+1][j];
		}
		for(int j=0;j<K;j++){
			dp[i+1][j+1]%=MOD;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

Measured memory_bytes: 79360
/*
“Being happy doesn't mean that everything is perfect.
It means that you decided to look beyond the imperfections.”
*/

#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;


#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define ii pair<int,int>
#define fr(i,x,n) for(i = x ; i< n ; i++)
#define f(i,n) for(i = 0 ; i< n ; i++) 
#define ff first
#define ss second
#define pb push_back
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
void solve();



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
//	freopen("input.txt", "r",stdin);
//	freopen("output.txt", "w", stdout);
    solve();
    return 0;
}



int i, j, k, l, n, a, c, nn, t, dot=0, toko=0, x, y, z;


void solve()
{
    // cin>>t;f(nn,t)
    {
        cin >> x ;
        for(i=int(sqrt(x));i>=1;i--)
        {
            if(x%i==0)
            {
                cout << (i+(x/i)-2);
                exit(0);
            }
        } 
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<queue>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
#define MAX_V 2*100000+10

using namespace std;



bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli k, n, m, e;


int main() {
	cin >> n;
	vector<lli>vec(n),vec2(n);
	rep0(i, n) {
		cin >> vec[i];
		vec2[i] = vec[i];
	}
	sort(all(vec2));
	int ans = 0,temp=0;
	rep0(i, n) {
		if (vec2[i] != vec[i])ans++;
	}
	if (ans == 2||ans==0)cout << "YES";
	else cout << "NO";
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
using namespace std;


int main(){

  int w, n;
  cin >> w >> n;

  vector<int> ans(w);
  for(int i=0; i<w; i++) ans[i] = i+1;

  for(int i=0; i<n; i++){
    int a, b;
    scanf("%d,%d",&a, &b);
    // cin >> a >> b;
    int tmp = ans[ a-1 ];
    ans[ a-1 ] = ans[ b-1 ];
    ans[ b-1 ] = tmp;
  }

  for(int i=0; i<w; i++){
    cout << ans[i] << endl;
  }


  return 0;
}














// EOF

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,M;
    cin>>N>>M;
    vector<vector<int>> s(M);
    vector<int> k(M);
    vector<int> p(M);
    rep(i,M){
        cin>>k[i];
        rep(j,k[i]){
            int _s;
            cin>>_s;
            _s--;
            s[i].push_back(_s);
        }
    }
    rep(i,M)cin>>p[i];
    auto check = [&](int swc){
        bool f = true;
        rep(i,M){
            int cnt = 0;
            rep(j,k[i]){
                if((swc>>s[i][j])&1){
                    cnt++;
                }
            }
            if(p[i]%2 != cnt%2){
                f = false;
            }
        }
        return f;
    };

    int ans = 0;
    for(int swc = 0; swc < (1<<N);swc++){
        if(check(swc))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<assert.h>
#include<tuple>
#include<string>
#include<algorithm>
#include<iostream>
#include<map>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 1 << 20;
const int MM = 1000000007;

int solve(int A, int B){
	if( A <= B ) return B-A;
	else return 2e9+10;
}

int main()
{
	int A, B;
	scanf("%d%d", &A, &B);
	printf("%d\n", min({
		solve(A, B), 
		solve(A, -B)+1,
		solve(-A, B)+1,
		solve(-A, -B)+2,
	}));
}


Measured memory_bytes: 256
N,M = list(map(int,input().split()))

lac = [0]*(N+1)
lpcnt = [0]*(N+1)

for i in range(M):
  s = input().split()
  n = int(s[0])
  if s[1] == "AC":
    lac[n] =1
    continue
  if s[1] == "WA" and lac[n] == 0:
    lpcnt[n] += 1

cnt = 0
for i in range(N+1):
  if lac[i] == 1:
    cnt += lpcnt[i]
  
print(sum(lac), end=" ")
print(cnt)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <sstream>
#include <string>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=100001;
bool vis[N];
vector <int> adj[N];
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
// ll binaryNum[64];
// void decToBinary(ll n, ll k) 
// { 
//     // binaryNum[64]={0};
//     rep(i,64){
//         binaryNum[i]=0;
//     }
//     int i = 0; 
//     while (n > 0) { 
//         binaryNum[i] = n % k; 
//         n = n / k; 
//         i++; 
//     } 
// }
// ll dp[2001][2001]; 
// ll countPartitions(ll n, ll k) 
// {   
//     if (n < k) 
//         return 0;
//     if (n < 2 * k) 
//         return 1; 
//     if (dp[n][k] >= 0) 
//         return dp[n][k]; 
//     ll answer = 1; 
//     for (int i = k; i < n; i++) 
//         answer = answer + countPartitions(n - i, k); 
//     dp[n][k] = answer%mod; 
//     return answer%mod; 
// } 


void solve(){
    string s;
    cin>>s;
    ll n = s.length();
    if(s[n-1]=='s'){
        s.pb('e');
        s.pb('s');
    }
    else{
        s.pb('s');
    }
    cout<<s;
}


int main()
{

    // cout<<1<<endl;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 6196
#include<iostream>
int main()
{
  int value[] = {0, 6000, 4000, 3000, 2000};
  for(int i = 0; i < 4; i++)
  {
    int a, b;
    std::cin >> a >> b;
    std::cout <<  value[a] * b << std::endl;
  }
}

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

int main()
{
    int N;
    ll buf;
    cin >> N;
    ll sum = 1;
    bool flag = false;
    bool zeroflag = false;
    for (int i = 0; i < N; i++)
    {
        cin >> buf;
        if (buf == 0)
        {
            zeroflag = true;
        }
        if (flag == false)
        {
            if (sum  > 1000000000000000000 / buf)
            {
                flag = true;
            }
            sum = sum * buf;
        }
    }

    if (zeroflag)
    {
        cout << 0 << endl;
    }
    else if (flag)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
N = int(input())

intList = list(map(int, input().split()))
intList.sort()

cntList = [1] * (intList[-1] + 1)

i = 0
j = 1
ans = 0

while i < (N - 1):
  base = intList[i]
  j = 1
  num = base
  if cntList[num] == 1:
    while num <= intList[-1]:
      if cntList[num] == 1:
        cntList[num] = 0
      j += 1
      num = base * j
    if intList[i] != intList[i+1]:
      ans += 1
  i += 1

if cntList[intList[-1]] == 1:
  ans += 1
  
print(ans)

Measured memory_bytes: 32044
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(1,len(arr)):
		if arr[i]>arr[i-1]:
			arr[i]-=1
		elif arr[i]<arr[i-1]:
			print("No")
			return
	print("Yes")
	return


main()


# 1 2 3 4 5
# 1 3 3 4 5
# 1 4 3 4 5 


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll R[105], B[105];
bool U[105];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> R[i].first >> R[i].second;
    }
    REP(i, N)
    {
        cin >> B[i].first >> B[i].second;
    }
    sort(B, B + N, [](pll a, pll b) { return a.first < b.first; });

    int sum = 0;
    REP(i, N)
    {
        int index = -1;
        REP(j, N)
        {
            if (U[j])
                continue;
            if (R[j].first >= B[i].first || R[j].second >= B[i].second)
                continue;

            if (index == -1)
                index = j;
            else
            {
                if (R[index].second < R[j].second)
                    index = j;
            }
        }
        if (index >= 0)
        {
            U[index] = true;
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[100] = {0};
int main()
{
    int i, n,flag=0;
    scanf("%d", &n);
    for(i=0 ; i<n ; i++){
        scanf("%d", &a[i]);
    }

    for(i=0; i<n; i++){
        if (a[i]%2==0)
            if (a[i]%3)
                if (a[i]%5)
                    flag=1;
        if(flag!=0)
            break;
    }
    if(flag==0)
        printf("APPROVED");
    else
        printf("DENIED");

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>

using namespace std;

const int mn = 6400;
const int ms = mn * 2 + 1;

int idx(int x) {
	return x + mn;
}
int val(int x) {
	return x - mn;
}
int valid(int x) {
	return (x > 0 && x < ms);
}

int main() {
	int h, w;
	int **a, **b;
	cin >> h >> w;
	a = new int*[h];
	b = new int*[h];
	for (int i = 0; i < h; ++i) {
		a[i] = new int[w];
		for (int j = 0; j < w; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h; ++i) {
		b[i] = new int[w];
		for (int j = 0; j < w; ++j) {
			cin >> b[i][j];
		}
	}
	bool ***f = new bool**[h];
	for (int i = 0; i < h; ++i) {
		f[i] = new bool*[w];
		for (int j = 0; j < w; ++j) {
			f[i][j] = new bool[mn * 2 + 1];
			for (int k = 0; k <= mn * 2; ++k) {
				f[i][j][k] = 0;
			}
		}
	}
	/*set<int> **vvs = new set<int>*[h];
	for (int i = 0; i < h; ++i) {
		vvs[i] = new set<int>[w];
		for (int j = 0; j < w; ++j) {
			vvs[i][j].clear();
		}
	}*/
	int d0 = a[0][0] - b[0][0];
	/*vvs[0][0].insert(d0);
	vvs[0][0].insert(-d0);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int dd = a[i][j] - b[i][j];
			if (i >= 1) {
				for (set<int>::iterator ii = vvs[i - 1][j].begin(); ii != vvs[i - 1][j].end(); ++ii) {
					vvs[i][j].insert((*ii) + dd);
					vvs[i][j].insert((*ii) - dd);
				}
			}
			if (j >= 1) {
				for (set<int>::iterator ii = vvs[i][j - 1].begin(); ii != vvs[i][j - 1].end(); ++ii) {
					vvs[i][j].insert((*ii) + dd);
					vvs[i][j].insert((*ii) - dd);
				}
			}
		}
	}*/
	f[0][0][d0 + mn] = f[0][0][mn - d0] = 1;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int dd = a[i][j] - b[i][j];
			for (int k = 0; k < ms; ++k) {
				if (i - 1 >= 0) {
					if (valid((k - dd)) && f[i - 1][j][k - dd]) {
						f[i][j][k] = 1;
					}
					if (valid((k + dd)) && f[i - 1][j][k + dd]) {
						f[i][j][k] = 1;
					}
				}
				if (j - 1 >= 0) {
					if (valid((k - dd)) && f[i][j - 1][k - dd]) {
						f[i][j][k] = 1;
					}
					if (valid((k + dd)) && f[i][j - 1][k + dd]) {
						f[i][j][k] = 1;
					}
				}
				if (f[i][j][k]) {
				//	cout << i << ' ' << j << ' ' << k << endl;
				}
			}
		}
	}
	int res = h * w * 160;
	/*for (set<int>::iterator ii = vvs[h - 1][w - 1].begin(); ii != vvs[h - 1][w - 1].end(); ++ii) {
		if (abs(*ii) < res) {
			res = abs(*ii);
		}
	}*/
	for (int i = 0; i < ms; ++i) {
		if (f[h - 1][w - 1][i]) {
			res = min(res, abs(val(i)));
		}
	}
	cout << res << endl;
	return 0;
}

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

using u64 = std::uint64_t;
constexpr u64 inf = std::numeric_limits<u64>::max();

#define REP(i, n) for (u64 i = 0; i < (n); ++i)

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline u64 scan() {
    u64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
  constexpr int os = 1 << 17;
  char ob[os], *op = ob, ot;
  inline void putc(const char c) {
    *op++ = c;
    if (op == ob + os) { write(STDOUT_FILENO, ob, os); op = ob; }
  }
  /* x shoud be greater than or equal to zero */
  inline void print(u64 x) {
    char d[20];
    int i = 0;
    while (true) {
      d[i] = x % 10 + 48;
      x /= 10;
      ++i;
      if (x <= 0) break;
    }
    while (i--) {
      putc(d[i]);
    }
  }
  inline void flush() {
    write(STDOUT_FILENO, ob, op - ob);
  }
}

signed main() {
  u64 n = io::scan();
  auto G = vector<vector<u64>>(n);
  auto H = vector<u64>(n);
  REP(i, n - 1) {
    u64 a = io::scan() - 1;
    u64 b = io::scan() - 1;
    G[a].push_back(i);
    G[b].push_back(i);
    H[i] = a ^ b;
  }
  u64 m = io::scan();
  auto paths = vector<u64>(m);
  auto collect = [&G, &H](auto collect, u64 u, u64 v, u64 p) -> u64 {
    if (u == v) return 0;
    for (auto e : G[u]) {
      u64 t = H[e] ^ u;
      if (t == p) continue;
      u64 s = collect(collect, t, v, u);
      if (s != inf) {
        return s | (1ULL << e);
      }
    }
    return inf;
  };
  REP(j, m) {
    u64 u = io::scan() - 1;
    u64 v = io::scan() - 1;
    paths[j] = collect(collect, u, v, -1);
  }
  auto search = [&paths](auto search, u64 ans, u64 j, u64 m, u64 mask) -> u64 {
    if (j != m) {
      return (
        search(search, ans, j + 1, m, mask)
      - search(search, ans, j + 1, m, mask | paths[j])
      );
    } else {
      return ans >> __builtin_popcountll(mask);
    }
  };
  u64 ans = search(search, 1ULL << (n - 1), 0, m, 0);
  io::print(ans);
  io::flush();
}


Measured memory_bytes: 256
import math
import numpy as np
a,b,h,m = list(map(int, input().split()))
s1 = h * 30
s2 = m * 6
s1 = s1 + 30 * m / 60
s3 = abs(s2-s1)
if(s3 > 180):
  s3 = 360 - s3

e = (a * a) + (b * b) - (2 * a * b * np.cos(math.pi * s3/180))
ans=e ** 0.5
print('{:.9f}'.format(ans))

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

int N, M, Q;
vector<long long> a,b,c,d;

long long score(vector<int> A){
    long long score=0;
    for(int i=0;i<Q;i++){
        if(A[b[i]]-A[a[i]]==c[i])score+=d[i];
    }
    return score;
}


long long depthFirstSearch(vector<int>& A){
    long long res=0;
    if(A.size()==N){
        return score(A);  
    }    
    int prev_last=(A.empty()?0:A.back());
    for(int i=prev_last;i<M;i++){
        A.emplace_back(i);
        res=max(depthFirstSearch(A),res);
        A.pop_back();
    }
    return res;
}

int main(){
    cin>>N>>M>>Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    for(int i=0;i<Q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        --a[i];
        --b[i];
    }
    vector<int> A;
    cout<<depthFirstSearch(A);
    return 0;
}

Measured memory_bytes: 3632
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    double av=0;
    vector<P> a(n);
    rep(i,n) {
        int x, y;
        cin >> x >> y;
        a[i] = P(x, y);
    }
    vector<int> b;
    rep(i,n){
        b.pb(i);
    }
    int nnn=1;
    int c=n;
    for(int i=0;i<c;i++){
        nnn*=n;
        n--;
        //cout<<nnn<<endl;
    }
    //debug(nnn);
    int past;
    for(int i=0;i<nnn;++i){
        int cnt=0;
        for(auto &now : b){
            if(cnt!=0){
                int memo=0;
                memo+=pow((a[now].fs-a[past].fs),2);
                memo+=pow((a[now].sc-a[past].sc),2);
                av+=sqrt(memo);
            }
            past=now;
            cnt++;
        }
        next_permutation(all(b));
    }
    cout<<av/nnn<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>

using namespace std;

std::mt19937 generator;
int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans1 = -1;
    int ans2 = -1;

    for (int ai = 0; ai * 100 <= f; ai += a) {
        for (int bi = 0; bi * 100 + ai * 100 <= f; bi += b) {
            int water = bi * 100 + ai * 100;
            for (int ci = 0; water + ci * c <= f; ci++) {
                for (int di = 0; di * d + water + ci * c <= f; di++) {
                    int sugar = di * d + ci * c;
                    if (sugar * 100 > e * water) {
                        continue;
                    }
                    if (water && (ans1 == -1 || ans1 * (sugar + water) < (ans1 + ans2) * sugar)) {
                        ans1 = sugar;
                        ans2 = water;
                    }
                }
            }
        }
    }
    cout << ans1 + ans2 << " " << ans1 << endl;

    return 0;
}


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

signed main(){
  int n; cin >> n;
  vector<ll> a(n), b(n);
  ll ans;
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
  if(n % 2 == 1){
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ans = b[n/2] - a[n/2] + 1;
  }
  if(n % 2 == 0){
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll x = a[n/2-1] + a[n/2];
    ll y = b[n/2-1] + b[n/2];
    ans = y - x + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6436
<?php
  fscanf(STDIN, "%d", $n);
  $aa = fgets(STDIN);
  $a = explode(' ', $aa);

  foreach($a as $num) {
    if(0 === (int) $num) {
      echo 0;
      exit;
    }
  }

  $ans = 1;
  foreach($a as $num) {
    $ans = $ans * (int) $num;
    if($ans > pow(10, 18)) {
      echo -1;
      exit;
    }
  }
  echo $ans;

Measured memory_bytes: 25588
#include <stdio.h>
#include <stdlib.h>
int main(){
	int W,H,N;
	int a[100],x[100],y[100];
	scanf("%d %d %d",&W,&H,&N);
	int i;
	for(i=0;i<N;i++){
		scanf("%d %d %d",&x[i],&y[i],&a[i]);
	}
	int x1=0,x2=W,y1=0,y2=H;
	for(i=0;i<N;i++){
		switch(a[i]){
		case 1:
			if(x1<x[i])
				x1=x[i];
			break;
		case 2:
			if(x2>x[i])
				x2=x[i];
			break;
		case 3:
			if(y1<y[i])
				y1=y[i];
			break;
		case 4:
			if(y2>y[i])
				y2=y[i];
			break;
		default:break;
		}
	}
	int w,h;
	w = x2>=x1 ? x2-x1 :0;
	h = y2>=y1 ? y2-y1 : 0; 
	printf("%d\n",w*h);
	return 0;
}


Measured memory_bytes: 128
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    long h = sc.nextLong();
    long w = sc.nextLong();

    long ret;
    if (h == 1 || w == 1) {
      System.out.println(1);
      return;
    }

    if (h % 2 == 0 || w % 2 == 0) {
      ret = (h * w) / 2;
    } else {
      ret = new BigDecimal(h).multiply(new BigDecimal(w)).divide(new BigDecimal(2), RoundingMode.UP).longValue();
    }
    System.out.println(ret);
  }
}


Measured memory_bytes: 23124
#include<stdio.h>

int main(){    
  int answer = 0;

  int max = 0;

  int an[6];
  for(int i=0; i<5; i++){
      scanf("%d", &an[i]);
      int wait = 10 - an[i]%10;
      if(wait==10){
        wait = 0;
      }
      if(max < wait)
        max = wait;
      answer += an[i] + wait;
  }

  answer -= max;

  printf("%d\n", answer);

  
  
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

up = False
down = False
ans = 1

for i in range(1, n):
    if up:
        if a[i] < a[i-1]:
            ans += 1
            up = False
    elif down:
        if a[i] > a[i-1]:
            ans += 1
            down = False
    else:
        if a[i] > a[i-1]:
            up = True
        elif a[i] < a[i-1]:
            down = True

print(ans)

Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int ans =0;
  for(int i= 0;i<n;i++){
    int maxhi ;
    int h;
    cin >> h;
    if( maxhi<= h){
      maxhi = h;
      ans +=1;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
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()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n - 1]
    }
    let mut p = vec![0; n];
    for i in v {
        p[i - 1] += 1;
    }
    for i in p {
        println!("{}", i);
    }
}


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

using namespace std;

int main()
{

    int A, B;
    cin >> A >> B;
    float minA, maxA, minB, maxB, minP, maxP;
    minA = A / 0.08;
    maxA = (A + 1) / 0.08;
    minB = B / 0.1;
    maxB = (B + 1) / 0.1;
    minP = max(minA, minB);
    maxP = min(maxA, maxB);

    int ans = ceil(minP);
    if(ans >= maxP){
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    int x,y,z;
    Scanner sc = new Scanner(System.in);
    
    x = sc.nextInt();
    y = sc.nextInt();
    z = sc.nextInt();
    
    System.out.println(z);
    System.out.println(x);
    System.out.println(y);
  }
}
    

Measured memory_bytes: 21844
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a == b {
		fmt.Println(a + b)
	} else if a > b {
		fmt.Println(a*2 - 1)
	} else {
		fmt.Println(b*2 - 1)
	}
}


Measured memory_bytes: 512