akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


struct BipartiteMatching{
    vector<vector<int>> graph;
    vector<int> match, alive, used;
    int timestamp;

    BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), 
    match(n, -1), timestamp(0){}

    void add_edge(int u, int v){
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    bool dfs(int idx){
        used[idx] = timestamp;
        for(auto &to : graph[idx]){
            int to_match = match[to];
            if(alive[to] == 0) continue;
            if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))){
                match[idx] = to;
                match[to]  = idx;
                return true;
            }
        }
        return false;
    }

    int bipartite_matching(){
        int ret = 0;
        for(int i = 0; i < graph.size(); i++){
            if(alive[i] == 0) continue;
            if(match[i] == -1){
                ++timestamp;
                ret += dfs(i);
            }
        }
        return ret;
    }
    void output() {
        for(int i = 0; i < graph.size(); i++) {
            if(i < match[i]) {
                cout << i << "-" << match[i] << endl;
            }
        }
    }
};


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

    int N;
    cin >> N;

    vector<pair<int, int>> a(N);
    vector<pair<int, int>> c(N);

    int tmp_x, tmp_y;
    for(int i = 0; i < N; i++){
        cin >> tmp_x >> tmp_y;
        a[i] = make_pair(tmp_x, tmp_y);
    }
    
    for(int i = 0; i < N; i++){
        cin >> tmp_x >> tmp_y;
        c[i] = make_pair(tmp_x, tmp_y);
    }

    BipartiteMatching bm(2*N);

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if((a[i].first < c[j].first) && (a[i].second < c[j].second)){
                bm.add_edge(i, j+N);
            }
        }
    }

    cout << bm.bipartite_matching() << endl;

    return 0;
}




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

namespace AtCoder.Contest.D
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			int a = cin.nextInt();
			int b = cin.nextInt();
			int c = cin.nextInt();
			int x = cin.nextInt();
			int ans = 0;

			for (int i = 0; i <= a; i++)
			{
				for (int j = 0; j <= b; j++)
				{
					int s = x - 500 * i - 100 * j;
					if (s / 50 <= c && s / 50 >= 0) ans++;
				}
			}
			Console.WriteLine(ans);
			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>
#include<tuple>
#include<utility>
#include<cassert>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3-1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy8[8] = { -1,-1,-1,0,0,1,1,1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

int main() {
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1)
		cout << min(a*b, min(b*c, c*a)) << endl;
	else
		cout << 0 << endl;



	return 0;
}

Measured memory_bytes: 256
# エラトステネスの篩, フェルマーの小定理
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        c = 0
        while n % p == 0:
            n //= p
            c += 1
        result.append((p, c))
    return result


N = int(input())
A = list(map(int, input().split()))

m = 1000000007

prime_table = make_prime_table(10 ** 6)

lcm_factors = {}
for a in A:
    for p, c in prime_factorize(a):
        if p not in lcm_factors or lcm_factors[p] < c:
            lcm_factors[p] = c

lcm = 1
for p in lcm_factors:
    lcm *= pow(p, lcm_factors[p], m)
    lcm %= m

result = 0
for i in range(N):
    result += lcm * pow(A[i], -1, m)
    result %= m
print(result)


Measured memory_bytes: 49604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	for(;cin>>str;){
		int len=str.size(),i;
		for(i=0;i<len;){
			if(str[i]=='@'){
				int k=str[i+1]-'0';
				for(;k--;)cout<<str[i+2];
				i+=3;
			}else{
				cout<<str[i];
				i++;
			}
		}
		cout<<endl;
	}
	return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    if(s[a]=='-')
    {
        int flag=1;
        for(int i=0;i<s.length();i++)
        {
            if(i==a)
                continue;
            if(!(s[i]>='0'&&s[i]<='9')){
                flag=0;break;
            }

        }
        if(flag)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
     else
        cout<<"No"<<endl;


}


Measured memory_bytes: 3628
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int price = 700;
        String order = sc.next();
        if(order.substring(0,1).equals("o")) {
            price +=100;
        }
        if(order.substring(1,2).equals("o")) {
            price +=100;
        }
        if(order.substring(2,3).equals("o") ){
            price +=100;
        }
        
        System.out.println(price);
    }
}

Measured memory_bytes: 21972
n, q = [int(i) for i in input().split()]
s = input()

