akhauriyash/Code-Regression huggingface dataset:
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    int n = Integer.parseInt(br.readLine());
    long[][] dist = new long[n][n];
    long total = 0;
    for (int i=0; i<n; i++) {
      String[] s = br.readLine().split(" ");
      for (int j=0; j<n; j++) {
        dist[i][j] = Long.parseLong(s[j]);
        if (i<j)
          total += dist[i][j];
      }
    }
    
    boolean valid = true;
    for (int k=0; k<n; k++) {
      for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
          long midDist = dist[i][k]+dist[k][j];
          if (midDist<dist[i][j]) {
            valid = false;
            System.out.println("-1");
            return;
          }
        }
      }
    }

    long sub = 0;
    boolean[][] subbed = new boolean[n][n];
    for (int k=0; k<n; k++) {
      for (int i=0; i<n; i++) {
        if (i==k)
          continue;
        for (int j=0; j<i; j++) {
          if (j==k)
            continue;
          if (dist[i][k]+dist[k][j]==dist[i][j] && !subbed[i][j]) {
            subbed[i][j] = true;
            subbed[j][i] = true;
            sub += dist[i][j];
          }
        }
      }
    }
    System.out.println(total-sub);

    /*
    long sum = 0;
    Edge[] edges = new Edge[(n*(n-1)/2)];
    int index = 0;
    for (int i=0; i<n; i++) {
      for (int j=0; j<i; j++) {
        edges[index] = new Edge(i,j,dist[i][j]);
        index++;
      }
    }
    Arrays.sort(edges);
    long[][] dist2 = new long[n][n];
    for (int i=0; i<n; i++) {
      Arrays.fill(dist2[i],(Long.MAX_VALUE/2)-2);
    }
    for (int i=0; i<edges.length; i++) {
      Edge e = edges[i];
      int u = e.u;
      int v = e.v;
      long d = e.d;
      if (dist2[u][v]>dist[u][v]) {
        sum += d;
        dist2[u][v] = d;
        dist2[v][u] = d;
        for (int j=0; j<n; j++) {
          for (int k=0; k<j; k++) {
            long d1 = dist2[j][u]+d+dist2[v][k];
            long d2 = dist2[j][v]+d+dist2[u][k];
            if (d1<dist2[j][k]) {
              dist2[j][k] = d1;
              dist2[k][j] = d1;
            }
            if (d2<dist2[j][k]) {
              dist2[j][k] = d2;
              dist2[k][j] = d1;
            }
          }
        }
      }
    }
    */
  }
}
class Edge implements Comparable<Edge> {
  int u,v;
  long d;
  public Edge(int uu, int vv, long dd) {
    u = uu;
    v = vv;
    d = dd;
  }
  public int compareTo(Edge e2) {
    return (int)Math.signum(d-e2.d);
  }
}


Measured memory_bytes: 35112
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll a,b,n; cin >> a >> b >> n;
    ll x = min(b-1,n);
    ll ans = (a*x/b) - a * (x/b);
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main(){
	int i,n;
	double ave,a,s[1001];
	while (1){
		scanf("%d",&n);
		if (n==0) break;
		ave=0.0;
		for (i=0;i<n;i++){
			scanf("%lf",&s[i]);
			ave+=s[i];
		}
		ave/=n;
		a=0.0;
		for (i=0;i<n;i++){
			a+=pow(s[i]-ave,2);
		}
		printf("%.8f\n",sqrt(a/n));
	}
	return 0;
}





Measured memory_bytes: 2048
#include <iostream>
#include <vector>


int input()
{
	int val;
	std::cin >> val;
	return val;
}

