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

using namespace std;
using int64 = long long int;

int P[25];

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

	for (int i = 0; i < n; i++)
	{
		cin >> P[i];
	}

	int ans = 0;
	for (int i = 0; i < n - 2; i++)
	{
		if (min(P[i], P[i + 2]) < P[i + 1] && max(P[i], P[i + 2]) > P[i + 1])
		{
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8

class Cards
	def initialize(args)
		@cards = args
		@rank = "nil"
		@cards.sort!
	end

	def getCards
		@cards
	end

	def rankcheck
		
		if four then
			@rank = "four card"
		elsif fullhouse then
			@rank = "full house"
		elsif straight then
			@rank = "straight"
		elsif three then
				@rank = "three card"
		elsif two then  			
			@rank = "two pair"
		elsif one then
			@rank = "one pair"
		else
			@rank = "null"
		end
		return @rank
	end

	def four
		a = check(@cards)
		uniq = unique(a,1)
		result = (a.size==4 && uniq)? true : false
	end
	def fullhouse
		a = check(@cards)
		uniq = unique(a,2)
		result = (a.size==5 && uniq)? true : false
	end
	def straight
		a,b,c = @cards[0],@cards[2], @cards[-1]
		sum = @cards.inject(0){|tmp,x| tmp+x}
		if sum==(a+c)*2+b && check(@cards).size==0 then
			result  = true	
		end
		result = true if @cards == [1,10,11,12,13]
		result = false if @cards == [1,2,11,12,13]
		return result
	end
	def three
		a = check(@cards)
		uniq = unique(a,1)
		result = (a.size==3 && uniq)? true : false
	end
	def two
		a = check(@cards)
		uniq = unique(a,2)
		result = (a.size==4 && uniq)? true : false
	end
	def one
		a = check(@cards)
		uniq = unique(a,1)
		result =  (a.size==2 && uniq)? true : false
	end
	
	def check(args)
		args.select{|x|args.index(x) != args.rindex(x)}
	end
	def unique(args,n)
		tmp = args.uniq.size==n
	end
	
end

while !STDIN.eof? do
	str = gets.chomp.split(',').map(&:to_i)
	cards = Cards.new(str)
	#p cards.getCards

	print "#{cards.rankcheck}\n"

end

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

    vector<int> w={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    k--;
    cout << w[k] << endl;
}    
    

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    int ans = b[q - 1] - b[0];
    for (int i = q; i < n; i++) {
        vector<int> keks(n);
        for (int j = 0; j < n; j++) {
            if (a[j] < b[i - q + 1]) {
                keks[j] = 1;
            } else {
                if (a[j] <= b[i]) {
                    keks[j] = 2;
                }
            }
        }
        int cnt = 0;
        int len = 0;
        int good = 0;
        for (int j = 0; j < n; j++) {
            if (keks[j] == 2) {
                cnt++;
            }
            if (keks[j] != 1) {
                len++;
            }
            if (j + 1 == n || keks[j + 1] == 1) {
                good += max(0, min(len - k + 1, cnt));
                cnt = len = 0;
            }
        }
        if (good >= q) {
            ans = min(ans, b[i] - b[i - q + 1]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    val = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            tmp = ((i % 2019) * (j % 2019)) % 2019
            val = tmp if val > tmp else val
            if val == 0:
                print(val)
                exit()

    print(val)


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

int main(){
  int N;
  cin >> N;
  int f=0;
  int temp=N;
  while(temp!=0){
    f+=temp%10;
    temp = temp/10;
  }
  if(N%f==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define Y {cout<<"YES"<<endl;return 0;}
#define pb(x) push_back(x)
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f,maxn=2e5+100;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
int x,y,a[maxn]; 
int main()
{
	cin>>x>>y;
	if(x<y) cout<<"0"<<endl;
	else cout<<"10"<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int l = 0;
    int r = s.size() - 1;
    while(s.at(l) != 'A') {
        l++;
    }
    while(s.at(r) != 'Z') {
        r--;
    }
    cout << r - l + 1 << endl;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,m,q=l_in()

abcd=[l_in() for _ in range(q)]

s = []


def check(s):
    return sum(d for a,b,c,d in abcd if s[b-1] - s[a-1] == c)

def search(s, current):
    tmp = 0
    for d in range(current, m+1):
        s.append(d)
        if len(s) == n:
            tmp = max(tmp, check(s))
        else:
            tmp = max(tmp, search(s, d))
        s.pop()
        
    return tmp

print(search(s,1))


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

int main() {

  string s,t;
  cin>>s>>t;


  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i))
      cnt++;
  }


    cout<<cnt<<endl;


  return 0;
}

Measured memory_bytes: 3920
/**
*   @Author : MeGaCrazy
*   @InitTime : Thu Jan 17 08:43:14 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif

    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++){
    	int a;
    	cin>>a;
	mp[a]++;
    }
    int ans=0;
    for(auto &v:mp){
    	if(v.second%2==1){
    		ans++;
    	}
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int n,maxs=0;
string s;
map<string,int> m;
map<string,int>::iterator it;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		m[s]++;
	}
	for(it=m.begin();it!=m.end();it++){
		maxs=max(maxs,it->second);
	}
	for(it=m.begin();it!=m.end();it++){
		if(it->second==maxs){
			cout<<it->first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
#include <iostream>

using namespace std;

int f(int a, int b, int h) {
    return (a + b) * h / 2;
}

int main() {

    int a, b, h;
    cin >> a >> b >> h;

    int result = f(a, b, h);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[][] robot = new int[N][2];
		for(int i=0; i<N; i++) {
			int X = sc.nextInt();
			int L = sc.nextInt();

			robot[i][0] = X-L;
			robot[i][1] = X+L;
		}

		int ans = 0;

		Arrays.sort(robot, (a, b) -> a[1] - b[1]);

		int index = 0;
		int point = robot[0][1];
		while(index < N) {
			point = robot[index][1];
			ans++;
			index++;
			while(index < N && robot[index][0] < point)
				index++;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 94672
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <random>
#include <map>
#include <ctime>
#include <cstdlib>

using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using namespace std;

int INF = 1e6;

typedef long long ll;
typedef double d;




void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int check = (int)s[--k];
	check += 32;
	s[k] = (char)(check);
	cout << s << endl;
}

int main() {
	
	//clock_t start = clock();
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//start = clock() - start;
	//cout << setprecision(10) <<"Program executed in: " <<  (float)start / CLOCKS_PER_SEC << endl;
}




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

int func(ll a, ll b){
  int diga, digb;
  diga = digb = 0;
  while(a!=0){
    a /= 10;
    diga++;
  }
  while(b!=0){
    b /= 10;
    digb++;
  }
  return max(diga, digb);
}

int main(){
  ll n;
  int m=99;
  
  cin >> n;
  for (ll i=1; i*i<=n; i++) {
    ll j=n/i;
    if(n==i*j) {
      m = min(m, func(i, j));
    }
  }
  
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3636
import Data.List
{-

-}
main = do
    n <- getLine >>= return . read 
    strlist <- sequence . take n $ repeat getLine
    let initials = map (\xs -> (head xs) : "") strlist
    let ans = solve initials
    print ans

solve :: [String] -> Integer
solve initials = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h
    where m = count "M" initials
          a = count "A" initials
          r = count "R" initials
          c = count "C" initials
          h = count "H" initials

count :: String -> [String] -> Integer
count search list = toInteger . length $ [e | e <- list, e == search]


Measured memory_bytes: 48508
N,K,Q=map(int,input().split())
p=[0]*N
s=0
for x in range(Q):
  A=int(input())
  p[A-1]+=1
  s+=1
for y in range(N):
  if K+p[y]-s>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9856
package main

import (
	"fmt"
)

func AizuITP12A() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Println("a > b")
	} else if a < b {
		fmt.Println("a < b")
	} else {
		fmt.Println("a == b")
	}

}


func main(){
       AizuITP12A()
}


Measured memory_bytes: 1092
#include <stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d %d %d",&a,&b,&c);
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  if(b>c){
    d=b;
    b=c;
    c=d;
  }
  if(a>b){
    d=a;
    a=b;
    b=d;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 998244353;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

vector<vector<ll>> g;

mint dfs(ll v, ll p = -1) {
    mint ans = 1;
    for(auto u : g[v]) {
        if (u == p) continue;
        ans *= dfs(u, v);
    }
    return ans + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<pair<ll, ll>> xd(n);
    rep(i, n) cin >> xd[i].first >> xd[i].second;
    sort(all(xd));
    set<pair<ll, ll>> s;
    g.resize(n);
    rrep(i, n) {
        ll x = xd[i].first, d = xd[i].second;
        while((sz(s) > 0) && (s.begin()->first < (x + d))) {
            g[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.insert(make_pair(x, i));
    }
    mint ans = 1;
    for(auto x : s) ans *= dfs(x.second);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 26880
_set = {
    "S" : [],
    "H" : [],
    "C" : [],
    "D" : []
}
for i in range(0 ,13):
    for item in _set:
        _set[item].append(0)

n = int(input())
for i in range(0, n):
    T, N = input().split()
    _set[T][int(N) - 1] = 1

for key in _set:
    for i in range(0, 13):
        if (_set[key][i] == 0):
            print(key + ' ' + str(i + 1))


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

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

  vector<vector<int>>  c(h+1, vector<int>(w+1, 0));
  int color = 1;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      int k = i & 1 ? j : w - j + 1;

      c[i][k] = color;
      if (--a[color] == 0) color++;
    }
  }

  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
}
  


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;


void solve() {
	string s; cin >> s;
	int len = s.size();
	rep(i, len) {
		if (i % 2 == 0 && s[i] == 'L') {
			cout << "No" << endl; return;
		}
		if (i % 2 && s[i] == 'R') {
			cout << "No" << endl; return;
		}
	}
	cout << "Yes" << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;

    ll ans = min(N, M / 2);
    N -= ans;
    M -= 2 * ans;

    ans += M / 4;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {


    int N;
    scanf("%d",&N);
    long long ans = 0;
    for(int i=1;i<N+1;i++) {
        long long lo = i;
        long long hi = (N / i) * i;
        long long cnt = hi / i - lo / i + 1;
        ans += (cnt * (lo + hi)) / 2;
    }
    printf("%lld",ans);

	return 0;
}

Measured memory_bytes: 1712
def main():
    MOD = 10 ** 9 + 7

    X, Y = map(int, input().split())

    if (X + Y) % 3:
        print(0)
        return

    a = (X * 2 - Y) // 3
    b = X - a * 2

    def choose(n, a, mod):
        x, y = 1, 1
        for i in range(a):
            x = x * (n - i) % mod
            y = y * (i + 1) % mod
        return x * pow(y, mod - 2, mod) % mod

    if a < 0 or b < 0:
        print(0)
        return

    ans = choose(a + b, min(a, b), mod=MOD)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int MOD = 2019;
int main(){
    int L, R;
    cin >> L >> R;
    int s = L / MOD;
    L %= MOD;
    R -= s*MOD;
    if(R >= MOD){
        cout << 0;
        return 0;
    }
    int min = MOD-1;
    for(int i = L; i < R; i++){
        for(int j = i+1; j <= R; j++){
            int t = (i*j) % MOD;
            if(t < min) min = t;
        }
    }
    cout << min;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])
ab.sort()
ab += [[n, n + 1]]
ans = 0
s = 0
f = n

for i in range(m + 1):
    if ab[i][0] >= f:
        ans += 1
        s = ab[i][0]
        f = ab[i][1]
    else:
        if ab[i][1] < f:
            f = ab[i][1]
print(ans)

Measured memory_bytes: 20068
// AOJ 2807 Fractal Tree
// 2018.3.21 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

double dbl()    // 実数の入力
{
	int minus = 0;
	double x, y;
	int n = 0, c = gc();
	if (c == '-') minus = 1, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');

	if (c == '.') {
		x = 0;
		y = 1, c = gc();
		do y *= 0.1, x += y * (c & 0xf), c = gc(); while (c >= '0');
		x += n;
	}
	else x = n;
	if (minus) x = -x;
	return x;
}


// 本問題関連
#define MAX 100005
typedef struct { int to, c; } T;
int hi[MAX]; T *t[100005]; int N;
int cost[MAX], depth[MAX], depth_max;
double p[MAX], P;

typedef struct { int n, d; } Q;
Q q[MAX]; int top;
char vis[MAX];

void dfs()
{
	int i, node, d, to;

	q[0].n = 1, q[0].d = 0, top = 1;
	while (top) {
		node = q[--top].n, d = q[top].d;

		if (vis[node]) continue;
		vis[node] = 1;

		depth[node] = d;
		if (d > depth_max) depth_max = d;
		for (i = 0; i < hi[node]; i++) {
			to = t[node][i].to;
			if (!vis[to]) {
				cost[to] = t[node][i].c;
				q[top].n = to, q[top++].d = d + 1;
			}
		}
	}
}

int main()
{
	int i, k, x, y, c;
	int *memo, sz;
	double a, b;

	// 入力受付
	P = dbl(), N = in();
	memo = malloc(sizeof(int) * 3 * N);
	sz = 0; for (i = 1; i < N; i++) {
		memo[sz++] = x = in(), memo[sz++] = y = in(), memo[sz++] = in();
		hi[x]++, hi[y]++;
	}
	for (i = 1; i <= N; i++) if (hi[i]) t[i] = malloc(sizeof(T)*hi[i]);
	memset(hi+1, 0, sizeof(int)*N);
	i = 0; while (i < sz) {
		x = memo[i++], y = memo[i++], c = memo[i++];
		k = hi[x]++, t[x][k].to = y, t[x][k].c = c;
		k = hi[y]++, t[y][k].to = x, t[y][k].c = c;
	}
//	free(memo);

	dfs();
	p[0] = 1; for (i = 1; i <= depth_max; i++) p[i] = p[i - 1] * P;
	a = 0, b = 1; for (i = 1; i <= N; i++)
		a += cost[i] * p[depth[i]], b += p[depth[i]];
	printf("%.10lf\n", a*b);
	return 0;
}



Measured memory_bytes: 8868
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;



int main(void){
    int n;
    cin >> n;
    vector<vector<int>> a(2);
    vector<vector<int>> dp(2);
    for(int i=0; i<2; i++) {
        a[i] = vector<int>(n);
        dp[i] = vector<int>(n);
        for(int j=0; j<n; j++) cin >> a[i][j];
    }
    
    dp[0][0] = a[0][0];
    //上段
    for(int i=1; i<n; i++) {
        dp[0][i] = dp[0][i-1] + a[0][i];
    }
    //下段
    dp[1][0] = dp[0][0]+a[1][0];
    for(int i=1; i<n; i++) {
        dp[1][i] = max(dp[1][i-1], dp[0][i])+a[1][i];
    }
    
    /*
    for(int i=0; i<2; i++) {
        for(int j=0; j<n; j++) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    
    cout << dp[1][n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

const ulli MOD = 1e+9 + 7;

ulli sum(const std::vector<slli> &v)
{
  long N = v.size();
  slli S = 0;
  
  for (long k = 0; k < N; ++k) {
    slli x = k * v[k] - (N - k - 1) * v[k];
    S += x;
  }
  
  return static_cast<ulli>(S) % MOD;
}

int main()
{
  unsigned N, M;
  std::cin >> N >> M;
  
  std::vector<slli> x(N), y(M);
  for (unsigned n = 0; n < N; ++n) std::cin >> x[n];
  for (unsigned m = 0; m < M; ++m) std::cin >> y[m];
  
  ulli X = sum(x) % MOD;
  ulli Y = sum(y) % MOD;
  
  std::cout << ((X * Y) % MOD) << std::endl;
  
  return 0;
}

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

int main() {
  string s;
  cin  >> s;
  vector<int> vec(26);
  rep(i,4){
    int x=s[i]-'A';
    vec[x]++;

  }
  rep(i,26){
    if(vec[i]!=2&&vec[i]!=0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int h,w,c;

bool used[10][10];

vvi coloring(int color,vvi v){
    int c=v[0][0];
    vector<vector<bool>> used(h,vector<bool>(w,true));
    queue<pii> que;
    que.push(make_pair(0,0));
    while(!que.empty()){
        auto q=que.front();
        que.pop();
        int x=q.first;
        int y=q.second;

        used[x][y]=false;
        v[x][y]=color;
        rep(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=0 and nx<h and ny>=0 and ny<w and v[nx][ny]==c and used[nx][ny]){
                que.push(make_pair(nx,ny));
            }
        }
    }
    return v;
}

int counter(vvi v,int val=0){
    int ret=0;
    vector<vector<bool>> used(h,vector<bool>(w,true));
    queue<pii> que;
    que.push(make_pair(0,0));
    used[0][0]=false;
    while(!que.empty()){
        auto q=que.front();
        que.pop();
        ret++;
        if(val==1) cerr << q << endl;
        int x=q.first,y=q.second;
        rep(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(0<=nx and nx<h and 0<=ny and ny<w and used[nx][ny] and v[nx][ny]==v[0][0]){
                used[nx][ny]=false;
                que.push(make_pair(nx,ny));
            }
        }
    }
    return ret;
}

void solve(){
    vvi p(h,vi(w));
    rep(i,h) rep(j,w) cin>>p[i][j];
    rep(i,h) rep(j,w) p[i][j]--;

    int ans=0;
    rep(i,6){
        if(i==p[0][0]) continue;
        rep(j,6) rep(k,6) rep(l,6){
            auto v = coloring(i,p);
            v = coloring(j,v);
            v = coloring(k,v);
            v = coloring(l,v);
            v = coloring(c,v);
            int tmp=counter(v);

            ans = max(ans,tmp);
        }
    }

    cout << ans << endl;
}

int main(){
    while(cin>>h>>w>>c){
        if(h==0 and w==0 and c==0) break;
        c--;
        solve();
    }
}

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

n = int(input())

def yakusuu(num):
    yakusuu_array = []
    for i in range(1,num):
        if num % i == 0:
            yakusuu_array.append(i)
    return(len(yakusuu_array)+1)

ans = 0

for i in range(1,n+1):
    if yakusuu(i) == 8 and i % 2 == 1:
        ans += 1
        
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>

#define N 5000

using namespace std;

void input();
void pro();

vector<int> vv;
queue<int> q;

bool ok = false;
char c[N][N];

int x[N];
int ans[N];
int n, m;
int v = 0;
int at = 0;
int a, b;
int i, j, l;

int main() {

	input();
	pro();

	for (i = 0; i < n; i++) cout << ans[i] + 1 << endl;

	if (ok == true)cout << "1" << endl;
	else cout << "0" << endl;

	//	cin >> n;

	return 0;

}

void input() {

	cin >> n >> m;
	for (i = 0; i < m; ++i) {

		cin >> a >> b;

		--a; --b;

		c[a][b] = 1;
		c[b][a] = 2;
		++x[b];

	}
}

void pro() {

	for (i = 0; i<n; ++i) {

		v = 0;

		for (j = 0; j<n; ++j) {

			if (x[j] == 0) {
				at = j;
				++v;

			}
		}

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

		if (v >= 2)ok = true;
		x[at] = 5000;
		ans[i] = at;
		for (j = 0; j<n; ++j)if (c[j][at] == 2) --x[j];

	}
}




Measured memory_bytes: 27596
A,B,N = map(int,input().split())


#ｘがB-1の時の値を求めればよい。
#ただし、NがB-1より小さいときはXがNの時を算出する。

if N < B:
    x = N
else:
    x = B-1

ans1 = (A*x) // B    
ans2 = A*((x) // B)

ans = ans1 - ans2    



print(ans)



Measured memory_bytes: 9100
W,H,x,y,r=(int(x) for x in input().split())

if -100<=x<=100 and -100<=y<=100 and 0<W<=100 and 0<H<=100 and 0<r<=100:
    if x-r<0 or x+r>W or y-r<0 or y+r>H:
        print("No")
    
    elif x-r>=0 or x+r<=W or y-r>=0 or y+r<=H:
        print("Yes") 


Measured memory_bytes: 5604
#include<stdio.h>

int main(void){  

int W,H,x,y,r;  

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);  

if(H>=y+r&&W>=x+r&&x-r>=0&&y-r>=0){   

printf("Yes\n");  

}  

else{   

printf("No\n");  

}  

return 0;

}

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

long dp[100001], a[100001], n;

long magic(int i){
	if(i == n)
		return 0;
	if(i > n)
		return 1e9 + 7;
	long &ret = dp[i];
	if(~ret)
		return ret;
	long p1, p2;
	p1 = abs(a[i] - a[i + 1]) + magic(i + 1);
	p2 = abs(a[i] - a[i + 2]) + magic(i + 2);
	return ret = min(p1, p2);
}

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

	memset(dp, -1, sizeof dp);
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	cout << magic(1);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int zz[121][121]={0};
	int t,n;
	while(cin>>t>>n){
		int z[121][121],ka[121][121];
		for(int x=0;x<=120;x++){
			for(int y=0;y<=120;y++){
				z[x][y]=zz[x][y];
				ka[x][y]=zz[x][y];
			}
		}
		if(t==0&&n==0) break;
		int x,y,ct=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			z[x+60][y+60]=2;
			ka[x+60][y+60]=2;
		}
		cin>>x>>y;
		z[x+60][y+60]=1;
		ka[x+60][y+60]=1;
		for(int i=0;i<t;i++){
			for(int j=0;j<=120;j++){
				for(int k=0;k<=120;k++){
					if(z[j][k]==1){
						if(z[j-1][k]==0){
							ka[j-1][k]=1;
						}
						if(z[j+1][k]==0){
							ka[j+1][k]=1;
						}
						if(z[j][k-1]==0){
							ka[j][k-1]=1;
						}
						if(z[j][k+1]==0){
							ka[j][k+1]=1;
						}
						if(z[j+1][k+1]==0){
							ka[j+1][k+1]=1;
						}
						if(z[j-1][k-1]==0){
							ka[j-1][k-1]=1;
						}
					}
				}
			}
			for(int j=0;j<=120;j++){
				for(int k=0;k<=120;k++){
					z[j][k]=ka[j][k];
				}
			}
		}
		for(int j=0;j<=120;j++){
			for(int k=0;k<=120;k++){
				if(z[j][k]==1) ct++;
			}
		}
		cout<<ct<<endl;
	}
    return 0;
}

Measured memory_bytes: 1336
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, x, m[1001];

	cin >> n;
	cin >> x;

	for (i = 0; i < n; i++) {
		cin >> m[i];
	}

	int cnt = 0;
	for (i = 0; i < n; i++) {
		x = x - m[i];
		cnt++;
	}

	int min = 9000000;
	int mini;
	for (i = 0; i < n; i++) {
		if (min > m[i]) {
			min = m[i];
			mini = i;
		}
	}


	for (; ;) {
		if (x - m[mini] >= 0) {
			x = x - m[mini];
			cnt++;
		}
		else {
			break;
		}
	}

	cout << cnt << endl;

	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    int N = ni();
    int L = ni();
    ArrayList<String> list = new ArrayList<>();
    for (int i = 0; i < N; ++i) {
      list.add(sc.next());
    }
    Collections.sort(list);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; ++i) {
      debug(list.get(i));
      sb.append(list.get(i));
    }
    System.out.println(sb.toString());
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 10452
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    int K,N; cin >> K >> N;
    vector<int> A(N);
    for(int i = 0;i < N;++i){
        cin >> A[i];
    }
    int d = 0;
    for(int i = 0;i < N-1;++i){
        d = max(d,A[i+1]-A[i]);
    }
    d = max(d,K+A[0]-A[N-1]);
    cout << K-d << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ra[100000],fa[100000],a[100000],b[100000];
vector<ll>v;
ll find(ll x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y]){swap(x,y);}
    fa[y]=x;
    //ra[x]++;
    ra[x]+=ra[y];
    //if(ra[x]==ra[y])ra[x]++;
}
int main(void){
    ll n,m,c,d;
    cin>>n>>m;
    for(ll i=0LL;i<100000;i++){
        fa[i]=i;
        ra[i]=1LL;
    }
    for(ll i=0;i<m;i++){
        cin>>c>>d;
        c--,d--;
        a[i]=c,b[i]=d;
    }
    reverse(a,a+m);
    reverse(b,b+m);
    for(ll i=0;i<m;i++){
        if(find(a[i])==find(b[i])){
            v.push_back(0LL);
        }
        else{
            v.push_back(ra[find(a[i])]*ra[find(b[i])]);
            uni(a[i],b[i]);
        }
    }
    reverse(v.begin(),v.end());
    ll ans=0LL;
    for(ll i=0LL;i<m;i++){
        ans+=v[i];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 5364
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int xor = 0;
        boolean[] x = new boolean[32];
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            x[Integer.toBinaryString((a - 1) ^ a).length() - 1] = true;
            xor ^= a;
        }
        long ans = 0;
        for (int i = Integer.toBinaryString(Integer.highestOneBit(xor) - 1).length(); i >= 0; i--) {
            int j = 1 << i;
            if ((xor & j) != 0) {
                if (x[i]) {
                    ans++;
                    xor ^= j * 2 - 1;
                } else {
                    System.out.println(-1);
                    return;
                }
            }
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef struct {
    int a, b, c;
}re;
int n, m;
re t[N];
int f[N];
int cmp(re x, re y){
    return x.c < y.c;
}
int findf(int x){
    return x == f[x] ? x : findf(f[x]);
}
int main(){
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++){
        scanf("%d %d %d", &t[i].a, &t[i].b, &t[i].c);
    }
    for(int i = 0; i < n; i++) f[i] = i;
    sort(t, t+m, cmp);

    int sum = 0;
    for(int i = 0; i < m; i++){
        if(findf(t[i].a) != findf(t[i].b)){
            sum += t[i].c;
            f[findf(t[i].a)] = findf(t[i].b);
        }
    }
    printf("%d\n", sum);
    return 0;
}


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

int main(){
    char token[100]={};
    while(fgets(token, sizeof(token), stdin)!=NULL){
        if (token[0]==token[1]&&token[0]==token[2]) printf("No");
        else printf("Yes");
    }
    return 0;
}



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

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

	int p[1010];
	for (int i = 0; i < N; i++)
	{
		cin >> p[i];
	}

	sort(p, p + N);

	int price = 0;
	for (int i = 0; i < K; i++)
	{
		price += p[i];
	}

	cout << price << endl;

	return 0;
}

Measured memory_bytes: 3644
n, k = map(int, input().split())
s = input()
l = []
c = 1
for i in range(n - 1):
    if s[i] != s[i + 1]:
        l.append(c)
        c = 0
    c += 1
l.append(c)
l += [0]
if s[0] == '0':
    l = [0] + l
tmp = sum(l[:2 * k + 1])
rslt = tmp
for i in range(0, len(l) - 2*k-2, 2):
    tmp = tmp - l[i] - l[i + 1] + l[i + 2 * k + 1] + l[i + 2 * k + 2]
    rslt = max(tmp, rslt)
print(rslt)
    

Measured memory_bytes: 4980
#include<stdio.h>
int main(void)
{
	int n,x,y,b,p,i,j,a[365];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		if(b>=5&&p<=2){
			if(x*b+y*p>(x*b+y*2)*0.8){
				a[i]=(x*b+y*2)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b<=5&&p>=2){
			if(x*b+y*p>(x*5+y*p)*0.8){
				a[i]=(x*5+y*p)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b<=5&&p<=2){
			if(x*b+y*p>(x*5+y*2)*0.8){
				a[i]=(x*5+y*2)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b>=5&&p>=2){
			a[i]=(x*b+y*p)*0.8;	
		}
	}
	for(j=0;j<n;j++){
		printf("%d\n",a[j]);
	}
	return 0;
}

Measured memory_bytes: 1028
k = int(input())
x = input()
a = int(x.split()[0])
b = int(x.split()[1])
count = 0

for i in range(a, b + 1):
  if i % k == 0:
    count = 1
  
if count == 1:
  print('OK')
else:
  print('NG')

Measured memory_bytes: 9180
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

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

	vector<int> A(n, 0);

	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;

		for (int j = 0; j < d; j++) {
			int have;
			cin >> have;
			A[have - 1] = 1;
		}

	}

	int count = 0;
	for (int i = 0; i < n; i++) {
		if (A[i] == 0) {
			count++;
		}
	}

	cout << count;

	return 0;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std ;
int abst(int a)
{
    if(a>=0) return a;
    return -a;
}
int n,k,A[100000+5],dp[100000+5] ;
int f(int i)
{
    if(i==0) return 0 ;
    if( dp[i] != -1  ) return dp[i] ;
    int ans = 1000000000 ;
    for( int j=1;j<=k ;j++)
    {
        if( i-j >= 0 )
        ans = min( ans , abst( A[i]-A[i-j] ) + f( i-j ) ) ;
    }
    return  dp[i] = ans ;


}

int main()
{
    cin >> n >> k ;
    for( int i=0;i<n;i++ ) {cin >> A[i] ;
     dp[i] = -1;
    }
    cout << f(n-1) ;




    return 0 ;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF 1000000001
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(rng(a));
  int ans=0;
  int d=INF;
  if(a[n-1]%2){
    for(int i=0;i<n-1;i++){
      int dd1=abs(a[n-1]/2-a[i]);
      int dd2=abs(a[n-1]/2+1-a[i]);
      if(dd1<=d&&dd1<=dd2)d=dd1,ans=i;
      if(dd2<=d&&dd2<=dd1)d=dd2,ans=i;
    }
  }
  else{
    for(int i=0;i<n-1;i++){
      int dd=abs(a[n-1]/2-a[i]);
      if(dd<=d)d=dd,ans=i;
    }
  }
  cout<<a[n-1]<<" "<<a[ans]<<endl;
  return 0;
}



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

using namespace std;

long long n,m,k,l,i,j,a,b,c,d[200005],dp[200005],mx=1000001;

struct LCtree{
    long long k,b;
    LCtree *L,*R;
    LCtree(){
        k=b=1000000000000000000;
        L=R=NULL;
    }
};

long long val(LCtree *&nw,long long x){
    return nw->k*x+nw->b;
}

void upd(LCtree *&it,long long l,long long r,LCtree *&nw){
    if(it==NULL) { it=new LCtree();it->k=nw->k;it->b=nw->b;return;}
    long long mid1=(val(it,(l+r)/2) > val(nw,(l+r)/2));
    long long l1=(val(it,l) > val(nw,l));
    if(mid1) {swap(it->k,nw->k);swap(it->b,nw->b);}
    if(r-l==1)
        return;
    if(l1!=mid1)
        upd(it->L,l,(l+r)/2,nw);
    else
        upd(it->R,(l+r)/2,r,nw);
}

long long fnd(LCtree *&it,long long l,long long r,long long x){
    if(it==NULL) return 1000000000000000000;
    if(r-l==1) return val(it,x);
    if(x<(l+r)/2) return min(val(it,x),fnd(it->L,l,(l+r)/2,x));
    else return min(val(it,x),fnd(it->R,(l+r)/2,r,x));
}

main(){

cin>>n>>c;cin>>d[1];

LCtree *root=new LCtree();
LCtree *nw=new LCtree();
root->k=-2*d[1];
root->b=d[1]*d[1]+c;
for(i=2;i<=n;i++){
    cin>>d[i];
    dp[i]=fnd(root,1,mx+1,d[i])+d[i]*d[i];
    nw->k=-2*d[i];
    nw->b=d[i]*d[i]+c+dp[i];
    upd(root,1,mx+1,nw);
}

cout<<dp[n];

}



Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::setprecision(15);}}fIO;
template<typename T> using V = std::vector<T>;
template<typename T> void fill(V<T>&v) { for(T&e:v) std::cin >> e; }
/*-*/

int main() {
	constexpr int N=1e6+1;
	V<int> factor(N,0);
	for(int i=2;i<N;i++) {
		if(factor[i]) continue;
		for(int j=i;j<N;j+=i) {
			factor[j]=i;
		}
	}

	int n;
	std::cin >> n;
	V<int> a(n);
	fill(a);
	if([&]()->int{
		V<int> pr(N,0);
		for(int e:a) {
			while(e>1) {
				int x=factor[e];
				if(pr[x]) {
					return 0;
				}
				pr[x]++;
				while(e%x==0) e/=x;
			}
		}
		return 1;
	}()) {
		print("pairwise coprime");
		return 0;
	}
	int g=0;
	for(int e:a) g=std::gcd(g,e);
	if(g==1) print("setwise coprime");
	else print("not coprime");
}


Measured memory_bytes: 15052
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();

        long a = n - 2;
        if (a < 0) {
            a = 1;
        }
        long b = m - 2;
        if (b < 0) {
            b = 1;
        }

        System.out.print(a * b);
    }
}

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

int main(){

  string s,t;
  // char b;
  int n,an=0;
  cin >> s>>t;
  n=s.length();
  for(int i=0;i<n;i++){
    // a=t.substr(0,n-1);
    // b=t[n-1];
    // t[0]=b;
    t = t[n-1] + t.substr(0, n-1);
    // for(int i=1;i<n;i++){
    //   t[i]=a[i-1];
    // }
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }

  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse", "sse2", "avx", "avx2")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int mod = 1e9 + 7;
const int K = 120;



signed main() {
    accell();
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

bool comp(pair<pair<string,li>,li> a,pair<pair<string,li>,li> b)
{
    if(a.F.F==b.F.F)
    {
        return b.F.S<a.F.S;
    }

    return a.F.F < b.F.F;
}

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

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

    li n;

    cin>>n;

    vector<pair<pair<string,li>,li>> v(n);

    f(i,0,n-1)
    {
        cin>>v[i].F.F;
        cin>>v[i].F.S;

        v[i].S=i+1;
    }

    sort(v.B,v.E,comp);

    f(i,0,n-1)
    {
        cout<<v[i].S<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect, bisect_left
from functools import reduce
from itertools import accumulate, product
from operator import itemgetter, xor
from math import sqrt
from random import randint, random
from heapq import heappop, heappush

from fractions import gcd
from collections import Counter, deque, defaultdict

import sys
#input = sys.stdin.readline
from sys import setrecursionlimit
setrecursionlimit(10**9)

def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
A = inpl()
C = Counter(A)
OK = True

if (N%2) and (C[0] != 1):
    OK = False
for i in range(N//2):
    if C[2*(i+1) -1 + N%2] != 2:
        OK = False

print(pow(2, N//2, MOD)*OK)

Measured memory_bytes: 16308
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;

#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
const ll N=1e5+5,inf=1e18;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin >> s;
	ll f=0;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}	    
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

#define ll long long int
#define ff(i,a,b) for(ll i = a; i < b; i++)
#define bf(i,b,a) for(ll i = b-1; i >= a; i--)
#define itf(i,a) for(auto i = a.begin(); i != a.end(); i++)
#define itfr(i,a) for(auto i = a.rbegin(); i != a.rend(); i++)
#define MII map<ll,ll> 
#define MCI map<char,ll>
#define MSI map<string,ll>
#define VI vector<ll> 
#define VC vector<char> 
#define VS vector<string> 
#define MP make_pair
#define tc ll t; cin>>t; while(t--)
#define DISPV(v) itf(i,v) cout << *i << ' ';
#define DISPM(m) itf(i,m) cout << i->first << ' ' << i->second << endl;

const int MOD = int(1e9) + 7;

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    VI v;
    ff(i,0,n){
        ll a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    ll sum = 0;
    ff(i,0,k){
        sum += v[i];
    }
    cout << sum << '\n';
}

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n;
map<int,int> m;

void nhap()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        m[x]++;
        if (m[x]>1)
        {
            cout<<"NO";
            return;
        }
    }
    cout<<"YES";
}

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


Measured memory_bytes: 9600