akhauriyash/Code-Regression huggingface dataset:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, x, y = map(int, input().split())
    ans = [0]*(n-1)
    for i in range(n-1):
        for j in range(i + 1, n):
            if j < x - 1 or y - 1 < i:
                distance = j - i
            else:
                distance = min(j - i, abs(x - 1 - i) + abs(y - 1 - j) + 1)
            ans[distance - 1] += 1
            
    for i in range(n - 1):
        print(ans[i])

if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 14196
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using ll = long long;
using namespace std;
int main(){
    int a,b,c,x,y;
    cin >>a >>b >>c >> x >> y;
    long long count=0;
    if(c*2<a+b){
        count += min(x,y)*c*2;
    }else{
        cout<<a*x+b*y<<endl;
        return 0;
    }
    if(x-min(x,y)>0){
        count += min((x-min(x,y))*a,(x-min(x,y))*c*2);
    }else{
        count += min((y-min(x,y))*b,(y-min(x,y))*c*2);
       // cout<<min((y-min(x,y))*b,(x-min(x,y))*c*2)<<endl;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std; 
using namespace __gnu_pbds;
#define pb push_back
#define int long long
#define m_p make_pair
#define pair pair<int,int> 
//#define M 998244353
#define M 1000000007
const int inf=4e18;
const int MX=100;
const int MN=-100;
const double pi=3.14159265358979;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int h,w;cin>>h>>w;
	int i,j,k,n=h*w;
	int adj[n+1][n+1];memset(adj,0,sizeof(adj));
	string s[h];
	for(i=0;i<h;i++)
		cin>>s[i];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			adj[w*i+j+1][w*i+j+1]=1;
			if(s[i][j]=='#')
				continue;
			if(j>0)
				if(s[i][j-1]=='.')
					adj[w*i+j+1][w*i+j]=1;
			if(j<w-1)
				if(s[i][j+1]=='.')
					adj[w*i+j+1][w*i+j+2]=1;
			if(i>0)
				if(s[i-1][j]=='.')
					adj[w*i+j+1][w*(i-1)+j+1]=1;
			if(i<h-1)
				if(s[i+1][j]=='.')
					adj[w*i+j+1][w*(i+1)+j+1]=1;
		}
	}
	int distance[n+1][n+1],o=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i==j)
				distance[i][j]=0;
			else if(adj[i][j])
				distance[i][j]=adj[i][j];
			else
				distance[i][j]=inf;
		}
	}
	for(k=1;k<=n;k++)
		for(i=1;i<=n;i++)
			for(j=1;j<=n;j++)
				distance[i][j]=min(distance[i][j],distance[i][k]+distance[k][j]);
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(distance[i][j]!=inf)
				o=max(o,distance[i][j]);
	cout<<o<<endl;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
int a,b,c;cin>>a>>b>>c;
int k;cin>>k;
for(int i=0;i<=k;i++){
    for(int j=0;j<=k-i;j++){
        for(int h=0;h<=k-i-j;h++){
            int an=a;int bn=b;int cn=c;
            if(i!=0){
                rep(d,i)an=an*2;
            }
            if(j!=0){
                rep(d,j)bn=bn*2;
            } 
            if(h!=0){
                rep(d,h)cn=cn*2;
            } 
            if((an<bn)&&(cn>bn)){
                if(i!=0||j!=0||h!=0){
                cout<<"Yes"<<endl;
                return 0;
                }
            }
        }
    }
}
cout<<"No"<<endl;


return 0;
 }


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll dp[10000005];
bool prime[10000005];
ve<ll> a;
 
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=0;
    prime[0]=0;
    for (int p=2; p*p<=10000000; p++) 
        if (prime[p]) 
            for (int i=p*p; i<=10000000; i += p) 
                prime[i] = false; 
} 
 
