akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;

class Main {

	public static void main(String[] args) {
		final FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer>[] g = new List[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}

		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
		}

		Queue<Integer> q = new LinkedList<>();
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		ans[0] = 0;
		int count = 1;
		q.offer(0);
		while (!q.isEmpty()) {
			int v = q.poll();
			for (int next : g[v]) {
				if (ans[next] != -1) continue;
				ans[next] = v;
				count++;
				q.offer(next);
			}
		}

		if (count < n) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
		for (int i = 1; i < n; i++) {
			System.out.println(ans[i] + 1);
		}
	}

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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


Measured memory_bytes: 66760
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var VEr = Console.ReadLine().SplittedStringToInt32List();
        var v = VEr[0];
        var e = VEr[1];
        var r = VEr[2];
        var ls = new List<Edge>();
        for (int i = 0; i < e; i++)
        {
            var item = Console.ReadLine().SplittedStringToInt32List();
            var edge = new Edge() { Cost = item[2], From = item[0], To = item[1] };
            ls.Add(edge);
        }
        InitializeBellmanFord(v, e, ls);
        SearchShortestPath(r);
        for (int i = 0; i < v; i++)
        {
            var omomi = ShortestDistances[i];
            if (omomi == INF)
                Console.WriteLine("INF");
            else
                Console.WriteLine(omomi);
        }

        Console.ReadLine();
    }


    // s番目の頂点から各々の頂点への最短距離を求めるBellman-Ford

    public static void InitializeBellmanFord(int v,int e, IEnumerable<Edge> edges)
    {
        V = v;
        Edges = edges.ToArray();
        ShortestDistances = new int[V];
        E = e;
    }

    public class Edge
    {
        public int From;
        public int To;
        public int Cost;
    }

    public static Edge[] Edges;

    public static int[] ShortestDistances;

    public static int V;

    public static int E;

    public static void SearchShortestPath(int s)
    {
        for (int i = 0; i < V; i++)
        {
            ShortestDistances[i] = INF;
        }
        ShortestDistances[s] = 0;
        while (true)
        {
            var update = false;
            for (int i = 0; i < E; i++)
            {
                var e = Edges[i];
                if (ShortestDistances[e.From] != INF && ShortestDistances[e.To] > ShortestDistances[e.From] + e.Cost)
                {
                    ShortestDistances[e.To] = ShortestDistances[e.From] + e.Cost;
                    update = true;
                }
            }
            if (!update)
                break;
        }
    }


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}



Measured memory_bytes: 43912
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;cin>>n;
    int a[110];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=INF;
    for(int i=-100;i<=100;i++){
        int c=0;
        for(int j=0;j<n;j++){
            c+=(a[j]-i)*(a[j]-i);
        }
        ans=min(c,ans);
    }
    cout<<ans<<endl;
}


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

int main() 
{
int n;
long long int k;
cin>>n>>k;
vector<int>visit(n+1);
vector<int>arr(n+1);
for(int i=1;i<=n;i++)
{
      cin>>arr[i];    
}
int pos=1;
int len=0;
while(visit[pos]==0)
{     
          visit[pos]=1;
          pos=arr[pos];
          len++;
}
int pos1=arr[pos];
int cycle=1;
while(pos1!=pos)
{
          pos1=arr[pos1];
          cycle++;
}
 
int j;
if(k<=(len-cycle))
{
          j=k;
          pos=1;
}
else
{
          k=(k-(len-cycle));
          j=k%cycle;
}
 
while(j--)
{
          pos=arr[pos];
}
cout<<pos<<endl;
}

Measured memory_bytes: 4824
program main
  implicit none
  integer :: n, i, c, s, t, ch
  integer, allocatable :: cnt(:, :)
  read *, n, c
  allocate (cnt(c, 0:200000))
  cnt(:, :) = 0
  do i = 1, n
    read *, s, t, ch
    cnt(ch, 2 * s - 1) = cnt(ch, 2 * s - 1) + 1
    cnt(ch, 2 * t) = cnt(ch, 2 * t) - 1
  end do

  do i = 1, 200000
    cnt(:, i) = cnt(:, i) + cnt(:, i - 1)
  end do
  cnt(:, :) = min(cnt(:, :), 1)
  print "(i0)", maxval(sum(cnt, dim=1))
