akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0339
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<long> l = new List<long>();
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Array.Sort(x);
                long a = x[0] * 10000 * 10000 + x[1] * 10000 + x[2];
                if (!l.Contains(a)) l.Add(a);
            }
            Console.WriteLine(n - l.Count());
        }
    }
}

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


int main()
{
    int x;
    cin >> x;
    cout << 10 - (x / 200) << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

int dig(int N) {//桁数
	int dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}

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

	double ans = 0;
	for (int x = 1; x <= N; x++) {
		if (x >= K) {
			ans += (1.0/N);
			continue;
		}
		ll i = ceil(log(K/x)/log(2));
		ans += pow(0.5, i) / N;
	}

	cout << setprecision(20) << ans << endl;
}



//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ

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

#define MAX_NODE 10000

using namespace std;

typedef struct{
	int from,to,weight;
} Edge;

typedef struct{
	int parent,rank;
} Node;

Node node[MAX_NODE];
vector<Edge> edge;

void init(int n){
	for(int i=0;i<n;i++){
		node[i].parent=i;
		node[i].rank=0;
	}
}

int find(int n){
	return node[n].parent==n?n:node[n].parent=find(node[n].parent);
}

void unite(int x,int y){
	int xr=find(x);
	int yr=find(y);
	if(node[xr].rank>node[yr].rank){
		node[yr].parent=node[xr].parent;
	}else if(xr!=yr){
		node[xr].parent=node[yr].parent;
		if(node[xr].rank==node[yr].rank){
			node[yr].rank++;
		}
	}
}

bool operator<(const Edge& left,const Edge& right){
	return (left.weight<right.weight?1:0);
}

int main(){
	int n,tmp,w=0;
	Edge e;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>tmp;
			if(tmp!=-1){
				e.from=i;
				e.to=j;
				e.weight=tmp;
				edge.push_back(e);
			}
		}
	}
	sort(edge.begin(),edge.end());
	init(n);
	for(int i=0;i<edge.size();i++){
		if(find(edge[i].from)==find(edge[i].to)){
			continue;
		}
		w+=edge[i].weight;
		unite(edge[i].from,edge[i].to);
	}
	cout<<w<<endl;
	return 0;
}