count_AC = [0]
index_A = -2
sum_AC = 0
for i in range(n):
  if s[i] == 'A':
    index_A = i
  elif s[i] == 'C' and i == index_A + 1:
    sum_AC += 1
  count_AC.append(sum_AC)

for i in range(q):
  l, r = [int(x) for x in input().split()]
  print(count_AC[r] - count_AC[l])


Measured memory_bytes: 6148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
using namespace std;
static const int max_n = 20000;
static const int INF = 1e8;
const long mod =1e9 + 7;
static long long x,a,b,V,m,n,h,D=0,amax=1;
typedef pair<long long, long long> p;
static long long s[max_n],t[max_n],u[max_n],v[max_n],w[2*max_n],z[2*max_n];
static long long dp[max_n][max_n];
long long k = 1;
void solve(){
    while(n>0){
        k *= a;
        k %= mod;
        n--;
    }
    cout << k << endl;
}
int main(){
    cin >> n >> a;
    solve();
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <bitset>
#include <algorithm>
#define ll long long
const int M = 80 * 80 * 2 + 10;
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector< vector<int> > a(h+1,vector<int>(w+1,0));
  vector< vector<int> > b(h+1,vector<int>(w+1,0));
  vector< vector<int> > d(h+1,vector<int>(w+1,0));

  for( int i = 0 ; i < h ; i++ ){
    for( int j = 0 ; j < w ; j++ ){
      cin >>  a[i][j];
    }
  }

  for( int i = 0 ; i < h ; i++ ){
    for( int j = 0 ; j < w ; j++ ){
      cin >>  b[i][j];
    }
  }
  
  for( int i = 0 ; i < h ; i++ ){
    for( int j = 0 ; j < w ; j++ ){
      d[i][j] = abs( a[i][j] - b[i][j] );
    }
  }
//  for( int i = 0 ; i < h ; i++ ){
//    for( int j = 0 ; j < w ; j++ ){
//      cout << d[i][j] << " " ;
//    }
//    cout << endl;
//  }
  
  vector<vector<bitset<M>>> dp(h+1,vector<bitset<M>>(w+1));
  dp[0][0][d[0][0]] = 1;

  for( int i = 0 ; i < h ; i ++ ){
    for( int j = 0 ; j < w ; j++ ){
      if( i < h - 1 ){
        dp[i+1][j] |= (dp[i][j] << d[i+1][j]) | (dp[i][j] >> d[i+1][j]);
        for( int k = 0 ; k <= d[i+1][j] ; k++ ){
          if( dp[i][j][k] ) {
            dp[i+1][j][d[i+1][j]-k] = 1;
          }
        }
      }
      if( j < w - 1 ){
        dp[i][j+1] |= (dp[i][j] << d[i][j+1]) | (dp[i][j] >> d[i][j+1]);
        for( int k = 0 ; k <= d[i][j+1] ; k++ ){
          if( dp[i][j][k] ) {
            dp[i][j+1][d[i][j+1]-k] = 1;
          }
        }
      }
    }
  }
  int ret = 0;
  for( int i = 0 ; i < M ; i++ ){
    if( dp[h-1][w-1][i] ){
      ret = i;
      break;
    }
  }
  cout << ret << endl;
  return 0;

}


Measured memory_bytes: 10880
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define y2 azdfsdgwre

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 2003;
int n, a[N];
bitset <2000001> dp;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> n;
    dp[0] = 1;
    int total = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        total += a[i];
        dp |= (dp << a[i]);
    }
    if (n == 1) {
        cout << a[1];
        return 0;
    }
    int pos = total / 2;
    if (total & 1) {
        total++;
    }
    for (int i = total / 2; i <= 2000000; i++) {
        if (dp[i]) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main(){
	int x,y;
	while(cin>>x>>y,x|y){
		if(x<y)swap(x,y);
		int count=0;
		while(y){
			x%=y;
			swap(x,y);
			count++;
		}
    cout<<x<<" "<<count<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;

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

    int a[n], b[n], c[n - 1];
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]), a[i]--;
    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);
    for (int i = 0; i < n - 1; i++)
        scanf("%d", &c[i]);

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += b[a[i]];
        if (i > 0 && a[i - 1] + 1 == a[i])
            ans += c[a[i - 1]];
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
 