int main()
{
	std::vector<int> x;

	while (true)
	{
		int val = input();
		if (val == 0)break;
		x.push_back(val);
	}

	for (int i = 0; i < x.size();++i)
		std::cout << "Case " << i+1 << ": " << x[i] << std::endl;

	return 0;
}

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

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
  dice() {
    id[TOP] = 1; id[FRONT] = 2; id[LEFT] = 3;
    id[RIGHT] = 4; id[BACK] = 5; id[BOTTOM] = 6;
  }
  dice(int top,int front,int right,int left,int back,int bottom) {
    id[TOP] = top; id[FRONT] = front; id[LEFT] = right;
    id[RIGHT] = left; id[BACK] = back; id[BOTTOM] = bottom;
  }
  int& operator[] (FACE f) { return id[f]; }
  const int& operator[] (FACE f) const { return id[f]; }
  bool operator==(const dice &b) const {
    const dice &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_x2() { roll(TOP, FRONT, BOTTOM, BACK); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_y2() { roll(TOP, RIGHT, BOTTOM, LEFT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  void roll_z2() { roll(FRONT, LEFT, BACK, RIGHT); }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  int id[6];
};

int main(){
	int d[6];
	for(int i=0;i<6;i++)cin>>d[i];
	dice di(d[0],d[1],d[2],d[3],d[4],d[5]);
	for(int i=0;i<6;i++)cin>>d[i];
	dice di2(d[0],d[1],d[2],d[3],d[4],d[5]);
	cout<<(di.equivalent_to(di2) ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long long dp[2010][2010];
int s[2010];
int t[2010];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i=1;i<=n;i++)
		cin >> s[i];
	for (int i=1;i<=m;i++)
		cin >> t[i];
	for (int i=0;i<=n;i++)
		dp[i][0]=1;
	for (int j=0;j<=m;j++)
		dp[0][j]=1; 
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			dp[i][j]=dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1];
			if (s[i]==t[j]) dp[i][j]+=dp[i-1][j-1];
			dp[i][j]=(dp[i][j]+1000000007)%1000000007;
		}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 31744
import java.util.*;

public class Main {
	static Node[] ns;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		ns = new Node[N];
		for (int i = 0; i < N; i++)
			ns[i] = new Node(i);
		for (int i = 0; i < N - 1; i++) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			ns[s].add(ns[t]);
			ns[t].add(ns[s]);
		}
		dfs(ns[0], null);
		for (int i = 0; i < Q; i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			ns[p - 1].cnt += x;
		}
		sum(ns[0]);
		StringBuilder res = new StringBuilder();
		for (Node node: ns)
			res.append(" ").append(node.cnt);
		System.out.println(res.substring(1));
	}
	private static void sum(Node node)
	{
		if (node.p != null)
			node.cnt += node.p.cnt;
		for (Node c: node) {
			if (c != node.p) {
				sum(c);
			}
		}
	}
	private static void dfs(Node c, Node p)
	{
		c.p = p;
		for (Node cc: c)
			if (cc != p)
				dfs(cc, c);
	}
	static class Node extends ArrayList<Node>
	{
		Node p;
		int id;
		int cnt = 0;
		Node(int _id) {id = _id;}
	}
}


Measured memory_bytes: 209984
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int K;
    cin >> K;
    // (cost, mod K)
    priority_queue<PII, VPII, greater<PII>> pq;
    pq.push(MP(1, 1));
    VI vis(K, INF);
    while (!pq.empty()) {
        //DEBUG(pq.size())
        auto nowState = pq.top();
        pq.pop();
        if (vis[nowState.second] <= nowState.first) {
            continue;
        }
        vis[nowState.second] = nowState.first;
        pq.push(MP(nowState.first + 1, (nowState.second + 1) % K));
        if (nowState.second) {
            pq.push(MP(nowState.first, (nowState.second * 10) % K));
        }
    }
    cout << vis[0] << endl;
}


Measured memory_bytes: 1784
import java.util.Scanner;
class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n , m;
    n = sc.nextInt();
    m = sc.nextInt();
    int[] A = new int[m];
    int i = 0;
    for(i=0 ; i < m ; i++){
      A[i] = sc.nextInt();
    }
    for(i = 0; i < m; i++){
      n = n - A[i];
    }
    if(n < 0){
      System.out.println(-1);
    }else{
      System.out.println(n);
    }
  }
}


