akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;

long long subsum(string s, long long former)
{
  long long sum =  stoll(s);
  //cout << "+ " << stoll(s) << "  sum " << sum << endl;
  for(int i=1; i<s.size() ; i++){
      long long tmp = stoll(s.substr(0, i)) + former;
      sum += tmp;
      //cout << "+ " << stoll(s.substr(0, i)) << " " << former << "  sum " << sum << endl;
      //cout << "next " << s.substr(i, s.size() - i) << endl;
      sum += subsum( s.substr(i, s.size() - i), tmp);
      //cout << "sum " << sum << endl;
  }
  return sum;
}

int main(void)
{
  string s;
  cin >> s;
  
  long long sum = subsum(s, 0);
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int min = 0;
        int max = 0;
        int sum = 0;
        int ans = 0;

        for(int i = 0 ; i < N ; i++){
            a[i] = sc.nextInt();

            if(i == 0){
                min = a[0];
                max = a[0];
            }

            if(min > a[i]){
                min = a[i];
            }

            if(max < a[i]){
                max = a[i];
            }
        }

        for(int j = min ; j <= max ; j ++){
            sum = 0;
            
            for (int i = 0 ; i < N ; i++){
                sum = sum + (a[i] - j) * (a[i] - j) ;
            }

            if(j == min){
                ans = sum;
            }

            if(ans > sum){
                ans = sum;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <string.h>
#include<bits/stdc++.h>
#include <iostream>
#include<algorithm>
#include<list>
#include <functional>
#include <map>
#include <deque>
using namespace std;

#define pt(...) prllf(__VA_ARGS__)
#define sf(...) scanf(__VA_ARGS__)
#define fui(p,n,d) for(ll i = p;i <= n; i += d)
#define fut(p,n,d) for(ll t = p;t <= n; t += d)
#define fuj(p,n,d) for(ll j = p;j <= n; j += d)
#define fdi(n,p,d) for(ll i = n;i >= p; i -= d)
#define fdt(n,p,d) for(ll t = n;t >= p; t -= d)
#define fdj(n,p,d) for(ll j = n;j >= p; j -= d)
#define Conn(x,y) x##y
#define ToString(x) #x
#define ll long long
#define MOD 1000000007
#define p(a,b) pow((double)a, b)
#define me(a,b) memset(a,b,sizeof(a))
bool compare(ll a, ll b){return a>b;}

ll n, a, b;

int main(){
    cin>>n>>a>>b;
    if(a == 0 && b == 0){
        cout<<0;
        return 0;
    }
    ll m = n/(a+b);
    ll t = n%(a+b);
    if(t >= a) cout<<(m*a+a);
    else cout<<(m*a+t);

    return 0;
}



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

int main() {
  int H, W;
  int M;
  cin >> H >> W >> M;
  vector<int> h(M), w(M);
  set<pair<int, int>> data;
  vector<int> counth(H, 0), countw(W, 0);
  for(int i = 0; i < M; i++) {
    cin >> h.at(i) >> w.at(i);
    h.at(i)--;
    w.at(i)--;
    data.insert(make_pair(h.at(i), w.at(i)));
    counth.at(h.at(i))++;
    countw.at(w.at(i))++;
  }
  int64_t hmax = 0;
  int64_t wmax = 0;
  for(int i = 0; i < H; i++) {
    if(counth.at(i) > hmax) {
      hmax = counth.at(i);
    }
  }
  for(int i = 0; i < W; i++) {
    if(countw.at(i) > wmax) {
      wmax = countw.at(i);
    }
  }
  set<int> keeph, keepw;
  vector<int> A, B;
  for(int i = 0; i < H; i++) {
    if(counth.at(i) == hmax) {
      keeph.insert(i);
      A.push_back(i);
    }
  }
  for(int i = 0; i < W; i++) {
    if(countw.at(i) == wmax) {
      keepw.insert(i);
      B.push_back(i);
    }
  }
  int64_t a = keeph.size();
  int64_t b = keepw.size();
  int64_t m = M;
  if(a * b > m) {
    cout << hmax + wmax << endl;
  }
  else {
    bool judge = false;
    for(int i = 0; i < A.size(); i++) {
      for(int j = 0; j < B.size(); j++) {
        if(!data.count(make_pair(A.at(i), B.at(j)))) {
          cout << hmax + wmax << endl;
          judge = true;
          break;
        }
      }
      if(judge) {
        break;
      }
    }
    if(!judge) {
      cout << hmax + wmax - 1 << endl;
    }
  }
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    int l = 0, r = 0;
    int ans = 0;
    int flag = 0;
    while(r < N){
        while(A[r] - A[l] <= 2){
            r++;
            if(r == N){
                ans = max(r-l, ans);
                flag = 1;
                break;
            }
        }
        if(flag) break;
        ans = max(r - l, ans);
        while(A[r] - A[l] > 2) l++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(void) {
  int n,len;
  string s;
  cin>>n>>s;
  len=(n+1)/2;
  
  if(s.substr(0,len)==s.substr(len,len)){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
c=0
m=10**9+7
q=[1,1]
p=[1,1]
an=0
for j in range(1,n+1):
    q.append((q[-1]*j)%m)
    p.append((p[-1]*(n-j))%m)
for i in range(1,n):
    c=(c*i+q[i])%m
    an=(an+(x[i]-x[i-1])*c*p[n-i])%m
print(an)

Measured memory_bytes: 15504
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b){
	return *(int*)b - *(int*)a;
}

int main(void)
{
    int n, i, j, k;
    int ans=0;
    int a[100];

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

    qsort(a, n, sizeof(int), cmp);

    for(i=0; i<n; i++){
        for(j=i+1; j<n; j++){
            for(k=j+1; k<n; k++){
                if(a[i]!=a[j] && a[j]!=a[k] && a[k]+a[j]>a[i]){
                    ans++;
                    
                }
            }
        }
    }

    printf("%d", ans);

}

Measured memory_bytes: 1724
import java.util.Scanner;
     
     
    public class Main {
        

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            long a =sc.nextLong();
            double b =sc.nextDouble();
            
           System.out.println((a*(long)(b*100+0.01))/100);
           
            
           } 
       }
        
    


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

using namespace std;

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

    x3 = y1 - y2 + x2;
    y3 = -(x1 - x2) + y2;
    x4 = -(y2 - y1) + x1;
    y4 = x2 - x1 + y1;

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N, c;
    scanf("%d", &N);
    c=N%10;
    if(c==2||c==4||c==5||c==7||c==9)
    {
        printf("hon\n");
    }
    if(c==0||c==1||c==6||c==8)
    {
        printf("pon\n");
    }
    if(c==3)
    {
        printf("bon\n");
    }

    return 0;
}


Measured memory_bytes: 1620
from scipy.sparse import coo_matrix
from scipy.sparse.csgraph import bellman_ford, NegativeCycleError
import sys
buf = sys.stdin.buffer


def main():
    n, m = map(int, buf.readline().split())
    ABC = map(int, buf.read().split())

    edges = []
    routes = [[] for _ in range(n)]
    rev_routes = [[] for _ in range(n)]

    def get_reachable_nodes(start, routes):
        seen = {start}
        todo = []
        for to in routes[start]:
            todo.append(to)
            seen.add(to)

        while todo:
            node = todo.pop()
            for to in routes[node]:
                if to in seen:
                    continue
                todo.append(to)
                seen.add(to)
        return seen

    for node1, node2, value in zip(ABC, ABC, ABC):
        node1, node2 = node1 - 1, node2 - 1
        edges.append([node1, node2, -value])
        routes[node1].append(node2)
        rev_routes[node2].append(node1)

    from_start = get_reachable_nodes(0, routes)
    to_goal = get_reachable_nodes(n-1, rev_routes)
    from_start_to_goal = from_start & to_goal

    values = []
    rows = []
    cols = []

    for row, col, minus_value in edges:
        if {row, col} <= from_start_to_goal:
            values.append(minus_value)
            rows.append(row)
            cols.append(col)

    graph = coo_matrix((values, (rows, cols)), shape=(n, n))
    try:
        bf = bellman_ford(graph, indices=[0])
        print(-int(bf[0][n - 1]))
    except NegativeCycleError:
        print("inf")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define MOD 1000000007
#define MAX 5000005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int arr[MAX], n;

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

    return cnt;
}

ll powMod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }

    return res;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll k;

    cin>>n>>k;

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

    int cnt1 = countInversion(arr);
    reverse(arr, arr + n);
    int cnt2 = countInversion(arr);
    ll d = 1LL * (cnt1 + cnt2);
    ll a = cnt1;

    ll temp = ((2 * a) % MOD + ((k - 1) * d) % MOD) % MOD;
    temp = (temp * k) % MOD;
    temp = temp * powMod(2, MOD - 2);

    cout<<temp % MOD<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define R register
using namespace std;
int n;
struct node
{
	int id;
	int zhi;
}a[100005];
bool cmp(const node &x,const node &y)
{
	return x.zhi<y.zhi;
}
int main()
{
	scanf("%d",&n);
	for(R int i=1;i<=n;++i)
	    scanf("%d",&a[i].zhi),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(R int i=1;i<=n;++i)
	    cout<<a[i].id<<" ";
    cout<<endl;
	return 0;
}

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

int n;
int ass[32][32];

int memo[65536];
int dfs(int flags) {
  if( flags == (1 << n) - 1 ) return 0;
  if( memo[flags] != 0 ) return memo[flags];
  bool fs[16];
  for(int i = 0; i < n; ++i) {
    fs[i] = (((flags >> i) & 0x01) != 0);
  }
  int min = (1 << 30);
  for(int i = 0; i < n; ++i) {
    if( fs[i] ) continue;
    int min2 = ass[i][0];
    for(int j = 0; j < n; ++j) {
      if( not fs[j] ) continue;
      min2 = std::min(min2, ass[i][j + 1]);
    }
    int t = min2 + dfs(flags | (1 << i));
    min = std::min(min, t);
  }
  if( min == (1 << 30) ) {
    printf("flags : %x\n", flags);
  }
  assert( min != (1 << 30) );
  
  memo[flags] = min;
  return min;
}

int main() {
  for(;;) {
    for(int i = 0; i < (1 << n); ++i) memo[i] = 0;
    scanf("%d", &n);
    if( n == 0 ) break;
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j <= n; ++j) {
        scanf("%d", &ass[i][j]);
      }
    }
    int res = dfs(0);
    printf("%d\n", res);
  }
    
  return 0;
}