Measured memory_bytes: 1344
#define _USE_MATH_DEFINES
#include <iostream> 
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int a, b, c;
		cin >> a >> b >> c;
		if(a*a+b*b == c*c || a*a+c*c == b*b || b*b+c*c == a*a){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
int m,n;
int i,j,k,l;
int a[10000];
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int main(void){
    scanf("%d %d",&n,&m);
    k = n;
    for (size_t i = 0; i < m; i++)
    {
        scanf("%d",&a[i]);
        n -= a[i];
    }
    if (n < 0)
    {
        printf("-1\n");
    }else
    {
        printf("%d\n",n);
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1740
using System;

namespace agc029_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int count = 0; long ret = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'W')
                {
                    ret += i - count; count++;
                }
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11616
import math
import itertools
import statistics
n, m = list(map(int, input().split()))
"""
if n%2==0 and m%2==0:
    # 2 4   1 3 5 7
    print((n+m)*(n+m-1)/2)
elif n%2==0 and m%2!=0:
"""



print(int(n*(n-1)/2 + m*(m-1)/2))

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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;
  int ctr = 0;
  for(int i=1;i<s.length();i++)
    if(s[i] != s[i-1])
  ctr++;
  cout << ctr << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int a, b, c;

int main(){
	IOS
	cin >> a >> b >> c;
	for(int i=0;i<=b;i++){
		if(a*i%b==c){
			cout << "YES" << '\n';
			return 0;
		}
	}
	cout << "NO" << '\n';
}


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

//zaki_FenwickTree

template <typename T>

class FenwickTree
{
    int n;
    std::vector<T> bit;

  public:
    FenwickTree(int _n) : n(_n), bit(_n, 0) {}

    void add(int pos, const T &w)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            bit[i] += w;
    }
    // v[0] + ... + v[pos-1]
    T sum(int pos)
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    int com, x, y;
    FenwickTree<int> ft(1000000);
    REP(i, q){
        cin >> com >> x >> y;
        if(com) cout << ft.sum(x, y + 1) << endl;
        else ft.add(x, y);
    }
    return 0;
}


Measured memory_bytes: 6780
N,Y = map(int, input().split())
ans = [-1,-1,-1]
for x in range(N+1):
    for y in range(N+1):
        z = N - (x + y)
        if z >= 0 and Y - (10000*x + 5000*y + 1000*z) == 0:
            ans = [x,y,z]
            break
        
print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[200005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    cin>>v[i];
    for(ll i=n;i>=1;i--){
        ll cnt=0;
        for(ll j=2*i;j<=n;j+=i)
        if(arr[j]==1)
        cnt++;
        if(cnt%2==0&&v[i]==1)
        arr[i]=1;
        else if(cnt%2!=0&&v[i]==0)
        arr[i]=1;
    }
    v.clear();
    for(ll i=1;i<=n;i++)
    if(arr[i])
    v.push_back(i);
    cout<<v.size()<<endl;
    for(ll i=0;i<v.size();i++)
    cout<<v[i]<<" ";
}


Measured memory_bytes: 3968
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N;
	cin >> N;
	int times = N;
	for (int i = 0; i <= N; i++) {
		int cc = 0;
		int t = i;
		while (t > 0) { 
			cc += t % 6; t /= 6;
		}
		t = N - i;
		while (t > 0) {
			cc += t % 9; t /= 9;
		}
		if (times > cc) {
			times = cc;
		}
	}
	cout << times << endl;
}


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

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;

    ll ans;

    if ((B - A) % 2 == 0) {
        ans = (B - A) / 2;
    } else {
        if (B - 1 < N - A) {
            ans = ((A - 1) + (B - 1) + 1) / 2;
        } else {
            ans = ((N - A) + (N - B) + 1) / 2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#define ll long long int
using namespace std;
int main(){
	int w,s;
	cin>>w>>s;
	if(s>=w){
		cout<<"unsafe"<<endl;
	}
	else{
		cout<<"safe"<<endl;
	}
	}
	

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int64_t *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%lld", &arr[i]);
    }
    return 0;
}

// sort
int desc(const void *a1, const void *a2) {
    int64_t aa1 = *(int64_t*)a1;
    int64_t aa2 = *(int64_t*)a2;
    if(aa1 > aa2) return -1;
    if(aa1 == aa2) return 0;
    return 1;
}

#define NUM_MAX 50

static int64_t combi[NUM_MAX+1][NUM_MAX+1];
void init_combi(int num){
    int i, j;
    for(i=0; i<=num; i++) {
        for(j=0; j<=i; j++) {
            if(j == 0 || j == i) combi[i][j] = 1;
            else {
                combi[i][j] = (combi[i-1][j-1] + combi[i-1][j]);
            }
        }
    }
}

