akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

const int MAX = 510000; //nCrのr
//const ll INF = (ll)1e18 + 1;

#include <cassert>
long long fac[MAX], finv[MAX], inv[MAX], facn[MAX];
class mint {
public:
    long long x;
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    //mint operator-() const{ return mint(-x);}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

};

template<class T>
struct combination {
    vector<T> fact_, ifact_;
    combination(long long n):fact_(n+1),ifact_(n+1) {
      assert(n < MOD);
      fact_[0] = 1;
      for (int i = 1; i <= n; ++i) fact_[i] = fact_[i-1]*i;
      ifact_[n] = fact_[n].inv();
      for (int i = n; i >= 1; --i) ifact_[i-1] = ifact_[i]*i;
    }
    T com(long long n, long long k) {
      if (k < 0 || k > n) return 0;
      return fact_[n]*ifact_[k]*ifact_[n-k];
    }
    T fact(ll n){
      if (n < 0) return 0;
      return fact_[n];
    }
};

int main(){
  ll N, M, K; cin >> N >> M >> K;
  combination<mint> C(1000000);
  mint sum = 0;
  for (int i = 0; i <= N - 1; ++i){
    for (int j = 0; j <= M - 1; ++j){
      mint tmp = mint(N - i) * mint(M - j) * (i + j);
      if (i != 0 && j != 0) tmp *= 2;
      sum += tmp;
    }
  }
  sum *= C.com(N * M - 2, K - 2);
  cout << sum.x << endl;
}


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

using namespace std;

const int N = 300005;

int a[N], b[N];

int main() {
	int n;
	scanf("%d", &n);
	string str;
	cin >> str;
	for (int i = 1; i <= n; i++) {
		if (str[i - 1] == 'E') {
			a[i] += 1 + a[i - 1];
			b[i] += b[i - 1];
		} else {
			b[i] += 1 + b[i - 1];
			a[i] += a[i - 1];
		}				
	}
	int ans = n - 1 - (b[n] - b[1]);  
	for (int i = 2; i <= n; i++) {
		int e = a[i - 1];
		int ne = i - 1;
		int w = b[n] - b[i];
		int nw = n - i;
		ans = min(ans, ne - e + nw - w);								
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2948
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

a,b,c = readInts()

i = a
his = []
while 1:
  if i%b==c:
    print("YES")
    exit()
  else:
    if i%b in his:
      print("NO")
      exit()
    else:
      his.append(i%b)
      i+=a



Measured memory_bytes: 9392
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n;
  cin>>n;
  double ans = 0;
  REP(i,n){
    double x;
    string s;
    cin>>x>>s;
    if(s=="JPY"){
      ans += x;
    }else{
      ans += x * 380000;
    }
  }
  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n;
  vector<pair<int,int> > ans;
  cin>>n;
  deque<int> a;
  int num;
  rep(i,n){
    cin>>num;
    a.push_back(num);
  }
  if(n==2 && a[0]==0 && a[1]==0){
    cout<<0<<endl;
    cout<<0<<" "<<0<<endl;
    return 0;
  }
  int p=0,m=0;
  sort(a.begin(),a.end());
  rep(i,n){
    if(a[i]<0) m++;
    else p++;
  }

  int newnum;
  if(m==0){
    newnum=a.front()-a.back();
    ans.push_back(make_pair(a.front(),a.back() ) );
    a.pop_front();
    a.pop_back();
    a.push_front(newnum);
  }
  int mx=a.back(),mn=a.front();
  repi(i,1,a.size()-1 ){
    if(a[i]<0){
      ans.push_back(make_pair(mx,a[i]));
      mx-=a[i];
    }else{
      ans.push_back(make_pair(mn,a[i]));
      mn-=a[i];
    }
  }
  cout<<mx-mn<<endl;
  rep(i,ans.size() ){
    cout<<ans[i].fst<<" "<<ans[i].scd<<endl;
  }
  cout<<mx<<" "<<mn<<endl;
  
  
  return 0;
}


Measured memory_bytes: 4468
using System;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            int[] s = new int[10];
            int sum = 0;
            for (int i = 0; i < 10; i++ )
            {
                s[i] = int.Parse(Console.ReadLine());
                sum += s[i];
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }


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

int main() {
    long long a=0, b=0, c=0, d=0;
    cin >> a >> b >> c >> d;
    long long e=0, f=0, g=0, h=0;
    e = a * c;
    f = a * d;
    g = b * c;
    h = b * d;
    long long x=0, y=0;
    x = max(e, f);
    y = max(g, h);
    if (x > y){
        cout << x << endl;
    }
    else {
        cout << y << endl;
    }
}

Measured memory_bytes: 3648
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	var a int
	nums := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a)
		nums[a]++
	}

	// priority_queue
	ih := &intHeap{}
	heap.Init(ih)
	for _, v := range nums {
		if v >= 2 {
			heap.Push(ih, v)
		}
	}

	ans := n
	for ih.Len() > 0 {
		v1 := heap.Pop(ih)

		var v2 interface{}
		if ih.Len() > 0 {
			v2 = heap.Pop(ih)
		}

		if v1.(int) > 2 {
			heap.Push(ih, v1.(int)-1)
		}
		if v2 != nil && v2.(int) > 2 {
			heap.Push(ih, v2.(int)-1)
		}

		ans -= 2
	}

	if ans <= 1 {
		fmt.Println(1)
	} else {
		fmt.Println(ans)
	}
}

