akhauriyash/Code-Regression huggingface dataset:
package main

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func main() {
	defer flush()

	N := readInt()
	K := readInt()

	P := make([]int, N)
	for i := 0; i < N; i++ {
		P[i] = readInt()
	}
	C := make([]int, N)
	for i := 0; i < N; i++ {
		C[i] = readInt()
	}

	result := math.MinInt64
	for i := 0; i < N; i++ {
		p := P[i] - 1
		c := C[p]
		k := K - 1
		t := c
		for p != i && k != 0 {
			p = P[p] - 1
			c += C[p]
			t = max(t, c)
			k--
		}
		if k == 0 || c <= 0 {
			result = max(result, t)
			continue
		}
		l := K - k
		c = c * (K/l - 1)
		k = K - (K/l-1)*l
		t = c
		for k != 0 {
			p = P[p] - 1
			c += C[p]
			t = max(t, c)
			k--
		}
		result = max(result, t)
	}
	println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

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

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 2084
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


int main()
{
    int N;
    cin >> N;

    int a[N * 3];
    for (int i = 0; i < N * 3; i++) {
        cin >> a[i];
    }
    sort(a, a + N * 3, greater<int>());
    
    long result = 0;
    for (int i = 0; i < N * 2; i++) {
        if (i % 2 == 1) {
            result += a[i];
        }
    }
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;

int main(void){
    // Your code here!
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

int main()
{
    int n;
    cin >> n;
    int x = 1;
    for (int i = 0; i < 100; i++)
    {
        if (x*2 > n){
            cout<<x<<endl;
            break;
        }
        else{
            x*=2;
        }
    }
}


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


int main()
{
   
    int A, yen;
    cin >> A>>yen;
    if (A >= 13) {
        cout << yen<<endl;
    }
    else if (A >= 6 && A <= 12) { cout << yen / 2<<endl; }
    else if(A<=5)
    {
        cout << 0;
    }

}

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

int main()
{
  int k;	cin>>k;
  while(k--)	cout<<"ACL";
}

static int fastio = []() {
    #define endl '\n'
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    return 0;
}();

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,m,x; cin >> n >> m >> x;
  vector<int> a(m);
  rep(i,m) cin >> a.at(i);
  int l=0,r=0;
  rep(i,m){
    if(a.at(i)<x) l++;
    else if(a.at(i)>x) r++;
  }

  cout << min(l,r) << endl;

}

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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int dp[1005][1005];

int totalWays(char **M, int i, int j, int H, int W) {

	if (i == H && j == W) return 1;
	if (dp[i][j] != -1) return dp[i][j];


	int rightWay = 0, downWay = 0;
	if (j + 1 <= W && M[i][j + 1] != '#') rightWay = totalWays(M, i, j + 1, H, W);
	if (i + 1 <= H && M[i + 1][j] != '#') downWay = totalWays(M, i + 1, j, H, W);

	dp[i][j] = rightWay + downWay;
	dp[i][j] %= mod;
	return dp[i][j];
}

int32_t main() {

	FASTIO;
	//IO();

	for (int i = 0; i < 1005; i++) {
		for (int j = 0; j < 1005; j++) {
			dp[i][j] = -1;
		}
	}

	int H, W; cin >> H >> W;

	char **M = new char*[H + 1];

	for (int i = 0; i <= H; i++) {
		M[i] = new char[W + 1];
	}

	for (int row = 1; row <= H; row++) {

		for (int col = 1; col <= W; ++col) {

			cin >> M[row][col];
		}
	}

	cout << totalWays(M, 1, 1, H, W) << endl;

	return 0;
}


Measured memory_bytes: 12552
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
using namespace std;

int main()
{
   int t;t=1;
   FAST
   while(t--)
   {
       int n,k;cin>>n>>k;
       cout<<(n<=k ? "unsafe\n":"safe\n");
   }
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL ec = 0,nxt[200005],to[200005],hed[100005] = {0};
void add_edge(LL f,LL t){
	++ ec; nxt[ec] = hed[f]; to[ec] = t; hed[f] = ec;
}

LL n,a,b;
LL dp[100005][2] = {0};

void dfs(LL u,LL f){
	dp[u][0] = 1;
	dp[u][1] = 1;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		dp[u][0] *= (dp[v][0] + dp[v][1]); dp[u][0] %= N;
		dp[u][1] *= dp[v][0]; dp[u][1] %= N;
	}
}

int main(){
	scanf("%lld",&n);
	for(LL i = 1;i < n;i ++){
		scanf("%lld %lld",&a,&b);
		add_edge(a,b);
		add_edge(b,a);
	}
	dfs(1,0);
	printf("%lld\n",(dp[1][0] + dp[1][1]) % N);
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define MAXN 110
using namespace std;

long long v[MAXN], dp[MAXN][100010];
int p[MAXN], ct = 1;
unordered_map < long long , int > m;

int hsh(long long p){
	if(m[p] == 0) return m[p] = ct++;
	else return m[p];
}

long long res(int i, int n, int w){
	if(i == n) return 0;
	if(dp[i][hsh(w)] != -1) return dp[i][hsh(w)];
	long long n_pega = res(i+1, n, w), pega = 0;
	if(w >= p[i]){
		pega = v[i] + res(i+1, n, w-p[i]);
	}
	return dp[i][hsh(w)] = max(pega, n_pega);
}

int main(){
	int n, w;
	cin >> n >> w;
	memset(dp, -1, sizeof(dp));
	for(int i = 0;i < n;++i){
		cin >> p[i] >> v[i];
	}
	cout << res(0, n, w) << endl;
	// for(auto i : m){
	// 	cout << i.first << ' ' << i.second << endl;
	// }
	// cout << endl;
}

Measured memory_bytes: 90276
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var cin = new MyInputStream();
            var N = cin.ri();
            var A = cin.ri();
            var B = cin.ri();
            var h = new int[N];
            for (int i = 0; i < N; ++i)
                h[i] = cin.ri();

            var diff = A - B;
            Func<long, bool> check = (K) =>
            {
                var k = K;
                for (int i = 0; i < N; ++i)
                {
                    var t = h[i] - B * K;
                    if (t > 0)
                        k -= (long)Math.Ceiling((double)t / diff);
                }
                return k >= 0;
            };

            var r = (long)0;
            var l = (long)1e9;
            for (int i = 0; i < 150; ++i)
            {
                var mid = (l + r) >> 1;
                if (check(mid))
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
                //WriteLine($"{r} {l}");
            }
            WriteLine(l);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Trim().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
        public string r() => Read();
        public int ri() => ReadInt();
        public long rl() => ReadLong();
        public double rd() => ReadDouble();
    }
}


Measured memory_bytes: 15568
# coding: utf-8
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if(max(a,b,c,d,e) - min(a,b,c,d,e) > k):
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

int main()
{
	char X,Y;
	int a,b;
	while(~scanf(" %c %c",&X,&Y))
    if(X<Y)
    	printf("<");
    	else if(X==Y)
    		printf("=");
    		else if(X>Y)
    			printf(">");
    			return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;

int main(){
    int a[10];
    for(int i = 0; i< 3; i ++){
        s(a[i])
    }
    sort(a,a+3);
    int count0 = 1;
    for(int i = 1; i< 3; i ++){
        if(a[i] != a[i-1]){
            count0 ++;
        }
    }
    p(count0) pn








    return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x,y,z,cnt=1;
int main()
{
  cin>>x>>y>>z;
  x=x-y-z*2;
  while(x>0)
  {
    x=x-y-z;
    if(x>=0)cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.GregorianCalendar;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);

		while(in.hasNext())
		{
			int m=in.nextInt();
			int d=in.nextInt();
			GregorianCalendar g= new GregorianCalendar(2004, m-1, d);
			if((m|d)==0)
				return;
			String w[] ={"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
			System.out.println(w[g.get(GregorianCalendar.DAY_OF_WEEK)]);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    int n=s.length();
    string ans="";
    if(n==0)
    {
        cout<<ans;
        return 0;
    }
    cin>>t;
    int m=t.length();
    if(n==0 || m==0) 
        {
            cout<<ans;
            return 0;
        }
        vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(s[i-1]==t[j-1])
            dp[i][j]=dp[i-1][j-1]+1;
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

    int i=n;
    int j=m;
    while(i>0 && j>0)
    {
        if(dp[i][j]==dp[i-1][j])
            i--;
        else if(dp[i][j]==dp[i][j-1])
            j--;
        else
        {
            ans=s[i-1]+ans;
            i--;
            j--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 35584
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt(), k = sc.nextInt();
		Integer[] l = new Integer[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l, Collections.reverseOrder());
		int ans = 0;
		for (int i = 0; i < k; i++) {
			ans += l[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include <cstdio>
#include <vector>
#include <algorithm>

#pragma warning(disable: 4996)

using namespace std;

int N, C;

vector<int> v;
vector<int> dp;

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

	v = vector<int>(N);
	dp = vector<int>(N + 7, 0);

	dp[N] = 1;

	for (int i = (N + 2) / 2; i > 1; i--)
	{
		dp[i] = dp[2 * i - 1] + 2 * dp[2 * i] + dp[2 * i + 1];
	}

	for (int i = 2; i <= N; i++)
	{
		C += dp[i] * i;
	}

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &v[i]);
	}

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

	for (int i = 0; i < N; i++)
	{
		if (i) { printf(" "); }

		printf("%d", v[i]);
	}

	printf("\n");

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

	return 0;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    lint d[10][10];
    int a[h][w];
    rep(i, 10)rep(j, 10) scanf("%lld", &d[i][j]);
    rep(i, h)rep(j, w) scanf("%d", &a[i][j]);

    rep(k, 10)rep(i, 10)rep(j, 10){
        chmin(d[i][j], d[i][k] + d[k][j]);
    }
    lint ans = 0;
    rep(i, h)rep(j, w)if(a[i][j] >= 0) ans += d[a[i][j]][1];
    printf("%lld\n", ans);
}

Measured memory_bytes: 384
#include <stdio.h>

int max(int a, int b) {
    if (a>=b) return a;
    else return b;
}

int main() {
    int h, w, n;
    scanf("%d%d%d", &h, &w, &n);
    int hi=max(h, w);
    n+=hi-1;
    printf("%d\n", n/hi);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;

  if (u == s) cout << a - 1 << " " << b << endl;
  else cout << a << " " << b - 1 << endl;
}


Measured memory_bytes: 3560
/// In The Name Of God
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
 
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define nl '\n'
#define ioi exit(0);
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
 
using namespace std;
 
int n;
int a[N], b[N];
 
vector <int> st;
ll ans;
int get(int l, int r) {
	if (l > r) return 0;
	return upper_bound(all(st), r) - lower_bound(all(st), l);
}
void solve(int k) {
	st.clear();
	for (int i = 1; i <= n; i++) {
		st.pb(a[i] % (1 << (k + 1)));
	}
	sort(all(st));
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		int cur = b[i] % (1 << (k + 1));
		cnt += get((1 << k) - cur, (1 << (k + 1)) - cur - 1);
		cnt += get((1 << k) + (1 << (k + 1)) - cur, (1 << 30));
	}
	if (cnt & 1) ans += 1 << k;
}
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < 29; i++) {
		solve(i);
	}
	cout << ans;
	ioi
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long H, N;
  scanln(H, N);
  long s = readln.split.to!(long[]).sum;
  if (s >= H) {
    "Yes".writeln;
  } else {
    "No".writeln;
  }
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 4504
#include<stdio.h>
int main(){
int a,c;
while(1){
scanf("%d\n",&a);
if(a==-1){
break;
}
else{
if(a<=10){
c=1150;
}
else if(a<=20){
c=1150+(a-10)*125;
}
else if(a<=30){
c=1150+10*125+(a-20)*140;
}
else{
c=1150+10*125+10*140+(a-30)*160;
}
printf("%d\n",4280-c);
}
}
return 0;
}



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

int main()
{
	int K, X,A;
	cin >> K >> X;
	A = (K * 2) - 1;

	vector<int> B(A);
	for (int i = 0; i < A; i++) {
		B.at(i) = X - (K - 1) + i;
		cout << B.at(i) << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-S
A,B = [int(i) for i in input().split()]

if A == B:
    print("Draw")
elif A != 1 and A < B:
    print("Bob")
elif A == 1 and B != 1:
    print("Alice")
elif B != 1 and B < A:
    print("Alice")
elif B == 1 and A != 1:
    print("Bob")


Measured memory_bytes: 2940
import numpy as np
N,L = map(int,input().split())
azi = [i+L for i in range(N) ]
azi_abs = np.abs(azi)

if 0 in azi:
    print(sum(azi))
else:
    apple_azi = [abs(sum(azi)-sum(azi)-azi[i]) for i in range(len(azi))]
    if sum(azi) >= 0:
        print(sum(azi)-min(apple_azi))
    else:
        print(sum(azi)+min(apple_azi))


Measured memory_bytes: 18296
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    vector<int> d(n);
    int k = 0;
    For(i, n){
        Cin(char, c);
        d[i] = ((c == 'E') ? -1 : 1);
        if(i > 0 && c == 'E') k ++;
    }
    
    int ans = k;
    For(i, n-1){
        k += (d[i]+d[i+1]) / 2;
        ans = min(ans, k);
    }
    Cout(ans);
}


Measured memory_bytes: 1408
/*
sg(1) ^ sg(2) != 0 不好考虑，正难则反，我们用 2^m - ( sg(1) = sg(2) 的方案数 )
考虑边集显然不现实，我们考虑点集

将 DAG 中的点按照 sg 值分层，显然点 1 和点 2 在同一层
根据分层，想到子集dp，f[S] 表示只考虑 S 这个点集使得 sg(1) = sg(2) 的方案数（注意 S 必须同时包含或不包含 1 和 2）

转移就枚举 S 的子集 T，设 U 为补集，其中 T 中 sg 值都不为 0，U 中 sg 值都为 0，也就是说 1 和 2 必须同时在 T 中或者 U 中
U 不能内部连边
T 内部就是 f[T]
T 中每个点都至少有一条到 U 的边（T 中 sg 值 += 1）
U 到 T 随便连
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 20, M = (1 << 15) + 5, mod = 1e9 + 7;
typedef long long ll;
ll n, m;
ll ed[N], f[M], bit2[N * N] = {1};

int main() {
    cin >> n >> m;
    rep(i, 1, m) {
        bit2[i] = bit2[i - 1] * 2 % mod;
        int x, y; scanf("%d%d", &x, &y);
        ed[x - 1] |= (1 << (y - 1));
    }
    f[0] = 1;
    rep(S, 1, (1 << n) - 1) {
        if ((S & 1) == ((S >> 1) & 1)) {
            for (ll T = S; ; T = (T - 1) & S) {
                if ((T & 1) == ((T >> 1) & 1)) {
                    ll U = (S ^ T), cnt = 1;
                    rep(i, 0, n - 1) {
                        if ((S >> i) & 1) {
                            if ((T >> i) & 1)
                                cnt = cnt * (bit2[__builtin_popcount(ed[i] & U)] - 1) % mod;
                            else
                                cnt = cnt * bit2[__builtin_popcount(ed[i] & T)] % mod;
                        }
                    }
                    f[S] = (f[S] + cnt * f[T] % mod) % mod;
                }
                if (!T) break;
            }
        }
    }
    printf("%lld\n", (bit2[m] - f[(1 << n) - 1] + mod) % mod);
    return 0;
}


Measured memory_bytes: 4052
/* @ by batr (T) */
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>
 
#define F first
#define S second
 
using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
ll a[maxn], b[maxn];
ll c[maxn];

int main () { 
	Need_For_Speed();
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	ll last = 0;
	for (int i = n; i >= 1; i--) {
		a[i] += last;
		c[i] = (a[i] / b[i] + 1) * 1ll * b[i] - a[i];
		if (c[i] >= b[i]) {
			c[i] = c[i] - b[i];
		}
		last += c[i];
	}
	cout << last;
	return 0;
}

Measured memory_bytes: 5120
a = list(map(int,input().split()))
a = sorted(a)
temp = list()
ans = 0

for i in a:
    if i%2 == 0:
        temp.append(0)
    else:
        temp.append(1)
        
if temp.count(1) == 2:
    for i in range(len(a)):
        if temp[i] == 1:
            a[i] += 1
    ans +=1
elif temp.count(0) == 2:
    for i in range(len(a)):
        if temp[i] == 0:
            a[i] += 1
    ans +=1

ans += int((a[2]-a[0]) / 2)
ans += int((a[2]-a[1]) / 2)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{
   long long int d,t,s,v;
   cin>>d>>t>>s;
   v=s*t;
   if(d<=v)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
#define pb push_back

int bottommost(vi& v)
{
  while (v[1] != -1) {
    for (int i = 0; v[i] != -1; i++) {
      if (v[i+1] == -1)
        v[i] = -1;
      else
        v[i] = v[i] + v[i+1];
    }
  }
  return v[0] % 10;
}

int bottommost(string& s)
{
  vi v;
  for (auto& c : s) {
    v.pb(int(c - '0'));
  }
  v.pb(-1);
  return bottommost(v);
}

int main(int argc, char **argv)
{
  string s;
  while (cin >> s) {
    cout << bottommost(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,m,t,k,a[262144],r=0,l;
    double d;
    char s[262144];
    scanf("%s",s);
    //l=strlen(s);
    //for(i=1;i<=n;i++){scanf("%d",&a[i]);}
    s[3]='8';
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>

using namespace std;

int main() {
	
	char b;
	cin >> b;

	switch (b) {
		case 'A': {
			cout << 'T' << endl;
			break;
		}
		case 'T': {
			cout << 'A' << endl;
			break;
		}
		case 'C': {
			cout << 'G' << endl;
			break;
		}
		case 'G': {
			cout << 'C' << endl;
			break;
		}
	}
	

}

Measured memory_bytes: 256
import Queue

V,E,r = map(int,raw_input().split())
edges = [[] for i in range(V)]

for i in xrange(E):
	(a,b,w) = map(int,raw_input().split())
	edges[a].append({'to':b,'weight':w})

INF = 2000000000

pq = Queue.PriorityQueue()
pq.put((0,r))

dist = [INF] * V
visited = [False] * V
dist[r] = 0
while not pq.empty():
	d,v = pq.get()
	visited[v] = True
	for e in edges[v]:
		if visited[e['to']] or dist[e['to']] < d+e['weight']: continue
		dist[e['to']] = d + e['weight']
		pq.put((d+e['weight'],e['to']))

for i in dist:
	print 'INF' if i == INF else i

Measured memory_bytes: 191124
import numpy as np


def main():
    n, k = map(int, input().split())
    height = np.fromstring(input(), 'int32', sep=' ')
    height = np.append(height, [0] * (k - 1))

    dp = np.full((n + k - 1), 10 ** 9, dtype='int')
    dp[0] = 0

    for i in range(n - 1):
        default_val = dp[i + 1:i + 1 + k]
        new_val = dp[i] + np.abs(height[i + 1:i + 1 + k] - height[i])
        dp[i + 1:i + 1 + k] = np.minimum(default_val, new_val)
    print(dp[n - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 16416
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static boolean hasDuplcate(char[] arr) {
		int[] counts = new int['z'-'a'+1];
		Arrays.fill(counts, 0);
		for(char c: arr) {
			if(c < 'a' || 'z' < c)
				continue;
			counts[c-'a']++;
			if(counts[c-'a']>1)
				return true;
		}
		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();

		System.out.println(hasDuplcate(str.toCharArray()) ? "no" : "yes");
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc070_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll X;
  cin >> X;
  ll l = 0;
  ll r = INF;
  ll ans = 0;

  while (l + 1 < r) {
    ll n = (l + r) / 2;
    ll sum = (1 + n) * n / 2;
    if (sum < X) {
      l = n;
    } else {
      r = n;
    }
    // printf("%d %d %d\n", l, r, sum);
    ans = X == (1 + l) * l / 2 ? l : l + 1;
  }

  cout << ans << endl;
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

ll dp[3050][3050][5];
ll value[3050][3050];
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll r, c, k;
    cin >> r >> c >> k;
    vl col(k), row(k), v(k);
    rep(i, k) cin >> col[i] >> row[i] >> v[i];
    rep(i, k) col[i]--, row[i]--;
    rep(i, k) value[col[i]][row[i]] += v[i];

    if (value[0][0] > 0) dp[0][0][1] += value[0][0];
    rep(x, r) rep(y, c) rep(z, 4) {
        if (z == 3) {
            chmax(dp[x][y + 1][z], dp[x][y][z]);
            chmax(dp[x + 1][y][1], dp[x][y][z] + value[x + 1][y]); //行移動、つかう
            chmax(dp[x + 1][y][0], dp[x][y][z]);
        } else {
            chmax(dp[x][y + 1][z + 1], dp[x][y][z] + value[x][y + 1]); //列移動、つかう
            chmax(dp[x][y + 1][z], dp[x][y][z]);
            chmax(dp[x + 1][y][1], dp[x][y][z] + value[x + 1][y]); //行移動、つかう
            chmax(dp[x + 1][y][0], dp[x][y][z]);
        }
    }
    // debug(dp[0][3][0]);
    // debug(dp[0][3][1]);
    // debug(dp[0][3][2]);
    // debug(dp[0][3][3]);
    r--, c--;
    out(max({dp[r][c][3], dp[r][c][2], dp[r][c][1], dp[r][c][0]}));

    return 0;
}


Measured memory_bytes: 436920
#include <iostream>

using namespace std;

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

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanVecLLInt(A, N);

    vector<ll> B(N);
    B[0] = A[0];
    REP(i, N - 1){
        B[i + 1] = B[i] + A[i + 1];
    }
    unordered_map<ll, ll> weight;
    weight[0] = 1;
    ll result = 0;
    REP(i, N){
        if (weight.count(B[i])){
            result += weight[B[i]];
        }
        if (weight.count(B[i])){
            ++weight[B[i]];
        }else{
            weight[B[i]] = 1;
        }
    }
    cout << result << endl;
}


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

int main()
{
  int k, x;
  cin >> k >> x;
  for(int i = x - k + 1; i <= x + k - 1; i++)
  {
    cout << i << ((i == x+k-1)? "\n" : " ");
  }
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 26 21:02:44 2019

@author: aono
"""

s = input().split()

s = [int(v) for v in s]

apple = s[0]
apple_pieces = s[1]

apple_pieces = apple_pieces + 3*apple
apple_pies = int(apple_pieces / 2)

print(apple_pies)

Measured memory_bytes: 3060
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, a[201010], sum[202020], xr[202020], ans, cnt[55], l, r;
bool flag ;

void add(ll x){

    rep(i, 0, 20){

        if((1<<i) & x )
        cnt[i]++;

    }

}

void sub(ll x){

    rep(i, 0, 20){

        if((1<<i) & x){
            cnt[i]--;
        }

    }

}

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

rep(i, 1, n){
    cin >> a[i];
}
l = 1, r =1;

while(l<=r && r<=n){

    flag = true;

    rep(i, 0, 20){

        if((1<<i)&a[r]){
            if(cnt[i]>=1){
                flag = false;
            }
        }

    }

    if(flag){
        add(a[r]);
        r++;
        xr[l]++;
    }
    else {
        sub(a[l]);
        l++;
        xr[l]=(r-l);
    }

}
l++;
while(l<=r){

    xr[l]= r-l;
    l++;
}

rep(i, 1, n){
ans+= xr[i];
//cout << xr[i] << endl;
}

cout << ans << endl;



return 0;}
///....


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
using dou = double;

dou dis(dou x, dou y, dou a, dou b){
    return sqrt(pow((x-a),2) + pow((y-b),2));
}

int main(){FIN
 
    ll n;cin>>n;
    vll per(0);
    vector<float> x(0), y(0);
    REP(i,n) {
        float xx,yy;cin>>xx>>yy;
        x.push_back(xx);
        y.push_back(yy);
    }

    REP(i,n) per.push_back(i);
    dou sm=0;
    do{
        REP(i,n-1){
            ll idx1 = per[i];
            ll idx2 = per[i+1];
            sm += dis(x[idx1], y[idx1], x[idx2], y[idx2]);
        }
    }while(next_permutation(ALL(per)));
    ll jun=1;
    FORR(i,n,1) jun *= i;
    // cout<<jun<<endl;
    cout<< setprecision(15)<< sm/jun <<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> L(N);
    rep(i,N) cin >> L[i];

    sort(all(L));
    int ans = 0;
    rep(i,N) {
        for (int j = i+1; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                if (L[i]==L[j] or L[j]==L[k]) continue;
                if (L[i]+L[j]>L[k]) ans++;
            }
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 3596
// std::set を用いた解法
#include <iostream>
#include <set>
using namespace std;

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];

    set<int> values;
    for (int i = 0; i < N; i++) {
        values.insert(d[i]);
    }

    cout << values.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>

class UnionFind{
public:
    UnionFind(int N):parent(N), rank(N,0), size(N,1){
        for(int i=0;i<N;++i) parent[i]=i;
    }
    int find(int x){
        return x==parent[x]?x:parent[x]=find(parent[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x), y=find(y);
        if(x==y) return;
        if(rank[x]==rank[y]) parent[y]=x, rank[x]++;
        else{
            if(rank[x]<rank[y]) std::swap(x,y);
            parent[y]=x;
        }
        size[x]+=size[y];
        size[y]=0;
    }
    int getParentSize(int x){
        return size[find(x)];
    }
    int getSize(int x){
        return size[x];
    }
private:
    std::vector<int> parent, rank, size;
};

#include<cmath>
#include<iostream>
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    UnionFind UF(N);
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        UF.unite(--a,--b);
    }
    int x=0,y=0;
    for(int i=0;i<N;++i) UF.getSize(i)>1?x++:UF.getSize(i)-1?:y++;
    cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll N=998244353;
ll power(ll x,ll n, ll MOD){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, N-2, N);}
void solve()
{
    ll n;
    string str;
    cin>>n>>str;
    ll total1=0, total2=0;
    ll check=0;
    forr(i, str.length())
    {
        if(str[i]=='1')
        check++;
    }
    vl plus(n), minus(n);
    forr(i, str.length())
    {
        ll num=str[i]-'0';
        if(num)
        {
            total1+=(ll)power(2, n-1-i, check+1);
            if(check>1)
            total2+=(ll)power(2, n-1-i, check-1);
            total1%=(check+1);
            if(check>1)
            total2%=(check-1);
            if(check>1)
            {
                if(total2<0)
                total2+=(check-1);
            }
            if(total1<0)
            total1+=(check+1);
        }
    }
    forr(i, n)
    {
        ll num=str[i]-'0';
        ll popc=check;
        ll ans=1;
        ll norm=0;
        if(num)
        {
            popc--;
            norm=total2;
            if(check==1)
            {
                cout<<0<<endl;
                continue;
            }
            if(check>1)
            norm-=power(2, n-1-i, check-1);
            if(check>1)
            norm%=(check-1);
        }
        else
        {
            popc++;
            norm=total1;
            norm+=power(2, n-1-i, check+1);
            norm%=(check+1);
        }
        if(norm<0)
        norm+=popc;
        while(true)
        {
            if(norm==0)
            {
                cout<<ans<<endl;
                break;
            }
            norm%=__builtin_popcount(norm);
            ans++;
        }
    }
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 6752
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
  int N;
  scanf("%d",&N);
  int mn=1000000000, mx=0;
  for(int i=0;i<N;i++){
    int v;
    scanf("%d",&v);
    mn=min(mn,v);
    mx=max(mx,v);
  }
  printf("%d",(mx-mn));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  int abc[3] = {0,0,0};
  for (char player = 'a'; true; player = S[player-'a'][abc[player-'a']++]) {
    if (abc[player-'a'] == S[player-'a'].length()) {
      cout << (char)('A'-'a'+player);
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<vector<ll>> dp(3010, vector<ll>(3010, -1));
vector<ll> a(3000, -1);
ll solve(int head, int tail) {
    if(dp[head][tail] != -1)
        return dp[head][tail];
    if(head == tail)
        return a[head];

    return dp[head][tail] = max(a[head] - solve(head + 1, tail),
                                a[tail] - solve(head, tail - 1));
}
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << solve(0, n - 1) << endl;
}

Measured memory_bytes: 74712
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int N,i;
	int A[25], B[25], C[25],ans=0,temp=50,itizi;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < N; i++) {
		scanf("%d", &B[i]);
	}
	for (i = 0; i < N - 1; i++) {
		scanf("%d", &C[i]);
	}

	
	for (i = 0; i < N; i++) {
		itizi = A[i];
		ans = ans + B[itizi-1];
		if (A[i] == temp + 1) {
			ans = ans + C[temp-1];
		}
		temp = A[i];
	}
	printf("%d", ans);
}


Measured memory_bytes: 128
#include <cstdio>

int main()
{
  char s[200];
  scanf("%s",s);
  int K=0;
  for(int i=0;s[i];i++){
    if(K==0&&s[i]=='C'){
      K=1;
    }
    else if(K==1&&s[i]=='F'){
      K=2;
    }
  }
  printf(K==2?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
s = list(input())
ans = 0
while len(s) > 1:
    if s[0] == s[-1]:
        del s[0]
        del s[-1]
    else:
        if s[0] == "x":
            del s[0]
            ans += 1
        elif s[-1] == "x":
            del s[-1]
            ans += 1
        else:
            print(-1)
            exit()
print(ans)

Measured memory_bytes: 9848