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

# define FOR(i,a,b) for (int i=(a);i<(b);i++)
# define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
# define REP(i, n) for (int i = 0; i < (int)(n); i++)
# define RREP(i,n) for (int i=(n)-1;i>=0;i--)

# define int(x) int x; scanf("%d",&x);
# define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
# define string(x) string x; cin >> x;

using namespace std;

namespace utils{
  template <typename T> void print(vector<vector<T>> mat) {
    REP (i, mat.size()) {
      REP (j, mat[0].size()) cout << mat[i][j] << ' ';
      cout << endl;
    }
  }

  template <typename T> void print(vector<T> v) {
    REP (i, v.size())
      if (i >= v.size()-1)
	cout << v[i];
      else
	cout << v[i] << ' ';
    
    cout << endl;
  }

  template <typename T> pair<T, T> shape(vector<vector<T>> mat) {
    int d1, d2;

    d1 = mat.size();
    if (d1 > 0) d2 = mat[0].size();
    else int d2 = 0;
    cout << "(" << d1 << ", " << d2 << ")" << endl;
    return make_pair(0, 0);
  }

  template <typename T> vector<vector<T>> empty(int n, int m) {
    vector<vector<T>> mat(n, vector<T>(m));
    return mat;
  }
}


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

  int cnt;
  int i =1;
  int next=0;
  while(cnt < n){
    if(next == 2){
      cout << cnt << endl;
      break;
    }
    next = A[i-1];
    i = next;
    cnt++;
  }
  if(next != 2){
    cout << -1 << endl;
  }
    
}


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

using namespace std;

vector<int> adjList[4096];
int n, k;
bool seen[4096];

int dfs(int x, int left)
{
	seen[x] = true;
	if (left <= 0) return 0;
	int ret = 1;
	for (int i = 0; i < adjList[x].size(); i++)
	{
		int y = adjList[x][i];
		if (seen[y]) continue;
		ret += dfs(y, left-1);
	}
	return ret;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int delta = 0, sum = 1;
		for (int j = 0; j < adjList[i].size(); j++)
		{
			int y = adjList[i][j];

			fill(seen, seen + n, false);
			seen[i] = true;
			int a = dfs(y, k / 2);

			fill(seen, seen + n, false);
			seen[i] = true;
			int b = dfs(y, (k+1)/2);
			delta = max(delta, b - a);
			sum += a;
		}
		ans = max(ans, sum + delta);
	}
	cout << n - ans << '\n';
	return 0;
}



Measured memory_bytes: 512
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

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

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

int f( LL x ) {
    int s=0;
    while ( x!=0 ) {
        s+=x%10;
        x/=10;
    }
    return s;
}