Measured memory_bytes: 3404
N,M,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(N)]

import numpy as np
B = np.array(b)
A = np.array(a)
#C = np.ones([N,1])*c
res = np.dot(A,B.T) #+ C
#print(A)
#print(B)
#print(res)
print(np.sum(res > -c))

Measured memory_bytes: 12468
// B - Coins
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int A,B,C,X; cin>>A>>B>>C>>X;
	int ans = 0;
	rp(a,0,A+1) rp(b,0,B+1) rp(c,0,C+1) if(X==500*a+100*b+50*c) ans++;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
i = 0 #ループ回数
m = 0 #ループ終了
while m < 1:
    i = i +1
    for j in range(N):
        if A[j] % 2 != 0:
            m = m + 1
        else:
            A[j] = A[j] / 2
print(i-1)

Measured memory_bytes: 3060
n, x = map(int, input().split())

a, p = [1], [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])


print(f(n, x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;
const int N = 1e5 + 87;

int a[N], b[N], n, m;

int main()
{
	IO_OP;
	
	cin >> m >> n;
	if(m > n) {
		cout << 0 << endl;
		return 0;
	}
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a, a+n);
	for(int i=0;i<n-1;i++)
		b[i] = a[i+1] - a[i];
	sort(b, b+n-1);
	int sm = 0;
	for(int i=n-1;i>=n-m;i--)
		sm += b[i];
	cout << a[n-1] - a[0] - sm << endl;
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  scanf("%d %d", &n, &m);

  int ans[100] = {};
  REP(i,m){
    int a, b;
    scanf("%d %d", &a, &b);
    ans[a - 1]++; ans[b - 1]++;
  }

  REP(i,n){
    printf("%d\n", ans[i]);
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int n, m;

int G[50][50];
bool visited[50];

void bfs(int v) {
  queue<int> que;
  que.push(v);
  visited[v] = true;
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    rep(i, n) {
      if (G[x][i] == 1 && visited[i] == false) {
        visited[i] = true;
        que.push(i);
      }
    }
  }
}

int main() {
  int ans = 0;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[i] = make_pair(a, b);
    G[a][b] = 1;
    G[b][a] = 1;
  }
  rep(i, m) {
    G[p[i].first][p[i].second] = 0;
    G[p[i].second][p[i].first] = 0;
    rep(j, n) { visited[j] = false; }
    bfs(0);
    int cnt = 0;
    rep(j, n) {
      if (visited[j]) cnt++;
    }
    if (cnt != n) ans++;
    G[p[i].first][p[i].second] = 1;
    G[p[i].second][p[i].first] = 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    int n,ans=0,f=0,b=0;
    bool r=1;
    string s;
    cin>>n;
    fr(i,n){
        cin>>s;
        if(s[0]=='B'){
            f++;
            if(s[s.length()-1]!='A') r=0;
        }
        fr(j,s.length()-1) if(s[j]=='A'&&s[j+1]=='B') ans++;
        if(s[s.length()-1]=='A'){
            b++;
            if(s[0]!='B') r=0;
        }
    }
    cout<<ans+max(min(f,b)-r,0)<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);

    string n;
    int k;
    cin >> n >> k;
    int len = n.length();
    // dp[pos][# of non-zero][OK=0/NG=1]
    ll dp[len][4][2] = {};
    for(int i=0;i<len;++i) {
        int current_val = n[i] - '0';
        if (i == 0) {
            dp[i][1][0] = current_val - 1;
            dp[i][1][1] = 1;
        } else {
            dp[i][1][0] += 9 + dp[i-1][1][0];
            if(current_val != 0) {
                // append 0 makes NG -> OK
                dp[i][1][0] += dp[i-1][1][1];
            } else {
                // append 0 makes NG -> NG
                dp[i][1][1] += dp[i-1][1][1];
            }
            for(int j=2;j<=3;++j) {
                // OK -> OK with 1-9
                dp[i][j][0] += dp[i-1][j-1][0] * 9;
                // OK -> OK with 0
                dp[i][j][0] += dp[i-1][j][0];
                if(current_val == 0)
                {
                    // append 0 makes NG -> NG, no other values are possible
                    dp[i][j][1] += dp[i-1][j][1];
                }
                else
                {
                    // append 0 makes NG -> OK
                    dp[i][j][0] += dp[i-1][j][1];
                    dp[i][j][0] += dp[i-1][j-1][1] * (current_val - 1);
                    // append current_val makes NG -> NG;
                    dp[i][j][1] += dp[i-1][j-1][1];
                }
            }
        }
    }
    cout << dp[len-1][k][0] + dp[len-1][k][1] << endl;
}

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

int main(){
	int a, b, x[4], y[4];
		
	while( scanf(" %d %d %d %d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &y[0], &y[1], &y[2], &y[3]) != EOF ){
		int  hit=0, blow=0; 
	
		for(int i=0; i<4; ++i){
			for(int j=0; j<4; ++j){
				if(x[i]==y[j]){
					if(i==j) ++hit;
					else ++blow;
				}
			}
		}
	
		printf("%d %d\n", hit, blow);
	}
	
	return 0;
}

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

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

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

  if(a>=k) cout << k;
  else if(a+b>=k) cout << a;
  else cout << a - (k-a-b);
}

Measured memory_bytes: 3592
import java.util.*

fun main(args: Array<String>) {
	val sc = Scanner(System.`in`)
	val n = sc.nextLine().toLong()
	var a = arrayListOf<Long>()
	for (i in 1..n) {
		a.add(sc.nextLong())
	}
	println("${a.min()} ${a.max()} ${a.sum()}")
}


Measured memory_bytes: 46184
#[allow(unused_imports)]
use std::*;
use proconio::input;

fn main() {
    input! {
		a: f64,
		b: f64,
		h: f64,
        m: f64,
    };
 	
  	let long_angle =  m / 60f64;
  	let short_angle = h / 12f64 + long_angle / 12f64;
  	let angle = long_angle - short_angle;
    let rad = std::f64::consts::PI * 2.0 * angle;
  
  	if angle == 0f64 {
		println!("{}", (a - b).abs());
  	} else {
		let result = (a * a + b * b - 2f64 * a * b * rad.cos()).sqrt();
        println!("{}", result);  	
  	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, K;
    cin >> N >> K;
    if (K == 0) {
        cout << N * N << "\n";
        return 0; 
    }
    ll ans = 0;
    for (int b = K + 1; b <= N; b++) {
        int n = (N+1) / b;
        ans += n * (b - K) + max(0ll, N - ( n * b + K) + 1);
        //printf("%d %d %d\n", b, n, N - (n * b + K));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
s=input()
strings=["dreamer","dream", "eraser","erase"]
i=-1
while len(s)!=0:
  if s[i-1:] in strings:
    s=s[:i-1]
    i=-1
  i-=1
  if i==-len(s):
    print('NO')
    exit()
if len(s)==0:
  print('YES')

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import Counter
import numpy as np

N,K = map(int,input().split())
P = [input().rstrip()[0] for _ in range(N)]

counter = np.array(tuple(Counter(P).values()))

answer = 0
while True:
    counter.sort()
    counter = counter[::-1]
    counter = counter[counter>0]
    if len(counter) < K:
        break
    counter[:K] -= 1
    answer += 1

print(answer)

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

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


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007

using namespace std;



int main()
{
   	IOS
	int n,m;
	cin>>n>>m;
	int mini=INT_MAX;
	int maxi=INT_MIN;
	for(int i=0;i<m;i++)
    {
        int l,r;
        cin>>l>>r;
        mini=min(mini,r);
        maxi=max(maxi,l);
    }
    if(maxi>mini)
        cout<<"0\n";
    else
        cout<<mini-maxi+1<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>

using namespace std;
#define MAX 100

int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    if (N % 2 == 0)
    {
        if (N / 2 >= K)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    else
    {
        if ((N+1) / 2 >= K)
        {
            cout << "YES" << endl;
            return 0;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int n,i,acnt,bcnt;
	char a[101],b[101];
	scanf("%d",&n);
	acnt=0;	bcnt=0;
	for(i=0;i<n;i++)	{
		scanf(" %s %s",a,b);
		if(strcmp(a,b)>0)	acnt+=3;
		else if(strcmp(a,b)==0) {
			acnt++;	bcnt++;
		}
		else bcnt+=3;
	}
	printf("%d %d\n",acnt,bcnt);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
const int INF = 1e9;


const int MOD = 1e9 + 7;
const int MAX = 2001;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

	ll N, K;
	ll ans = 0;

	cin >> N >> K;

	COMinit();

	rep(i, K) {
		cout << COM(N - K + 1, i + 1) * COM(K-1,i) % MOD << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b ,c;
	cin>>a>>b>>c;
	if(a==1 && b==0  &&c==0){
		cout << "Close" <<endl;
	}
	if(a==0&&b==1&&c==0){
		cout<< "Close" <<endl;
	}
	if(a==1&&b==1&&c==0){
		cout << "Open"<<endl;
	}
	if(a==0&&b==0&&c==1){
		cout << "Open"<<endl;
	}
	if(a==0&&b==0&&c==0){
		cout << "Close"<<endl;
	}
	return 0;
}

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

int main(){
	int n;

	while (cin >> n){
		int a = 0;
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				for (int k = 0; k < 10; k++){
					for (int l = 0; l < 10; l++){
						if (i + j + k + l == n)
							a++;
					}
				}
			}
		}
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
//19
#include<iostream>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
  int n;
  cin>>n;
  int a[20];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  static double dp[2][200000];
  fill(dp[0],dp[2],1<<30);
  dp[0][1]=0;
  for(int i=1;i<=n;i++){
    fill(dp[i&1],dp[(i&1)+1],1<<30);
    for(int j=1;j<200000;j++){
      for(int k=j;k<200000;k+=j){
	dp[i&1][k]=min(dp[i&1][k],max(dp[i-1&1][j],abs(k-a[i-1])*1./a[i-1]));
      }
    }
  }
  cout.precision(8);
  cout<<fixed<<*min_element(dp[n&1],dp[(n&1)+1])<<endl;
  return 0;
}

Measured memory_bytes: 4360
#include <stdio.h>
int main(void) {
	int N;
	int x[1024];
	int i;
	int saisyo = 0, saidai = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &x[i]) != 1) return 1;
		if (i == 0 || x[i] < saisyo) saisyo = x[i];
		if (i == 0 || x[i] > saidai) saidai = x[i];
	}
	printf("%d\n", (saidai - saisyo + 1) / 2);
	return 0;
}



Measured memory_bytes: 2144
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
int main() {
	int num[10]={};
	int a[4];
	for(int i=0;i<4;i++){
		int b;
		cin>>b;
		num[b]++;
	}
	if(num[1] && num[9] && num[7] &&num[4])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<sstream>  
#include<set>  
#include<vector>  
#include<stack>  
#include<map>  
#include<queue>  
#include<deque>  
#include<cstdlib>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<ctime>  
#include<functional> 
#define INT_MAX 2147483647
#define INT_MIN -2147483648
typedef long long LL;
using namespace std;
const int maxn = 1024 + 10;
int main()
{
	//freopen("data_in.txt", "r", stdin);
	//freopen("data_out.txt", "w", stdout);
	int a = 0, b = 0;
	cin >> a >> b;
	if (a >= 9 || b >= 9) cout << ":(";
	else cout << "Yay!";

	return 0;
}

Measured memory_bytes: 256
//
// Created on 2020/07/21.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int d;
    cin>>d;
    vector<int>c(26);
    vector<int>last(26,0);
    vector<vector<int>>s(d+1,vector<int>(26));
    for (int i = 0; i < 26; ++i) {
        cin>>c[i];
    }
    for (int i = 1; i <= d; ++i) {
        for (int j = 0; j < 26; ++j) {
            cin>>s[i][j];
        }
    }
    int final_score = 0;
    for (int k = 1; k <= d; ++k) {
        vector<int> best = {-INF,0,0};//score,contest,c*score
        for (int j = 0; j < 26; ++j) {
            int temp_score = final_score;
            int t = j;
            temp_score += s[k][t];
            for (int i = 0; i < 26; ++i) {
                if(i != t) temp_score -= c[i] * abs(k - last[i]);
            }
            if(temp_score > best[0]){
                best[0] = temp_score;
                best[1] = t;
            }
        }
        last[best[1]] = k;
        final_score = best[0];
        cout<<best[1]+1<<endl;
    }

    return 0;
}


Measured memory_bytes: 3684
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
def main():
    n=I()
    lis=LI()
    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a
    lists=[Counter(prime_factorize(lis[i])) for i in range(n)]
    C=Counter([])
    for i in range(n):
        x=lists[i]
        for j in x.keys():
            C[j]=max(C[j],x[j])
    #print(C)
    
    ans=1
    '''for i in range(n):
        x=lists[i]
        y=1
        for j in C.keys():
            y=(y*pow(j,C[j]-x[j],mod))%mod
        #print(y%mod)
        ans=(ans+y)%mod
    print(ans%mod)'''
    invmod=0
    for i in range(n):
        invmod=(invmod+pow(lis[i]%mod,mod-2,mod))%mod
    for x in C.keys():
        ans=(ans*pow(x,C[x],mod))%mod
    print(ans*invmod%mod)
        
if __name__=="__main__":
    main()
        
        
    
    
        
    
    


Measured memory_bytes: 79684
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005

string get(vector<string> &V){
	vector<pair<pair<int,int>,int>> P;
	
	for(int i=0;i<V.size();i++){
		int mini = 0;
		int now = 0;
		for(int j=0;j<V[i].size();j++){
			if(V[i][j]=='(')now++;
			else now--;
			
			mini = min(mini,now);
		}
		P.push_back({{-mini,-now},i});
	}
	sort(P.begin(),P.end());
	string ret = "";
	for(int i=0;i<P.size();i++){
		ret += V[P[i].second];
	}

	return ret;
}

int main(){
	
	int N;
	cin>>N;
	
	vector<string> S(N);
	for(int i=0;i<N;i++){
		cin>>S[i];
	}
	
	vector<string> s1,s2;
	
	for(int i=0;i<N;i++){
		int t = 0;
		for(int j=0;j<S[i].size();j++){
			if(S[i][j]=='(')t++;
			else t--;
		}
		if(t>=0)s1.push_back(S[i]);
		else{
			s2.push_back(S[i]);
			reverse(s2.back().begin(),s2.back().end());
			for(int j=0;j<s2.back().size();j++){
				if(s2.back()[j]=='(')s2.back()[j]=')';
				else s2.back()[j]='(';
			}
		}
	}
	
	
	string S1 = get(s1),S2 = get(s2);
	reverse(S2.begin(),S2.end());
	for(int i=0;i<S2.size();i++){
		if(S2[i]=='(')S2[i]=')';
		else S2[i]='(';
	}
	

	string ans = S1+S2;

	int now = 0;
	for(int i=0;i<ans.size();i++){
		if(ans[i]=='(')now++;
		else now--;
		if(now<0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	if(now!=0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 78812
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())//2
s=input().rstrip()
#print(s[:n],s[n:],"abc"=="abc")
print("Yes" if s[:n]==s[n:] else "No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  cin>>N;
  cin>>S;
  ;
}
void solve() {
  deque<char> q;
  int cntl=0,cntr=0;
  for(auto x : S){
    if (x=='('){
      cntl++;
      q.push_back('(');
    }
    if (x==')'){
      cntr++;

      if (cntl<cntr){
        q.push_front('(');
        cntl++;
      }
    q.push_back(')');
    }
  }
  if (cntl > cntr){
    rep(i,1,cntl-cntr){
      q.push_back(')');
    }
  }
  for(auto x : q){
    cout<<x;
  }
  cout<<endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

using namespace std;

vector<int> adj[100'000];
int subgraph[100'000];

void fill(int node_id, int sub_id)
{
    if (subgraph[node_id] != -1)
    {
        return;
    }

    subgraph[node_id] = sub_id;
    for (auto to = adj[node_id].begin(); to != adj[node_id].end(); to++)
    {
        fill(*to, sub_id);
    }
}

int main()
{
    int N, M;

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y, _z;
        cin >> x >> y >> _z;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for (int i = 0; i < N; i++)
    {
        subgraph[i] = -1;
    }

    int sub_next = 0;
    for (int i = 0; i < N; i++)
    {
        if (subgraph[i] == -1)
        {
            fill(i, sub_next);
            sub_next++;
        }
    }

    cout << sub_next << endl;

    return 0;
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

struct Tree {
	typedef int T;
	const T LOW = 0;
	T f(T a, T b) { return a+b; }

	int n;
	vi s;
	Tree() {}
	Tree(int m, T def=0) { init(m, def); }
	void init(int m, T def) {
		n = 1; while (n < m) n *= 2;
		s.assign(n + m, def);
		s.resize(2 * n, LOW);
		for (int i = n; i --> 1; )
			s[i] = f(s[i * 2], s[i*2 + 1]);
	}
	void update(int pos, T val) {
		pos += n;
		s[pos] = val;
		for (pos /= 2; pos >= 1; pos /= 2)
			s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
	}
	T query(int l, int r) { return que(1, l, r, 0, n); }
	T que(int pos, int l, int r, int lo, int hi) {
		if (r <= lo || hi <= l) return LOW;
		if (l <= lo && hi <= r) return s[pos];
		int m = (lo + hi) / 2;
		return f(que(2 * pos, l, r, lo, m),
				que(2 * pos + 1, l, r, m, hi));
	}
};

int main(){
	cin.sync_with_stdio(false);
    string str;
    cin>>str;
    ll n = str.size();
    vector<vi> v(26);
    vector<vi> v1(26);
    vector<vi> v2(26);
    rep(i,0,n) v[str[i]-'a'].push_back(i);
    rep(i,0,26){
        rep(j,0,v[i].size()){
            if(j<v[i].size()/2) v1[i].push_back(v[i][j]);
            else v2[i].push_back(v[i][j]);
        }
        reverse(all(v1[i]));
    }
    Tree st(n,1);
    ll placed = 0;
    ll ans = 0;
    while(true){
        ll minChar = 0;
        ll mn = 1e18;
        rep(i,0,26){
            if(v1[i].size()==0||v2[i].size()==0) continue;
            ll dist = st.query(0,v1[i][v1[i].size()-1]) + st.query(v2[i][v2[i].size()-1]+1,n);
            if(dist<mn){
                minChar = i;
                mn = dist;
            }
        }
        if(mn==1e18) break;
        ans += mn;
        st.update(v1[minChar][v1[minChar].size()-1],0);
        st.update(v2[minChar][v2[minChar].size()-1],0);
        v1[minChar].pop_back();
        v2[minChar].pop_back();
        placed+=2;
    }
    if(placed+1>=n) cout<<ans<<endl;
    else cout<<-1<<endl;
}


Measured memory_bytes: 14216
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a,b,c,d,e,temp,i;

	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(b>a){
		temp=a;
		a=b;
		b=temp;
	}
	if(c>a){
		temp=a;
		a=c;
		c=temp;
	}
	if(d>a){
		temp=a;
		a=d;
		d=temp;
	}
	if(e>a){
		temp=a;
		a=e;
		e=temp;
	}

	if(c>b){
		temp=c;
		c=b;
		b=temp;
	}
	if(d>b){
		temp=d;
		d=b;
		b=temp;
	}
	if(e>b){
		temp=e;
		e=b;
		b=temp;
	}

	if(d>c){
		temp=d;
		d=c;
		c=temp;
	}
	if(e>c){
		temp=e;
		e=c;
		c=temp;
	}

	if(e>d){
		temp=e;
		e=d;
		d=temp;
	}
	printf("%d %d %d %d %d\n",a,b,c,d,e);
	//for(i=0;i<=1000000000;i++);
	return 0;
}

Measured memory_bytes: 596
use std::io;
use std::cmp;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn change_arr(arr: &mut Vec<i32>, x:usize, y:usize) {
    arr[y] += arr[x];
    println!("{} {}", x+1, y+1);
}



fn main() {
    let n = read_line().trim().parse::<usize>().expect("invalid");
    let mut arr:Vec<i32> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut max = 0;
    let mut idx = 0;
    for i in 0..n {
        if max < arr[i].abs() {
            max = arr[i].abs();
            idx = i;
        }
    }

    println!("{}", 2*n-1);

    for i in 0..n {
        change_arr(&mut arr, idx, i);
    }

    if arr[idx] < 0 {
        for i in (0..n-1).rev() {
            if arr[i+1] < arr[i] {
                change_arr(&mut arr, i+1, i);
            } else {
                change_arr(&mut arr, 0, 0);
            }
        }
    } else {
        for i in 0..n-1 {
            if arr[i+1] < arr[i] {
                change_arr(&mut arr, i, i+1);
            } else {
                change_arr(&mut arr, n-1, n-1);
            }
        }
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

ll march[10];
int main(void){
  int n;
  string s;
  cin>>n;
  ll res=0;
  
  for(int i=0;i<n;i++){
    cin>>s;
    if(s[0]=='M') march[0]++;
    if(s[0]=='A') march[1]++;
    if(s[0]=='R') march[2]++;
    if(s[0]=='C') march[3]++;
    if(s[0]=='H') march[4]++;
  }
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      for(int k=j+1;k<5;k++){
	res+=march[i]*march[j]*march[k];
      }
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            Console.WriteLine(S == "ABC" ?"ARC":"ABC");
        }
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> CS(N + 1, 0);
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    CS[l]++, CS[r + 1]--;
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (CS[i] == M) res++;
    CS[i + 1] += CS[i];
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

int main() {
	long long a, b, c, d;
	int n;
	scanf("%lld %lld %lld %lld %d", &a, &b, &c, &d, &n);
	long long cur = min(a * 4, min(b * 2, c));
	long long ans = (n / 2) * d + (n % 2) * cur;
	ans = min(ans, cur * n);
	printf("%lld\n", ans);	 
	return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         long N = Long.parseLong(st.nextToken());
         long[] pow26 = new long[12];
         pow26[0] = 1L;
         for(int i=1; i <= 11; i++)
            pow26[i] = pow26[i-1]*26;
         int len = 0;
         long total = 0L;
         for(int l=1; l <= 11; l++)
         {
            long temp = 1L;
            for(int i=0; i < l; i++)
               temp *= 26;
            total += temp;
            if(total >= N)
            {
               len = l;
               break;
            }
         }
         char[] res = new char[len];
         Arrays.fill(res, '?');
         for(int i=1; i < len; i++)
            N -= pow26[i];
         for(int curr=0; curr < len-1; curr++)
         {
            long suffix = pow26[len-1-curr];
            char c = 'a';
            long cons = 0L;
            while(true)
            {
               if(N <= cons)
               {
                  res[curr] = (char)(c-1);
                  cons -= suffix;
                  N -= cons;
                  break;
               }
               cons += suffix;
               c = (char)(c+1);
            }
         }
         res[len-1] = (char)('a'+(int)N-1);
         System.out.println(res);
      }
   }

Measured memory_bytes: 32680
#include<map>
#include<cstdio>
#include<iostream>
using namespace std;

char ch;
int n,ans;
map<char,int> mp;

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ch;
		if(!mp[ch]) mp[ch]=1,ans++;
	}
	printf(ans==4?"Four":"Three");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
typedef long long int lli;
const long long int MaxN=1000105;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}

int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	string S;
	int K;
	cin>>K;
	cin>>S;
	if(S.size()>K){
		cout<<S.substr(0,K)<<"...";
	}
	else cout<<S;
}

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

int main(){
  int k,t;
  cin >> k >> t;
  vector<int>a(t);
  for(int i=0;i<t;i++)cin >> a.at(i);
  sort(a.begin(),a.end(),greater());
  int sum=0;
  for(int i=1;i<t;i++)sum+=a.at(i);
  if(a.at(0)-1<=sum)cout << "0\n";
  else cout << a.at(0)-sum-1 << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
  
// driver code 
signed main() 
{ 
    int n, k;
    cin >> n >> k;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
        cin >> arr[i];
    int s = 1, e = 1e9, ans = -1;
    while(s <= e)
    {
        int mid = (s+e)/2;
        int cnt = 0;
        for(i=0;i<n;i++)
        {
            if(arr[i] <= mid)
                continue;
            cnt = cnt + (arr[i] + mid-1)/mid - 1;
        }
        if(cnt <= k)
            ans = mid, e = mid-1;
        else
            s = mid+1;
    }
    cout << ans << '\n';
} 

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

int main()
{
    int N;
    cin >> N;
    int mini = 1000, maxi = 0, a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);
    }
    cout << maxi - mini << endl;
}

Measured memory_bytes: 256
S = input()
if ord(S[0]) != 65:
  print('WA')
else:
  b = 0
  c = 0
  for i in range(1, len(S)):
    if i != 1 and i != len(S) - 1 and ord(S[i]) == 67:
      b += 1
    elif ord(S[i]) <= 96 or 123 <= ord(S[i]):
      c = 1
  if b == 1 and c == 0:
    print('AC')
  else:
    print('WA')

Measured memory_bytes: 61560
#include <cstdint>
#include <iostream>
 
using namespace std;
 
uint64_t gcd(uint64_t a, uint64_t b)
{
  if (b == 0) {
    return a;
  }
 
  return gcd(b, a % b);
}
 
int32_t main()
{
  uint64_t N;
  cin >> N;
 
  uint64_t l = 1;
  for (uint64_t i = 0; i < N; i++) {
    uint64_t val;
    cin >> val;
    l = l / gcd(l, val) * val;
  }
 
  cout << l << endl;
 
  return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  (function(S) {
    var h = Math.floor(S / (60 * 60));
    var m = Math.floor(m = S % (60 * 60) / 60);
    var s = Math.floor(s = S % 60);
    console.log(h +':'+ m +':'+ s);
}(parseInt(inputs.trim(),10))); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644