akhauriyash/Code-Regression huggingface dataset:
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-12 10:42:26
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=200010,mod=1000000007,i2=(mod+1)/2;
i64 n,s[N],v[N],w[N],zr[N],lst[N],a[N],b1[N],b2[N],ans,Ans;
i64 &Add(i64 &a,i64 b){ return a=(a+b)%mod; }
void add(i64 *b,int p,i64 v)
{
	while(p){ Add(b[p],v); p-=p&(-p); }
}
i64 query(i64 *b,int p)
{
	i64 ans=0;
	while(p<=n){ Add(ans,b[p]); p+=p&(-p); }
	return ans;
}
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1; a%=p;
	for(;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p;
	return r;
}
i64 inv(i64 a){ return power(a,mod-2,mod); }
i64 Query(i64 *b,int l,int r){ return (query(b,l)-query(b,r+1)+mod)%mod; }
int main()
{
	n=read();
	fr(i,1,n) s[a[i]=read()]++;
	fd(i,n,1) s[i]+=s[i+1];
	Ans=1;
	fr(i,1,n)
	{
		v[i]=s[i]-(n-i); Ans=Ans*v[i]%mod;
		if(!v[i]){ printf("0\n"); return 0; }
		if(v[i]-1){ zr[i]=zr[i-1]; w[i]=w[i-1]*(v[i]-1)%mod*inv(v[i])%mod; }
		else{ zr[i]=zr[i-1]+1; w[i]=1; }
		lst[zr[i]]=i;
	}
	fd(i,n,1)
	{
		Add(ans,Ans*(inv(w[a[i]])*Query(b1,a[i]+1,lst[zr[a[i]]])%mod*i2%mod));
		add(b1,a[i],w[a[i]]);
	}
//	printf("%d\n",int(Ans));
//	fr(i,1,n) printf("%d%c",int(zr[i]),i==n?'\n':' ');
	fr(i,1,n) b1[i]=0;
	fr(i,1,n)
	{
		Add(ans,Ans*(Query(b2,a[i],n)-Query(b1,a[i],lst[zr[a[i]]])*inv(w[a[i]])%mod*i2%mod+mod)%mod);
		add(b1,a[i],w[a[i]]); add(b2,a[i],1);
	}
	printf("%d\n",int(ans));
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)

