akhauriyash/Code-Regression huggingface dataset:
N = int(input())
M = 1000000007
t, t1, t2 = 1, 1, 1

for _ in range(N):
    t, t1, t2 = t*10, t1*9, t2*8
    t, t1, t2 = t%M, t1%M, t2%M

print((t - t1*2 + t2) % M)


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

using namespace std;

string LineData;
vector<pair<string, int> > WordsInfo;
vector<pair<string, int> >::iterator it;


void solve() {
	string word;
	stringstream ss(LineData);
	
	while (ss>>word) {
		//cout << word << " ";
		for (it = WordsInfo.begin(); it != WordsInfo.end(); ++it) {
			if (it->first == word) {
				++it->second;
				break;
			}
		}
		if (it == WordsInfo.end()) {
			WordsInfo.push_back(make_pair(word, 1));
		}
	}
}

bool cmp(const pair<string, int>& w1, const pair<string, int>& w2) {
	if (w1.second == w2.second) {
		return w1.first < w2.first;
	}
	return w1.second > w2.second;
}

bool matchWords(char target) {
	
	for (it = WordsInfo.begin(); it != WordsInfo.end();) {
		if (it->first[0] != target) {
			it = WordsInfo.erase(it);
			continue;
		}
		++it;
	}

	if (WordsInfo.empty()) {
		return false;
	}
	sort(WordsInfo.begin(), WordsInfo.end(), cmp);
	return true;
}

void show() {
	int cnt;

	cnt = WordsInfo.size() > 5 ? 5 : WordsInfo.size();
	for (int i = 0; i < cnt; ++i) {
		if (i != 0) {
			cout << " ";
		}
		cout << WordsInfo[i].first;
	}
	cout << endl;
}