using namespace std;
 
typedef pair<int, int> P;

int n, m;
P info[10001];
 
int main()
{
    while (cin >> n >> m, n || m)  {
        long long ans = 0;
 
        for (int i = 0; i < n; i++) 
            cin >> info[i].second >> info[i].first;

        sort(info, info + n);
 
        for (int i = n - 1; i >= 0; i--) {
            if (m >= info[i].second)
                m -= info[i].second;
            else  {
                ans += (info[i].second - m) * info[i].first;
                m = 0;
            }
        }
 
        cout << ans << endl;
    }
 
    return 0;
}

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

int main()
{
  char number;
  int n[10];
  int i,j;

  while(scanf("\n%c",&number)!=EOF){
    n[0]=number-'0';
    for(i=1;i<10;i++){
      scanf("%c",&number);
      n[i]=number-'0';
    }
    for(i=1;i<10;i++)
      for(j=0;j<10-i;j++)
	n[j]=(n[j]+n[j+1])%10;

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

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

ll n,a[50];
ll mn=1,mx=1;

int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[mn]>a[i])mn=i;
        if(a[mx]<a[i])mx=i;
    }
    ll x=abs(a[mn])<abs(a[mx])?mx:mn;
    cout<<n*2-1<<endl;
    rep(i,n)cout<<x+1<<" "<<i+1<<endl;
    if(a[x]>0)rep(i,n-1)cout<<i+1<<" "<<i+2<<endl;
    else for(int i=n-1;i;i--)cout<<i+1<<" "<<i<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update> */

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

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
	
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
        s=s+"es";
    else
    {
        s=s+"s";
    }
    cout<<s<<endl;
    
    return 0;
}




Measured memory_bytes: 3652
#あーーーー5の倍数か
#そりゃそう、常に選ぶにはmodNを考えたときにすべて同じにしてmodNで0にすれば良いのか
#つまり、1mod5に全部できれば良い



import math
k=int(input())
def isPrime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True

x=[str(i) for i in range(10,55556) if ((i%10==1) and (isPrime(i)))][:k]
print(" ".join(x))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++)a[i] = sc.nextInt();
		int min = a[0];
		int max = a[0];
		long sum = 0;
		//min
		for(int i = 0; i < n-1; i++) {
			min = Math.min(min, a[i + 1]);
		}
		//max
		for(int i = 0; i < n-1; i++) {
			max = Math.max(max, a[i + 1]);
		}
		//sum
		for(int b : a)sum +=b;
		System.out.println(min+" "+max+" "+sum);
		sc.close();
	}
}



Measured memory_bytes: 42288
//ALDS1_5_A_ExhaustiveSearch

#include<bits/stdc++.h>
using namespace std;
const int INF=2E9;
typedef pair<int,int> Pair;
typedef long long LL;
int cnt=0;

void merge(int A[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    int *L=new int[n1+1];
    int *R=new int[n2+1];
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1]=R[n2]=INF;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
            i=i+1;
        }else {
            A[k]=R[j];
            j=j+1;
        }
        cnt++;
    }
    delete[] L;
    delete[] R;
}

