akhauriyash/Code-Regression huggingface dataset:
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 998244353;
const double PI = acos(-1);

int main() {
	IOS;
	vector<int> aa(3);
	for (int i = 0; i < 3; i++) cin >> aa[i];
	sort(aa.begin(), aa.end());
	if (aa[0] == 5 && aa[1] == 5 && aa[2] == 7) {
		cout << "YES";
	}
	else cout << "NO";
}

Measured memory_bytes: 3660
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e3 + 5;
const double eps = 1e-9;
vi adj[MAXN];
char s[MAXN];
int vis[MAXN], col[MAXN];

bool dfs(int u, int d) {
	vis[u] = 1;
	col[u] = d;
	for (int v: adj[u]) {
		if (vis[v] && col[v] == d)
			return 0;
		if (vis[v])
			continue;
		if (!dfs(v, d^1))
			return 0;
	}
	return 1;
}

void mrk(vi& cur, int& cnt) {
	if (cur.empty())
		return;
	cnt++;
	for (int i: cur)
		vis[i] = 1;
	vi nx;
	for (int i: cur) {
		for (int j: adj[i]) {
			if (vis[j])
				continue;
			nx.pb(j);
		}
	}
	sort(nx.begin(), nx.end());
	nx.erase(unique(nx.begin(),nx.end()),nx.end());
	mrk(nx, cnt);
}

int main() {
	int n; ni(n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		for (int j = 0; j < n; j++) {
			if (s[j] == '1')
				adj[i].pb(j);
		}
	}
	bool fl = dfs(0, 0);
	if (!fl) return !printf("-1\n");
	int ans = 0;
	for (int i = 0; i < n; i++) {
		mem(vis, 0);
		int cnt = 0;
		vi tmp = {i};
		mrk(tmp, cnt);
		ans = max(ans, cnt);
	}
	pri(ans);
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int coin = 0;
    
    for(int i = 0; i < 2; i++){
        if(a > b){
            coin += a--;
        } else {
            coin += b--;
        }

    }

    cout << coin;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        final long A = sc.nextLong();
        final long B = sc.nextLong();

        final long g = gcd(A, B);

        final List<Map<Long, Integer>> pfs = primeFactorize(g);

        System.out.println(pfs.size() + 1);
    }

    private static long gcd(final long x, final long y) {
        return y == 0 ? x : gcd(y, x % y);
    }

    private static List<Map<Long, Integer>> primeFactorize(long n) {
        final List<Map<Long, Integer>> res = new ArrayList<>();
        for (long a = 2; a*a <= n; a++) {
            if (n % a != 0) continue;
            int ex = 0;
            while (n % a == 0) {
                ex++;
                n /= a;
            }
            res.add(Collections.singletonMap(a, ex));
        }
        if (n != 1) {
            res.add(Collections.singletonMap(n, 1));
        }
        return res;
    }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main{
  static int N;
  static boolean[] check;
  static ArrayList<String> list = new ArrayList<>();
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    N = Integer.parseInt(sc.nextLine());
    String P = String.join("", sc.nextLine().split(" "));
    String Q = String.join("", sc.nextLine().split(" "));
    check = new boolean[N];
    func(0,"");
    Collections.sort(list);
    System.out.println(Math.abs(list.indexOf(P)-list.indexOf(Q)));
  }
  public static void func(int M, String str){
    if(str.length() == N){
      list.add(str);
      check[M-1] = true;
      return;
    }
    
    for(int i = 1; i <= N; i++){
      if(check[i-1]){
        continue;
      }
      String U = str + i;
      check[i-1] = true;
      func(i, U);
      check[i-1] = false;
    }
  }
}

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