int main() {
	int n;
	char target;

	while (cin >> n, n) {
		getchar();
		WordsInfo.clear();
		for (int i = 0; i < n; ++i) {
			getline(cin, LineData);
			//cout << LineData << endl;
			solve();
		}
		cin >> target;
		//cout << "target:" << target << endl;
		if (matchWords(target)) {
			show();
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3228
import java.util.*;

class Main {
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        String t = sc.next();
        
        String str = "";
        
        for(int i = 0; i < n; ++i) {
            str += s.charAt(i);
            str += t.charAt(i);
        }
        
        System.out.println(str);
    }
}

Measured memory_bytes: 21076
import itertools
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1

N, M, R = map(int, input().split())
T = sorted(list(map(int1, input().split())))
A = np.array([tuple(map(int, input().split())) for _ in range(M)]).T

matr = csr_matrix((A[2], (A[0] - 1, A[1] - 1)), shape=(N, N))
way = [dijkstra(matr, indices=t, directed=False)[T].astype(int).tolist() for t in T]

ans = float('inf')
for t in itertools.permutations(range(R)):
    tmp = 0
    for i in range(R - 1):
        tmp += way[t[i]][t[i + 1]]
    ans = min(ans, tmp)
print(ans)

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;
}

/*Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z =malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}


void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    //  if ( com[0] == 'f' ){
    // scanf("%d", &x);
    // Node t = treeSearch(root, x);
    // if ( t != NIL ) printf("yes\n");
      //else printf("no\n");
    //  }
  if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
  } //else if ( com[0] == 'd' ){
  //scanf("%d", &x);
  //  treeDelete(treeSearch(root, x));
  //}
  }

  return 0;
}



Measured memory_bytes: 25208
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

int A, B;
int main(int argc, char **argv) {
    std::cin >> A >> B;

    if (A <= 5) {
        std::cout << 0 << std::endl;
    } else if (A <= 12) {
        std::cout << B/2 << std::endl;
    } else {
        std::cout << B << std::endl;
    }

    return 0;
}



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

int main(){
  int N, K;
  cin >> N >> K;
  int c = 1;
  for(int i = 0; i < N; i++){
    if(2 * c > c + K){
      c += K;
    }
    if(2 * c <= c + K){
      c = c * 2;
    }
  }
  cout << c;
}

Measured memory_bytes: 3636
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(map(int, list(input())))
num = 0
dict = [0 for i in range(2019)]
dict[0] = 1
ans = 0

for i , n in enumerate(S[::-1]):
    num += n * pow(10,i,2019)
    dict[num % 2019] += 1

for i in range(2019):
    ans += dict[i] * (dict[i] - 1) // 2
print(ans)

Measured memory_bytes: 12004
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
//#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;

const int N = 105, MOD = 1e9 + 7;

int n, m;
char A[N][N];
int dp[N][N][N + N];

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> A[i][j];
    if (A[1][1] == '#')
        dp[1][1][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            if (i + j == 2)
                continue;
            for (int l = 0; l <= n + m; l++){
                dp[i][j][l] = n + m + 1;
                if (A[i][j] == '.'){
                    int k = l - l % 2;
                    if (i > 1)
                        dp[i][j][l] = min (dp[i][j][l], dp[i - 1][j][k]);
                    if (j > 1)
                        dp[i][j][l] = min (dp[i][j][l], dp[i][j - 1][k]);
                    continue;
                }
                int k = l - (l + 1) % 2;
                int p = 0;
                if (l == 0){
                    k = 1;
                    p = 1;
                }
                if (i > 1)
                    dp[i][j][l] = min (dp[i][j][l], dp[i - 1][j][k] + p);
                if (j > 1)
                    dp[i][j][l] = min (dp[i][j][l], dp[i][j - 1][k] + p);
            }
        }
    cout << dp[n][m][0] << endl;
    return 0;
}


Measured memory_bytes: 17408
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>

using namespace std;

int main(void) {
    int N;
    cin>>N;
    int B=(N+1)/2;
    cout<<(double)B/N<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  int ans=MAX;
  rep(i,n) {
    int x;
    R x;
    int cnt=0;
    while(x%2==0) {
      x/=2;
      cnt++;
    }
    ans=min(ans,cnt);
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,x,y;cin>>N>>A>>B;
  vector<int>P(N);
  for(int i=0;i<N;i++)cin>>P.at(i);
  sort(P.begin(),P.end());
  x=upper_bound(P.begin(),P.end(),A)-P.begin();
  y=upper_bound(P.begin(),P.end(),B)-P.begin();
  cout<<min({x,y-x,N-y})<<endl;
}

Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
L=[[] for i in range(n+1)]
DIC={}
for _ in range(m):
    a,b,c=map(int,input().split())
    L[a].append((b,c))
    L[b].append((a,c))
    DIC[(a,b)]=0

que=[] #あとで


heapq.heapify(que)

for tar in range(1,n+1):
    sc=[10**8 for i in range(n+1)]
    sc[tar]=0
    pre=[tar for i in range(n+1)]
    heapq.heappush(que,(0,tar))
    while len(que)>0:
        nco,now=heapq.heappop(que)
        
        for can in L[now]:
            nex=can[0]
            cos=can[1]
            if sc[nex]>cos+nco:
                sc[nex]=cos+nco
                heapq.heappush(que,(cos+nco,nex))
                pre[nex]=now
    for i in range(1,n+1):
        if pre[i]!=i:
            a,b=i,pre[i]
            if a>b:
                a,b=b,a
            DIC[(a,b)]=1

ans=m
for val in DIC.values():
    ans-=val
print(ans)

Measured memory_bytes: 75652
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

vector<string> grid(21);
int n,m;
vector<pair<int,int>> dir = {{0,1},{1,0},{-1,0},{0,-1}};

int bfs(pair<int,int> start, pair<int,int> target){
	deque<tuple<int,int,int>> q;
	vector<vector<int>> vu(20,vector<int>(20,INT_MAX));
	q.emplace_back(0,start.first,start.second);
	while (!q.empty()){
		auto f=q.front();
		q.pop_front();
		int x,y,prev_weight;
		tie(prev_weight,x,y) = f;
		for (auto& i:dir){
			int weight=prev_weight+1, newx = x+i.first, newy = i.second+y;
			if (newx < n and newy < m and newx >= 0 and newy >= 0 and vu[newx][newy] == INT_MAX and grid[newx][newy] != '#'){
				vu[newx][newy] = weight;
				q.emplace_back(weight,newx,newy);
			}
		}
	}
	return vu[target.first][target.second];
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h,w;
	cin >> h >> w;
	n = h;
	m = w;
	vector<pair<int,int>> start;
	for (int i=0; i<h; ++i){
		cin >> grid[i];
		for (int j=0; j<w; ++j){
			if (grid[i][j] == '.') start.emplace_back(i,j);
		}
	}
	int ans = 0;
	for (int i=0; i<start.size(); ++i){
		for (int j=i+1; j<start.size(); ++j){
			ans = max(ans,bfs(start[i],start[j]));
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
    string a,b;
    cin >> a >> b;
    int S = stoi(a+b);
    int r = sqrt(float(S));
    if (r*r == S) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;













#define int long long

signed main(){
    int n;
    cin >> n;
    if(n%2 == 1){cout << 0; return 0;}
    int ans = 0;
    int ce = 10;
    ans = n/ce;
    ce = 50;
    while(ce <= n){
        ans += n/ce;
        ce *= 5;
    }
    cout << ans;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl; 
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    B=[(i,a) for i,a in enumerate(A)]
    B.sort(key=lambda x:x[1])
    for b in B:
        print(b[0]+1,end=' ')
resolve()

Measured memory_bytes: 61932
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;
static inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int pow(long x, int n, long m){
    long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= m;
        x *= x, x %= m;
        n >>= 1; 
    }
    return ret % m;
}

int euler_phi(int n) {
   int ret = n;
   for(int i = 2; i * i <= n; ++i){
       if(n % i == 0) {
           ret -= ret / i;
           while(n % i == 0) n /= i;
       }
   }
   if(n > 1) ret -= ret / n;
   return ret;
}

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

    K /= gcd(K, 7);
    K *= 9;

    if(gcd(K, 10) != 1) {
        printf("%d\n", -1);
        return 0;
    }

    int res = euler_phi(K);

    int ans = 1000000;
    for(int i = 1; i * i <= res; ++i){
        if(res % i == 0) {
            if(pow(10, i, K) == 1){
                printf("%d\n", i);
                return 0;
            }
            if(pow(10, res / i, K) == 1) if(res / i < ans) ans = res / i;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1736
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 2e3 + 7;

int len[N][N], cnt[N], n, x, y;
vector < int > adj[N];

int32_t main() {
    speed;
    cin >> n >> x >> y;

    for ( int i = 1; i < n; i++ ) {
        adj[i].push_back( i + 1 );
        adj[i + 1].push_back( i );
    }
    adj[x].push_back(y);
    adj[y].push_back(x);

    for ( int i = 1; i <= n; i++ ) {

        queue < int > q;
        vector < int > used(n + 1);
        q.push( i );
        used[i] = 1;

        while ( !q.empty() ) {
            int f = q.front();
            q.pop();

            for ( auto v: adj[f] ) {

                if ( !used[v] ) {
                    used[v] = 1;
                    len[i][v] = len[i][f] + 1;
                    q.push(v);
                }
            }
        } 
    }
    for ( int i = 1; i <= n; i++ ) {

        for ( int j = 1; j <= n; j++ ) {
            cnt[ len[i][j] ]++;
        }
    }
    for ( int i = 1; i < n; i++ ) {
        cout << cnt[i] / 2 << '\n';
    }
}   
  

Measured memory_bytes: 31744
#include <iostream>
#include <string.h>
using namespace std;

int main(void){
 int n,a,b,c,d,i;
 string s;
 cin >> n >> a >> b;
 cin >> s;
 c=0;
 d=0;
 for(i=0;i<n;i++){
 	if(s[i]=='a'){
    if(c<(a+b)){
     c++;
     cout << "Yes"<<endl;
    }else{
     cout << "No"<<endl;
    }
 	}else if(s[i]=='b'){
    if((c<(a+b))&&(d<b)){
     c++;
     d++;
     cout << "Yes"<<endl;
    }else{
     cout << "No"<<endl;
    }}else if(s[i]=='c'){
    cout << "No"<<endl;
   }
   }
   return 0;
   }

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    cout<<n*(n+1)/2;
	return 0;

}


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

int main(void) {
	int n ,q;
	char name[200002][11];
	int time[200002];
	char clearname[100002][11];
	int cleartime[100002];
	int endtime = 0;
	int front = 0;
	int rear;
	int i = 0;

	scanf("%d %d", &n, &q);

	for (rear = 0; rear < n; rear++) {
		scanf("%s %d", name[rear], &time[rear]);
	}

	rear++;
	while (1) {
		if (time[front] > 0) {
			if (time[front] > q) {
				time[front] -= q;
				endtime += q;
				strcpy(name[rear], name[front]);
				time[rear] = time[front];
				rear++;
			}
			else {
				endtime += time[front];
				time[front] = endtime;
				strcpy(clearname[i], name[front]);
				cleartime[i] = time[front];
				i++;
			}

			time[front] = 0;
			memset(name[front], 0, 1);
		}

		if (rear == front) {
			break;
		}

		front++;

	}

	for (i = 0; i < n; i++) {
		printf("%s %d\n", clearname[i], cleartime[i]);
	}

	return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a;
    for(int i = 0; i < n; i++){
        int ta;
        cin >> ta;
        if(ta <= k){
            a.push_back(ta);
        }
    }
    sort(a.begin(),a.end());
    n = a.size();

    int ok = -1;
    int ng = n;

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        vector<vector<bool>> dp2(n,vector<bool>(k+1,0));
        dp2[0][0] = true;
        for(int i = 0; i < n-1; i++){
            int index = i >= mid ? i+1 : i;
            for(int j = 0; j <= k; j++){
                if(dp2[i][j]){
                    dp2[i+1][min(j+a[index],k)] = true;
                    dp2[i+1][j] = true;;
                }

            }
        }
        bool is_wasteful = true;
        for(int i = k-a[mid]; i < k; i++){
            if(dp2[n-1][i]){
                is_wasteful = false;
            }
        }
        if (is_wasteful) ok = mid;
        else ng = mid;
    }


    cout << ok + 1 << endl;

    return 0;

}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a*b%2==0){
            System.out.println("Even");
        }
        else{
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21972
n, k = map(int,input().split()) 
l = [int(_) for _ in range(1,n+1)]
#print(l)

a = 0
for i in range(n):
    if l[i] % k == 0:
        a += 1
#print(a)

b = 0
for j in range(n):
    if l[j] % k == k/2:
        b += 1
#print(b)

if k % 2 == 1:
    print(a**3)
else:
    print(a**3 + b**3)


Measured memory_bytes: 11032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    cout<<(h-a)*(w-b)<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll tests=1 ;
   //cin>>tests ;
   for(ll testcase=1;testcase<=tests;testcase++)
   {
     ///cout<<"Case #"<<testcase<<": " ;
     ///Read ,Think and Test Properly,then code
     ll n ;
     cin>>n ;
     vector<ll>v(n) ;
     ll f[n+1] ;
     memset(f,0,sizeof(f)) ;
     for(ll i=0;i<n;i++)
       {

        cin>>v[i] ;
        f[v[i]]++ ;
       }

       ll ans=0 ;
       for(ll i=0;i<=n;i++)
       {
           ll x=f[i] ;
           ans+=(x*(x-1))/2 ;
       }
       for(ll i=0;i<n;i++)
       {
           ll nans=ans ;
          ll x=f[v[i]] ;
           ans-=(x*(x-1))/2 ;
           x-- ;
           ans+=(x*(x-1))/2 ;

           cout<<ans<<endl ;
           ans=nans ;

       }

     //  cout<<ans ;



   }
}


Measured memory_bytes: 5760
#標準入力
n = int(input())

#下1桁
x = n % 10

#読み方のリスト
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if x in hon:
  print('hon')
elif x in pon:
  print('pon')
elif x in bon:
  print('bon')

Measured memory_bytes: 9052
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import math
n = int(input())
x_list = []
y_list = []
d_sum = 0
for i in range(0, n):
    x, y = map(int, input().split())
    x_list.append(x)
    y_list.append(y)

for i in range(0, n - 1):
    for j in range(i + 1, n):
        d_sum += 2 / n * math.sqrt((x_list[i] - x_list[j])**2 + (y_list[i] - y_list[j])**2)
print(d_sum)



Measured memory_bytes: 3064
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ans=0
c=Counter(a)
a=list(set(a))

for aa in a:
    t=0
    t+=c[aa]
    t+=c[aa-1]
    t+=c[aa+1]
    ans=max(ans,t)
print(ans)


Measured memory_bytes: 15072
def bb
    n,m,x,y = gets.chomp.split(/\s/).map{|x| x.to_i}

    xx = [gets.chomp.split(/\s/).map{|x| x.to_i}.max, x].max
    yy = [gets.chomp.split(/\s/).map{|x| x.to_i}.min, y].min

    puts xx < yy ? 'No War' : 'War'
end

bb

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define repc(...) GET_MACRO(__VA_ARGS__, repc4, repc3, repc2, repc1) \
(__VA_ARGS__)
#define repc1(n) repc2(_, n)
#define repc2(i, n) repc3(i, 0, n)
#define repc3(i, a, n) repc4(i, a, n, 1)
#define repc4(i, a, n, d) rep5(i, a, n, d, <=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

void solve()
{
  int n = in();
  vector<int> h(n);
  vcin(h);

  vector<int> h_1(n);
  rep(i, n) h_1[i] = h[i] - 1;

  int now = h_1[0];
  rep(i, n-1)
  {
    if (now <= h_1[i + 1])
    {
      now = h_1[i + 1];
    }
    else if (now <= h[i + 1])
    {
      now = h[i + 1];
    }
    else
    {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
  return;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, N: int, A: "List[int]"):
    if H <= sum(A):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define int long long 
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  for( int i = 0; i < N; i++ ){
    int A;
    cin >> A;
    if( A % 2 == 1 ) continue;
    if( A % 3 != 0 && A%5 != 0 ){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
def main():
    keylist = input()

    word = ''

    for key in keylist:
        if key == 'B':
            word = word[:-1]
        else:
            word += key

    print(word)

    # word = []
    # 
    # for key in keylist:
    #     if key == 'B':
    #         if word:
    #             word.pop()
    #     else:
    #         word.append(key)
    # 
    # print(''.join(word))

if __name__ == "__main__":

    main()


Measured memory_bytes: 2940
#include<stdio.h>

int main()

{
	int h, w, i, j;

	while (1)
	{
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)break;

		for (i = 1; i <= h; i++){
			for (j = 1; j <= w; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int n;
  cin >> n;
  int a[n];
  REP(i,n)cin>>a[i];

  set<ll> ss;
  REP(i,n){
    if(a[i]==0){
      ss.insert(0);
      continue;
    }
    ll tmp = 0;
    REP(j,5){
      if(i+j>=n)break;
      tmp *= 10;
      tmp += a[i+j];
      ss.insert(tmp);
    }
  }
  set<ll>::iterator iter;
  ll f = 0;
  iter = ss.begin();
  while(iter != ss.end()){
    if(*iter != f)break;
    ++f;
    ++iter;
  }
  cout << f << endl;
  return 0;

}

Measured memory_bytes: 1312
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char const *argv[]) {

  int a1,a2,a3,b1,b2,b3;
  scanf("%d %d", &a1, &b1);
  scanf("%d %d", &a2, &b2);
  scanf("%d %d", &a3, &b3);

  int a[6] = {a1,a2,a3,b1,b2,b3};

  int n[5] = {0,0,0,0,0};

  for (int i = 0; i < 6; i++) {
    switch (a[i]) {
      case 1:
        n[1]++;
      break;
      case 2:
        n[2]++;
      break;
      case 3:
        n[3]++;
      break;
      case 4:
        n[4]++;
      break;
    }
  }

  for (int i = 1; i < 5; i++) {
    if(n[i] > 2 || n[i] < 1) {
      printf("NO");
      return 0;
    } else {

    }
  }
  printf("YES");
  return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
Query=[list(map(int,input().split())) for i in range(Q)]
mod=10**9+7

EDGELIST=[dict() for i in range(N+1)]
for x,y,c,l in EDGE:
    EDGELIST[x][y]=(c,l)
    EDGELIST[y][x]=(c,l)
    
# LCA(オイラーツアー＋Segment tree)

DEPTH=[-1]*(N+1)
DEPTH[1]=0

from collections import deque
QUE = deque([1])
QUE2 = deque()
EULER=[]#(i,j)で,(1からツアーで辿った点の深さ,そのindex)

USED=[0]*(N+1)
while QUE:
    x=QUE.pop()
    EULER.append((DEPTH[x],x))
    if USED[x]==1:
        continue
    for to in EDGELIST[x]:
        
        if USED[to]==0:
            DEPTH[to]=DEPTH[x]+1
            QUE2.append(to)
        else:
            QUE.append(to)
    QUE.extend(QUE2)
    QUE2=deque()
 
    USED[x]=1

MINP=[1<<30]*(N+1)
MAXP=[-1]*(N+1)

for ind,(depth,p) in enumerate(EULER):
    MINP[p]=min(MINP[p],ind)
    MAXP[p]=max(MAXP[p],ind)

LEN=len(EULER)

seg_el=1<<(LEN.bit_length())#Segment treeの台の要素数
SEG=[(1<<30,0)]*(2*seg_el)#1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(LEN):#Dを対応する箇所へupdate
    SEG[i+seg_el]=EULER[i]

for i in range(seg_el-1,0,-1):#親の部分もupdate
    SEG[i]=min(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el):#A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1#子ノードへ
    
    while i!=0:
        SEG[i]=min(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):#区間[l,r)に関するminを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=(1<<30,0)

    while L<R:
        if L & 1:
            ANS=min(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=min(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

def LCA(l,r):
    return getvalues(min(MINP[l],MINP[r]),max(MAXP[l],MAXP[r])+1)

check=[set() for i in range(N+1)]
for c,l,x,y in Query:
    check[x].add(c)
    check[y].add(c)
    check[LCA(x,y)[1]].add(c)

LENGTH=[0]*(N+1)
LENG=0
C_LENGTH=[0]*N
C_SUM=[0]*N
C_LDICT=dict()
C_SDICT=dict()

for c in check[1]:
    C_LDICT[(1,c)]=0
    C_SDICT[(1,c)]=0
    

for i in range(1,len(EULER)):
    ind=EULER[i][1]
    c,l=EDGELIST[EULER[i-1][1]][ind]
    if EULER[i][0]>EULER[i-1][0]:
        LENG+=l
        C_LENGTH[c]+=l
        C_SUM[c]+=1

        LENGTH[ind]=LENG

        for c in check[ind]:
            C_LDICT[(ind,c)]=C_LENGTH[c]
            C_SDICT[(ind,c)]=C_SUM[c]
            

    else:
        LENG-=l
        C_LENGTH[c]-=l
        C_SUM[c]-=1
        
        
for c,pl,x,y in Query:
    ind=LCA(x,y)[1]
    print(LENGTH[x]+LENGTH[y]-LENGTH[ind]*2+(C_SDICT[x,c]+C_SDICT[y,c]-C_SDICT[ind,c]*2)*pl-(C_LDICT[x,c]+C_LDICT[y,c]-C_LDICT[ind,c]*2))
    
        
        


Measured memory_bytes: 219256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(ll i=0;i<n;i++)



int main() {
	ll K,S;
  	cin>>K>>S;
  	ll count=0;
  
  	rep(x,K+1){
     	rep(y,K+1){
         	 if(0<=S-x-y&& S-x-y<=K){
              	count++; 
             }
        }
    }
  	cout<<count<<endl;
}

Measured memory_bytes: 3636
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var arr = Console.ReadLine().Split();
        var ab = int.Parse(arr[0] + arr[1]);
        var sqrt = Math.Sqrt(ab);
        var answer = sqrt == (int) sqrt ? "Yes" : "No";
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 27504
from collections import deque
H,W = map(int,input().split())
n = int(input())
a_ls = list(map(int, input().split()))
color_q = deque()
for color, times in enumerate(a_ls,1):
    for _ in range(times):
        color_q.append(color)
ans_mat = [[0] * W for _ in range(H)]
for y in range(H):
    for x in range(W):
        ans_mat[y][x] = color_q.popleft()
for i,y in enumerate(range(H)):
    ans_ls = ans_mat[y]
    if i % 2 == 1:
        ans_ls = ans_ls[::-1]
    ans_ls = list(map(str,ans_ls))
    print(' '.join(ans_ls))

Measured memory_bytes: 3956
def gaishin(p,q,r):
  a = ((q[0]-r[0])**2+(q[1]-r[1])**2)**(0.5) #qとrの間
  b = ((r[0]-p[0])**2+(r[1]-p[1])**2)**(0.5) #rとpの間
  c = ((p[0]-q[0])**2+(p[1]-q[1])**2)**(0.5) #pとqの間
  cosp = (b**2+c**2-a**2)/(2*b*c)
  cosq = (c**2+a**2-b**2)/(2*c*a)
  cosr = (a**2+b**2-c**2)/(2*a*b)
  if cosp >= 1: cosp = 1
  if cosp <= -1: cosp = -1
  if cosq >= 1: cosq = 1
  if cosq <= -1: cosq = -1
  if cosr >= 1: cosr = 1
  if cosr <= -1: cosr = -1
  sinp = (1-cosp**2)**(0.5)
  sinq = (1-cosq**2)**(0.5)
  sinr = (1-cosr**2)**(0.5)
  sin2p = 2*sinp*cosp
  sin2q = 2*sinq*cosq
  sin2r = 2*sinr*cosr
  #if sinp == 0:
  #print(p,q,r,sinp,sin2p+sin2q+sin2r)
  
  if sin2p+sin2q+sin2r < pow(10,-7):
    infinite = float("inf")
    return (infinite, infinite)
  x = (sin2p*p[0]+sin2q*q[0]+sin2r*r[0])/(sin2p+sin2q+sin2r)
  y = (sin2p*p[1]+sin2q*q[1]+sin2r*r[1])/(sin2p+sin2q+sin2r)
  R = a/(2*sinp) #正弦定理による外接円
  return (x,y)

N = int(input())
A = []
for i in range(N):
  x,y = map(int,input().split())
  A.append((x,y))
INF = float("inf")
ans = INF
for i in range(N):
  for j in range(i+1,N):
    z = ((A[i][0]+A[j][0])/2,(A[i][1]+A[j][1])/2) #二点の中心
    dx = A[i][0]-A[j][0]
    dy = A[i][1]-A[j][1]
    hankei = ((dx**2+dy**2)**(0.5))/2
    Flag = True
    for t in range(N):
      if t == i or t == j: #選んだ二点ならスキップ
        continue
      temp = ((z[0]-A[t][0])**2+(z[1]-A[t][1])**2)**(0.5)
      hankei = max(hankei,temp)
    ans = min(ans,hankei)
#print(ans)
if N == 2:
  print(ans)
  exit()
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      p = A[i]; q = A[j]; r = A[k]
      z = gaishin(p,q,r)
      #print(z)
      hankei = 0
      for t in range(N):
        temp = ((z[0]-A[t][0])**2+(z[1]-A[t][1])**2)**(0.5)
        hankei = max(hankei,temp)
      ans = min(ans,hankei)
print(ans)

Measured memory_bytes: 76524
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n;
    cin>>n;
    vector<int> v1(n);
    for(auto &i:v1) cin>>i;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if((v1[i]+v1[j])>v1[k]&&(v1[k]+v1[j])>v1[i]&&(v1[i]+v1[k])>v1[j]&&v1[i]!=v1[j]&&v1[j]!=v1[k]&&v1[i]!=v1[k]) ans++;
            }
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 11004
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int h = sc.nextInt();
      	int w = sc.nextInt();
    	int ma[][] = new int[h][w];
      	int mb[][] = new int[h][w];
      	String stack;
      	boolean elh[] = new boolean[h];
      	boolean elw[] = new boolean[w];
      	boolean elj = true;
      
      	for(int i = 0;i < h;i++) elh[i] = false;
      	for(int i = 0;i < w;i++) elw[i] = false;
      	
		
      	for(int i = 0;i < h;i++){
          stack = sc.next();
          elj = true;
          for(int j = 0;j < w;j++){
          	if(stack.charAt(j) == '#'){
              ma[i][j] = 1;
              elj = false;
            } else ma[i][j] = 0;
          }
          if(elj) elh[i] = true;
        }
     
      	for(int i = 0; i < w;i++){
          	elj = true;
        	for(int j = 0; j < h && elj;j++){
            	if(ma[j][i] == 1) elj = false;                      
            }
          	if(elj) elw[i] = true;
        }
      
      	for(int i = 0; i < h;i++){
          if(!elh[i]){
        	for(int j = 0; j < w;j++){
            	if(!elw[j]) {
                  if(ma[i][j] == 1) System.out.print('#');
                  else System.out.print('.');
                }                     
            }
         	System.out.println();
          }
        }      	
     
	}
}


Measured memory_bytes: 39364
#include <iostream>
#include <vector>
using namespace std;
int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0)break;
    int sum = 0;
    
    for(int i = 0;i < n/4;i++){
      int tmp;
      cin >> tmp;
      sum += tmp;
    }
    cout << sum << endl;
  }
  return 0;
}

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

int32_t main()
{
     int n;
     cin>>n;
     double ans=0.0;
     for(int i=1;i<=n;i++)
     {
           double x;
           cin>>x;
           x=1/x;
           ans+=x;
     }
     ans=1/ans;
     cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int a,b,c,d; cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  int xn = 0, yn = 0, tn = 0;
  FOR(i, N) {
    GI3(t, x, y);
    int dist = abs(x - xn) + abs(y - yn), tp = t - tn;
    if (dist > tp || dist % 2 != tp % 2) {
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}

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

using namespace std;
int main(){

  vector<double> n;  
  double a;
  int i=0;
  while(cin >> a){
    n.push_back(a);
    i++;
  }
  sort(n.begin(),n.end());

  cout << n[i-1] - n[0] << endl;

 
 return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>

using namespace std;

int sq(int x)
{
	return x * x;
}

bool is_sq(int x)
{
	for (int i = 0; i * i <= x; ++i) {
		if (i * i == x) {
			return true;
		}
	}
	return false;
}

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

	vector<vector<int>> p(N, vector<int>(D));

	for (auto &v : p) {
		for (auto &x : v) {
			cin >> x;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int d2 = 0;
			for (int k = 0; k < D; ++k) {
				d2 += sq(p[i][k] - p[j][k]);
			}
			if (is_sq(d2)) {
				++ans;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int n, q, t;
	int i, left, right, mid, count = 0;
	int s[100001];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &s[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d", &t);
		left = 0;
		right = n;
		while (left < right) {
			mid = (left + right) / 2;
			if (s[mid] == t) {
				count++;
				break;
			}
			else if (t < s[mid])
				right = mid;
			else
				left = mid + 1;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<string>a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i);
  }
  vector<int>b(4);
  for (int i=0;i<n;i++) {
    if(a.at(i)=="AC"){
      b.at(0)++;
    }
    if(a.at(i)=="WA"){
      b.at(1)++;
    }
    if(a.at(i)=="TLE"){
      b.at(2)++;
    }
    if(a.at(i)=="RE"){
      b.at(3)++;
    }
  }
  cout << "AC" << " " << 'x' << " " << b.at(0) << endl;
  cout << "WA" << " " << 'x' << " " << b.at(1) << endl;
  cout << "TLE" << " " << 'x' << " " << b.at(2) << endl;
  cout << "RE" << " " << 'x' << " " << b.at(3) << endl;
}

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

int main(void){
    double W, H;
    double x, y;
    double ans_1;
    int ans_2;
    
    cin >> W >> H >> x >> y;

    ans_1 = W / 2 * H;
    if(W/2 == x && H/2 == y){
        ans_2 = 1;
    } else {
        ans_2 = 0;
    }

    printf("%.9lf %d", ans_1, ans_2);

    return 0;
}

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

int main() 
{
    long long n,m,l,sum=0;
    cin>>n>>m>>l;
    long long a[n][m];
    long long b[m][l];
    long long c[n][l];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    
    
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin>>b[i][j];
        }
    }
    
     for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
            sum=sum+a[i][k]*b[k][j];
            }
            c[i][j]=sum;
            sum=0;
        }
    }
    
     for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout<<c[i][j]<<((j==l-1) ? "\n" :" ");
        }
    }
return 0;
} 




Measured memory_bytes: 3320
#include <bits/stdc++.h>
#define Mashu cout << "UUZ ate it." << endl
#define RE register int
#define ll long long
using namespace std;

inline int read(){
	char ch=getchar();
	int x=0,cf=1;
	while(ch<'0'||ch>'9') {
		if(ch=='-') cf=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	if (cf < 0) return -x;
	else return x;
}

int qwq[100010];

int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		int a, b;
		cin >> a >> b;
		if (a == b) qwq[i] = 1;
	} 
	int ok = 0;
	for (int i = 1; i <= n - 2; i++){
		if (qwq[i] && qwq[i + 1] && qwq[i + 2]) ok = 1;
	} 
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	Mashu;
}


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;

const string N = "No\n";
const string Y = "Yes\n";

int main() {
#ifdef LOCAL
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    if (a.back() - a[0] > 1) {
        cout << N;
        return 0;
    }
    if (a.back() == a[0]) {
        if (a[0] == n - 1 || a[0] * 2 <= n)
            cout << Y;
        else
            cout << N;
        return 0;
    }
    int small = 0;
    int large = 0;
    for (int x : a)
        if (x == a[0])
            small++;
        else
            large++;
    int unique_large = a.back() - small;
    if (unique_large * 2 <= large && unique_large >= 1)
        cout << Y;
    else
        cout << N;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    cin >> s;
    for (auto &&i : s) {
        i = static_cast<char>('A' + ((i - 'A' + 23) % 26));
    }
    cout << s << "\n";
    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const ll inf = 1e18;
int main() {
    IO;
    int n;
    ll ans = 1;
    cin >> n;
    bool flag = true;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        if (x == 0) {
            ans = 0;
            flag = true;
        }
        else if (ULLONG_MAX / ans < x || x * ans > inf) {
            flag = false;
            //cout << ans << " " << ULLONG_MAX << " " << ULLONG_MAX / ans << endl;
        }
        if (flag) ans *= x;
        // cout << ans << endl;
    }
    if (flag)
        cout << ans << endl;
    else {
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <time.h>

const char week[7][10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int main()
{
  struct tm tm;
  int month, day;


  while(scanf("%d %d", &month, &day)!=EOF){
    if(month == 0 && day == 0) break;

    tm.tm_hour = 0;
    tm.tm_min = 0;
    tm.tm_sec = 0;
    tm.tm_mday = day;
    tm.tm_mon = month-1;
    tm.tm_year = 2004-1900;
    tm.tm_isdst = 0;
    mktime(&tm);

    printf("%s\n", week[tm.tm_wday]);
  }

  return 0;
}

Measured memory_bytes: 644