LL n;
void main() {
    R(n);
    int ans=f(n);
    LL x=n,y=1;
    while ( x ) {
        chkmax(ans,f(x-1)+f(y-1));
        x/=10;
        y*=10;
    }
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<cmath>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

int cave_num[1000][1000];
bool is_prime[1000001];
P trans[1000001];
P dp[1000001];
int m;

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

P dfs(int n) {
	if (dp[n].first != -1)return dp[n];
	int res1 = 0, res2 = 0;
	P now = trans[n];
	for (int i = -1; i <= 1; i++) {
		if (now.second + 1 > 999)break;
		if (now.first + i < 0 || now.first + i>999)continue;
		if (cave_num[now.first + i][now.second + 1] > m)continue;
		P next = dfs(cave_num[now.first + i][now.second + 1]);
		if (res1 <= next.first) {
			if (res1 == next.first) {
				res2 = max(res2, next.second);
			}
			else {
				res2 = next.second;
			}
			res1 = next.first;
		}
	}
	if (is_prime[n]) {
		if (res2 == 0)res2 = n;
		res1++;
	}
	return dp[n] = P(res1, res2);
}

void num() {
	int sx = 499, sy = 500;
	int x = 1; cave_num[sx][sy] = x; trans[x] = P(sx, sy);
	for (int i = 1; i <= 999; i++) {
		if (i % 2) {
			for (int j = 0; j < i; j++) {
				cave_num[++sx][sy] = ++x;
				trans[x] = P(sx, sy);
			}
			for (int j = 0; j < i; j++) {
				cave_num[sx][--sy] = ++x;
				trans[x] = P(sx, sy);
			}
		}
		else {
			for (int j = 0; j < i; j++) {
				cave_num[--sx][sy] = ++x;
				trans[x] = P(sx, sy);
			}
			for (int j = 0; j < i; j++) {
				cave_num[sx][++sy] = ++x;
				trans[x] = P(sx, sy);
			}
		}
	}
	for (int i = 0; i < 999; i++) {
		cave_num[--sx][sy] = ++x;
		trans[x] = P(sx, sy);
	}
}

int main() {
	int n;
	prime();
	num();
	while (scanf("%d %d", &m, &n), m) {
		for (int i = 0; i <= m; i++)dp[i] = P(-1, -1);
		P p = dfs(n);
		printf("%d %d\n", p.first, p.second);
	}
}

Measured memory_bytes: 23332
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    c = set(LI())
    if len(c) == n:
        return 'YES'

    return "NO"


print(main())





Measured memory_bytes: 27756
def solve(A, B, C):
    return B + min(C, B) + min(A+1, C - min(C, B))

if __name__ == "__main__":
    l = input().split()
    A, B, C = int(l[0]), int(l[1]), int(l[2])
    print(solve(A, B, C))


Measured memory_bytes: 2940
n,a,b,c = map(int, input().split())
s=[input() for i in range(n)]
ans=[]
from collections import defaultdict
d = defaultdict(int)
d["A"]=a
d["B"]=b
d["C"]=c
def add(c1,c2):
    global d
    ans.append(c1)
    d[c1]+=1
    d[c2]-=1

for i in range(n):
    que = s[i]
    nxt="NONE"
    if i!=n-1:
        nxt = s[i+1]

    q1,q2=que

    if d[q1]==d[q2]==0:
        print("No")
        exit()
    if d[q1]==d[q2]==1:
        if q1 in nxt:
            add(q1,q2)
        else:
            add(q2,q1)
    elif d[q1]>=d[q2]:
        add(q2,q1)
    else:
        add(q1,q2)

print("Yes")
for a in ans:
    print(a)

Measured memory_bytes: 87204
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(dead_code)]
const MOD: usize = 1e9 as usize + 7;

macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        x: i32,
        l: [i32; n],
    }
    let mut dist: i32 = 0;
    let mut ans: i32 = 1;
    for i in l.into_iter(){
        dist += i;
        if dist > x {break;}
        ans += 1;
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int n;
  cin>>n;
  int cnt=0;
  set<string>st;
  rep(i,n){
    string s;
    cin>>s;
    if(!st.count(s)){
      cnt++;
      st.insert(s);
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 19120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	private static ArrayList<Integer> queue = new ArrayList<Integer>();
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
        	String input[] = br.readLine().split("\\s+");
        	int a=0;
        	int b=0;

        	for(int i = 0; i < input.length; i++){
        		String l = input[i];
        		if(checkInt(l)){
        			//数字なのでデキューに追加
        			queue.add(Integer.valueOf(l));
        			continue;
        		}
        		a = queue.get(queue.size()-1);
        		queue.remove(queue.size()-1);
        		b = queue.get(queue.size()-1);
        		queue.remove(queue.size()-1);
        		//記号なのでキューを利用して演算
        		if(l.equals("+")){
        			queue.add(b+a);
        		} else if(l.equals("-")){
        			queue.add(b-a);
        		} else if(l.equals("*")){
        			queue.add(b*a);
        		} else if(l.equals("/")){
        			queue.add(b/a);
        		}
        	}
        	System.out.println(queue.get(0));
        } catch (NumberFormatException e) {
        	e.printStackTrace();
        } catch (IOException e) {
        	e.printStackTrace();
        }
    }
	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}
}