type intHeap []int

func (h intHeap) Len() int           { return len(h) }
func (h intHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h intHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}
func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
char s[3010],t[3010];
int dp[3010][3010],pr[3010][3010];
int sl,tl;
void ds(int p) {
	for(int i=0;i<tl;i++) {
		int lv=0,rv=0;
		if(i > 0) {lv=dp[p][i-1];}
		if(p > 0) {rv=dp[p-1][i];}
		if(t[i] == s[p]) {
			pr[p][i] = p;
			if(p == 0 || i == 0) {
				dp[p][i] = 1;
			} else {
				dp[p][i] = dp[p-1][i-1]+1;
				if(lv == dp[p][i]) {pr[p][i] = pr[p][i-1];}
				if(rv == dp[p][i]) {pr[p][i] = pr[p-1][i];}
			}
		} else {
			if(rv >= lv) {
				if(rv == 0) {pr[p][i] = -1;} else {
					pr[p][i] = pr[p-1][i];
				}
				dp[p][i] = rv;
			} else {
				if(lv == 0) {pr[p][i] = -1;} else {
					pr[p][i] = pr[p][i-1];
				}
				dp[p][i] = lv;
			}
		}
	}
}
int main() {
	scanf("%s ",s);
	scanf("%s ",t);
	memset(dp,-1,sizeof(dp));
	sl = strlen(s);tl=strlen(t);
	for(int i=0;i<sl;i++) {
		ds(i);
	}
	char ret[3010];
	int rd = tl-1;
	int vl=dp[sl-1][rd],pl=pr[sl-1][rd];
	ret[vl] = '\0';
	while(vl > 0) {
		ret[vl-1] = s[pl];
		pl = pr[pl][rd];
		vl = dp[pl][rd];
		rd--;
	}
	/*
	for(int i=tl-1;i>=0;i--) {
		for(int j=0;j<sl;j++) {
			printf("%d ",dp[j][i]);
		}
		printf("\n");
	}
	for(int i=tl-1;i>=0;i--) {
		for(int j=0;j<sl;j++) {
			printf("%d%c ",pr[j][i],pr[j][i]>-1?s[pr[j][i]]:'|');
		}
		printf("\n");
	}
	*/
	printf("%s\n",ret);
}

Measured memory_bytes: 71040
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<char> v(4);
    string A = "+-*";
    while(true){
        for (auto &&i : v) scanf(" %c", &i);
        if(v[0] == '0') break;
        auto solve = [&](string &s) -> string {
            stack<pair<string, int>> S;
            for (auto &&i : s) {
                if(isdigit(i)) S.emplace(string(1, i), i-'0');
                else if(i == '+'){
                    if(S.size() < 2) return {};
                    auto a = S.top(); S.pop();
                    auto b = S.top(); S.pop();
                    S.emplace("(" + a.first + "+" + b.first + ")", a.second+b.second);
                }else if(i == '*'){
                    if(S.size() < 2) return {};
                    auto a = S.top(); S.pop();
                    auto b = S.top(); S.pop();
                    S.emplace("(" + a.first + "*" + b.first + ")", a.second*b.second);
                }else if(i == '-'){
                    if(S.size() < 2) return {};
                    auto a = S.top(); S.pop();
                    auto b = S.top(); S.pop();
                    S.emplace("(" + a.first + "-" + b.first + ")", a.second-b.second);
                }
            }
            if(S.top().second != 10) return {};
            else return S.top().first;
        };
        int ok = 0;
        for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) for (int k = 0; k < 3; ++k) {
             string s = string(1, v[0])+v[1]+v[2]+v[3]+A[i]+A[j]+A[k];
             sort(s.begin(),s.end());
             do {
                 auto ret = solve(s);
                 if(!ret.empty()){
                     cout << ret << "\n";
                     i = j = k = 3;
                     ok = 1;
                     break;
                 }
             }while(next_permutation(s.begin(),s.end()));
        }
        if(!ok) puts("0");
    }
    return 0;
}