int main(){
	string s,t;
  	cin >> s >> t;
  
  	int ans = 0;
  	for(int i = 0; i < 3 ; i++){
    	if(s[i] == t[i]){
        	ans++;
        }
    }
  cout << ans <<  endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n,d; cin>>n>>d;
    double D = 2*(double)d  + 1;
    double a = n/D;
    int ans = ceil(a);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
    int f1, f2, temp, m[10];
    for(f1 = 0; f1 < 10; f1++)
    {
        scanf("%d",&m[f1]);
    }
    for(f1 = 0; f1 < 9; f1++)
    {
        for(f2 = f1 + 1; f2 < 10; f2++)
        {
            if(m[f1] < m[f2]){
                temp = m[f1];
                m[f1] = m[f2];
                m[f2] = temp;
            }
        }
    }
    for(f1 = 0; f1 < 3; f1++)
    {
        printf("%d\n",m[f1]);
    }
    return 0;
}


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

signed main() {
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    mp[a]++;
    mp[b]++;
  }

  bool flag = true;
  for (int i = 0; i < N; i++) {
    if (mp[i] % 2 == 1) {
      flag = false;
      break;
    }
  }

  if (flag) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 6528
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 参考書数
        int n = sc.nextInt();
        // アルゴリズム数
        int m = sc.nextInt();
        // すべてのアルゴリズム理解度
        int x = sc.nextInt();
        // 参考書の金額
        int[] c = new int[n];
        // アルゴリズムの理解度
        int[][] a = new int[n][m];
        // 入力
        for(int i=0; i<n; i++) {
            c[i] = sc.nextInt();
            for(int j=0; j<m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        // 参考書の合計金額のリスト
        List<Integer> list = new ArrayList<>();

        // 参考書の全パターンのループ、bit全探索の全通り
        // for (int i = 0; i < 1 << n; i++)でもいい
        for (int i = 0; i < Math.pow(2,n); i++) {
            // m番目のアルゴリズムの理解度の合計
            int[] aTotal = new int[m];
            // 参考書の合計金額
            int cTotal = 0;
            // 各参考書のループ
            for (int j = 0; j < n; j++) {
                // 最下桁が1かどうかを判定
                // 1だったら購入の対象
                if ((i >> j & 1) == 1) {
                    for(int k=0; k<m; k++) {
                        // アルゴリズム理解度の合計
                        aTotal[k] += a[j][k];
                    }
                    // 参考書金額の合計
                    cTotal += c[j];
                }
            }

            // アルゴリズムを覚えたかどうか
            boolean isMastered = true;
            // 参考書を買い終わったので、アルゴリズムを覚えられたかどうかの判定
            for(int k=0; k<m; k++) {
                if(aTotal[k] < x) {
                    isMastered = false;
                    break;
                }
            }
            // アルゴリズムを覚えた場合は参考書の合計金額をlistについか
            if(isMastered) {
                list.add(cTotal);
            }
        }
        // アルゴリズムを１つも覚えていない場合は-1、覚えた場合最小値
        if(list.size() < 1) {
            System.out.println(-1);
        } else {
            Collections.sort(list);
            System.out.println(list.get(0));
        }
    }
}

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

