akhauriyash/Code-Regression huggingface dataset:
N,T=map(int, input().split())
A=list(map(int, input().split()))
if N==1:
  print(1)
  exit()
mn=10**9+1
V=-1*10**9
cnt=0
for i in range(N):
  if V==A[i]-mn:
    cnt+=1
  elif V<A[i]-mn:
    V=A[i]-mn
    cnt=1
  mn=min(A[i],mn)
print(cnt)

Measured memory_bytes: 14252
function main(input){
  input = input.split(' ').map(Number);
  const N = input[0];
  const K = input[1];
  
  var result = 0;
  
  for(i = 1;i <= N;i++){
    var tmp = 1/N;
  	var now = i;
  	while(now < K){
      now *= 2;
      tmp /= 2;
    }
    result += tmp;
  }
  
  console.log(result.toString().slice(0,14));
}
main(require('fs').readFileSync('/dev/stdin','utf8'));



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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)
#define sz(v) ((int)v.size())
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int nax = 2e5 + 200;
const ll mod = 1e9+7;
int n, root;
vi g[nax];
ll sz[nax];
ll ways[nax];
ll fact[nax];

ll mult(ll a, ll b){
  return (a*b)%mod;
}

ll binPow(ll a, ll q) {
  a %= mod;
  if (q == 0) return 1;
  return mult(q % 2 == 1 ? a : 1,  binPow(a * a, q / 2));
}


ll C(int n, int k){
  return mult(fact[n], mult(binPow(fact[k], mod-2),binPow(fact[n-k], mod-2) ));
}



void calc(int u, int p){
  sz[u] = 0;
  ways[u] = 1;
  for(int v: g[u]){
    if(v==p) continue;
    calc(v,u);
    ways[u] = mult( C(sz[u]+ sz[v], sz[v]) , mult( ways[v], ways[u]) );
    sz[u]+= sz[v];
  }
  sz[u]+=1;
}

void change_root(int r, int v){
  ll wr = ways[r], wv = ways[v], szv = sz[v], szr = sz[r];

  sz[v] = n;

  wr = mult( wr , mult( binPow(C( szr-1 , szv ), mod-2) , binPow(ways[v], mod-2)) );

  ways[v] = mult( C(szr-1, szr-szv), mult(wv, wr) );
}

void dfs(int u, int p){
  for(int v: g[u]){
    if(v==p) continue;
    change_root(u,v);
    dfs(v,u);
  }
}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cout<< setprecision(20)<< fixed;
  fact[0] = 1;
  for1(i,nax-1){
    fact[i] = (1LL*fact[i-1]*i)%mod;
  }
  cin>> n;
  int u, v;
  forn(i,n-1){
    cin>> u>> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  root = 1;
  calc(root, root);
  dfs(root, root);
  for1(i,n){
    cout<< (ways[i])%mod<<el;
  }
}




Measured memory_bytes: 18676
#include<stdio.h>

int main(void)
{
    int x,y,z,h,m,s;
    scanf("%d",&x);
    h = x/3600;
    y = (x % 3600);
    m = y / 60;
    z = (x % 3600) % 60;
    s = z;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<int(n); i++)
#define print(x) cout << (x) << endl

bool isPrime(int n) {
    for (int i=2; i*i<=n; i++) {
        if (n%i == 0) return false;
    }
    return true;
}