Measured memory_bytes: 3100
#!python3

LI = lambda: list(map(int, input().split()))

# input
H1, M1, H2, M2, K = LI()


def main():
    x = H1 * 60 + M1
    y = H2 * 60 + M2
    ans = y - x - K
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
package main

import "fmt"

func DayDream(S string) string {
	i := 0
	S = Reverse(S)
	for i < len(S) {
		if S[i:i+5] == "maerd" || S[i:i+5] == "esare" {
			i += 5
		} else if S[i:i+6] == "resare" {
			i += 6
		} else if S[i:i+7] == "remaerd" {
			i += 7
		} else {
			return "NO"
		}
	}
	return "YES"
}

func Reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main(){
    var S string
	fmt.Scan(&S)
	dream := DayDream(S)
	fmt.Println(dream)
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(){
  int n,h,m,s;
  char str;
  int temp;

  while(1){
    int t[86401]={0};
    int max=t[0];
    cin>>n;
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin>>h>>str>>m>>str>>s;
      temp=h*3600+m*60+s;
      t[temp]+=1;
      cin>>h>>str>>m>>str>>s;
      temp=h*3600+m*60+s;
      t[temp]+=-1;
    }
    
    for(int i=1;i<=86400;i++){
      t[i]+=t[i-1];
      if(max<=t[i])
        max=t[i];
    }

    cout<<max<<endl;
  }
}



