akhauriyash/Code-Regression huggingface dataset:
//written by libra9z
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
#define all(s) s.begin(),s.end()
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
int dp[500005],pre[500005],nxt[500005],n;
string str;
int main()
{
	cin>>n>>str;
	str='0'+str+'0';
	n++;
	pre[0]=0;
	nxt[n]=n;
	for (int i=1;i<n;++i)
	{
		if (str[i]=='0') pre[i] = i;
		else pre[i]=pre[i-1];
	}
	for (int i=n-1;i>=0;--i)
	{
		if (str[i]=='0') nxt[i]=i;
		else nxt[i]=nxt[i+1];
	}
	for (int i=1;i<n;++i)
	{
		dp[i+1]=max(dp[i],dp[i+1]);
		if (str[i]=='1')
		{
			if (str[pre[i]-1]=='1')
			{
				int tmp=i-pre[i];
				dp[i+1]=max(dp[pre[i]-1]+tmp,dp[i+1]);
			}
			if (str[nxt[i]+1]=='1')
			{
				int tmp=nxt[i]-i;
				dp[nxt[i]+2]=max(dp[nxt[i]+2],dp[i]+tmp);
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 6680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int a, b;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        if (a <= 8 && b <= 8) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  
  int Alice = 0;
  int Bob = 0;
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i = 0; i < n; ++i){
	  if(i%2 == 0) Alice += a[i];
	  else Bob += a[i];
  }
  
  cout << Alice - Bob << endl;
  
  return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string s;
    cin >> s;
    if ( s.find('C' ) == string::npos || s.find('F') == string::npos ) {
        cout << "No" << endl;
        return 0;
    }

    if (s.find('C') > s.rfind('F')) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int a[305],vis[305];
int main() {
    int x,n;
    cin>>x>>n;
    ii {
        int t;
        cin>>t;
        vis[t]=1;
    }
    int mx=1e9,ans=0;
    for(int i=-200;i<=300;++i) {
        if(i>=0 && vis[i]) continue;
        int d=abs(i-x);
        if(d<mx) {
            mx=d;
            ans=i;
        }
    }
    cout<<ans<<endl;
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> a;
int main() {
    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];

    vector<ll> sum(N + 1);
    rep(i, N) {
        sum[i + 1] = sum[i] + a[i];
    }

    // rep(i, N + 1) {
    //     cout << sum[i] << endl;
    // }
    ll ans = INF;
    for (int i = 1; i <= N - 1; i++) {
        ll x = sum[i];
        ll y = sum[N] - x;
        ll tmp = abs(x - y);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

ll ans[50];

int main()
{
	ll K, N;

	cin >> K;
	N = 50;

	rep(i, N) ans[i] = (N - 1) + (K / N);

	rep(loop, K % N) {
		int least = 0;

		rep(i, N) {
			if (ans[least] > ans[i]) least = i;
		}

		rep(i, N) {
			if (i == least) ans[i] += N;
			else ans[i]--;
		}
	}

	cout << N << endl;
	cout << ans[0];
	repc(i, 1, N - 1) cout << ' ' << ans[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

for i in range(1000):
    st = set()
    for k in str(i+N):
        st.add(k)
    if len(st) == 1:
        print(i+N)
        exit()

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int[] result = new int[n];
			Arrays.fill(result, 0);
			IntStream.range(0, 2 * m).forEach(i -> result[scanner.nextInt() - 1]++);
			Arrays.stream(result).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 28496
n,m = map(int, input().split())

import math
import heapq
import sys
def judge_p(n):
	d = math.floor(n**(1/2))
	for i in range(2,d+1):
		if n%i == 0:
			return False
	return True

if n == 1:
	print(m)
	sys.exit()
if judge_p(m):
	print(1)
	sys.exit()

P = []
D = math.floor(m**(1/2))

for j in range(2,D+1):
	if judge_p(j):
		P.append(j)

deck = []

for prime in P:
	cnt = 0
	tmp = m
	while True:
		if tmp % prime == 0:
			cnt += 1
			tmp //= prime
		else:
			break
	deck.append([prime, cnt])

ans = 1
for i in range(len(deck)):
	prime, cnt = deck[i]
	if cnt//n == 0:
		continue
	ans *= prime**(cnt//n)

print(ans)

Measured memory_bytes: 57948
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    N = A.length;
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    //nums.writeln; 
    
    ulong all_num = grps.map!(a => a[1] * (a[1]-1)).sum / 2;
    ulong all_num_true = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    
    int[] re; re.length = N;
    if (all_num < all_num_true) {
        if (
            equal( sort(grps.map!(a => a[1]).array), sort(nums.values) ) &&
            !equal( sort(grps.map!(a => a[1] * (a[1]-1)).array), sort(nums.values.map!(a => a * (a-1)).array) )
        ) re[N] = 1;  // RE
    }
    
    foreach (k; 0 .. N) {
        writeln( all_num_true - (nums[A[k]] - 1) );
    }
}



Measured memory_bytes: 25872
#include <stdio.h>

int main(void)
{
	int size_limit[6] = {60, 80, 100, 120, 140, 160};
	int weight_limit[6] = {2, 5, 10, 15, 20, 25};
	int fee[6] = {600, 800, 1000, 1200, 1400, 1600};
	
	int n;
	int x, y, h, w;
	int size;
	int sum;
	int i, j;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		sum = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d %d %d %d", &x, &y, &h, &w);
			size = x + y + h;
			
			for (j = 0; j < 6; j++){
				if (size <= size_limit[j] && w <= weight_limit[j]){
					break;
				}
			}
			
			if (j < 6){
				sum += fee[j];
			}
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		if(x <= k * 500)
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
signed main()
{

	int n;
	cin>>n;
	vector<vector<int>> v(n+1, vector<int> (3));
	vector<vector<int>> dp(n+1, vector<int> (3));
	for (int i = 1; i < n+1; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin>>v[i][j];
		}
	}
	dp[0][0]=0;

	dp[1][0]=v[1][0];
	dp[1][1]=v[1][1];
	dp[1][2]=v[1][2];
	for (int i = 2; i < n+1; ++i)
	{
		dp[i][0]=v[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]=v[i][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]=v[i][2] + max(dp[i-1][1], dp[i-1][0]);
	}
	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<endl;



}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] as = new int[n + 1];
    int[] bs = new int[n + 1];
    int[] cs = new int[n + 1];

    for (int i = 1; i <= n; i++) {
      as[i] = sc.nextInt();
    }

    for (int i = 1; i <= n; i++) {
      bs[i] = sc.nextInt();
    }

    for (int i = 1; i < n; i++) {
      cs[i] = sc.nextInt();
    }

    int sum = 0;
    int x = 0;

    for (int i = 1; i <= n; i++) {
      sum += bs[as[i]];
      if (i > 1 & as[i] - as[i - 1] == 1) {
        sum += cs[as[i - 1]];
      }
    }

    System.out.println(sum);
  }
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  double x1, y1, x2, y2, x3, y3;
  cin >> x1 >> y1;
  cin >> x2 >> y2;
  cin >> x3 >> y3;

  double a = hypot(x1-x2, y1-y2);
  double b = hypot(x2-x3, y2-y3);
  double c = hypot(x3-x1, y3-y1);
  double r = abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/(a+b+c);
  double d = max(a, max(b, c));
  double x = d/(2+d/r);
  printf("%.12lf\n", x);

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut ans = 0;
    for i in 1..n + 1 {
        let mut v = i;
        let mut cnt = 0;
        while v > 0  {
            cnt += 1;
            v /= 10;
        }
        if cnt % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n) cin>>a[i];
    int cnf=0;
    int cnt=0;
    rep(i,n){
        if(a[i]%4==0)cnf+=1;
        if(a[i]%2==0)cnt+=1;
    }
    cnt-=cnf;
    if(cnt>=n-cnf*2 | cnf>=(n/2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner) = {
    println(sc.nextInt % 7 match {
      case 0 => "thu"
      case 1 => "fri"
      case 2 => "sat"
      case 3 => "sun"
      case 4 => "mon"
      case 5 => "tue"
      case 6 => "wed"
    })
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}




Measured memory_bytes: 45096
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;
using namespace std;

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

string s;

void code() {
    cin >> s;

    int mx = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] != 'R') continue;
        int j = i, cnt = 0;
        while (j < 3 and s[j] == 'R') cnt++, j++;
        i = j - 1;
        mx = max(mx, cnt);
    }

    cout << mx << "\n";
}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
  string S,T;
  cin>>S>>T;
  int ans=0;
  for(int i=0;i<S.size();++i){
    ans += (S[i]==T[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
let inputs = readLine()!.split(separator: " ")
let h1 = Int(inputs[0])!
let m1 = Int(inputs[1])!
let h2 = Int(inputs[2])!
let m2 = Int(inputs[3])!
let k = Int(inputs[4])!

let minutes1 = h1 * 60 + m1
let minutes2 = h2 * 60 + m2 - k

let diff = minutes2 - minutes1

print(diff)

Measured memory_bytes: 8324
A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) >= rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

const int MAX = 257;

char data[MAX][MAX];
int num[4][MAX][MAX];
int in;

int solve(){
  for(int i = 1; i <= in; i++){
    for(int j = 1; j <= in; j++){
      if(data[i][j] == '1'){
	num[0][i][j] = num[0][i-1][j]+1;
	num[1][i][j] = num[1][i][j-1]+1;
	num[2][i][j] = num[2][i-1][j-1]+1;
	num[3][i][j] = num[3][i-1][j+1]+1;
      }
    }
  }
  int m = 0;
  for(int i = 0; i < 4; i++)
    for(int j = 1; j <= in; j++)
      for(int k = 1; k <= in; k++) m = max(m,num[i][j][k]);
  return m;
}

void init(){
  for(int i = 0; i < MAX; i++){
    fill(num[0][i],num[0][i]+MAX,0);
    fill(num[1][i],num[1][i]+MAX,0);
    fill(num[2][i],num[2][i]+MAX,0);
    fill(num[3][i],num[3][i]+MAX,0);
  }
}
int main(){

  while(cin >> in && in){
    init();
    for(int i = 1; i <= in; i++)
      for(int j = 1; j <= in; j++) cin >> data[i][j];

    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1964
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 2e5 + 7;

int cnt[N];

int32_t main() {
    speed;
    int n, ans = 0;
    cin >> n;

    vector < int > a(n);

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

        if ( cnt[i] ) {
            ans += (cnt[i] * (cnt[i] - 1)) / 2;
        }
    } 
    for ( int i = 0; i < n; i++ ) {
        int res = ans;
        res -= ( cnt[a[i]] * ( cnt[a[i]] - 1 ) ) / 2;
        cnt[a[i]]--;
        res += ( cnt[a[i]] * ( cnt[a[i]] - 1 ) ) / 2;
        cnt[a[i]]++;
        cout << res << '\n';
    }
}   
  

Measured memory_bytes: 4736
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)

int main( void ){
	int n;
	if (!scanf( "%d", &n )){
		return -1;
	}
	int* index = new int[ n ];
	int* array_x = new int[ n ];
	int* array_y = new int[ n ];
	rep( i, 0, n ){
		if (!scanf( "%d", array_x + i ))
			return -1;
		if (!scanf( "%d", array_y + i ))
			return -1;
	}
	int n_ex = 1;
	rep( i, 0, n ){
		index[ i ] = i;
		n_ex*= (i+1);
	}
	double avg = 0;
	do {
		double pre_x = array_x[index[0]], pre_y = array_y[index[0]];
		rep( i, 1, n ){
			avg += std::sqrt((array_x[index[i]] - pre_x)*(array_x[index[i]] - pre_x) + (array_y[index[i]] - pre_y)*(array_y[index[i]] - pre_y));
			pre_x = array_x[index[i]];
			pre_y = array_y[index[i]];
		}
	} while( std::next_permutation( index, index + n ));	// 次の順列を生成
	printf("%lf\n", avg/n_ex);
	return 0;
}


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

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll k;
    cin>>k;
    string s;
    cin>>s;
    rep(i,0,min(k,sz(s))){
    	cout<<s[i];
    }
    if (sz(s)>k){
    	//rep(i,0,sz(s)-k){
    		cout<<"...";
    	
    }
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

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

int main(){
    int n, min_r = 2000000000, max_v = -1000000000;
    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        max_v = max(max_v, tmp - min_r);
        min_r = min(min_r, tmp);
    }

    cout << max_v << endl;

    return 0;

}


Measured memory_bytes: 3116
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long N,i,sum,ave1,ans1,t,ave2,ans2;
vector<long> a;

inline void solve(){
  IN(N);
  a.resize(N);
  REP(i,N){
    IN(a[i]);
    sum+=a[i];
  }
  // if(sum>0)ave=(sum+N-1)/N;
  // else {
  //   sum*=-1;
  //   ave=(sum+N-1)/N;
  //   ave*=-1;
  // }
  ave1=(sum+N-1)/N;
  if(ave1<0)ave1--;
  ave2=sum/N;
  // OUT(ave2);
  REP(i,N){
    t=abs(ave1-a[i]);
    ans1+=t*t;
  }
  REP(i,N){
    t=abs(ave2-a[i]);
    ans2+=t*t;
  }
  OUT(min(ans1,ans2));
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=1000000;
int dp[M],DP[M];

int main(){
	fill(dp+1,dp+M,inf);
	fill(DP+1,DP+M,inf);
	for(int i=1;i*(i+1)*(i+2)/6<=M;i++){
		int t=i*(i+1)*(i+2)/6;
		for(int j=t;j<M;j++) if(dp[j-t]!=inf) dp[j]=min(dp[j],dp[j-t]+1);
		if(t%2==1) for(int j=t;j<M;j++) if(DP[j-t]!=inf) DP[j]=min(DP[j],DP[j-t]+1);
	}
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		cout<<dp[n]<<' '<<DP[n]<<endl;
	}
}


Measured memory_bytes: 10900
#include <iostream>

using namespace std;

int divide_num(int n) {
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (n % i == 0) cnt++;
  }
  return cnt;
}

int main() {
  int n; cin >> n;
  int cnt = 0;

  for (int i = 1; i <= n; ++i) {
    if (i % 2 == 1 && divide_num(i) == 8) cnt++;
  }

  cout << cnt;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

struct Point{
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(x*a, y*a); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;

struct Segment{
  Point p1, p2;
};

double dot(Vector a, Vector b){
  return a.x*b.x + a.y*b.y;
}

double cross(Vector a, Vector b){
  return a.x*b.y - a.y*b.x;
}

Point project(Segment s, Point p){
  Vector a = s.p2 - s.p1;
  Vector b = p - s.p1;
  return s.p1 + a * (dot(a, b)/a.norm());
}

Point reflect(Segment s, Point p){
  return p + (project(s, p) - p)*2;
}

static const int Counter_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

int ccw(Point p0, Point p1, Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a, b) > EPS) return Counter_CLOCKWISE;
  else if(cross(a, b) < -EPS) return CLOCKWISE;
  else if(dot(a, b) < -EPS) return ONLINE_BACK;
  else if(a.norm() < b.norm()) return ONLINE_FRONT;
  else return ON_SEGMENT;
}

int main(){
  double x0, y0, x1, y1;
  cin >> x0 >> y0 >> x1 >> y1;
  Point p0 = Point(x0, y0);
  Point p1 = Point(x1, y1);

  int q; cin >> q;
  rep(i, q){
    int x2, y2; cin >> x2 >> y2;
    Point p2 = Point(x2, y2);
    int ans = ccw(p0, p1, p2);
    if(ans == 1) cout << "COUNTER_CLOCKWISE" << endl;
    if(ans == -1) cout << "CLOCKWISE" << endl;
    if(ans == 2) cout << "ONLINE_BACK" << endl;
    if(ans == -2) cout << "ONLINE_FRONT" << endl;
    if(ans == 0) cout << "ON_SEGMENT" << endl;
  }

  return 0;

}




Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200010;
int n, k, l;
int par[2][MAX_N];    //親int par[MAX_N];    //親
int deapth[2][MAX_N]; //木の深さ
int cnt[2][MAX_N];
map<pair<int, int>, long long int> m;
//n要素で初期化
void init(int n, int id)
{
    for (int i = 0; i < n; i++)
    {
        par[id][i] = i;
        deapth[id][i] = 0;
        cnt[id][i] = 1;
    }
}
//木の根を求める
int find(int x, int id)
{
    if (par[id][x] == x)
    {
        return x;
    }
    else
    {
        return par[id][x] = find(par[id][x], id);
    }
}

//xとyの属する集合を併合
void unite(int x, int y, int id)
{
    x = find(x, id);
    y = find(y, id);
    if (x == y)
        return;
    if (deapth[id][x] < deapth[id][y])
    {
        par[id][x] = y;
        cnt[id][y] += cnt[id][x];
    }
    else
    {
        par[id][y] = x;
        cnt[id][x] += cnt[id][y];
        if (deapth[id][x] == deapth[id][y])
            deapth[id][x]++;
    }
}

bool same(int x, int y, int id)
{
    return find(x, id) == find(y, id);
}

int main()
{
    cin >> n >> k >> l;
    init(n + 1, 0);
    init(n + 1, 1);
    for (int i = 0; i < k; i++)
    {
        int x, y;
        cin >> x >> y;
        unite(x, y, 0);
    }
    for (int i = 0; i < l; i++)
    {
        int x, y;
        cin >> x >> y;
        unite(x, y, 1);
    }
    for (int i = 0; i <= n; i++)
    {
        par[0][i] = find(i, 0);
        par[1][i] = find(i, 1);
    }

    for (int i = 0; i <= n; i++)
    {
        m[make_pair(par[0][i], par[1][i])]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << m[make_pair(par[0][i], par[1][i])] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 16640
import sys
import math
from itertools import accumulate
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) 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 II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
acc = LI()
for i in range(N):
    acc[i] = (1+acc[i]) / 2
acc2 = list(accumulate(acc))
# print(acc)
# print(acc2)

res = acc2[N-1] if K == N else 0
for i in range(1, N-K+1):
    if i == 1:
        res = acc2[K-1]
    else:
        res = max(res, acc2[i+K-1] - acc2[i-1])
    # print(i-1, i+K-1)

print(res)


Measured memory_bytes: 79112
#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>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  double ans = 0;
  REP(i,n){
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY") ans += x;
    if(u == "BTC") ans += x * 380000;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3824
#Chairs Where Demanding People Sit:
def A():
    for i in xrange(n):
        if ch[i] == "#":
            ch[i] = "A"
            return

def B():
    for i in xrange(n - 1, 0, -1):
        if ch[i] == "#" and ch[i - 1] != "A":
            ch[i] = "B"
            return
    for i in xrange(n):
        if ch[i] == "#":
            ch[i] = "B"
            return

def C():
    if all(map(lambda s: s == "#", ch)):
        ch[((n / 2) + 1 if n % 2 == 0 else (n + 1) / 2) - 1] = "C"
        return
    if ch[0] != "#" and ch[1] == "#":
        ch[1] = "C"
        return
    for i in xrange(1, n - 1):
        if ch[i] != "#":
            if ch[i + 1] == "#":
                ch[i + 1] = "C"
                return
            if ch[i - 1] == "#":
                ch[i - 1] = "C"
                return
    ch[-1] = "C"

def D():
    if all(map(lambda s: s == "#", ch)):
        ch[0] = "D"
        return
    dist = [1 << 30] * n
    d, flag = 0, False
    for i in xrange(n):
        flag = flag or ch[i] != "#"
        if flag == False:
            continue
        if ch[i] != "#":            
            d = 0
        dist[i] = d
        d += 1
    d, flag = 0, False
    for i in xrange(n - 1, -1, -1):
        flag = flag or ch[i] != "#"
        if flag == False:
            continue
        if ch[i] != "#":            
            d = 0
        dist[i] = min(dist[i], d)
        d += 1
    ch[max(xrange(n), key = lambda i: dist[i])] = "D"

while True:
    n, m = map(int, raw_input().split())
    if n | m == 0:
        break
    ch = ["#"] * n
    f = {"A":A, "B": B, "C": C, "D": D}
    for _ in xrange(m):
        f[raw_input()]()
    print "".join(ch)

Measured memory_bytes: 4364
import java.util.Scanner;
public class Main {
	static int mod = 1000000007;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] A =new long[n];
		long sum = 0;
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		long[] b = new long[n];
		b[0] = sum;
		for(int i = 1; i < n-1; i+=2) {
			b[0] -= 2*A[i];
		}
		for(int i = 1; i < n; i++) {
			b[i] = 2*A[i-1] - b[i-1];
		}
		for(int i = 0; i < n; i++) {
			System.out.print(b[i] + " ");
		}
		System.out.println();
		//System.out.println(ans);
		sc.close();

	}
}


Measured memory_bytes: 66948
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  unsigned long long ans=1;
  vector<long long> a(n);
  for(int i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  if(a[0]==0){
    cout<<0<<endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    if(ans>(long long)1e18/a[i]){
      cout<<-1<<endl;
      return 0;
    }
    ans*=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long l,r,ans,dp[65][2][2];
long long solve(int idx,bool f1,bool f2)
{
	if (idx<0)
	return 1;
	if (dp[idx][f1][f2]!=-1)
	return dp[idx][f1][f2];
	long long ret=0;
	bool b1=(r&(1LL<<idx)),b2=(l&(1LL<<idx));
	for (int i=0;i<2;i++)
	{
		if (f1 && i==1 && !b1)
		continue;
		for (int j=0;j<=i;j++)
		{
			if (f2 && !j && b2)
			continue;
			ret=(ret+solve(idx-1,(f1 && i==b1),(f2 && j==b2)))%mod;
		}
	}
	return dp[idx][f1][f2]=ret;
}
int main()
{
	cin >> l >> r;
	int j=60;
	for (;!(r&(1LL<<j));j--);
	for (int i=j;;i--)
	{
		memset(dp,-1,sizeof(dp));
		ans=(ans+solve(i-1,(i==j),(l&(1LL<<i))))%mod;
		if (l&(1LL<<i))
		break;
	}
	cout << ans;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
mod = 998244353


factorial = [1]
inverse = [1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))

def comb(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


m_1_i = [1]
for i in range(n):
    m_1_i.append(m_1_i[-1] * (m-1) % mod)

ans = 0
for i in range(k+1):
    kosu = n - i
    ans = (ans + m*m_1_i[kosu-1] * comb(n-1, kosu-1, mod)) % mod

print(ans)

Measured memory_bytes: 117940
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll mycalc(ll S) {
	ll count = 0;
	vector<ll> vec(S + 1);

	vec[0] = 1;
	vec[1] = vec[2] = 0;

	for (int i = 3; i <= S; i++) {
		count += vec[i - 3];
		count %= mod;
		vec[i] = count;
	}

	return count;
}




int main() {
	ll S;

	cin >> S;

	cout << mycalc(S);
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
	static final int MAX = 100;
	static final int INF = 1 << 21;
	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;
	static int n;
	static int[][]M = new int[MAX][MAX];
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				M[i][j] = INF;
			}
		}
		for(int i = 0; i < n; i++) {
			int u = scan.nextInt();
			int k = scan.nextInt();
			for(int j = 0; j < k; j++) {
				int v = scan.nextInt();
				int c = scan.nextInt();
				M[u][v] = c;
			}
		}
		scan.close();
		dijkstra();
	}
	static void dijkstra() {
		int minV;
		int[]d = new int [MAX];
		int[]color = new int [MAX];
		for(int i = 0; i < n; i++) {
			d[i] = INF;
			color[i] = WHITE;
		}
		d[0] = 0;
		color[0] = GRAY;
		while(true) {
			minV = INF;
			int u = -1;
			for(int i = 0; i < n; i++) {
				if(minV > d[i] && color[i] != BLACK) {
					u = i;
					minV = d[i];
				}
			}
			if(u == -1) break;
			color[u] = BLACK;
			for(int v = 0; v < n; v++) {
				if(d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
		for(int i = 0; i < n; i++) {
			if(d[i] == INF) {
				System.out.println(i + " " + -1);
			}else {
				System.out.println(i + " " + d[i]);
			}
		}
	}
}


Measured memory_bytes: 40216
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 200100;
long long cnt[maxn];
int main(){
	int n, k;
	cin >> n >> k;
	for(int e = 1; e <= n; e++) cnt[e % k]++;
	long long ans = 0;
	for(int e = 0; e < k; e++){
		if((e + e)%k == 0){
			ans += cnt[e] * cnt[e] * cnt[e];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	hSlice := make([]int, n)
	for i := range hSlice {
		fmt.Scan(&hSlice[i])
	}

	sort.Ints(hSlice)

	min := 1000000001
	for i := 0; k+i-1 < n; i++ {
		if hSlice[k+i-1]-hSlice[i] < min {
			min = hSlice[k+i-1] - hSlice[i]
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 5504
# AOJ 1062: It's our delight!!
# Python3 2018.6.8 bal4u

# 昼11:00-14:59, 夕18:00-20:59, 深夜21:00-01:59
tt = [[660, 899], [1080, 1259], [1260, 1559]]
ss = ["lunch", "dinner", "midnight"]

while True:
	n = int(input())
	if n == 0: break
	cnt, ok = [0]*3, [0]*3
	for i in range(n):
		hm, MM = input().split()
		hh, mm = map(int, hm.split(':'))
		MM = int(MM)
		if hh <= 2: hh += 24
		MM = MM+hh*60 if MM >= mm else MM+(hh+1)*60
		t = hh*60+mm
		for j in range(3):
			if tt[j][0] <= t and t <= tt[j][1]:
				cnt[j] += 1
				if MM-t <= 8: ok[j] += 1
	for j in range(3):
		print(ss[j]+' ', end='')
		print("no guest" if cnt[j] == 0 else ok[j]*100//cnt[j])


Measured memory_bytes: 5608
function Main(input){
    const lines = input.split("\n");
    const n = parseInt(lines[0]);
    const p = lines[1].split(" ");
    ans = 0;
    min_p = n+10;
    for (i = 0; i < n; ++i){
        if (parseInt(p[i]) <= min_p){
            min_p = parseInt(p[i]);
            ans ++;
        }
    }
    console.log(ans);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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




int main() {
	int count;
	cin >> count;
	for (int i = 0;i <= count;i++) {
		if (i*i > count) {
			cout << (i - 1)*(i - 1) << endl;
			break;
		}
		if (count==1 ) {
			cout << 1 << endl;
			break;
		}
		if (count == 0) {
			cout << 0 << endl;
			break;
		}
	}

	return 0;
	}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		List<String> subs = new ArrayList<String>();
		for(int i = 1; i <= k; i++) {
			for(int j = 0; j + i <= s.length(); j++) {
				if(!(subs.contains(s.substring(j, j + i)))) subs.add(s.substring(j, j + i));
			}
		}
		Collections.sort(subs);
		System.out.println(subs.get(k - 1));
	}
}


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

int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  bool vic=false;
  for(int i=0;i<n;i++) cin >> a.at(i);
  sort(a.begin(),a.end(),greater<int>());
  int sum=0;
  for(int i=0;i<n;i++){
    h = h - a.at(i);
    if( h <= 0){
      vic = true;
      break;
    }
  }
  if(vic==true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

#define MAX_N 128;

int ans;


int main()
{
    int e;
    
    int ans = 100000000;;
    int temp = 10000000;
    
    
    while(cin >> e && e)
    {
        ans = 100000;
        for(int z=0; z<=100; ++z)
        {
            for(int y=0; y<=1000; ++y)
            {
                
                int m = (e - y*y - z*z*z) + y*y + z*z*z;
                if(m == e)
                {
                    int x = e - y*y - z*z*z;
                    if(x < 0){break;}
                    if(ans > x+y+z){ans = x+y+z;}
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
import sys
from itertools import permutations
def input(): return sys.stdin.readline().strip()


def main():
    N, M, num = map(int, input().split())
    R = list(map(int, input().split()))

    # 全点対間最短距離を予め求めておく（ワーシャルフロイド）
    path = [[10**18] * N for _ in range(N)]
    for i in range(N): path[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        path[a - 1][b - 1] = min(c, path[a - 1][b - 1])
        path[b - 1][a - 1] = min(c, path[b - 1][a - 1])
    for k in range(N):
        for i in range(N):
            for j in range(N):
                path[i][j] = min(path[i][j], path[i][k] + path[k][j])

    # あとはRの全順列に対して一つずつ評価すれば良い
    ans = 10**18
    for r in list(permutations(R)):
        d = 0
        for i in range(num - 1):
            d += path[r[i] - 1][r[i + 1] - 1]
        ans = min(ans, d)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 84048
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
l = []
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        t = 0
        for k in range(d):
            t+= (x[i][k]-x[j][k])**2
        if t == int(math.sqrt(t))**2:
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int,int>;
using ll = long long;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n,x,t; cin >> n >> x >> t;
  int c = 0, ans = 0;
  while (c < n) {
    c += x;
    ans += t;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	LL A, B;
	char op;
	cin >> A >> op >> B;

	cout << (op == '+' ? A + B : A - B) << endl;


	return 0;
}

Measured memory_bytes: 256