int main() {
    int x; cin >> x;
    for (int i=x; ; i++) {
        if (isPrime(i)) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    int n,m;
    cin>>n>>m;
    int a[m];
    int ans = 0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        if(a[i]>m) ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 3192
n,m = map(int,input().split())
a = sorted(list(map(int, input().split())))

dic = {}

for v in a:
  tmp = dic.get(v, 0)
  dic[v] = tmp + 1
  
for i in range(m):
  b,c = map(int, input().split())
  
  dic[c] = dic.get(c,0) + b
  
ans = 0
for k in sorted(dic.keys(), reverse=True):
  v = dic.get(k)
  if v <= n:
    ans += v * k
    n -= v
  else:
    ans += n * k
    break

print(ans)

Measured memory_bytes: 32064
#include <stdio.h>

int main(){
  int a, b;
  int sum = 0;
  scanf("%d %d",&a, &b);
  for(int i = 0; i < 2; i ++){
  if(a > b){
    sum += a;
    a -= 1;
  }
  else {
    sum += b;
    b -= 1;
  }
  }
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> d(N);
    readvec(d);

    SORT(d);

    int ans = 1;
    REP(i, N - 1){
        if(d[i] != d[i + 1]) ans++;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
vi G[100010];

int dfs( int x ){
  if( SZ(G[x]) == 0 ){
    return 0;
  }
  vi v(0);
  YYS( w , G[x] ){
    v.pb( dfs(w) );
  }
  SORT( v );
  REVERSE( v );
  ll res = 0;
  REP( i , SZ(v) ){
    chmax( res , v[i] + i + 1 );
  }
  return res;
}

int main(){

  n = in();
  FOR( i , 1 , n ){
    int a = in() - 1;
    G[a].pb( i );
  }

  printf( "%d\n" , dfs( 0 ) );
  
  return 0;
}


Measured memory_bytes: 13568
from copy import deepcopy as dcopy
def main():
    global count,N,M,edges,stack
    N, M = map(int, input().split())
    edges = [[0]*N for n in range(N)]
    for m in range(M):
        a,b = map(lambda x:int(x)-1,input().split())
        edges[a][b] = 1
        edges[b][a] = 1

    count = 0
    stack = [[[0], [0]]]
    while len(stack) != 0:
        tansaku = stack.pop()
        next_list = [n for n,v in enumerate(edges[tansaku[0][-1]]) if v == 1]
        search(tansaku, next_list)
    print(count)

def search(tansaku, next_list):
    global count, stack
    for node in next_list:
        tmp_tansaku = dcopy(tansaku)
        tmp_node = tmp_tansaku[0]
        houmonzumi = tmp_tansaku[1]
        if node in houmonzumi:
            pass
        else:
            houmonzumi.append(node)
            if len(houmonzumi) == N:
                count += 1
            else:
                tmp_node.append(node)
                stack.append([tmp_node, houmonzumi])

if __name__ == "__main__":# {{{
    try:
        import test
        test.test()
    except:
        main()# }}}


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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	string s; cin >> s;
	if (s[1] == 'R') cout << "ABC" << endl;
	else cout << "ARC" << endl;
	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>x;
      rrep(i,1,1001){
        rrep(j,2,1001){
          pos=pow(i,j);
          if(pos>x)break;
          ans=max(ans,pos);
        }
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()




int main() {

	ll c[3][3];
	rep(i, 3) rep(j, 3) cin >> c[i][j];

	if (c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] - c[2][1] &&
		c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[1][1] - c[1][2] == c[2][1] - c[2][2] &&
		c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][1] - c[1][1] == c[0][2] - c[1][2] &&
		c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][1] - c[2][1] == c[1][2] - c[2][2]) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
    int Q;
    cin >> Q;
    for(int i=0; i<Q; i++) {
        int64_t A, B;
        cin >> A >> B;
        if(A == B) {
            cout << 2*(A-1) << endl;
        } else {
            int64_t s = (int64_t)sqrt(A*B);
            if(s*s == A*B) {
                cout << 2*s - 3 << endl;
            } else if(s*(s+1) >= A*B){
                cout << 2*s - 2 << endl;
            } else {
                cout << 2*s - 1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int a, b, c;
    int ans = 3;
    cin >> a >> b >> c;
    if (a == b) ans--;
    if (b == c) ans--;
    if (c == a) ans--;
    if (a == b && b == c) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
    int n, ans; 
    cin >> n;
    ans = n/2;
    if(n%2==0)ans--;
    cout << ans;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll A, ll N){
  if (N == 0) return 1;
  else{
    if (N % 2 == 0){
      return AN(A * A % nmax, N / 2) % nmax;
    }else{
      return A * AN(A * A % nmax, N / 2) % nmax;
    }
  }
}

int main(){
  string S; cin >> S;
  ll DP[S.length() + 1][4];
  DP[0][0] = 1; DP[0][1] = 0; DP[0][2] = 0; DP[0][3] = 0;

  ll cnt = 0;
  for (int i = 0; i < S.length(); i++){
    
    for (int j = 0; j < 4; j++){
      DP[i + 1][j] = DP[i][j];
    }

    if (S[i] == 'A'){
      DP[i + 1][1] = DP[i][0] + DP[i][1];
    }else if (S[i] == 'B'){
      DP[i + 1][2] = DP[i][1] + DP[i][2];
    }else if (S[i] == 'C'){
      DP[i + 1][3] = DP[i][2] + DP[i][3];
    }else{
      cnt++;
      DP[i + 1][1] = DP[i][0] + DP[i][1] * 3; 
      DP[i + 1][2] = DP[i][1] + DP[i][2] * 3;
      DP[i + 1][3] = DP[i][2] + DP[i][3] * 3;
    }

    DP[i + 1][0] = AN(3, cnt);
    
    for (int j = 0; j < 4; j++){
      DP[i + 1][j] %= nmax;
    }
  }

  cout << DP[S.length()][3] << endl;

  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void printArray(const int *arr, int n);
void printArray(const vector<int> &arr);

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
char s[102];

int main(){
	scanf("%d %d", &n, &k);
    scanf("%s", s);
    --k;
    s[k] += 'a' - 'A';
    printf("%s\n", s);
	return 0;
}

/* Template Function */
void printArray(const int * a, int n){
	for(int i=0;i<n;++i){
		printf("%d ", a[i]);
	}
	puts("");
}

void printArray(const vector<int> &arr){
	for(int x : arr){
		printf("%d ", x);
	}
	puts("");
}


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
A = list(map(int,input().split()))
A = [(-a,a) for a in A]
heapq.heapify(A)
for i in range(m):
    max = heapq.heappop(A)[1]
    max //= 2
    heapq.heappush(A,(-max,max))
print(sum([a[1] for a in A]))

Measured memory_bytes: 17424
#include<bits/stdc++.h>
using namespace std;
long long e[100005];
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<c;i++)
	{
		int d;
		cin>>d;
		e[d]++;
	}
	for(int i=1;i<=a;i++)
	{
		e[i]=e[i]+b-c;
		
	}
	for(int i=1;i<=a;i++)
	{
		if(e[i]>0)
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
N = int(input())
a_list = list(map(int, input().split()))

first_num = 0
for i in range(1, N):
    first_num ^= a_list[i]

ans_list = [first_num]
now_num = first_num
for i in range(1, N):
    now_num ^= a_list[i - 1] ^ a_list[i]
    ans_list.append(now_num)

print(" ".join(map(str, ans_list)))

Measured memory_bytes: 41392
#include <iostream>
#include <algorithm>

using namespace std;

int N;
string P;
string m1;

string f(string a, string b){
  if(a == "T" && b == "F"){
    return "F";
  }
  return "T";
}

int main(){
  cin >> N;
  cin >> m1;
  for(int i=0;i<N-1;i++){
    cin >> P;
    m1 = f(m1, P);
  }

  cout << m1 << endl;
  return 0;
}



Measured memory_bytes: 3160
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int N = sc.nextInt();
	    
	    int sum = 0;
	    for(int i = 1; i <= N; i++) {
	    	sum += i;
	    }
	    
	    System.out.println(sum);
	}
	
}

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

using namespace std;

int main()
{
    int n,a;
    while(cin>>n)
    {
        a=n%10;
        n/=10;
        if(n==9 || a==9)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


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

using namespace std;

#ifndef ONLINE_JUDGE
#define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
#define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
__attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
#define pr_debug(...) do { } while(0)
#define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
                                                for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
                                                    if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll n, k; cin >> n >> k;
    if (k == 0) { cout << n * n << endl; exit(0); }
    for (ll b = 1; b <= n; b++) {
        ll r = 0;
        ll st = b - k;
        if (st <= 0) continue;
        r += st;
        ll cur = b - 1;
        while (cur <= n) {
            cur += k + 1;
            ll diff = n - cur + 1;
            diff = min(diff, st);
            if (diff < 0) diff = 0;
            r += diff;
            cur += st - 1;
        }
        //pr_vars(b, r);
        res += r;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

long money = 100000;

void oneweekafter() {
    money *= 1.05;
    money = ceil(money / 1000.) * 1000;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        oneweekafter();
    }
    cout << money << endl;
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define MOD             1000000007
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)

using namespace std;

int main(void){
    //boost;
   LL a,e,f=0;

   for(int i=1; i<=5; i++){
        cin>>a;
    if(a==0)
        e=i;
       f=1;
    }
    if(f)
        cout<<e;
}

Measured memory_bytes: 3568
a,b,c = map(int, input().split())
if a > b:
  tmp = a
  a = b
  b = tmp
if a > c:
  tmp = a
  a = c
  c = tmp
if b > c:
  tmp = b
  b = c
  c = tmp
print("{0} {1} {2}".format(a, b, c))


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

	int main()
{
	// 	入力
	string o;
	string e;
	cin >> o >> e;

	// 繋げる
	int i = 0;
	for (i = 0; i<e.size(); i++) {
		cout <<o[i]<<e[i];
	}
	
	// 奇数のとき
	if ((o.size() - e.size()) == 1) {
		cout << o[i];
	}

	cout << endl;
	
	return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class CountedHashSet
        {
            public class Counter
            {
                public Counter()
                {
                    count = 1;
                }

                public int count { get; set; }
            }


            public Dictionary<int, Counter> keySet { get; private set; }

            public CountedHashSet()
            {
                keySet = new Dictionary<int, Counter>();
            }

            public void Add(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    c.count++;
                }
                else
                {
                    keySet.Add(key, new Counter());
                }
            }

            public int GetKeyCount(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    return c.count;
                }

                return 0;
            }
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            CountedHashSet hs = new CountedHashSet();
            for (int i=0;i<N;i++)
            {
                int v = int.Parse(s[i]);

                hs.Add(v);
            }

            int ans = 0;
            foreach(KeyValuePair<int,CountedHashSet.Counter> e in hs.keySet)
            {
                if (e.Key < e.Value.count)
                {
                    ans += e.Value.count - e.Key;
                }
                else if(e.Key > e.Value.count)
                {
                    ans += e.Value.count;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

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

vector<int> seen;
vector<int> c;
vector<int> a;
ll r, l;

void dfs(int i, int count) {
	if (seen[i] != -1) {
		r = count;
		l = seen[i];
		return;
	}
	seen[i] = count;
	c[count] = i;
	dfs(a[i], count + 1);
}

int main() {
	ll n, k;
	cin >> n >> k;
	seen.resize(n + 1, -1);
	a.resize(n + 1);
	c.resize(n);
	REP(i, n) cin >> a[i];
	dfs(1, 0);
	if (k > l) {
		k -= l;
		k %= r - l;
		k += l;
	}
	cout << c[k] << endl;
	return 0;
}



Measured memory_bytes: 5572
#!/usr/bin/env pypy3

import itertools


def solve(n, a, xs0):
    xs = sorted(xs0)
    xs.insert(0, 0)
    y = max(a, *xs)
    dp = [[[0 for _ in range(n * y + 1)]
          for _ in range(n + 1)] for _ in range(n + 1)]
    g = itertools.product(range(n + 1), range(n + 1), range(n * y + 1))
    for j, k, s in g:
        if j == k == s == 0:
            dp[j][k][s] = 1
        elif j >= 1 and s < xs[j]:
            dp[j][k][s] = dp[j - 1][k][s]
        elif j >= 1 and k >= 1 and s >= xs[j]:
            dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xs[j]]
    ans = sum(dp[n][k][k * a] for k in range(1, n + 1))
    return ans


def main():
    n, a = (int(x) for x in input().split())
    xs = [int(x) for x in input().split()]
    ans = solve(n, a, xs)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 96732
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
const ll INF=1e15;
ll dp[333][112345];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  fill(dp[1],dp[1]+332*112345,-INF);
  int n,m,t;
  cin>>n>>m>>t;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  deque<pll> que[333];
  rep(i,n)rep(j,t){
    while(que[j].size() && que[j].back().X<=dp[j][i]) que[j].pop_back();
    que[j].eb(dp[j][i],i);
    while(i-que[j].front().Y>=m) que[j].pop_front();
    assert(que[j].size());
    dp[j+1][i+1]=que[j].front().X+(j+1ll)*a[i];
  }
  //rep(i,t+1){rep(j,n+1)cout<<dp[i][j]<<",";cout<<endl;}
  cout<<*max_element(dp[t],dp[t]+n+1)<<endl;
  return 0;
}


Measured memory_bytes: 292736
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1000000007
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll a[4444];
ll cnt[2222];
ll memo[2222];
signed main() {
	ll n, k, ans = 0;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j])memo[a[i]]++;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j])cnt[a[i]]++;
		}
	}
	rep(i, 2002) {
		ans += memo[i] * k % inf + cnt[i] * (k * (k - 1) / 2 % inf) % inf;
		ans %= inf;
	}
	cout << ans << endl;
	ggr
}


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