Measured memory_bytes: 3332
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<complex>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<ctime>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define Cpy(x,y) memcpy(x,y,sizeof(x))
#define Set(x,y) memset(x,y,sizeof(x))
#define FILE "4911"
#define mp make_pair
#define pb push_back
#define RG register
#define il inline
using namespace std;
typedef unsigned long long ull;
typedef vector<int>VI;
typedef long long ll;
typedef double dd;
const int N=50010;
const int M=1e7+10;
const int base=26;
const dd eps=1e-6;
const int inf=1e9;
const ll INF=1ll<<60;
const ll P=100000;
const int mod=1e9+7;
il ll read(){
  RG ll data=0,w=1;RG char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
il void file(){
  srand(time(NULL)+rand());
  freopen(FILE".in","r",stdin);
  freopen(FILE".out","w",stdout);
}

int n,m,f[305][305][305],ans;
vector<pair<int,int> >Q[305];
il void upd(int &a,int b){a+=b;if(a>=mod)a-=mod;}
#define fi first
#define se second
bool check(int i,int j,int k,int t){
  if(Q[i][t].se==3&&Q[i][t].fi>k)return 1;
  if(Q[i][t].se==2&&(Q[i][t].fi>j||Q[i][t].fi<=k))return 1;
  if(Q[i][t].se==1&&Q[i][t].fi<=j)return 1;
  return 0;
}

int main()
{
  n=read();m=read();
  for(RG int i=1,l,r,x;i<=m;i++){
    l=read();r=read();x=read();
    Q[r].push_back(make_pair(l,x));
  }
  f[0][0][0]=1;
  for(RG int i=0;i<=n;i++){
    for(RG int t=0,sz=Q[i].size();t<sz;t++)
      for(RG int j=0;!j||j<i;j++)
	for(RG int k=0;!k||k<j;k++)
	  if(check(i,j,k,t))f[i][j][k]=0;
    for(RG int j=0;!j||j<i;j++)
      for(RG int k=0;!k||k<j;k++){
	upd(f[i+1][j][k],f[i][j][k]);
	upd(f[i+1][i][k],f[i][j][k]);
	upd(f[i+1][i][j],f[i][j][k]);
      }
  }
  /*for(RG int i=1;i<=n;i++)
    for(RG int j=0;!j||j<n;j++)
      for(RG int k=0;!k||k<j;k++)
	if(f[i][j][k])
	  printf("f[%d][%d][%d]=%d\n",i,j,k,f[i][j][k]);*/
  for(RG int j=0;!j||j<n;j++)
    for(RG int k=0;!k||k<j;k++)
      upd(ans,f[n][j][k]);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 108928
n = input()
A = [0]
p = range(1, n)
a = [[0 for i in range(n)]for j in range(n)]

for i in range(n):
    a[i] = map(int, raw_input().split() )

l = 0

while p != []:
    a_min = 10000
    for i in A:
        for j in p:
            if 0 <= a[i][j] < a_min:
                a_min = a[i][j]
                add_A = j
    A.append(add_A)
    p.remove(add_A)
    l += a_min

print l

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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
   ll n,k;
   cin >>n;
    string s;
    cin >>s;
    if ( n <3200)cout << "red";
    else cout << s;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int X; cin>>X;
  int sum=0;
  int ans=0;
  REP(i,1,MOD){
    sum+=i;
    if(sum>=X){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  }


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

int main() {
  int n,k,disp;
  cin>>n;
  cin>>k;
  disp=1;
  for (int i = 0; i < n; i++) {
   if(disp+disp>=disp+k){
     disp+=k;
   }
    else{
      disp+=disp;
    }
  }
  cout<<disp;

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

ll count(string s){
    ll ret=0;
    for(int i=0;i<s.size();i++){
        ret+=s[i]-'0';
    }
    return ret;
}


int main(){
    string s;
    cin>>s;
    ll mx=count(s);
    s[0]--;
    for(int i=1;i<s.size();i++){
        s[i]='9';
    }
    mx=max(mx,count(s));
    cout<<mx<<endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

var (
	n int
	s string
)

func main() {
	fmt.Scan(&n)
	fmt.Scan(&s)

	r := 0
	b := 0

	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			r++
		}
		if s[i] == 'B' {
			b++
		}
	}
	if r > b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

bool seisu(double x){
  return floor(x) == x;
}

int main(void){
  int n,d; cin >> n >> d;
  double x[n][d];
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < n-1; i++){
    double dst =0;
    for(int j = i + 1; j < n; j++){
      for(int k = 0; k < d; k++){
        dst += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      dst = pow(dst,0.5);
      if(seisu(dst)){
        ans++;
      }
      dst = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
  int S, h, m, s;

  scanf("%d", &S);
  
  s = S%60;
  m = (S/60)%60;
  h = ((S/60)/60)%60;
    

  printf("%d:%d:%d\n", h, m, s);
  
  return 0;
}



Measured memory_bytes: 2760
/*
バブルソート
*/
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func bubbleSort(a ints) int {
	count := 0
	sorted := 0
	for sorted < len(a)-1 {
		for cur := len(a) - 1; cur > sorted; cur-- {
			if a[cur-1] > a[cur] {
				// 左隣の方が大きいので入れ替える.
				v := a[cur]
				a[cur] = a[cur-1]
				a[cur-1] = v
				count++
			}
		}
		sorted++
	}
	return count
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	eGetInt(reader)
	a := eGetInts(reader)
	count := bubbleSort(a)
	fmt.Println(ints(a))
	fmt.Println(count)
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



Measured memory_bytes: 1164
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,K;
ll dp[16][16][300];
ll a[20];
vector<ll> inde;

int main(void){
	scanf("%d%d",&n,&K);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		for(int j=0;j<15;j++){
			inde.push_back((ll)a[i]+j);
		}
	}
	inde.push_back(0);
	sort(inde.begin(),inde.end());
	inde.erase(unique(inde.begin(),inde.end()),inde.end());
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=inde.size();k++){
				dp[i][j][k]=(ll)n*INF;
			}
		}
	}
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		a[i]=lower_bound(inde.begin(),inde.end(),a[i])-inde.begin();
		for(int j=0;j<n;j++){
			for(int k=0;k<inde.size();k++){
				dp[i+1][j][max(k,(int)a[i])]=min(dp[i+1][j][max(k,(int)a[i])],dp[i][j][k]);
				if(a[i]>k){
					dp[i+1][j+1][a[i]]=min(dp[i+1][j+1][a[i]],dp[i][j][k]);
				}else{
					ll cost=inde[k+1]-inde[a[i]];
					dp[i+1][j+1][k+1]=min(dp[i+1][j+1][k+1],dp[i][j][k]+cost);
				}
			}
		}
	}
	ll res=dp[n][K][0];
	for(int i=0;i<inde.size();i++){
		res=min(res,dp[n][K][i]);
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int n,l,sum=0,ans=0;;
    cin>>n>>l;
    vector<int>a(10000000);
    
    for(int i=0;i<n;i++){
        a[i]=i+l;
        sum+=a[i];
    }
    if(a[0]<0&&a[n-1]<0){
        ans=sum-a[n-1];
    }
    else if(a[0]<0&&a[n-1]>=0){
        ans=sum;
    }
    else if(a[0]>=0&&a[n-1]>=0){
        ans=sum-a[0];
    }
    
    cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 39296
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    int n;
    cin >> n;
    int a[n];
    bool flg = true;
    for( int i = 0; i < n; ++i ) {
        cin >> a[i];

    }

    for( int i = n - 1; i > 1; --i ) {
        if( a[i] < a[i - 1] ) {
            --a[i - 1];

        }
        if( a[i] < a[i - 1] ) flg = false;

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

    return 0;
}



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

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

int main(){
	int a,b,c,d,s=0,t=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	s=a+b+c+d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	t=a+b+c+d;
	printf("%d\n",max(s,t));
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF 99999999 
using namespace std;
 
int main()
{
    ll N; cin >> N;
    if(N%2 == 1) cout << 0 << endl;
    else{
        ll ans = 0;
        N /= 2;
        while(0<N){
            ans += N/5;
            N /= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


int main()
{
    
    int A,B,C;
    cin >> A >> B >> C;
    cout << A+B+C+(9*max(A,max(B,C))) << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func gcd(m, n uint64) uint64 {
	if (m % n) == 0 {
		return n
	}
	return gcd(n, m%n)
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	K := nextInt()

	anser := uint64(0)
	for a := uint64(1); a <= uint64(K); a++ {
		for b := uint64(1); b <= uint64(K); b++ {
			for c := uint64(1); c <= uint64(K); c++ {
				temp := gcd(a, b)
				anser += gcd(temp, c)
			}
		}
	}
	fmt.Println(anser)
}


Measured memory_bytes: 1772
fun main(arr:Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toLong() }
    val ans = (a..Math.min(b, a+k-1)).toList().union((Math.max(b-k+1, a)..b)).toSet()
    ans.forEach { println(it) }
}




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

int main(){
    int64_t N, A, B;
    cin >> N >> A >> B;
    int64_t k = N/(A+B);
    int64_t l = N%(A+B);
    int64_t x =0;
    if(l < A) x = l;
    else x = A;
    cout << k*A + x << endl;    
}

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

int main(){
    string s;
    cin >> s;
    vector<string> vs(s.size());
    rep(i,s.size()){
        vs[i] = s[i];
    }
    sort(vs.begin(),vs.end());
    bool ans = true;
    for(int i=0;i<s.size()-1;i++){
        if(vs[i] == vs[i+1]){
            ans = false;
            break;
        }
    }
    if(ans) cout << "yes";
    else cout << "no";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define loop(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define len(a) (int)a.size()
#define allv(a) (a).begin(),(a).end()
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double err = 1e-9;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int lp[N], rp[N];


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

	int n;
	cin>>n;
	
	string s;
	cin>>s;

	loop(i,0,n)
		lp[i] = (i > 0 ? lp[i - 1] + (s[i - 1] == '#'): 0);

	for(int i = n - 1; i >= 0; i--)
		rp[i] = (i < n - 1 ? rp[i + 1] + (s[i + 1] == '.') : 0);

	int ans = N;
	loop(i,0,n)
		ans = min(lp[i] + rp[i], ans);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 2196
S = list(input())

if len(S)%2 != 0:
    S.pop()
else:
    S.pop()
    S.pop()
    
for i in range(len(S)):
    if S[:len(S)//2] == S[len(S)//2:]:
        res = len(S)
        break
    else:
        S.pop()
        S.pop()
print(res)

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  double d,t,s;
  cin >> d >> t >> s;
  double time = d / s;
  // cout << time << endl;
  if(time > t) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3672
/* *>>>>>Anshit_Bhardwaj<<<<<* */
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int l = 0, r = n-1;
    int cnt = 0;
    while(l+1 < r){
        while(s[l] == 'R' && l < r){
            l++;
        }
        while(s[r] == 'W' && r > l){
            r--;
        }
        if(l < r){
            s[l] = 'R';
            s[r] = 'W';
            cnt++;
        }
    }
    bool isW = false;
    f(i, 0, n){
        if(s[i] == 'W'){
            isW = true;
        }
        if(isW){
            if(s[i] == 'R'){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL a[100001];
int main(){
	cin>>N;
	REP(i,N){
	    cin>>a[i];
	}
	LL ans=0;
	bool check=true;
	LL sum=0;
	REP(i,N){
	    sum+=a[i];
	    if(check){
	       check=false;
	       if(sum<=1){
	          ans+=(1-sum);
	          sum=1;
	       }
	    }else{
	       check=true;
	       if(sum>=-1){
	          ans+=(sum+1);
	          sum=-1;
	       }
	    }
	}
	check=false;
	LL ans2=0;
	sum=0;
	REP(i,N){
	    sum+=a[i];
	    if(check){
	       check=false;
	       if(sum<=1){
	          ans2+=(1-sum);
	          sum=1;
	       }
	    }else{
	       check=true;
	       if(sum>=-1){
	          ans2+=(sum+1);
	          sum=-1;
	       }
	    }
	}
	//cout<<ans<<" "<<ans2;
        cout<<min(ans,ans2)<<endl;
	return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int c[4][4];
    int sum = 0;
    reps(i, 1, 4){
        reps(j, 1, 4){
            cin >> c[j][i];
            sum += c[j][i];
        }
    }

    if(sum%3 != 0){
        ans(false);
        return 0;
    }

    if(sum/3 == c[1][1]+c[2][2]+c[3][3]
        && sum/3 == c[1][3]+c[2][2]+c[3][1]
        && sum/3 == c[1][1]+c[3][2]+c[2][3]
        && sum/3 == c[1][3]+c[3][2]+c[2][1]
        && sum/3 == c[3][3]+c[1][2]+c[2][1]
        && sum/3 == c[3][1]+c[1][2]+c[2][3]){
            ans(true);
        }else{
            ans(false);
        }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,i; cin>>n;
    int a[200];
    double v=0,hoge;
    for(i=0;i<n;i++){
        cin>>a[i];
        v+=a[i];
    }
    v/=n;
    int ans;
    double tmp=200;
    for(i=0;i<n;i++){
        double hoge=v-a[i];
        if(hoge<0)hoge*=-1;
        if(hoge<tmp){
            tmp=hoge;
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
A = np.array(list(map(int,input().split())))

balls = np.array([0]*(n+1))

for i in range(1,n+1):
    s = sum(balls[n+1-i::n+1-i])
    if (s%2 and not A[-i]) or (A[-i] and not s%2):
        balls[-i] += 1

#print(balls)

ans = np.where(balls==1)[0].tolist()
if sum(balls):
    print(sum(balls))
    print(*ans)
else:
    print(0)

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

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

    int d,s;
    double t;
    cin>>d>>t>>s;
    double result=(double)d/s;
    if(result<=t)
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
	else cout << "NO" << endl;
 	return 0;
 }




Measured memory_bytes: 256
s = input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();
        String s = sc.next();

        ArrayList<V> ar = new ArrayList<>();
        int c = s.charAt(0) - '0', len = 1;
        for (int i = 1; i < n; i++) {
            if (c == s.charAt(i) - '0') {
                len++;
            } else {
                ar.add(new V(c, len));
                c = s.charAt(i) - '0';
                len = 1;
            }
        }
        ar.add(new V(c, len));

        int ans = 0;
        int sum = 0;
        for (int l = 0, r = 0; r < ar.size(); r++) {
            if (ar.get(r).c == 0) {
                if (k > 0) {
                    k--;
                } else {
                    if (ar.get(l).c == 0) {
                        sum -= ar.get(l).len;
                        l++;
                    } else {
                        sum -= ar.get(l).len;
                        sum -= ar.get(l + 1).len;
                        l += 2;
                    }
                }
            }
            sum += ar.get(r).len;
            ans = Math.max(ans, sum);
        }
        System.out.println(ans);
    }

    class V {
        int c, len;
        V(int c, int len) {
            this.c = c;
            this.len = len;
        }

        @Override
        public String toString() {
            return String.format(String.format("(%d, %d)", c, len));
        }
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 29740
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int INF=99999999999999,inf=199999;
const long long int mod=998244353;


//aからbまでの積を求める(mod)

//階乗先に計算
long long int kaizyou[4000005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
	long long int tmp = 1;
	for (long long int i = a; i <= b; i++) {
		tmp *= i;
		tmp %= mod;

		kaizyou[i] = tmp;
	}
	return tmp;
}


//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

//コンビネーション計算
long long int comb(long long int n, long long int r, long long int mod) {
	long long int tmp;

	tmp = (kaizyou[n] * rui(kaizyou[r], mod - 2, mod)) % mod;
	tmp *= rui(kaizyou[n - r], mod - 2, mod);
	tmp %= mod;
	if (tmp < 0) { tmp = (mod - tmp) % mod; }
	return tmp;
}


long long int n,m,k,a,b,c,d,count=0,res=0,tmp;
int main() {
    int count=0;
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>n>>m;
    kai(1,4000001,mod);
    res=comb(n+3*m-1,n-1,mod);
    //cout<<res<<endl;
    res=res+mod-((n)*comb(n+m-2,n-1,mod))%mod;
    res%=mod;
    //cout<<res<<endl;
    for(int i=m+1;i<=min(3*m,n);i++){
        if((3*m-i)%2==1){continue;}
        //n個中m個が0でn-m個が1
        tmp=comb(n,i,mod)*comb((3*m-i)/2+n-1,n-1,mod);
        tmp%=mod;
        res=(mod+res-tmp)%mod;
    }
    cout<<res;
} 


Measured memory_bytes: 31488
<?php

class Operator
{
    private $operations;
    private $operations_count;

    public function __construct()
    {
        fscanf(STDIN, '%d', $this->operations_count);
        $this->operations = new \SplDoublyLinkedList();
        while ($this->operations_count > 0) {
            $word = trim(fgets(STDIN));
            if ($word[0] === 'i') {
                $this->operations->unshift(substr($word, 7));
            } elseif ($word[6] === 'F') {
                $this->operations->shift();
            } elseif ($word[6] === 'L') {
                $this->operations->pop();
            } else {
                foreach ($this->operations as $key => $element) {
                    if ($element === substr($word, 7)) {
                        $this->operations->offsetUnset($key);
                        break;
                    }
                }
            }
            $this->operations_count -= 1;
        }
    }

    public function getAnswer()
    {
        while (1) {
            if (count($this->operations) > 0) {
                $keys_operated[] = $this->operations->shift();
            } else {
                break;
            }
        }
        echo implode(' ', $keys_operated), PHP_EOL;
    }
}

$operator = new Operator();
$operator->getAnswer();



Measured memory_bytes: 136152
var Mountains = {
  mountain_input: function() {
    var mountain = [];
    var input = require('fs').readFileSync('/dev/stdin', 'utf8');
    input.trim().split('\n').forEach(function(line){
      mountain.push(parseInt(line));
    });  
    return mountain;
  },
  sort: function() {
    var data = this.mountain_input();
    data.sort(function(a,b){return a - b;});
    for(k=data.length -1; k >= data.length-3; k--) {
      console.log(data[k]);
    }
    return true;
  }
}
Mountains.sort();

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

int main() {
  string s;
  cin>>s;s="0"+s;
  int f=0,cnt=0;
  for(int i=s.size()-1;i>0;i--){
    int d=s[i]-'0'+f;
    int m=min(d,10-d);
    cnt+=m;
    f=(d>5||d==5&&s[i-1]-'0'>=5);
  }
  cout<<cnt+f<<endl;
  return 0;
}

Measured memory_bytes: 2308
ABCD = list(map(int, input()))

for i in range(8) :
    ret = ABCD[0]
    for j in range(3) :
        if (i >> j) & 1 :
            ret += ABCD[j+1]
        else :
            ret -= ABCD[j+1]
    
    if ret == 7 :
        op1 = '+' if (i >> 0) & 1 else '-'
        op2 = '+' if (i >> 1) & 1 else '-'
        op3 = '+' if (i >> 2) & 1 else '-'
        print('{}{}{}{}{}{}{}=7'.format(ABCD[0], op1, ABCD[1], op2, ABCD[2], op3, ABCD[3]))
        break

Measured memory_bytes: 38460
N = input()
N = N[::-1]
ans = 0
p = 0
for i in range(len(N)):
    p += int(N[i])
    if p<5:
        ans += p
        p = 0
    elif p==5:
        if i+1==len(N):
            ans += 5
            p = 0
        elif int(N[i+1])>=5:
            ans += 5
            p = 1
        else:
            ans += 5
            p = 0
    else:
        ans += 10-p
        p = 1
if p==1:
    ans += 1
print(ans)

Measured memory_bytes: 58352
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
static class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
	}
	public void BFS(int s) 
	{
		boolean visited[] = new boolean[totalVertex]; 
        Queue<Integer> toVisit = new LinkedList<Integer>(); 
        visited[s]=true; 
        toVisit.add(s); 
        int[] dist = new int[totalVertex];
        for(int i = 0;i<dist.length;i++) {
        	dist[i]=-1;
        }
        dist[s]=0;
        
        while (!toVisit.isEmpty()) 
        { 
            int u = toVisit.poll(); 
            LinkedList<Integer> n = adjList.get(u);
            for(int i = 0 ; i<n.size();i++) {
            	int v = adjList.get(u).get(i);
            	if (!visited[v]) 
                { 
                    visited[v] = true; 
                    toVisit.add(v); 
                    dist[v]=dist[u]+1;
                } 
            } 
            
   
        }
        for(int i=0;i<totalVertex;i++) {
        	System.out.println(i+1+" "+dist[i]);
        }
		
	}
}
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		//g.printAdjMatrix();
		g.BFS(0);
	}
	
}


Measured memory_bytes: 28156
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt();
        boolean ans = false;
        for (int i = a; i <= b; i++) {
            if (i % k == 0) ans = true;
        }
        System.out.println(ans ? "OK" : "NG");
    }


}

Measured memory_bytes: 35720
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 5010;
const int M = 1e9 + 7;

int main()
{
    int n,k;
    scanf("%d",&n);
    for (int i = 0 ; i < n; i++){
        cin>>k;
        if (k%2 ==0){
            if (k % 3 != 0 && k % 5 != 0){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n, 0);
	int t = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		t += v[i];
	}
	sort(v.begin(), v.end(), greater<int>());
	if (v[m - 1] * 4 * m >= t) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	bool v[8][8] = { };
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a][b] = true;
		v[b][a] = true;
	}

	vector<int> per;
	for(int i = 1; i < N; i++)
		per.push_back(i);

	int ans = 0;
	do {
		//cout << 0 << "-" << per[0] << ":" << v[0][per[0]] << endl;
		if(! v[0][per[0]]) continue;
		bool flag = false;
		for(int i = 0; i < per.size() - 1; i++) {
			//cout << per[i] << "-" << per[i + 1] << ":" << v[per[i]][per[i + 1]] << endl;
			if(! v[per[i]][per[i + 1]]) {
				flag = true;
				break;
			}
		}
		if(flag) continue;
		ans++;
	} while(next_permutation(per.begin(), per.end()));  
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll MOD = 1e9 + 7;
vector<ll> pos[200001];
ll N;
vector<ll> C;
vector<ll> memo;

ll solve(ll left) {
    if (left >= N) {
        return 1;
    }

    if (memo[left] != -1) {
        return memo[left];
    }

    ll next = *upper_bound(pos[C[left]].begin(), pos[C[left]].end(), left);

    ll ans;

    if (next == left + 1) {
        ans = solve(next);
    } else if (next >= N) {
        ans = solve(left + 1);
    } else {
        ans = (solve(next) + solve(left + 1)) % MOD;
    }

    return memo[left] = ans;
}

int main() {
    cin >> N;
    C.resize(N);
    memo.resize(N, -1);
    for (ll i = 0; i < N; i++) {
        cin >> C[i];
        pos[C[i]].push_back(i);
    }
    for (ll i = 1; i <= 200000; i++) {
        pos[i].push_back(N);
    }

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

Measured memory_bytes: 22128