int main(){
    for(int i = 0; i < 3; i++){
        int aH, aM, aS, bH, bM, bS, a, b, ans, h, m, s;
        cin >>aH >>aM >>aS >>bH >>bM >>bS;
        a = (aH * 60 * 60) + (aM * 60) + aS;
        b = (bH * 60 * 60) + (bM * 60) + bS;
        ans = b - a;
        h = ans / 60 / 60;
        m = ans % 3600 / 60;
        s = ans % 60;
        cout <<h <<" " <<m <<" " <<s <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int a[3][3];
  bool b[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    cin>>a[i][j];
    b[i][j]=false;
    }
  }
  int n;
  cin>>n;
  int num;
  for(int i=0;i<n;i++){
    cin>>num;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(num==a[j][k]) b[j][k]=true;
      }
    }
  }
  if(b[0][0]&b[0][1]&b[0][2]){cout<<"Yes"<<endl;}
  else if(b[1][0]&b[1][1]&b[1][2]){cout<<"Yes"<<endl;}
  else if(b[2][0]&b[2][1]&b[2][2]){cout<<"Yes"<<endl;}
  else if(b[0][0]&b[1][0]&b[2][0]){cout<<"Yes"<<endl;}
  else if(b[0][1]&b[1][1]&b[2][1]){cout<<"Yes"<<endl;}
  else if(b[0][2]&b[1][2]&b[2][2]){cout<<"Yes"<<endl;}
  else if(b[0][0]&b[1][1]&b[2][2]){cout<<"Yes"<<endl;}
  else if(b[0][2]&b[1][1]&b[2][0]){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


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


int main(){
	long i,j,k,z;
	long n,m,l,sum,a[100][100],b[100][100];
	char input[6002],*p=NULL;
	
	fgets(input,sizeof input,stdin);
	sscanf(input,"%ld %ld %ld",&n,&m,&l);
	
	for(i=0;i<n;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		a[i][0]=atol(p);
		
		for(j=1;j<m;j++){
			p=strtok(NULL," ");
			a[i][j]=atol(p);
		}
		
	}
	for(i=0;i<m;i++){
		fgets(input,sizeof input,stdin);
		p=strtok(input," ");
		b[i][0]=atol(p);
		
		for(j=1;j<l;j++){
			p=strtok(NULL," ");
			b[i][j]=atol(p);
		}
		
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			sum=0;
			for(k=0;k<m;k++){
				sum+=a[i][k]*b[k][j];
			}
			printf("%ld",sum);
			if(j+1!=l){
				printf(" ");
			}
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 764
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

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

areas = []
for i in range(M):
	a, b = list(map(int, input().split()))
	areas.append([b - 1, a])
areas.sort()

num = 0
loc = 0
for i in range(M):
	if loc < areas[i][1]:
		num += 1
		loc = areas[i][0]

print(num)

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

using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int u = 1e6;

    int n, c; cin >> n >> c;

    vvi v(c + 1, vi(u + 1));

    for(int i = 0; i < n; i++)
    {
        int s, t, ch; cin >> s >> t >> ch;

        for(int j = (s * 10) - 5; j < t * 10; j++)
            v[ch][j] = 1;
    }

    for(int i = 2; i <= c; i++)
    for(int j = 1; j <= u; j++)
        v[i][j] += v[i - 1][j];

    int ans = 0;

    for(int i = 1; i <= u; i++)
        ans = max(ans, v[c][i]);

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


Measured memory_bytes: 125312
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict

N = int(readline())
C = (0,) + tuple(map(int, readline().split()))
m = map(int, read().split())
AB = zip(m, m)

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)


root = 1
parent = [0] * (N + 1)
depth = [0] * (N + 1)  # 根を深さ 1 として
order = []
stack = [root]
depth[root] = 1
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
        depth[y] = depth[x] + 1


def merge(v, p):
    A = dp[v]
    B = dp[p]
    size_A = size[v]
    size_B = size[p]
    c = C[p]
    if len(A) < len(B):
        A, B = B, A
        size_A, size_B = size_B, size_A
    answer[c] += (size_A - A[c]) * (size_B - B[c])
    # B を A にマージ
    for key, cnt in B.items():
        answer[key] -= cnt * A[key]
        A[key] += cnt
    size[p] = size_A + size_B
    dp[p] = A


answer = [0] * (N + 1)
dp = [defaultdict(int) for _ in range(N + 1)]
size = [0] * (N + 1)

for v in order[::-1]:
    c = C[v]
    n = size[v] + 1 - dp[v][c]
    answer[c] -= size[v] * n
    size[v] += 1
    dp[v][c] = size[v]
    if v == root:
        break
    p = parent[v]
    merge(v, p)

A = dp[root]
c = size[root]
for v in range(1, N + 1):
    print(c * A[v] + answer[v])


Measured memory_bytes: 162912
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n;

int main(){
	cin >> n;

	cout << n/2 + (n%2) << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        d = 4*h*n-N*h-N*n
        if d == 0 or N*h*n%d != 0: continue
        w = N*h*n//d
        if w < 0: continue
        print(h,n,w)
        exit()

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

int main(){
    int x;
    rep(i, 5){
        int x;
        cin >> x;
        if (x == 0) cout << i + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            int n = Integer.parseInt(line);
            
            if(n == 0)break;
            
            LinkedHashMap<Integer, Long> employee = new LinkedHashMap<Integer, Long>();
            
            for(int i = 0;i < n;i++){
                String[] dataSet = br.readLine().split(" ");
                int e = Integer.parseInt(dataSet[0]);
                int p = Integer.parseInt(dataSet[1]);
                int q = Integer.parseInt(dataSet[2]);
                
                if(employee.containsKey(e)){
                    employee.put(e, employee.get(e) + (long)p * q);
                }else{
                    employee.put(e, (long)p * q);
                }
            }
            
            boolean zeroFlag = true;
            for(int e : employee.keySet()){
                if(employee.get(e) >= 1000000){
                    zeroFlag = false;
                    System.out.println(e);
                }
            }
            if(zeroFlag){
                System.out.println("NA");
            }
        }
    }
}



Measured memory_bytes: 26348
#include <cstdio>

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

  char s;

  printf("%d\n", N-1);
  fflush(stdout);

  scanf(" %c%*s", &s);
  if (s == 'V') return 0;

  printf("0\n");
  fflush(stdout);

  scanf(" %c%*s", &s);
  if (s == 'V') return 0;  

  int lb=0, ub=N-1;
  while (ub-lb > 1) {
    int mid=(lb+ub)>>1;
    printf("%d\n", mid);
    fflush(stdout);

    char t;
    scanf(" %c%*s", &t);
    if (t == 'V') return 0;
    ((mid&1)^(s==t)? lb:ub) = mid;
  }
}

Measured memory_bytes: 760
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        v: [i64; 3]
    }
    if v.iter().max().unwrap() != &v[2] && v.iter().min().unwrap() != &v[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
{$R-,S-,Q-,I-,O+}
const NN=28;
      MAX=200000;
var a,b,seq:array[0..MAX+9] of int64;
    bits:array[0..NN] of int64;
    n,i,k:longint;
    l,m,t,ans,bit_count:int64;

procedure quicksort(l,r:longint);
var v,t:int64;i,j:longint;
begin
  if l<r then begin
    v:=seq[r];i:=l-1;j:=r;
    repeat
      repeat inc(i) until v<=seq[i];
      repeat dec(j) until seq[j]<=v;
      t:=seq[i];seq[i]:=seq[j];seq[j]:=t;
    until j<=i;
    seq[j]:=seq[i];seq[i]:=seq[r];seq[r]:=t;
    quicksort(l,i-1);
    quicksort(i+1,r);
  end;
end;

function count(p,q:int64):int64;
var p_idx,q_idx,l,r,m:longint;
begin
  l:=1;r:=n;
  p_idx:=-1;
  while l<=r do begin
    m:=(l+r) div 2;
    if p>seq[m] then
      l:=m+1
    else begin
      p_idx:=m;
      r:=m-1;
    end;
  end;

  if p_idx=-1 then
  begin
    count:=0;
    exit;
  end;

  l:=1;r:=n;
  q_idx:=-1;
  while l<=r do begin
    m:=(l+r) div 2;
    if q>=seq[m] then
      l:=m+1
    else begin
      q_idx:=m;
      r:=m-1;
    end;
  end;

  if q_idx=-1 then q_idx:=n else dec(q_idx);
  count:=q_idx-p_idx+1;
end;

begin
  read(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n do read(b[i]);
  for k:= 0 to NN do begin
    bit_count:=0;
    l:=1 shl k;
    m:=1 shl (k+1);
    for i:=1 to n do seq[i]:=b[i] mod m;
    quicksort(1,n);
    for i:=1 to n do begin
      t:=a[i] mod m;
      inc(bit_count,count(l-t  ,m-1-t  ));
      inc(bit_count,count(l-t+m,m-1-t+m));
    end;
    bits[k]:=bit_count mod 2;
  end;

  ans:=0;
  for k:=0 to NN do inc(ans,(1 shl k)*bits[k]);
  writeln(ans);
end.

Measured memory_bytes: 4736
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = []
q.append(0)
d_f[0] = 0
while q:
    x = q.pop(-1)
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop(-1)
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 62496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	int N,M;
	int[] K;
	List<int>[] L;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		N = cin.nextInt();
		M = cin.nextInt();
		L = new List<int>[M];
		for (int i = 0; i < M; i++)
		{
			L[i] = new List<int>();
		}

		for (int i = 0; i < N; i++)
		{
			int K = cin.nextInt();
			for (int j = 0; j < K; j++)
			{
				int l = cin.nextInt() - 1;
				L[l].Add(i);
			}
		}
		UnionFind uf = new UnionFind(N);
		for (int i = 0; i < M; i++)
		{
			for (int j = 0; j < L[i].Count; j++)
			{
				uf.unite(L[i][0], L[i][j]);
			}
		}
		for (int i = 1; i < N; i++)
		{
			if (!uf.same(i, 0))
			{
				Console.WriteLine("NO");
				return;
			}
		}
		Console.WriteLine("YES");
	}

	class UnionFind
	{
		int N;
		int[] parent;
		int[] rank;

		public UnionFind(int N)
		{
			parent = new int[N];
			rank = new int[N];
			for (int i = 0; i < N; i++)
			{
				parent[i] = i;
			}
		}

		public int find(int x)
		{
			if (parent[x] == x)
			{
				return x;
			}
			else
			{
				return parent[x] = find(parent[x]);
			}
		}

		public void unite(int x, int y)
		{
			x = find(x);
			y = find(y);
			if (rank[x] < rank[y])
			{
				parent[x] = y;
			}
			else
			{
				parent[y] = x;
				if (rank[x] == rank[y]) rank[x]++;
			}
		}

		public bool same(int x, int y)
		{
			return find(x) == find(y);
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 15916
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005;

int a[105], f[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, 1, k + 1) {
        vector<int> b;
        rep(j, 0, n) {
            if(i - a[j] < 0) {
                break;
            }
            b.emplace_back(f[i - a[j]]);
        }
        sort(b.begin(), b.end());
        b.erase(unique(b.begin(), b.end()), b.end());
        b.emplace_back(sz(b) + 1);
        int res = 0;
        rep(j, 0, sz(b)) {
            if(b[j] != j) {
                res = j;
                break;
            }
        }
        f[i] = res;
    }
    if(f[k]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

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

int main() {
  string S;
  int K;
  int64_t Q=998244353;
  cin>>S>>K;
  vector<int> p;
  int a=0,A=0,V=S.size();
  for(int i=0;i<V;i++){
    if(S.at(i)=='1'){
      a++;
      A++;
    }
    else{
      p.push_back(a);
      a=0;
    }
  }
  int N=p.size();
  K=min(K,A);
  vector<vector<vector<int64_t>>> dp(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> yr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  vector<vector<vector<int64_t>>> tr(K+1,vector<vector<int64_t>>(K+1,vector<int64_t>(N+1)));
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=K;j++){
      yr[j][j][i]=dp[j][j][i];
      tr[K-j][0][i]=dp[K-j][0][i];
      for(int k=j;k<K;k++){
        yr[k+1][j][i]=(yr[k][j][i]+dp[k+1][j][i])%Q;
        tr[K-j][k+1-j][i]=(tr[K-j][k-j][i]+dp[K-j][k+1-j][i])%Q;
      }
    }
    int B=p[i];
    for(int j=0;j<=K;j++){
      for(int k=0;k<=j;k++){
        int64_t X=0,Y=0;
        if(k-B-1>=0){
          X=tr[j][k-B-1][i];
        }
        if(j-A+B-1>=0){
          Y=yr[j-A+B-1][k][i];
        }
        dp[j][k][i+1]=(tr[j][k][i]+yr[j][k][i]-dp[j][k][i]-X-Y+3*Q)%Q;
      }
    }
  }
  int64_t Z=0;
  for(int j=0;j<=K;j++){
    for(int i=j;i<=min(K,j+a);i++){
      Z+=dp[i][j][N];
      Z%=Q;
    }
  }
  cout<<Z<<endl;
}



Measured memory_bytes: 85120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i=l; i<=r; i++){
        if(i%d == 0){
            ans ++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3580
from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
ans = 0
for i in a:
    d[i] += 1
ans1 = []
for v, c in d.items():
    if c >= 2:
        ans1.append(v)

ans1.sort(reverse=True)
if len(ans1) > 1:
    ans = ans1[0] * ans1[1]

ans2 = []
for v, c in d.items():
    if c >= 4:
        ans2.append(v)

ans2.sort(reverse=True)

if len(ans2) > 0:
    ans = max(ans, ans2[0] * ans2[0])

print(ans)

Measured memory_bytes: 18592
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef long long ll;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n;
    cin >> n;
    vector<ll> a_s(n), b_s(n);
    rep(i, n)
    {
        cin >> a_s[i] >> b_s[i];
    }
    sort(a_s.begin(), a_s.end());
    sort(b_s.begin(), b_s.end());
    ll ans;
    if (n & 1)
    {
        ans = b_s[(n - 1) / 2] - a_s[(n - 1) / 2] + 1;
    }
    else
    {
        ans = (b_s[n / 2 - 1] + b_s[n / 2]) - (a_s[n / 2 - 1] + a_s[n / 2]) + 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6276
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    string s;
    int n;
    int count1 = 0;
    int count2 = 0;
    int x = 0, y = 0, z = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> s;
        int j = 0;
        for (string::size_type pos = 0; (pos = s.find("AB", pos)) != string::npos; pos += 2) {
            count1++;
        }

        if (s[0] == 'B' && s[s.size() - 1] == 'A') x++;
        else if (s[s.size() - 1] == 'A') y++;
        else if (s[0] == 'B') z++;
    }

    if (y == 0 && z == 0) count2 = max(0, x - 1);
    else count2 = x + min(y, z);

    cout << count1 + count2 << endl;

    return 0;
}



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

#define gc() std::getchar()
#define pc(i) std::putchar(i)

template <typename T>
inline T read(){ 
	T x = 0;
	char ch = gc();
	bool f = 0;
	while(!std::isdigit(ch)){ 
		f = (ch == '-');
		ch = gc();
	} 
	while(std::isdigit(ch)){ 
		x = x * 10 + (ch - '0');
		ch = gc();
	} 
	return f ? -x : x; 
}

template <typename T>
void put(T x){ 
	if (x < 0){ 
		x = -x;
		pc('-');
	} 
	if (x < 10){ 
		pc(x + 48);
		return;
	} 
	put(x / 10);
	pc(x % 10 + 48);
	return ;
} 

#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Rep(i, j, k) for(int i = j; i >= k; --i)
#define rdi() read <int> ()
#define rdl() read <long long> ()
#define pti(i) put <int> (i), putchar(' ')
#define ptl(i) put <long long> (i), putchar(' ')
#define pub(i) push_back(i)
#define pob() pop_back()

typedef long long ll;
typedef float fl;
typedef double db;

void fake_main(){ 
	int d = rdi(), t = rdi(), s = rdi();
	if (t * s >= d) printf("Yes");
	else printf("No\n");
} 

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

Measured memory_bytes: 3760
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, X);
    IN(ll, D);
    if (D == 0)
    {
        if (X == 0)
        {
            OUT(1);
        }
        else
        {
            OUT(N + 1);
        }
        return 0;
    }
    if (D < 0)
    {
        X += (N - 1) * D;
        D = -D;
    }
    auto f = [&](ll x) {
        ll m = (x % D + D) % D;
        return ii{(x - m) / D, m};
    };
    map<ll, vii> C;
    ll a = 0;
    ll b = 0;
    REP(l, N + 1)
    {
        auto [i, k] = f(a);
        auto [j, _] = f(b);
        C[k].push_back({i, -1});
        C[k].push_back({j, 1});
        a += X + l * D;
        b += X + (N - l - 1) * D;
    }
    ll ans = 0;
    for (auto [_, S] : C)
    {
        SORT(S);
        ll s = 0;
        ll p = -INF;
        for (auto [i, k] : S)
        {
            k = -k;
            if (k == 1 and s == 0)
            {
                p = i;
            }
            if (k == -1 and s == 1)
            {
                ans += i - p + 1;
            }
            s += k;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 28604
#include <iostream>

using namespace std;

int main(){

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

    int a;

    cin>>a;

    for(int i = 9; i > 0; i--){
        if(a % i == 0){
            int res = a/i;
            if(res > 9){
                cout<<"No";
                break;
            }else{
                cout<<"Yes";
                break;
            }
        }
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <tuple>
using namespace std;

string S; int c1 = 0, c2 = 0;

int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0') c1++;
		if (S[i] == '1') c2++;
	}
	cout << min(c1, c2) * 2 << endl;
	return 0;
}

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

void fnInput(int& rnHighNum, int& rnMinSum, int& rnMaxSum)
{
  cin >> rnHighNum >> rnMinSum >> rnMaxSum;
}

int fnDigitsSum(int nNum)
{
  int nDigitsSum = 0;
  while ( nNum )
  {
    nDigitsSum += nNum % 10;
    nNum /= 10;
  }
  return nDigitsSum;
}

int fnSomeSums(int nHighNum, int nMinSum, int nMaxSum)
{
  int nTotal = 0;
  for (int n = 1; n <= nHighNum; n++)
  {  
    int nDigitsSum = 0;
    nDigitsSum += fnDigitsSum(n);
    if (nMinSum <= nDigitsSum && nDigitsSum <= nMaxSum)
      nTotal += n;
  }
  return nTotal;
}

int main()
{
  int nHighNum, nMinSum, nMaxSum;
  fnInput(nHighNum, nMinSum, nMaxSum);

  cout << fnSomeSums(nHighNum, nMinSum, nMaxSum) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> m1(n), m2(n);
    rep(i, n){
        cin >> a[i];
        m1[i] = a[i];
        m2[i] = a[i];
    }

    REP(i, 1, n){
        chmax(m1[i], m1[i - 1]);
    }
    rrep(i, n - 1){
        chmax(m2[i], m2[i + 1]);
    }

    rep(i, n){
        int ans = 0;
        if(i){
            chmax(ans, m1[i - 1]);
        }
        if(i < n - 1){
            chmax(ans, m2[i + 1]);
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
    
    int n,count=0,ans;
    cin >> n;
    int l[n*2];
    for(int i = 0; i < n*2; i++){
        cin >> l[i];
    }
    
    sort(l,l+n*2);
    
    while(count < n*2){
        ans += min(l[count],l[count+1]);
        count+=2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] dp=new int[n+1];
    int[] a={6,9,36,81,216,729,1296,6561,7776,46656,59049};
    Arrays.fill(dp,Integer.MAX_VALUE-7);
    dp[n]=0;
    for(int i=n;i>=0;i--){
      if(dp[i]!=Integer.MAX_VALUE){
        for(int j=0;j<11;j++){
          if(i>=a[j]){
            dp[i-a[j]]=Math.min(dp[i]+1,dp[i-a[j]]);
          }
        }
      }
    }
    int min=Integer.MAX_VALUE;
    for(int i=0;i<6&&i<dp.length;i++){
      min=Math.min(dp[i]+i,min);
    }
    System.out.println(min);
  }
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int ans(int N)
{
    if(N < 2) return 0;
    else return N * (N - 1) / 2;
}

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

    cout << ans(N) + ans(M) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n, x;
    cin >> n >> x;

    if(n == 2 && x == 2){
        cout << "Yes\n1\n2\n3" << endl;
        return 0;
    }

    if(x == 1 || x == 2 * n - 1){
        cout << "No" << endl;
        return 0;
    }

    vector<int> a(2*n-1);
    if(x == 2){
        int m = (2*n-1)/2;
        a[m-1] = 2*n-1;
        a[m] = 1;
        a[m+1] = 2;
        a[m+2] = 2*n-2;

        int y = 3;
        for(int i = 0; i < 2*n-1; i++){
            if(m-1 <= i && i <= m+2){
                continue;
            }
            a[i] = y++;
        }
    }else{
        int m = (2*n-1)/2;
        a[m-1] = 1;
        a[m] = x;
        a[m+1] = x+1;
        a[m+2] = 2;

        int y = 3;
        for(int i = 0; i < 2*n-1; i++){
            if(m-1 <= i && i <= m+2){
                continue;
            }
            if(y == x){
                y += 2;
            }
            a[i] = y++;
        }
    }

    cout << "Yes" << endl;

    rep(i, 2*n-1){
        cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
from itertools import product
def inpl(): return list(map(int, input().split()))

N, A, B, C = inpl()
L = [int(input()) for _ in range(N)]

ans = 1e9

for X in product(range(4), repeat=N):
    P = [[] for _ in range(4)]
    for i, x in enumerate(X):
        P[x].append(L[i])

    if min(map(len, P[1:])) == 0:
        continue

    tmp = 0
    for Q, D in zip(P[1:], [A, B, C]):
        tmp += 10*(len(Q)-1) + abs(D-sum(Q))
    if tmp < ans:
        ans = min(tmp, ans)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i,3){
        if(s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    ans = inf
    for i in range(1, 11):
        if i * 1000 >= N:
            ans = min(ans, i * 1000 - N)
    print(ans)
main()



Measured memory_bytes: 78248
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = double.Parse(Console.ReadLine());
            var ans = (int)(n/2) / n;
            Console.WriteLine(1-ans);
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    StringBuilder SS = new StringBuilder(S);
    int N = SS.length(), check =0;
    SS = SS.reverse();    
    while (true) {
      if (N >= 5) {
        if (SS.substring(0,5).equals("esare") || SS.substring(0,5).equals("maerd")) {
          SS = SS.delete(0,5);
          N = SS.length();
          continue;
        }
      }
      if (N >= 6) {
        if (SS.substring(0,6).equals("resare")) {
          SS = SS.delete(0,6);
          N = SS.length();
          continue;
        }
      }
      if (N >= 7) { 
        if (SS.substring(0,7).equals("remaerd")) {
          SS = SS.delete(0,7);
          N = SS.length();
          continue;
        }
      }
      break;
    }
    if (N == 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  } 
}

Measured memory_bytes: 27708
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import math

def dic_order(a):
    b =[x for x in range(1, n+1)] 
    cnt = 1
    for i in range(n - 1):
        cnt += b.index(a[i]) * math.factorial(n - i - 1)
        b.remove(a[i])
    return cnt

p_order = dic_order(p)
q_order = dic_order(q)
print(abs(p_order - q_order))

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <utility>
using namespace std;
void rotate(int& a,int& b,int& c,int& d){
	swap(a,b);
	swap(a,d);
	swap(c,d);
}
int main()
{
	while(true){
		int n,sum=1,num[6]={1,2,3,4,5,6};
		string s;
		cin>>n;
		if(!n)break;
		while(n--){
			cin>>s;
			if(s=="North")rotate(num[5],num[1],num[0],num[4]);
			else if(s=="South")rotate(num[4],num[0],num[1],num[5]);
			else if(s=="West")rotate(num[5],num[2],num[0],num[3]);
			else if(s=="East")rotate(num[3],num[0],num[2],num[5]);
			else if(s=="Right")rotate(num[1],num[3],num[4],num[2]);
			else if(s=="Left")rotate(num[2],num[4],num[3],num[1]);
			sum+=num[0];
		}
		cout<<sum<<endl;
	}
    return 0;
}

Measured memory_bytes: 1212