akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i= 0; i < n; i ++) {
            a[i] = sc.nextInt();
        }
        System.out.println(cal(n, a));
    }

    private static long cal(final int n, final int[] a) {
        long res = 0L;
        int maxP = 0;
        for (int i = 0; i < n; i ++) {
            if (maxP == 0) {
                res += a[i] - 1;
                maxP = 1;
            } else {
                int num = a[i] / (maxP + 1);
                if (a[i] == maxP + 1) {
                    maxP ++;
                } else if (a[i] % (maxP + 1) == 0) {
                    res += num -1;
                } else {
                    res += num;
                }
            }
        }
        return res;
    }
}


Measured memory_bytes: 46608
#include <stdio.h>
void selectionSort(int *arr, int arrsize, int *count) {
  int minj, tmp;
  for (int i = 0; i < arrsize; i++) {
    minj = i;
    for (int j = i; j < arrsize; j++) {
      if (arr[j] < arr[minj]) minj = j;
    }
    if (i != minj) {
      tmp = arr[i];
      arr[i] = arr[minj];
      arr[minj] = tmp;
      *count += 1;
    }
  }
}
int main() {
  int num,count = 0;
  scanf("%d",&num);
  int arr[num];
  for (int i = 0; i < num; i++) scanf("%d", &arr[i]);
  selectionSort(arr,num,&count);
  for (int i = 0; i < num; i++) {
    if (i == num-1) printf("%d", arr[i]);
    else printf("%d ", arr[i]);
  }
  printf("\n%d\n", count);
  return 0;
}



Measured memory_bytes: 2756
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll r,g;
cin>>r>>g;
cout<<g+(g-r)<<endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <sstream>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <istream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    vector<int> bell;
    int a, b, c;
    cin >> a >> b >> c;
    bell.push_back(a);
    bell.push_back(b);
    bell.push_back(c);

    sort(bell.begin(), bell.end());
    cout << bell[0]+bell[1] << endl;
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int n, d, x;
  cin >> n >> d >> x;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];

  int ans = x;
  rep(i, 0, n) {
    int j = 1;
    while(j <= d) {
      ans++;
      j += a[i];
    }
  }
  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int length = S.size();
  int64_t total = 0;  
  for (int i = 0; i < (1 << (length - 1)); i++) {
    bitset<9> op(i);
    int64_t sum = 0;
    string a;
    a += S.at(0);
    for (int j = 0; j < length - 1; j++) {
      if (op.test(j)) {
        sum += stoll(a);
        a ="";
        a += S.at(j + 1);
      }
      else {
        a += S.at(j + 1);
      }
      if (j == length - 2) {
        sum += stoll(a);
      }
    }
    if (length == 1) {
      sum += stoll(S);
    }
    total += sum;
  }
  cout << total << endl;  
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  
  int c[n],v[n],count=0;
  int i;
  for(i=0; i<n; i++) scanf("%d",&v[i]);
  for(i=0; i<n; i++){
    scanf("%d",&c[i]);
    if(v[i]-c[i] > 0) count += (v[i]-c[i]);
  }
  printf("%d\n",count);
  return 0;
}
  
  

Measured memory_bytes: 128
a, b, c = map ( int , input().split() )
x = 0
y = 0
if a==5:
    x+=1
elif a==7:
    y+=1
if b==5:
    x+=1
elif b==7:
    y+=1
if c==5:
    x+=1
elif c==7:
    y+=1
if x==2 and y==1:
    print( "YES" )
else:
    print ( "NO" )


Measured memory_bytes: 3060
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

    int ans = 0;
    while(N) {
        ans++;
        N /= K;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,k,i,j;

    scanf("%d %d",&n,&k);

    int d[k],tmp,b[n];
    for(i=0;i<n;i++){
        b[i]=0;
    }

    for(i=0;i<k;i++){
        scanf("%d",&d[i]);
        for(j=0;j<d[i];j++){
            scanf("%d",&tmp);
            b[tmp-1]=1;
        }
    }
    int cnt=0;
    for(i=0;i<n;i++){
        if(b[i]==0){
            cnt++;
        }
    }
    printf("%d\n",cnt);

    return 0;
}