Measured memory_bytes: 46532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	string s;
	cin >> s;
	rep(i,(1 << 3)) {
		int x = s[0] - '0';
		rep(j,3) {
			if (i & (1 << j)) {
				x += s[j+1] - '0';
			} else {
				x -= s[j+1] - '0';
			}
		}
		if (x == 7) {
			char op[3];
			rep(j,3) {
				op[j] = ((i & (1 << j))? '+': '-'); 
			}
			rep(j,3) {
				printf("%c%c", s[j], op[j]);
			}
			printf("%c=7\n", s[3]);
			return;
		}
	}
}

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

Measured memory_bytes: 3676
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {

	const T inf = numeric_limits<T>::max(); // different from INF!!!
	vector<T> dist(V, inf);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) {
			if (dist[e.from] == inf) continue;
			dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
		}
	}

	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) { // finding negative loop
			if (dist[e.from] == inf) continue;
			if (dist[e.from] == -inf) dist[e.to] = -inf; // src is nloop -> dst is nloop
			if (dist[e.to] > dist[e.from] + e.cost) dist[e.to] = -inf; // chmin is possible -> nloop
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, P;
	cin >> N >> M >> P;

	int a, b, c;
	vector<Edge<lint>> edges(M);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = { a, b, P - c };
	}

	auto dist = Bellman_Ford(edges, N, 0);
	DMP(dist);
	
	lint ans = -dist.back();
	DMP(ans);
	if (ans == numeric_limits<lint>::max()) cout << "-1\n";
	else if (ans < 0) cout << "0\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <queue>