int main() {
  int H, W;
  cin >> H >> W;
  
  string f = "";
  //(H+2)*(W+2)の形にして余裕を作る
  rep(i, W+2){
    f += '-';
  }
  rep(i, H){
    f += '-';
    rep(j, W){
      char cell;
      cin >> cell;
      f += cell;
    }
    f += '-';
  }
  rep(i, W+2){
    f += '-';
  }
  
  int bombs = 0;
  rep(i, H+2){
    rep(j, W+2){
      int x = (W+2)*i+j;
      if(f.at(x) == '-')
        continue;
      
      int b = 0;
      
      //左上
      if(f.at(x - (W+2) - 1) == '#')
        b++;
      
      //上
      if(f.at(x - (W+2)) == '#')
        b++;
      
      //右上
      if(f.at(x - (W+2) + 1) == '#')
        b++;
      
      //左
      if(f.at(x - 1) == '#')
        b++;
      
      //右
      if(f.at(x + 1) == '#')
        b++;
      
      //左下
      if(f.at(x + (W+2) - 1) == '#')
        b++;
      
      //下
      if(f.at(x + (W+2)) == '#')
        b++;
      
      //右下
      if(f.at(x + (W+2) + 1) == '#')
        b++;
      
      //出力部分
      if(f.at(x) == '#')
        cout << '#';
      else
        cout << b;
    }
    if(i != 0)
      cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PI;
typedef vector<PI> VT ;
#define ll long long int
# define print(arr) for(auto x:arr) cout<<x<<" "; cout<<endl
int solve(unordered_map<int,int>& freq){
	int Ans=0;
	for(auto x:freq){
		if(x.first<=x.second)
			Ans+=x.second-x.first;
		else
			Ans+=x.second;
	}
	return Ans;
}
int main() {
	int n,temp;
	cin>>n;
	unordered_map<int,int>freq;
	for(int i=0;i<n;i++){
		cin>>temp;
		freq[temp]+=1;
	}
	cout<<solve(freq)<<endl;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 1 << 30;
typedef pair< int, int > Pi;
 
struct UnionFind
{
  vector< int > data;
 
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
 
  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  void unite(int a, int b)
  {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(data[a] > data[b]) swap(a, b);
    data[a] += data[b];
    data[b] = a;
  }
};
 
struct edge
{
  int to, cost;
};
 
struct edgee
{
  int u, v, cost;
 
  bool operator<(const edgee& e) const
  {
    return (cost < e.cost);
  }
};
 
int N, M, K, Q;
int A[200000], B[200000], L[200000];
vector< edge > graph[100000];
int min_cost[100000];
vector< edgee > es;
int S[100000], T[100000];
int l[100000], r[100000];
 
int main()
{
  scanf("%d %d %d %d", &N, &M, &K, &Q);
  for(int i = 0; i < M; i++) {
    scanf("%d %d %d", &A[i], &B[i], &L[i]);
    --A[i], --B[i];
    graph[A[i]].push_back((edge) {B[i], L[i]});
    graph[B[i]].push_back((edge) {A[i], L[i]});
  }
 
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  fill_n(min_cost, N, INF);
 
  while(K--) {
    int F;
    cin >> F;
    min_cost[--F] = 0;
    que.emplace(0, F);
  }
 
  while(!que.empty()) {
    auto p = que.top();
    que.pop();
    if(min_cost[p.second] > p.first) continue;
    for(auto& e : graph[p.second]) {
      if(min_cost[e.to] > p.first + e.cost) {
        min_cost[e.to] = p.first + e.cost;
        que.emplace(min_cost[e.to], e.to);
      }
    }
  }
 
  for(int i = 0; i < M; i++) {
    es.emplace_back((edgee) {A[i], B[i], min(min_cost[A[i]], min_cost[B[i]])});
  }
  sort(begin(es), end(es));
  reverse(begin(es), end(es));
 
  UnionFind uf(M);
 
  for(int i = 0; i < Q; i++) {
    scanf("%d %d", &S[i], &T[i]);
    --S[i], --T[i];
    l[0] = -1, r[i] = M - 1;
  }
 
  for(int i = 0; i < 19; i++) {
    UnionFind tree(N);
    vector< Pi > querys;
    for(int j = 0; j < Q; j++) {
      if(r[j] - l[j] > 1) querys.emplace_back((l[j] + r[j]) >> 1, j);
    }
    sort(begin(querys), end(querys));
    int tail = 0;
    for(int j = 0; j < M; j++) {
      tree.unite(es[j].u, es[j].v);
      while(tail < querys.size() && querys[tail].first <= j) {
        int idx = querys[tail].second;
        int u = S[idx], v = T[idx];
        if(tree.find(S[idx]) == tree.find(T[idx])) {
          r[idx] = querys[tail].first;
        } else {
          l[idx] = querys[tail].first;
        }
        ++tail;
      }
    }
  }
 
  for(int i = 0; i < Q; i++) {
    printf("%d\n", es[r[i]].cost);
  }
}

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

int sum[2][101];

int main() {
    int n;
    cin >> n;
    rep(i,2){
        rep(j,n){
            int a;
            cin >> a;
            sum[i][j+1] = sum[i][j] + a;
        }
    }
    int ans = 0;
    rep(i,n){
        ans = max(ans, sum[0][i+1] + sum[1][n] - sum[1][i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import *
import sys
S=sys.stdin.readlines()
N,M=map(int,S[0].split())
G=[[] for i in range(N)]
a,b=0,0
for i in range(M):
  a,b=map(int,S[i+1].split())
  a,b=a-1,b-1
  G[a].append(b)
  G[b].append(a)
P=deque([0,G[0][0]])
U=[1]*N
U[0]=0
U[G[0][0]]=0
F=0
while True:
  for i in range(len(G[P[0]])):
    if U[G[P[0]][i]]:
      U[G[P[0]][i]]=0
      P.appendleft(G[P[0]][i])
      break
  else:
    break
while True:
  for i in range(len(G[P[-1]])):
    if U[G[P[-1]][i]]:
      U[G[P[-1]][i]]=0
      P.append(G[P[-1]][i])
      break
  else:
    break
print(len(P))
Q=[]
for i in range(len(P)):
  Q.append(P.popleft()+1)
print(*Q)

Measured memory_bytes: 103492
#include<bits/stdc++.h>
using namespace std;
int main(){
  double w,h,x,y;
  scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
  printf("%f ",w*h/2);
  if(fabs(x*2-w)<=1e-7&&fabs(y*2-h)<=1e-7)
  	printf("1\n");
	else
	printf("0\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

// Manages Union-Find Forest.
class UnionFindForest {
  std::vector<int> parent_;
  std::vector<int> rank_;
  std::vector<int> size_;

 public:
  // Initialize forest.
  // parent[i]=i, rank[i]=0.
  UnionFindForest(int n);
  // Get the number of the root of the node q.
  int Root(int q);
  // Return true if the roots of x and y is same.
  bool IsSame(int x, int y);
  // Unite the tree x and tree y.
  void Unite(int x, int y);
  int Size(int q);
};
int UnionFindForest::Size(int q) {
  return size_[Root(q)];
}
UnionFindForest::UnionFindForest(int n) {
  for (int i = 0; i < n; i++) {
    parent_.push_back(i);
    rank_.push_back(0);
    size_.push_back(1);
  }
}
int UnionFindForest::Root(int q) {
  if (parent_[q] == q) {
    return q;
  } else {
    return parent_[q] = Root(parent_[q]);
  }
}

bool UnionFindForest::IsSame(int x, int y) {
  return Root(x) == Root(y);
}

void UnionFindForest::Unite(int x, int y) {
  x = Root(x);
  y = Root(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) {
    parent_[x] = y;
    size_[y] += size_[x];
    size_[x] = 0;

  } else {
    parent_[y] = x;
    size_[x] += size_[y];
    size_[y] = 0;
    if (rank_[x] == rank_[y]) rank_[x]++;
  }
}

struct Queue {
  int a, b;
  Queue(int x, int y) {
    a = x;
    b = y;
  }
};

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t n, m;
  cin >> n >> m;
  UnionFindForest UFF(n + 1);
  std::vector<Queue> q;
  std::vector<int64_t> result;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    q.push_back(Queue(x, y));
  }
  int64_t answer = n * (n - 1) / 2;
  result.push_back(answer);
  for (int i = m - 1; i >= 0; i--) {
    int a = q[i].a;
    int b = q[i].b;
    // cout << a << " " << b << endl;
    if (UFF.IsSame(a, b)) {
      result.push_back(answer);
    } else {
      // cerr << UFF.Size(a) << "\t" << UFF.Size(b) << endl;
      answer -= UFF.Size(a) * UFF.Size(b);
      result.push_back(answer);
      UFF.Unite(a, b);
    }
  }

  for (int i = m - 1; i >= 0; i--) {
    cout << result[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4200
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    a = LI()
    max_a = max(a)
    min_a = min(a)

    if max_a > min_a + 1:
        print('No')
        return

    x = a.count(min_a)
    if max_a == min_a:
        if min_a == N-1 or min_a <= N//2:
            print('Yes')
        else:
            print('No')
        return

    if x < max_a and (N-x) >= (max_a - x) * 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 92156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans = "Even";

		if ((a * b) % 2 != 0) {
			ans = "Odd";
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long k = sc.nextLong();
    if(k<=a){
      System.out.print(a-k);
      System.out.print(" ");
      System.out.println(b);
    }else if(a+b<=k){
      System.out.println("0 0");
    }else{
      System.out.print("0 ");
      System.out.println(b-k+a);
    }

  }
  

  
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

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

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	int sa = 0;
	int sb = 0;
	for (auto &t : a) {
		cin >> t;
		sa += t;
	}
	for (auto &t : b) {
		cin >> t;
		sb += t;
	}
	int c = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= b[i]) {
			c += (b[i] - a[i] + 1) / 2;
		}
	}
	if (c <= sb - sa) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3328
import sys
input = sys.stdin.readline

from itertools import groupby

N, K = [int(x) for x in input().split()]
S = list(input().rstrip())

S_groupby = groupby(S)

zero_idx = [] # ゼロが何番目か
value_list = [] # 各インデックスのキーに対する個数
i = -1
for j in S_groupby:
    i += 1
    key, value = j[0], len(list(j[1]))
    value_list.append(value)
    if key == '0':
        zero_idx.append(i)

if len(zero_idx) <= K:
    print(len(S))
    sys.exit()

left = zero_idx[0]
right = zero_idx[K - 1]
if zero_idx[0] == 0:
    ans = [sum(value_list[left:right + 2])]
else:
    ans = [sum(value_list[left - 1:right + 2])]

for i in range(K, len(zero_idx)):
    new_right = zero_idx[i]
    new_left = zero_idx[i - K + 1]
    new_ans = ans[-1] + value_list[new_right] - value_list[left]
    if new_right + 1 < len(value_list):
        new_ans += value_list[new_right + 1]
    if left - 1 >= 0:
        new_ans -= value_list[left - 1]
    ans.append(new_ans)
    right, left = new_right, new_left

print(max(ans))


Measured memory_bytes: 8140
open System
open System.Collections.Generic

module InputUtility =
    let InputTokens = new Queue<string>()

    let EnsureInput () =
        if InputTokens.Count = 0 then
            let input = Console.ReadLine ()
            let s = input.Split ([|' '|], StringSplitOptions.RemoveEmptyEntries)
            if s.Length > 0 then
                for x in s do InputTokens.Enqueue(x)
                true
            else false
        else true

    let rec ReadNext () =
        if EnsureInput () then InputTokens.Dequeue ()
        else ReadNext ()

    let ReadNextInt () = ReadNext () |> int

    let Read2Int () = ReadNextInt (), ReadNextInt ()

    let ReadListOf f n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop ((ReadNext () |> f) :: acc) (c-1)
        loop [] n

    let MultipleCaseWithId f =
        let caseNum = ReadNextInt ()
        let rec loop index =
            if index = caseNum then ()
            else
                f index
                loop (index + 1)
        loop 0

    let MultipleCase f = MultipleCaseWithId (fun _ -> f ())

    let ReadList n =
        let rec loop acc = function
            | 0 -> List.rev acc
            | c -> loop (ReadNext () :: acc) (c-1)
        loop [] n

open InputUtility

module ARC075 =
    let private Bugged () = 
        let n = ReadNextInt ()
        let rec cal i (f: _ array) (g: _ array) =
            if i = n then
                f |> Seq.skip 1 |> Seq.max
            else
                [0..9] |> Seq.iter (fun i -> g.[i] <- f.[i])
                let d = ReadNextInt ()
                for i in [0..9] do
                    if f.[i] > -1 then
                        let j = (i + d) % 10
                        g.[j] <- max g.[j] (f.[i] + d)
                cal (i + 1) g f
        let na () = Array.create 10 -1
        let f = na ()
        f.[0] <- 0
        cal 0 f (na ())
        |> max 0
        |> printfn "%d"

    let Entry = Bugged

ARC075.Entry ()

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

knock=0
ex=0
for i in range(n):
    if a[i] < b[i]:
        ex=b[i]-a[i]
        knock+=a[i]
    elif a[i] >= b[i]:
        ex=0
        knock+=b[i]

    if ex != 0:
        if a[i+1] - ex <= 0:
            knock+=a[i+1]
            a[i+1]=0
        else :
            knock+=ex
            a[i+1]=a[i+1]-ex

print(knock)


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

#define MOD 1000000007

ll get_attack_count(ll hp) {

  if (hp == 1) {
    return 1;
  }

  return get_attack_count(hp / 2) * 2 + 1;
}

int main() {
  ll h;
  cin >> h;

  ll ans = get_attack_count(h);

  cout << ans << endl;
}


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

using namespace std;

int D,N;
int temp[201];
int cloth[201][3];
int a[201][201][201];


int dp(int d,int yk,int k){
	if(d > 0){
		if(!(cloth[k][0] <= temp[d] && cloth[k][1] >= temp[d]))return 0;
	}

	if(a[d][yk][k] >= 0) return a[d][yk][k];

	if(d == D){
		return a[d][yk][k] = fabs(cloth[yk][2] - cloth[k][2]) ;
	}

	int eva = 0;
	int sum = 0;
	for(int i = 1; i <= N ;i++){
		if(d < 2){
			sum = dp(d+1, k, i);
			eva = max(eva,sum);
		}else{
			sum = dp(d +1, k, i) + fabs(cloth[yk][2] - cloth[k][2]);
			// cout <<d <<" "<< yk << " "<<k <<" "<< sum << endl;
			eva = max(eva,sum);
		}
	}

	return a[d][yk][k] = eva;


	// long long int eva = 0;
	// long long int sum = 0;
	// if(d >= 2){

	// 	eva = fabs(yeva - cloth[k][2]);
	// }

	// if(d == D){
	// 	// cout<<d<<" "<<k<<" "<<eva<<endl;
	// 	return a[d][k] = eva;
	// }


	// for(int i = 1;i <= N;i++){
	// 	if(d == 0){
	// 		eva = max(eva, dp(d+1, i, 0));
	// 	}else if( d == 1){
	// 		// cout<<sum<< " "<<eva<<endl;
	// 		// cout<<eva<<" "<<dp(d+1,i,cloth[k][2])<<endl;
	// 		eva = max(eva,dp(d+1, i, cloth[k][2]));
	// 	}else{
	// 		sum = dp(d+1,i,cloth[k][2]) + eva;
	// 		cout<<d<<" "<<dp(d+1,i,cloth[k][2])<<" "<<eva <<" "<<sum<<endl;
	// 		// cout<<eva<<" "<<dp(d+1,i,cloth[k][2])<<endl;
	// 		eva = max(eva,sum);
	// 	}
	// }
	// // cout << d <<" " <<k<<" " << eva <<endl; 
	// return a[d][k] = eva;
}


int main(){
	fill_n(temp,201,-1);
	fill_n(*cloth,201*3,-1);
	fill_n(**a,201*201*201,-1);
	cin >> D >> N;
	for(int i = 1;i <= D;i++){
		cin >>temp[i];
	}
	for(int i = 1;i <= N;i++){
		for(int j = 0;j < 3;j++){
			cin >> cloth[i][j];
		}
	}
	cout << dp(0,0,0) << endl;
}

Measured memory_bytes: 34820
n = int(input())
 
ac_counter = 0
wa_counter = 0
tle_counter = 0
re_counter = 0
 
for i in range(n):
  str = input()
  if str == "AC":
    ac_counter += 1
  elif str == "WA":
    wa_counter += 1
  elif str == "TLE":
    tle_counter += 1
  else :
    re_counter += 1
print("AC x",ac_counter)
print("WA x",wa_counter)
print("TLE x",tle_counter)
print("RE x",re_counter)

Measured memory_bytes: 9112
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int sec = int.Parse(Console.ReadLine());

            int hour = sec / 3600;
            int min = (sec / 60) % 60;
            int second = sec % 60;

            Console.WriteLine(hour + ":" + min + ":" + second);
        }
    }
}

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

const int MOD = 1000000007;

int main(){

    int N,M;
    cin >> N >> M;
    vector<bool> ok(N+1,true);
    rep(i,M){
        int a;
        cin >> a;
        ok[a] = false;
    }

    vector<int> dp(N+1,0);//dp[i+1]->i+1段目に到達する移動方法の数
    dp[0] = 1;
    rep(i,N){
        if(ok[i+1]){
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
        if(ok[i+2] && i+2 <= N){
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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


struct mint {
  ll x;
  mint(ll x=0) : x((x%MOD+MOD)%MOD) {}
  mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  mint operator+(const mint a) const { return mint(*this) += a; }
};
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


const int M = 60;
mint dp[M+1][2][2][2];


int main() {
  ll L, R; cin >> L >> R;
  dp[0][0][0][0] = 1;

  rep(i, M) {
    int Li = L>>(M-1-i)&1; // L の上から i 桁目
    int Ri = R>>(M-1-i)&1; // R の上から i 桁目
    rep(j, 2) rep(l, 2) rep(r, 2) rep(xi, 2) rep(yi, 2) {
      int j2 = j, l2 = l, r2 = r; // 遷移前の状態で初期化

      if (xi > yi) continue; // (xi, yi) = (1, 0) なら無視

      if (!j && (xi < yi)) continue; // (1, 1) が現れる前に (0, 1) が現れたら無視
      if (xi&yi) j2 = 1;             // (1, 1) が現れたら j2 を更新

      // 条件 x ≧ L の処理
      if (!l && (xi < Li)) continue;
      if (xi > Li) l2 = 1;

      // 条件 y ≦ R の処理
      if (!r && (yi > Ri)) continue;
      if (yi < Ri) r2 = 1;

      dp[i+1][j2][l2][r2] += dp[i][j][l][r]; // 遷移式
    }
  }

  mint ans = 0;
  rep(l, 2) rep(r, 2) ans += dp[M][1][l][r];
  cout << ans << '\n';
}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  
  for (int i=0; i < N; i++) {
  int L, R;
    cin >> L >> R;
   
   sum += (R - L + 1);
    
  }
  
  cout << sum << endl;
  
}
    

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

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

    sort(a,a+n);

    int ans=1e9,ret=0;

    for(int i=a[0];i<=a[n-1];i++){
        ret=0;
        for(int j=0;j<n;j++){
            ret+=pow(a[j]-i,2);
        }
        ans=min(ret,ans);
    }

    cout<<ans;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

x = [a,b,c,d,e]

z = [10-(x[i]%10) for i in range(len(x))]
zz = [0 if z[i] == 10 else z[i] for i in range(len(z))]

ans = sum(x)+sum(zz)-max(zz)

print(ans)


Measured memory_bytes: 3064
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write

root = None
def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z[2] < x[2]:
            x = x[0]
        else:
            x = x[1]
    z[3] = y

    if y is None:
        root = z
    elif z[2] < y[2]:
        y[0] = z
    else:
        y[1] = z

def find(k):
    x = root
    while x is not None:
        if x[2] == k:
            return 1
        if k < x[2]:
            x = x[0]
        else:
            x = x[1]
    return 0

def debug():
    s0 = [""]
    s1 = [""]

    def dfs(nd):
        v = str(nd[2])
        s0.append(v)
        if nd[0] is not None:
            dfs(nd[0])
        s1.append(v)
        if nd[1] is not None:
            dfs(nd[1])
    dfs(root)
    return " ".join(s1), " ".join(s0)


M = int(readline())
ans = []
for m in range(M):
    cmd, *V, = readline().split()
    if cmd == "print":
        ans.extend(debug())
    elif cmd == "find":
        ans.append("yes" if find(int(V[0])) else "no")
    else:
        insert([None, None, int(V[0]), None])
write("\n".join(ans))
write("\n")




Measured memory_bytes: 108156
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<list>
#include<algorithm>

using namespace std;

int main() {
	int k;
	int a, b;
	bool flag = false;
	cin >> k;
	cin >> a >> b;
	for (int i = a; i <= b; ++i) {
		if (i % k == 0) {
			flag = true; break;
		}
	}
	if (flag) cout << "OK" << endl;
	else  cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3624
<?php
$a = (int)trim(fgets(STDIN));
$b = (int)trim(fgets(STDIN));

switch ($a+$b) {
	case 3:
		echo 3;
		break;
	case 4:
		echo 2;
		break;
	case 5:
		echo 1;
		break;
}

Measured memory_bytes: 4728
package main

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

func nextLine(r *bufio.Reader) string {
	var buf []byte
	for {
		line, isPrefix, err := r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func nextStr(s *bufio.Scanner) string {
	s.Scan()
	ref := s.Bytes()
	cp := make([]byte, len(ref))
	copy(cp, ref)
	return string(cp)
}

func nextInt(s *bufio.Scanner) int {
	n, err := strconv.Atoi(nextStr(s))
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	N := nextInt(s)
	K := nextInt(s)

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

	sort.Ints(P)

	sum := 0

	for i := 0; i < K; i++ {
		sum += P[i]
	}

	fmt.Println(sum)
}


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

constexpr int MAX = 100000;

class Union_Find {
  public:
    int par[MAX], rank[MAX], size[MAX], gnum;

    Union_Find(int N) {
        gnum = N;
        for (int i = 0; i < N; i++) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    int find(int x)
    {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        gnum--;
    }

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

    int getSize(int x)
    {
        return size[find(x)];
    }

    int groups()
    {
        return gnum;
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        std::cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    int bridge_count = 0;
    for (int i = 0; i < M; i++) {
        Union_Find uf(N);
        for (int j = 0; j < M; j++) {
            if (i == j) {
                continue;
            }

            uf.unite(a[j], b[j]);
        }

        if (uf.groups() != 1) {
            bridge_count++;
        }
    }

    std::cout << bridge_count << std::endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = nk[0];
            var k = nk[1];
            Console.WriteLine(Math.Ceiling((n - 1) / (k - 1)));
        }
    }
}


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

int main(){
    int N;
    cin >> N;
    vector<int> R(N);
    for(int i=0; i<N; i++) cin >> R.at(i);
    
    int maxv = R.at(1)-R.at(0), minv=R.at(0);
    
    for(int i=1; i<N; i++){
        if(maxv < R.at(i) - minv) maxv = R.at(i) - minv;
        if(minv > R.at(i)) minv = R.at(i);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3568
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(int i=a;i<b;i++)
#define rfor(i,a,b)     for(int i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

ll _gcd(ll a, ll b)
{
    if(b == 0) return a;
    return _gcd(b,a%b);
}

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

void solve()
{
    ll n; cin>>n;
    vector<ll> a(n), bits(25,0);
    rep(i,0,n)
    {
        cin>>a[i];
    }
    ll l = 0;
    ll ans = 0;
    rep(i,0,n)
    {
        ll temp = a[i];
        while(temp)
        {
            ll power = log2(temp&(-temp));
            temp-=(temp&(-temp));
            while(bits[power])
            {
                ans+=(i-l);
                while(a[l])
                {
                    ll rem = log2(a[l]&(-a[l]));
                    bits[rem] = 0;
                    a[l]-=(a[l]&(-a[l]));
                }
                l++;
            }
            bits[power] = 1;
        }
    }
    ans+=((n-l)*(n-l+1))/2;
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; /*cin>>t;*/ t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
N=input()
target = list(map(int, input().split()))

def calc_factors(N):
    n = int(N**.5)
    arr = []
    tmp = N
    for i in range(2,n+1):
        if tmp % i == 0:
            while tmp % i == 0:
                arr.append(i)
                tmp = int(tmp/i)
    if tmp != 1: arr.append(tmp) 
    return arr

d = {}
for i in target:
    arr = calc_factors(i)
    for a in set(arr):
        if a in d.keys():
            d[a] = max(d[a], arr.count(a))
        else:
            d[a] = arr.count(a)
res = 1
for k,v in d.items():
    res*=(int(k)**int(v))
print(res)


Measured memory_bytes: 5652
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <iostream>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; ++i)


int main() {
    int n, strMax = 12;
    scanf("%d", &n);
    char action[strMax], key[strMax];
    char *ins = "insert";
    char *fin = "find";
    map<string, bool> data;
    rep(i, n) {
        scanf("%s %s", action, key);
        if (strcmp(ins, action) == 0) {
            data[key] = true;
        } else if (strcmp(fin, action) == 0) {
            if (data[key]) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 47560
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (b >= a * c)
        cout << c << endl;
    else
    {
        cout << b / a << endl;
        }
}


Measured memory_bytes: 256
// this line is here for a reason
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
  return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(
    ostream& o, const C& c) {
  o << '{';
  for (auto it = c.begin(); it != c.end();)
    o << *it << (++it != c.end() ? ", " : "}");
  return o;
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}

const ll inf = 1e17;

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

    int n, W;
    cin >> n >> W;

    vector<ll> wgt(n), val(n);
    F0R(i, n) cin >> wgt[i] >> val[i];

    ll maxVal = accumulate(ALL(val), 0);

    vector<vector<ll>> dp(maxVal + 1, vector<ll>(n, inf));
    fill(ALL(dp[0]), 0);

    FOR(r, 1, maxVal + 1) {
        F0R(c, n) {
            if(!c) {
                if(val[0] == r)
                    dp[r][0] = wgt[0];
            } else {
                dp[r][c] = min(dp[r][c - 1], 
                               r - val[c] < 0 ? inf : dp[r - val[c]][c - 1] + wgt[c]);
            }
        }
    }

    int r = maxVal;
    while(dp[r][n - 1] > W)
        r--;
    cout << r << endl;

}



Measured memory_bytes: 82304
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep(i,n) for(int i=0;i<n;i++)

int N,t[16][17],dp[1<<16];

int main(){
	while(cin>>N&&N){
		fill(dp,dp+(1<<N),INF);
		rep(i,N)rep(j,N+1)cin>>t[i][j];
		dp[0]=0;
		for(int i=1;i<(1<<N);i++)rep(j,N)if(1<<j&i){
			int c=t[j][0];
			rep(k,N)if(j!=k&&1<<k&i)c=min(c,t[j][k+1]);
			dp[i]=min(dp[i],dp[i^1<<j]+c);
		}
		cout<<dp[(1<<N)-1]<<endl;
	}
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

int main(){

	lli w,h;
	cin>>w>>h;

	vector<lli> p(w),q(h);

	REP(i,0,w)cin>>p[i];
	REP(i,0,h)cin>>q[i];

	sort(p.begin(),p.end());
	sort(q.begin(),q.end());

	lli pi=0,qi=0;

	lli ans=0;
	while(true){
		if(pi == p.size()){
			for(;qi<q.size();qi++)ans+=q[qi];
			break;
		}
		if(qi == q.size()){
			for(;pi<p.size();pi++)ans+=p[pi];
			break;
		}

		if(p[pi]<=q[qi]){
			ans += p[pi]*(h+1-qi);
			pi++;
		}
		else{
			ans += q[qi]*(w+1-pi);
			qi++;
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll x, k; gi(x), gi(k);
	x = x % k;
	print(min(x, k-x));
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(9);
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    if (a <= 399) data.at(0)++;
    else if(a <= 799) data.at(1)++;
    else if(a <= 1199) data.at(2)++;
    else if(a <= 1599) data.at(3)++;
    else if(a <= 1999) data.at(4)++;
    else if(a <= 2399) data.at(5)++;
    else if(a <= 2799) data.at(6)++;
    else if(a <= 3199) data.at(7)++;
    else data.at(8)++;
  }
  int base = 0;
  for(int i = 0; i < 8; i++) {
    if(data.at(i) != 0) base++;
  }
  cout << max(base, 1) << ' ' << base + data.at(8) << endl;
  return 0;
}


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

void f(long long n)
{
	if(n<=0) return;
	f((n-1)/26);
	cout << char((n-1)%26+'a');
}
int main() {
	long long n;
	cin >> n;
	f(n);
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        public struct Card
        {
            public char c;
            public int d;
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            //SolveB(args);
            SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            //int n =int.Parse(Console.ReadLine());
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '),  int.Parse);
            int a = arr[0];
            int b = arr[1];
            string result = null;
            if( a + b == 15)
            {
                result = "+";
            }else if( a * b == 15)
            {
                result = "*";
            }else
            {
                result = "x";
            }
            Console.WriteLine(result);
        }
        static void SolveB(string[] args)
        {
            string sz = Console.ReadLine();
            int w = int.Parse(Console.ReadLine());

            string result = "";
            for(int i=0;i<sz.Length;i+=w)
            {
                result += sz[i];
            }
            Console.WriteLine(result);
        }
        static void SolveC(string[] args)
        {
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long n = arr[0];
            long m = arr[1];
            long d = arr[2];

            double result = 0.0;
            if (n == 1)
            {
                result = 1.0;
            }
            else if( n == 2)
            {
                result = (double)(m - 1) / 2;
            }
            else
            {
                 if( d == 0)
                {
                    result = (double)(m - 1) / n;
                }
                else
                {
                    result = (double)(n - d) * 2 * (m - 1) / n / n;
                }
            }
            Console.WriteLine(result);
        }
    }

}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second

int main(void){
	int n,d;
	cin >> n >> d;
	int ans = 0;
	vector<vector<int>> x(n,vector<int>(d,0));
	rep(i, n){
		rep(j, d){
			cin >> x[i][j];
		}
	}
	rep(i, n-1){
		for(int j = i+1; j<n; j++){
			int dis = 0;
			rep(k, d){
				int sa = x[i][k] - x[j][k];
				dis += sa * sa;
			}
			int sq = sqrt(dis);
			ans += (sq * sq == dis);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int SIZE = 10000000;
bool isprime[SIZE + 1];
vector<int> prime;
void make_prime(){
    for(int i = 2; i <= SIZE; i++){
        isprime[i] = true;
    }
    isprime[0] = false;
    isprime[1] = false;
    for(int i = 2; i <= SIZE; i++){
        if(isprime[i] == false) continue;
        for(int j = i * 2; j <= SIZE; j += i){
            isprime[j] = false;
        }
        prime.push_back(i);
    }
}

vector<int> yotugo;
void make_list(){
    for(int i = 0; i <= (prime.size() - 4); i++){
        if(prime[i + 1] == (prime[i] + 2) && prime[i + 2] == (prime[i] + 6) && prime[i + 3] == (prime[i] + 8)){
            yotugo.push_back(prime[i + 3]);
        }
    }
}

int check(int n){
    int i;
    for(i = 0; yotugo[i] <= n && i < yotugo.size(); i++) ;
    return yotugo[i - 1];
}

int main(){
    make_prime();
    make_list();
    int n;
    while(cin >>n){
        if(n == 0) break;
        cout <<check(n) <<endl;
    }
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if ( A == 1 && B == 2 ){
    cout << 3 << endl;
  }
  else if ( A == 1 && B == 3 ){
    cout << 2 << endl;
  }
  else if ( A == 2 && B == 1 ){
    cout << 3 << endl;
  }
  else if ( A == 2 && B == 3 ){
    cout << 1 << endl;
  }
  else if ( A == 3 && B == 1 ){
    cout << 2 << endl;
  }
  else if ( A == 3 && B == 2 ){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			int num = 0, c = i;
			for (int j = 0; j < 5; j++) {
				num += c % 10;
				c = c / 10;
			}
			if (a <= num && num <= b) {
				sum += i;
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <stack>
typedef long long int llint;

int main(void){
  int n;
  std::cin >> n;
  std::vector<std::array<int, 2> > edges(n-1);
  for(int i=0; i<n-1; i++){
    std::cin >> edges[i][0] >> edges[i][1];
    edges[i][0]--;
    edges[i][1]--;
  }
  
  std::vector<int> counts(n, 0);
  for(int i=0; i<n-1; i++){
    counts[edges[i][0]]++;
    counts[edges[i][1]]++;
  }

  int color = *std::max_element(counts.begin(), counts.end());
  std::cout << color << std::endl;

  std::vector<std::vector<int> > indices(n);
  for(int i=0; i<n-1; i++){
    indices[edges[i][0]].push_back(i);
    indices[edges[i][1]].push_back(i);
  }

  std::vector<int> edge_colors(n-1, -1);
  std::vector<int> connected_colors(n, -1);
  connected_colors[0] = 0;

  int cnt_checked = 0;
  std::vector<bool> checked(n, false);
  std::stack<int> st;
  st.push(0);
  while(cnt_checked < n){
    int next = st.top();
    st.pop();
    int next_color = 1;
    
    if(checked[next] == false){
      checked[next] = true;
      cnt_checked++;
    }else{
      continue;
    }

    for(const auto& elem: indices[next]){
      if(next_color == connected_colors[next]) next_color++;
      if(edges[elem][0] == next){
	if(checked[edges[elem][1]] == true) continue;
	connected_colors[edges[elem][1]] = next_color;
	st.push(edges[elem][1]);
      }else{
	if(checked[edges[elem][0]] == true) continue;
	connected_colors[edges[elem][0]] = next_color;
	st.push(edges[elem][0]);
      }
      edge_colors[elem] = next_color++;
    }
  }

  for(int i=0; i<n-1; i++){
    std::cout << edge_colors[i] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 7936
N = int(input())
A = list(map(int, input().split()))

A = [i for i in A if i % 2 == 0]
odd = len(A)
A = [i for i in A if i % 3 == 0 or i % 5 == 0]
if odd == len(A):
    print("APPROVED")
else:
    print("DENIED")
    

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

using ui = unsigned int;
using ull = unsigned long long;
using sll = signed long long;

template<class C>
auto f(sll n, sll x,const C&apn)->sll {
//	std::cout << n <<" "<< x << "\n";

	if (n == 0)
		return 1 <= x ? 1 : 0;
	
	auto u_index = static_cast<ui>(n) - 1;

	if (x <= apn[u_index].first + 1 )
		return f(n - 1, x - 1,apn);
	else
		return apn[u_index].second + 1
		+ f(n - 1, x - 2 - apn[u_index].first, apn);
}



int main() {
	
	//ui n;
	
	sll n,x;
	std::cin >> n >> x;

	std::vector<std::pair<sll, sll>> apn;
	apn.resize(static_cast<ui>(n));
	apn[0] = { 1,1 };

	for (ui i{ 1 }; i < static_cast<ui>(n); ++i) {
		apn[i].first = 3 + 2 * apn[i - 1].first;
		apn[i].second = 1 + 2 * apn[i - 1].second;
	}

	std::cout << f(n, x, apn) << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int n,y,r,t;
		String b;
		n=scan.nextInt();
		if(n==0)break;
		y=scan.nextInt();
		String num[]=new String[n];
		double max=0;
		
		String most="";
		for(int i=0;i<n;i++)
		    {
			b=scan.next();
			r=scan.nextInt();
			t=scan.nextInt();
			double gankin=0;
			if(t==1)
			    {
				
				gankin=1+(y*(r/100.0));
				    
			    }
			else if(t==2)
			    {
				
				gankin=(Math.pow(1+(r/100.0),y));
				    
			    }
			
			if(max<gankin)
			    {
				max=gankin;
				most=b;
			    }
			
		    }
		
		System.out.println(most);
	    }
    }
}

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

using ll=long long;
int H,W;
const int MOD=1000000007;
char graph[1010][1010];
ll dp[1010][1010];


void add(ll &a, ll b){
  a=(a+b)%MOD;
  }

int main(){
  cin >> H >> W;
  dp[0][0]=1;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >> graph[i][j];
    }
  }
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      if (graph[i+1][j]=='.') add(dp[i+1][j],dp[i][j]);
      if (graph[i][j+1]=='.') add(dp[i][j+1],dp[i][j]);
    }
  }
      
  cout << dp[H-1][W-1] << endl;
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

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

const int max_n = 1, inf = 1000111222;

int main()
{
    //freopen("input.txt", "r", stdin);
    int a, b ,c, d;
    cin >> a >> b >> c >> d;
    int s = a * 60 + b;
    int f = c * 60 + d;
    int k;
    cin >> k;
    cout << max(0, f - s - k) << endl;

    return 0;
}




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

int main() {
    int n;
    cin>>n;
    int t1,x1,y1;
    int t2,x2,y2;
    t1=0;x1=0;y1=0;
    for(int i=0;i<n;i++){
        t2=t1;x2=x1;y2=y1;
        cin>>t1>>x1>>y1;
        if(((abs(x1-x2)+abs(y1-y2))>(t1-t2))||((abs(x1-x2)+abs(y1-y2))%2!=((t1-t2)%2))){
                cout<<"No"<<endl;
                exit(0);
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256