int main(void) {
    int num = get_int();
    int ulimit, llimit;
    get_int2(&llimit, &ulimit);
    static int64_t arr[NUM_MAX];
    fget_array(arr, num);
    init_combi(NUM_MAX);
    qsort(arr, num, sizeof(int64_t), desc);
    
    int i;
    double sum = 0;
    for(i = 0; i < llimit; i++) {
        int64_t cur = arr[i];
        sum += cur;
    }
    int64_t prev = arr[llimit-1];
    double ave = sum / llimit;

    int n = 0;
    int k = 0;
    for(i = 0; i < num; i++) {
        if(prev == arr[i]) {
            n++;
            if(i < llimit) k++;
        }
    }

    int64_t ans = 0;
    if(prev == arr[0]) {
        // [llimit-1, i) -> [llimit, i+1)
        for(i = llimit; i <= min(ulimit, n); i++) {
            ans += combi[n][i];
        }
    } else {
        ans = combi[n][k];
    }

    printf("%.8lf\n", ave);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
x, a = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
# a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
if x < a:
    print(0)
else:
    print(10)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

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



int main() {
	

	unsigned long long int a, b, c;
	unsigned long long int pre, md,n;
	pre = 0;
	n = 1;
	cin >> a >> b >> c;

	bool flag = true;



	while (flag) {

		md = a*n % b;
		if (md == c) {
			cout << "YES" << endl;
			return 0;
		}

		if (pre == md) {
			cout << "NO" << endl;
			return 0;
		}
		if (n > b) {
			cout << "NO" << endl;
			return 0;
		}
		pre = md;
		n++;
	}

		
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <complex>
#include <math.h>

using namespace std;
typedef complex<double> Point;

double cross(Point a, Point b) {
  return imag(conj(a) * b); 
}

int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    double x, y;
    scanf("%lf %lf", &x, &y);
    Point c1 = Point(x, y); 
    scanf("%lf %lf", &x, &y);
    Point c2 = Point(x, y); 
    scanf("%lf %lf", &x, &y);
    Point c3 = Point(x, y); 
    double S = abs(cross(c2 - c1, c3 - c1) / 2.0);
    double a = norm(c3 - c2);
    double b = norm(c1 - c3);
    double c = norm(c2 - c1);
    Point p = (a * (b + c - a) * c1 + b * (c + a - b) * c2 + c * (a + b - c) * c3) / (16.0 * S * S); 
    printf("%.3lf %.3lf %.3lf\n", p.real(), p.imag(), abs(p - c1));
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    int N = scan.nextInt();
    scan.nextLine();
    String s = scan.nextLine();
    String[] result = s.split("B");
    int count = 0;
    for (String ss : result) {
      count += ss.length();
    }
    System.out.println(count > N / 2 ? "Yes" : "No");
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main () {

  int n,a,b,max,min;
  scanf ("%d %d %d",&n,&a,&b);

   if (a>b) {
     max=b;
  }else {
     max=a;
   }
  if (a+b>n) {
    min=a+b-n ;
   }
   else {
    min=0 ;
   }
   printf ("%d %d\n",max,min);

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		long ans = 1;
		for (int i = a; i <= b; i++) {
			if (i == 0) {
				ans = 0;
				break;
			} else if (i > 0) {
				ans *= 1;
			} else {
				ans *= -1;
			}
		}
		if (ans > 0) {
			System.out.println("Positive");
		} else if (ans == 0) {
			System.out.println("Zero");
		} else {
			System.out.println("Negative");
		}
		in.close();
	}
}

Measured memory_bytes: 23508
void maxHeapify(int );
void buildmaxHeap();
int x;
int A[2000001];
int main(){

  int i;

  scanf("%d",&x);

  for(i=1;i<=x;i++)
    scanf("%d",&A[i]);

  buildmaxHeap();


  for(i=1;i<x+1;i++)
    printf(" %d",A[i]);

  printf("\n");

  return 0;
}
void maxHeapify(int i)
{
  int l=0,r=0,largest=0,w=0;

  l=i*2;
  r=i*2+1;

  if(l <= x && A[l] > A[i])
    largest = l;

  else largest = i;

  if(r <= x && A[r] > A[largest])
    largest = r;

  if(largest != i){
    w=A[i];
    A[i]=A[largest];
    A[largest]=w;
    maxHeapify(largest);
  }
}
void buildmaxHeap()
{
  int i;
  for(i=(x/2);i>=1;i--)
    maxHeapify(i);
}

Measured memory_bytes: 2552
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <functional>
#include <array>
#include <climits>
//#include "debug.h"
using namespace std;
 
#define A first
#define B second
 
typedef long long ll;
constexpr int MOD = 1e9 + 7;

void solve() {
  int N;
  cin >> N;
  ll ans = 0;
  for(int i = 1; i < N; i++){
    ans += (N - 1) / i;
  }
  cout << ans;
}
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  //cin >> T;
  while(T--){
    solve();
  }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = 1;
            int i = 0;
            int[] a = new int[1000];
            int A__score = 0;
            int B_score = 0;
            int add = 0;
            int comp = 0;
            N=int.Parse(Console.ReadLine());
            string s = "";
            
            s = Console.ReadLine();

            string[] s2 = new string[1000];
            s2=s.Split(' ');
            //a =int.Parse(s.Split(' '));
            for (int j=0; j<N;j++) {
                a[j] = int.Parse(s2[j]);

            }

          //  for (int j=0; j<N;j++) {

            //    a[j]=int.Parse(Console.ReadLine());
             
          // }
            
           // int sum = 0;
            //sum=Console.Read();
            //Console.WriteLine(sum);
            for (int j=0; j<N;j++) {
                comp = 0;
                for (int k = 0; k < a.Length; k++)
                {
                    add =Math.Max(comp,a[k]);
                    comp = add;
                }

                for (int k = 0; k < a.Length; k++)
                {
                    if (add==a[k]) {
                        a[k] = -1;
                        break;
                    }
                }


                if (j%2==0) {//2の倍数はアリスの晩
                   

                    A__score += add;
                  //  Console.WriteLine("現在A::"+A__score);
                }
                else {

                    B_score += add;
                  //  Console.WriteLine("現在B::" + B_score);

                }

            }

            Console.WriteLine(A__score-B_score);
            
           
        }
    }
}


