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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

string N;
int  k, sz;
vector<int> digits;
int cache[105][5][2];

void getDigits(string s)
{
      digits.clear();
      for(int i = 0; i < s.size(); i++)
      {
            int d = s[i] - '0';
            digits.push_back(d);
      }
}

int dp(int idx, int nonzero, int tight)
{
      if(nonzero > k) return 0;
      if(idx == sz)
      {
           return (nonzero ==k);
      }
      int &res = cache[idx][nonzero][tight];
      if(res != -1 )
            return res;

      res = 0;
      int limit = tight ? digits[idx] : 9;
      for(int i = 0; i <= limit; i++)
      {
            int newTight = (i == limit) ? tight : 0;
            res += dp(idx + 1, nonzero + (i != 0) , newTight);
      }
      return res;
}


int32_t main()
{
      IOS;
      cin >> N >> k;
      sz = N.size();
      memset(cache, -1, sizeof(cache));
      getDigits(N);
      int ans = dp(0, 0, 1);
      cout << ans;

      return 0;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1000000];
int sum[1000000];
int n;
int main(){
 for (int i=2;i<1000000;i++){
  if (!a[i])
   for (int j=i*2;j<1000000;j+=i)
    a[j]=1;
 }
 for (int i=2;i<1000000;i++) sum[i]=sum[i-1]+(a[i]==0?1:0);
 while (cin>>n)
  cout<<sum[n]<<endl;
 return 0;
}


Measured memory_bytes: 10808
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const info = input.shift().split(' ');

const studends = [];

// 生徒がどこにいるかの配列
for(let s_i = 0; s_i < info[0]; s_i++){
	studends.push(input[s_i].split(' '));
}

const checkpoints = [];

// チェックポイントについての配列
for(let c_i = info[0]; c_i < info[1]*1 + info[0]*1; c_i++){
	checkpoints.push(input[c_i].split(' '));
}


for(let s_i = 0; s_i < info[0]; s_i++){
  // minはとりあえずめちゃくちゃ大きな値にする
  let min = Infinity;
  let point_no = null;
  let diff;
  for(let c_i = 0; c_i < checkpoints.length; c_i++){
      diff = 
        Math.abs(checkpoints[c_i][0] - studends[s_i][0])
          + Math.abs(checkpoints[c_i][1] - studends[s_i][1]);
      if(diff < min){
        min = diff;
        //1スタートなので +1 している
        point_no = c_i + 1;
      }
  }
  console.log(point_no);
}


Measured memory_bytes: 7500
n, q = gets.split.map(&:to_i)
previous_is_a = false
count = 0
s = gets.chomp.split("").map { |char|
  if char == "A"
    previous_is_a = true
    count
  elsif char == "C" && previous_is_a
    previous_is_a = false
    count += 1
  else
    previous_is_a = false
    count
  end
}
q.times do
  l, r = gets.split.map(&:to_i)
  puts s[r-1] - s[l-1]
end


Measured memory_bytes: 10876
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int N = 505;

int n,x,a[N][N];
LL s1[N][N], s2[N][N], dp[N][N];