ll countDivisors(ll n) 
{ 
    if (n == 1) 
        return 1; 
    ll ans = 1;
    for (ll i = 0;; i++) 
    { 
        if (a[i] * a[i] * a[i] > n) 
            break; 
        ll cnt = 1; 
        while (n % a[i] == 0)  
        { 
            n = n / a[i]; 
            cnt = cnt + 1;  
        } 
        ans = ans * cnt; 
    } 
    
    if (prime[n]) 
        ans = ans * 2; 
        
    else if (n == ((ll)sqrt(n))*((ll)sqrt(n)) && prime[(ll)sqrt(n)]) 
        ans = ans * 3; 
        
    else if (n != 1) 
        ans = ans * 4; 
        
    return ans; 
} 

int main() 
{
    FAST;
    SieveOfEratosthenes();
    for(int i=2;i<10000001;i++)
        if(prime[i])
            a.pb(i);
    dp[1]=1;
    for(int i=2;i<10000001;i++)
        dp[i]=i*(countDivisors(i));
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=dp[i];
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 96444
#include<bits/stdc++.h>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
typedef pair<int , int > pii;
#define MOD 1000000007
#define MOD1 998244353
#define ff first
#define ss second
#define bn cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define sz(a) (a).size()
#define o(a) cout << a
#define MAX6 1000006
#define int ll
#define all(x) x.begin(), x.end()
#define ppii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define viii vector<ppii>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define MAX5 300005
#define MAX7 10000007
#define rep(i,a,b)  for (__typeof((b)) i=(a);i<=(b);i++)
#define nrep(i,b,a)  for (__typeof((b)) i=(b);i>=(a);i--)
#define mem(a) memset(a,0,sizeof(a))
#define memneg(a) memset(a,-1,sizeof(a))
//#define se second
#define LN 14
#define LIM 22
#define MAX_ALPHA 26
const long long INF64 = 1e18;
const ll INF = 1e9;
const double PI = acos(-1);
#define ld long double
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline void max_self(ll &a, ll b)
{
  a = max(a,b);
}
 
inline void min_self(ll &a,ll b)
{
  a = min(a,b);
}
 
inline void add_self(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
inline void sub_self(int &a, int b) {
  a -= b;
  if (a < 0) a += MOD;
}
 
inline int mul(int a, int b) {
  return (int) ( a * b % MOD);
}
 
 
ll gcd(ll a,ll b)
{
  if(b == 0)
    return a;
  else 
    return gcd(b, a%b);
}
 
 
int countDigits(int x)
{
  int cnt = 0;
  while(x)
  {
    x /= 10;
    cnt++;
  }
  return cnt;
}
 
 
ll binExpo(ll a,ll b)
{
  ll res = 1;
  while(b)
  {
    if(b&1)
      res = (res * a)%MOD;
    a = (a * a)%MOD;
    b /= 2;
  }
  return res%MOD;
}
 
int sum(int a) {
    int result = 0;
    while (a > 0) {
        result += a % 10;
        a /= 10;
    }
    return result;
}

void solve(){

  int n;
  cin>>n;
  vector<int > h(n), a(n);

  rep(i, 0, n-1)
    cin>>h[i];
  rep(i, 0, n-1)
    cin>>a[i];

  int base = 1;
  while(base <= n)
    base *= 2;

  vector<int > tree(2 * base);

  vector<int > dp(n + 1);

  rep(flower, 0, n-1)
  {
    int x = base + h[flower];
    int best = 0;
    while(x > 1){
      if(x & 1)
        max_self(best, tree[x-1]);
      x /= 2;
    }
    dp[h[flower]] = best + a[flower];

    for(x = base + h[flower]; x >= 1;x /= 2)
      max_self(tree[x], dp[h[flower]]);
  }
  int mx = -1;
  rep(i, 0, n)
    max_self(mx, dp[i]);
  cout<<mx<<endl;
}


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

  int t = 1;
  //cin>>t;
  while(t--) solve();
  return 0;
}















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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){

    int n, k;
    cin >> n >> k;
    vector<ll> v(200000);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        v[a]++;
    }
    ll ans = 0;
    sort(v.rbegin(), v.rend());
    for(int i = k; i < (int)v.size(); i++){
        if(v[i] == 0) break;
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4848
#include<stdio.h>
#include<string.h>
int F[101][101],N,W,H,w,h,i,j,k,l,t,r;
int main()
{
	for(;scanf("%d%d%d",&N,&W,&H),N;)
	{
		memset(F,0,sizeof(F));
		for(i=0;i<N;i++)
		{
			scanf("%d%d",&w,&h);
			F[h][w]=1;
		}
		scanf("%d%d",&w,&h);
		for(i=1,r=0;i<=H-h+1;i++)
			for(j=1;j<=W-w+1;j++)
			{
				for(k=t=0;k<h;k++)
					for(l=0;l<w;l++)
						if(F[i+k][j+l])
							t++;
				r=r<t?t:r;
			}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
int main(void){
    int t,h,m,s;
    scanf("%d",&t);
    h = (t-(t%3600))/3600;
    t = t-(h*3600);
    m = (t-(t%60))/60;
    t = t -(m*60);
    s = t;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Objects;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSimpleKnapsack solver = new DSimpleKnapsack();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSimpleKnapsack {
        private static int n;
        private static int[] w;
        private static int[] v;
        private static final Map<DSimpleKnapsack.Key, Integer> dp = new HashMap<>();

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            dp.clear();
            n = in.nextInt();
            int wa = in.nextInt();
            w = new int[n];
            v = new int[n];
            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
                v[i] = in.nextInt();
            }
            out.println(calc(new DSimpleKnapsack.Key(0, wa)));
            // System.out.println(dp);
        }

        private int calc(DSimpleKnapsack.Key key) {
            if (key.index == n) {
                return 0;
            } else if (dp.containsKey(key)) {
                return dp.get(key);
            }
            int ans = calc(new DSimpleKnapsack.Key(key.index + 1, key.toughness));
            int nt = key.toughness - w[key.index];
            if (nt >= 0) {
                ans = Math.max(ans, calc(new DSimpleKnapsack.Key(key.index + 1, nt)) + v[key.index]);
            }
            dp.put(key, ans);
            return ans;
        }

        private static class Key {
            int index;
            int toughness;

            public Key(int index, int toughness) {
                this.index = index;
                this.toughness = toughness;
            }

            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                DSimpleKnapsack.Key key = (DSimpleKnapsack.Key) o;
                return index == key.index &&
                        toughness == key.toughness;
            }

            public int hashCode() {
                return Objects.hash(index, toughness);
            }

            public String toString() {
                return "Key(" +
                        index +
                        ", " + toughness +
                        ')';
            }

        }

    }
}