Measured memory_bytes: 13124
#include<bits/stdc++.h>
#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using namespace std;
signed main(){
  int a;
  cin>>a;
  int b;
  b=a/500;
  int c;
  c=a%500/5;
  cout<<b*1000+c*5;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef int mat[3][3];
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int M=1e5+5,mo=1e9+7;
int n,m;
mat C,A={{1,2,1},{0,1,1},{1,2,2}},B={{1,2,1},{0,1,1},{0,0,1}};
void mul(mat &c,mat a,mat b)
{
	static mat p;mset(p,0);
	fo(i,0,2)
		fo(j,0,2)
			fo(k,0,2) p[i][j]=(p[i][j]+(ll)a[i][k]*b[k][j]%mo)%mo;
	fo(i,0,2) fo(j,0,2) c[i][j]=p[i][j];
}
void qmi(int n)
{
	static mat a;
	fo(i,0,2) fo(j,0,2) a[i][j]=A[i][j];
	for(;n;n>>=1)
	{
		if(n&1) mul(C,C,a);
		mul(a,a,a);
	}
}
int main()
{
	n=read(),m=read();
	fo(i,0,2) C[i][i]=1;
	int lst=0;
	fo(i,1,m)
	{
		int x=read();
		qmi(x-lst);
		mul(C,C,B);
		lst=x+1;
	}
	qmi(n-lst);
	printf("%d",C[0][2]);
	return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
a1 = list(map(int, input().split(' ')))
a2 = list(map(int, input().split(' ')))
count = np.zeros(N)
a = np.array([a1,a2])
for i in range(N):
    count[i] += a.T[i].sum()
    count[i] += a[0][:i].sum()
    count[i] += a[1][i+1:].sum() if i+1 < N else 0
print(int(count.max()))

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	cout << ((int)s.size() == n ? "yes" : "no") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <complex>
#include <cmath>
#include <utility>
using namespace std;

#define EPS 1e-8

typedef complex<double> P;
typedef const P &rP;
typedef pair<P,P> seg;

double dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(const seg &s, P c){
	P b = s.second - s.first;
	c -= s.first;
	double cr = cross(b, c);
	if(cr < -EPS){ return 1; }
	if(cr > EPS){ return -1; }
	if(dot(b, c) < -EPS){ return 2; }
	if(norm(b) < norm(c) - EPS){ return -2; }
	return 0;
}

bool intersectSS(const seg &s, const seg &t){
	return ccw(s, t.first) * ccw(s, t.second) <= 0 &&
	       ccw(t, s.first) * ccw(t, s.second) <= 0;
}

double distanceSP(const seg &s, rP c){
	rP a = s.first, b = s.second;
	if(dot(b - a, c - a) <= 0.0) return abs(c - a);
	if(dot(a - b, c - b) <= 0.0) return abs(c - b);
	return abs(cross(b - a, c - a)) / abs(b - a);
}

double distanceSS(const seg &s, const seg &t){
	if(intersectSS(s, t)){ return 0.0; }
	return min(min(distanceSP(s, t.first), distanceSP(s, t.second)),
	           min(distanceSP(t, s.first), distanceSP(t, s.second)));
}

int main(){
	int n;
	double x1, x2, y1, y2, h;
	while(scanf("%d%lf%lf%lf%lf", &n, &x1, &y1, &x2, &y2) == 5){
		seg crs(P(x1, y1), P(x2, y2));
		double ans = 1e99;

		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &h);
			
			if(x1 <= real(crs.first) && real(crs.first) <= x2 &&
			   y1 <= imag(crs.first) && imag(crs.first) <= y2){
				ans = 0.0;
			}
			
			P box[5];
			box[0] = box[4] = P(x1, y1);
			box[1] = P(x1, y2);
			box[2] = P(x2, y2);
			box[3] = P(x2, y1);

			for(int j = 0; j < 4; ++j){
				double d = distanceSS(crs, seg(box[j], box[j + 1]));
				double r;
				if(d <= h){
					r = d;
				}
				else{
					r = (d * d + h * h) / (2.0 * h);
				}
				ans = min(ans, r);
			}
		}
		printf("%.9f\n", ans);
	}
}