int main(){
	scanf("%d",&n);
	rep(i,1,n)rep(j,1,n-1){
		scanf("%d",&x);
		a[i][j+(j>=i)]=x;
	}
	
	rep(i,1,n){
		LL sum1 = 0, sum2 = 0;
		rep(j,i,n){
			sum1 += a[i][j], sum2 += a[j][i];
			s1[i][j] = s1[i-1][j] + sum1;
			s2[i][j] = s2[i-1][j] + sum2;
		} 
	}
	
	rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=1e18;
	dp[1][0]=0;
	rep(i,1,n)rep(j,0,i-1)rep(x,i+1,n+1){
		LL sum1 = s1[x-1][x-1] - s1[i-1][x-1];
		LL sum2 = s2[i-1][n] - (j?s2[j-1][n]:0) - s2[i-1][x-1] + (j?s2[j-1][x-1]:0);
		dp[x][i] = min(dp[x][i], dp[i][j] + sum1 + sum2);
	}
	LL ans = 1e18;
	rep(i,1,n) ans = min(ans, dp[n+1][i]);
	printf("%lld\n",ans);
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

int compute(int a,int b,int c) {
  if( a == b && b == c ) {
    if( a % 2 || b % 2 || c % 2 ) return 0;
    return -1;
  }
  int cnt = 0;
  while( a%2 == 0 && b%2 == 0 && c%2 == 0 ) {
    ++cnt;
    int ta = ( b / 2 ) + ( c / 2 );
    int tb = ( a / 2 ) + ( c / 2 );
    int tc = ( a / 2 ) + ( b / 2 );
    a = ta, b = tb, c = tc;
  }
  return cnt;
}

int main() {
  int i,j,k;
  cin >> i >> j >> k;
  cout << compute(i,j,k) << endl;;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace abc149_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            for (var i = x;; i++)
            {
                if (!IsPrime(i))
                {
                    continue;
                }

                Console.WriteLine(i);
                break;
            }
        }

        private static bool IsPrime(int x)
        {
            for (var i = 2; i <= x/2; i++)
            {
                if (x % i == 0)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

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

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

    int kaisuu[26] = {0};
    for (int i = 0; i < S.size(); ++i) {
        ++kaisuu[(int)(S[i] - 'a')];
    }

    bool all0 = true;
    for (int i = 0; i < 26; ++i) {
        if (!kaisuu[i]) {
            all0 = false;
            cout << (char)(i + 'a') << endl;
            break;
        }
    }

    if (all0) cout << "None" << endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;
const int N=2e5+5;


int main(){
    int A, B; cin >> A >> B;
    cout << 6-A-B<< endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
PS= [[s for s in input().split()] for _ in range(M)]

def main():
    ac = 0
    wa = 0
    dic = {}
    cleared = {}
    for p,s in PS:
        if s == "AC" and p not in cleared:
            cleared[p] = True
            if p in dic:
                wa += dic[p]
            ac += 1
        else:
            if p in dic:
                dic[p] += 1
            else:
                dic[p] = 1
    print(ac,wa)
    return 


if __name__ == "__main__":
    main()

Measured memory_bytes: 35208
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int ar[13][13],cost[13],check[13];

int main()
{
   //freopen("inputfile.txt","r",stdin);
   ll n,m,h;cin>>n>>m>>h;
   for(ll i=0;i<n;i++)
   {
       cin>>cost[i];
       for(ll j=0;j<m;j++)
       {
           ll k;cin>>k;
           ar[i][j] = k;

       }
   }
  ll net = 1<<n;
  ll mi = 10000000;
  for(ll i=0;i<net;i++)
  {
     ll sum=0;
     ll dup[m];
     memset(dup,0,sizeof(dup));
      for(ll j=0;j<n;j++)
      {
         ll f = 1<<j;
          if(f&i)
          {
              sum+=cost[j];
              for(ll k=0;k<m;k++)
              {
                  dup[k]+=ar[j][k];
              }

          }
      }
      bool flag = true;
      for(ll i=0;i<m;i++)
      {
          if(dup[i]<h)
          {
              flag = false;
              break;
          }
      }
      if(flag==true)mi = min(mi,sum);
  }
   if(mi == 10000000){
        cout << -1<<endl;
    }
    else{
        cout << mi<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        string[] s = ReadLine().Split(' ');
        long A = long.Parse(s[0]);
        long B = long.Parse(s[1]);
        long C = long.Parse(s[2]);
        long D = long.Parse(s[3]);
        long CD = Lcm(C, D);
        WriteLine(B  - A + 1 + B / CD - (A - 1) / CD - B / D - B / C + (A - 1) / D + (A - 1)/ C);
    }
      static long Gcd(long n, long m)
    {
        if (n < m) return Gcd(m, n);
        while(m != 0)
        {
            long r = n % m;
            n = m;
            m = r;
        }
        return n;
    }
    static long Lcm(long n, long m)
    {
        return n / Gcd(n, m) * m;
    }
}

Measured memory_bytes: 11092
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
double to_deg(double r) {return r * 180.0 / (atan(1.0) * 4.0);}

int main(){
    char s[5];
    scanf("%s",s);
    if(!strcmp(s,"SUN")){
        printf("7");
    }else if(!strcmp(s,"MON")){
        printf("6");
    }else if(!strcmp(s,"TUE")){
        printf("5");
    }else if(!strcmp(s,"WED")){
        printf("4");
    }else if(!strcmp(s,"THU")){
        printf("3");
    }else if(!strcmp(s,"FRI")){
        printf("2");
    }else if(!strcmp(s,"SAT")){
        printf("1");
    }
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;

int main(){
	int N;
	int a;
	int pre=2;
	ll ans=0;
	scanf("%d",&N);
	scanf("%d",&a);
	ans+=a-1;
	REP(i,N-1){
		scanf("%d",&a);
		if (a==pre){
			pre++;
		}else{
			ans+=(a-1)/pre;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  vector<int> X(N);
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  rep(i, N) X[i] = i + 1;
 
  map<vector<int>, int> D;
  int cnt = 1;
  do{
    D[X] = cnt;
    cnt++;
  }
  while (next_permutation(X.begin(), X.end()));
  cout << abs(D[P] - D[Q]) << endl;
}

Measured memory_bytes: 8620
using System;

namespace a1
{
    //1181100049 大町泰史
    using System;
    class Qsort
    {
        public void Sort(int[] data, int start, int end)
        {
            if (end - start <= 1)  //要素数が1個以下。end=data.Lengthよりdata[end-1]が最後の要素であることに注意する。
            {
                return;
            }

            int p = data[start];                   //データの1番目をピボットする
            int i = start - 1;
            int j = end;

            while (true)
            {
                //データのstart(1番目、左端)から一つずつ調べて、p以上ならbreakしてiの値を保存。次に調べるのはi+1番目から
                for (i = i + 1; i < data.Length; i++)
                {
                    if (p <= data[i])
                        break;
                }
                //データのend-1(最後、右端)から一つずつ調べて、p以下ならbreakしてjの値を保存。次に調べるのはj-1番目から
                for (j = j - 1; j > 0; j--)
                {
                    if (p >= data[j])
                        break;
                }

                if (j < i)     //iとjの値が逆転したなら、whileから抜け出す。
                    break;
                else        //そうでないなら、i番目とj番目を交代
                {
                    int tmp = data[i];
                    data[i] = data[j];
                    data[j] = tmp;
                }
            }
            //i-1番目とi番目の間を境界にして分けて再帰。data[end-1]がデータの最後であるので前半(start～i-1)、後半(i～end-1)
            Sort(data, start, i);
            Sort(data, i, end);
        }
    }

    class MainQsort
    {
        public static void Main()
        {          
                           
            int n = int.Parse(Console.ReadLine());
            double sum = 0;
            string[] str = Console.ReadLine().Split(' ');
            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                b[i] = int.Parse(str[i]);
                sum += (double)1 / b[i];
            }

            Qsort qsort = new Qsort();
            qsort.Sort(b, 0, b.Length);
            double c = (b[0] + b[1]) / 2.0;
            for(int i = 2; i < n; i++)
            {
                c = (c+b[i]) / 2.0;
            }
            Console.WriteLine(c);
        }
    }
}
      

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int result = 0;

		result += Math.min(a, k);
		k -= Math.min(a, k);

		if(k > 0){
			k -= Math.min(b, k);
		}

		if(k > 0){
			result -= k;
		}
		System.out.println(result);


	}

}


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}

ll mod(ll a, ll b) {return (a % b + b) % b;}

ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main() 
{	
	fast;
	ll n,k; cin>>n>>k;
	unordered_map<ll,ll>mp;
	while(k--)
	{
		ll t; cin>>t;
		while(t--)
		{
			ll x; cin>>x;
			mp[x]++;
		}
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++)
	{
		if(!mp.count(i))
		{
			ans++;
		}
	}
	cout << ans << endl;
 	return 0;
}

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

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);}


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

  Int n;
  cin>>n;

  if(n==1){
    cout<<"Yes"<<endl;
    cout<<1<<endl;
    return 0;
  }

  if(n&1) drop("No");

  vector< vector<Int> > ans(n,vector<Int>(n,-1));

  Int cnt=1;
  for(Int i=0;i<n;i++) ans[i][i]=cnt;
  cnt++;

  for(Int t=0;t<2;t++){
    auto add_edge=
      [&](Int p,Int q,Int x){
        p=(p+n)%n;
        q=(q+n)%n;
        if(t==0) if(p>q) swap(p,q);
        if(t==1) if(p<q) swap(p,q);
        ans[p][q]=x;
      };
    for(Int i=0;i<n-1;i++){
      add_edge(i,n-1,cnt);
      for(Int j=1;j<n/2;j++){
        Int p=(i+(n-1)+j)%(n-1);
        Int q=(i+(n-1)-j)%(n-1);
        add_edge(p,q,cnt);
      }
      cnt++;
    }
  }

  cout<<"Yes"<<endl;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(j) cout<<" ";
      cout<<ans[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 4996
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s;
	cin >> s;

	string displayed = "";
	for (int i = 0; i < (int) s.size(); ++i) {
		if (s[i] == '0') {
			displayed.push_back('0');
		} 
		else if (s[i] == '1') {
			displayed.push_back('1');
		} else {
			if (displayed.size()) {
				displayed.pop_back();
			}
		}
	}

	cout << displayed << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char text[100001];
	scanf("%s",text);
	int i,l=0,a=0,b=0,ans;
	for(i=0;text[i]!='\0';i++){
		l++;
	}
	if(l%2==0){
		for(i=0;i<l/2;i++){
			if(text[i*2]!='1'){
				a++;
			}
			if(text[i*2+1]!='0'){
				a++;
			}
		}
		for(i=0;i<l/2;i++){
			if(text[i*2]!='0'){
				b++;
			}
			if(text[i*2+1]!='1'){
				b++;
			}
		}
	}else{
		for(i=0;i<l/2+1;i++){
			if(text[i*2]!='1'){
				a++;
			}
		}
		for(i=0;i<l/2;i++){
			if(text[i*2+1]!='0'){
				a++;
			}
		}
		for(i=0;i<l/2+1;i++){
			if(text[i*2]!='0'){
				b++;
			}
		}
		for(i=0;i<l/2;i++){
			if(text[i*2+1]!='1'){
				b++;
			}
		}
	}
	if(a<=b){
		ans=a;
	}else{
		ans=b;
	}
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 256
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


rating = int(input())

if 400 <= rating <= 599:
    ans = 8
elif 600 <= rating <= 799:
    ans = 7
elif 800 <= rating <= 999:
    ans = 6
elif 1000 <= rating <= 1199:
    ans = 5
elif 1200 <= rating <= 1399:
    ans = 4
elif 1400 <= rating <= 1599:
    ans = 3
elif 1600 <= rating <= 1799:
    ans = 2
elif 1800 <= rating <= 1999:
    ans = 1

print(ans)


Measured memory_bytes: 68676
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
ll n,a,b,c,d; 
int main()
{
	bool paulzrm=false;
	cin>>n>>a>>b>>c>>d;
	for(int i=0;i<n;i++){
		if(c*(n-1-i)-d*i<=(b-a)&&(n-1-i)*d-c*i>=(b-a)){
			paulzrm=true;
			break;
		}
	}
	if(paulzrm){
		cout<<"YES";
	}
	else cout<<"NO";
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;

   long int n;
   cin>>n;


   cout<<n*n;  

   return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }

const int inf = 1e9 + 7;
const LL infLL = 1e18 + 100;
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );

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

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafCLover

  int n; cin >> n;
  vector<pair<int, int> > a(n);
  vector<int> com;
  int lim = inf;
  for (auto &i : a) {
    cin >> i.first >> i.second;
    if (i.first > i.second) swap(i.first, i.second);
    com.emplace_back(i.first);
    com.emplace_back(i.second);
    asMn(lim, i.second);
  }
  sort(all(com) ); com.erase(unique(all(com) ), com.end() );

  multiset<int> r, b;
  for (const auto &i : a) {
    r.emplace(i.second);
    b.emplace(i.first);
  }

  vector<int> sorI(n); iota(all(sorI), 0);
  sort(all(sorI), [&](const int &i, const int &j) {
       return a[i].first < a[j].first;
       });
  LL ans = infLL;
  for (const auto &mnB : com) {
    if (mnB > lim) break ;
    static auto i = sorI.begin();
    while (i != sorI.end() && a[*i].first < mnB) {
      r.erase(r.find(a[*i].second) ); r.emplace(a[*i].first);
      b.erase(b.find(a[*i].first) ); b.emplace(a[*i].second);
      ++i;
    }
    asMn(ans, (LL)(*r.rbegin() - *r.begin() ) * (*b.rbegin() - *b.begin() ) );
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 22896
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 998244353;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e5+5;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1e7;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
int power(int x,int y){
    int res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST  
    int n,k;
    cin>>n>>k;
    int a[n+2],prod[n+2];
    prod[0]=1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=k+1;i<=n;i++){
        if(a[i]>a[i-k]) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 4428
N = int(input())
A = list(map(int, input().split()))
a = A.copy()
for i in range(N):
    a[i] = a[i] -i-1
B = sorted(a)
# print(a)
if N%2==1:
    med = B[N//2]
else:
    med = (B[N//2]+B[N//2-1])//2

    
# print(med)
ans = 0
for i in range(N):
    ans += abs(a[i]-(med))
print(ans)

Measured memory_bytes: 30888
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <cstdlib>

int dx[8] = {1, 2, 1, 2, -1, -2, -1, -2}, dy[8] = {2, 1, -2, -1, -2, -1, 2, 1};

int main() {

	int n; cin >> n;
	long long int taka, ao;

	for(int i = 0; i < n; i++) {
		int t, a; cin >> t >> a;
		if(i == 0) { taka = t; ao = a;}
		else {
			long long int new_taka, new_ao;
			if(taka%t == 0) new_taka = taka;
			else new_taka = (taka+t-taka%t);
			if(ao%a == 0) new_ao = ao; 
			else new_ao = (ao+a-ao%a);
			if(new_ao /a*t > taka && new_taka/t*a > ao) { taka = min(new_taka, new_ao/a*t); }
			else taka = max(new_taka, new_ao/a*t);
			if(taka == new_taka) ao = new_taka/t*a;
			else ao = new_ao;
		}
		//cout << taka << ao <<endl;
	}
	cout << taka+ao <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define int long long
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
#define infi INT_MAX
#define rinfi INT_MIN
#define inf LLONG_MAX
#define rinf LLONG_MIN
#define ff first
#define ss second
using namespace std;
main()
{
    //fast
    int tc=1,i,j,k;
//    cin>>tc;
    while(tc--)
    {
      int a,b,x,y;
      cin>>a>>b>>x>>y;
     int ans=min(a,b)*x;
     if(a<=b)
        cout<<ans<<endl;
     else ans+=(a-b)*y, cout<<ans<<endl;

    }
}




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

const ll MOD = 1e9 + 7;

int main() {
    int N; cin >> N;
    vector<int> C(1);
    cin >> C[0];
    for (int i = 1; i < N; i++) {
        int c; cin >> c;
        if (C[C.size()-1] != c) C.push_back(c);
    }
    N = C.size();
    map<ll, ll> cnt;
    vector<ll> dp(N+1); dp[0] = 1;
    for (int i = 1; i < N+1; i++) {
        dp[i] = dp[i-1] + cnt[C[i-1]];
        dp[i] %= MOD;
        cnt[C[i-1]] = dp[i];
    }

    cout << dp[N] % MOD << endl;
}


Measured memory_bytes: 15092
import java.util.*;

public class Main {
  /**
   * Iterate through each line of input.
   */
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int count = 1;
    int div = 0;
    char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray(); 
    String ans = "";
    String dst = "";
    
    while(true) {
    	div = (int) (n % 26);
    	if(div == 0) {
    		div = 26;
    		n--;
    	}
    	ans = ans + alphabet[div-1];
    	
    	if(n / 26 == 0) {
    		StringBuffer sb = new StringBuffer(ans);
    		dst = sb.reverse().toString();
    		break;
    	}
    	
    	n = (long) (n / 26);
    	if(n == 0) {
    		StringBuffer sb = new StringBuffer(ans);
    		dst = sb.reverse().toString();
    		break;
    	}
    }
    System.out.println(dst);
  }
}

Measured memory_bytes: 38632
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, X, M;
int memo[101010], seen[101010], num[101010];
int loop = INF, loop_val;

void solve() {
    int ans = 0;
    int A = X;
    A %= M;
    int c = 0;
    while (N) {
        if (N % loop == 0) {
            int cnt = N / loop;
            N -= loop * cnt;
            ans += cnt * loop_val;
        } else {
            ans += A;
            if (seen[A]) {
                loop = num[A] - c;
                loop_val = memo[A] - ans;
            }
            num[A] = c;
            seen[A] = 1;
            memo[A] = ans;
            A = A * A;
            A %= M;
            N--;
            c++;
        }
    }
    cout << ans << endl;
}

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

    cin >> N >> X >> M;

    solve();
    return 0;
}


Measured memory_bytes: 5920
n, k = map(int, input().split())
P =list(map(int, input().split()))

P = [(p+1)/2 for p in P]

from itertools import accumulate
Q = [0]+P
Q = list(accumulate(Q))

ans = 0
for i in range(n-k+1):
    ans = max(ans, Q[i+k]-Q[i])
print(ans)


Measured memory_bytes: 83592
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
h=list(map(int,input().split()))
lst=[0]*n
for i in range(n-1):
    if h[i+1]<=h[i]:
        lst[i+1]=lst[i]+1
    else:
        lst[i+1]=0
# print(lst)
print(max(lst))

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

int main(){
  std::vector<int> v(4);
  for(int i =0;i<4;i++){
    std::cin >> v[i];
  }

  int t_life = v[0];
  int t_atack = v[1];
  int a_life = v[2];
  int a_atack = v[3];


  while(1){
    a_life -= t_atack;
    if (a_life <= 0){
      printf("Yes");
      return 0;
    }

    t_life -= a_atack;
    if(t_life <= 0){
      printf("No");
      return 0;
    }

  }

  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int d=10; d>=0; d--){
                if( (i&(1<<d)) != (j&(1<<d)) ){
                    A[i][j] = d;
                    break;
                }
            }
        }
    }
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            cout << A[i][j]+1 << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 1536
"""
方針:累積和(0初期化配列のやりかた), 最後が0終わりのケア, 累積和の範囲
"""

N, K = map(int, input().split())
S = str(input())

# まず'1'の塊, '0'の塊をカウントしていく
L = [0]
tmp = '1'
for i in range(N):
    if tmp != S[i]:
        L.append(1)
    else:
        L[-1] += 1
    tmp = S[i]
# こうすることでLのカウントは必ず'1'の文字を数え上げた値からスタートする
# 最初が'0'ならLは[0('1'は存在していないから0), 0を数えあげた値, hogehoge]って進んでいく

# 最後が'0'のときをケアする必要がある
if tmp == '0':
    L.append(0)  # 最後が'0'であり'1'が存在しない、つまり0を追加する
# Lが完成した

# print(len(L)), Lは絶対に奇数個になっている。'1'カウントスタート, '1'カウントエンド

# 最速で終わらせる方法の判定
M = len(L)
if int(M/2) <= K:
    print(N)
    exit()

X = [0 for _ in range(M+1)]

for i in range(M):
    X[i+1] = X[i] + L[i]
# Xが完成した

ans = 0
for i in range(0, M-K*2, 2):
    ans = max(ans, X[i+K*2+1]-X[i])

print(ans)


Measured memory_bytes: 7880
n, k = list(map(int, input().split(' ')))
orig_a = input()
acs = {}
for i in range(n):
  if i < 1:
    acs[i] = 0
  else:
    acs[i] = acs[i-1] + (orig_a[i-1: i+1] == 'AC')
for _ in range(k):
  s, e = list(map(int, input().split(' ')))
  print(acs[e-1] - acs[s-1])


Measured memory_bytes: 17992
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] cnt = new long[5];
        for(int i = 0; i<N; i++) {
            char c = sc.next().charAt(0);
            if(c=='M') cnt[0]++;
            if(c=='A') cnt[1]++;
            if(c=='R') cnt[2]++;
            if(c=='C') cnt[3]++;
            if(c=='H') cnt[4]++;
        }

        long sum = 0;
        for(int i = 0; i<3; i++) {
            for(int j = i+1; j<4; j++) {
                for(int k = j+1; k<5; k++) {
                    sum +=  cnt[i]*cnt[j]*cnt[k];
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 45592
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;


const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
vector<vector<int>>field;
int memo[50][50][1010][4];
string order;
int a = 0;
int nx, ny,way=3;
int turn = 0;
int aans = 0;
bool getcond(bool valid) {
	bool rev = false;
	if (order[a] == '~') {
		a++;
		rev = true;
	}
	bool ans;
	switch (order[a]) {
	case 'N':
		ans= way == 3;
		break;
	case 'E':
		ans = way == 2;
		break;

	case 'S':
		ans = way == 1;
		break;

	case 'W':
		ans = way == 0;
		break;

	case 'C':
		ans = !field[ny + dy[way]][nx + dx[way]];
		break;

	case 'T':
		ans = true;
		break;
	default:
		assert(false);
	}
	a++;
	if (rev)ans=!ans;
	 return ans;
}
void getmove(bool valid) {
	if (valid) {
		turn++;
		switch (order[a]) {
		case '^':
			if (field[ny + dy[way]][nx + dx[way]]) {
				ny += dy[way];
				nx += dx[way];
			}
			break;
		case 'v':
			if (field[ny - dy[way]][nx - dx[way]]) {
				ny -= dy[way]; 
				nx -= dx[way];
			}
			break;
		case '<':
			way = (way + 1) % 4;
			break;
		case '>':
			way = (way +3) % 4;
			break;
		default:
			assert(false);
		}
		//cout << "y:" << ny << " x:" << nx << "way:" << way << endl;
		a++;
		if (field[ny][nx] == 2) {
			aans = turn;
			throw(false);
		}
		else {
			return;
		}
		
	}
	a++;
	return ;
}
void getpro(bool valid);
void getif(bool valid) {
	assert(order[a] == '[');
	a++;
	bool ok = getcond(valid);
	getpro(ok&valid);
	assert(order[a] == ']');
	a++;
	return ;
}
void  getwhile(bool valid) {
	assert(order[a] == '{');
	a++;
	int pre = a;
	while (1) {
		if (valid) {
			if (memo[ny][nx][a][way] <= turn) {
				aans = -1;
				throw(false);
			}
			else {
				memo[ny][nx][a][way] = turn;

			}
		}
		
		a = pre;
		bool ok = getcond(valid);
		getpro(valid&ok);
		if (!ok)break;
		if (!valid)break;
	}
	assert(order[a] == '}');
	a++;
}
void getexpr(bool valid) {
	if (order[a] == '[') {
		getif(valid);
	}
	else if (order[a] == '{') {
		getwhile(valid);
	}
	else {
		getmove(valid);
	}
}
void getpro(bool valid) {
	while (1) {
		if (order[a] == ']' || order[a] == '}')break;
		getexpr(valid);
		if (a == order.size())break;
	}
	
}
int main() {
	for (int i = 0; i < 50; ++i) {
		for (int j = 0; j < 50; ++j) {
			for (int t = 0; t < 1010; ++t) {
				for (int w = 0; w < 4; ++w) {

					memo[i][j][t][w] = 1e9;
				}
			}
		}
	}
	int H, W; cin >> H >> W;
	field.resize(H);
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		field[i].resize(W);
		for (int j = 0; j < W; ++j) {
			if (st[j] == '#') {
				field[i][j] = 0;
			}
			else if (st[j] == '.') {
				field[i][j] = 1;
			}
			else if (st[j] == 's') {
				field[i][j] = 1;
				nx = j; ny = i;
			}
			else {
				assert(st[j] == 'g');
				field[i][j] = 2;
				
			}
		}
	}
	cin >> order;
	try {
		getpro(true);
		if (aans == 0)aans = -1;
	}
	catch (...) {
		if (aans == 0) {
			aans = -1;
		}
	}
	cout << aans << endl;
	return 0;
}

Measured memory_bytes: 42768
import java.util.*;
 
public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		String step = sc.next();
      	for(int i = 0; i < step.length(); i++){
        	if(i%2 == 0){
            	if(step.charAt(i) == 'L'){
                	System.out.println("No");
                  	break;
                }
            }else if(i%2 == 1){
            	if(step.charAt(i) == 'R'){
                	System.out.println("No");
                  	break;
                }
            }
            if(i == step.length()-1){
            	System.out.println("Yes");
            }
        }
      	
	}
}

Measured memory_bytes: 22100
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        r: usize
    }
    println!("{}", 3 * r * r);
}