int F[102][102];
int xg,yg,ok;

void Maze(int X,int Y,int C){
	if(F[X][Y]!=C)
		return;

	

	if(X==xg&&Y==yg){
		cout << "OK"<<endl;
		ok++;
	}

	F[X][Y]='.';

	Maze(X-1,Y  ,C);
	Maze(X  ,Y+1,C);
	Maze(X+1,Y  ,C);
	Maze(X  ,Y-1,C);
	
}



int main(){	
	while(1){
		ok=0;

		int w,h,xs,ys,n,c,d,x,y;

		cin >>w>>h;
		if(w==0&&h==0)
			return 0;

		cin >>xs>>ys;
		cin >>xg>>yg;
		cin >>n;


		for(int i=1; i<=w; i++)
			for(int j=1; j<=h; j++)
				F[j][i]=0;

		for(int i=1; i<=w;i++){
				F[w+1][i]=6;
				F[0][i]=6;
		}
		for(int i=1; i<=h;i++){
				F[i][h+1]=6;
				F[i][0]=6;
		}

		int N=0;
		while(N<n){
			cin >>c>>d>>x>>y;

			if(d){
				for(int i=x; i<x+2; i++)
					for(int j=y; j<y+4; j++){
						F[i][j]=c;
				}
			}else{
				for(int i=x; i<x+4; i++)
					for(int j=y; j<y+2; j++){
						F[i][j]=c;
					}
			}
			N++;
		}

/*for(int i=0; i<=h+1; i++){
	for(int j=0; j<=w+1; j++){
		cout <<F[j][i];
		}
	cout << endl;
}*/
		
		Maze(xs,ys,F[xs][ys]);

		if(ok==0)
			cout <<"NG"<<endl;

	}

}