Measured memory_bytes: 1112
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const ll MAX_N = 300010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inv(ll a) {
    return modpow(a, mod-2);
}

ll fact[MAX_N];
ll invfact[MAX_N];

void init() {
    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inv(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    init();

    ll ans = 0;
    exrep(x, 0, n) {
        if((k - a*x)%b != 0) {
            continue;
        }
        ll y = (k - a*x)/b;
        if(y < 0 || n < y) {
            continue;
        }
        ans += Comb(n, x)*Comb(n, y);
        ans %= mod;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  string s;
  ll n;
  cin>>s>>n;
  int c=0;
  char a;
  rep(i,0,s.size()){
    if(s[i]=='1') c++;
    else{a=s[i]; break;}
  }
  if(n>c) co(a);
  else co(1);
  
  return 0;
}

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




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  //#ifndef ONLINE_JUDGE
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);
  //#endif //ONLINE_JUDGE

  int n;
  cin >> n;

  long long a[3] = {0};

  a[0] = 2;
  a[1] = 1;

  int i = 2;
  while(i <= n) {
    a[2] = a[1] + a[0];
    a[0] = a[1];
    a[1] = a[2];
    i++;
  }

  cout << a[1];
}


Measured memory_bytes: 256
n = int(input())
aka = []
ao = []
for _ in range(n):
    ab = list(map(int, input().split()))
    aka.append(ab)
aka = sorted(aka, key=lambda x:x[1], reverse=True)
for _ in range(n):
    cd = list(map(int, input().split()))
    ao.append(cd)
ao = sorted(ao)
count = 0
for a, b in aka:
    for c, d in ao:
        if a<c and b<d:
            ao.remove([c,d])
            count+=1
            break
print(count)

Measured memory_bytes: 3064
N, Y = map(int, input().split())
Y_dash = Y // 1000
ans = 0
for a in range(0, N+1):
    for b in range(0, N + 1 - a):
        if -9*a - 5*b + 10*N == Y_dash:
            ans = (a, b, N-a-b)
            break