Measured memory_bytes: 1728
def main():
    n = int(input())

    minSum = 10**18

    for a in range(1, n):
        b = n - a

        sumA = 0
        sumB = 0

        for digit in str(a):
            sumA += int(digit)
        
        for digit in str(b):
            sumB += int(digit)
        
        total = sumA + sumB
        
        if total < minSum:
            minSum = total
    
    print(minSum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std;
int main(){
    int h,w,tr;
    cin>>h>>w>>tr;
    string s[h];
    vi v[h],c(h,0);
    int ans[h][w],a=1,arr[w];
    memset(arr,0,sizeof(arr));
    pan(i,h) {
        int count=0;
        cin>>s[i];
        pan(j,w){
            if(s[i][j]=='#'){ 
                v[i].pb(j);
                count++;
            }
        }
        c[i]=count;
    }
    int chut=0;
    for(int i=h-1;i>=0;i--){
        if(c[i]!=0){
            chut=i;
            break;
        }
    }
    int i=0,j=0,dum=1,x,k=0;
    for( k=0;k<h;k++){
        if(c[k]!=0){
            int q=0;
            for(int we:v[k]){
                for(q;q<=we;q++){
                    arr[q]=dum;
                }
                dum++;

            }
            dum--;
            for(int we=v[k][v[k].size()-1];we<w;we++)
                arr[we]=dum;
            dum++;
            for(i;i<=k;i++){
                for(j=0;j<w;j++){
                    ans[i][j]=arr[j];
                }
            }
        }
        if(k==chut) break;
    }
    k++;
    for(k;k<h;k++){
        for(j=0;j<w;j++)
            ans[k][j]=arr[j];
    }
    pan(i,h){
        pan(j,w) cout<<ans[i][j]<<" ";
        cout<<endl;
    }
}

Measured memory_bytes: 2048
#include <stdio.h>

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

  scanf("%d",&S);

  h = S/3600;
  m = S%3600/60;
  s =S%60;

  /*
  printf("%d:%d:%d\n",S/3600, S/60, S);
  */

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

  return 0;

}

Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long x = scan.nextInt();
        long y = scan.nextInt();
        long answer = Long.MAX_VALUE;
        long step1 = step1(x, y);
        if (0 < step1) {
            answer = Math.min(answer,step1);
        }
        long step2 = step2(x, y);
        if (0 < step2) {
            answer = Math.min(answer,step2);
        }
        long step3 = step3(x, y);
        if (0 < step3) {
            answer = Math.min(answer,step3);
        }
        long step4 = step4(x, y);
        if (0 < step4) {
            answer = Math.min(answer,step4);
        }
        System.out.println(answer);
    }
    private long step1(long x, long y) {
        if (x <= y) {
            return y - x;
        }
        return -1;
    }
    private long step2(long x, long y) {
        if (-x < y) {
            return y + x + 1;
        }
        if (-x == y) {
            return 1;
        }
        return -1;
    }
    private long step3(long x, long y) {
        if (x < -y) {
            return - y - x + 1;
        }
        if (x == -y) {
            return 1;
        }
        return -1;
    }
    private long step4(long x, long y) {
        if (-x < -y) {
            return - y + x + 2;
        }
        return -1;
    }
}


Measured memory_bytes: 21716
#include <stdio.h>