Measured memory_bytes: 1216
#include <stdio.h>
#define H 251

typedef struct {
  int k;
  int pk;
  int lk;
  int rk;
} node;

int main(int argc, char const *argv[]) {
  int input,i,j;
  node n[H];

  scanf("%d",&input);

for (i = 1; i <= input; i++) {
  scanf("%d",&n[i].k);

  if (i / 2 > 0) {
    n[i].pk = n[i/2].k;
  }
  if (i * 2 <= input) {
    n[i].lk = n[i*2].k;
  }
  if (i * 2 + 1<= input) {
    n[i].rk = n[i*2+1].k;
  }

}

for (i = 1; i <= input; i++) {
    printf("node %d: key = %d, ",i,n[i].k);
  if (i / 2 > 0) {
    printf("parent key = %d, ",n[i/2].k);
  }
  if (i * 2 <= input) {
    printf("left key = %d, ",n[i*2].k);
  }
  if (i * 2 + 1 <= input) {
    printf("right key = %d, ",n[i*2+1].k);
  }
  printf("\n");
}
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (k <= h) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int A[3005];

long long memo[3005][3005];
const long long modConst = 998244353;

long long DP(int N, int S)
{
    if(S < 0)
        return 0;
        
    if(N == 0 && S == 0)
        return 1;
    
    if(N == 0)
        return 0;
        
    if(memo[N][S] != -1)
        return memo[N][S];
        
    long long putToBoth = DP(N - 1, S - A[N]);
    long long putToTOnly = DP(N - 1, S);
    long long putToNone = DP(N - 1, S);
    
    memo[N][S] = (putToBoth + putToTOnly + putToNone) % modConst;
    return memo[N][S];
}

int main()
{
    int N, S;
    scanf("%d%d", &N, &S);
    
    for(int i = 1; i <= N; i++)
        scanf("%d", &A[i]);
        
    for(int i = 0; i < 3005; i++)
    {
        for(int j = 0; j < 3005; j++)
            memo[i][j] = -1;
    }
    
    long long ans = DP(N, S);
    printf("%lld", ans);
}


Measured memory_bytes: 74500
#include <iostream>

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    
    if ((A < B && A < C && C < B) || (A > B && A > C && C > B)) 
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
'use strict'
const main = arg => {
  const n = parseInt(arg.split('\n')[0], 10)
  const xn = arg
    .split('\n')[1]
    .split(' ')
    .map(e => parseInt(e, 10))
  const avg = Math.round(xn.reduce((val, e) => val + e, 0) / n)
  const w = xn.reduce((v, e) => v + (e - avg) * (e - avg), 0)
  console.log(w)
}
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


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

int check(string &s) {
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != s[s.size()-1-i]) {
			return 0;
		}
	}
	return 1;
}