if ans == 0:
    print(-1, -1, -1)
else:
    print(ans[2], ans[1], ans[0])

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

ll gcd(ll a, ll b)
{
    return (a < b) ? gcd(b, a) : ((a % b) ? gcd(b, a % b) : b);
}

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

int main()
{
    ll n;
    cin >> n;
    llv p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    ll cnt = 0;
    FOR(i, 2, n)
    {
        if ((p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i]))
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

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

    int x, y;
    cin >> x >> y;

    int tmp = 0;
    vector<int> data;
    int k = (int)s.size();
    for (int i = 0; i < k; i++){
        if (s[i] == 'T') {
            data.push_back(tmp);
            tmp = 0;
        }
        else tmp++;
    }
    data.push_back(tmp);

    vector<int> dx;
    vector<int> dy;
    for (int i = 0; i < (int)data.size(); i++) {
        if (i % 2) dy.push_back(data[i]);
        else dx.push_back(data[i]);
    }
    if (dy.size() == 0) dy.push_back(0);

    vector<bool> ss(16001, false);

    queue<int> q;
    vector<bool> xs(16001, false);
    q.push(dx[0] + 8000);
    for (int i = 0; i < (int)dx.size(); i++) {
        for (int j = 0; j < 16001; j++) {
            if (xs[j]) {
                q.push(j + dx[i]);
                q.push(j - dx[i]);
            }
        }
        xs = ss;
        while (q.size() > 0) {
            xs[q.front()] = true;
            q.pop();
        }
    }

    vector<bool> ys(16001, false);
    q.push(dy[0] + 8000);
    q.push(-dy[0] + 8000);
    for (int i = 0; i < (int)dy.size(); i++) {
        for (int j = 0; j < 16001; j++) {
            if (ys[j]) {
                q.push(j + dy[i]);
                q.push(j - dy[i]);
            }
        }
        ys = ss;
        while (q.size() > 0) {
            ys[q.front()] = true;
            q.pop();
        }
    }

    if (xs[x+8000] && ys[y+8000]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];

    int cou=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                swap(a[j],a[j+1]);
                cou++;
            }
        }
    }
    for(int i=0;i<n;i++)cout << a[i] << (i!=n-1?" ":"\n");
    cout << cou << endl;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(begin(a), end(a));
  double ans = a[0];
  for (int i = 1; i < n; ++i) {
    ans = (ans + a[i]) / 2;
  }
  cout.precision(11);
  cout.setf(ios::fixed);
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "sort"
    "strconv"
    "strings"
)

func main() {
  var a, b, c int
  fmt.Scan(&a, &b, &c)

  hani := []int{a, b, c}

  result := ""
  sort.Sort(sort.IntSlice(hani))

  for _, han := range hani {
    s := strconv.Itoa(han)
    result = result + s + " "
  }
  fmt.Printf("%s\n", strings.Trim(result, " "))
}



Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n, q, ar[100001];
string str;

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        cin >> n>> q;
        cin >> str;
        for (int i = 0; i < n; i++) {
                if (str[i] == 'A' && str[i + 1] == 'C') {
                        ar[i + 1] = 1;
                }
        }
        for (int i = 1; i < 100001; i++)
                ar[i] += ar[i - 1];
        while ( q-- ) {
                int l, r;
                cin >> l>> r;
                cout << ar[r - 1] - ar[l - 1]<< "\n";
        }
return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int Q = 301;