end program main


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

int main() {
  ll n; cin >> n;
  double a = (n/2+1.0)/n;
  if(n%2==0) cout << 0.5 << endl;
  else cout << a << endl;

  return 0;
}

Measured memory_bytes: 3784
from collections import deque
H, W = map(int, input().split())
index = ".#".index
S = [list(map(index, input())) for i in range(H)]

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

used = [[0]*W for i in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if used[i][j]:
            continue
        que = deque([(i, j)])
        used[i][j] = 1
        C = [0, 0]
        C[S[i][j]] += 1
        f = ((i + j) & 1) ^ S[i][j]
        while que:
            x, y = que.popleft()
            s = ((x + y) & 1) ^ 1
            for dx, dy in dd:
                nx = x + dx; ny = y + dy
                if not 0 <= nx < H or not 0 <= ny < W or used[nx][ny] or (s ^ S[nx][ny]) != f:
                    continue
                que.append((nx, ny))
                used[nx][ny] = 1
                C[S[nx][ny]] += 1
        ans += C[0] * C[1]
print(ans)

Measured memory_bytes: 48348
#include<stdio.h>
int main(){
  int a,A[100],n,i,count=0,arr=101,arr2,arr3;/*arrは最小の値、arr2は交換、arr3は最小の場所*/
  scanf("%d",&a);
  for(n=0;n<a;n++){
    scanf("%d",&A[n]);
  }
  for(i=0;i<a-1;i++){
    arr=A[i];
 for(n=i;n<a;n++){
   if(A[n]<arr){
     arr=A[n];
     arr3=n;
}
 }
   if(A[i]!=arr){
     arr2=A[i];
   A[i]=arr;
   A[arr3]=arr2;
   count++;
  }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double d = (60 * h + m) * 0.5 - 6 * m;

    double c = 0;
    c = sqrt(a*a + b*b - 2*a*b*cos(d * M_PI / 180));

    printf("%.10lf\n", c);
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N, K;
    string str;

    cin >> N >> K >> str;

    str[K-1] += 'a' - 'A';
    cout << str << endl;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char[] C = new char[4] { 'A', 'T', 'C', 'G' };
            int ans = 0;
            int cnt = 0;
            for(int i = 0; i < S.Length; i++)
            {
                if (C.Contains(S[i]))
                    cnt++;
                else
                    cnt = 0;
                ans = Math.Max(ans, cnt);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11348
//#include <boost/math/common_factor.hpp>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll lcm(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
ll x,y;
cin>>x>>y;
cout<<lcm(x,y);
return 0;
}


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

ll a,b,c,x,y;

int main(void){
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	ll ans=x*a+y*b;
	for(ll i=2;i<=max(x,y)*2;i+=2){
		ll now=c*i;
		if(x-i/2>=0)now+=(x-i/2)*a;
		if(y-i/2>=0)now+=(y-i/2)*b;
		ans=min(ans,now);
	}
	printf("%lld\n",ans);	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
     
int main() {
    int len; 
    cin >> len; 
    int arr[len] = {};
    int j, key;
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    for(int i = 1; i < len; i++) {
        for (int j = 0; j < len; j++) {
            cout << arr[j];
            if (j == len-1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
        key = arr[i];
        j = i-1; 
        while( j >= 0 && arr[j] > key) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;
    }
    for (int j = 0; j < len; j++) {
            cout << arr[j];
            if (j == len-1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum%10){
    cout<<sum<<endl;
    return 0;
  }
  vsort(a);
  ll ans=0;
  rep(i,n){
    if((sum-a[i])%10){
      ans=sum-a[i];
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
c = [False]*8
k = 0
ans = 0
for i in range(n):
  cn = a[i]//400
  if cn < 8:
    if c[cn] == False:
      ans += 1
      c[cn] = True
  else:
    k += 1
print(max(1, ans), ans + k)


Measured memory_bytes: 9072
// clang-format off
	#include <bits/stdc++.h>
	using namespace std; using ll = long long; using uint = unsigned int; using ull = unsigned long long;
	#define SFINAE(x, ...)	template <class, class = void> struct x : false_type {}; template <class T> struct x<T, void_t<__VA_ARGS__>> : true_type {};
	SFINAE(DefaultIO, decltype(cout << declval<T &>()))
	SFINAE(IsTuple, typename tuple_size<T>::type)
	SFINAE(Iterable, decltype(begin(declval<T>())))
	template <class T> constexpr char Space(const T &) { return (Iterable<T>::value or IsTuple<T>::value) ? '\n' : ' '; }
	template <auto &os> struct Writer {
		template <class T> void Impl(T const &t) const {
			if constexpr (DefaultIO<T>::value) os << t;
			else if constexpr (Iterable<T>::value) { int i = 0; for (auto &&x : t) ((i++) ? (os << Space(x), Impl(x)) : Impl(x)); }
			else if constexpr (IsTuple<T>::value) apply([this](auto const &... args) { int i = 0; (((i++) ? (os << ' ', Impl(args)) : Impl(args)), ...);}, t);
			else static_assert(IsTuple<T>::value, "No matching type for print");
		}
		template <class F, class... Ts> auto &operator()(F const &f, Ts const &... ts) const { return Impl(f), ((os << ' ', Impl(ts)), ...), os << '\n', *this; }
	};
	template <auto &is> struct Reader {
		template <class T> auto& Rd(T &t) const {
			if constexpr (DefaultIO<T>::value) is >> t;
			else if constexpr (Iterable<T>::value) for (auto &x : t) Rd(x);
			else if constexpr (IsTuple<T>::value) apply([this](auto &... args) { (Rd(args), ...); }, t);
			else static_assert(IsTuple<T>::value, "No matching type for read");
			return *this;
		}
		template <class T> auto operator[](T t) const { Rd(t); return t; }
		template <class... Ts> auto operator()(Ts... ts) const { (Rd(ts), ...); return tuple{move(ts)...}; }
	};
	#ifdef NARUT_LOCAL
	#define Debug(...) cerr << "\033[0;31m", Writer<cerr>{}(__VA_ARGS__), cerr << "\033[0m"
	#define ASSERT(...) if(not(__VA_ARGS__)) throw runtime_error("local assertion failed")
	#define LOCAL_ONLY(...) __VA_ARGS__
	#else
	#define Debug(...) 0
	#define ASSERT(...) 0
	#define LOCAL_ONLY(...) 0;
	#endif
	[[maybe_unused]] constexpr Reader<cin> Cin; [[maybe_unused]] constexpr Writer<cout> Cout;
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)
	#define let auto const

// clang-format on





auto Main() {
	let[h,w,m] = Cin(0u,0u,0u);
	let A = Cin[vector<pair<int, int> >  (m)]	;

	vector<uint> H(h+1), W(w+1);
	for(auto [i,j] : A) {
		H[i]++;
		W[j]++;
	}

	auto mxH = *max_element(begin(H), end(H));
	auto mxW = *max_element(begin(W), end(W));

	auto hc = count(begin(H), end(H), mxH);
	auto wc = count(begin(W), end(W), mxW);
	
	uint bad = 0;
	for(auto [i,j]: A){
		if(H[i]==mxH and W[j]==mxW) bad++;
	}
	
	if(bad == hc*wc) {
		cout << mxH+mxW-1;
	} else {
		cout << mxH+mxW;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 7928
/*input
3 1
ABC
*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	string s; cin>>n>>k>>s;
	s[k-1] = s[k-1] + 32;
	cout<<s;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int N,K;
int m[111111],ans;
vector<int>v;
int main(){
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>m[i];
    }
    int low = *min_element(m,m+N);
    for(int i=0;i<N;i++)
        if(m[i]==low)
            v.push_back(i);
    v.push_back(1e9);
    for(int i=0;i<N;){
        if(m[i]==low){
            i++;
        }
        else{
            // [i~K) low 가 있는가?
            if(*lower_bound(v.begin(),v.end(),i)<i+K)i++;
            i+=K-1;
            ans++;
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B;
  cin>>A>>B;
  char ans[100][100];
  for(int i=0;i<100;++i) {
    for(int j=0;j<100;++j) {
      if(i<50) ans[i][j] = '.';
      else ans[i][j] = '#';
    }
  }
  A--;
  B--;
  for(int i=1;i<49;++i) {
    if(B==0) break;
    if(i%2==0) continue;
    for(int j=1;j<99;++j) {
      if(B==0) break;
      if(ans[i-1][j]=='.' && ans[i][j-1]=='.') {
        ans[i][j] = '#';
        B--;
      }
    }
  }
  for(int i=51;i<100;++i) {
    if(A==0) break;
    if(i%2==0) continue;
    for(int j=1;j<99;++j) {
      if(A==0) break;
      if(ans[i-1][j]=='#' && ans[i][j-1]=='#') {
        ans[i][j] = '.';
        A--;
      }
    }
  }
  cout<<100<<" "<<100<<endl;
  for(int i=0;i<100;++i) {
    for(int j=0;j<100;++j) {
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-2;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m;
	double t,tt,ans = 0,tmp;
	cin >> n >> m;
	t = n * 100 + m * 1800;
	tt = 1.0 / (double)(1 << m);
	tmp = 1.0;
	for(int i = 1;i <= 1000;i++){
		ans += tmp * tt * i * t;
		tmp *= (1.0 - tt);
	}
	cout << (int)(ans + EPS) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(int argc, char *argv[]) {
	int q;
	cin>>q;
	while (q--){
		ll a,b,x,y,ans;
		cin>>a>>b;
		x=a*b;
		y=sqrt(x);
		if (y*(y+1)<x) 
			ans=y*2-1;
		else if (y*y==x){
			if (a==b)
				ans=(y-1)*2;
			else 
				ans=(y-1)*2-1;
		}
		else 
			ans=(y-1)*2;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
//////////////////////

int const N = 41;
int const M = 18;
int const MOD = 1e9 + 7;

int n, x, y, z;
int ans;

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int mul(int a, int b){
	return (ll) a * b % MOD;
}

bool bit(int m, int i){
	return (m & (1 << i));
}

void removeleast(int &m){
	fi(1, 11){
		if(bit(m, i)){
			m >>= i;
			return;
		}
	}
}

int getnewmask(int m, int o){
	fdi(M, 0){
		if(bit(m, i)){
			m |= (1 << (o + i));
			break;
		}
	}	
	//cerr << m <<  " " << o << endl;
	while(m >= (1 << M)){
		removeleast(m);
		//cerr << "getnewmask " << m << endl;
	}
	return m;
}

int hm[(1<<M)];

bool have(int m){
	if(hm[m] != -1) return hm[m];
	vector<int> v;
	fi(0, M){
		if(bit(m, i)) v.pb(i);
	}
	fdi(sz(v), 1) v[i] -= v[i-1];
	fi(0, sz(v)){
		int sx = x, sy = y, sz = z;
		fj(i, sz(v)){
			if(sx > 0){
				sx -= v[j];
			}else if(sy > 0){
				sy -= v[j];
			}else if(sz > 0){
				sz -= v[j];
			}
		}
		if(sx == sy && sy == sz && sz == 0) return hm[m] = 1;
	}
	return hm[m] = 0;
}

int d[N][(1 << M)];

void solve(){
	memset(hm, 255, sizeof(hm));
	int ten[4141];
	ten[0] = 1;
	fi(1, 4141) ten[i] = mul(10, ten[i-1]);

	d[0][1] = 1;
	fi(0, n){
		cerr << i << endl;
		/*int cur = (i&1);
		int nxt = (1 ^ cur);*/
		int cur = i;
		int nxt = i + 1;
		//memset(d[nxt], 0, sizeof(d[nxt]));
		fj(0, (1<<M)){ 
			if(d[cur][j]){
				fo(1, 11){
					//cerr << i << " " << j << " " << o << endl;
					int nj = getnewmask(j, o);
					if(have(nj)){
						add(ans, mul(ten[n-1-i], d[cur][j]));
					}else{
						add(d[nxt][nj], d[cur][j]);
					}
				}
			}
		}
	}
}

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

	scanf("%d %d %d %d",&n,&x,&y,&z);

	solve();

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

	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  int p[n];
  int count = 0;
  for(int i = 0; i < n; i++) cin >> p[i];

  for(int i = 1; i < n - 1; i++){
   if(p[i - 1] < p[i + 1]){
     if(p[i] > p[i - 1] && p[i] < p[i + 1]) count++;
   }
   if(p[i - 1] > p[i + 1]){
     if(p[i] < p[i - 1] && p[i] > p[i + 1]) count++;
   }
  }

  cout << count;
  return 0;
}






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

int main()
{
    int n;
    cin >> n;
    
    const int N = 1e5+5;
    int a[N];
    
    for(int i = 1;i <= n; i++)
    {
        cin >> a[i];
    }
    
    int res = 0;
    
    for(int i = 1;i <= n;i++)
    {
        if(a[i] == i)
        {
            swap(a[i],a[i+1]);
            res++;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 640
import collections

N = int(input())
S = ['']*N

for i in range(N):
    S[i] = input()

s = collections.Counter(S)

max_num = max(s.values())

ans = []

for k, v in s.items():
    if v == max_num:
        ans.append(k)

ans.sort()

print('\n'.join(ans))

Measured memory_bytes: 35928
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		BigInteger MAX = new BigInteger("1000000000000000000");
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		BigInteger[] s = new BigInteger[n];
		BigInteger ans = BigInteger.ONE;
		for (int i = 0; i < n; i++) {
			s[i] = sc.nextBigInteger();
			if (s[i].compareTo(BigInteger.ZERO) == 0) {
				System.out.println(0);
				System.exit(0);
			}
		}

		for (int i = 0; i < n; i++) {
			ans = ans.multiply(s[i]);
			if (ans.compareTo(MAX) == 1) {
				System.out.println(-1);
				System.exit(0);
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 66816
n = gets.chomp.to_i
ary = gets.chomp.split().map(&:to_i)

idx = 0
diff_ary = []
(ary.size - 1).times do |i|
  if ary[i+1] - ary[i] != 0
    diff_ary << [ary[i+1] - ary[i],idx]
    idx += 1
  end
end

if diff_ary.any?{|diff| diff.first < -1}
  puts "No"
else
  # 最初のifで-2以下のdiffは無くなっている。
  m_a = minus_diff_ary_idx = diff_ary.select{|diff| diff.first == -1}.map(&:last)
  if (m_a.size-1).times.any? do |m_idx|
      m_a[m_idx+1] - m_a[m_idx] == 1
    end
    puts "No"
  else
    puts "Yes"
  end
end

Measured memory_bytes: 14476
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
int a[(ll)1e4+1];
int f(int x)
{
	if(x==a[x])
		return x;
	return a[x]=f(a[x]);
}
signed main(void)
{ios
	
	int n,q;
	cin>>n>>q;
	rep(i,0,n+1)
	a[i]=i;
	while(q--)
	{
		int c,x,y;
		cin>>c>>x>>y;
		if(c)
		{
			if(f(x)==f(y))
				cout<<1<<endl;
			else
				cout<<0<<endl;
		}
		else
		{
			a[f(x)]=f(y);
		}
	}
}


Measured memory_bytes: 3252
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	int n;
	cin >> n;
	vector<ll> l(100);
	l[0] = 2;
	l[1] = 1;
	REP(i,2,n+1) {
		l[i] = l[i - 1] + l[i - 2];
	}

	cout << l[n] << endl;
}






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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL x, y;

int dp[55][55];

int f(int i, int j) {
	
	if(dp[i][j] != 0) { return dp[i][j]; }
	inc1(ii, i / 2) {
		if( f(i - ii * 2 , j + ii) == -1 ) { dp[i][j] = 1; return dp[i][j]; }
	}
	inc1(jj, j / 2) {
		if( f(i + jj , j - jj * 2) == -1 ) { dp[i][j] = 1; return dp[i][j]; }
	}
	
	dp[i][j] = -1;
	return dp[i][j];
}

int main() {
	cin >> x >> y;
	
	cout << (abs(x-y) < 2 ? "Brown" : "Alice") << endl;
	
	/*
	dp[0][0] = -1;
	inc(i, 55) {
	inc(j, 55) {
		f(i, j);
	}
	}
	
	inc(i, 55) {
	inc(j, 55) {
		printf("%c", (dp[i][j] == 1 ? '+' : '.'));
	} cout << endl;
	}
	*/
	
	return 0;
}


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

if N == 1:
	print(1)
elif N < 4:
	print(2)
elif N < 8:
	print(4)
elif N < 16:
	print(8)
elif N < 32:
	print(16)	
elif N < 64:
	print(32)
else:
	print(64)

Measured memory_bytes: 3060
#include <cstdio>
//#define int unsigned long long
#include <math.h>
#include <vector>

long MAX;
std::vector<bool> sosuu;

//?????°?????°?????¢??°
void erase(long foo)
{
   
 //   static int a=1;
  //  a++;
    //printf("%llu ", foo);
 //   if (a == 10) { a = 0; printf("\n"); }
    
    //?´???°???????????????????????????
    for (long i = foo*foo; i < MAX; i+=foo*2)
    {
        sosuu[i] = false;
    }
}

signed main()
{
    long  n;
    scanf("%ld",&n);
    printf("%ld:",n);
    
    MAX = sqrt(static_cast<signed>(n));
    //MAX = n;
    //  printf("%llu",MAX);
    
    
    sosuu.reserve(MAX);
    //?????????true??§?????????
    for (long i = 3; i < MAX; i+=2)
    {
//        if (i % 2)sosuu[i] = true;
//        else	  sosuu[i] = false;
        sosuu[i] = true;
    }
    sosuu[2]=true;
    
    while(n%2==0)
    {
        printf(" %ld",2);
        n=n/2;
    }
    //MAX?????§?????????????????????
    for (long p = 3; p < MAX; p+=2)
    {
        if (sosuu[p])
        {
            while(n%p==0)
            {
                printf(" %ld",p);
                n=n/p;
            }
            erase(p);
        }
    }
    if(n!=1){printf(" %llu",n);}
    printf("\n");
}

/*
#include <cstdio>
#include <math.h>
#include <set>
//#include <vector>
#define ulln unsigned int
ulln MAX;
//std::vector<bool> sosuu[1000000000];
std::set<unsigned int> sosuu;
int n;



//?????°?????°?????¢??°
void eraser(ulln foo)
{
//    static int a=1;
//    a++;
//    printf("%llu ", foo);
//    if (a == 10) { a = 0; printf("\n"); }
    for (ulln i = foo*foo; i <= MAX; i+=foo*2)
    {
        sosuu.insert(i);
    }
}

signed main()
{
    ulln n;
    scanf("%u",&n);
    printf("%u:",n);
    
    MAX=sqrt(n)+1;
    
    //?????????true??§?????????
/ *
    for (int i = 0; i <= MAX; i++)
    {
        if (i % 2)sosuu[i] = true;
        else	  sosuu[i] = false;
    }
* /
    sosuu.insert(2);
    
    while(n%2==0)
    {
        printf(" 2");
        n=n/2;
    }
    
    //MAX?????§?????????????????????
    for (ulln p = 3; p <= MAX; p+=2)
    {
//      auto f = sosuu.insert(p);
        if (sosuu.find(p)==sosuu.end())
        {
            while(n%p==0)
            {
                printf(" %u",p);
                n=n/p;
            }
            if(n==0){break;}
            eraser(p);
        }
        sosuu.erase(p);
    }
    printf("\n");
}

*/

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

int main(){
	int n;
	double s[1000], ave = 0, a = 0;
	while(cin >> n && n != 0){
		ave = 0, a = 0;
		for(int i = 0; i < n; i++){
			cin >> s[i];
			ave += s[i];
		}
		ave /= n;
		for(int i = 0; i < n; i++){
			a += pow(s[i]-ave, 2);
		}
		a /= n;
		cout << fixed << setprecision(5) << sqrt(a) << endl;
	}
	return 0;
}


Measured memory_bytes: 3240
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
	int n;
	cin >> n;
	ll a[n], b[n];
	rep(i, 0, n) cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	if(n & 1) cout << b[n/2] - a[n/2] + 1ll;
	else cout << b[n/2 - 1] + b[n/2] - a[n/2 - 1] - a[n/2] + 1ll;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 6736
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();
constexpr ll I_MAX = numeric_limits<int>::max();
constexpr ull UI_MAX = numeric_limits<unsigned int>::max();

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)


struct product {
	ll w;
	ll v;
};

void topological_sort(vector<vector<int>> &adjacency_list, vector<ll> &ans) {

}


int main() {

	int h, w;
	constexpr int modulo = 1000000007;
	cin >> h >> w;

	vector<bool> emptymap(w, true);
	vector<vector<bool>> map(h, emptymap);


	rep(i, 0, h) {
		rep(j, 0, w) {
			char temp;
			cin >> temp;
			if (temp == '.') {
				map[i][j] = true;
			}
			else {
				map[i][j] = false;
			}
		}
	}



	vector<ll> emptydp(w, 0);
	vector<vector<ll>> dp(h, emptydp);



	//initialize dp
	rep(i, 0, w) {
		if (map[0][i] == true) {
			dp[0][i] = 1;
		}
		else {
			break;
		}
	}
	rep(i, 0, h) {
		if (map[i][0] == true) {
			dp[i][0] = 1;
		}
		else {
			break;
		}
	}


	rep(i, 1, h) {
		rep(j, 1, w) {
			if (map[i - 1][j] == true) {
				dp[i][j] += dp[i - 1][j];
			}
			if (map[i][j - 1] == true) {
				dp[i][j] += dp[i][j - 1];
			}
			dp[i][j] = dp[i][j] % modulo;
		}
	}

	cout << dp[h - 1][w - 1] << endl;

	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
using namespace std;
int n, i, j;
int main() {
	cin>>n;
	for(i=11; n; i+=10) {
		for(j=2; j*j<=i; j++) if(i%j==0) break;
		if(j*j>i) cout<<i<<' ', n--;
	}
	return 0;
}

Measured memory_bytes: 256
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
int A[1000000], cnt[1000000], N;
signed main() {
  cin >> N;
  int mx1 = 0, mx2 = 0;
  for (int i = 0; i < 200001; i++) cnt[i] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cnt[A[i]]++;
    if (A[i] > mx1) {
      mx2 = mx1;
      mx1 = A[i];
    } else if (A[i] > mx2) {
      mx2 = A[i];
    }
  }

  for (int i = 0; i < N; i++) {
    if (A[i] == mx1 && cnt[A[i]] == 1) {
      cout << mx2 << endl;
    } else {
      cout << mx1 << endl;
    }
  }
}



Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        boolean flg = false;
        for(int i = 0; i < N; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == b){
                count++;
                if(count >= 3){
                    flg = true;
                    break;
                }
            }else{
                count = 0;
            } 
        } 
        if(flg == true){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}



Measured memory_bytes: 35948
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define pb push_back
using namespace std;
signed main()
{
    fastio;
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes";
    else cout<<"No";   
           
return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


// vector< ll > divisor(ll n) {
//   vector< ll > ret;
//   for(ll i = 1; i * i <= n; i++) {
//     if(n % i == 0) {
//       ret.push_back(i);
//       if(i * i != n) ret.push_back(n / i);
//     }
//   }
//   sort(begin(ret), end(ret));
//   return (ret);
// }

int main() {
    int k;
    cin >> k;

    ll sum = 0;

    // vvl tb(201);
    // rep(i, 1, 201) {
    //     tb[i] = divisor(i);
    // }

    rep(a, 1, k + 1) {
        rep(b, 1, k + 1) {
            rep(c, 1, k + 1) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3636
import sys
from math import gcd
from collections import defaultdict

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
mod = 10**9+7
plus = defaultdict(int)
minus = defaultdict(int)
flag = defaultdict(int)
A_zero,B_zero = 0,0
zero_zero = 0
for i in range(N):
    a,b = MI()
    if a == b == 0:
        zero_zero += 1
    elif a == 0:
        A_zero += 1
    elif b == 0:
        B_zero += 1
    else:
        if a < 0:
            a,b = -a,-b
        a,b = a//gcd(a,b),b//gcd(a,b)
        if b > 0:
            plus[(a,b)] += 1
        else:
            minus[(a,b)] += 1
            flag[(a,b)] = 1

ans = 1

for a,b in plus.keys():
    ans *= pow(2,plus[(a,b)],mod)+pow(2,minus[(b,-a)],mod)-1
    ans %= mod
    flag[(b,-a)] = 0

for key in minus.keys():
    if flag[key] == 1:
        ans *= pow(2,minus[key],mod)
        ans %= mod

ans *= pow(2,A_zero,mod)+pow(2,B_zero,mod)-1
ans %= mod

ans += zero_zero-1
ans %= mod

print(ans)


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

using ll = long long; 
using P = pair<int,int>;

int main() {

  ll x,K;
  cin >> x >> K;

  ll a = x % K;
  ll ans = min(a, K-a);

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Sep 13 18:35:58 JST 2020
 **/

signed main() {
    Int n, Q;
    std::cin >> n >> Q;
    atcoder::dsu uf(n);
    REP(q, Q) {
        Int t, u, v;
        std::cin >> t >> u >> v;
        if (t == 0) {
            uf.merge(u, v);
        } else {
            std::cout << uf.same(u, v) << "\n";
        }
    }
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define maxe              max_element
#define mine              min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl
#define see(x)            cout<<#x<<" = "<<x<<endl
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll n,k,q; cin>>n>>k>>q;
    ll v[n],a[q];
    get(a);
    for(ll i=0;i<n;i++) v[i]=k;
    //print(v);
    //print(a);
    for(ll i=0;i<q;i++)
    {
        v[a[i]-1]++;
    }
    for(ll i=0;i<n;i++) v[i]-=q;
    ll c=0;
    for(ll i=0;i<n;i++)
    {
        if(v[i]>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}




















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

int main(){
    int n;
    cin >> n;
    vector <long long> a(n);
    for (int i = 0; i < n; i ++){
        long long _a; cin >> _a;
        a.at(i) = _a;
    }

    for (int i = 1; i < n; i ++) a.at(i) += a.at(i - 1);
    long long sum_of_a = a.at(n - 1);

    long long ans = 100000000000000000;
    for (int i = 0; i < n - 1; i ++){
        ans = min(ans, abs((sum_of_a - a.at(i)) - a.at(i)));
    }

    cout << ans << endl;
}

Measured memory_bytes: 4752
#include <iostream>
#define MIN(a,b) ((a>b)?(b):(a))
using namespace std;

int main(void){
	int n,m;
	int p[20];
	int dp[50001];
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>p[i];
	for(int i=0;i<=n;i++)dp[i]=9999999;
	dp[0]=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<=n;j++){
			if(j-p[i]>=0)dp[j]=MIN(dp[j-p[i]]+1,dp[j]);
			else dp[j]=dp[j];
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

#define LL long long
#define NL '\n'
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define sd(x) scanf("%lf",&x)
#define ss(x) scanf("%s",x)
#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(i=j;i<=k;i++)
#define REV(i,j,k) for(i=j;i>=k;i--)
#define READ(f) freopen(f,"r",stdin)
#define WRITE(f) freopen(f,"w",stdout)
#define cnd tree[idx]
#define lnd tree[idx*2]
#define rnd tree[(idx*2)+1]
#define lndp (idx*2),(b),((b+e)/2)
#define rndp (idx*2+1),((b+e)/2+1),(e)
#define pi 2.0*acos(0.0)
#define MOD 1000000007
#define MAX 200005

int v[MAX]={0}, a[MAX];

int main()
{
    //READ("input.txt");
    //WRITE("out.txt");
    std::ios_base::sync_with_stdio(0);
    int cases, caseno=0, n, i, j, k, cnt, sum=0, sz=0;

    cin >> n >> j;

    FOR(i,1,n)
    {
        cin >> k;
        v[k]++;
    }

    FOR(i,1,n)
    {
        if(v[i])
            a[sz++] = v[i];
    }

    sort(a,a+sz);

    FOR(i,0,sz-1)
    {
        if(sz-i <= j) break;
        sum += a[i];
    }

    cout << sum;

    return 0;
}



Measured memory_bytes: 1792