Measured memory_bytes: 4352
#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 = 200'001;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  int64 a, b;
  cin >> a >> b;
  map<int64, int> mp1, mp2;
  for (int64 i = 2; i * i <= a; ++i) {
    while (a % i == 0) {
      a /= i;
      ++mp1[i];
    }
  }
  for (int64 i = 2; i * i <= b; ++i) {
    while (b % i == 0) {
      b /= i;
      ++mp2[i];
    }
  }
  if (a > 1) ++mp1[a];
  if (b > 1) ++mp2[b];
  int ans = 1;
  for (auto& pr : mp1) {
    if (mp2[pr.first]) {
      ++ans;
    }
  }
  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
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

vector<int> vec;

int main(){
  REP(i,3){
    int a;
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end());
  cout << abs(vec[0]-vec[2]) <<endl;
}


Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    s = input()
    if s[0] == "R":
        if s[1] == "R":
            if s[2] == "R":
                print(3)
            else:
                print(2)
        else:
            print(1)
    elif s[1] == "R":
        if s[2] == "R":
            print(2)
        else:
            print(1)
    elif s[2] == "R":
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()

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

int main() {
  
  vector<int> mat;
  mat = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int K;
  cin >> K;
  
  int num = mat.at(K-1);
  
  cout << num << endl;;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve() {
	ll a;
	double b;
	cin >> a >> b;
	cout << (ll) (a * (ll)(b * 100 + 0.5)) / 100;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i, n) {
        cin >> d[i];
    }
    sort(ALL(d));
    if (d[n / 2] == d[n / 2 - 1]) {
        cout << 0 << endl;
    } else {
        cout << d[n / 2] - d[n / 2 - 1] << endl;
    }
}