int dp[N];
int rec(int x,vector<pi>& v,int n) {
    if (x<=0) return 0;
    if (dp[x]!=(-1)) return dp[x];
    int ret = INT_MAX;
    for (int i=0;i<n;i++) {
        ret = min(ret,v[i].second+rec(x-v[i].first,v,n));
    }
    dp[x] = ret;
    return ret;
}
void solve() {
    mms(dp,-1);
    int h,n;
    cin>>h>>n;
    vector<pi> v(n);
    REP(i,0,n-1) {
        cin>>v[i].first>>v[i].second;
    }
    cout<<rec(h,v,n);
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1792
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
ll f[200004];
ll even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<ll> v){
    ll i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve(){
    ll n,m,i,j,k;
    ll a[200005],b[200005];
    ll ans=0,res=0;
    bool flag=true;
    string s1,s2;
    set<ll> s;
   // cin>>n;
    vector<ll> v;
   // for0(i,n)cin>>v[i];
    cin>>n;
    enterarray(a,n);
    b[0]=a[0];
    for1(i,n-1)b[i]=max(b[i-1],a[i]);
    for0(i,n)ans+=b[i]-a[i];
    cout<<ans;
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

    

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<int> a(n);
        rep(i,n) scanf(" %d", &a[i]);

        //??´??????????????£????????????(b1/w0,?????°)??¨??§???????????????
        vector<pi> f;
        f.pb(pi(a[0],1));
        for(int i=1; i<n; ++i)
        {
            int s=f.size();
            if(i%2==1)
            {
                //?????????????????????????????????
                if(f[s-1].fi==a[i]) ++f[s-1].se;
                else
                {
                    if(s==1)
                    {
                        f[s-1].fi=a[i];
                        ++f[s-1].se;
                    }
                    else
                    {//s>=2
                        //?????°?????????
                        int num=f[s-1].se;
                        //?????????????????????????????????????????????
                        f.erase(f.begin()+s-1);
                        //??????????????????????????¨??°???????????????????????????
                        f[s-2].se+=num+1;
                    }
                }
            }
            else
            {
                if(f[s-1].fi==a[i]) ++f[s-1].se;
                else f.pb(pi(a[i],1));
            }
        }

        //output
        int ans=0;
        rep(i,f.size()) if(f[i].fi==0) ans+=f[i].se;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3068
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] S = sc.next().toCharArray();
    if(S[2] == S[3] && S[4] == S[5]){
      System.out.print("Yes");
    }else{
      System.out.print("No");
    }
  }
}
                                 


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const int MAXS = (1 << 26) + 5;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

char s[MAXN];
int n, dp[MAXS];

void solve() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	mset(dp, 0x3f);
	int S = dp[0] = 0;
	for (int i = 1; i <= n; ++i) {
		S ^= (1 << (s[i] - 'a'));
		dp[S] = dp[S] + 1;
		for (int j = 0; j < 26; ++j) {
			dp[S] = min(dp[S], dp[S ^ (1 << j)] + 1);
		}
		if (i < n) dp[0] = 0;
	}
	printf("%d\n", dp[S]);
}

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



Measured memory_bytes: 262656
h,n = map(int,input().split())
m = []
for i in range(n):
    ai,bi = map(int,input().split())
    m.append((ai,bi))

INF = 1000100001001