Measured memory_bytes: 25028
#include <bits/stdc++.h>
# define ll long long 
# define vi vector<int>
# define pii pair<int,int> 
#define mp make_pair
#define pb push_back
# define PI acos(-1)
# define double long double
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	double a,b,x ; 
	cin >> a >> b >> x ; 
	double ans ; 
	double v = (a*a*b) / 2 ; 
	if( v > x ) {
		ans = (PI / 2) - atan((2*x) /(b*b*a)); 
	} else {
		ans =  atan((2*a*a*b - 2*x)/(a*a*a)) ; 
	}
	cout << fixed << setprecision(10) << (ans *180 )/ PI ; 
	return 0 ; 
}



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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  int count = 3;
  if(a == b){
    count--;
  }
  if(b == c){
    count--;
  }
  if(c == a){
    count--;
  }
  if(count == 0){
    cout << "1" <<endl;
  }
  else{
    cout << count << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

#include<cmath>

using namespace std;

int main()

{

    string s;

    cin>>s;

    if(s=="++++")

    {

        cout<<4;

    }

    else if(s=="+-++" || s=="++-+" || s=="+++-" || s=="-+++")

    {

        cout<<2;

    }

    else if(s=="++--" || s=="+-+-" || s=="-+-+" || s=="--++" or s=="+--+" or s=="-++-")

    {

        cout<<0;

    }

    else if(s=="+---" || s=="-+--" || s=="--+-" || s=="---+")

    {

        cout<<-2;

    }

    else if(s=="----")

    {

        cout<<-4;

    }

    return 0;

}



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

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

  int num = 0;
  long long ans = 0;
  num = N/K;
  ans += pow(num,3.0);
  if(K%2==0){
    num = (N+(K/2))/K;
    ans += pow(num,3.0);
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define inf 1e9 + 10
using namespace std;
int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    ll m=s.length();
    ll n=t.length();
    ll dp[m+1][n+1];
    for(ll i=0;i<=n;i++)
        dp[0][i]=0;
    for(ll i=0;i<=m;i++)
        dp[i][0]=0;
    for(ll i=1;i<=m;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    ll i=m,j=n;
    string out="";
    while(i>0&&j>0)
    {
        if(s[i-1]==t[j-1])
        {
            out+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
            j--;
    }
    reverse(out.begin(),out.end());
    cout<<out<<endl;
    return 0;
}


Measured memory_bytes: 74000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    int a[n],b[n],c[n];
    REP(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<vector<int>>> dp(vector<vector<vector<int>>>(n + 1, vector<vector<int>>(400 + 1, vector<int>(400 + 1, INF))));
    dp[0][0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                if(j - a[i] < 0 || k - b[i] < 0) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
            }
        }
    }
    int ans = INF;
    for(int i = 1; ma * i <= 400 && mb * i <= 400; i++){
        ans = min(ans, dp[n][ma * i][mb * i]);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27264
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int k, x;

    cin >> k >> x;

    vector <int> v;

    v.push_back(x);

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

        v.push_back(x-i);
        v.push_back(x+i);
    }

    sort(v.begin(), v.end());

    for (auto n : v) {

        cout << n << " ";
    }

    return 0;
}


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

int main() {
    int a, b;
    
    cin >> a >> b;
    
    if ( a + b >= 10 ) {
        cout << "error" << endl;
    } else {
        cout << a + b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
'use strict'

function compare(a,b) {
  let r = 0;
  if(a.city < b.city){r = -1}
  else if( a.city > b.city ){ r = 1; }
  else if( a.value < b.value ){ r = 1; }
  else if( a.value > b.value ){ r = -1; }

  return r;
}
function Main(input) {
  input = input.split('\n');
  let N = input.shift();
  let array=[];
  for(let i=0;i<N;i++){
    let tmp = input[i].split(' ')
    array.push({id:i+1,city:tmp[0],value:parseInt(tmp[1])});
  }
  array.sort(compare);
  for(let i=0;i<N;i++){
    console.log(array[i].id);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}


void solve(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
}

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


Measured memory_bytes: 3656
#include <stdio.h>

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

int main(void)
{
    char buf[256];
    int x;

    fgets(buf, 256, stdin);
    buf[255] = '\0';

    sscanf(buf, "%d", &x);

    printf("%d\n", cube(x));
    return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string s = Console.ReadLine ();
            int l = s.Length;

            long total = 0;

            for (int i = 0; i < (1 << (l - 1)); i++)
            {

                long sum = 0;

                string m = s[0].ToString ();

                for (int j = 0; j < l - 1; j++)
                {
                    if (((i >> j) & 1) > 0)
                    {
                        sum += long.Parse (m);
                        m = s[j + 1].ToString ();

                    }
                    else
                    {
                        m += s[j + 1].ToString ();
                    }
                }
                total += sum + long.Parse (m);
            }

            Console.WriteLine (total);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static long MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  string s; cin >> s;
  int sum = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') sum++;
  }
  cout << 700 + 100 * sum << endl;
  return;
}

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
   int n,cnt,min,min2;
  scanf("%d",&n);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  min = a[0];
  min2 = a[1];
  for(int i = 1;i<n;i++){
     if(min > a[i]){
       min2 = min;
       min = a[i];
     } 
    if(min < a[i] && min2 > a[i]){
      min2 = a[i];
    }
  }

  while(min2 > 0){
    cnt = 0;
    for(int i = 0;i < n;i++){
      if(a[i]%min2 != 0){
        cnt++;
      }
    }
    if(cnt <= 1){
      printf("%d\n",min2);
      min2 = 0;
    }
    min2 --;
  }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll N, M; cin >> N >> M;
	vector<P> v;
	REP(i, N) {
		ll s, t; cin >> s >> t;
		v.pb({s, t});
	}
	vector<ll> p(M); cin >> p; p.pb(0); p.pb(linf);
	sort(p.begin(), p.end());
	vector<ll> sOdd(p.size(), 0), sEven(p.size(), 0);
	REP(i, (int)p.size()-1) {
		sOdd[i+1] += sOdd[i];
		sEven[i+1] +=+ sEven[i];
		if (i % 2 == 0) {
			sEven[i+1] += p[i+1]-p[i];
		}
		else {
			sOdd[i+1] += p[i+1]-p[i];
		}
	}
	ll ans = 0;
	REP(i, N) {
		ll s, t; tie(s, t) = v[i];
		bool f = false;
		if (s > t) {
			f = true;
			int temp = s; s = t; t = temp;
		}
		int sid = (upper_bound(ALL(p), s)-p.begin())-1;
		int tid = (lower_bound(ALL(p), t)-p.begin())-1;
		// [sid, tid)
		// cout << s << " " << t << " " << sid << " " << tid << endl;
		// ll ba = ans;
		if (tid > sid+1) {
			if ((!f && (sid % 2 == 0)) || (f && (tid%2 == 0))) {
				ans += sEven[tid] - sEven[sid+1];
			}
			else {
				ans += sOdd[tid] - sOdd[sid+1];
			}
		}
		if (sid == tid) { // [s, t)
			ans += t-s;
		}
		else {
			if ((tid-sid)%2 == 0 || !f) {
				ans += p[sid+1]-s;
			}
			if ((tid-sid)%2 == 0 || f) {
				ans += t-p[tid];
			}
		}
		// cout << ans-ba << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6848
#include <bits/stdc++.h>
//#pragma warning( disable : 4996 )
#define ll long long
#define pb push_back
#define endl '\n'
#define fastIO cin.tie( 0 );ios_base::sync_with_stdio( false )
#define pii pair<int, int>
#define eps 1e-13
#define N 200005

using namespace std;

int n, node, MAXDIS = 0;
vector<int> G[N];

void dfs( int now, int depth, int parent )
{
    if ( depth > MAXDIS ) {
        MAXDIS = depth;
        node = now;
    }
    for ( int v:G[now] ) {
        if ( v != parent )
            dfs( v, depth + 1, now );
    }

}

inline void init()
{
    int a, b;
    cin >> n;
    for ( int i = 0; i < n - 1; ++i ) {
        cin >> a >> b;
        G[a].emplace_back( b );
        G[b].emplace_back( a );
    }
}

inline void solve()
{
    dfs( 1, 1, -1 );
    dfs( node, 1, -1 );
    if ( MAXDIS % 3 == 2 )
        cout << "Second";
    else
        cout << "First";
    cout << endl;
}

int main()
{
    fastIO;
    init();
    solve();

    return 0;
}

Measured memory_bytes: 20608
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cmath>

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

class node{
public:
	int id;
	node *parent;
	vector<node*> child;
	int depth;
	node():id(-1),parent(NULL),child(0),depth(0){};
	
	friend ostream& operator<<(ostream& os,const node& N){
		cout << "node " << N.id << ": parent = ";
		if(N.parent==NULL)cout << -1;
		else cout << N.parent->id;
		cout << ", depth = " << N.depth << ", ";
		if(N.parent==NULL)cout << "root";
		else if(N.child.empty()) cout << "leaf";
		else cout << "internal node";
		cout << ", [";
		if(!N.child.empty())cout << N.child[0]->id;
		for(int i=1;i<N.child.size();i++) cout << ", " << N.child[i]->id;
		cout << "]" << endl;
	}
};

int main(){
	int n,m;
	cin >> n;
	vector<node> N(n);
	REP(i,n){
		N[i].id=i;
	}
	REP(i,n){
		int id,k,c;
		cin >> id >> k;
		REP(j,k){
			cin >> c;
			N[c].parent = &N[id];
			N[id].child.push_back(&N[c]);
		}
	}
	int i=0;
	while(N[i].parent!=NULL)i++;
	queue<node> que;
	que.push(N[i]);
	while(!que.empty()){
		node n = que.front();que.pop();
		int cSize=n.child.size();
		REP(j,cSize){
			N[n.child[j]->id].depth=n.depth+1;
			que.push(N[n.child[j]->id]);
		}
	}
	REP(j,n) cout << N[j];
	return 0;
}

Measured memory_bytes: 13964
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n;
    cin>>n;
    for (long long int i=500; i>=-500; i--){
        for (long long int j=500; j>=-500; j--){
            long long int i1=pow(i,5);
            long long int j1=pow(j,5);
            if (i1-j1==n){
                cout<<i<<' '<<j;
                return 0;
            }
        }
    }
}

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

int main(){
	int w, h, n; cin >> w >> h >> n;
	int x1 = 0, x2 = w, y1 = 0, y2 = h;
	for(int i = 0; i < n; ++i){
		int x, y, a; cin >> x >> y >> a;
		switch(a){
			case 1:
				x1 = max(x1, x);
				break;
			case 2:
				x2 = min(x2, x);
				break;
			case 3:
				y1 = max(y1, y);
				break;
			case 4:
				y2 = min(y2, y);
				break;
		}
	}
	cout << ((x2 - x1 > 0) && (y2 - y1 > 0) ? (x2 - x1) * (y2 - y1) : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
k = int(input())

digit = len(str(n))
# dp[i桁まで検査済み][coincidence][0以外の個数]
dp = [[[0] * (k + 1) for i in range(2)] for j in range(digit + 1)]

dp[0][1][0] = 1
for a in range(1, digit + 1):
    digitvalue = int(str(n)[a - 1])
    for c in range(k + 1):
        if c == k:
            # 最大値と不一致で0以外の個数がk個になる
            dp[a][0][c] += dp[a-1][0][k] * 1
            dp[a][0][c] += dp[a-1][0][k-1] * 9
            # d != 0(仮に3) -> 0
            # d == 0 -> 0にすると最大値と一致するのでだめ
            dp[a][0][c] += dp[a-1][1][k] * (1 if digitvalue != 0 else 0)
            # d != 0(仮に3) -> 1, 2(0はkにならないのでだめ、3はb == 1になるのでだめ)
            # d == 0 -> 0にするとkが増えないのでだめ
            dp[a][0][c] += dp[a-1][1][k-1] * (digitvalue - 1 if digitvalue != 0 else 0)
            # 最大値と一致で0以外の個数がk個になる
            dp[a][1][c] += dp[a-1][1][k] * (1 if digitvalue == 0 else 0)
            dp[a][1][c] += dp[a-1][1][k-1] * (1 if digitvalue != 0 else 0)
        elif c != k:
            # 最大値と不一致で0以外の個数がc個になる
            dp[a][0][c] += dp[a-1][0][c] * 1
            dp[a][0][c] += 0 if c == 0 else dp[a-1][0][c-1] * 9
            dp[a][0][c] += dp[a-1][1][c] * (1 if digitvalue != 0 else 0)
            dp[a][0][c] += 0 if c == 0 else dp[a-1][1][c-1] * (digitvalue - 1 if digitvalue != 0 else 0)
            dp[a][1][c] += dp[a - 1][1][c] * (1 if digitvalue == 0 else 0)
            dp[a][1][c] += 0 if c == 0 else dp[a - 1][1][c - 1] * (1 if digitvalue != 0 else 0)
        else:
            None
#     print("--", a)
#     for i in range(k + 1):
#         print(dp[a][0][i])
#     for i in range(k + 1):
#         print(dp[a][1][i])

print(dp[digit][0][k] + dp[digit][1][k])


Measured memory_bytes: 3192
program hi;
var 
    a, ans: QWord;
    n, i: integer;
    ex: boolean = false;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do begin
        read(a);
        if a = 0 then begin
            writeln(0);
            exit;
        end;
        if ans > 1000000000000000000 div a then
            ex := true;
        ans := ans * a;
    end;
    if ex then 
        writeln(-1)
    else
        writeln(ans);
end.

Measured memory_bytes: 1328
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
void solve(){
	ll a,b,c,d; 
	cin>>a>>b>>c>>d; 
	cout<<max({a*c,a*d,b*c,b*d})<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3664
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int x = 0;

        int c = 1;
        int p = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();

            if (p == a) {
                c++;
            } else {
                if (c > 1) {
                    x += c / 2;
                }
                p = a;
                c = 1;
            }
        }
        if (c > 1) {
            x += c / 2;
        }

        out.println(x);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b; cin>>a>>b;
    if(a+b<10) cout<<a+b<<endl;
    else cout<<"error"<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];

    vector<int> Y(N);
    rep(i, N) Y[i] = X[i];
    sort(Y.begin(), Y.end());    

    int z = N/2;
    int prev, after;
    prev = Y[z - 1];
    after = Y[z];

    rep(i, N) {
        if (X[i] == after) {
            cout << prev << endl;
        } else if (X[i] <= prev) {
            cout << after << endl;
        } else {
            cout << prev << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>

int main(void)
{
	int n,i,t,max,min;
	scanf("%d",&n);
	scanf("%d",&t);
	max=t;
	min=t;
	for(i=0;i<n-1;i++){
		scanf("%d",&t);
		if(t>max){
			max=t;
		}
		if(t<min){
			min=t;
		}
	}
	printf("%d\n",((max-min+1)/2));
	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  double x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  double ans;
  ans = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
  cout << fixed << setprecision(4) << sqrt(ans) << endl;
  return 0;
}

Measured memory_bytes: 1284
#include <cstdio>
#include <set>
#include <queue>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define QCLR(q) while(!q.empty()) q.pop();

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

int N,K,rx[100],ry[100],gx,gy;

class Hex
{
public:
	int px[8], py[8];
	Hex(int tpx[8], int tpy[8])
	{
		REP(i,N) 
		{
			px[i]=tpx[i];
			py[i]=tpy[i];
		}
	}

	bool operator<(const Hex& h) const
	{
		REP(i,N)
		{
			if(px[i]!=h.px[i]) return px[i]<h.px[i];
			if(py[i]!=h.py[i]) return py[i]<h.py[i];
		}
		return false;
	}
};

class State
{
public:
	Hex h;
	int c;
	State(Hex h, int c)
	:h(h),c(c)
	{}
};

queue<State> q;
set<Hex> s;

int dist60(int x1, int y1, int x2, int y2)
{
	return (abs(x1-x2)+abs(y1-y2)+abs((x1+y1)-(x2+y2)))/2;
}

bool crash(Hex& h, int p)
{
	REP(i,K) if(h.px[p]==rx[i]&&h.py[p]==ry[i]) return true;
	
	return false;
}

bool connect(Hex& h, int j)
{
	FOR(i, max(j-2,0), j)
	{
		if(h.px[i]==h.px[j]&&h.py[i]==h.py[j]) return false;
		
		int cnt=0;
		REP(k,6)
		{
			int tx=h.px[i]+dx[k], ty=h.py[i]+dy[k];
			if(h.px[j]==tx&&h.py[j]==ty) 
			{
				++cnt;
				break;
			}
		}
		
		if(j-i==1&&cnt!=1) return false;
		if(j-i!=1&&cnt==1) return false;
	}
	
	return true;
}

bool end=false;

bool create(int p, Hex& h, int c, bool sk)
{
	if(end) return true;
	if(p==N) 
	{		
		if(!s.count(h)) 
		{
			if(dist60(gx,gy,h.px[0],h.py[0])==0) end=true;
			s.insert(h);
			q.push(State(h,c+1));
			return true;
		}
		return false;
	}
	
	int cnt=0;
	if(connect(h,p)) create(p+1,h,c,false);
	if(!sk)
	{
		REP(i,6)
		{	
			h.px[p]+=dx[i], h.py[p]+=dy[i];
			int dist=dist60(gx,gy,h.px[0],h.py[0]);
			if(dist>1) dist=(dist-1)*2+1;
			if(i<=1) ++dist;
			if( p==0&&dist > 20-c || !connect(h,p) || crash(h,p))
			{
				h.px[p]-=dx[i], h.py[p]-=dy[i];
				continue;
			}
			
			if(create(p+1,h,c,true)) ++cnt;
			h.px[p]-=dx[i], h.py[p]-=dy[i];
			
			if(p==0||p==N-1) { if(cnt==2) break; }
			else { if(cnt==1) break; }
		}
	}
	
	return false;
}

int bfs(int ix[8], int iy[8])
{
	q.push(State(Hex(ix,iy), 0));

	while(1)
	{
		State s=q.front(); q.pop();
		if(s.h.px[0]==gx&&s.h.py[0]==gy) return s.c;
		
		create(0,s.h,s.c,false);
	}
	
	return 0;
}
int main()
{
	while(scanf("%d", &N),N)
	{
		end=false;
		QCLR(q);
		s.clear();
		int px[8], py[8];
		REP(i,N) scanf("%d %d", &px[i], &py[i]);
		
		scanf("%d", &K);
		REP(i,K) scanf("%d %d", &rx[i], &ry[i]);

		scanf("%d%d", &gx,&gy);
		printf("%d\n", bfs(px,py));
	}
}

Measured memory_bytes: 5380
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    string s;
    int r = 0, b = 0;
  	cin >> n;
    cin >> s;
    for(char c: s)
    {
        if (c == 'R')
        {
            r++;
        }
        else
        {
            b++;
        }
    }

    if(r > b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long unsigned
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;


int main() {
    set<int> st;
    int a, b, c;
    cin >> a >> b >> c;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    if(st.size() == 2) cout << "Yes" << endl;
    else cout << "No"  << endl;


    return 0;
}

/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(std::string S)
{
    if (S == "SUN")
    {
        cout << 7 << endl;
    }
    if (S == "MON")
    {
        cout << 6 << endl;
    }
    if (S == "TUE")
    {
        cout << 5 << endl;
    }
    if (S == "WED")
    {
        cout << 4  << endl;
    }
    if (S == "THU")
    {
        cout << 3 << endl;
    }
    if (S == "FRI")
    {
        cout << 2 << endl;
    }
    if (S == "SAT")
    {
        cout << 1 << endl;
    }
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

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

vector<int> zAlgorithm(const string& s){
    int N = s.size();
  vector<int> z(N);
  
  int L = 0;   // LCP の左端
  int R = 0;   // LCP の右端
  for (int i = 1; i < N; i++) {
    if (i > R) {
      // Case 1
      L = R = i;
      while (R < N && s[R-L] == s[R]) R++;
      z[i] = R-L;
      R--;
    } else {
      int k = i-L;
      // z[k] < s[i..R].size()
      if (z[k] < R-i+1) {
        // Case 2
        z[i] = z[k];
      } else {
        // Case 3
        // R の次から照合を続ける
        L = i;
        R++;
        while (R < N && s[R-L] == s[R]) R++;
        z[i] = R-L;
        R--;
      }
    }
  }
  return z;
}

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

    int ans = 0;
    REP(i, N){
        auto prefix = zAlgorithm(S.substr(i));
        REP(j, N-i){
            int tmp = min(prefix[j], j);
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

int main(){
	int M=1000000007,N,W,r=0;
	scanf("%d%d",&N,&W);
	vector<int>w(N+1);
	vector<vector<int> >bag(N+1);
	bag[0].resize(W+1);bag[0][0]=1;
	for(int i=0;i<N;bag[++i].resize(W+1))scanf("%d",&w[i]);
	sort(w.begin(),w.end(),greater<int>());
	for(int i=0;i<N;i++)for(int j=W;j>=0;j--)bag[i+1][j]=(bag[i][j]+(j>=w[i]?bag[i][j-w[i]]:0))%M;
	for(int i=N-1,s=0;i>=0;s+=w[i--])for(int j=max(0,W-s-w[i]+1);j<=W-s-w[i+1];j++)r=(r+bag[i+1][j])%M;
	printf("%d\n",r);
}

Measured memory_bytes: 8660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
vector<int> g[2][size];
int visit[2][size] = {};
int color[2][size] = {};
map<int,map<int,int>> cnt;
void dfs(int i,int v){
	visit[i][v] = 1;
	if(i == 1) cnt[color[0][v]][color[1][v]]++;
	for(int u:g[i][v]){
		if(visit[i][u]) continue;
		color[i][u] = color[i][v];
		dfs(i,u);
	}return;
}
int main(){
	int N,K,L;cin>>N>>K>>L;
	rep(i,0,K){
		int a,b;
		cin>>a>>b; a--; b--;
		g[0][a].push_back(b);
		g[0][b].push_back(a);
	}rep(i,0,L){
		int a,b;
		cin>>a>>b; a--; b--;
		g[1][a].push_back(b);
		g[1][b].push_back(a);
	}
	rep(i,0,N){
		if(!visit[0][i]){ color[0][i] = i; dfs(0,i); }
	}rep(i,0,N){
		if(!visit[1][i]){ color[1][i] = i; dfs(1,i); }
	}rep(i,0,N){
		cout<<(i ? " " : "")<<cnt[color[0][i]][color[1][i]];
	}cout<<endl;
}

Measured memory_bytes: 41600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0161
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Dictionary<int, int> teams = new Dictionary<int, int>();
                for (int i = 0 ; i < n ; i++)
                {
                    int[] items = RIntAr();
                    int time = (items[1] + items[3] + items[5] + items[7]) * 60 + items[2] + items[4] + items[6] + items[8];
                    teams.Add(items[0], time);
                }
                int[] ranks = teams.OrderBy(x => x.Value).Select(x => x.Key).ToArray();
                Console.WriteLine(ranks[0]);
                Console.WriteLine(ranks[1]);
                Console.WriteLine(ranks[n - 2]);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 20952
R, G, B, N = map(int, input().split())

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0:
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n, x;
  cin >> n >> x;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];


  ll cnt = 0;
  ll y = 0;
  rep(i, n){
    if(y <= x) cnt++;
    y += l[i];
  }
  if(y <= x) cnt++;

  cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 256
// 基本テンプレート

#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
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 int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M;
int a[100010], cnt[200010], rec[200010];

signed main() {
    cin >> N >> M;
    rep(i,0,N) cin >> a[i];

    int sum = 0;
    rep(i,0,N-1) {
        int x = a[i] + 1, y = a[i+1];
        if(x > y) y += M;
        int d = y - x;
        sum += d + 1;
        cnt[x]++; cnt[y]--; rec[y] -= d;
    }

    rep(i,1,2*M+2) {
        cnt[i] += cnt[i-1];
        rec[i] += (cnt[i] + rec[i-1]);
    }

    int ans = INF;
    repq(i,1,M) {
        int temp = rec[i] + rec[i+M];
        chmin(ans, sum - temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096