Measured memory_bytes: 640
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


list = make_divisors(n)
min = 1e13
for i in list:
    if n//i+i < min:
        min = n//i+i

print(min-2)

Measured memory_bytes: 3264
//前向星+SPFA
/*
edeg[]: 邻接表
dis[]: 最短路数组
vis[]: 出入队标记数组
cnt[]: 入队次数统计
head[u]:表示起点为u的最后一条边的标号，如果是-1表示没有以u为起点的边
init::初始化边
add::(u起点, v终点, w权值)
spfa::(s起点，n点数)[-1存在负环，反之为到点n最短路权值]

*/
#include<iostream>
#include<queue>
#include<algorithm>
#include<string.h>
#define N 100005
#define INF 0x3f3f3f3f
using namespace std;
struct Edge
{
	int to;
	int next;//表示和该边有共同起点的上一条边的标号
	int val;
}edge[500000];
int tot;
int head[N];
int dis1[N];
int dis2[N];
int vis[N];
int cnt[N];
void init()
{
	tot=0;
	for(int i=0;i<N;i++)
	head[i]=-1;
	memset(vis,0,sizeof(vis));
	memset(cnt,0,sizeof(cnt));
	
}
void add(int u,int v,int w)
{
	edge[tot].to=v;
	edge[tot].val=w;
	edge[tot].next=head[u];
	head[u]=tot++;
}
int spfa1(int s,int n)
{
	queue<int> q;
	for(int i=1;i<=n;i++)
	{
		vis[i]=0;
		cnt[i]=0;
		dis1[i]=INF;
	}
	cnt[s]=1;
	vis[s]=1;
	dis1[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=head[u];i!=-1;i=edge[i].next)
		{
			int v=edge[i].to;
			int w=edge[i].val;
			if(dis1[u]+w<dis1[v])
			{
				dis1[v]=dis1[u]+w;
				if(!vis[v])
				{
					vis[v]=1;
					if(++cnt[v]>n) return -1;
					q.push(v);
				}
			}
		}
	}
	return dis1[n];//默认返回最后一个点最短距离，可更改
}
int spfa2(int s,int n)
{
	queue<int> q;
	for(int i=1;i<=n;i++)
	{
		vis[i]=0;
		cnt[i]=0;
		dis2[i]=INF;
	}
	cnt[s]=1;
	vis[s]=1;
	dis2[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		vis[u]=0;
		for(int i=head[u];i!=-1;i=edge[i].next)
		{
			int v=edge[i].to;
			int w=edge[i].val;
			if(dis2[u]+w<dis2[v])
			{
				dis2[v]=dis2[u]+w;
				if(!vis[v])
				{
					vis[v]=1;
					if(++cnt[v]>n) return -1;
					q.push(v);
				}
			}
		}
	}
	return dis2[n];//默认返回最后一个点最短距离，可更改
}
int n;
int main()
{
	init();
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		add(a,b,1);
		add(b,a,1);
	}

	spfa1(1,n);
	spfa2(n,n);
	int s=0;
	for(int i=1;i<=n;i++)
	if(dis1[i]<=dis2[i])
	s++;

	/*
for(int i=1;i<=n;i++)
	cout<<"dis1: "<<dis1[i]<<" dis2: "<<dis2[i]<<endl;*/
	if((s-1)>=(n-s))
	cout<<"Fennec"<<endl;
	else
	cout<<"Snuke"<<endl;
	return 0;
	
}