dp = [[INF]* (h + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1 ):
    for j in range(h + 1):
        inx = max(0, j - m[i -1 ][0])
        dp[i][j] = min(dp[i -1][j], dp[i][inx] + m[i -1 ][1])


print(dp[n ][h])

Measured memory_bytes: 120556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;
public class Main {
    public static void main(String[] args) throws IOException {
        int n;
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String str;
        BitSet bs = new BitSet(1000000);
        bs.set(2,1000000,true);
        for(int i=2;i<=1000;i++){
            if(!bs.get(i))continue;
            for(int j=i*2;j<1000000;j+=i)bs.clear(j);
        }
        while((str=bf.readLine())!=null){
            n=Integer.parseInt(str);
            System.out.println(bs.get(1,n+1).cardinality());
        }
    }
}

Measured memory_bytes: 27612
ABC = [int(i) for i in input().split()]
ABC.sort()

diff = ABC[2] - ABC[1]
ret = diff
ABC[0] += diff
ABC[1] += diff

ret += (ABC[1] - ABC[0]) // 2
if (ABC[1] - ABC[0]) % 2 == 1 :
    ret += 2
    
print(ret)

Measured memory_bytes: 38256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

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

    if(s == "AAA" || s == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Hemant Malviya

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define lld long long int 
#define vint vector<int>
#define vlld vector<long long int>
#define vst vector<string>
#define ps push_back
#define pii pair<int,int>
#define mk make_pair
#define le length
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define sv()                  int t; scanf("%d",&t); while(t--)
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main()
{ 
    
    int n ; 
    cin>>n;
    int sm =0;
  //  vector<vector<int> > ans = makeCombi(n, k); 
    for (int i = 1; i <= n; i++) { 
        for (int j = 1; j <=n; j++) { 
            for(int k =1;k<=n;k++){
                sm += gcd(gcd(i,j),k);
            } 
        } 
    } 
        cout <<sm<< endl; 
    return 0; 
}

Measured memory_bytes: 3672
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE];
bool finished[SIZE];
LL A[SIZE];
string s, t;
bool solve2(LL x) {
	if (x < 0) return 1;
	if (x == 0) return 0;
	if (finished[x]) return DP[x];
	finished[x] = true;
	REP(i, N) {
		if (!solve2(x - A[i])) return DP[x] = true;
	}
	return DP[x] = false;
}
LL solve() {
	cin >> N >> K;
	EFOR(i,0, N-1) {
		cin >> A[i];
	}
	if (solve2(K)) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 19456
n, m = map(int, input().split())
sides = [list(map(int, input().split())) for _ in range(m)]
check = [0] * n
ans = 0

def DFS(v):
    # print(v)
    if check.count(0) == 0:
        global ans
        ans += 1
        return
    for side in sides:
        if side[0] == v and check[side[1]-1] == 0:
            check[side[1]-1] = 1
            DFS(side[1])
            check[side[1]-1] = 0
        if side[1] == v and check[side[0]-1] == 0:
            check[side[0]-1] = 1
            DFS(side[0])
            check[side[0]-1] = 0
    return ans


check[0] = 1
print(DFS(1))

# procedure DFS(現在の頂点 v)
#     if 全ての頂点を訪問済み then
#         答えを 1 増やす。
#         return
#     end if
#     for 頂点 i: 頂点 v に隣接しているかつ未訪問 do
#         頂点 i を訪問済みとする。
#         DFS(i)
#         頂点 i を未訪問とする。
#      end for
#      return
#  end procedure


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

int main(){
int n,k;
cin>>n>>k;
vector<int> l(n);
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l.begin(),l.end());
int ans=0;
for(int i=0;i<k;i++){
ans+=l[n-1-i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
// int gcd(int a, int b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
// };
int N;
set<string> s;
string str;
void solve() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> str;
		s.insert(str);
	}
	cout << s.size() << endl;
}
int main() {

	int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

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

int main()
{
    unsigned long K;
    cin >> K;
    int res = -1;
    unsigned long comp = 7;
    for (long i = 1; i <= K; i++) {
      	comp = comp % K;
        if (comp == 0) {
            res = i;
            break;
        }
        comp = comp * 10 + 7;
    }
    cout << res << endl;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import sys
import numpy as np


def solve(X: int, N: int, p: "List[int]"):
    ii = [i for i in range(102)]
    iii = sorted(list(set(ii) - set(p)))
    idx = np.abs(np.asarray(iii) - X).argmin()
    print(iii[idx])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()


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

int main(void){

int a,b,i;

scanf("%d%d", &a, &b);


if(a==b){

for (i = 1; i <= a; i++){

printf("%d",a);

}

}

if(a<b){

for (i = 1; i <= b; i++){

printf("%d",a);

}

}

if(b<a){

for (i = 1; i <= a; i++){

printf("%d",b);

}

}

return(0);

}


Measured memory_bytes: 128