using namespace std;
typedef long long ll;
int N, M; priority_queue<pair<int, int>> q;
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 0, A; i < N; ++i) {
    scanf("%d", &A);
    q.push({A, 1});
  }
  for(int i = 0, B, C; i < M; ++i) {
    scanf("%d %d", &B, &C);
    q.push({C, B});
  }
  ll ans = 0;
  while(N > 0) {
    auto t = q.top(); q.pop();
    ans += 1LL*t.first*min(N, t.second);
    N -= t.second;
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define int long long
int r, d;
vector<int> x;

signed main() {
    cin >> r >> d;
    x.resize(11);
    cin >> x[0];
    for(int i = 1; i <= 10; i++) {
        x[i] = r*x[i-1] - d;
        cout << x[i] << endl;
    } 
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

int N;
VI cnt(100005, 0);
int main() {
    std::cin >> N;

    int a, b;
    REP(i, N) {
        std::cin >> a >> b;
        FOR(i, a, b+1) {
            ++cnt[i];
        }
    }

    int ans = 0;
    FOR(i, 2, 100002) {
        if(i-1 <= cnt[i]) {
            ans = i-1;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3108
# Author: cr4zjh0bp
# Created: Tue Feb 25 07:58:24 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

n = ni()
T = nin(n)

ans = T[0]
for i in range(n):
    ans = lcm(ans, T[i])

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MXX = 50 + 5;

ll dp[MXX][MXX][MXX * MXX];
int n, k, a[MXX];

ll solve(int i, int cnt, int sum)
{
    if(i == n)
    {
        if(cnt>0 && sum/cnt == k && sum % cnt == 0)
        {
            return 1;
        }
        else
        {
            return 0;
        }
    }
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    return dp[i][cnt][sum] = solve(i + 1, cnt, sum) + solve(i + 1, cnt + 1, sum + a[i]);
}
int main()
{
    cin>>n>>k;
    for(int i = 0; i<n; i++)cin>>a[i];
    memset(dp, -1, sizeof(dp));
    cout<<solve(0, 0, 0)<<endl;
    return 0;
}


Measured memory_bytes: 71680
using System;

class Program
{
    static void Main()
    {
        var line = Console.ReadLine();

        byte cnt = 0;
        var len = line.Length;
        var half = len / 2;
        len -= 1;

        for (byte i = 0; i < half; i++)
        {
            if (line[i] != line[len - i])
            {
                cnt++;
            }
        }

        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353  //1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   map<string,int>m;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       m[s]++;
   }
   int mx=0;
   for(auto it=m.begin();it!=m.end();it++)
   {
       mx=max(mx,(it->S));
   }
   vector<string>v;
   for(auto it=m.begin();it!=m.end();it++)
   {
       if(it->S == mx)
        v.pb(it->F);
   }
   sort(v.begin(),v.end());
   for(auto x:v)
    cout<<x<<endl;

}



Measured memory_bytes: 25712
n=int(input())
a=list(map(int,input().split()))

if n==2:
    print(abs(a[1]-a[0]))
else:
    asum=sum(a)
    xsum=0
    xmin=n*(10**9)+1
    for i in range(n-1):
        xsum=xsum+a[i]
        xmin=min(xmin,abs(asum-2*xsum))
    print(xmin)
        

Measured memory_bytes: 24944
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <time.h>
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> ipair;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(i=0;i<n;i++)
#define fu(i,a,n) for(i=a;i<=n;i++)
#define fd(i,n,a) for(i=n;i>=a;i--)
#define all(a)  a.begin(),a.end() 
#define gi(n) scanf("%d",&n)
#define gl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pl(n) printf("%lld",n);
#define pp printf(" ")
#define pn printf("\n")

int main() {
	ll a, b;
	gl(a);
	gl(b);
	ll c = 0;
	while(a <= b) {
		c++;
		a<<=1;
	}
	pl(c);
	pn;
	return 0;
}

Measured memory_bytes: 256
program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,b
    
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n,m,x
    allocate(a(m))
    read(*,*)a
    do i=1,m
        if(a(i)>x)then
            b=i
        exit
        end if
    end do
    if (b-1<m-b+1)then
        write(*,*)b-1
    else
        write(*,*)m-b+1
    endif

  
    
    stop
end program sample
  



Measured memory_bytes: 2796
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <deque>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 998244353;
const int INF = 1e15;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

signed main()
{
	fast();

	int n;
	cin >> n;

	int cnt = 0, ans = 0;
	for (int i = 1; i <= n; ++i) 
	{
		if (n % i == 0) 
			--ans;
		ans += n / i;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
 
public class Main {
 
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int N = scanner.nextInt();
            long [] A = new long[N];
            for (int i=0; i<N; i++)
                A[i] = scanner.nextLong();
            long [] B = new long[N];
            for (int i=0; i<N; i++)
                B[i] = scanner.nextLong();
            long Pos=0;
            long Neg=0;
            for (int i=0; i<N; i++){
                long s=A[i]-B[i];
                if (s < 0){
                    Neg +=s/2;
                } else {
                    Pos +=s;
                }
            }
            long Judge = Neg + Pos;
            if (Judge > 0) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            } 
      }
}

Measured memory_bytes: 43412
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int suma = 0, sumb = 0;
    rep(i, n) suma += a[i];
    rep(i, n) sumb += b[i];
    int t = sumb - suma;
    int cnta = 0, cntb = 0;
    rep(i, n)
    {
        if (a[i] < b[i])
            cnta += (b[i] - a[i] + 1) / 2;
        else
            cntb += a[i] - b[i];
    }
    bool f = cnta <= t && cntb <= t;
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import math
a,b,c = map(int,input().split())
rad = c*math.pi/180
m = 0.5*a*b*math.sin(rad)

print("{:.8f}".format(m))
print("{:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(rad))))
print("{:.8f}".format(2*m/a))


Measured memory_bytes: 5716
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


use std::collections::HashMap;
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }

    let mut map = HashMap::new();
    for i in &a {
        let h =map.entry(i).or_insert(0);
        *h += 1;
    }

    // println!("{:?}", map);

    // 
    let mut comb: HashMap<usize, (usize, usize)> = HashMap::new();
    for (&k, &v) in &map {
        if v == 1 {
            comb.insert(*k, (0, 0));
        } else {
            comb.insert(*k, (v*(v-1)/2, (v-1)*(v-2)/2));
        }
    }

    let ans: usize = comb.values().cloned().collect::<Vec<(usize, usize)>>().iter().map(|t| t.0).sum();
    for c in &a {
        println!("{}", ans - comb[c].0 + comb[c].1);
    }
}


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

int main() {
  long long a,b,k;
  cin >> a >> b >> k;
  if(a-k > 0){
    a = a - k;
  }else if(a - k == 0){
    a = 0;
  }else if(a - k < 0){
    b = b - (k - a);
    a = 0;
    if(b <= 0){
      b = 0;
    }
  }

  cout << a  << " "<< b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int m,d,c=0,prod,diff,diff1,k=22;
  scanf("%d%d",&m,&d);
  if(d>=22)
  {
    while(k<=d)
    {
      if((k%10)>=2)
      {
        diff=k%10;
        diff1=k/10;
        prod=diff*diff1;
        if(prod<=m)
        {
          c++;
        }
      }
      k++;
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]

cost = [0] * (N + 2)
for i in range(N+1):
  cost[i] += abs(A[i+1] - A[i])
  
sum_money = sum(cost)
  
skip = [0] * N
for j in range(N):
  skip[j] += abs(A[j+2] - A[j])
  
for k in range(N):
  print(sum_money - (cost[k] + cost[k+1]) + skip[k])

Measured memory_bytes: 20480
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
ll ask(ll u, ll v) {
    cout << "? " << u << " " << v << endl;
    ll ans; cin >> ans;
    if (ans == -1) {
        exit(EXIT_FAILURE);
    } else {
        return ans;
    }
}

// 処理内容
int main() {
    
    ll n, s, t;
    cin >> n >> s >> t;

    vector<ll> froms(n+1, LINF); froms[s] = 0;
    vector<ll> fromt(n+1, LINF); fromt[t] = 0;

    RANGE(i, 1, n) if (i != s) {
        froms[i] = ask(s, i);
    }
    RANGE(i, 1, n) if (i != t) {
        fromt[i] = ask(t, i);
    }

    ll pl = froms[t]; // the length of the shortest path
    vector<ll> cand;
    RANGE(i, 1, n) {
        if (froms[i] + fromt[i] == pl) {
            cand.push_back(i);
        }
    }
    sort(ALL_OF(cand), [&](ll i, ll j) -> bool {
        return froms[i] < froms[j];
    });

    vector<ll> ans;
    for (ll i = 0; cand[i] != t; ) {

        ans.push_back(cand[i]);

        for (ll j = i+1; j < cand.size(); j++) {
            ll x = ask(cand[i], cand[j]);
            if (x == froms[cand[j]] - froms[cand[i]]) {
                i = j;
                break;
            }
        }

    }

    ans.push_back(t);

    cout << "! ";
    REP(i, ans.size()) cout << ans[i] << " \n"[i == i_len-1];
    
}


Measured memory_bytes: 4688
MOD = 10 ** 9 + 7

S = input()
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1

for i, s in enumerate(S):
	if s == "?":
		for n in range(13):
			for m in range(10):
				mod = (n * 10 + m) % 13
				dp[i + 1][mod] += dp[i][n]
				dp[i + 1][mod] %= MOD
	else:
		m = int(s)
		for n in range(13):
			mod = (n * 10 + m) % 13
			dp[i + 1][mod] += dp[i][n]
			dp[i + 1][mod] %= MOD

#for l in dp:
#	print(l)

print(dp[-1][5])


Measured memory_bytes: 61916
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    N, M = map(int, input().split())
    result = 0
    if N > 1:
        result += combinations_count(N, 2)
    if M > 1:
        result += combinations_count(M, 2)
    print(result)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;


int main()
{

	
	int x;
	cin>>x;
	int y = x + x*x + x*x*x;
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
#define pi 3.141592653589793238
int main()
{
    double a, b, c, s, C;
	double S, L, h; 
	
	scanf("%lf%lf%lf", &a, &b, &C);
	c = sqrt(a*a + b*b - 2*a*b*cos(C*pi/180));
	L = a+b+c;
	s = L/2;
	S = sqrt(s*(s-a)*(s-b)*(s-c));
	h = 2*S/a;
	printf("%.8lf\n%.8lf\n%.8lf\n",S,L,h);
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<pair<int,int> >neigh[55];
bool tk[55];
void Traverse(int v,int forb)
{
	if(tk[v])return;
	tk[v]=true;
	for(int i=0;i<neigh[v].size();i++)
	{
		pair<int,int>u=neigh[v][i];
		if(u.second==forb)continue;
		Traverse(u.first,forb);
	}
}
bool Con(int forb)
{
	fill(tk,tk+55,false);
	Traverse(1,forb);
	for(int i=1;i<=n;i++)
	if(!tk[i])return false;
	return true;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		neigh[a].push_back(pair<int,int>(b,i));
		neigh[b].push_back(pair<int,int>(a,i));
	}
	int res=0;
	for(int i=0;i<m;i++)
	if(!Con(i))res++;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数


int main()
{
  string s ;
  cin >> s ;
  string t ;
  int w ;
  cin >> w ;
  int n = SZ(s) ;
  REP(i,n){
    if(i%w==0){
      t += s.at(i) ;
    }
  }
  
  cout << t <<endl ;


  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
using namespace std;
 
int main() {
  set<int> S;
  int N;
  cin>>N;
  for(int i = 0; i<N; i+=1) {
    int d;
    cin>>d;
    S.insert(d);
  }
  cout<<S.size()<<endl;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    string s;
	cin>>s;

	ll sum=0;
	Ff(i,0,s.size())
	{
		sum+=(s[i]-'0');
	}

	if(sum%9)
	cout<<"No";
	else
	cout<<"Yes";
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

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

Measured memory_bytes: 10788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int a;
        int b;

        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();

        int ans;
        if (a == 2) ans = b - 1;
        else {
            if (b % (a - 1) < 2) ans = b / (a - 1);
            else ans = (b / (a - 1)) + 1;
        }
        System.out.println(ans);
    }
}

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

int main() {
	int x,y;
	while (true){
	cin>>x>>y;
	if (x==0 && y==0){
		
	}else if (x<=y){
		cout<<x<<" "<<y<<endl;
	}else{
		cout<<y<<" "<<x<<endl;
	}if (x==0 && y==0) break;
	}
}

Measured memory_bytes: 3068
#include<stdio.h>
int main(void){
    char ch;
    char alpha[26]="abcdefghijklmnopqrstuvwxyz";
    int count[26]={0};
    while((ch=getchar())!='\n'){
        for(int i=0;i<26;i++){
            if(ch==alpha[i])count[i]++;

        }
    }
    int a=0;
    for(int i=0;i<26;i++){
        if(count[i]%2!=0) a++;
    }
    if(a!=0)printf("No");
    if(a==0)printf("Yes");

    printf("\n");
    return 0;
}

Measured memory_bytes: 1564
def ICH(n):
  x=(n-1)%5
  return x
while True:
  n = int(input())
  if n==0:
    break
  J=list(map(int, input().split()))
  i, num=0,31
  print(num)
  while num>1:
    num-=J[i]
    print(num)
    num=num-ICH(num)
    print(num)
    i+=1
    if i>=n:
      i=0
  print(0)


Measured memory_bytes: 5600
program ABC145_B
type xy
  real(16)::x,y
end type
integer N
type(xy),allocatable::town(:)
real(16) average
read*,N
allocate(town(N))
do i=1,N
    read*,town(i)%x,town(i)%y
end do
average=0
do i=1,N-1
    do j=i+1,N
        average=average+dist(town(i),town(j))
    end do
end do
average=average/real(N*(N-1)/2)
print"(f0.14)",average*(N-1)
contains
pure real(16) function dist(a,b)
    type(xy),intent(in)::a,b
    dist=sqrt((a%x-b%x)**2+(a%y-b%y)**2)
end function
end program

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}

int d[6][6]={
    {0,0,1,1,1,0},
    {0,0,0,1,1,1},
    {1,0,0,0,1,1},
    {1,1,0,0,0,1},
    {1,1,1,0,0,0},
    {0,1,1,1,0,0}};
void go(){
    ll int x=lin(),y=lin();
    cout<<(abs(x-y)<=1 ? "Brown":"Alice")<<endl;
        
}





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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	ll a,b,ta,tb;
	cin >> a >> b;
	ta = a,tb = b;
	map<ll,ll> mp;
	mp[1]++;
	for(ll i = 2; i*i <= max(ta,tb); i++){
		if(a%i == 0 && b%i == 0){
			while(a%i == 0) a /= i;
			while(b%i == 0) b /= i;
			mp[i]++;
		}	
		while(a%i == 0) a /= i;
		//while(b%i == 0) b /= i;
	}

	if(a < b) swap(a,b);
	if(a%b == 0) mp[b]++;

	cout << mp.size() << endl;
 	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	//
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	n, err := strconv.Atoi(numString[0])
	d, err := strconv.Atoi(numString[1])

	points := make([][]int, n)

	for i := 0; i < n; i++ {
		point := make([]int, d)
		sc.Scan()
		numString := strings.Split(sc.Text(), " ")
		for i := 0; i < d; i++ {
			point[i], err = strconv.Atoi(numString[i])
			if err != nil {
				panic(err)
			}
		}
		points[i] = point
	}

	var dist float64
	var sum int
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			dist = Distance(points[i], points[j])
			_, frac := math.Modf(dist)
			if frac == 0 {
				sum++
			}
		}
	}
	fmt.Println(sum)
}

// Distance calculate distance between two point
func Distance(a, b []int) float64 {
	var sum int
	for i := 0; i < len(a); i++ {
		sum += (a[i] - b[i]) * (a[i] - b[i])
	}
	return math.Sqrt(float64(sum))
}

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

int main() {
	int n;
	cin >> n;
	vector<string> w;
	string s;

	for (int i = 0; i < n; i++) {
		cin >> s;
		if (i != 0 && (count(w.begin(), w.end(), s) || s.front() != w.back().back())) {
			cout << "No" << endl;
			return 0;
		}
		w.push_back(s);
	}
	cout << "Yes" << endl;
}

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

bool f(pair<string,pair<int,int>> a,pair<string,pair<int,int>> b){
    return a.second.second<b.second.second;
}

int main(){

    int n;
    cin >> n;

    set<string> s;
    map<string,vector<pair<int,int>>> mp;

    rep(i,n){
        string t;
        int tt;
        cin >> t >> tt;
        s.insert(t);
        mp[t].push_back({tt,i+1});
    }

    for(auto it=s.begin();it!=s.end();it++){
        sort(mp[*it].begin(),mp[*it].end(),greater<pair<int,int>>());
        for(int i=0;i<mp[*it].size();i++){
            cout << mp[*it][i].second << endl;
        }
    }

    

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

  while(1){
    int m=0;
    scanf("%d %d",&n,&x);

    if(n==0&&x==0)break;

    for(i=1;i<=n-2;i++)
      for(j=2;j<=n-1;j++)
	for(k=3;k<=n;k++)
	  if(i!=j&&i!=k&&k!=j)
	    if(i<j&&j<k)
	      if(x==i+j+k)
		m++;

    printf("%d\n",m);

  }
  return 0;
}

Measured memory_bytes: 1028
fun main(arr:Array<String>) {
    println(if(isKuku(readLine()!!.toInt())) "Yes" else "No")
}

fun isKuku(num:Int):Boolean {
    for(i in (1..9)) {
        for(j in (1..9)) {
            if(i*j == num) {
                return true
            }
        }
    }
    return false
}

Measured memory_bytes: 31868
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tommy6073
 */

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

class CTraveling {
public:
    void solve(std::istream &in, std::ostream &out) {
        int N;
        in >> N;
        int t[N], x[N], y[N];
        for (int i = 0; i < N; ++i) {
            in >> t[i] >> x[i] >> y[i];
        }

        bool possible = true;
        int i = 0;
        while (possible && i < N) {
            int distance = 0;
            int time = 0;
            if (i == 0) {
                distance = (x[i] + y[i]);
                time = t[i];
            } else {
                distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
                time = t[i] - t[i - 1];
            }
            if (time >= distance) {
                if ((distance % 2 == 0) && (time % 2 != 0)) {
                    possible = false;
                } else if ((distance % 2 == 1) && (time % 2 != 1)) {
                    possible = false;
                }
            } else {
                possible = false;
            }
            ++i;
        }

        out << (possible ? "Yes" : "No");
    }
};


int main() {
	CTraveling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < K; i++){
        int a, b;
        cin >> a >> b;
        int t = min(a - 1, min(b - 1, min(N - a, N - b)));
        cout << t % 3 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import math
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
  x[i], y[i] = map(int, input().split())

Kai = math.factorial(N)
C = N * (N-1) // 2
pathcount = Kai * (N-1) // C
Ans = 0
dist = 0

for j in range(N):
  for k in range(N):
    if j < k:
      dist = dist + ((x[j] - x[k]) ** 2 + (y[j] - y[k]) ** 2)** 0.5

Ans = dist * pathcount / Kai
print(Ans)


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

int main(){
    int N;
    cin>>N;
    vector<long long > A(N);
    map<int,long long> cnt;
    for(int i=0; i<N; i++) cin>>A[i];
    for(int i=0; i<N; i++) cnt[A[i]]++;

    long long sum = 0;

    for(auto a : cnt){
        sum += (a.second)*(a.second-1)/2;
    }

    for(int i=0; i<N; i++){
        long long ans;
        ans = sum;
        ans -= cnt[A[i]]*(cnt[A[i]]-1)/2;
        ans += (cnt[A[i]]-1)*(cnt[A[i]]-2)/2;
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 11776
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a[5];
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);
	scanf("%d",&a[2]);
	scanf("%d",&a[3]);
	scanf("%d",&a[4]);

	int space=9;
	int temp;

	for (int i = 0; i < 5; ++i)
	{
		if (a[i]%10!=0)
		{
			if (a[i]%10<space)
			{
				space=a[i]%10;
				temp=i;
			}
		}

	}

	for (int i = 0; i < 5; ++i)
	{
		if (i!=temp)
		{
			if (a[i]%10!=0)
			{
				a[i]=((a[i]/10)+1)*10;
			}
		}
		//printf("a[%d] is %d\n",i,a[i] );
	}

	int total=0;
	for (int i = 0; i < 5; ++i)
	{
		total=total+a[i];
	}
	printf("%d\n",total);
	return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int[][] a = new int[m][2];
    for (int i = 0; i < m; i++) {
      a[i][0] = scanner.nextInt();
      a[i][1] = scanner.nextInt();
    }

    Arrays.sort(a, Comparator.comparingInt(o -> o[1]));

    int count = 0;
    for (int i = 0; i < m;) {
      count++;
      int right = a[i][1];
      i++;
      while (i < m && a[i][0] < right) {
        i++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 93404
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;


bool compare_by_b(pair<string,ll> a, pair<string,ll> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return b.second < a.second;
    }
}
ll n,r;
vl a,b,c;
int main(){
    cin>>n;
    rep(i,n){
        cin>>r; a.push_back(r);
    }
    SORT(a);
    rep(i,n) {
        cin>>r; b.push_back(r);
    }
    rep(i,n){
        cin>>r; c.push_back(r);
    }
    SORT(c);
    ll ans=0;
    rep(i,n) {
        ll search=b.at(i);
        ll top=lower_bound(all(a),search) - a.begin();
        ll botom=c.end()-upper_bound(all(c),search);
        ans+=top*botom;
    }
    cout<<ans<<endl;
};


Measured memory_bytes: 3316
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  n <- readLn :: IO Int
  k <- readLn :: IO Int
  (print .last .take (n+1) .iterate (f k)) 1
  
f k x | x*2<x+k = x*2 | otherwise = x+k

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

    // Your code here!
    int count(int n, int x){
        int cnt = 0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k == x)cnt++;
                }
            }
        }
        return cnt;
    }
    
    int main(){
    int n,x;
    
    while(1){
        cin >> n>> x;
        if(n==0 && x==0) break;
        cout << count(n, x) << endl;
    }
    
    return 0;
    }



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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;

  if (a >= b) cout << "delicious" << endl;
  else if (a < b && x >= b - a) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


Measured memory_bytes: 256