Measured memory_bytes: 6400
import sys
input = sys.stdin.readline
from collections import *
from bisect import *

s = input()[:-1]
t = input()[:-1]
idx = defaultdict(list)

for i in range(len(s)):
    idx[s[i]].append(i)

now = -1
cnt = 0

for i in range(len(t)):
    if t[i] not in idx:
        print(-1)
        exit()
        
    mark = bisect_right(idx[t[i]], now)
    
    if mark==len(idx[t[i]]):
        now = idx[t[i]][0]
        cnt += 1
    else:
        now = idx[t[i]][mark]
    
print(len(s)*cnt+now+1)

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

typedef struct{
  double x;
  double y;
}Point;

void kock(int n,Point p1,Point p2){
  Point s,t,u;
  double th=M_PI*60.0/180.0;

  if(n == 0)
  return;

  s.x=(p2.x+2*p1.x)/3;
  s.y=(p2.y+2*p1.y)/3;
  t.x=(2*p2.x+p1.x)/3;
  t.y=(2*p2.y+p1.y)/3;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;



  kock(n-1, p1, s);
  printf("%.8f %.8f\n",s.x,s.y);
  kock(n-1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  kock(n-1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  kock(n-1, t, p2);
}

int main(){
  int n;
  Point p1={0,0},p2={100,0};
  scanf("%d",&n);

  printf("%.8f %.8f\n",p1.x,p1.y);
  kock(n, p1, p2);
  printf("%.8f %.8f\n",p2.x,p2.y);

  return 0;
}



Measured memory_bytes: 2064
import java.util.*;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long x = scan.nextLong();
		long range = 0;
		for(int i = 1; ; i++) {
			range+=i;
			if(range>=x) {
				System.out.println(i);
				return;
			}
		}
	}
}


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