Measured memory_bytes: 56840
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for(int i = 0; i < n; i++){
        	int num = sc.nextInt();
            ans += num - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 40512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[105],i;
    vector<int>v;
    cin>>n;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
            v.push_back(a[i]);
    }
    for(int i=0; i<v.size(); i++)
    {
        if(v[i]%3!=0&&v[i]%5!=0)
        {
            cout<<"DENIED"<<endl;
            return 0;
        }

    }
    cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  for {
    h := nextInt()
    w := nextInt()
	if h == 0 && w == 0 {
		break
	}
	for i := 0; i < h; i++ {
		line := ""
		for j := 0 ; j < w; j++ {
			if i == 0 || i % 2 == 0 {
				if j == 0 || j % 2== 0 {
			      line += "#"
				} else {
			      line += "."
				}
			} else {
				if j == 0 || j % 2== 0 {
			      line += "."
				} else {
			      line += "#"
				}

			}
		}
		fmt.Println(line)
	}
	fmt.Println()
  }

}

func getStdin() (string) {
	sc.Scan()
	v := sc.Text()
	return v
}

func nextInt() (int) {
	sc.Scan()
	v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}

func nextFloat() (float64) {
	sc.Scan()
	v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}



Measured memory_bytes: 4152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	var N, D int
	fmt.Scan(&N, &D)
	var count int = 0

	for i := 0; i < N; i++ {
		a := readInt()
		b := readInt()

		if a*a+b*b <= D*D {
			count += 1
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 4952
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int dp[505][10010];
int INF=1e9+7;
int main(){
	int m,n,c[500],e[500];
	cin>>m>>n;
	vector<int>p(m);
	REP(i,m)cin>>p[i];
	sort(ALL(p));
	p.PB(0);
	reverse(ALL(p));
	REP(i,p.size()-1)p[i+1]+=p[i];
	REP(i,n)cin>>c[i]>>e[i];
	memset(dp,-1,sizeof(dp));
	REP(i,505)REP(j,10010)dp[i][j]=INF;
	dp[0][0]=0;
	REP(i,n){
		for(int j=0;j<=m;j++){
			int to=min(m,j+c[i]);
			dp[i+1][to]=min(dp[i+1][to],dp[i][j]+e[i]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
		for(int j=m;j>=1;j--){
			dp[i+1][j-1]=min(dp[i+1][j],dp[i+1][j-1]);
		}
	}
	int ans=0;
	REP(i,n+1){
		REP(j,m+1){
			ans=max(ans,p[j]-dp[i][j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    vector<int> a(m);
    int x=0;
    for(int j=0;j<m;j++){
      cin>>a[j];
      x+=a[j]*b[j];
    }
    if(x+c>0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn count_divx(x: usize, mut n: usize) -> usize {
    let mut r = 0;
    while n % x == 0 {
        r += 1;
        n /= x;
    }
    r
}

#[fastout]
fn main() {
    input! {
        n:usize,
        a:[f64;n]
    }
    let mut v = vec![];
    let mut table = vec![vec![0; 64]; 64];

    let mut ans = 0;
    let mut zero = 0;
    for (c, i) in a.iter().enumerate() {
        let buf = (i * 1000000000.0 + 0.2) as usize;
        if buf == 0 {
            ans += c;
            zero += 1;
        } else {
            let d2 = count_divx(2, buf);
            let d5 = count_divx(5, buf);
            v.push((d2, d5));
            ans +=
                table[if d2 > 18 { 0 } else { 18 - d2 }][if d5 > 18 { 0 } else { 18 - d5 }] + zero;
            for i in 0..=d2 {
                for j in 0..=d5 {
                    table[i][j] += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 9564
#include <bits/stdc++.h> 
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

ll mpow(ll a, ll b){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}

ll mpow(ll a, ll b, ll p){
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}

ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}

void solve(){
	ll a,b;
	cin >> a >> b;
	if((a+b)%2){
		cout << "IMPOSSIBLE" << ln;
	}
	else{
		cout << (a+b)/2 << ln;
	}
}

int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
        int a[106];
int main () {
	int N, K;
	cin >> N >> K;
	while (K--) {
		int d;
		cin >> d;
		for (int i=0; i<d; i++) {
            int x;
            cin >> x;
            a[x]+=d;
        }
	}
    int cnt=0;
    for (int i=1; i<=N; i++) {
        if (a[i]==0) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
# -*- coding: utf-8 -*-

# 入力
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())

for i in range(H):
    for j in range(W):

        # ボムはスキップ
        if S[i][j] == "#":
            continue

        # 検査対象のセルを格納する配列。初期値は現在対象のセル
        x_ary = [i]
        y_ary = [j]

        # 上下左右のセルについて存在確認
        if 0 <= i-1 and i-1 <= H-1:
            x_ary.append(i-1)
        if 0 <= i+1 and i+1 <= H-1:
            x_ary.append(i+1)
        if 0 <= j-1 and j-1 <= W-1:
            y_ary.append(j-1)
        if 0 <= j+1 and j+1 <= W-1:
            y_ary.append(j+1)

        # 周囲のボムの数のカウンター
        num_of_bombs = 0
        
        # ボムの数を数える
        for x in x_ary:
            for y in y_ary:
                if S[x][y] == "#":
                    num_of_bombs += 1

        # 文字列を置き換える
        s = list(S[i])
        s[j] = str(num_of_bombs)
        S[i] = ''.join(s)

# 表示
for i in range(H):
    print(S[i])


Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    long MOD = (long)Math.pow(10, 9) + 7;
    long[][] dp = new long[h + 1][w];
    dp[0][0] = 1;
    if(w != 1) {
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
        for(int t = 0; t < (int)Math.pow(2, w - 1); t++) {
          int[] m = new int[w - 1];
          int p = 0;
          for(int c = 0; c < w - 1; c++) {
            if((t & (1 << c)) != 0) m[c] = 1;
            if((c > 0) && ((m[c - 1] == 1) && (m[c] == 1))) p = 1; 
          }
          if(p == 0) { 
            if(j == 0) {
              if(m[0] == 1) {
                dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
              } else {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
              }
            } else if(j == (w - 1)) {
              if(m[w - 2] == 1) {
                dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
              } else {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
              }              
            } else {
              if(m[j - 1] == 1) {
                dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
              } else if(m[j] == 1) {
                dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
              } else {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
              }              
            }
          }
        }
      }
    }
    System.out.println(dp[h][k - 1]);
    } else {
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 27452
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        boolean nodec = true;
        for(int i=1; i<n; i++){
            if(a[i] <= a[i-1]) nodec = false;
        }
        if(nodec){
            System.out.println(1);
            return;
        }

        
        int m = 500;
        int l = 1, r = 210000;
        int mid = 2;
        int[] dec = new int[m];

        out: while(r-l > 1){
            mid = (l+r)/2;
            dec = new int[m];
            Arrays.fill(dec, 1);
            nout: for(int i=1; i<n; i++){
                if(a[i] <= a[i-1] && a[i]-1 < m){
                    if(dec[a[i]-1] < mid){
                        dec[a[i]-1]++;
                    }else{
                        int pos = a[i]-1;
                        
                        while(pos > 0){
                            dec[pos-1]++;
                            for(int j=pos; j<m; j++){
                                dec[j] = 1;
                            }
                            if(dec[pos-1] <= mid) continue nout;
                            pos--;
                        }
                        l = mid;
                        continue out;
                    }
                }else{
                    for(int j=a[i]-1; j<m; j++){
                        dec[j] = 1;
                    }
                }
            }
            r = mid;
        }

        System.out.println(r);
    }
}


Measured memory_bytes: 85744
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
import math
#print(a)
val=0
for i in range(n):
	for j in range(n):
		val+=math.sqrt((a[j][0]-a[i][0])**2+(a[j][1]-a[i][1])**2)
print(val/n)

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

using namespace std;

int main()
{
    char str[7];
    cin >> str ;
    //cout << str;

    if(str[2] == str[3] && str[4]==str[5])
    cout << "Yes"<< endl;
    else
    cout << "No" << endl;
    
}
    



Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    t = LI()
    u = LI()
    a = [inf] * n
    b = [inf] * n
    a[0] = 0
    b[0] = min(t[0],u[0])
    b[-1] = 0
    a[-1] = min(a[-1],t[-1],u[-1])
    for i in range(1,n):
        a[i] = min(a[i],b[i-1],u[i])
        b[i] = min(b[i],a[i]+t[i],u[i])
    for i in range(n-2,-1,-1):
        b[i] = min(b[i],a[i+1],u[i])
        a[i] = min(a[i],b[i]+t[i],u[i])
    r = 0
    for i in range(n):
        c = a[i]
        d = b[i]
        e = u[i]
        f = t[i]
        k = abs(c-d)
        m = max(c,d)
        l = min(m + (f-k) / 2.0,e)
        ct = l-c
        r += c*ct + ct*(l-c) / 2.0
        dt = l-d
        r += d*dt + dt*(l-d) / 2.0
        r += l * (f-ct-dt)

    return r


print(main())




Measured memory_bytes: 67052
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

char c;

int main(){
    INIT;
    cin >> c;
    if(c == 'A')cout << 'T' << endl;
    if(c == 'C')cout << 'G' << endl;
    if(c == 'G')cout << 'C' << endl;
    if(c == 'T')cout << 'A' << endl;
    
}

Measured memory_bytes: 256
N = gets.to_i
W = gets.split.map(&:to_i)

min_sa = Float::INFINITY
0.upto(N - 2) do |t|
  sum_l = W[0..t].inject(:+)
  sum_r = W[(t+1)..(N-1)].inject(:+)
  sa = (sum_l - sum_r).abs
  min_sa = sa if sa < min_sa
end

puts min_sa


Measured memory_bytes: 1788
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		int i=0;
		for(i=0;i<values.length;i++){
			values[i]=i+1;
		}
		for(i=0;i<n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0])-1;
			int b = Integer.parseInt(ab[1])-1;
			int temp;
			temp=values[a]; values[a]=values[b]; values[b]=temp;
		}
		for(i=0;i<values.length;i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 25832
def ballrobot(n , k , xl):

    ans = 0

    for i in xl:
        if k - i < i:
            ans += k - i
        else:
            ans += i

    return ans*2

def main():
    n = int(input())
    k = int(input())
    xl = list(map(int , input().split()))
    print(ballrobot(n , k , xl))

if __name__ == '__main__':
    main()

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    map<ll,ll> m;
    ll n;
    cin>>n;
    vl A(n);
    rep(i,n){
        cin>>A[i];
        m[A[i]]++;
    }
    ll res=0;
    rbf(p,m){
        if(p.first<p.second){
            res+=p.second-p.first;
        }else if(p.first>p.second){
            res+=p.second;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 10012
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_A
 */
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int
main()
{
    ios::sync_with_stdio(false);

    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << setprecision(10) << sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) << endl;
    return 0;
}

Measured memory_bytes: 3192
use proconio::input;

fn main() {
    input! {
        a: u64,
        b: u64,
    }

    let a_count = 
        if a > 0 {
            generate_vec(a-1)
        } else {
            vec![0; 64]
        };

    let b_count = generate_vec(b);

    let sum = a_count.into_iter()
        .zip(b_count.into_iter())
        .map(|(x, y)| (x + y) % 2)
        .collect::<Vec<_>>();

    let mut ans = 0;
    for i in 0..64 {
        let d = 1 << i;
        ans += d * sum[i];
    }

    println!("{}", ans);

}

fn generate_vec(a: u64) -> Vec<usize> {
    let mut v = vec![0; 64];
    for i in 0..64 {
        let mut num = 0;
        let d = 1 << i;
        let div = (a + 1) / d;
        if div % 2 == 1 {
            num += (a + 1) % d;
        }
        num += d * (div / 2);
        v[i] = num as usize; //(num % 2) as usize;
    }
    v
}

Measured memory_bytes: 2152
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    
    int x = 1, y = 1;
    rep(i, n) {
        x *= 3;
        int a;
        cin >> a;
        if(a%2 == 0) {
            y *= 2;
        }
    }

    cout << x - y << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();

		for(int i = 0; i <= N; i++) {
			for(int j = 0; j + i <= N; j++) {
				int k = N - i - j;
				if(k < 0) continue;
				if(10*i+5*j+k == (Y/1000)) {
					System.out.println(i + " " + j + " " + k);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

}

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

int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};
string s = "RDLU";

#define inRange(x,a,b) (a <= x && x < b)

int main(){
    char mat[9][5];
    for(int i = 0; i < 9; i++){
        for(int j = 0; j < (i%2 == 0 ? 4 : 5); j++){
            cin >> mat[i][j];
        }
    }

    int i = 0, j = 1, dir = 0;
    string ans = "R";
    
    while(1){
        if(i == 0 && j == 0)    break;
        
        if(dir % 2 == 0){
            int ti = 2*i + (dir-1);
            if(inRange(ti, 0, 9)){
                if(mat[ti][j] == '1'){
                    dir = (dir - 1 + 4)%4;
                    i += di[dir], j += dj[dir];
                    ans += s[dir];
                    continue;
                }
            }
            int tj = j - dir/2;
            if(!inRange(tj, 0, 4) || mat[2*i][tj] == '0'){
                dir = (dir + 1)%4;
            }else{
                i += di[dir], j += dj[dir];
                ans += s[dir];
            }
        }else{
            int tj = j - dir/2;
            if(inRange(tj, 0, 4)){
                if(mat[2*i][tj] == '1'){
                    dir = (dir - 1 + 4)%4;
                    i += di[dir], j += dj[dir];
                    ans += s[dir];
                    continue;
                }
            }
            int ti = 2*i + (2-dir);
            if(!inRange(ti, 0, 9) || mat[ti][j] == '0'){
                dir = (dir + 1)%4;
            }else{
                i += di[dir], j += dj[dir];
                ans += s[dir]; 
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int e, y, a[] = {1868,1912,1926,1989,9999};
    string s[] = {"M","T","S","H"};
    cin >> e >> y;
    if(e==0){
        REP(i,4){
            if(y < a[i+1]){
                cout << s[i] << y-a[i]+1 << endl;
                break;
            }
        }
    }
    else{
        cout << a[e-1]+y-1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import Data.List
import Data.Bits
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import Debug.Trace
import qualified Data.IntMap as M

solve :: Int -> VU.Vector Int -> Bool
solve !n !vn
  | VU.all (== 0) vn = True
  | M.size mp == 2 = mp M.! 0 == n `div` 3
  | M.size mp == 3 =  all (\v -> v == n `div` 3) (M.elems mp)
  && isXorTriple (M.keys mp)
  | otherwise = False
 where
  isXorTriple [x, y, z] = x `xor` y == z || y `xor` z == x || z `xor` x == y
  mp = VU.foldl' (\(!mp) (!v) -> M.insertWith (+) v (1 :: Int) mp) M.empty vn

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  vn <- VU.unfoldrN n readInt <$> B.getLine

  putStrLn $ if solve n vn then "Yes" else "No"


Measured memory_bytes: 13948
# Studying https://atcoder.jp/contests/abc140/submissions/7415625

def Next _N, _P, _O1, _I, o
	(_N-1).downto(0){|i|
		j = [_I[i]+1, _N].min
		j = _O1[j] while j < _N and _P[j] <= _P[i]
		o[i] = j
	}
end

def Gen _N, _P
	io = (0..._N).to_a # 0
	Next(_N, _P, io, io, io)
	o1 = io.dup # 1
	return Enumerator.new{|y|
		y << o1.dup # 1
		loop {
			Next(_N, _P, o1, io, io)
			y << io.dup # 2, 3, 4,...
		}
	}
end

N = gets.to_i
P = gets.split.map &:to_i
RU = Gen(N, P).take(2)
LU = Gen(N, P.reverse).take(2).map!{|_| _.map!{|i| N-1-i }.reverse! }

p N.times.map{|i|
	ll, l, r, rr = LU[1][i], LU[0][i], RU[0][i], RU[1][i]
	P[i] * ((i-l)*(rr-r) + (r-i)*(l-ll))
}.inject(&:+)


Measured memory_bytes: 17420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
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 (b<a) { a=b; return 1; } return 0; }

double kyori(double xi, double yi, double xj , double yj)
{
	return pow((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj), 0.5);
}

double kaijo(double N)
{
    if(N==1) return 1;
    return N*kaijo(N-1);
}

double tasu(double N)
{
    if(N==1) return 1;
    return N+tasu(N-1);
}

int main(void)
{
    cout << fixed;
	int N;
	cin >> N;
	double Z[N][2];
	rep(i, N) cin >> Z[i][0] >> Z[i][1];
	double ave=0.0, ans;
	rep(i, N-1)
	{
		repd(j, i+1, N)
		{
			if(i==j) continue;
			ave += sqrt(pow(Z[i][0]-Z[j][0], 2.0) + pow(Z[i][1]-Z[j][1], 2.0));
		}
	}
	ans = ave*(N-1)/tasu(N-1);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N,i;
    cin >> N;
    int mx=0,sum=0;
    int a;
    for(i=0;i<N;i++){
      cin >> a;
      sum+=a;
      mx=max(a,mx);
    }
    if(sum>2*mx)cout<<"Yes";else cout <<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int r = 1;
        while(input.hasNext()){
            int c = input.nextInt();
            if (c == 0)
                break;
            else{
                System.out.println("Case " + r + ": " + c);
                r++;
            }
        }
    }
}


Measured memory_bytes: 41768
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  if (s.back() != 's') {
    cout << s << 's';
  }
  else {
    cout << s << "es";
  }
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
T = []

for _ in range(N):
	a, b = map(int, input().split(' '))
	T.append((a, b))

T = sorted(T, key=lambda t: t[1])

s = 0
ok = True

for (t, d) in T:
	s += t
	if s > d:
		ok = False
		break

print('Yes' if ok else 'No')

Measured memory_bytes: 33396
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int n, m;
int s[400], l[400], p[400], w[400];
int dp[400];

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> s[i] >> l[i] >> p[i];
    cin >> m;
    for(int i = 0; i < m; i++) cin >> w[i];

    for(int i = 0; i < n; i++){
        for(int j = s[i]; j <= l[i]; j++){
            for(int k = j; k <= 393; k++){
                dp[k] = max(dp[k], dp[k-j] + p[i]);
            }
        }
    }

    vector<int> res;
    bool flag = true;
    for(int i = 0; i < m; i++){
        if(dp[w[i]] == 0) flag = false;
        res.push_back(dp[w[i]]);
    }

    if(flag){
        for(auto x: res) cout << x << '\n';
    }else{
        cout << -1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    ll ans=0;
    for(int i=0;i<(1<<s.size()-1);i++){
        ll sum=0;
        ll a = s[0] - '0';
        for(int j=0;j<s.size()-1;j++){
            if(i & 1<<j){
                sum += a;
                a = 0;
            }
            a = a * 10 + s[j+1] - '0';
        }
        sum += a;
        ans += sum;
    }
    cout<<ans<<endl;
}


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

string s;
int ans, temp;

int main() {
  cin >> s;
  ans = 0;
  rep (i, 3) {
    if (s[i] == 'S') {
      ans = max(ans, temp);
      temp = 0;
    } else {
      temp++;
    }
  }
  ans = max(ans, temp);
  cout << ans << endl;
  return 0;
}


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

int main(void) {
  string A, B, C;
	cin >> A >> B >> C;
  if (A[A.length()-1] == B[0] && B[B.length()-1] == C[0]) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var n, k int 
    fmt.Scan(&n, &k) 
    var sum int 
    for b := 1; b <= n; b++ {
        if b >= k { 
            sum += (b - k) * int(n/b)
            amari := n % b 
            if amari > 0 && amari >= k { 
                sum += amari - k + 1 
                if k == 0 { 
                    sum--
                }   
            }   
        }   
    }   

    fmt.Println(sum)
}


Measured memory_bytes: 512
def main():
    n = int(input())
    P = list(map(int, input().split()))
    ans = 0
    for idx in range(1, n-1):
        if P[idx] == sorted([P[idx-1], P[idx], P[idx+1]])[1]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61596
import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))
    if N == 1:
        print(abs(a[0] - W))
    else:
        print(max(abs(a[-1] - W), abs(a[-1] - a[-2])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	string s;
	cin>>s;
	int n=s.size();
	rep(i,n-1){
		if(s[i]=='A'&&s[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256