void mergeSort(int A[],int left,int right){
    if(left+1<right){
        int mid =(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}

int main(){
    int n;
    int A[500100];
    cin >> n;
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A,0,n);
    for(int i=0;i<n;i++){
        cout << A[i];
        if(i==n-1) cout << endl;
        else cout << " ";
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 6884
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<numeric>
#include<algorithm>
using namespace std;

int main() {

	int N;
	cin >> N;
	int min = N + 1;

	int num = 0;
	int ans = 0;

	for (int i = 0; i < N; i++) {
		cin >> num;
		if (num < min) {
			min = num;
			ans += 1;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
n, m = map(int, input().split())

drink = []

for i in range(n):
    a, b = map(int, input().split())
    drink.append((a, b))

drink.sort()

cost = 0
bought = 0

for i in range(n):
    a, b = drink[i]

    if bought + b < m:
        bought += b
        cost += a * b
    else:
        cost += a * (m - bought)
        break

print(cost)


Measured memory_bytes: 53336
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pair<ll,ll>
#define MAX 200001
using namespace std;
int main()
{
	ll n,i,j,k,l;
    string st;
    cin>>st;
    ll cnt=0;
    for(i=0;i<st.size();i++){
        if(st[i]=='2')
            cnt++;
    }
    cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  string s;

  cin >> s;
  int ok = 1;

  for (int i = 0; i < s.size(); i++){
    if (i % 2 == 0 && s[i] == 'L')
      ok = 0;
    if (i % 2 == 1 && s[i] == 'R')
      ok = 0;
    
  }

  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main(void){
    string s;
    cin >> s;
    int c[27];
    fill(c,c+26,0);
    for(int i=0; i<s.length(); i++){
        c[s[i]-'a']++;
    }
    for(int i=0; i<26; i++){
        if(c[i] == 0){
            printf("%c\n", (char)i+'a');
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    ll K, N;
    cin >> K >> N;
    vector<int>A(N + 1);
    rep(i, N)cin >> A[i];
    A[N] = K + A[0];
    int interval = -1;
    rep(i, N){
        chmax(interval, A[i + 1] - A[i]);
    }
    cout << K - interval;
    
 
    return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		br.readLine();
		List<String> a=Arrays.asList(br.readLine().split(" "));
		int n1=Integer.parseInt(a.get(0));
        int min=n1,max=n1;
        long sum=n1;
        for(Iterator<String> i=a.iterator();i.hasNext();){
			String s=i.next();
        	int n2=Integer.parseInt(s);
            if(n2<min) min=n2;
            if(n2>max) max=n2;
            sum+=n2;
		}
        System.out.println(min+" "+max+" "+(sum-n1));
	}
}

Measured memory_bytes: 25676
n = int(input())
if 400 <= n and n <= 599:
    print("8")
elif 600 <= n and n <= 799:
    print("7")
elif 800 <= n and n <= 999:
    print("6")
elif 1000 <= n and n <= 1199:
    print("5")
elif 1200 <= n and n <= 1399:
    print("4")
elif 1400 <= n and n <= 1599:
    print("3")
elif 1600 <= n and n <= 1799:
    print("2")
else:
    print("1")


Measured memory_bytes: 61680
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cill(n);
    cill(k);
    V<LL> v(n), route;
    V<bool> boo(n, false);
    for(auto&& i : v) {std::cin >> i;i--;}
    route.pb(0);
    boo[0] = true;
    LL breaked=-1;
    rep1(i, n){
        LL next = v[route[i-1]];
        if(boo[next]){
            breaked = next;
            break;
        }
        boo[next] = true;
        route.pb(next);
    }
    LL roop = route.size(), offset=0;
    rep(i, route.size()){
        if (route[i]==breaked){
            offset = i;
            break;
        }
    }
    if (breaked==0) offset=0;
    roop -= offset;
    if (offset < k){
        co(route[offset + (k-offset) % roop] + 1);
    }else{
        co(route[k] + 1);
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 6920
#include<iostream>
 #include<algorithm>
 #include<cmath>
 #include<iomanip>
 #include<cstring>
 #include<cmath>
 #include<map>
 #include<vector>
 #include<sstream>
 #include<queue>
using namespace std;

typedef long long ll;
const ll maxn=1e18;
int main()
{
    long long sum=1;
    int n;
    long long mid;
    cin>>n;
    int flag=0;
    while(n--)
    {
        cin>>mid;
        if(mid==0)
        {
            flag=-1;
        cout<<"0";
        return 0;
        }
        if(maxn/sum>=mid)
        sum*=mid;
        else
        flag=1;
    }
    
    if(flag==1) cout<<"-1";
    else if(flag==-1)cout<<"0";
    else cout<<sum;
    
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    ll a,b,c;
    cin >> a >> b >> c;

    ll ans = LLONG_MAX;

    if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
        ans = 0;
    }else{
        ans = a * b;
        ans = min(ans, a * c);
        ans = min(ans, b * c);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

ll S(ll a){
  ll res = 0;
  while(a > 0){
    res += a % 10;
    a /= 10;
  }
  return res;
}

int main(){

  /*
  {
  double mi = INF;
  for(int i = 199999999; i >= 1; i--){
    double res = (double)i / S(i);
    if(res < mi){
      cout << i << " " << res << endl;
      mi = res;
    }
  }
  return 0;
  }
  */
  
  vector<ll> snuke(0);

  double mi = INFLL;
  ll d = 100000000000;
  while(d > 0){
    for(ll i = 99999; i >= 10000; i--){
      ll cur = i * d + d - 1;
      double res = (double)cur / S(cur);
      if(res < mi){
        mi = res;
        snuke.pb(cur);
      }
    }
    d /= 10;
  }

  
  for(ll i = 9999; i >= 1; i--){
    ll cur = i;
    double res = (double)cur / S(cur);
    if(res < mi + 1e-6){
      mi = res;
      snuke.pb(cur);
    }
  }

  reverse(snuke.begin(), snuke.end());
  
  ll k = in();
  REP(i, k){
    printf("%lld\n", snuke[i]);
  }
  
  return 0;
}


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

int main() {
    string s; cin >> s;
    int n = (int)s.size();

    char center = s[n/2];
    int i = 0;
    if(n & 1) {
        for(; i <= n/2; ++i) {
            if(s[n/2 - i] != center || s[n/2 + i] != center) break;
        }
    } else {
        for(; i <= n/2; ++i) {
            if(s[n/2 - i - 1] != center || s[n/2 + i] != center) break;
        }
    }

    cout << n / 2 + i << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<deque>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<fstream>
#include<sstream>
#include<cassert>
#include<iomanip>
#include<utility>
#include<bitset>
using namespace std;
int a[200010];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	if(n%2)
	{
		for(int i=0;i<=n/2;i++)
		cout<<a[n-i*2]<<" ";
		for(int i=1;i<=n/2-1;i++)
		cout<<a[i*2]<<" ";
		if(n!=1)
		cout<<a[n-1];
	}
	else
	{
		for(int i=0;i<n/2;i++)
		cout<<a[n-i*2]<<" ";
		for(int i=0;i<n/2-1;i++)
		cout<<a[i*2+1]<<" ";
		cout<<a[n-1]; 
	}
	return 0;
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int c_0 = 0;
        int c_1 = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == '0')
                c_0++;
            if (s[i] == '1')
                c_1++;
        }
        Console.WriteLine(s.Length - Math.Abs(c_0 - c_1));
    }
}

Measured memory_bytes: 11360
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
  q.append((-1)*a[i])
heapq.heapify(q)
for k in range(m):
  ma=heapq.heappop(q)
  if ma%2==0:
    heapq.heappush(q,ma//2)
  else:
    heapq.heappush(q,ma//2+1)
print(sum(q)*(-1))

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

int n;
int a[200005];
map <long long, int> f;
int main()
{
    scanf("%d", &n);
    long long Sol = 0, Sum = 0;
    int x;
    for(int i = 1; i <= n ; ++i){
        scanf("%d", &x);
        Sum += x;
        if(Sum == 0) ++Sol;
        Sol = Sol + f[Sum];
        ++f[Sum];
    }
    printf("%lld", Sol);
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

struct Vegi {
    double cost;
    string name;
    Vegi(double cost0, string name0) {
        cost = cost0;
        name = name0;
    }
};

bool operator < (const Vegi& vegi, const Vegi& vegi2) {
    if (vegi.cost == vegi2.cost) {
        return vegi.name < vegi2.name;
    }
    return vegi.cost < vegi2.cost;
}
bool operator > (const Vegi& vegi, const Vegi& vegi2) {
    if (vegi.cost == vegi2.cost) {
        return vegi.name >= vegi2.name;
    }
    return vegi.cost >= vegi2.cost;
}

int main(void) {
    while(1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        priority_queue<Vegi, Vec<Vegi>, std::greater<Vegi> > pq;

        for (int i = 0; i < n; i++) {
            string l;
            int p;
            int a;
            int b;
            int c;
            int d;
            int e;
            int f;
            int s;
            int m;
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double time = a + b + c + m * (d + e);
            double profit = f * s * m - p;
            double input_cost = profit / time;
            pq.push(Vegi(-input_cost, l));
        }

        while (!pq.empty()) {
            Vegi output = pq.top();
            cout << output.name << endl;
            pq.pop();
        }
        cout << "#" << endl;
    }
    return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int r = 0;
    int b = 0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='R') r++;
        else b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(1<<N);
    rep(i,1<<N) cin >> A[i];

    set<pii> dic;
    rep(i,1<<N) {
        dic.emplace(A[i],i);
    }
    vector<int> B;
    B.emplace_back(dic.rbegin()->first);
    dic.erase(*dic.rbegin());
    rep(i,N) {
        vector<int> C;
        for (auto j : B) {
            auto it = dic.lower_bound(make_pair(j,-1));
            if (it==dic.begin()) {
                cout << "No" << ln;
                return 0;
            }
            C.emplace_back(prev(it)->first);
            dic.erase(prev(it));
        }
        for (auto j : C) B.emplace_back(j);
    }

    cout << "Yes" << ln;
}


Measured memory_bytes: 15036
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  if b in a1:
    #vは穴が空いたということ
    num = a1.index(b)
    a1[num] = "v"
  elif b in a2:
    num = a2.index(b)
    a2[num] = "v"
  elif b in a3:
    num = a3.index(b)
    a3[num] = "v"
if a1.count("v")==3 or a2.count("v")==3 or a3.count("v")==3 or a1[0]==a2[0]==a3[0]=="v" or a1[1]==a2[1]==a3[1]=="v" or a1[2]==a2[2]==a3[2]=="v" or a1[0]==a2[1]==a3[2]=="v" or a1[2]==a2[1]==a3[0]=="v":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
# 白色マスで４方向のマスに黒マスが一つ以上存在するものを黒にかえる。
# 何回の操作でマスが全て黒マスになるか？
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]
black_list = []
for h in range(H):
    for w in range(W):
        if field[h][w] == "#":
            black_list.append((h, w))

count = 0
move = ((0, 1), (1, 0), (-1, 0), (0, -1))
# 広がり方は一点の黒から一定なのでそれを行うことで、計算量を改善できる？
while black_list:
    n_pl = []
    for b in black_list:
        for m in move:
            n_p = (b[0] + m[0], b[1] + m[1])
            if not(n_p[0] < 0 or n_p[1] < 0 or n_p[0] >= H or n_p[1] >= W) and field[n_p[0]][n_p[1]] == ".":
                field[n_p[0]][n_p[1]] = "#"
                n_pl.append(n_p)
    black_list = n_pl
    count += 1
print(count-1)


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

long long int a,b,c,d;

int main(){
  cin >> a >> b >> c >> d;
  for(long long int i = 0;i < a;i++){
    
    for(long long int j = 0;j < b;j++){
      
      cout << (long long int) (((i < d) + (j < c)) % 2);
    }
    
    cout << endl;
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
int d[305];
int dc[305];
int main() {

	string s;
	long long int k;
	cin >> s;
	cin >> k;

	long long int n = s.size();
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			d[i] = d[i - 1] + 1;
		}
	}
	if (d[n - 1] == n - 1) {
		long long int m = n * k;

		cout << m / 2;
		return 0;
	}
	long long int ans1 = 0;
	for (int i = 0; i < n - 1; i++) {
		if (d[i] > d[i + 1]) {
			ans1 += (d[i] + 1) / 2;
		}
	}
	ans1 += (d[n - 1] + 1) / 2;


	long long int ans2 = 0;
	for (int i = 1; i < 2 * n; i++) {
		if (i == n) {
			if (s[0] == s[n - 1])
				dc[n] = dc[n - 1] + 1;
			continue;
		}
		if (s[i % n] == s[i % n - 1]) {
			dc[i] = dc[i - 1] + 1;
		}
	}
	for (int i = 0; i < (2 * n) - 1; i++) {
		if (dc[i] > dc[i + 1]) {
			ans2 += (dc[i] + 1) / 2;
		}
	}
	ans2 += (dc[2 * n - 1] + 1) / 2;
	long long int ans = (ans2 - ans1) * (k - 1) + ans1;
	cout << ans;
}

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, ans = 0, m = 0;
	cin >> n;
	FOR(i, n) {
		int a;
		cin >> a;
		ans += a;
	}
	cout << ans - n << endl;
	

	return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll X;
    cin >> X;
    if(X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
n, m = map(int, input().split())
mat = [input() for _ in range(n)]


for i in range(n):
    for j in range(m):
        target = mat[i][j]
        if target == "#":
            if not i == 0:
                if mat[i-1][j] == "#":
                    continue
            if not i == n-1:
                if mat[i+1][j] == "#":
                    continue
            if not j == 0:
                if mat[i][j-1] == "#":
                    continue
            if not j == m-1:
                if mat[i][j+1] == "#":
                    continue
            print("No")
            exit()
                
print("Yes")

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

int main() {
  
  int N; cin >> N;
  
  int multiplesOfTwo = 0, multiplesOfFour = 0, other = 0;
  
  for (int i = 0; i < N; i++) {
    
    int64_t a; cin >> a;
    
    if (a % 4 == 0) {
      multiplesOfFour++;
    }
    
    else if (a % 2 == 0) {
      multiplesOfTwo++;
    }
    
    else {
      other++;
    }
    
  }
  
  if (multiplesOfTwo == 0) {
    
    if (other - 1 <= multiplesOfFour) cout << "Yes" << endl;
    
    else cout << "No" << endl;
    
    return 0;
    
  }
  
  if (other <= multiplesOfFour) cout << "Yes" << endl;
  
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
#define puts(x) cout << x << "\n"
using namespace std;
signed main() {
	int x, n, ans = 0; cin >> n >> x;
	n -= x;
	while (1) {
		if (n < x)swap(n, x);
		if (x == 0)break;
		ans += (n - n % x) * 3; n %= x;
	}
	puts(ans);
}

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

int main(){
  string s,t;
  string s_d,t_d;

  cin >> s >> t;

  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());

  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define repr(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
template<typename T> constexpr auto square(T x) { return (x)*(x); }

int main()
{
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));

	for (auto& vec : X) {
		for (auto& x : vec) {
			cin >> x;
		}
	}

	int ans = 0;

	rep(i, N-1) {
		repr(j, i + 1, N) {
			int dd = 0;
			rep(k, D) dd += square(X[i][k] - X[j][k]);
			int d = static_cast<int>(sqrt(static_cast<double>(dd)));
			if (dd == d * d) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long md=998244353;
long long n,m,k,ft[202020],ans;
long long pw(long long x,long long y)
{
	long long ans=1;
	while(y)
	{
		if(y&1)
		{
			ans*=x;
			ans%=md;
		}
		y>>=1;
		x*=x;
		x%=md;
	}
	return ans;
}
long long chu(long long x)
{
	return pw(x,md-2);
}
long long C(long long a,long long b)
{
	return (ft[a]*chu(ft[b]*ft[a-b]%md))%md;
}
int main()
{
	ft[0]=1;
	ft[1]=1;
	for(long long i=2;i<=200100;i++)
	{
		ft[i]=ft[i-1]*i;
		ft[i]%=md;
	}
	cin>>n>>m>>k;
	for(long long i=0;i<=k;i++)
	{
		long long rt=n-i-1,nw=m;
		if(i!=0)
		{
			nw*=C(n-1,i);
			nw%=md;
		}
		nw*=pw(m-1,rt);
		nw%=md;
		ans+=nw;
		ans%=md;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5204
N,K = map(int,input().split())

mod = 10**9+7

m = N+1
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    if n<0 or k<0 or k>n:return 0
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

for i in range(1,K+1):
    print(comb(N-K+1,i)*comb(K-1,i-1)%mod)

Measured memory_bytes: 43504
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    double a;
    double bunbo;
    for(int i = 0; i < n; i++){
        cin >> a;
        bunbo += 1.0 / a;
    }
    cout << setprecision(12) << 1.0 / bunbo << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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 = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

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

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;
  return 0;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
x=dict()
m=1
mc=0
ans=0
for i in range(N):
    if A[i] in x:
        x[A[i]]+=1
        m=max(m,x[A[i]])
        if m==x[A[i]]:
            mc=A[i]
    else:
        x[A[i]]=1
        ans+=1
if mc==0:
    print(N)
    exit()
l=[]
for idx in x:
    l.append(x[idx]-1)

n=sum(l)
if n%2==0:
    print(ans)
else:
    print(ans-1)

Measured memory_bytes: 17400
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int t=1;
//        String T=br.readLine();
//        if(T!=null) t=Integer.parseInt(T);
        while(t-- > 0) {
            int x = Integer.parseInt(br.readLine());
            if(x >= 30) System.out.print("Yes\n");
            else System.out.print("No\n");
        }
    }
}

Measured memory_bytes: 32436