akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

//Concert Hall Scheduling
public class Main{

	class R implements Comparable<R>{
		int s, t, c;
		public R(int s, int t, int c) {
			this.s = s;
			this.t = t;
			this.c = c;
		}
		public int compareTo(R o) {
			return t-o.t;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int[][][] dp = new int[2][366][366];
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			R[] r = new R[n];
			for(int i=0;i<n;i++)r[i]=new R(sc.nextInt(), sc.nextInt(), sc.nextInt());
			Arrays.sort(r);
			int x = 0;
			for(int i=0;i<2;i++)for(int j=0;j<366;j++)for(int k=0;k<366;k++)dp[i][j][k]=0;
			for(int i=0;i<n;i++,x=1-x)for(int j=1;j<366;j++)for(int k=1;k<366;k++){
				int max = Math.max(dp[1-x][j][k], Math.max(dp[x][j-1][k], dp[x][j][k-1]));
				if(r[i].t==j)max = Math.max(max, dp[1-x][r[i].s-1][k]+r[i].c);
				if(r[i].t==k)max = Math.max(max, dp[1-x][j][r[i].s-1]+r[i].c);
				dp[x][j][k] = max;
			}
			System.out.println(dp[1-x][365][365]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main{


  public static void main(String[] args){
    int num_turn; //ターン数
    List<String> taro_c = new ArrayList<String>();
    List<String> hanako_c = new ArrayList<String>();

    int taro_p=0;
    int hanako_p=0;


    Scanner scan = new Scanner(System.in);
    num_turn = scan.nextInt();

    for(int i = 0; i < num_turn; i++){
      String taro_w = scan.next();
      taro_c.add(taro_w);
      String hanako_w = scan.next();
      hanako_c.add(hanako_w);

      int judge = taro_w.compareTo(hanako_w);
      //太郎があとなら+3,
      if( judge >= 1 ) taro_p += 3;
      else if( judge == 0 ) {taro_p += 1; hanako_p += 1;}
      else if( judge <= -1) hanako_p += 3;

      judge=0;
    }

    System.out.println(taro_p + " " + hanako_p);


  }

}



Measured memory_bytes: 29808
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, h; cin >> n >> h;
  vector<lint> a(n);
  vector<lint> b(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  sort(RALL(a));
  sort(RALL(b));
  
  lint ans = 0;
  for(int i = 0; i < n; i++) {
    if(b[i] < a[0]) break;
    if(h > 0) {
      ans++;
      h -= b[i];
    } else {
      break;
    }
  }
  if(h <= 0) {
    cout << ans << endl;
    return 0;
  }
  ans += (h + a[0] - 1) / a[0];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

 int main(){
     int n,s,x,i,j,count;
     int a[10000];
     int q[10000];
     x = 0;
     count = 0;
     scanf("%d",&n);
     for (i = 0; i < n; i++)
         scanf("%d", &a[i]);
     scanf("%d",&s);
     for (i = 0; i < s; i++)
         scanf("%d", &q[i]);
     for(j=0; j<s; j++) {
         for (i=0; i<n; i++){
             if (a[i] == q[j]){
                 count++;
                 break;
             }
         }
     }
     printf("%d\n",count);
     return 0;
 }


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int a[2], b[2];
	for (auto &i : a) i = ri();
	for (auto &i : b) i = ri();
	int64_t res = -1000000000000000001;
	for (auto i : a) for (auto j : b) res = std::max(res, (int64_t) i * j);
	printf("%" PRId64 "\n", res);
	return 0;
}


Measured memory_bytes: 3696
s = input()

s_len  = len(s)
mul = [1,1,2,4,8,16,32,64,128,256]

ans = 0
for i in range(s_len):
    num = int(s[(s_len-1-i)])

    temp = 0
    for j in range(i+1):
        temp += num*(10**j)*mul[(i-j)]

    ans = ans*2 + temp

print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int D;
int c[27], s[366][27];
int last[27];
long long ans = 0;
int main(){
    scanf("%d",&D);
    for (int i = 1; i <= 26; i++) scanf("%d",&c[i]);
    for (int i = 1; i <= D; i++){
        for (int j = 1; j <= 26; j++) scanf("%d",&s[i][j]);
    }
    for (int i = 1; i <= D; i++){
        int t;
        scanf("%d",&t);
        ans += s[i][t];
        last[t] = i;
        for (int j = 1; j <= 26; j++){
            ans -= c[j]*(i-last[j]);
        }
        printf("%lld\n",ans);
    }

}


Measured memory_bytes: 3900
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int n;
int X[110],Y[110];
int main(){
	cin >> n;
	double sum = 0,sum2 = 0,sum3 = 0,m = 0;
	for(int i=0;i<n;i++){
		cin >> X[i];
	}
	for(int i=0;i<n;i++){
		cin >> Y[i];
	}
	for(int i=0;i<n;i++){
		sum += abs(X[i]-Y[i]);
		sum2 += abs(X[i]-Y[i])*abs(X[i]-Y[i]);
		sum3 += abs(X[i]-Y[i])*abs(X[i]-Y[i])*abs(X[i]-Y[i]);
		if(m < abs(X[i]-Y[i])) m = abs(X[i]-Y[i]);
	}
	printf("%.6f\n",sum);
	printf("%.6f\n",sqrt(sum2));
	printf("%.6f\n",cbrt(sum3));
	printf("%.6f\n",m);
}


Measured memory_bytes: 3356
#include<stdio.h>
#include<math.h>
main(){
  int i;
  int n;
  double s[1000];
  double avarage,sum;
  while(1){
    scanf("%d",&n);
    if(n==0)
      break;
    for(i=0;i<n;i++)
      scanf("%lf",&s[i]);
    for(i=0,sum=0;i<n;i++)
      sum=sum+s[i];
    avarage=1.0*sum/n; 
    for(i=0,sum=0;i<n;i++)
      sum=sum+pow(avarage-s[i],2);
    printf("%f\n",sqrt(1.0*sum/n));
  }
  return 0;
}

Measured memory_bytes: 660
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
char a[100007];
int main(){
	cin>>a;
	int n=strlen(a);
	for(int i=0;i<n;++i){
		if(a[i]=='e' && a[i+1]=='r' && a[i+2]=='a' && a[i+3]=='s' && a[i+4]=='e'){
				if(a[i+5]=='r')i+=5;
				else i+=4;
		}
		else if(a[i]=='d' && a[i+1]=='r' && a[i+2]=='e' && a[i+3]=='a' && a[i+4]=='m'){
				if(a[i+5]=='e' && a[i+6]=='r' && a[i+7]=='a' && a[i+8]=='s' && a[i+9]=='e')i+=4;
				else{
					if(a[i+5]=='e' && a[i+6]=='r')i+=6;
					else i+=4;
				}
		}
		else{puts("NO");return 0;}
	}
	cout<<"YES"<<endl;
	return 0;
}


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

int main()
{
    int n,k,ans;

    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    //sort
    sort(h.begin(), h.end());

    ans = INT_MAX;
    for (int i = 0;i <= n - k;++i) {
        int sa = h[i + k - 1] - h[i];
        ans = min(ans, sa);
    }

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


Measured memory_bytes: 3748
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  int *A, *B;
  int C[VMAX+1];
  int n, i, j;

  

  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);
  
  /* your code */
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    
  }
  
  for(i=0;i<VMAX;i++){
    C[i] = 0;
  }
  
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
  for(i=1;i<VMAX;i++){
    C[i] = C[i] + C[i-1];
  }
  for(i=0;i<7;i++){
    // printf("%d ",C[i]);
  }
  // printf("\n");
  for(j=n-1;j>=0;j--){
    //printf("%d,",A[j]);
    B[C[A[j]]] = A[j];
    //printf("%d ",B[C[A[j]]]);
    C[A[j]]--;
  }
  // printf("\n");
  for(i=1;i<=n;i++){
    if(i !=n) printf("%d ",B[i]);
    else printf("%d",B[i]);
  }
  printf("\n");

  free(A);
  free(B);
  return 0;
}



Measured memory_bytes: 17104
#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){
  long int n;
  long int x,m;
  scanf("%ld%ld%ld",&n,&x,&m);
  if(m==1){
    printf("0\n");
    return 0;
  }
  int che[m+1];//鳩ノ巣原理判断基準の配列
  long int mod[m+1];//a[i]の余り
  for(int i=0;i<m+1;i++){
    che[i]=0;
    mod[i]=0;
  }
  long int ans=0;
  if(n<=m){  //n<=mの時はO(10^5)だからゴリゴリでできる.
    for(int i=0;i<n;i++){
      if(i==0){
        ans+=x%m;
      }else{
        ans+=x*x%m;
        x=x*x%m;
      }
    }  //ここまではok.
  }else{  //m<nの時,鳩ノ巣原理よりa[i]=a[j])i!=j)となるa[j]が存在する→a[j]の次はa[i+1],...,a[j]と繰り返す.
  long int loop=0,sta=0,fin=0,count=0,lcount=0;
    for(int i=0;i<m;i++){  //まずはa[i]=a[j](i!=j)となるものが存在しないところまでansを求める.
      if(i==0){
        x=x%m;
      }else{
        x=(x*x)%m;
      }
      che[x]++;
      mod[i]=x;
      fin=i-1;
      sta=x;  //ループは最初の値
      if(che[x]>1){
        break;
      }
    }
    for(int i=0;i<=fin;i++){
      if(mod[i]==sta){
        sta=i;
        break;
      }
    }
    for(int i=0;i<sta;i++){
      ans+=mod[i];
    }
    for(int i=sta;i<=fin;i++){
      loop+=mod[i];
      count++;
    }
    lcount=(n-(sta))/count;
    ans+=loop*lcount;
    n=(n-(sta))%lcount;
    for(int i=sta;i<sta+n;i++){
      ans+=mod[i];
    }
  }
  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 2880
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    priority_queue<long> a;
    long b;
    for (int i = 0; i < n; i++)
    {
        cin >> b;
        a.push(b);
    }
    long p = a.top();
    long q;
    a.pop();
    while (!a.empty())
    {
        q = a.top();
        if (p==q)
        {
            cout << "NO" << endl;
            return 0;
        }
        p = q;
        a.pop();
    }
    cout << "YES" << endl;
    return 0;
}

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

/*int main(void)
{
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int a = 0; a <= k; a++)
    {
        for (int b = 0; b <= k; b++)
        {
            for (int c = 0; c <= k; c++)
            {
                if ((a+b+c) == s)
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}*/

int main(void)
{
    int k, s;
    cin >> k >> s;

    int ans = 0, a = 0;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            a = s - (i + j);
            if (a >= 0 && a <= k)
            {
                ans++;
            }      
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l=[0]*100
l[0]=2
l[1]=1
def ryuka(x):
    r = 0
    for i in range(2,x+1):
        l[i]=l[i-1]+l[i-2]
    return l[i]
if n==1:
    print(1)
    exit()
else:
    print(ryuka(n))

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#define ll long long int
ll a[20];
ll vis[20];
ll n,k;
ll output;
void Dfs(ll u)
{
    if(u==n+1)
    {
        ll b[20];
        ll cnt=0;
        ll pre=a[1];
        for(ll i=1;i<=n;i++)if(vis[i]==1)cnt++;
        for(ll i=1;i<=n;i++)b[i]=a[i];
        if(cnt==k)
        {
            ll sum=0;
            for(ll i=2;i<=n;i++)
            {
                if(vis[i]==1)
                {
                    if(b[i]>pre)pre=b[i];
                    else
                    {
                        sum+=pre+1-b[i];
                        b[i]=pre+1;
                        pre=b[i];
                    }
                }
                else pre=max(pre,b[i]);
            }
            ll look=1;
            for(ll i=2;i<=n;i++)
            {
                ll flag=0;
                for(ll j=1;j<i;j++)
                {
                    if(b[j]>b[i])flag=1;
                }
                if(flag==0)look++;
            }
            if(look==k)
            {
                output=min(output,sum);
            }
        }
        return ;
    }
    vis[u]=1;
    Dfs(u+1);
    if(u!=1)
    {
        vis[u]=0;
        Dfs(u+1);
    }
}
int main()
{
    while(~scanf("%lld%lld",&n,&k))
    {
        output=2000000000000000000;
        memset(vis,0,sizeof(vis));
        for(ll i=1;i<=n;i++)scanf("%lld",&a[i]);
        Dfs(1);
        printf("%lld\n",output);
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        var abc = Console.ReadLine().Split();
        var a = int.Parse(abc[0]);
        var b = int.Parse(abc[1]);
        var c = int.Parse(abc[2]);

        var x = Math.Min(a - b, c);
        Console.WriteLine(c - x);
    }
}


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

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

const int MAX_N = 100010;

int N;
int a[MAX_N];
int x[MAX_N];

int main() {
  N = in();
  REP(i,N) a[i] = in();

  for (int i = 0; i < N; i++) {
    int t = a[i];
    if (0 <= t - 1) x[t - 1]++;
    x[t]++;
    x[t+1]++;
  }

  int mx = 0;
  for (int i = 0; i < MAX_N; i++) chmax(mx, x[i]);
  cout << mx << endl;

  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
  using namespace std;
  #define ll  long long int
  #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
  int main()
  {

  

    fastio; 
    long double  n,x,t;
    cin>>n>>x>>t;
    ll z=ceil(n/x);
    cout<<(ll)(z*t);




  return 0;   
  }

Measured memory_bytes: 3704
#include<iostream>

using namespace std;

int main(void)

{
    int n,i,a,f=0;
    cin>>n;
    for(i = 0; i < n; i++){
        cin>>a;
        if(a%2==0&&f==0){
            if(a%3==0||a%5==0){
                f = 0;
            }
            else{
                f = 1;
            }
        }
    }
    if(f==0){
        cout<<"APPROVED\n";
    }
    else{
        cout<<"DENIED\n";
    }
    return 0;
}


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

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

    int n;
    cin >> n;

    int coin = 0;
    coin += n / 25;
    n %= 25;

    coin += n / 10;
    n %= 10;

    coin += n / 5;
    n %= 5;
    coin += n;

    cout << coin << endl;
    return 0;
}


Measured memory_bytes: 3216
def isPrime(x):
  for i in range(2, int(x**0.5)+1):
    if x % i == 0:
      return False
  return True

dp = [0] * 10**5
for i in range(3, 10**5, 2):
  if isPrime(i) and isPrime((i+1)//2):
    dp[i] = dp[i-2] + 1
  else:
    dp[i] = dp[i-2]

Q = int(input())
for i in range(Q):
  l,r = map(int,input().split())
  print(dp[r] if l==1 else dp[r]-dp[l-2])


Measured memory_bytes: 51936
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};

int main()
{
    int h, w;
    cin >> h >> w;
    int ch, cw;
    cin >> ch >> cw;
    int dh, dw;
    cin >> dh >> dw;
    --ch;
    --cw;
    --dh;
    --dw;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    G dist(h, vector<int>(w, INF));
    deque<P> q;
    dist[ch][cw] = 0;
    q.emplace_back(ch, cw);
    while(!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        rep(v, 4) {
            int ni = i + di[v];
            int nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ++ei) {
            for(int ej = -2; ej <= 2; ++ej) {
                int ni = i + ei;
                int nj = j + ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d + 1) continue;
                dist[ni][nj] = d + 1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[dh][dw];
    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9472
def resolve():
    N = int(input())
    W = []
    for _ in range(N):
        w = input()
        W.append(w)
    ans = [W[0]]
    for i in range(N-1):
        if ans.count(W[i+1]) != 0 or ans[i][-1] != W[i+1][0]:
            print("No")
            exit()
        else:
            ans.append(W[i+1])
    print("Yes")
resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector< vector<int> > data(n + 1, vector<int>(n + 1));
		int sum = 0;
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				cin >> data[i][j];
			}
			int row_sum = 0;
			for(int j = 0; j < n; ++j)
			{
				row_sum += data[i][j];
			}
			data[i][n] = row_sum;
			sum += row_sum;
		}
		data[n][n] = sum;
		for(int i = 0; i < n; ++i)
		{
			int column_sum = 0;
			for(int j = 0; j < n; ++j)
			{
				column_sum += data[j][i];
			}
			data[n][i] = column_sum;
		}
		for(int i = 0; i < n + 1; ++i)
		{
			for(int j = 0; j < n + 1; ++j)
			{
				printf("%5d", data[i][j]);
			}
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 1248
N,Y=map(int,input().split())
ans=(-1,-1,-1)
for a in range(N+1):
	for b in range(N+1-a):
		c=N-a-b
		if Y == a*10000 + b*5000 + c*1000:
			ans=(a,b,c)

print(*ans)


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    //a -> 97 A ->
    char c; cin >> c;
    if('a' <= c && c <= 'z') {
        cout << 'a' << endl;
    }else {
        cout << 'A' << endl;
    }
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll a, b;

int main(){
    cin >> a >> b;
    ll x= a*b;
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

    cout << x/b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmin(x,y) do { x = min((ll)x, (ll)y); }while(0)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

const ll INF = 1e18;
ll N;
map<string, ll> m;
vector<ll> c;
vector<string> s;

vector<pair<ll,string>> nxt(string remain) {
  ll cost = m[remain];
  vector<pair<ll,string>> res;
  if (remain.size() == 0) {
    return res;
  }

  //cout << "base: " << cost << " " << remain << endl;

  rep(i, N) {
    string L, R;
    if (remain[0] == '^') {
      L = remain.substr(1);
      R = s[i];
    } else {
      L = s[i];
      R = remain.substr(0, remain.size() - 1);
    }
    ll l = min(L.size(), R.size());
    bool ok = true;
    rep(j, l) {
      if (L[j] != R[R.size() - 1 - j]) ok = false;
    }
    if (!ok) continue;
    if (L.size() > R.size()) res.emplace_back(cost + c[i], "^" + L.substr(l));
    else                     res.emplace_back(cost + c[i], R.substr(0, R.size()-l) + "$");
  }

  for (auto &e : res) {
    if (e.second == "^" || e.second == "$") e.second = "";
    //cout << "nxt: " << e.first << " " << e.second << endl;
  }
  return res;
}

int main(void) {
  cin >> N;
  c.resize(N);
  s.resize(N);
  rep(i, N)
    cin >> s[i] >> c[i];

  priority_queue<pair<ll,string>, vector<pair<ll,string>>, greater<pair<ll,string>>> q;
  rep(i, N) {
    q.emplace(c[i], "^" + s[i]);
  }
  while (!q.empty()) {
    ll cost = q.top().first;
    string remain = q.top().second;
    q.pop();
    if (m.find(remain) == m.end()) m[remain] = INF;
    if (m[remain] <= cost) continue;
    m[remain] = cost;
    for (auto e : nxt(remain)) {
      q.emplace(e.first, e.second);
    }
  }

  ll ans = INF;
  for (auto e : m) {
    string str = e.first;
    if (str.size() > 0 && str[0] == '^') str = str.substr(1);
    if (str.size() > 0 && str[str.size()-1] == '$') str = str.substr(0, str.size()-1);
    bool ok = true;
    rep(i, str.size()) {
      if (str[i] != str[str.size()-1-i]) ok = false;
    }
    if (!ok) continue;
    chmin(ans, e.second);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 21:01:25 2018
//
package main

import (
	"fmt"
	"strconv"
)

var s string

func abs(n int) int {
	if n > 0 {
		return n
	}
	return -n
}
func main() {
	fmt.Scan(&s)

	min := 10000
	for i := 0; i < len(s)-2; i++ {
		val, _ := strconv.Atoi(s[i : i+3])
		diff := abs(val - 753)
		if diff < min {
			min = diff
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

def ok(c):
    if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] \
            and c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2] \
            and c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2] \
            and c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2] \
            and c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2] \
            and c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        return True
    return False

print("Yes" if ok([c1, c2, c3]) else "No")

Measured memory_bytes: 3700
#include<stdio.h>
int Prime(int);

int main(){
  int i,n,x;
  int count = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(Prime(x)) count++;
  }
  printf("%d\n",count);

  return 0;
}

int Prime(int x)
{
  int i;
  if(x<2) return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i=3; i*i <=x; i+=2){
    if(x%i == 0) return 0;
  }

  return 1;
}

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

int main() {
  	int N;
  	cin >> N;
    string s;
    cin >> s;
    int counter = 0;
  	for(int i; i<N; ++i){
    if (s[i] == 'R') ++counter;
    }
    
  	if(counter>N/2) cout << "Yes" << endl;
  	else cout << "No" <<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = [-1] + list(map(int ,input().split()))
is_good = [1] * (N+1)
is_good[0] = 0
for _ in range(M):
    a,b = map(int, input().split())
    ha,hb = H[a], H[b]
    if ha > hb:
        is_good[b] = 0
    if hb > ha:
        is_good[a] = 0
    if ha == hb:
        is_good[a] = 0
        is_good[b] = 0

print(sum(is_good))

Measured memory_bytes: 20036
m,f,r = map(int,input().split())

while m + f + r != -3 :

    if m * f < 0 :
        print("F")
    elif m + f >= 80 :
        print("A")
    elif 65 <= m + f < 80 :
        print("B")
    elif 50 <= m + f < 65 :
        print("C")
    elif 30 <= m + f < 50 :
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

    m,f,r = map(int,input().split())


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

int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
  }

  for ( int i = k; i < n; i++ ) {
    if ( a[i] > a[i-k] ) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb(x)  push_back(x);
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int N, X;
    cin >> N >> X;
    // vi L(N);
    int ans = 1;
    int D = 0;
    rep(i,N) {
        int L; 
        cin >> L;
        D += L;
        if(D > X) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
a, b = map(int, input().split())
out = 0
for i in range(1, a+1):
    if i < b:
        t = 0
        o = i
        while o < b:
            o *= 2
            t += 1
            #print(i, o, t)
        out += (1/a)*(0.5**t)
    else:
        out += (1/a)
# output
print(out)


Measured memory_bytes: 2940
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        c: Chars,
    }

    for e in c {
        if e == '7' {
            echo!("Yes");
            return;
        }
    }

    echo!("No");
}


Measured memory_bytes: 2140
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, sum=0, i;
	
	cin >> N;
	
	i = N;
	
	while(i != 0){
		sum += i % 10;
		i /= 10;
	}
	
	if(N%sum == 0){
		cout << "Yes";
		return 0;
	}
	
	cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    switch(x){
        case 0:
        if(1989<=y&&y<=2016){
            cout<<"H"<<y-1988<<endl;
        }
            if(1926<=y&&y<=1988){
            cout<<"S"<<y-1925<<endl;
            }
            if(1912<=y&&y<=1925){
            cout<<"T"<<y-1911<<endl;
            }
             if(1868<=y&&y<=1911){
           cout<<"M"<<y-1867<<endl;
             }
             break;
          case 1:       
           cout<<y+1867<<endl;
              break;
           case 2:  
             cout<<y+1911<<endl;
             break;
          case 3:   
            cout<<y+1925<<endl;
            break;
          case 4:    
            cout<<y+1988<<endl; 
            break;
             }
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
long u,n,su=0,sn=0,s=0;
char c;
while(cin>>u){
cin>>c>>n;
su+=u*n;
sn+=n;
s++;
}
cout<<su<<endl;
cout<<int(double(sn)/s+.5)<<endl;
return 0;
}

Measured memory_bytes: 1160
N=int(input())
work=[]
for i in range(0,N):
    a,b=map(int,input().split())
    work.append([b,a])

work.sort()

now=0
for i in range(0,N):
    b,a=work[i]
    now+=a
    if now>b:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 76376
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
        printf("3\n");
    else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R')
        printf("2\n");
    else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
        printf("1\n");
    else printf("0\n");
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


const long long int mod = 1000000007, INF = 100000000000000;

//階乗先に計算
long long int kaizyou[200005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
	long long int tmp = 1;
	for (long long int i = a; i <= b; i++) {
		tmp *= i;
		tmp %= mod;

		kaizyou[i] = tmp;
	}
	return tmp;
}


//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

//コンビネーション計算
long long int comb(long long int n, long long int r, long long int mod) {
	long long int tmp;

	tmp = (kaizyou[n] * rui(kaizyou[r], mod - 2, mod)) % mod;
	tmp *= rui(kaizyou[n - r], mod - 2, mod);
	tmp %= mod;
	if (tmp < 0) { tmp = (mod - tmp) % mod; }
	return tmp;
}



long long int n, k, h, a,b,w, res = 0, num[200000] = {}, sum[200003] = {}, dp[150][70000] = {};
int main() {
	cout << fixed << setprecision(10);
	kai(1, 200000, mod);
	cin >> h >> w >> a >> b;
	for (int i = 0; i <= h - a && i <= w - b - 1; i++) {
		res+=comb(h - a +b-1, b  + i, mod)* comb(a +w-b-1, w - b - 1-i, mod);
		res %= mod;
	}
	cout << res;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::io::stdin;
 
#[derive(Default)]
struct Scanner {
    buffer: Vec<String>
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    println!("{}", (Scanner::default().next::<u64>()).pow(3));
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	string fr = "", la = "";
	bool rev = false;
	int q; cin >> q;
	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			rev ^= true;
		}
		else {
			int f; char c; cin >> f >> c;
			if ((f == 1) ^ rev) {
				fr += c;
			}
			else {
				la += c;
			}
		}
	}
	if (rev) {
		reverse(s.begin(), s.end());
		swap(fr, la);
	}
	reverse(fr.begin(), fr.end());
	cout << fr << s << la << endl;
	return 0;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;

int cmb (int n, int k) {
    int res = 1;
    rep (i, 1, k + 1) {
        res *= n - i + 1;
        res /= i;
    }
    return res;
}

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    double v[n];
    map<double, int, greater<double>> mp;
    rep (i, 0, n) {
        cin >> v[i];
        mp[v[i]]++;
    }
    int cnt = 0;
    double sum = 0;
    int ans = 0;
    double ave = 0;
    for (auto p : mp) {
        if (cnt + p.second < a) {
            sum += p.second * p.first;
            cnt += p.second;
        } else if (a <= cnt + p.second) {
            if (cnt == 0) {
                rep (i, a, min (p.second, b) + 1) { ans += cmb (p.second, i); }
                ave = p.first;
            } else {
                int cnt2 = a - cnt;
                ans += cmb (p.second, cnt2);
                ave = (sum + cnt2 * p.first) / a;
            }
            break;
        }
    }
    cout << fixed << setprecision (15) << ave << "\n" << ans << "\n";
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    long n,k;
    stack<long>sta;
    cin>>n>>k;
    while(n!=0)
    {
        sta.push(n%k);
        n/=k;
    }
    cout<<sta.size()<<endl;
    return 0;
}



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


int main()
{
	
	int T_H,T_S;
	int A_H,A_S;
	cin>>T_H>>T_S>>A_H>>A_S;
	
	while(T_H>0){
	A_H=A_H-T_S;
	if(A_H<=0) {
	
		printf("Yes");
		break;
	}
	
	T_H=T_H-A_S;
    
	if(T_H<=0){
		
  		printf("No");
  		break;
    }
	
}
	return 0;
	
}

Measured memory_bytes: 3764
M, K = map(int, input().split())

if K>=(2**M):
    print(-1)
elif M==0:
    if K==0:
        print(0, 0)
    else:
        print(-1)
elif M==1:
    if K==0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    b = [str(i) for i in range(2**M) if not i==K]
    c = [str(i) for i in range(2**M-1, -1, -1) if not i==K]
    ans = b+[str(K)]+c+[str(K)]
    print(' '.join(ans))

Measured memory_bytes: 26384
import os, sys, re, math

lines = sys.stdin.readlines()

S = lines[0]
K = lines[1]

for i in range(len(S)):
    c = S[i]
    if i + 1 == int(K):
        print (c)
        break
    else:
        if c != '1':
            print (c)
            break


Measured memory_bytes: 3316
s=gets.chomp.chars
k=gets.to_i
s.size.times do |i|
  l=122-s[i].ord+1
  if s[i]!="a"&&l<=k
    k-=l
    s[i]="a"
  end
end
s[-1]=((s[-1].ord-97+k)%26+97).chr
puts s.join


Measured memory_bytes: 12028
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline char CH()
{
  static char buf[100000],*ptr1=buf,*ptr2=buf;
  return ptr1==ptr2&&(ptr2=(ptr1=buf)+fread(buf,1,100000,stdin),ptr1==ptr2)?EOF:*ptr1++;
}
static inline int IN(void)
{
  int x=0,f=0,c=CH();while(c<48||c>57){f^=c==45,c=CH();}
  while(c>47&&c<58){x=x*10+c-48,c=CH();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Radix32(int A[],const int sz)
{
  static int temp[200001];const int bit=8;
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,sz)u[A[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&((1<<bit)-1)]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&((1<<bit)-1)]++;
    rep(i,(1<<bit)-1)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&((1<<bit)-1)]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N,p=0,m=0,z=0,A[200000];
  long K,count=0,l=-2e18,r=-l,mid,x=scanf("%d %ld",&N,&K);
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;x=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=x;if(count>=K){r=mid-1l;continue;}
      rep(i,p){while(i<plus&&1l*A[i]*A[plus]>mid){plus--;}if(i==plus){break;}count+=1l*plus-i;}if(count>=K){r=mid-1l;continue;}
      rep(i,m){while(i<minus&&1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i==minus){break;}count+=1l*minus-i;}
    }
    else{int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

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

#define   f(i,n) 					for(ll i=0;i<(n);i++)
#define   ff(i,n) 					for(ll i=1;i<=(n);i++)
#define   m0(X) 					memset((X), 0, sizeof((X)))
#define   m1(X) 					memset((X), -1, sizeof((X)))
#define   pb(x) 					push_back(x)
#define   F     					first
#define   S  						second
#define   MP 						make_pair
#define   inf						(1LL << 60LL)

typedef long long ll;

ll rd(ll &n){
    n = 0;
    char c = 0;
    while(c<33) c = getchar();
    while(c>33){
        n = n*10 +c-48;
        c = getchar();
    }
    return 1;
}

ll rd (ll &x, ll &y){return rd(x)+rd(y);}
ll rd (ll &x, ll &y, ll &z){return rd(x,y)+rd(z);}
ll rd (ll &x, ll &y, ll &z, ll &s){return rd(x,y)+rd(z,s);}

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void debug(const T &head, const U &... tail) {
//#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
//#endif
}

/*

*/

int main()
{
    ll n;
    cin>>n;
    ll a[5];
    f(i,4){
        a[i]=n%10;
        n/=10;
    }
    if((a[0]==a[1] && a[1]==a[2]) || (a[1]==a[2] && a[2]==a[3])) cout<<"Yes";
    else cout<<"No";

    return 0;
}


















Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
 int n;
  cin>>n;
  cout<<n*n*n;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
bool a[100][100];
using namespace std;
int main() {
	int n,m,l,p;
	cin >> n;
	for ( int i = 0;i < n;i++) {
		for(int j= 0; j < n;j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0;i < n; i++){
		cin >> m;
		cin >> l;
		for(int j = 0; j < l;j++) {
			cin >> p;
			a[m-1][p-1] = 1;
		}
	}
	for ( int i = 0;i < n;i++) {
		for(int j= 0; j < n-1;j++) {
			cout << a[i][j] << " ";
		}
		cout << a[i][n-1] << endl;
	}
}
		

Measured memory_bytes: 1168
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(x) for x in input().split()]
    g[x - 1].append(y - 1)

memo = [-1]*n

def dp(v):
    if memo[v] >= 0:
        return memo[v]
    else:
        res = 0
        for u in g[v]:
            res = max(res, dp(u) + 1)
        memo[v] = res
        return res

for i in range(n):
    dp(i)
print(max(memo))




Measured memory_bytes: 59056
#include <bits/stdc++.h> 
        using namespace std;
        
        void output(int X){
              string A;
              A=to_string(X);  
              for(int i=1; i<= 6- A.size(); i++ ){
                    cout<<0;
              }
              cout<<A; 
        }

        int main() {    
             
             int N, M; 
             cin>> N >> M;
             
             priority_queue<tuple<int,int,int>> pq;
             
             for(int i=0; i<M; i++){
                   int P, Y; 
                   cin >> P >> Y;
                   pq.push( make_tuple(-P,-Y,-i) ); 
             }
             
             priority_queue<tuple<int,int,int>> qr;
             
             int p=0;
             int y=1; 
             while(pq.size()>0){
                  int a, b, c;
                  tie(a,b,c) = pq.top();  
                  if(p==a) y++; 
                  if(p!=a) y=1; 
                  pq.pop(); 
                  
                  qr.push(make_tuple(c,a,y)); 
                  p=a;
             }
             
             while(qr.size()>0){
                  int d, e, f;
                  tie(d,e,f) = qr.top();
                  qr.pop(); 
                  output(-e);
                  output(f); 
                  cout<< endl; 
             }
             
             
             
        }

Measured memory_bytes: 3956
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

char buf[110];
int main(void) {
  int nRow, nCol;
  scanf("%d%d", &nRow, &nCol);
  REP(i, nRow) {
    scanf("%s", buf);
    puts(buf);
    puts(buf);
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  if(n <=599 && n>=400 ){
      cout<<8;
  }if(n <=799 && n>=600 ){
      cout<<7;
  }if(n <=999 && n>=800 ){
      cout<<6;
  }if(n <=1199 && n>=1000 ){
      cout<<5;
  }if(n <= 1399 && n>=1200 ){
      cout<<4;
  }if(n <= 1599&& n>=1400 ){
      cout<<3;
  }if(n <=1799 && n>=1600 ){
      cout<<2;
  }if(n <=1999 && n>=1800 ){
      cout<<1;
  }
}


Measured memory_bytes: 3640
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

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

// int n; 

int main(){

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

    // int T;
    // cin >> T;
 
    // while (T--) {
        double t, d, s;
        cin >> d >> t >> s;
        // double tt = d / s;
        // cout << tt << endl;
        if(d / s > t) cout << "No" << endl;
        else cout << "Yes" << endl; 
    // }
    return 0;
}

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

#define  __  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define  int  long long
#define  endl  '\n'
const double pi = acos(-1);
const int mod = 1e9 + 7;
//______________________


int32_t main()
{ 

  string s;
  cin >> s;
  int n = s.size();
  vector<int> rfl(n), lfr(n), ans(n, 1);

  
  for(int i = 0; i < n; i++)
  {
    if(s[i] == 'R')
      rfl[i] = i;
    else
      rfl[i] = rfl[i - 1];
  }
  
  for(int i = n - 1; i >= 0; i--)
  {
    if(s[i] == 'L')
      lfr[i] = i;
    else
      lfr[i] = lfr[i + 1];
  }
  
  int shift, m;

  for(int i = 0; i < n; i++)
  {
    if(s[i] == 'L')
    {
        m = (i - rfl[i]);
        if(m & 1)
         ans[rfl[i] + 1]++;
        else
         ans[rfl[i]]++;
    }
    else
    {
        m = (lfr[i] - i);
        if(m & 1)
          ans[lfr[i] - 1]++;
        else
          ans[lfr[i]]++;
    }

    ans[i]--;
  }

  for(int i = 0; i < n; i++)
    cout << ans[i] << ' ';

 return 0;
}

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

using namespace std;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int h;
    if ((a+b)< n){
        h=0;
    } else {
        h= (a+b)-n;
    }
    cout << min(a,b) << " " << h << endl;
}

Measured memory_bytes: 256