akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll n;
    cin >> n;

    cout << (n*(n+1))/2-n << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<P> ans;
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
            if ((N % 2 == 0 && i + j != N + 1) || (N % 2 == 1 && i + j != N)) {
                ans.push_back(P(i, j));
            }
        }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 26;
	static int MOD = 998244353;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			Map<Long, Integer> map = new HashMap<>();
			for (int i = 0; i < n; i++) {
				map.merge(a[i], 1, Integer::sum);
			}

			int ans = 0;
			for (int i : map.values()) {
				if (i % 2 == 1) ans++;
			}

			out.println(ans);
		}
	}



	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}
}

Measured memory_bytes: 45988
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll L; cin >> L;
    long double tmp = L / 3.0;
    cout << fixed << setprecision(10) << tmp*tmp*tmp<< endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  const lines = input.split('\n');
  const n = Number( lines[0] );
  const s = lines[1]
  
  const result = s.split('').map(v => {
		const code = v.charCodeAt(0) + n;
		return String.fromCharCode(code % 91 + (65 * Number(code > 90)));
	}).join('');
  
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Spiral Pattern
 */
public class Main {

	static final int[][] DIR = {
			{-1, 0},
			{0, 1},
			{1, 0},
			{0, -1},
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int d = parseInt(line);

			for (int i = 0; i < d; i++) {

				int n = parseInt(br.readLine());
				char[][] grid = new char[n][n];
				int[] path = new int[n];

				for (int j = 0; j < grid.length; j++) {
					Arrays.fill(grid[j], ' ');
				}

				for (int j = 0; j < n; j++) {
					path[j] = n - j;
					if (j > 0 && (j & 1) == 0) path[j]++;
				}

				int y = n, x = 0;

				for (int j = 0; j < path.length; j++) {
					for (int k = 0; k < path[j]; k++) {
						y += DIR[j % 4][0];
						x += DIR[j % 4][1];
						grid[y][x] = '#';
					}
				}

				//
				for (int j = 0; j < grid.length; j++) {
					System.out.println(grid[j]);
				}
				if (i < d - 1) System.out.println();
			}
		}
	}
}

Measured memory_bytes: 24672
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toLong()
        val B = sc.next().toLong()
        val C = sc.next().toLong()
        val D = sc.next().toLong()
        val E = lcm(C, D)
        val b = (B / C + B / D - B / E)
        val a = ((A - 1) / C + (A - 1) / D - (A - 1) / E)
        val ans = (B - A + 1) - (b - a)
        pw.println(ans)

    }
}


Measured memory_bytes: 31000
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        Arrays.setAll(array, i -> sc.nextInt());

        for (int i = 0; i < n - k; i++) {
            System.out.println(array[i] >= array[i + k] ? "No" : "Yes");
        }
    }
}