int main(void)
{
	int N,A,B;
	int x,y;
	
	scanf("%d%d%d",&N,&A,&B);
	
	if(A>B){
	x=B;
	}else{
	x=A;
	}
	
	if(A+B-N>0){
	y=A+B-N;
	}else{
	y=0;
	}
	
	printf("%d %d",x,y);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double a,sum;
    sum = 0;
    for(int i=0;i<n;i++){
        cin>>a;
        sum+=(1/a);
    }
    cout<<setprecision(12)<<(1/sum)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d, e, n, s, t, m;
  m = 0;
  in3(n, s, t);
  rep(i, n + 1){
    a = i / 10000;
    b = (i / 1000) % 10;
    c = (i / 100) % 10;
    d = (i / 10) % 10;
    e = i % 10;
    if(s <= a+b+c+d+e && a+b+c+d+e <= t)
      m = m + i;
  }
  out(m);
  memi;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int sum = 0;
  REP(i,n){
    if(i%2) sum -= a[i];
    else sum += a[i];
  }

  REP(i,n){
    cout << sum << " ";
    sum = (a[i]-sum/2)*2;
  }
  cout << endl;

  return 0;
}

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

int main(){
  char a;
  cin >> a;
  if('A'<=a && a<='Z')cout << "A\n";
  else cout << "a\n";
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c,d=0;
    cin >> a >> b >> c;
    if(10*a+b+c>d){
        d=10*a+b+c;
    }
    if(10*b+c+a>d){
        d=10*b+c+a;
    }
    if(10*c+a+b>d){
        d=10*c+a+b;
    }
    cout << d;
}

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

int main(){

    string s;
    int n;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){

        if(s.at(i)+n<='Z') s.at(i)+=n;
        else s.at(i)+=(n-26);


    }

    cout<<s<<endl;






    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    VEC(Pii) shops(N);
    FOR(i, 0, N) {
        cin >> shops[i].first >> shops[i].second;
    }

    sort(ALL(shops));
    lint ret = 0;
    FOR(i, 0, N) {
        if (M <= 0)
            break;
        int buy = min(M, shops[i].second);
        ret += buy * 1LL * shops[i].first;
        M -= buy;
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 1024
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn fact_divn(n: u64, m: u64) -> u64 {
    let mut n = n;
    let mut cnt = 0;
    while n != 0 {
        cnt += n / m;
        n /= m;
    }
    cnt
}

fn main() {
    input! {
        n: u64
    }
    if n % 2 == 1 {
        println!("0");
        return;
    }
    println!("{}", fact_divn(n/2, 5));
}
/* vim:set foldmethod=marker: */


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

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

    while (1) {
        c = c - b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a = a - d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int a[100000];
int dp[100000];
signed main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> a[i];
  sort(a, a+M);
  
  dp[0] = 1;
  int p = 0;
  if (a[p] == 1) {
    dp[1] = 0;
    p++; 
  } else {
    dp[1] = 1;
  }
  for (int i = 2; i < N+1; i++) {
    if (a[p] == i) {
      dp[i] = 0;
      p++;
    } else {
      dp[i] = dp[i-1] + dp[i-2];
    }
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
}



Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<pair<long long, long long>, null_type, less<pair<long long, long long> >, rb_tree_tag, tree_order_statistics_node_update>
const int N = 2e5 + 5;
ordered_set s;
long long a[N];
long long ans = 0;
int main() 
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) 
    {
		cin >> a[i + 1];
		a[i + 1] += a[i] - k;
	}
	for (int i = 0; i <= n; i++) 
    {
		int tmp = s.order_of_key({a[i], i});
		ans += tmp;
		s.insert({a[i], -i});
	}
	cout << ans;
}



	
            


 

Measured memory_bytes: 14336
def calc(formula)
  # ここでしか使わないので限定的
  return formula.split("+").map(&:to_i).inject(0, &:+)
end

s = gets.chomp
# 文字と文字の間の数は、文字列長-1
len = s.length - 1

result = 0

# 総当たり
calc_count = 2 ** len
index_range = (0...len).to_a
(0...calc_count).each { |b|
  # 毎回文字列を破壊的に編集するのでコピー
  copied = String.new(s)
  # "+"を挿入する
  index_range.each{ |i|
    if b[i] == 1
      # 後ろから（前からやるとズレる）
      copied[len - i, 0] = '+'
    end
  }
  # 計算実行
  result += calc(copied)
}