int main()
{
	string s; cin >> s;
	int n = s.size();string s1=s.substr(0, (n-1)/2),s2=s.substr((n+3)/2-1, n-(n+3)/2+1);
	if (check(s) && check(s1) && check(s2))
		puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    map<string, int> m;
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;

    string x;
    cin >> x;

    cout << m[x] << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  rep(i,n) {
    if (i%2 == 0 && s[i] == 'L') ok = false;
    if (i%2 == 1 && s[i] == 'R') ok = false;
  }
  if (ok) puts("Yes"); else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);


    int n, m;
    cin >> n >> m;

    vector<int> divs;
    for(int d=1; d*d<=m; d++){
        if (m%d == 0){
            divs.push_back(d);
            divs.push_back(m/d);
        }
    }
    sort(divs.begin(), divs.end());

    for(int i = divs.size()-1; i>=0; i--){
        if (m/divs[i] >= n){
            cout << divs[i] << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
int main() {
    long long n, w;
    cin >> n >> w;
    long long ws[n];
    long long vs[n];
    long long dp[w+1];
    for (long long i = 0; i < n; i ++) {
        cin >> ws[i] >> vs[i];
    }
    for (long long i = 0; i <= w; i ++) {
        dp[i] = 1000000000000000000;
    }
    dp[0] = 0;
    for (long long i = 0; i < n; i ++) {
        for (long long j = w; j >= 0; j --) {
            if (j + ws[i] <= w && dp[j] != 1000000000000000000) {
                if (dp[j + ws[i]] == 1000000000000000000) {
                    dp[j + ws[i]] = dp[j] + vs[i];
                    continue;
                }
                dp[j + ws[i]] = max(dp[j + ws[i]], dp[j] + vs[i]);
            }
        }
    }
    long long ans = 0;
    for (long long i = 0; i <= w; i ++) {
        if (dp[i] != 1000000000000000000)
            ans = max(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4376
N = int(input())

mulArr = []
for _ in range(N):
  arr = list(map(int, input().split(" ")))
  mulArr.append(arr)
# print(mulArr)

result = 0
for i in range(0, len(mulArr) - 2):
  # print(i)
  if mulArr[i][0] == mulArr[i][1] and mulArr[i + 1][0] == mulArr[i + 1][1] and mulArr[i + 2][0] == mulArr[i + 2][1]:
    result += 1

# print(result)
if result != 0:
  print("Yes")
else:
  print("No")


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

int e(int a, int b, char op) {
    if(op == '+')
        return a + b;
    else 
        return a - b;
}

int main() {
    string N; cin >> N;
    vector<int> a;
    for(auto&c:N)
        a.push_back(c-'0');
    vector<char> op = {'+','+','+'};

    for(int bit = 0; bit < (1<<3); bit++) {
        int val = 0;
        val += a.at(0);
        for(int i = 0; i < 3; i++) {
            if(!(bit & 1<<i)) {
                op.at(i) = '-';
                val -= a.at(i+1);
            } else {
                val += a.at(i+1);
                op.at(i) = '+';}
        }
        if(val == 7) {
            cout << a.at(0);
            for(int i = 0; i < 3; i++)
                cout << op.at(i) << a.at(i+1);
            cout << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
A, B = map(int, input().split())
import fractions
gcd = fractions.gcd(A, B)
#gcd
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
# n == 1のとき、[1, 1]を返す
def factorization(n):
    
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if gcd == 1:
    print(1)
else:
    ans = len(factorization(gcd)) + 1
    print(ans)


Measured memory_bytes: 5872
package main

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

func main() {
	scanInit()

	n := nextStr()
	sum := 0
	for i := 0; i < len(n); i++ {
		sum += int(n[i] - '0')
	}

	if sum%9 != 0 {
		fmt.Println("No")
		return
	} else {
		fmt.Println("Yes")
		return
	}
}

// 各桁の和
func sumKeta(n int) int {
	keta := 0
	for n > 0 {
		keta += n % 10
		n /= 10
	}
	return keta
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;
int main(){
  int h,w;

  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if((i+j)%2==0)cout<<'#';
	else cout<<'.';
      }
      cout<<'\n';
    }
    cout<<'\n';
  }   
  return 0;
}



Measured memory_bytes: 3092
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            for (int i = 0; i < a.Length; ++i) // a.Length は配列 a の長さ。これの例では5。
            {
                a[i] = int.Parse(Console.ReadLine());
            }

            int k = int.Parse(Console.ReadLine());
            int check = 0;
            for (int j = 0; j < a.Length; ++j)
            {
                for(int dif =j+1; dif < a.Length; ++dif)
                {
                    if (a[dif] - a[j] > k)
                    {
                        check = 1;
                    }
                }

            }

            if(check == 1)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
            
            Console.Read();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int fact[9] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320};
  cin >> n;
  int x[n], y[n];
  for(int i = 0; i < n; ++i){
    cin >> x[i] >> y[i];
  }
  double sum = 0, dist;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      dist = (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]);
      dist = sqrt(dist);
      sum += dist;
    }
  }
  double ans = sum / n;
  cout  << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	int n, k, x, sum;
	sum = 0;
	cin >> n >> k;
	for (int i = 0; i<n; i++) {
		cin >> x;
		sum += min(x, k - x);
	}
	cout << sum * 2 << endl;;
}

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

int main() {
    int count, minPrice = INT_MAX, nowPrice, nowIncome, maxIncome = INT_MIN;
    cin >> count;
   
    for (int i = 0; i < count; i++) {
        cin >> nowPrice;

        nowIncome = nowPrice - minPrice;
        if (nowIncome > maxIncome) {
            //cout << "OOOOI" << nowPrice << minPrice << endl;
            maxIncome = nowIncome;
        }

        if (minPrice > nowPrice) {
            minPrice = nowPrice;
        }
    }

    cout << maxIncome << endl;
}

Measured memory_bytes: 1164
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function root(uf::Array{Int,1},x)
	s=x
	while uf[s]>0
		s=uf[s]
	end
	s
end
function same(uf::Array{Int,1},x,y)
	root(uf,x)==root(uf,y)?true:false
end
function unite(uf::Array{Int,1},x,y)
	l = root(uf,x)
	r = root(uf,y)
	if l < r
		uf[l] += uf[r]
		uf[r] = l
	elseif l > r
		uf[r] += uf[l]
		uf[l] = r
	end
end


function main()
	n,h,w = readline() |> split |> parseMap
	e = Tuple{Int,Int,Int}[(0,0,0) for i in 1:n]
	for i in 1:n
		r,c,a = readline() |> split |> parseMap
		e[i] = (r,c,a)
	end
	e = sort(e,by=x->x[3],rev=true)
	uf = -ones(Int,h+w)
	d = zeros(Int,h+w)
	s = 0
	for i in 1:n
		r = e[i][1]
		c = e[i][2]+h
		if same(uf,r,c)
			o = root(uf,r)
			if d[o]<-uf[o]
				d[o]+= 1
				s += e[i][3]
			end
		else
			o = min(root(uf,r),root(uf,c))
			p = max(root(uf,r),root(uf,c))
			if d[o]+d[p]<-uf[o]-uf[p]
				d[o] += d[p]+1
				unite(uf,o,p)
				s += e[i][3]
			end
		end
	end
	println(s)
end

main()

Measured memory_bytes: 165920
#include<bits/stdc++.h>
#define ll long long
#define p(x,y) pair<x,y>
#define pb push_back
#define fo(i,n) for(int i=0;i<(n);i++)
using namespace std;

ll solve(vector<ll>v[],ll start,ll dp[])
{

if(dp[start]!=-1)
{
    return dp[start];
}

    ll value=0;
    for(auto & i:v[start])
    {
        ll ans=0;

       ans=1+solve(v,i,dp);
        value=max(value,ans);

    }

    dp[start]=value;
    return value;



}



int main()

{
ll n,m;
cin>>n>>m;
vector<ll>v[n+1];
ll dp[n+1];
memset(dp,-1,sizeof(dp));
for(int i=1;i<=m;i++)
{
    ll x,y;

    cin>>x>>y;
    v[x].push_back(y);

}

ll max1=0;

for(int i=1;i<=n;i++)
{

    max1=max(max1,solve(v,i,dp));

}

cout<<max1<<endl;

    return 0;
}


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

signed main()
{
    int n, a, b;
    cin >> n;
    vector<pair<int, int>> t;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        t.push_back({b, a});
    }

    sort(t.begin(), t.end());
    int now = 0;

    for (auto v : t)
    {
        now += v.second;
        if (now > v.first)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 6384
#include<cstdio>

typedef long long int lli;

int main(void) {
    int n;
    scanf("%d",&n);
    int k;
    scanf("%d",&k);

    char ok[10]={1,1,1,1,1,1,1,1,1,1};
    for(int i=0; i<k; i++) {
        int d;
        scanf("%d",&d);
        ok[d] = 0;
    }

    while(1) {
        int t=n;
        bool o = true;
        while(t) {
            if(!ok[t%10])
                o = false;
            t/=10;
        }
        if(o) break;
        n++;
    }
    printf("%d\n",n);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int a, b;
    cin >> a >> b;
    if(a < 6) cout << 0;
    else if(6 <= a && a <= 12) cout << b/2;
    else cout << b;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const long long mod=1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return a%b?gcd(b,a%b):b;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}

int main(){
ll a,b;
ll ans=2020;
cin>>a>>b;
if(b-a>=2018)cout<<0<<endl;
else{
	for(ll i=a;i<b;i++){
       for(ll j=i+1;j<=b;j++){
		   if(ans>(i%2019)*(j%2019)%2019)ans=(i%2019)*(j%2019)%2019;
	   }
	}
cout<<ans<<endl;
}
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    char c[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << c[i][j];
        }
        cout << endl;
        for (int j = 0; j < w; j++) {
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = input()

MOD = 10**9 + 7

# dp[i][j] : 左からi番目の数値まで確定していて、最後に置いた値が未使用の値のうちj番目に小さい値 である場合の数(0-indexed)
dp = [[0]*N for _ in range(N)]
for i in range(N):
    dp[0][i] = 1 # 一番左は0からN-1まで1通りずつ

for i in range(1,N):
    if s[i-1] == ">": # dp[i-1][j]をdp[i][j-1],...,dp[i][0] に足す
        x = dp[i-1][N-i]
        for j in reversed(range(N-i)): # jが大きい要素から順に累積和を足す
            dp[i][j] += x
            dp[i][j] %= MOD
            x += dp[i-1][j]
            x %= MOD
    else: # dp[i-1][j]をdp[i][j],...,dp[i][N-i-1] に足す。dp[i][j]が含まれる点に注意
        x = dp[i-1][0]
        for j in range(N-i): # jが小さい要素から順に累積和を足す
            dp[i][j] += x
            dp[i][j] %= MOD
            x += dp[i-1][j+1]
            x %= MOD

print(dp[N-1][0]) # 最後に置く値は必ず0番目に小さいのでdp[N-1][0]以外のdp[N-1]の要素は0

Measured memory_bytes: 112348
from collections import Counter
 
n = int(input())
vs = input().split()
 
xs = [v for v in vs[::2]]
x = Counter(xs).most_common()

ys = [v for v in vs[1::2]]
y = Counter(ys).most_common()
 
if x[0][0] != y[0][0]:
    rw1 = n - x[0][1] - y[0][1]
    print(rw1)
else:
    if len(x) == 1 and len(y) != 1:
        rw2 = n//2 - y[1][1]
        print(rw2)
    elif len(x) != 1 and len(y) == 1:
        rw3 = n//2 - x[1][1]
        print(rw3)
    elif len(x) ==1 and len(y) == 1:
        rw4 = n//2
        print(rw4)
    else:
        rw5_1 = (n//2 - x[0][1]) + (n//2 - y[1][1])
        rw5_2 = (n//2 - x[1][1]) + (n//2 - y[0][1])
        print(min(rw5_1, rw5_2))

Measured memory_bytes: 23528
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
	char s[4];
	scanf("%s", s);
	if (s[1] == 'R')
		printf("ABC\n");
	else if (s[1] == 'B')
		printf("ARC\n");
	return (0);
}

Measured memory_bytes: 2088