Measured memory_bytes: 60812
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n,k;
//deque<ll> d;
Vi d;
priority_queue<ll,Vi,greater<ll>> pq;
ll cal(ll l,ll r,ll kk){//[l,r]
    if(l>r)return 0;
    while(!pq.empty())pq.pop();
    ll ans = 0;
    if(l+d.size()-r-1> kk)return 0;
    rep(i,d.size()){
        if(i>=l && i<=r)continue;
        ans += d[i];
        pq.push(d[i]);
    }
    kk -= l+d.size()-r-1;
    rep(i,kk){
        if(!pq.empty() && pq.top()<0){
            ans -= pq.top();
            pq.pop();
        }
    }
    //cout<<l<<" "<<r<<" "<<ans<<endl;
    return ans;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll inp;
    cin>>n>>k;
    rep(i,n){
        cin>>inp;
        d.pb(inp);
    }
    ll ans = 0;
    ll tmp = 0;
    if(k>=n){
        rep(i,n){
            tmp += d[i];
            pq.push(d[i]);
        }
        rep(i,k-n){
            if(pq.top()<0){
                tmp -= pq.top();
                pq.pop();
            }
        }
        chmax(ans,tmp);
    }
    rep(i,n)rep(j,n){
        chmax(ans,cal(i,j,k));
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
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();
		sc.close();
		
		int sum = 0;
		for(int i = 0;i < N;++i)
			sum += a[i];
		double ave = ((double)sum) / N;
		
		int ans = 0;
		double minDiff = Math.abs(a[0] - ave);
		for(int i = 1;i < N;++i) {
			if(Math.abs(a[i] - ave) < minDiff) {
				ans = i;
				minDiff = Math.abs(a[i] - ave);
			}
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
N = int(input())
H = list(map(int,input().split()))
ans = 0
count = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        count += 1
    else:
        ans = max(ans, count)
        count = 0
ans = max(ans, count)
print(ans)


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

using weight = int;

constexpr weight INF = 1e8;

// warshall-floyd
void warshall_floyd(std::vector<std::vector<weight>>& g) {
    int V = g.size();
    for(int k=0; k<V; ++k) {
        for(int i=0; i<V; ++i) {
            for(int j=0; j<V; ++j) {
                g[i][j] = std::min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}


int main() {
    int n, m, s, g1, g2;
    while(cin >> n >> m >> s >> g1 >> g2, n) {
        vector<vector<weight>> d(n, vector<weight>(n, INF));
        for(int i=0; i<n; ++i) {
            d[i][i] = 0;
        }
        for(int i=0; i<m; ++i) {
            int b1, b2, c;
            cin >> b1 >> b2 >> c;
            d[b1-1][b2-1] = c;
        }
        warshall_floyd(d);
        weight ret = INF;
        for(int i=0; i<n; ++i) {
            ret = min(ret, d[s-1][i] + d[i][g1-1] + d[i][g2-1]); // 1e9 * 3 overflow
        }
        cout << ret << endl;
    }
}


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

int main(){
  int n;cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i+=2){
    int sum = 0;
    for(int j=1;j<=i/2;++j){
      if(i%j == 0)sum += 1;
    }
    if(sum == 7)ans += 1;
    sum = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma optimization ("unroll-loops")

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>


using namespace std;

int main() {

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

    int arr[n][n-1];
    for(register int i = 0; i < n; i++) {
        for(register int j = 0; j < n-1; j++) {
            scanf("%d", &arr[i][j]);
            arr[i][j]--;
        }
    }

    int pointers[n];
    memset(pointers, 0, sizeof pointers);

    int dia = 0;
    int algum_match = false;

    bool jogou[n];
    while(true) {
        memset(jogou, false, sizeof jogou);
        algum_match = false;
        for(register int i = 0; i < n; i++) {
            if(pointers[i] == n-1 || jogou[i]) continue;
            //cout << "pi: " << pointers[i] << endl;
            int j = arr[i][pointers[i]];
            //cout << "i: " << i << " p: " << j << " pj: " << pointer << endl;
            if(arr[j][pointers[j]] != i || jogou[j]) continue;

            algum_match = true;
            pointers[i]++;
            pointers[j]++;
            jogou[i] = true;
            jogou[j] = true;
        }
        if(algum_match) dia++;
        else break;
    }

    bool cond = true;
    for(register int i = 0; i < n; i++) 
        if(pointers[i] != n-1) cond=false;

    if(cond) {
        printf("%d\n", dia);
    }else {
        printf("-1\n");
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0,a,b;cin>>n;
  vector<P> red(n),blue(n); 
  rep(i,n) {cin>>a>>b;red[i]=P(b,a);}
  rep(i,n) {cin>>a>>b;blue[i]=P(a,b);}
  sort(RALL(red));sort(ALL(blue));
  rep(i,n) {
    a=blue[i].first,b=blue[i].second;
    ll pos=0;
    while(pos<red.size()) {
      if(red[pos].second>=a) {pos++;continue;}
      if(red[pos].first>=b) {pos++;continue;}
      ans++;red.erase(red.begin()+pos);break;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
    char a[105][105];
    int H,W;
    while (scanf("%d %d",&H,&W)==2)
    {
        for (int i=1;i<=H;i++)
        {
            getchar();
            for (int j=1;j<=W;j++)
                scanf("%c",&a[i][j]);
        }
      //  getchar();
        for (int i=0;i<=H+1;i++)
        {
            for (int j=0;j<=W+1;j++)
            {
                if (i==0||j==0||i==H+1||j==W+1)printf("#");
                else printf("%c",a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin >> H >> N;
  int A[N];
  int sum=0;
  for (int i=0;i<N;i++){
    cin >> A[i];
    sum+=A[i];
  }
  if(sum>=H) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
	Scanner scan=new Scanner(System.in);
	int n;
	n=scan.nextInt();
	int s,t;
	s=n%10;
	n/=10;
	n/=10;
	t=n;
	if(s==t)System.out.println("Yes\n");
	else System.out.println("No\n");
}
}


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

void countingSort(int *a,int *b,int n,int k){
  int i,j;
  int c[k+1];
  for(i=0;i<=k;i++)c[i]=0;
  for(j=1;j<=n;j++)c[a[j]]++;
  for(i=1;i<=k;i++)c[i]=c[i]+c[i-1];
  for(j=n;j>=1;j--){
    b[c[a[j]]]=a[j];
    c[a[j]]--;
  }
}

int main(){
  int i,n,max=0;
  int *ar1,*ar2,*a,*b;
  
  scanf("%d",&n);
  ar1=(int *)malloc(n*sizeof(int)+1);
  ar2=(int *)malloc(n*sizeof(int)+1);
  a=ar1;
  b=ar2;

  for(i=1;i<n+1;i++){
    scanf("%d",a+i);
    if(*(a+i)>max)max=*(a+i);
  }
  countingSort(a,b,n,max);

  for(i=1;i<n;i++)printf("%d ",*(b+i));
  printf("%d\n",*(b+i));
  free(ar1);
  free(ar2);
  return 0;
}

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

long long int KnapSack(long long int w[] ,long long int v[],long long int W ,long long int n)
{
    long long int KS[n+1][W+1], i , j;
    for(i=0 ; i <=W ; i++)KS[0][i]=0;
    for(i=0 ; i <=n ; i++)KS[i][0]=0;

    for( i = 1 ; i <= n ; i++)
    {
        for( j = 1 ; j<=W ; j++)
        {
            if(j<w[i])
            {
                KS[i][j]=KS[i-1][j];
            }
            else
            {
                KS[i][j]=max(v[i]+KS[i-1][j-w[i]] , KS[i-1][j]);
            }
        }
    }
    return KS[n][W];

}

int main()
{
    long long int n , W , i;
    cin>>n>>W;
    long long int w[n+1] , v[n+1];
    for( i = 1 ; i < n+1 ; i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<KnapSack(w,v,W,n)<<endl;
}

Measured memory_bytes: 79104
#include <iostream>

using namespace std;

int main()
{
    int A,B,C,D,E,F,G,H,S,T;
    cin >> A >> B >> C >> D >> E >> F >> G >> H;
    S=A+B+C+D;
    T=E+F+G+H;
    cout << (S>T?S:T) << endl;
    return 0;
}

Measured memory_bytes: 3096
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, x;
    cin >> n >> x;
    int ans = 1, cur = 0;
    for(int i = 1; i <= n; i++){
        int p;  cin >> p;
        cur += p;
        if(cur <= x)    ans++;
    }   
    cout << ans;
    return 0;
}

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

int main() {

  int H,W;
  cin >> H >> W;

  vector<vector<int>> c(10,vector<int>(10)),A(H+1,vector<int>(W+1));

  for(int i = 0;i < 10;i++) {
    for(int j = 0;j < 10;j++) {
      cin >> c.at(i).at(j);
    }
  }

  
  for(int i = 1;i <= H;i++) {
    for(int j = 1;j <= W;j++) {
      cin >> A.at(i).at(j);
    }
  }

  int d[10],seen[10],D[10];

  D[1] = 0;

  for(int k = 0;k < 10;k++) {
    priority_queue<pair<int,int>> PQ;

    for(int i = 0;i < 10;i++) {
      d[i] = 100000000;
      seen[i] = 0;
    }

    PQ.push(make_pair(0,k));
    d[k] = 0;

    while(!PQ.empty()) {

      int u;
      pair<int,int> p = PQ.top();
      PQ.pop();
      u = p.second;

      seen[u] = 1;
      if(d[u] < p.first * (-1)) continue;

      if(seen[1]) {
        D[k] = d[1];
        break;
      }

      for(int i = 0;i < 10;i++) {
        if(!seen[i] && d[i] > d[u] + c.at(u).at(i))   {
          d[i] = d[u] + c.at(u).at(i);
          PQ.push(make_pair(d[i]*(-1),i));
        }
      }
    }
  }

  int ans = 0;
  for(int i = 1;i <= H;i++) {
    for(int j = 1;j <= W;j++) {
      if(A.at(i).at(j) != -1) ans += D[A.at(i).at(j)];
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll cd = C * D / __gcd( C, D );
	ll by_c = B / C - ( A - 1 ) / C;
	ll by_d = B / D - ( A - 1 ) / D;
	ll by_c_d = B / cd - ( A - 1 ) / cd;
	cout << ( B - ( A - 1 )) - by_c - by_d + by_c_d << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define min(a,b) (((a)<(b))?(a):(b))

int main(void){
    int i,num[3];
    scanf("%d %d %d",&num[0],&num[1],&num[2]);
    printf("%d",min(num[0]+num[1],min(num[1]+num[2],num[2]+num[0])));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    ll n,m,d;
    cin >> n >> m >> d;


    double ans = 0;

    double kumi = (n-d)*2;
    if(d==0)kumi/=2;

    ans = (kumi/(double)(n*n))*(double)(m-1);
    
    cout << fixed << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy
n, m = map(int, input().split())
x  = list(map(int, input().split()))

sub = []
x.sort()
for i in range(m-1):
    sub.append(abs(x[i]-x[i+1]))

sub.sort(reverse=True)
if n >= m:
    print(0)
    quit()
for i in range(n-1):
    sub[i] = 0
print(sum(sub))

Measured memory_bytes: 82340
//
//  code.cpp
//  Cpp
//
//  Created by Yash Jain on 25/02/20.
//  Copyright © 2020 Yash Jain. All rights reserved.
//

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int degree[200001];
long long fact[200001];

long long powermod(long long a,long long b){
    if(b == 0)
        return 1;
    if(b%2 == 1)
        return (a*(powermod((a*a)%mod,b/2)))%mod;
    return powermod((a*a)%mod, b/2);
}

long long ncr(long long a,long long b){
    long long temp = (fact[a]*powermod(fact[b],mod-2))%mod;
    temp = (temp*powermod(fact[a-b],mod-2))%mod;
    return temp;
}

int main(){
    
    string s;
    cin>>s;
    
    if(s[2] == s[3] && s[4] == s[5]){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	last_match := -1
	for i := 0; i <= len(s)-len(t); i++ {
		for j := 0; j < len(t); j++ {
			if s[i+j] != t[j] && s[i+j] != '?' {
				break
			}
			if j == len(t)-1 {
				last_match = i
			}
		}
	}

	if last_match == -1 {
		fmt.Println("UNRESTORABLE")
	} else {
		ans := ""
		for i := range s {
			if s[i] != '?' {
				ans += string(s[i])
			} else if last_match <= i && i < last_match+len(t) {
				ans += string(t[i-last_match])
			} else {
				ans += "a"
			}
		}
		fmt.Println(ans)
	}
}


Measured memory_bytes: 512
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double degree = scanner.nextDouble();
 
        double S = 0.5*a*b*Math.sin(Math.PI*degree/180.0);
        double c = Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.PI*degree/180.0));
 
        System.out.printf("%.10f\n",S);
        System.out.printf("%.10f\n", a+b+c);
        System.out.printf("%.10f\n", 2*S/a);
    }
}


Measured memory_bytes: 28240
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define int long long
using namespace std;

void Solve(){
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < 3; i++){
    cnt += (s[i] == t[i]);
  }
  cout << cnt;
}

signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  Solve();
  
  return 0;
}
/*



*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(b < c || d < a) cout << 0 << endl;
    else{
        if(a < c){
            if(d < b) cout << d-c << endl;
            else cout << b-c << endl;
        }
        else{
            if(b < d) cout << b-a << endl;
            else cout << d-a << endl;
        }
    }
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100007
#define ll long long int
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(int x){writ(x);putchar('\n');}

int main()
{
	int a=read(),b=read();
	write(a-1+(b>=a));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  vector<int> v;
  rep(i,4){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  if(v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
yn=0
if a.count(0)!=0:
    print(0)
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            yn=1
            break
    if yn==1:
        print(-1)
    else:
        print(ans)


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

int main() {
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

long long S;

int main() {
	cin>>S;
	long long T=sqrt(S);
	if(T*T!=S) T++;
	int x1=T, y2=T;
	int x2=((LL)x1*y2==S) ? 0 : 1;
	int y1=((LL)x1*y2==S) ? 0 : ((LL)x1*y2-S);
	cout<<0<<' '<<0<<' '<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<'\n';
}

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

vector<int> res;

vector<int> dfs(vector<int> b){

    vector<int> stack;
    rep(i, b.size()){
        if(i+1 == b[i]) stack.push_back(i);
    }

    if(b.size()==1 && stack.size()==1){
        res.push_back(b[0]);
        return res;
    }

    while(!stack.empty()){
        int pop_idx = stack.back();
        int pop_value;
        stack.pop_back();

        vector<int> nxt;
        rep(i, b.size()){
            if(i == pop_idx) pop_value = b[i];
            else nxt.push_back(b[i]);
        }

        bool ngflg = false;
        rep(i, nxt.size()){
            if(nxt[i] > i+1) ngflg = true;
        }
        if(ngflg) continue;

        res = dfs(nxt);
        
        if(res.size()>0){
            res.push_back(pop_value);
            return res;
        }
    }

    return vector<int> {};
}

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

    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];

    res = dfs(b);

    if(res.empty()) cout << -1 << endl;
    else rep(i, res.size()) cout << res[i] << endl;


    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n, m;
vector<int> adj[N];
map<int, int> in_edges;
int par[N];

void bfs(int root) {
    queue<int> Q;
    Q.push(root);
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int v : adj[u]) {
            in_edges[v]--;
            if(in_edges[v] == 0) {
                par[v] = u;
                Q.push(v);
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n>>m;
    int tot = n + m - 1;
    int root = -1;
    f(i, tot){
        int u, v;
        cin>>u>>v;
        u--, v--;
        adj[u].pb(v);
        in_edges[v]++;
    }
    f(i, n){
        if(in_edges.find(i) == in_edges.end()) {
            root = i;
            break;
        }
    }
    assert(root != -1);
    bfs(root);
    par[root] = -1;
    f(i, n) cout<<par[i] + 1<<'\n';
    return 0;
}

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c=LI()
  k=I()
  for _ in range(k):
    if a<b<c:
      return 'Yes'
    if a>=b:
      b*=2
    elif b>=c:
      c*=2

  if a<b<c:
    return 'Yes'
  return 'No'

# main()
print(main())


Measured memory_bytes: 10784
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=57;
ll mod;

int n=50;

ll pot[nax][nax];

ll wyn;

void ff()
{
	fflush(stdout);
}

int pyt(int a, int b, int x, int y)
{
	printf("? %d %d %d %d\n", a, x, b, y);
	ff();
	int v;
	scanf("%d", &v);
	return v;
}

int los(int a, int b)
{
	return (rand()%(b-a+1))+a;
}

void szuk(int a, int b, int x, int y, int w)
{
	if (!w)
		return;
	if (w==(b-a+1)*(y-x+1))
	{
		for (int i=a; i<=b; i++)
			for (int j=x; j<=y; j++)
				wyn+=pot[i][j];
		return;
	}
	if (x==y || (a!=b && (rand()&1)))
	{
		int s=(a+b)>>1;
		//~ int s=los(a, b-1);
		int p=pyt(a, s, x, y);
		szuk(a, s, x, y, p);
		szuk(s+1, b, x, y, w-p);
	}
	else
	{
		int s=(x+y)>>1;
		//~ int s=los(x, y-1);
		int p=pyt(a, b, x, s);
		szuk(a, b, x, s, p);
		szuk(a, b, s+1, y, w-p);
	}
}

int main()
{
	int szit;
	scanf("%d%d%d%lld", &szit, &szit, &szit, &mod);
	ll trz=1;
	for (int i=0; i<n; i++)
	{
		for (int j=0; j<n; j++)
		{
			pot[i][j]=trz;
			trz=(trz*2)%mod;
		}
	}
	szuk(0, n-1, 0, n-1, 250);
	printf("! %lld\n", wyn%mod);
	ff();
	return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<Pi> AB(N);
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        AB[i] = mp(a,b);
    }

    sort(all(AB));
    ll ans = 0;
    ll now = 0;
    ll i = 0;
    while(1){
        if(now+AB[i].second >= M){
            ans += AB[i].first*(M-now);
            break;
        }else{
            ans+=AB[i].first*AB[i].second;
            now += AB[i].second;
        }
        i++;
    }
    
    cout << ans << endl;


    return 0;
    

}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    int K;
    cin >> K;
    ll sm = 0;
    REP(am,K) {
        REP(bm,K) {
            REP(cm,K) {
                auto a = am+1;
                auto b = bm+1;
                auto c = cm+1;
                sm += gcd(gcd(a,b),c);
            }
        }
    }
    cout << sm << endl;
}

int main() {
    solve();
    return 0;
}


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

int main() {
    string s;
    cin >> s;

    if (s.size() < 4) {
        cout << "No" << endl;
    }
    else {
    string y = "YAKI";
    bool ans = true;
    for (int i = 0; i < 4; i++) {
        if (s.at(i) != y.at(i)) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

template<typename T> class BIT {
    int n;
    vector<T> dat;
public:
    void init(int in) {
        n = in + 1;
        dat.clear();
        dat.resize(n + 1, 0);
    }
    T sum(int i) {
        T s = 0;
        while (i >= 0) {
            s += dat[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(int i, T x) {
        while (i <= n) {
            dat[i] += x;
            i |= i + 1;
        }
    }
};

int main() {
    ll n;
    cin >> n;
    VL a(n), sorted(n);
    FOR(i, 0, n) {
        cin >> a[i];
        sorted[i] = a[i];
    }
    SORT(sorted);
    int ok = 0, ng = n;
    BIT<ll> bit;

    ll border = ((n * (n + 1) / 2) + 1) / 2;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        int midnum = sorted[mid];
        bit.init(2 * n + 1);
        int sum = 0;
        bit.add(sum + n, 1);
        ll result = 0;
        FOR(i, 0, n) {
            sum += (a[i] >= midnum ? 1 : -1);
            result += bit.sum(sum + n);
            bit.add(sum + n, 1);
        }
        if (result >= border)ok = mid;
        else ng = mid;
    }
    cout << sorted[ok] << endl;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    map<ll, ll> mp;
    mp[0]++;
    ll res = 0;
    if(P == 2) {
        for(ll i = 0; i < N; i++) {
            if((int)(S[i] - '0') % 2 == 0) {
                res += i + 1;
            }
        }
    } else if(P == 5) {
        for(ll i = 0; i < N; i++) {
            if((int)(S[i] - '0') % 5 == 0) {
                res += i + 1;
            }
        }
    } else {
        ll num = 0;
        ll coef = 1;
        for(int i = N - 1; i >= 0; i--) {
            num += (ll)(S[i] - '0') * coef;
            num %= P;
            res += mp[num];
            mp[num]++;
            coef = (coef * 10) % P;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4168
open Batteries
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in

  let rec digits base n res =
    if n = 0 then res 
    else digits base (n/base) ((n mod base)::res)
  in

  Printf.printf "%d\n" @@
    List.fold_left (+) 0 (digits 10 n [])


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair <int, int> pii;


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (c-min(a-b,c));
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int s = int.Parse(input[0] + input[1]);
        double d = Math.Sqrt(s);
        
        if (d % 1 == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

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

int main() {
    std::string s;
    std::cin >> s;

    bool no = false;

    for ( int i = 0; i < s.length(); i++ ) {
        if ( ( i + 1 ) % 2 == 0 ) {
            if ( s.substr(i, 1) == "R" ) {
                no = true;
            }
        }
        else {
            if ( s.substr(i, 1) == "L") {
                no = true;
            }
        }
    }
    if ( no ) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N= int(input())
W=[]
f=0
s2=" "
for i in range(N):
    s=str(input())
    if s in W or (i >0 and s2[-1]!=s[0]):
        f=1
        break
    W.append(s)
    s2=s
if f==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDarumaOtoshi solver = new DDarumaOtoshi();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDarumaOtoshi {
        private static int n;
        private static int[] a;
        private static int[][] dp;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            n = in.nextInt();
            while (n != 0) {
                a = new int[n];
                dp = new int[n][n];
                for (int i = 0; i < n; i++) {
                    a[i] = in.nextInt();
                    Arrays.fill(dp[i], -1);
                }
                out.println(2 * calc(0, n - 1));

                //Arrays.stream(dp).map(Arrays::toString).forEach(System.out::println);

                n = in.nextInt();
            }
        }

        private static int calc(int i, int j) {
            if (i >= j || i < 0 || n <= j) return 0;
            if (dp[i][j] >= 0) return dp[i][j];
            int res = Math.max(calc(i + 1, j), calc(i, j - 1));

            for (int k = i + 1; k <= j; k++) {
                if (Math.abs(a[i] - a[k]) <= 1) {
                    res = Math.max(res, calcAll(i + 1, k - 1) + 1 + calc(k + 1, j));
                }
            }

            for (int k = i; k <= j - 1; k++) {
                if (Math.abs(a[k] - a[j]) <= 1) {
                    res = Math.max(res, calc(i, k - 1) + calcAll(k + 1, j - 1) + 1);
                }
            }
            return dp[i][j] = res;
        }

        private static int calcAll(int i, int j) {
            int count = Math.max(0, j - i + 1);
            int result = calc(i, j);
            if (result * 2 == count) {
                return result;
            } else {
                return -1;
            }
        }

    }
}




Measured memory_bytes: 61360