int main() {
    int N, Y;
    cin >> N >> Y;

    int a=-1;
    int b=-1;
    int c=-1;

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

            int o_left = N - i - j;

            int total = 10000*i + 5000*j + 1000*o_left;
            if (total == Y && o_left >= 0) {
                // cout << total << endl;
                a = i;
                b = j;
                c = o_left;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin>>N;
    vector<int> A(N+1);
    vector<int> ans(N+1);
    for(int i=2;i<=N;i++)
    {
        cin>>A.at(i);
    }
    for(int i=2;i<=N;i++)
    {
        ans.at(A.at(i))++;
    }
    for(int i=1;i<=N;i++)
    {
        cout<<ans.at(i)<<endl;
    }
 
return 0;
 
 
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long double ld;

int main() {
    int n;
    cin >> n;
    vector<vector<ld>> city(n, vector<ld>(2));
    for (int i = 0; i < n; i++)cin >> city[i][0] >> city[i][1];

    ld ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ld now = sqrt(pow(city[i][0] - city[j][0], 2) + pow(city[i][1] - city[j][1], 2));
            ret += now * 2.0 / n;
        }
    }
    cout << fixed << setprecision(15) << ret << endl;
    return 0;
}

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

int main() {

  string s;
  cin >> s;

  vector<int> count(26);
  for (int i = 0; i < s.size(); i++) {
    count[s[i] - 'a']++;
  }

  string answer = "yes";

  for (int i = 0; i < 26; i++) {
    if (1 < count[i]){
      answer = "no";
      break;
    } 
  }

  cout << answer << endl;

}

Measured memory_bytes: 256