akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string a, b;
  cin >> a >> b;
  string tmp  = a + b;
  int num = atoi(tmp.c_str());
  for (int i = 0; i < 1000; i++)
  {
    if (i * i == num)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

for i in range(max(n, m)) :
    if a[i] > b[i] :
        print(0)
        break
    elif a[i] < b[i] :
        print(1)
        break
    elif i + 1 == m :
        print(0)
        break
    elif i + 1 == n :
        print(1)
        break
        


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;


int main() {
  int n, cnt, ans = 0;
  cin >> n;
  for(int i = 1; i <= n; i += 2){
    cnt = 0;
    for(int j = 1; j <= n; j++){
      if(i%j == 0) cnt++;
    }
    if(cnt == 8)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a, b, c;

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

  int a_b, b_c, c_a, ans;

  a_b = a + b;
  b_c = b + c;
  c_a = c + a;

  if (a_b <= b_c && a_b <= c_a){
    ans = a_b;
  }else if (b_c <= a_b && b_c <= c_a){
    ans = b_c;
  }else{
    ans = c_a;
  }

  printf("%d", ans);


}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n),c(n);
  rep(i,0,n) cin >> v[i];
  rep(i,0,n) cin >> c[i];
  int ans = 0;
  rep(i,0,n) {
    if (v[i] > c[i]) {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3528
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

# nが小さいとき（<5000）にcmb % modを計算．modは素数でなくてもよい
# 前処理
l = 2500
Com = [[0]*(l+5) for i in range(l+5)]
Com[0][0] = 1
for i in range(1,l+5):
    Com[i][0] = 1
    for j in range(1,i+1):
        Com[i][j] = (Com[i-1][j-1] + Com[i-1][j]) % mod

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

Measured memory_bytes: 128564
n=int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))

d1=0
d2=0
d3=0
for i in range(n):
	d1+=abs(x[i]-y[i])
	d2+=(x[i]-y[i])**2
	d3+=abs(x[i]-y[i])**3

from math import pow
d2=pow(d2,(1.0/2.0))
d3=pow(d3,(1.0/3.0))
di=max([abs(x[i]-y[i]) for i in range(n)])

print(d1)
print(d2)
print(d3)
print(di)

Measured memory_bytes: 7828
n, k = map(int, input().split())
white = [[0 for _ in range(2*k+1)] for _ in range(2*k+1)]

for _ in range(n):
	x, y, c = input().split()
	x, y = (int(x) - 1) % (2*k), (int(y) - 1) % (2*k)
	if (c == "B"):
		x = (x-k) % (2*k)

	if not ((x<k) ^ (y<k)):
		if y >= k:
			x, y = x-k, y-k
		white[0][0] += 1
		white[x][0] += -1
		white[x+k][0] += -1
		white[2*k][0] += 1
		white[0][y] += -1
		white[x][y] += 2
		white[x+k][y] += -2
		white[2*k][y] += 1
		white[0][y+k] += 1
		white[x][y+k] += -2
		white[x+k][y+k] += 2
		white[2*k][y+k] += -1
		white[0][2*k] += -1
		white[x][2*k] += 1
		white[x+k][2*k] += -1
		white[2*k][2*k] += 1

	else:
		if y >= k:
			x, y = x+k, y-k
		white[x-k][0] += 1
		white[x][0] += -1
		white[0][y] += 1
		white[x-k][y] += -2
		white[x][y] += 2
		white[2*k][y] += -1
		white[0][y+k] += -1
		white[x-k][y+k] += 2
		white[x][y+k] += -2
		white[2*k][y+k] += 1
		white[x-k][2*k] += -1
		white[x][2*k] += 1

#print(white)

for i in range(2*k+1):
	for j in range(2*k):
		white[i][j+1] += white[i][j]

for j in range(2*k+1):
	for i in range(2*k):
		white[i+1][j] += white[i][j]

#print(white)

ans = 0
for i in range(2*k):
	for j in range(2*k):
		ans = max(ans, white[i][j])

print(ans)

Measured memory_bytes: 92636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  int K;cin >> K;
  vector<int> v(26);
  rep(i,26) v[i] = (26-i)%26;
  rep(i,s.length()){
    int x = s[i] - 'a';
    if(v[x]<=K){
      s[i] = 'a';
      K-=v[x];
    }
  }
  s[s.length()-1] = (s[s.length()-1] - 'a' + K)%26 + 'a';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,x,y=0,n;
  char s[100];
  cin>>a>>b;
  if(a==b)
    cout<<"Draw"<<endl;
  else if(a==1)
    cout<<"Alice"<<endl;
  else if(b==1)
    cout<<"Bob"<<endl;
  else if(a>b)
    cout<<"Alice"<<endl;
  else if(a<b)
    cout<<"Bob"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0,xx,yy;
vl s;
vl g[200000];
void dfs(int x,int y){
  if (x==yy){
    s.push_back(-1);
    return;
  }
  if(x==xx&&y>-1){
    s.push_back(1);
    return;
  }
  if(x==xx){
  dfs(g[x][0],x);
  dfs(g[x][1],x);
  dfs(g[x][2],x);
  dfs(g[x][3],x);
  }
  else{
    dfs(g[x][0]+g[x][1]-y,x);
  }
  return;
}  
  
int main(){
    ll n,m;
    c=0;
  d=0;
  e=0;
    cin>>n>>m;
vl x(n+1,0);
vl k;
 
for(int i=0;i<m;i++){
    cin>>a>>b;
    x[a]++;
    x[b]++;
  g[a].push_back(b);
  g[b].push_back(a);
}
 
for(int i=1;i<n+1;i++){
    if(x[i]%2!=0)c=-1;
    else{
        if(x[i]==4){
          d++;
          k.push_back(i);
        } 
      if(x[i]==6)e++;
    }
}
  
    if(c==0&&d==2&&e==0){
      xx=k[0];
      yy=k[1];
      dfs(xx,-1);
      if(s[0]+s[1]+s[2]+s[3]==0)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  else{
    if(c==0&&(d>2||e>0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}
 

Measured memory_bytes: 9984
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-1):
    x=int(s[i+a])
    y=int(s[i+a+1])
    if(x*y==1):
        f=-1
for j in range(d-b-1):
    x=int(s[j+b])
    y=int(s[j+b+1])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-2:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;


int main() {

    int n; cin >> n;
    vector<ll> v(n);
    priority_queue< ll, vector<ll>, greater<ll> > q;
    rep(i,n){
        cin >> v[i];
        q.push(v[i]);
    }

    while (q.size() > 1) {
        ll first = q.top();
        q.pop();
        ll second = q.top();
        q.pop();
        q.push(first);
        if(second%first != 0) q.push(second%first);

    }
    cout << q.top();



    return 0;
}


Measured memory_bytes: 4992
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, z, K, cake int
	fmt.Scan(&x, &y, &z, &K)

	var one, two, three []int
	for i := 0; i < x; i++ {
		fmt.Scan(&cake)
		one = append(one, cake)
	}
	for i := 0; i < y; i++ {
		fmt.Scan(&cake)
		for j := 0; j < x; j++ {
			two = append(two, cake+one[j])
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(two)))
	for i := 0; i < z; i++ {
		fmt.Scan(&cake)
		for j := 0; j < K && j < x*y; j++ {
			three = append(three, cake+two[j])
		}

	}
	sort.Sort(sort.Reverse(sort.IntSlice(three)))
	for i := 0; i < K; i++ {
		fmt.Println(three[i])
	}

}


Measured memory_bytes: 99584
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int W, H, x, y; cin >> W >> H >> x >> y;
    cout << 1.0 * W * H / 2 << " " << (x * 2 == W && y * 2 == H) << endl; 
    return 0;
}

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

using namespace std;

int main(){
    int K;
    int data[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> K;
    cout << data[K-1]<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n+1);
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		if(i+1==A) a[i]++;
	}
	int res=0;
	for(int i=1;i<=n;i++) if(a[i-1]){
		a[i-1]=0;
		a[i]=0;
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((s (read-line))
         (len (length s)))
    (if (>= (+ (- 15 len) (count #\o s)) 8)
        (write-line "YES")
        (write-line "NO"))))

#-swank(main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  (labels ((ensure-last-lf (s)
             (if (and (> (length s) 0)
                      (eql (char s (- (length s) 1)) #\Linefeed))
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 14948
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int n;
  cin >> n;
  ll ans = 1;
  ll mod = 1e9+7;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int A,B,C,D;

scanf("%d%d%d%d",&A,&B,&C,&D);
int a=A*B;
int b=C*D;	
if(A>=1&&A<=10000&&B>=1&&B<=10000&&C>=1&&C<=10000&&D>=1&&D<=10000)
{

if(a>b)
{
printf("%d",a);
}


if(b>a)
{
printf("%d",b);
}

if(b==a)	
{
printf("%d",a);
}
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int left(int i){ return i*2; }

int right(int i){ return i*2 + 1; }

void swap(int *x, int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int n;

void maxHeapify(int *arr, int i){
  int largest;
  int l = left(i), r = right(i);

  // choice largest key in this and parents
  if(l <= n && arr[l] > arr[i]) largest = l;
  else largest = i;
  if(r <= n && arr[r] > arr[largest]) largest = r;

  if(largest != i){ // if arr[i]'s parent key larger than arr[i]'s key
    swap(&arr[i], &arr[largest]);
    maxHeapify(arr, largest);
  }
}

void buildMaxHeap(int *arr){
  int i;
  for(i=n/2; i>=1; i--) maxHeapify(arr, i);
}

int main(void){
  int i;
  int *heap;

  // input and alloc
  scanf("%d", &n);
  heap = (int *)malloc(sizeof(int) * n);
  for(i=1; i<=n; i++) scanf("%d", &heap[i]);

  // build heap
  buildMaxHeap(heap);

  // output
  for(i=1; i<=n; i++) printf(" %d", heap[i]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 2556
#include<stdio.h>
int main()
{
    unsigned long long int n,i;
    while(scanf("%llu",&n)==1)
    {
        printf("%llu:",n);
        while(n%2==0)
        {
            n=n/2;
            printf(" 2");

        }
        int m=sqrt(n);
        for(i=3; i<=m; i++)
        {
            while(n%i==0)
            {
                n=n/i;
                printf(" %llu",i);

            }
        }
        if(n<=2)
        {

            printf("\n");
        }
        if(n>2)
            printf(" %llu\n",n);
    }
    return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <list>

using namespace std;

// 最大公約数
long long gcd(long long a, long long b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b)
{
    long long g = gcd(a, b);
    return a / g * b;
}

int main()
{
    long s,w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main()
{
  int n,i;
  int f=0;
  scanf("%d",&n);
  for(i=0;i<3;i++){
    if(n%10==7) f=1;
    n=n/10;
  }
  if(f==1) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>
#include <utility>
#include<queue>
#include<algorithm>
#include<list>

using namespace std;

void print_list(const list<int>& dlist){
  const list<int>::const_iterator itEnd = dlist.end();
  for(list<int>::const_iterator it =dlist.begin();it !=itEnd;++it){
    if(it!=dlist.begin())cout <<" ";
    cout << *it;
  }
  cout << endl;
}

//void delete_list(list<int> &dlist,int key){
 // list<int>::iterator find_ptr = find_list(dlist,key);

//}

int main(){
  
  int n = 0;
  cin >> n;

  string command;
  int num;

  list<int> dlist;
  list<int>::iterator it;
  list<int>::iterator l;

  for(int i=0;i<n;i++){
   cin >> command ;
     if(command=="insert"){
        cin >> num;
        dlist.push_front(num);
     }
     else if(command =="delete"){
        cin >> num;
        //delete_list(dlist);
        //list<int>::iterator find_ptr = find(dlist.begin(),dlist.end(),num);
        //if()
        for(it=dlist.begin(),l=dlist.end();it!=l;++it){
          if(*it == num){
            dlist.erase(it);
            break;
          }
     }
    }
     else if(command =="deleteFirst"){
      dlist.pop_front();
     }
     else{
     dlist.pop_back();
     } 

     
  }


  print_list(dlist);


  return 0;
}


Measured memory_bytes: 34248
#include<stdio.h>
#include<stdlib.h>
#define N 500000
typedef struct Jeep{
  struct Jeep *oya;
  struct Jeep *left;
  struct Jeep *right;
  int key;
}Jeep;
void pre(Jeep *);
void in(Jeep *);
void insert(int);
Jeep *kon;
int total;
int main(){
  int i,j,key;
  char A[N];
  scanf("%d",&total);
  for(i=0;i<total;i++){
    scanf("%s",A);
    if('i'==A[0]){
      scanf(" %d",&key);
      insert(key);}
    else{
      in(kon);
      printf("\n");
      pre(kon);
      printf("\n");
    }
  }
  return 0;
}
void in(Jeep *a){
  if(a==NULL){
    return ;
  }
  if(a->left!=NULL) in(a->left);
  printf(" %d",a->key);
  if(a->right!=NULL)in(a->right);
  return ;
}
void pre(Jeep *a){
  if(a==NULL){
    return ;
  }
  printf(" %d",a->key);
  if(a->left!=NULL)pre(a->left);
  if(a->right!=NULL)pre(a->right);
  return ;
}
void insert(int key){
  Jeep *x=kon;
  Jeep *y=NULL;
  Jeep *z;
    z=(Jeep*)malloc(sizeof(Jeep));
    z->left=NULL;
    z->right=NULL;
    z->key=key;
    while(x!=NULL){
      y=x;
      if(key<x->key){
        x=x->left;
      }
      else{
        x=x->right;
      }
    }
    z->oya=y;
    if(y==NULL){
      kon=z;
    }
    else if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
      return ;
    }


Measured memory_bytes: 25188
from math import sin, cos, pi
 
a,b,h,m=map(int,input().split())
tax=a*cos((h/12+m/60/12)*2*pi)
tay=a*sin((h/12+m/60/12)*2*pi)
tbx=b*cos(m/60*2*pi)
tby=b*sin(m/60*2*pi)
 
print( ((tax - tbx)**2 + (tay - tby)**2) ** .5)

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

int main() {
    int n;
    cin >> n;

    int a[n-1], ans[n];
    for (int i=0;i<n-1;i++) {
        cin >> a[i];
    }
    for (int i=0;i<n;i++) {
        ans[i] = 0;
    }
    for (int i=0;i<n-1;i++) {
        ans[a[i]-1]++;
    }
    for (int i=0;i<n;i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 5196
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) noexcept {
    return b > a && (a = b, true);
}

template <class A, class B> inline bool chmin(A &a, const B &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline vector<T> make_v(const T &initializeValue, size_t sz) {
    return vector<T>(sz, initializeValue);
}

template <class T, class... Args>
inline auto make_v(const T &initializeValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initializeValue, args...))>(sz, make_v<T>(initializeValue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    size_t N; cin >> N;

    auto a = make_v(0, 3, N + 1);
    for (size_t i = 1; i <= 2; ++i) {
        for (size_t j = 1; j <= N; ++j) {
            cin >> a[i][j];
        }
    }

    auto dp = make_v(0, 3, N + 1);
    for (size_t i = 1; i <= 2; ++i) {
        for (size_t j = 1; j <= N; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
        }
    }

    cout << dp[2][N] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string S;

  cin >> S;

  for (char c : S) {
    cout << "x";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	double a[11];
	double sum;
	int i;
	while(scanf("%lf",a+1) != EOF){
		sum = a[1];
		for(i = 2; i <= 10; i++){
			if(!(i % 2)){
				a[i] = a[i-1] * 2;
				sum += a[i];
			}else{
				a[i] = a[i-1] / 3;
				sum += a[i];
			}
		}
		printf("%.8lf\n",sum);
	}

	return 0;
}

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

int main(){
	int i, j, n, m;
	char s[55];

	scanf("%s", s);

	for (i = 0; i < strlen(s) - 8; i++) {
		printf("%c", s[i]);
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 128
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
#+sbcl (declaim (sb-ext:unmuffle-conditions sb-ext:compiler-note))
(declaim (optimize (speed 3) (safety 0) (debug 0)))

(defvar k (read))
(defvar min-d (read))
(defvar max-d (read))

(format t "~:[NG~;OK~]" (<= (ceiling min-d k) ;; min multiple of k ge min-d
			    (floor max-d k))) ;; max mutiple of k le max-d


Measured memory_bytes: 23516
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    vint a(N);
    REP(i,N){
        cin>>a[i];
        a[i]-=(i+1);
    }
    sort(ALL(a));
    
    int ans=0;
    REP(i,N){
        ans+=abs(a[i]-a[N/2]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
def inpl(): return map(int, input().split())

def primes(N):
    P = []
    sieve = [1]*(N+1)
    sieve[:2] = [0]*2
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
            sieve[i::i] = [0]*(N//i)
    return P

P = primes(123456*2)

N = int(input())

while N:
    l = bisect(P, N)
    r = bisect(P, 2*N)-1
    print(r-l+1)
    N = int(input())


Measured memory_bytes: 9264
#include <stdio.h>
#include <math.h>
#define PI M_PI
typedef struct{
  double x;
  double y;
}P;

void Kock(P f, P l, int n){
  double theta = PI/3.0;
  P s, u, t;
  if(n == 0) return ;
  s.x = (2*f.x + l.x)/3;
  s.y = (2*f.y + l.y)/3;
  t.x = (f.x + 2*l.x)/3;
  t.y = (f.y + 2*l.y)/3;
  u.x = (t.x - s.x)*cos(theta) - (t.y - s.y)*sin(theta) + s.x;
  u.y = (t.x - s.x)*sin(theta) + (t.y - s.y)*cos(theta) + s.y;

  Kock(f,s,n-1);
  printf("%f %f\n",s.x, s.y);
  Kock(s,u,n-1);
  printf("%f %f\n",u.x, u.y);
  Kock(u,t,n-1);
  printf("%f %f\n",t.x, t.y);
  Kock(t,l,n-1);
  
}

int main(){
  P f={0.0, 0.0}, l={100.0, 0.0};
  int n;
  scanf("%d",&n);
  printf("%f %f\n",f.x, f.y);
  Kock(f, l, n);
  printf("%f %f\n",l.x, l.y);
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main{
     public static void main(String[] args){
          Scanner sc=new Scanner(System.in);
          int N=sc.nextInt();
          int a=0;int b=0;int A=0;int B=0;
          for(int i=1;i<=N;i++){
               A=sc.nextInt();
               B=sc.nextInt();
               if(A>a){
                     a=A;
                     b=B;
             }
        }System.out.print(a+b);
   }
}

Measured memory_bytes: 64908
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
   long long int d;
  cin>>n;
  if(n%1000==0)
  { cout<<0<<endl;
     return 0;
  }
 
  else
  {
    long long int c = n/1000;
     c = c+1;
    c = c*1000;
    d = c - n;
  }
  cout<<d<<endl;
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<int> p(n),q(n),v(n);
    for(int i=1;i<=n;i++){
    	v[i-1]=i;
    }
    for(int i=0;i<n;i++){
    	cin>>p[i];
    }
    for(int i=0;i<n;i++){
    	cin>>q[i];
    }
    ll a,b,num=0;
    do{
    	if(v==p)a=num;
    	if(v==q)b=num;
    	num++;
    }while(next_permutation(be(v)));
    cout << abs(a-b) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main () {
    string s;
    map<char, int> mp;

    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (mp.count(s[i]) != 0) {
            mp[s[i]]++;
        }
        else {
            mp[s[i]] = 1;
        }
    }

    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

    vector<pair<ll,ll>> p;
    for (int i = 0; i < N; i++) {
        ll A, B;
        cin >> A >> B;
        p.push_back({B, A}); // 締切、単位時間
    }

    sort(all(p));
    ll totaltime = 0;
    for (int i = 0; i < N; i++) {
        totaltime += p[i].second;
        if (totaltime <= p[i].first) {
            continue;
        } else {
            cout << "No" << endl;
            return;
        }
    }

    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

const int NIL = -1;
const int MAX = 2147483647;
const int INF = -10001;
const int N = 1000001;
clock_t START, END;
bool debug = false;

int setv[N << 2], sumv[N << 2];
int ql, qr, p, v;
int _sum;

void pushdown(int o)
{
	int lc = o * 2, rc = o * 2 + 1;
	if (setv[o] > INF) {
		setv[lc] = setv[rc] = setv[o];
		setv[o] = INF;
	}
}

void maintain(int o, int L, int R)
{
	int lc = o * 2, rc = 2 * o + 1;
	if (setv[o] > INF) {
		sumv[o] = setv[o] * (R - L + 1);
	}
	else {
		sumv[o] = sumv[lc] + sumv[rc];
	}
}

void query(int o, int L, int R, int add)
{
	int M = L + (R - L) / 2;
	if (setv[o] > INF) {
		_sum += setv[o] * (min(R, qr) - max(L, ql) + 1);
	}
	else if (ql <= L && qr >= R) {
		_sum += sumv[o];
	}
	else {
		if (ql <= M)
			query(o * 2, L, M, add + sumv[o]);
		if (qr > M)
			query(o * 2 + 1, M + 1, R, add + sumv[o]);
	}
}

void update(int o, int L, int R)
{
	int M = L + (R - L) / 2;
	int lc = o * 2, rc = o * 2 + 1;
	if (ql <= L && qr >= R) {
		setv[o] = v;
	}
	else {
		pushdown(o);
		if (ql <= M)
			update(lc, L, M);
		else
			maintain(lc, L, M);
		if (qr > M)
			update(rc, M + 1, R);
		else
			maintain(rc, M + 1, R);
	}
	maintain(o, L, R);
}


int main(void)
{
	if (debug) {
		START = clock();
		freopen("in18.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int n, q, com;
	scanf("%d%d", &n, &q);
	for (int i = 0; i <= 4 * n; i++) {
		setv[i] = INF;
		sumv[i] = 0;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d", &com);
		if (com) {
			scanf("%d%d", &ql, &qr);
			ql++;
			qr++;
			_sum = 0;
			query(1, 1, n, 0);
			printf("%d\n", _sum);
		}
		else {
			scanf("%d%d%d", &ql, &qr, &v);
			ql++;
			qr++;
			update(1, 1, n);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6340
#include <stdio.h>
#include <string.h>

int main(void)
{
	char a[5], b[5];
	int hit, blow, i, j;
	
	while (1){
		hit = 0;
		blow = 0;
		
		scanf("%s %s", a, b);
		
		if (strcmp(a, "0") == 0){
			break;
		}
		
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]){
					if (i == j){
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}

Measured memory_bytes: 540
def alchemist(v)
  v.sort!
  while v.size > 1
    a = v.shift
    b = v.shift
    v.push((a + b) / 2.0)
    v.sort!
  end
  v[0]
end

n = gets.to_i
v = gets.split.map(&:to_i)
puts alchemist(v)

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

int N;
int answer;

void f(long long n) {

  string s = to_string(n);

  if (s.find("3") != std::string::npos) {
    if (s.find("5") != std::string::npos) {
      if (s.find("7") != std::string::npos) {
        if (n <= N) {
          answer++;
        }
      }
    }
  }
  
  if (n < 1000000000) {
    f(10 * n + 3);
    f(10 * n + 5);
    f(10 * n + 7);
  }
  
  return;

} 

int main() {

  cin >> N;
  
  answer = 0;

  f(0);

  cout << answer << endl;

  return 0;

}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  bool ok = 1;
  for (auto&& e : h) {
    cin >> e;
    if (ok && e != 0) ok = 0;
  }
  int cnt = 0;
  while (!ok) {
    int maxh = *max_element(h.begin(), h.end());
    ok = 1;
    for (int i = 0; i < n; i++) {
      if (h[i] == maxh) {
        if (h[i + 1] != maxh || i == n - 1) {
          cnt++;
        }
        h[i]--;
        if (h[i] != 0) ok = 0;
      }
    }
  }
  cout << cnt << '\n';
  return 0;
}


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

int main()
{
  int a;
  string S,T,T1;

  cin >> S >> T;

  a=S.size();

  T1=T.substr(0,a);

  if(S==T1){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	ll n,d;
	cin>>n>>d;
	ll dsq=d*d;
	int ans=0;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		ll len=x*x+y*y;
		if(len<=dsq){
			ans++;
		}
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};

template<class T> struct Counting {
    void init(int64_t n) {
        _fact.assign(n+1, 1);
        for(int64_t i = 1; i <= n; i++)  _fact[i] = T(i) * _fact[i-1];
    }

    T fact(int64_t n) {
        assert(0 <= n && n < (int)_fact.size());
        return _fact[n];
    }

    T comb(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / (fact(k) * fact(n-k));
    }

    private:
        vector<T> _fact;
};

const int64_t MOD = 1e9+7;
using mint = Mint<MOD>;
Counting<mint> cnt;

// = = = = = = = = = = = = = = = =
lint n, m, k;

mint multi(lint w, lint h) {
    if(h == 0)  return mint((m - w) * n);
    if(w == 0)  return mint(m * (n - h));
    return mint( (m - w) * 2*(n - h) );
}

int main() {
    cin >> n >> m >> k;
    mint ans(0);

    for(lint w = 0; w < m; w++) {
        for(lint h = 0; h < n; h++) {
            ans += mint(w + h) * multi(w, h);
        }
    }
    cnt.init(200000);
    ans *= cnt.comb(n*m-2, k-2);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    char a[10], b[4];
    ins(a); ins(b);
    strcat(a,b);
    ll x=0, N=strlen(a);
    rep(i, N) x += (a[N-1-i]-'0')*powll(10,i);
    ll t=3;
    while(1){
        if(powll(t,2)==x){
            puts("Yes");
            return 0;
        }
        if(powll(++t,2)>x){
            puts("No");
            return 0;
        }
    }
}


Measured memory_bytes: 128
A = int(input())
B = int(input())
if (A == 1 and B == 2) or (A == 2 and B == 1):
  print(3)
elif (A == 2 and B == 3) or (A == 3 and B == 2):
  print(1)
elif (A == 1 and B == 3) or (A == 3 and B == 1):
  print(2)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#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>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// ?§?????????¨????????¨???????????????????¨???????????§???????
template <typename T>
struct Edge {
    int to; T cap; int rev;
    Edge(int t, T c, int r) : to(t), cap(c), rev(r) {}
};

template <typename T>
struct Flow {
    vector< vector< Edge<T> > > G;
    int n;
    vector<bool> used;
    Flow(int _n) : G(_n), n(_n), used(_n, false) {}

    // G[e.to][e.rev] ??§?????????????????§??????
    void add_edge(int from, int to, T cap) {
        G[from].push_back(Edge<T>(to, cap, G[to].size()));
        G[to].push_back(Edge<T>(from, 0, G[from].size() - 1));
    }

    T dfs(int v, int t, T f) {
        if(v == t) return f;
        used[v] = true;
        for(int i=0; i < G[v].size(); i++) {
            Edge<T> &e = G[v][i];
            if(!used[e.to] && e.cap > 0) {
                T 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;
    }

    T max_flow(int s, int t) {
        T flow = 0;
        while(1) {
            fill(used.begin(), used.end(), false);
            T f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

signed main() {
    int V, E; cin >> V >> E;
    Flow<int> fl(V);
    int u, v, c;
    rep(i,0,E) {
        cin >> u >> v >> c;
        fl.add_edge(u, v, c);
    }

    cout << fl.max_flow(0, V-1) << endl;
    return 0;
}

Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int s[100];

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (int i = a; i < b; i++)s[i]++;
	for (int i = c; i < d; i++)s[i]++;
	int ans = 0;
	for (int i = 0; i < 100; i++) {
		if (s[i] == 2)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

const int mod = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  pair<int, int> ma = make_pair(INT_MIN, 0);
  pair<int, int> mi = make_pair(INT_MAX, 0);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > ma.first)
      ma = make_pair(a[i], i + 1);
    if (a[i] < mi.first)
      mi = make_pair(a[i], i + 1);
  }
  cout << N * 2 - 1 << endl;
  if (ma.first + mi.first < 0) {
    for (int i = 0; i < N; i++) {
      a[i] += mi.first;
      cout << mi.second << ' ' << i + 1 << endl;
    }
    for (int i = N - 1; i > 0; i--) {
      a[i - 1] += a[i];
      cout << i + 1 << ' ' << i << endl;
    }
  } else {
    for (int i = 0; i < N; i++) {
      a[i] += ma.first;
      cout << ma.second << ' ' << i + 1 << endl;
    }
    for (int i = 0; i < N - 1; i++) {
      a[i + 1] += a[i];
      cout << i + 1 << ' ' << i + 2 << endl;
    }
  }
}

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

#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

int solve(int n) {
    if (n < 10)
        return n;
    int oddcnt = 9;
    if (n < 1000)
        return oddcnt + max(0, n-99);
    oddcnt += 900;
    if (n < 100000)
        return oddcnt + max(0, n-9999);
    oddcnt += 90000;
    return oddcnt;
}

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

    int n;
    cin >> n;
    cout << solve(n) << "\n";
}


Measured memory_bytes: 384
#include<stdio.h>
#define T 250
int main(){
  int o,i;
  int hep[T];
  scanf("%d",&o);
  for(i=1;i<=o;i++){
    scanf("%d",&hep[i]);
  }
  for(i=1;i<=o;i++){
    printf("node %d: ",i);
    printf("key = %d, ",hep[i]);
    if(i/2>=1)printf("parent key = %d, ",hep[i/2]);
    if(i*2<=o)printf("left key = %d, ",hep[i*2]);
    if(i*2+1<=o)printf("right key = %d, ",hep[i*2+1]);
    printf("\n");
  }


  return 0;
}



Measured memory_bytes: 2108
using System;

namespace _0002 {

	public static class Program {

		public static void Main() {
			string input;
			while (!string.IsNullOrEmpty(input = Console.ReadLine())) {
				var inarray = input.Split(' ');
				Console.WriteLine((int.Parse(inarray[0]) + int.Parse(inarray[1])).ToString().Length);
			}
		}

	}

}

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

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr <<">>>>>>"<< #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif


int main()
{
	
	int w,a,b;
	cin>>w>>a>>b;
	cout<<max({0,b-a-w,a-b-w})<<endl;
}



Measured memory_bytes: 3524
a = input().split(" ")
x = int(a[0])
if a[1] == "0":
    print(a[0])
else:
    b = input().split(" ")
    c = []
    for i in b:
        c.append(int(i))
    d = sorted(c)
    e = 0
    while True:
        y = x - e
        if d.count(y) == 0:
            print(x-e)
            break
        y = x + e
        if d.count(y) == 0:
            print(x+e)
            break
        e += 1

Measured memory_bytes: 9144
#include <stdio.h>

int GCD(int a, int b) {
  if (a%b == 0) {
    return b;
  }
  else {
    return GCD(b, a%b);
  }
  
}

int main() {
  int a, b;
  int n;

  scanf("%d %d", &a, &b);
  if (a >= b) {
    n = GCD(a, b);
  }
  else {
    n = GCD(b, a);
  }

  printf("%d\n", n);

  return 0;
}



Measured memory_bytes: 2044
sx,sy,tx,ty = map(int,input().split())
ans = 'R'*(tx-sx)+'U'*(ty-sy) + 'L'*(tx-sx) +'D'*(ty-sy) + 'D' + 'R'*(tx-sx+1) + 'U'*(ty-sy+1)+ 'L' + 'U' + 'L'*(tx-sx+1) + 'D'*(ty-sy+1) + 'R'
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,x,last,ans;
int main()
{
	cin>>n>>m;
	cin>>last;
	for (i=2;i<=n;i++)
	{
		cin>>x;
		ans+=min(m,x-last);
		last=x;
	}
	cout<<ans+m;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define INF 10000000
#define cost first
#define node second
using namespace std;
typedef pair <int,int> P;
vector <P> mp[101];
int n,m,s,g1,g2;

int dijkstra(int start,int goal){
  int D[101];
  for(int i=0;i<=n;i++) D[i]=INF;
  priority_queue <P,vector<P>,greater<P> >Q;
  Q.push((P){0,start});
  while(!Q.empty()){
    P t=Q.top(); Q.pop();
    if(t.node==goal) return t.cost;
    for(int i=0;i<mp[t.node].size();i++){
      int ncost = mp[t.node][i].cost + t.cost;
      int nnode = mp[t.node][i].node;
      if(D[nnode] > ncost)Q.push((P){ncost,nnode}),D[nnode] = ncost;
    }
  }
  return INF;
}

int main(){
  while(1){
    cin >>n>>m>>s>>g1>>g2;
    if(n==0&&m==0&&s==0&&g1==0&&g2==0)break;
    int b1,b2,c;
    for(int i=0;i<=n;i++) mp[i].clear();
    for(int i=0;i<m;i++) cin >> b1>>b2>>c,mp[b1].push_back((P){c,b2});
    
    int ans = INF;
    for(int i=1;i<=n;i++)ans= min(ans,dijkstra(s,i)+dijkstra(i,g1)+dijkstra(i,g2));
    cout << ans <<endl;
  } 
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<math.h>

using namespace std;

int N;
int a,b,c;

int main(){
	cin >> N;

	for(int i=0;i<N;i++){
		cin >> a >> b >> c;

		if(pow(a,2)+pow(b,2) == pow(c,2)){
			cout << "YES" <<endl;
		}else if(pow(a,2)+pow(c,2) == pow(b,2)){
			cout << "YES" <<endl;
		}else if(pow(b,2)+pow(c,2) == pow(a,2)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 3052
def iroha_loves_strings(N: int, L: int, S: list) -> str:
    return ''.join(sorted(S))


if __name__ == "__main__":
    N = 0
    N, L = map(int, input().split())
    S = [input() for _ in range(N)]
    ans = iroha_loves_strings(N, L, S)
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#define pb push_back
#define int long long int 
#define inf (int)(1e12)
using namespace std;
typedef pair<int,int> pii;


int a,b,q;
signed main(){
  cin>>a>>b>>q;

  vector<int> s,t;
  vector<pii> x;
  int tmp;
  for(int i=0;i<a;i++){
    cin>>tmp;
    s.pb(tmp);
  }
  for(int i=0;i<b;i++){
    cin>>tmp;
    t.pb(tmp);
  }
  
  s.pb(inf);
  t.pb(inf);
  s.pb(-inf);
  t.pb(-inf);
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());

  for(int i=0;i<q;i++){
    cin>>tmp;
    x.pb(pii(tmp,i));  
  }
  sort(x.begin(),x.end());

  int l,r;
  l=r=0;
  vector<pii> res;
  for(int i=0;i<x.size();i++){
    int ret;
    int ima=x[i].first;
    if(s[l]<ima){
      while(s[l+1]<ima) l++;
    }
    if(t[r]<ima){
      while(t[r+1]<ima) r++;
    }

    ret=inf;
    
    ret=min(ret,min(ima-s[l],t[r+1]-ima)*2 + max(ima-s[l],t[r+1]-ima));
    ret=min(ret,min(ima-t[r],s[l+1]-ima)*2 + max(ima-t[r],s[l+1]-ima));
    ret=min(ret,max(s[l+1],t[r+1])-ima);
    ret=min(ret,ima-min(s[l],t[r]));
    
    res.pb(pii(x[i].second,ret));
  }
  sort(res.begin(),res.end());
  for(int i=0;i<res.size();i++){
    cout<<res[i].second<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 6912
# -*- coding: utf-8 -*-


def main():
    n, h, w = map(int, input().split())
    ans = 0

    for i in range(n):
        ai, bi = map(int, input().split())
        ans += min(ai // h, bi // w)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = gets.to_i
sent = []
ans = []
n.times do
  sent << gets.chomp.split('').sort!
end
# p sent
# binding.pry



("a".."z").each do |i|
  while sent.all? {|sen|sen.include?(i)}
    ans << i
    sent.each do |sen|
      sen.delete_at(sen.bsearch_index{|x|x >= i})
    end
  end
end
puts ans.join


Measured memory_bytes: 1916