akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

struct s_t{
  string a,b;
};

bool operator<( const s_t& left, const s_t& right ) {
  return left.a == right.a ? left.b < right.b : left.a < right.a;
}

bool operator>( const s_t& left, const s_t& right ) {
  return left.a == right.a ? left.b > right.b : left.a > right.a;
}

bool operator==( const s_t& left, const s_t& right ) {
  return (left.a == right.a) && (left.b == right.b);
}


int main(){
  int n;
  ll ans=0;
  string ss,ss1,ss2;
  cin>>n;
  cin>>ss;
  vector<s_t> s1,s2;
  s_t st;
  for(int i=0;i<n;i++){
    ss1.push_back(ss[i]);
  }
  for(int i=n;i<2*n;i++){
    ss2.push_back(ss[i]);
  }
  for(int i=0;i<(1<<n);i++){
    string p="";
    string q="";
    for(int j=0;j<n;j++){
      if(i&(1<<j)) p.push_back(ss1[j]);
      else q.push_back(ss1[j]);
    }
    reverse(q.begin(),q.end());
    st.a=p+q;
    st.b=p;
    s1.push_back(st);
  }
  for(int i=0;i<(1<<n);i++){
    string p="";
    string q="";
    for(int j=0;j<n;j++){
      if(i&(1<<j)) p.push_back(ss2[j]);
      else q.push_back(ss2[j]);
    }
    reverse(q.begin(),q.end());
    st.a=q+p;
    st.b=q;
    s2.push_back(st);
  }
  sort(s1.begin(),s1.end());
  sort(s2.begin(),s2.end());
  ll p,q;
  p=0;
  q=0;
  while(p<(int)s1.size()&&q<(int)s2.size()){
    if(s1[p]==s2[q]){
      ll a1=1;
      ll a2=1;
      ll i=1;
      while(p+i<(int)s1.size()&&s1[p+i]==s2[q]){
        i++;
        a1++;
      }
      i=1;
      while(q+i<(int)s2.size()&&s2[q+i]==s1[p]){
        i++;
        a2++;
      }
      p+=a1;
      q+=a2;
      ans+=a1*a2;
    }
    else if(s1[p]<s2[q]){
      p++;
    }
    else if(s1[p]>s2[q]){
      q++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 72684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int intx = 0;
		int intCount = 0;

		try {

			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while(true){
				String strline = br.readLine();

				if (strline != null) {
					intx = Integer.parseInt(strline);
					if (1 <= intx && intx <= 10000) {
						//??¶??°?????§????????¨
						intCount++;

						//??????
						System.out.println("Case " +  intCount + ": " + intx);
					}else{
						break;
					}
				}else{
					break;
				}
			}
			/*for (int i = 0; i < 10000; i++) {

				//??\????????????
				BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
				String strInput = strLine.readLine();

				intx = Integer.parseInt(strInput);

				if (1 <= intx && intx <= 10000) {
					//??¶??°?????§????????¨
					intCount++;

					//??????
					System.out.println("Case " +  intCount + ": " + intx);
				}else{
					break;
				}
			}*/
			//System.out.println(intCount);
		}catch (IOException e1) {
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}
	}

}

Measured memory_bytes: 31828
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+ 1,m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

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

    string s,m;

    cin >> s >> m;

    if (s[0]==m[2]&&s[1]==m[1]&&s[2]==m[0]){
        cout << "YES";

    }
    else{
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#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)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int D,G;
    cin >> D >> G;
    vector<int>p(D);
    vector<int>c(D);

    rep(i,D){
        cin >> p[i] >> c[i];
    }

    int ans=10000000;

    for(int mask=0;mask<(1<<D); ++mask){
        int s=0, num=0, rest_max=-1;
        for(int i=0; i<D; ++i){
            if(mask >> i & 1){
                s += 100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s < G){
            int s1 = 100*(rest_max+1);
            int need = (G-s+s1-1)/s1;
            if(need >= p[rest_max]){
                continue;
            }
            num+=need;
        }
        ans = min(ans,num);
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>

using namespace std;

int prime[999999];
bool is_prime[1000000];

int sieve(int n){
  int p=0;
  for(int i=0; i<=n; i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2; i<=n; i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
    }
  }
  return p;
}

int main(){

int n;

while(cin>>n){
  cout<<sieve(n)<<endl;
}

}

Measured memory_bytes: 2444
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


long int gcd(long int a, long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

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

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


int main(void){
  int n,t,a;
  scanf("%d%d%d",&n,&t,&a);
  int min=1e8;
  int ans=0;
  for(int i=0;i<n;i++){
    int h,dif;
    scanf("%d",&h);
    dif=1000*t-6*h-1000*a;
    if(dif<0){
      dif*=-1;
    }
    if(dif<min){
      min=dif;
      ans=i+1;
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> p(M+1);
  p.at(0)=-1;
for (int i=1;i<=M;i++) {
  cin>>p.at(i);
}
  int a=0;
  if(M!=0){
    a++;
  }
  vector<int> z(N+1);
  z.at(0)=1;
  z.at(1)=1;
  if(p.at(a)==1){
    z.at(1)=0;
    if(M!=1){
      a++;
    }
  }
  
  for(int i=2;i<=N;i++){
    if(p.at(a)==i){
      z.at(i)=0;
      if(a!=M){
        a++;
      }
    }
    else{
      z.at(i)=(z.at(i-1)+z.at(i-2))%1000000007;
    }
  }
  cout<<z.at(N)<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*d, max(b*c, max(b*d, a*c))) << endl;
}

Measured memory_bytes: 3644
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def Turn(s):
  if s == 'a':
    return 1
  elif s == 'b':
    return 2
  else:
    return 3
  
def main():
  a = input()
  b = input()
  c = input()
  turn = 1 # first_A_! A:1, B:2, C:3
  
  while True:
    if turn == 1:
      if len(a) != 0:
        turn = Turn(a[0])
        a = a[1:]
        #print(a)
      else:
        print('A')
        exit()
    elif turn == 2:
      if len(b) != 0:
        turn = Turn(b[0])
        b = b[1:]
      else:
        print('B')
        exit()
    else:
      if len(c) != 0:
        turn = Turn(c[0])
        c = c[1:]
      else:
        print('C')
        exit()
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,*a,*b;
    cin>>n;
    a = (int*)malloc(sizeof(int)*n);
    b = (int*)malloc(sizeof(int)*n);
    int i;
    for(i=0; i<n; i++)
        cin>>a[i];
        for(i=0; i<n; i++)
            b[i] = a[i];
    sort(a,a+n);
    for(i=0; i<n; i++)
    {
        if(b[i]!=a[n-1])
            cout<<a[n-1]<<endl;
        else
            cout<<a[n-2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var a = int.Parse(Console.ReadLine().Replace(" ", ""));
        var sqrta = (int)(Sqrt(a));
        Console.WriteLine(sqrta * sqrta == a ? "Yes" : "No");
    }
}


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

int main() {
  int N, T;
  cin >> N >> T;
  int A, B[N], m, M = 0;
  cin >> m;
  for (int i=1; i<N; i++) {
    cin >> A;
    B[i] = A - m;
    m = min(m, A);
    M = max(M, B[i]);
  }
  int ans = 0;
  for (int i=1; i<N; i++)
    if (B[i] == M)
      ans++;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S[100010];
  for (int i = 0; i < N; i++) cin >> S[i];

  long long cnt[10] = {};
  string str = "MARCH";
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 5; j++) {
      if (S[i][0] == str[j]) cnt[j]++;
    }
  }

  long long ans = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        long long tmp = cnt[i] * cnt[j] * cnt[k];
        ans += tmp;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <iomanip>
#include <queue>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;
const ll MOD = 1e9 + 7;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//-----------------------------------------------------------//

int main() {
    init();
    int N;
    cin>>N;
    bool f=false;
    rep(i,N){
    	int a;cin>>a;
    	if(a%2==1){
    		f=true;
    		break;
    	}
    }
    if(f)cout<<"first"<<endl;
    else cout<<"second"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

if n.odd?
    puts 0
else
    d = 1
    time_of_5 = 0
    
    while 5**d * 2 <= n do
        time_of_5 += n / (5**d * 2)
        d += 1
    end
    
    puts time_of_5
end

Measured memory_bytes: 1788
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll X = 0;
	ll M = 0;
	ll Q = 0;
	//double a[100000] = {};
	//double b[100000] = {};
	//ll v[100] = {};
	ll *p, *c, *d;
	string S,T,U;
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;


	//char p;
	cin >>A >> B >> X;
	//cin >> D >> G;
	vector<pair<int,int>> tr(M);
	vector<pair<int,int>> qes(Q);

	if (A + B >= X && A <= X)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;


	//sort(is.begin(), is.end());
	//p = (ll *)malloc(D * sizeof(ll));
	//c = (ll *)malloc(D * sizeof(ll));
	//d = (ll *)malloc(D * sizeof(ll));

	

	
	//sort(l,l+N);


	return 0;

}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        sc.close();

        String ans = "";
        for (int i = 0; i < n.length(); i++) {
            if (n.charAt(i) == '1') {
                ans += "9";
            } else {
                ans += "1";
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 20564
#from sys import stdin
from collections import Counter
from operator import itemgetter

#input = stdin.readline

S = list(input())
T = list(input())


def main():
    C1 = Counter(S).most_common()
    C2 = Counter(T).most_common()

    if len(C1) != len(C2):
        print("No")
        return

    flg = True
    for i in range(len(C1)):
        if C1[i][1] != C2[i][1]:
            flg = False

    print("Yes" if flg else "No")
    return


main()


Measured memory_bytes: 6960
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
// const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e3 + 10;

int n, dp[N][N], lim;
string s;

int solve(int idx1, int idx2){
   if(idx1 > lim or idx2 >= n){
      return 0;
   }

   int &ans = dp[idx1][idx2];
   if(~ans)
      return ans;

   ans = 0;
   if(s[idx1] != s[idx2]){
      return ans = 0;
   }

   return ans = 1 + solve(idx1+1, idx2+1);
}

void solve0(){
   cin >> n;
   cin >> s;

   memset(dp, -1, sizeof dp);

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      for (int j = i+1; j < n; ++j)
      {
         lim = j - 1;
         smax(ans, solve(i, j));
      }
   }

   cout<<ans;
}

int32_t main(){_

   int q = 1;
   // cin >> q;

   while(q--){
      solve0();
   }

   return 0;
}

Measured memory_bytes: 98432
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll ma(ll x, ll y){
    if(x>y)return x;
    return y;
}
ll a[100000];
ll mem[100];
int k2[100];
int main(void){
    int n;
    ll k;
    scanf("%d %lld", &n, &k);
    for(int i = 0;i < n;i++){
        scanf("%lld", &a[i]);
    }
    ll sum = 0;
    for(int i = 0;i < n;i++){
        sum += a[i];
    }
    if(k!=0){
    int length = floor(log2(k))+1;
    for(int i = 0;i < length;i++){
        int count = 0;
        for(int j = 0;j < n;j++){
            count += (a[j]%(long long int)pow(2, i+1)>=pow(2, i));
        }
        if(count > n/2)mem[i] = 0;
        else mem[i] = pow(2, i) * (n - 2*count);
    }
    for(int i = 0;i < length;i++){
        k2[i] = ((k%(ll)pow(2, i+1))>=pow(2, i));
    }
    int i = length-1;
    ll pma = 0;
    for(int j = 0;j < length;j++){
       pma += k2[j]*mem[j];
    }
    while(i >= 0){
        ll plus = 0;
        if(k2[i] == 1){
            for(int j = 0;j < i;j++){
                plus += mem[j];
            }
            for(int j = i+1;j < length;j++){
                plus += k2[j]*mem[j];
            }
            pma = ma(pma, plus);
        }
        i--;
        //printf("%lld\n", plus);
    }
    printf("%lld\n", sum + pma);
    }else{
        printf("%lld\n", sum);
    }
    return 0;
}


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

int main() {
  int n,k;
  cin>>n;
  k=0;
  vector<int> a(0);
  for(int i=0;i<n;i++){
       cin>>k;
       a.push_back(k);
  }
  int alice=0;
  int bob=0;

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i%2==0){
            alice+=a[i];
        }else{
            bob+=a[i];
        }
    }

    cout<<alice-bob<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d=0,e=0;
	scanf("%d %d %d",&a,&b,&c);
	for(d=a;d<=b;d++){
		if(c%d==0){
			e++;
		}
	}
		printf("%d\n",e);
	return 0;
}

Measured memory_bytes: 596
def main():
    N, M = map(int, input().split())
    # M本買う

    shop_list = []

    for n in range(N):
        price, quantity = map(int, input().split())
        shop_list.append([price, quantity])

    shop_list = sorted(shop_list, key=lambda x: x[0])

    count = 0
    paid = 0
    for price, quantity in shop_list:
        count += quantity
        paid += price*quantity

        if count >= M:
            over_count = count - M
            count -= over_count
            paid -= over_count*price

    print(paid)


if __name__ == "__main__":
    main()


Measured memory_bytes: 21972
#include<cstdio>
#include<iostream>
#include<stack>

using namespace std;       
int main(){
  stack<int> s;
  int a;
  while(cin >> a){
    if(a != 0){
      s.push(a);
    }else if(s.size() == 0){
      break;    
    }else{
      cout << s.top()<< endl;
      s.pop();
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#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>;

ll x = 1e9 + 7; 
const int INF = 1001001001;


int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;const string table[] ={"100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000",};void out( const string &s ){int n = strtol( s.substr( 0, 5 ).c_str(), 0, 2 );if( n < 26 )putchar( n + 'A' );else putchar( " .,-'?"[n - 26] );}int main(){int c;string s;for(; c = getchar(), c != EOF; ){switch(c){case '\n':if( s.length() > 0 ){s += "0000";out(s);}puts("");s = "";break;case ' ':s += "101";break;case '\'':s += "000000";break;case ',':s += "000011";break;case '-':s += "10010001";break;case '.':s += "010001";break;case '?':s += "000001";break;default:s += table[c - 'A'];break;}while( s.length() > 4 ){out( s );s = s.substr(5);}}}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
struct circle { int x, y, r, col; };
bool con(circle a, circle b) {
	if ((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y) < (a.r + b.r)*(a.r + b.r))return true;
	return false;
}
int main() {
	int n;
	while (cin >> n, n) {
		circle a[24]; int c[24];
		rep(i, n) {
			int x, y, r, col;
			cin >> x >> y >> r >> col;
			a[i] = { x,y,r,col };
			c[i] = col;
		}
		vector<int> cov[24];
		rep(i, n) {
			Rep(j, i + 1, n) {
				if (con(a[i], a[j])) {
					cov[j].push_back(i);
				}
			}
		}
		int sta = (1 << n) - 1;
		map<int, int> used; used[sta] = 1;
		queue<int> q;
		int ma = 0;
		q.push(sta);
		while (!q.empty()) {
			int now = q.front(); q.pop();
			int del[24] = {}; vector<int>noncov;
			int cnt = 0;
			rep(k, n) {
				if (!(now&(1 << k)))del[k] = 1;
				else {
					cnt++;
				}
			}
			ma = max(ma, n - cnt);
			rep(k, n) {
				if (del[k])continue;
				int len = cov[k].size();
				bool f = true;
				rep(i, len) {
					if (!del[cov[k][i]])f = false;
				}
				if (f)noncov.push_back(k);
			}
			int len2 = noncov.size();
			rep(i, len2) {
				Rep(j, i + 1, len2) {
					if (c[noncov[i]] == c[noncov[j]]) {
						int res = now;
						res ^= (1 << noncov[i]); res ^= (1 << noncov[j]);
						if (used[res] != 1) {
							used[res] = 1; q.push(res);
						}
					}
				}
			}
		}
		cout << ma << endl;
	}
	return 0;
}



Measured memory_bytes: 52412
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cstdlib>
using namespace std;

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;

  int xdif = tx - sx;
  int ydif = ty - sy;


  for(int i = 0; i < ydif; i++){
    cout << "U";
  }
  for(int i = 0; i < xdif; i++){
    cout << "R";
  }
  for(int i = 0; i < ydif; i++){
    cout << "D";
  }
  for(int i = 0; i < xdif; i++){
    cout << "L";
  }

  cout << "L";
  for(int i = 0; i < ydif+1; i++){
    cout << "U";
  }
  for(int i = 0; i < xdif+1; i++){
    cout << "R";
  }
  cout << "D";
  cout << "R";
  for(int i = 0; i < ydif+1; i++){
    cout << "D";
  }
  for(int i = 0; i < xdif+1; i++){
    cout << "L";
  }
  cout << "U";

  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	ll n, k;

	cin>>n>>k;
	ll res = (n/k) * (n/k) * (n/k);
	if(k % 2 == 0)
	{
		n += k/2;
		res += (n/k) * (n/k) * (n/k);
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#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;
    cin >> N;
    string ans="Three";
    rep(i,N){
        char a;
        cin >> a;
        if(a=='Y'){
            ans="Four";
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    s = input()
    yyyy = int(s[:4])
    mm = int(s[5:7])
    # print(yyyy, mm)
    if (yyyy>=2019 and mm>=5):
        print("TBD")
    else:
        print("Heisei")
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 102636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
/*
int main(){
    int n;cin >> n;
    set<int> se;
    int cnt=0;
    rep(i,n){
        int a;
        cin >> a;
        a /= 400;
        if(a>8) a = 8;
        if(a>=8) cnt++;
        se.insert(a);
    }

    int ansmin = se.size();
    if(cnt>=1) ansmin--;
    if(ansmin==0) ansmin++;
    int ansmax = se.size();
    if(cnt>=1) ansmax += cnt - 1;
    if(ansmax >= 8) ansmax = 8;
    cout << ansmin << " " << ansmax << endl;
}
*/

int main(){
    int n;cin>>n;
    vector<int> b(9,0);
    rep(i,n){
        int a;cin >> a;
        a /= 400;
        if(a>=8) a = 8;
        b[a]++;
    }
    int ansmin=0;
    int ansmax=0;
    rep(i,8){
        if(b[i]>=1){
            ansmin++;
            ansmax++;
        }
    }
    if(b[8]>=1){
        if(ansmin==0) ansmin = 1;
        ansmax += b[8];
        //if(ansmax>=9) ansmax = 8; 
    }
    if(ansmin==0) ansmin = 1;
    cout << ansmin << " " << ansmax <<endl;
}
// ABC064C

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

int main () {
  int n;
  cin >> n;
  cout << (n * 800 - (n / 15 * 200)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	vector<double> mpq;
	mpq.push_back(0);
	vector<double> vd;
	for(ll i=1;i<=a;i++)
	{
		ll c;
		cin>>c;
		double jk = 1.0*(c+1)/2;
		mpq.push_back(jk+mpq[i-1]);
		if(i-b>=0)
		{
			vd.push_back(mpq[i]-mpq[i-b]);
		}
	}
	double sum = 0.0;
	for(ll i=0;i<vd.size();i++)
	{
		if(sum<vd[i])
		{
			sum = vd[i];
		}
	}
	printf("%.12f",sum); 
	return 0;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main(){
char s;
int x,y,n,a[20][20],i,j,k=0,b[1000],c[1000],l;
scanf("%d\n\n",&n);
for(l=0;l<n;l++){
for(i=3;i<11;i++){
for(j=3;j<11;j++){
scanf("%c",&s);
a[i][j]=s-'0';
}
scanf("\n");
}
scanf("%d %d\n",&y,&x);
x=x+2,y=y+2;
while(1){
a[x][y]=0;
for(i=x-3;i<x+4;i++){
if(a[i][y]==1){
k++;
b[k]=i,c[k]=y;
}
}
for(i=y-3;i<y+4;i++){
if(a[x][i]==1){
k++;
b[k]=x,c[k]=i;
}
}
if(k==0){
break;
}
x=b[k],y=c[k];
k--;
}
k=0;
printf("Data %d:\n",l+1);
for(i=3;i<11;i++){
for(j=3;j<11;j++){
printf("%d",a[i][j]);
}
printf("\n");
}
}
return 0;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<62)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size
#define T ((ll)(2e12))

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n;
	cin >> n;
	cout << (n/3) << endl;
	return 0;
}


Measured memory_bytes: 256
/* ITP1_5_B */
import java.io.*;

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

    while(true){
      //input
      String str[] = br.readLine().split(" ");
      int height = Integer.parseInt(str[0]);
      int width = Integer.parseInt(str[1]);
      //finish
      if(height == 0 && width == 0) break;
      if(height < 3 && width > 100) break;
      //draw
      for(int i = 0; i < height; i++){ //height

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

          if(i == 0 || i == height-1){
            sb.append("#");

          }else {
            if(j == 0 || j== width-1)
              sb.append("#");
            else
              sb.append(".");
          }
        }
        sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a==1){
    a=14;
  }
  if(b==1){
    b=14;
  }
  if(a>b){
    cout<<"Alice"<<"\n";
  }
  else if(a<b){
    cout<<"Bob"<<"\n";
  }
  else{
    cout<<"Draw"<<"\n";
  }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> par;
int a[1<<18],n,m,bh[1<<18];
par b[1<<18];
vector<par>v[1<<18];
priority_queue<par,vector<par>,greater<par> >pq;
int main(){
	scanf("%d",&n),m=1<<n;
	for(int i=0;i<m;++i){
		bh[i]=(bh[i>>1]>>1)|((i&1)<<(n-1));
		scanf("%d",&a[i]),a[i]--;
		if(a[i]>=0)b[i]=par(a[i],a[i]);
		else b[i]=par(0,m-1);
	}
	for(int i=m-1;i>=0;--i)
		for(int j=0;j<n;++j)if(~i>>j&1)
			b[i].second=min(b[i].second,b[i^(1<<j)].second);
	for(int i=0;i<m;++i)
		for(int j=0;j<n;++j)if(~i>>j&1)
			b[i^(1<<j)].first=max(b[i^(1<<j)].first,b[i].first);
	for(int i=0;i<m;++i)
		if(b[i].first>b[i].second)return puts("NO"),0;
		else v[b[i].first].push_back(par(b[i].second,i));
	for(int i=0;i<m;++i){
		for(int j=0;j<v[i].size();++j)
			pq.push(v[i][j]);
		if(pq.empty())continue;
		if(pq.top().first<i)return puts("NO"),0;
		else a[pq.top().second]=i,pq.pop();
	}
	puts("YES");
	for(int i=0;i<m;++i)
		printf("%d ",a[bh[i]]+1);
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

int main() {
    Int n, a, b;
    cin >> n >> a >> b;
    vector<Int> x(n);
    for (Int i = 0; i < n; i++) {
        cin >> x[i];
    }
    Int res = 0;
    Int cur = x[0];
    for (Int i = 0; i < n; i++) {
        res += min((x[i] - cur) * a, b);
        cur = x[i];
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    int k;
    cin >> k;

    string s;
    cin >> s;

    int sz = (int)s.size();

    if(sz<=k) {
        cout << s << endl;
    } else {
        for (int i=0; i<k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}



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

char F[102][102];

void DFS(int Y, int X ,char c){
      if(F[Y][X]!=c)
            return;

      F[Y][X] = '.';

      DFS(Y+1, X  , c);
      DFS(Y  , X+1, c);
      DFS(Y-1, X  , c);
      DFS(Y  , X-1, c);
}

int main(){
      int H,W, cnt;
      char c;
      while(true){
            cin >> H >> W;
                  if(H==0)    break;
            for(int y=1; y<=H; y++)
                  for(int x=1; x<=W; x++)
                  cin >> F[y][x];

            cnt = 0;
            for(int y=1; y<=H; y++)
                  for(int x=1; x<=W; x++)
                  if(F[y][x]=='@' || F[y][x]=='#' || F[y][x]=='*'){
                        cnt++;
                        DFS(y, x, F[y][x]);
                  }
            cout << cnt << endl;
      }
   return 0;
}



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

using namespace std;
char c;
int main() {
	bool tag=0;
	for(int i=1; i<=3; i++) {
		cin>>c;
		if(c=='7') tag=1;
	}
	if(tag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
typedef long long ll;
ll max(ll a, ll b){ return (a>b)?a:b;}
ll min(ll b, ll a){ return (a>b)?b:a;}
int main(void){
    // Your code here!
    char S[101];
    int N;
    scanf("%d",&N);
    scanf("%s",S);
    
    int leftcount[30];
    int rightcount[30];
    

    int ans = 0;
    for(int cut = 0; cut <= N-1; cut++){
        for(int i = 0; i < 30; i++){ 
            leftcount[i] = rightcount[i] = 0;
        }
        for(int i = cut; i >= 0; i--){
            leftcount[S[i]-'a']++;
        }
        for(int i = cut+1; i < N; i++){
            rightcount[S[i]-'a']++;
        }
        
        int count = 0;
        for(int i = 0; i <= 'z'-'a'; i++){
            if(leftcount[i] != 0 && rightcount[i] != 0) count++;
        }
        if(ans < count) ans=count;
    }
    
    printf("%d\n",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define For(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}

int main(){
    int n,m;cin>>n>>m;
    int sita=0;
    int ue=1111111;
    For(i,m){
        int L,R;
        cin>>L>>R;
        sita=max(sita,L);
        ue=min(ue,R);
    }
    cout<<max(0,ue-sita+1)<<endl;
}



Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>

#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;


int main(){

    int a[3];
    rep(i,0,3)cin >> a[i];

    sort(a, a+3);
    cout << a[1]-a[0]+a[2]-a[1] << endl;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin >> a >> b;
	cout << max({2*a-1,2*b-1,a+b}) << endl;
	return 0;
}


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

    // 1項も残さない場合
    if(n == k) {
        out(0);
        re0;
    }

    // 以下1項以上残す

    vvl dp(n+1, vl(n+1, INF));  // dp[x][y] : 残った項の最も右の項の番号がx、h[1]からh[x]で残った項数がyのときのコストの最小値
    
    exrep(x, 1, n) {
        dp[x][1] = h[x];
    }
    exrep(x, 2, n) {
        exrep(y, 2, x) {
            exrep(i, 1, x-1) {
                chmin(dp[x][y], dp[i][y-1] + max(0LL, h[x] - h[i]));
            }
        }
    }
    
    ll ans = INF;
    exrep(i, 1, n) {
        chmin(ans, dp[i][n-k]);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){	

	string S;
	string x = "keyence";
	cin >> S;
	if(S == x){
		cout << "YES" << endl;
		return 0;
	}
	for(int i = 0; i < S.length(); i++){
		for(int j = i; j < S.length(); j++){
			string s = "";
			for(int k = 0; k < S.length(); k++){
				if(i <= k && k <= j){
					continue;
				} else {
					s.push_back(S[k]);
				}
			}
			if(s == x){
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;

	return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  int cnt[n][26];
  int ansCnt[26];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      cnt[i][j] = 0;
      ansCnt[j] = 2500;
    }
  }
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    for (int j = 0; j < s.length(); j++) {
      int index = s[j] - 'a';
      cnt[i][index]++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (ansCnt[j] > cnt[i][j]) {
        ansCnt[j] = cnt[i][j];
      }
    }
  }
  std::string ans = "";
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < ansCnt[i]; j++) {
      ans += ('a' + i);
    }
  }
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nk = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nk[0], K = nk[1];
    let X = lines.shift().split(/\s/).map((v) => v - 0);
let ans = 1e9;
    for (let i = 0; i < N - K+1; i++) {
       let a = Math.abs(X[i]) + X[i+K-1] - X[i];
       let b = Math.abs(X[i+K-1]) + X[i+K-1] - X[i];
      ans = Math.min(...[ans, a, b]);
    }
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27940
import sys
input = sys.stdin.readline
mod=10**9+7

N,X=map(int,input().split())
S=list(map(int,input().split()))

S.sort(reverse=True)

DP={X:1}

for i in range(N):
    s=S[i]
    
    NDP=dict()

    for d in DP:
        if d<s:
            NDP[d]=(NDP.get(d,0)+DP[d]*(N-i))%mod

        else:
            NDP[d]=(NDP.get(d,0)+DP[d]*(N-i-1))%mod
            NDP[d%s]=(NDP.get(d%s,0)+DP[d])%mod

    DP=NDP

SUM=0
for d in DP:
    SUM=(SUM+d*DP[d])%mod

print(SUM)

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 * 1000 + 13;

int n, w;
pt a[N];

bool read () {
	if (scanf("%d%d", &n, &w) != 2)
		return false;
	forn(i, n)
		scanf("%d%d", &a[i].x, &a[i].y);
	return true;
}

li dp[2][N];

void solve() {
	memset(dp, 0, sizeof(dp));
	forn(ii, n){
		int i = ii & 1;
		int ni = i ^ 1;
		memset(dp[ni], 0, sizeof(dp[ni]));
		forn(j, w + 1){
			dp[ni][j] = max(dp[ni][j], dp[i][j]);
			if (j + a[ii].x <= w)
				dp[ni][j + a[ii].x] = max(dp[ni][j + a[ii].x], dp[i][j] + a[ii].y);
		}
	}
	printf("%lld\n", dp[n & 1][w]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//最大流
struct MaxFlow {
    struct Edge {
        int to, cap, rev;
        Edge() {};
        Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {};
    };
    int V;
    vector<vector<Edge>> G;
    vector<int> used;

    MaxFlow(int V) : V(V), G(V, vector<Edge>()), used(V){}

    void add_edge(int from, int to, int cap) {
        G[from].push_back({to, cap, (int)G[to].size()});
        G[to].push_back({from, 0, (int)G[from].size() - 1});
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            Edge& e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            // memset(used, 0, sizeof(used));
            used = vector<int>(V, 0);
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};


int main(){
    int n;
    cin >> n;
    MaxFlow flow(31+n+2);
    int source = 0, sink = 31+n+2-1;
    REP(i, 1, n+1) {
        int cur = 31+i;
        int a, b;
        cin >> a >> b;
        REP(j, a, b+1) {
            flow.add_edge(cur, j, 1);
        }
        flow.add_edge(source, cur, 1);
    }
    REP(i, 1, 31 + 1) {
        flow.add_edge(i, sink, 1);
    }
    int f = flow.max_flow(source, sink);
    cout << f*100+(31-f)*50 << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>

using namespace std;
typedef long long ll;
///定義場所///
ll i, j, k, l, m, n;
ll N, M, K;
ll MOD = 1000000007;
ll ans = 1000000000;

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<ll, ll> firstElof, pair<ll, ll> secondElof)
{
	return firstElof.second > secondElof.second;
}
//////////////

int Keta(ll X) {
	int keta = 1;
	while (X / 10 > 0) {
		X /= 10;
		keta++;
	}
	return keta;
}
int main()
{
	cin >> N;
	i = 2;
	ll res = N;
	vector<ll> B;
	B.push_back(1);
	while (i*i<=N) {
		if (res % i == 0) {
			//res /= i;
			B.push_back(i);
		}
			i++;
	}
	int ans = 10000;
	for (i = 0; i < B.size(); i++) {
		ans = min(Keta(max(B[i], N / B[i])), ans);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
 int S,h,m,s;
 cin >> S;
 h=S/3600;
 m=(S-3600*h)/60;
 s=S-(3600*h+60*m);
 
 cout<<h<<":"<<m<<":"<<s<<endl;
 
 return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
long long int m=1000000007;
int main(){
  int n;
  cin>>n;
  long long int* a =new long long int[n];
  long long int s=0,t=0;
  for(int i=0;i<n;i++){
   	cin>>a[i];
    s=(s+a[i])%m;
    t=(t+(a[i]*a[i])%m)%m;
  }
  s=(s*s)%m;
  long long int ans=(s+m-t)%m;
  ans=(ans*(500000004))%m;
  cout<<ans<<endl;
}

Measured memory_bytes: 5156
function Main(input){
    input=input.split("¥n");  //ここまで必須
    var answer=input[0];

    var answerA=input[0].toUpperCase();
    if (answer==answerA){console.log("A")} else {console.log("a")}
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 29540