puts result


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

int main(){
  int n;
  double ax,ay,ar,bx,by,br;
  double dis;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> ax >> ay >> ar >> bx >> by >> br;

    dis = sqrt( (ax-bx)*(ax-bx) + (ay-by)*(ay-by) );
    if( dis > ar + br)cout << 0 << endl;
    else if( br < ar && dis < ar - br)cout << 2 << endl;
    else if( ar < br && dis < br - ar)cout << -2 << endl;
    else cout << 1 << endl;
  }
}

Measured memory_bytes: 0
//Sum of Integers

#include<stdio.h>

#define MAX_N   10


int main(void){
    int i, j, k, l;
    int n;
    
    while(scanf("%d", &n) != EOF){
        int count = 0;
        //??¨??¢?´¢
        for(i = 0; i < MAX_N; i++)
            for(j = 0; j < MAX_N; j++)
                for(k = 0; k < MAX_N; k++)
                    for(l = 0; l < MAX_N; l++)
                        if(i + j + k + l == n) count++;
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 596
using System;
class main{
    static void Main(string[] args){
        string[] line = Console.ReadLine().Split(' ');
        double x1 = double.Parse(line[0]);
        double y1 = double.Parse(line[1]);
        double x2 = double.Parse(line[2]);
        double y2 = double.Parse(line[3]);
        double x = 0;
        double y = 0;
        double distance = 0;
        if(x1>0 && x2>0){
            if (x1 > x2)
            {
                x = x1 - x2;
            }
        }
        else if (x1 <= 0 && x2 <= 0)
        {
            if (x1 > x2)
            {
                x = x2 + x1;
            }
        }
        else if (x1 > 0)
        {
            x = x1 + x2 * -1;
        }
        else
        {
            x = x2 + x1*-1;
        }

        if (y1 > 0 && y2 > 0)
        {
            if (y1 > y2)
            {
                y = y1 - y2;
            }
        }
        else if (y1 <= 0 && y2 <= 0)
        {
            if (y1 > y2)
            {
                y = y1 - y2;
            }
        }
        else if (y1 > 0)
        {
            y = y1 + y2 * -1;
        }
        else
        {
            y = y2 + y1*-1;
        }

        distance = Math.Sqrt(x * x + y * y);
        Console.WriteLine("{0:f6}", distance);
    }
}

Measured memory_bytes: 20096
{-# LANGUAGE BangPatterns #-}
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve !n !m !edges = V.create $ do
  -- m 番目の島から順番に島同士が「繋がっていく」と考える

  -- j = assocs ! i : i 番目の島の親が j
  -- assocs <- VM.new n
  -- forM_ [0..n-1] $ \i -> VM.write assocs i i
  !assocs <- V.thaw $ V.enumFromN 0 n

  -- numberOfElements ! i : i番目の島と同じ連結成分に属する島の個数
  !numberOfElements <- VM.replicate n 1

  !rank <- VM.replicate n (0 :: Int)

  let getRoot !i xs = do
        !j <- VM.read assocs i
        if i == j
          then forM_ xs (\l -> VM.write assocs l i) >> return i
          else getRoot j (i:xs)

      -- i 番目の島と j 番目の島を繋いで、新たに繋がった組み合わせの個数を返す
      unify !i !j = do
        !i' <- getRoot i []
        !j' <- getRoot j []
        if i' == j'
          then return 0
          else do
          !ri <- VM.read rank i'
          !rj <- VM.read rank j'
          !k <- case compare ri rj of
                  EQ -> do VM.write rank i' (ri + 1)
                           return i'
                  LT -> return j'
                  GT -> return i'
          VM.write assocs i' k
          VM.write assocs j' k
          !n1 <- VM.read numberOfElements i'
          !n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return $! n1 * n2
  !result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

readIntPair :: IO (Int, Int)
readIntPair = do
  [a,b] <- BS.words <$> BS.getLine
  case (BS.readInt a, BS.readInt b) of
    (Just (a', _), Just (b', _)) -> return (a',b')

main = do
  (n,m) <- readIntPair
  -- [n,m] <- map (read . BS.unpack) . BS.words <$> BS.getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    (a,b) <- readIntPair
    -- [a,b] <- map (read . BS.unpack) . BS.words <$> BS.getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 6908
//Binomial
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,a[N],maxv,minv,ans,val,maxvv;
int main(){
	cin>>n;
	maxv=-999;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		maxv=max(maxv,a[i]);
	}
	cout<<maxv<<' ';
	maxvv=maxv/2;
	minv=1000000000;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==maxv)
			continue;
		if(maxv%2==0)
			val=abs(a[i]-maxvv);
		else
			val=min(abs(a[i]-maxvv),abs(a[i]-(maxvv+1)));
		if(val<minv)
			minv=val,ans=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
def solve(x,y):
  ans=x*y
  for i in range(1,x):
    a=i*y
    b=max((x-i)*(y//2),((x-i)//2)*y)
    c=x*y-a-b
    ans=min(ans,max(a,b,c)-min(a,b,c))
  return ans

h,w=map(int,input().split())
print(min(solve(h,w),solve(w,h)))

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

int main(){

    string S;
    int N;

    cin >> N;
    cin >> S;

    for(auto& temp:S){
        for(int i=0;i<N;i++){
            temp++;
            if(temp=='Z'+1)temp='A';
        }
        cout << temp;
    }
    return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  auto ci = [](char c){
    return (int)(c - 'a');
  };

  int ans = 0;
  for (int j = 0; j < m-1; j++){
    int dp[n+1][n+1], cl[n+1][n+1], cr[n+1][n+1];
    memset(dp, 0x3f3f3f, sizeof dp);
    memset(cl, 0x3f3f3f, sizeof cl);
    memset(cr, 0x3f3f3f, sizeof cr);
    
    dp[0][0] = 0;

    for (int i = 0; i <= n; i++) { cl[0][i] = 0; cr[0][i] = 0; }

    for (int i = 1; i <= n; i++){
      for (int k = 0; k <= n; k++) {
        if (i + k > n) continue;
        cl[i][k] = cl[i-1][k];
        if (a[i-1][j] == a[i+k-1][j+1]) cl[i][k]++;
      }
    }

    for (int i = 1; i <= n; i++){
      for (int k = 0; k <= n; k++) {
        if (i + k > n) continue;
        cr[i][k] = cr[i-1][k];
        if (a[i-1][j+1] == a[i+k-1][j]) cr[i][k]++;
      }
    }

    for (int k = 1; k <= 2 * n; k++){
      for (int i = 0; i <= min(k, n); i++){
        int i2 = k - i;
        if (i > 0) {
          int add = 0;
          if (i <= i2) add = cl[i][i2 - i];
          else add = cr[i2][i - i2];
          dp[i][i2] = min(dp[i][i2], dp[i-1][i2] + add);
        }
        if (i2 > 0) {
          int add = 0;
          if (i <= i2) add = cl[i][i2 - i];
          else add = cr[i2][i - i2];
          dp[i][i2] = min(dp[i][i2], dp[i][i2-1] + add);
        }
      }
    }

    //cout << dp[n][n] << '\n';
    ans += dp[n][n];
  }

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

    solve();

    return 0;
}


Measured memory_bytes: 4836
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int c1 = sc.nextInt();
      int c2 = sc.nextInt();
      int c3 = sc.nextInt();
      boolean[] used = new boolean[11];
      used[c1] = true;
      used[c2] = true;
      used[c3] = true;
      int counter = 0;
      for (int i = 0; i < 11; i++) {
        if (!used[i] && c1+c2+i < 20) {
          counter++;
        }
      }
      if(counter > 3) {
        System.out.println("YES");
      }
      else {
        System.out.println("NO");
      }
    }
  }
}

Measured memory_bytes: 11000
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // memset()
#include <stdbool.h>

#define MAX_N 50000
#define MAX_SQRT_N 224
#define MAX_P 5140

bool f[MAX_N + 1];
int primes[MAX_P];
int np;

int
main(int argc, char **argv)
{
	int i, j;

	memset(f, 0x00, sizeof(f));
	np = 0;
	for (i = 2; i <= MAX_N; ++i)
	{
		if (!f[i])
		{
			primes[np++] = i;
			if (i <= MAX_SQRT_N)
			{
				for (j = i + i; j <= MAX_N; j += i)
					f[j] = true;
			}
		}
	}

	while (true)
	{
		int n;
		scanf("%d", &n);
		if (n == 0)
			break;

		int count = 0;
		for (i = 0; primes[i] <= n / 2; ++i)
		{
			if (n - primes[i] >= 2 && !f[n - primes[i]])
				count++;
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 676
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

n,m=get_i
s=get_nsp
t=get_nsp
if n>m
    n,m=m,n
    s,t=t,s
end
unless (m%n).zero?
    l=n.lcm(m)
    na=l/m
    ma=l/n
    flag=true
    min(n/na,m/ma).times do|i|
        if s[i*na]!=t[i*ma]
            flag=false
            break
        end
    end
    if flag
        puts l
    else
        puts "-1"
    end
else
    x=m/n
    flag=true
    n.times do|i|
      if s[i]!=t[i*x]
          flag=false
          break
      end 
    end
    if flag
        puts n.lcm(m)
    else
        puts "-1"
    end
end

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

using namespace std;

int main() {
    int a, b;cin>>a>>b;
    string s; cin>>s;
    if(s.length() != (a+b+1) || s[a]!='-') {
        cout<<"No\n";
        return 0;
    }
    for(int i=0;i<a;i++) {
        if(s[i]<'0' || s[i]>'9') {
            cout<<"No\n";
            return 0;
        }
    }
    for(int i=a+1;i<a+b+1;i++) {
        if(s[i]<'0' || s[i]>'9') {
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;cin>>a;
        mp[a]++;
    }
    vector<ll> a;
    for(auto& p:mp)a.push_back(p.second);
    sort(a.begin(),a.end());
    ll res=a.size();
    rep(i,a.size()-1){
        a[i+1]-=(a[i]-1);
        a[i]=1;
    }
    if(a[a.size()-1]%2==0)res--;
    cout<<res<<endl;
}


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

int main() {
	int n;
	cin >>n;
	vector<int> d(n);
	rep(i,n)cin>>d[i];
	sort(d.begin(),d.end());
	int ans=d[n/2]-d[n/2-1];
	cout<<ans<<endl;
}


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

int main(int argc, char const *argv[]) {
    int N;std::cin >> N;
    long long a[N];
    for (size_t i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    long long sum_1=0;
    long long ans_1=0;

    for (size_t i = 0; i < N; i++) {
        if (i%2==0 && sum_1+a[i] >= 0) {
            ans_1+=sum_1+a[i]+1;
            sum_1=-1;
        }else if(i%2==1 && sum_1+a[i] <= 0){
            ans_1+=1-sum_1-a[i];
            sum_1=1;
        }else{
            sum_1+=a[i];
        }
    }
    long long sum_2=0;
    long long ans_2=0;


    for (size_t i = 0; i < N; i++) {
        if (i%2==0 && sum_2+a[i] <= 0) {
            ans_2+=1-sum_2-a[i];
            sum_2=1;
        }else if(i%2==1 && sum_2+a[i] >= 0){
            ans_2+=sum_2+a[i]+1;
            sum_2=-1;
        }else{
            sum_2+=a[i];
        }
    }
    std::cout << std::min(ans_1,ans_2) << '\n';


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, K;
    cin >> N >> K;

    vec<ll> P(N);
    rep(i, N) cin >> P[i], --P[i];

    vec<ll> C(N);
    rep(i, N) cin >> C[i];

    ll ans = -1e18 - 9;
    rep(i, N) {
        ll now = i;
        ll smS = 0;
        vec<ll> sm;
        while (1) {
            smS += C[now];
            sm.push_back(smS);
            now = P[now];
            if (now == i) break;
        }
        int L = sm.size();
        rep(j, L) {
            ll tmp     = -1e18 - 9;
            ll zan     = K - (j + 1);
            if(zan < 0) break;
            ll roopCnt = zan / L;
            ll roopSm  = smS * roopCnt;
            tmp        = max({tmp, sm[j], sm[j] + roopSm});
            ans        = max(ans, tmp);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3808
#include <iostream>

#define B (1000000007ULL)
using namespace std;
typedef unsigned long long ull;

int h, w, r, c;
char t[1000][1001], p[1000][1001];
ull th[1000][1000], ph[1000];
int st[1001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    cin.ignore();
    for(int i=0; i<h; i++)
        cin.getline(t[i], 1001);
    cin>>r>>c;
    cin.ignore();
    for(int i=0; i<r; i++)
        cin.getline(p[i], 1001);

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            ph[i]=ph[i]*B+p[i][j];
        }
    }
    ull bn=B;
    for(int i=1; i<c; i++) bn*=B;
    for(int i=0; i<h; i++){
        for(int j=0; j<c; j++) th[i][0]=th[i][0]*B+t[i][j];
        for(int j=0; j<w-c; j++) th[i][j+1]=th[i][j]*B-t[i][j]*bn+t[i][j+c];
    }
    for(int y=0; y<=h-r; y++){
        for(int x=0; x<=w-c; x++){
            int i;
            for(i=0; i<r&&th[y+i][x]==ph[i]; i++);
            if(i==r) cout<<y<<' '<<x<<'\n';
        }
    }
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    if(s.size()%2==1) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < s.size()-1; i+=2) {
        if(s.substr(i, 2)!="hi") {
            cout << "No" << endl;
            return 0;
        }
    } 
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int a[200];
signed main()
{
	int n,y=0;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		y+=a[i];
	}
	int x=0,ans=1000000;
	for (int i=0;i<n;i++){
		x+=a[i];
		ans=min( ans , abs( x-(y-x) ) );
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define DIV 1000000000

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main()
{
    ull a;
    double b;
    cin >> a >> b;
    ull tmp = b *  1000LL;

    cout << a * tmp / 1000LL << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= t * s) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
using Graph = vector<vector<int>>;
Graph G;

void dfs(int s, map<pair<int, int>, int> &ma, vector<int> &color,
         set<int> &cnt) {
    int c = 0;
    for (auto ns : G[s]) {
        if (color[ns] != -1)
            continue;
        c++;
        if (color[s] == c)
            c++;
        ma[{min(s, ns), max(s, ns)}] = c;
        color[ns] = c;
        cnt.insert(c);
        dfs(ns, ma, color, cnt);
    }
    return;
}

int main() {
    int N;
    cin >> N;
    G.assign(N, vector<int>());
    vector<vector<int>> nodes(N, vector<int>(2));
    int s;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        s = a;
        G[a].push_back(b);
        G[b].push_back(a);
        nodes[i][0] = a, nodes[i][1] = b;
    }

    map<pair<int, int>, int> ma;
    vector<int> color(N, -1);
    set<int> cnt;
    color[s] = 0;
    dfs(s, ma, color, cnt);
    cout << cnt.size() << endl;
    rep(i, N - 1) {
        int a = nodes[i][0], b = nodes[i][1];
        cout << ma[{a, b}] << endl;
    }
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
#define fst first
#define snd second
#define pb push_back
 
template<typename T> bool chkmin(T&a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool chkmax(T&a, T b) { return a < b ? a = b, 1 : 0; }
 
const int maxn = 400000 + 10;

LL n, m;
LL a[maxn];
pair<LL, LL> rng[maxn];
 
LL cnt, ans;
void add(LL l, LL r) {
    rng[++cnt] = make_pair(l, LLONG_MIN);
    rng[++cnt] = make_pair(r, l-r);
    ans += r-l;
}
 
int main() {
 
    cin >> n >> m;
    for(LL i = 1; i <= n; i++) {
        cin >> a[i];
        if(i > 1) {
            if(a[i-1] == a[i]) continue;
            if(a[i-1] < a[i]) add(a[i-1], a[i]);
            else add(a[i-1], a[i] + m);
        }
    }
 
    sort(rng+1, rng+cnt+1);
 
    static LL del[maxn];
    LL dans = 0;
    LL tot = 0, res = 0;
    for(LL j = 1, i = 1; i <= 2*m + 1; i++) {
 
        res += tot;
        del[i-1] = res - tot;
 
        while(j <= cnt && rng[j].fst == i) {
            if(rng[j].snd == LLONG_MIN) ++ tot; 
            else break;
            ++ j;
        }
        while(j <= cnt && rng[j].fst == i) {
            -- tot, res += rng[j].snd;
            ++ j;
        }
    }
    for(int i = 1; i <= m; i++) chkmax(dans, del[i] + del[i+m]);
    printf("%lld\n", ans - dans);
    return 0;
}


Measured memory_bytes: 10496
//二部グラフ判定
//UnionFindによる
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

//頂点0は塗分け用のノード、1~100000は1つ目のノードセット、100001~200000は二つ目のノードセット
const int MAX_N=200001;
int par[MAX_N]; //親の番号
int height[MAX_N]; //木の高さ(ランク)

//xの親番号を返す、再帰処理あり
int root(int x){
  return par[x] == x ? x : par[x] = root(par[x]);
}

//xとyの親番号が同一か判定する
bool same(int x, int y){
  return root(x) == root(y);
}

//xとyのある木を結合する
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y) return; //親が同一なら結合済み。

  if(height[x] < height[y]) par[x] = y;
  else {
    par[y] = x;
    if(height[x] == height[y]) height[x]++;
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  par[0]=0;
  height[0]=0;
  REP(i, N){
    par[i+1] = i+1;
    height[i+1] = 0;
    par[i+1+100000] = i+1+100000;
    height[i+1+100000] = 0;
  }
  pair<int, int> edge[M];
  REP(i, M) cin >> edge[i].first >> edge[i].second;

  unite(0, 1);
  REP(i, M){
    unite(edge[i].first, edge[i].second + 100000);
    unite(edge[i].first + 100000, edge[i].second);
  }

  //二部グラフ判定、ついでに一方の色に塗り分けた頂点の個数を数える
  bool bip=true;
  int color=0;
  REP(i, N){
    if(same(i+1, i+1+100000)) bip = false;
    if(same(0, i+1)) ++color;
  }

  LINT ans;
  if(bip) ans = (LINT)color*(LINT)(N-color)-M;
  else ans = (LINT)N*(LINT)(N-1)/2-M;

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


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

using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}
 
  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
 
  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}
 
  Mint inv(){return pow(MOD-2);}
 
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
 
  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}
 
  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}
 
  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
 
  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

typedef Mint<Int> P;

int main()
{
    Int n, a, b;
    cin >> n >> a >> b;
    P res = P(2).pow(n) - P(1) - P().comb(n,a) - P().comb(n,b);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# (1,2,3,4,5..,N) + (1,2,3,4,...,N/2) * 2 + (1,2,...,N/3) * 3 + ...+(1,) * N
# 累積和を使うことでO(1)でそれぞれの計算をする．N回ループをするので，合計O(N)の計算量で終了する

N = int(input())

S=[0]*(N+1)
for i in range(1,N+1):
    S[i] = S[i-1] + i

ans = 0
for i in range(1,N+1):
    ind = int(N/i)
    ans += S[ind] * i

print(ans)



Measured memory_bytes: 142760
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,a,b;
  cin >> n >> a >> b;
  pr(min(n*a,b));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256