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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    vector<int> v(n);
    cin >> n;
    rep(i, n)
    {
        cin >> v[i];
    }
    int sum1, sum2;
    int ans = inf;
#pragma omp parallel for
    for (int i = 1; i <= n - 1; i++)
    {
        sum1 = 0;
        sum2 = 0;
#pragma omp parallel for
        for (int j = 0; j < i; j++)
        {
            sum1 += v[j];
        }
#pragma omp parallel for
        for (int k = n - 1; k >= i; k--)
        {
            sum2 += v[k];
        }
        if (ans > max(sum1, sum2) - min(sum1, sum2))
        {
            ans = max(sum1, sum2) - min(sum1, sum2);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
   int h, w;
   int c[10][10];
   cin >> h >> w;
   for (int i = 0; i < 10; i++) 
      for (int j = 0; j < 10; j++) 
         cin >> c[i][j];

   for (int k = 0; k < 10; k++) {
      for (int i = 0; i < 10; i++) {
         for (int j = 0; j < 10; j++) {
            c[i][j] = 
               min(c[i][j], c[i][k] + c[k][j]);
         }
      }
   }

   int ans = 0;
   for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
         int x;
         cin >> x;
         if (x == -1) continue;
         ans += c[x][1];
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n=0):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0: return x
        self.d[x] = self.find(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x,y=self.find(x),self.find(y)
        if x==y:return False
        if self.d[x] > self.d[y]: x,y=y,x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x,y): return self.find(x)==self.find(y)
    def size(self,x): return -self.d[self.find(x)]

H,W=map(int,input().split())
S=[input() for _ in range(H)]

def index(i,j):
  return i*W+j

dx,dy = (1,-1,0,0),(0,0,1,-1)
uf = UnionFind(H*W)
for i in range(H):
  for j in range(W):
    x1,y1 = i,j
    for k in range(4):
      x2,y2 = i+dx[k],j+dy[k]
      if 0<=x2<H and 0<=y2<W:
        if S[x1][y1] != S[x2][y2]:
          uf.unite(index(x1,y1),index(x2,y2))
  
data = {}
for k in range(H*W):
  if uf.d[k]==-1:continue
  g = uf.find(k)
  if not data.get(g):
    data[g] = [0,0]
  i,j = divmod(k,W)
  if S[i][j] == '#':
    data[g][0] += 1
  else:
    data[g][1] += 1
    
ans = 0
for k in data.keys():
  ans += data[k][0]*data[k][1]

print(ans)

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

int main(){
    int a,b;
    cin>>a>>b;
    if ((a==1 && b==2) || (a==2 && b==1)) cout<<'3';
    if ((a==2 && b==3) || (a==3 && b==2)) cout<<'1';
    if ((a==1 && b==3) || (a==3 && b==1)) cout<<'2';
}

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

struct Sieve {
  vector<int> f, primes; // primesは素数集合，fは合成数に素因数を一つ示したもの
  Sieve(int N):f(N+1,0) {
    f[0] = f[1] = -1;
    for (int i = 2; i <= N; ++i) {
      if (!f[i]==0){
        continue;
      }
      primes.push_back(i);
      f[i] = i;
      if(i>sqrt(N)){
        continue;
      }
      for (int j = i*i; j <= N; j += i) {
        if (f[j]==0){
          f[j] = i;
        }
      }
    }
  }

  bool isPrime(int x) { //xが素数かどうかを判断するメンバ関数
    return f[x] == x;
  }

  vector<int> factorList(int x) { //xの素因数を小さい順ソートされた配列
    vector<int> res;
    if(x==0 || x==1){
      return { };
    }
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<pair<int,int>> factor(int x) { //xのfactorListをランレングス圧縮したもの
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<pair<int,int>> res(1, make_pair(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      }
      else {
        res.push_back(make_pair(p, 1));
      }
    }
    return res;
  }

  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0){
        x /= p, ++y;
      }
      if (y != 0){
        res.push_back(make_pair(p,y));
      }
    }
    if (x != 1){
      res.push_back(make_pair(x,1));
    }
    return res;
  }
};

int main(){
  Sieve S(1e5+5);
  vector<int> num(1e5+5);
  num[1]=0;
  for(int i=3;i<=1e5+5;i+=2){
    num[i]=num[i-2];
    if(S.isPrime(i) && S.isPrime((i+1)/2)){
      num[i]++;
    }
  }
  int Q;
  cin >> Q;
  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >> r;
    if(l!=1){
      cout << num[r]-num[l-2] << endl;
    }
    else{
      cout << num[r] << endl;
    }
  }
}

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

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

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

int main() {
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}

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

using namespace std;

typedef long long ll;


int main(){
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<m;k++){
				cout<<a[i][k];
			}
			cout<<endl;
		}
	}
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - RGB Boxes
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int r, g, b, n;
  scanf("%d%d%d%d", &r, &g, &b, &n);

  int cnt = 0;
  for (int i = 0; r * i <= n; i++) {
    int m = n - r * i;
    for (int j = 0; g * j <= m; j++) {
      int l = m - g * j;
      if (l % b == 0) cnt++;
    }
  }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    System.out.println(a-(b*2)>0?a-(b*2):0);
  }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define rep(i,x) for(int i=0;i<x;i++)
int n,m;
ll dp[8005][205];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[16005],R[16005];
void make(){
	F[0] = 1;
	rep(i,16004) F[i+1] = F[i]*(i+1)%mod;
	rep(i,16005) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
    return F[a]*R[b]%mod*R[a-b]%mod;
}
ll g[16];
int a[(1<<14)],b[(1<<14)],c[(1<<14)];
void mul(int *a,int *b,int *c,int n){
	if (n<=8){
		memset(g,0,sizeof(g));
		rep(i,n)rep(j,n) g[i+j]+=(ll)a[i]*b[j]%mod;
		rep(i,2*n) c[i]=g[i]%mod;
		return;
	}
	int mid = n/2;
	mul(a,b,c,mid); mul(a+mid,b+mid,c+n,mid);
	int x[mid],y[mid],z[n];
	rep(i,mid){
		x[i]=(a[i]+a[i+mid])%mod; y[i]=(b[i]+b[i+mid])%mod;
	}
	mul(x,y,z,mid);
	rep(i,n) z[i]-=c[i]+c[i+n];
	rep(i,n) c[i+mid]=((c[i+mid]+z[i])%mod+mod)%mod;
}
int main(){
	cin>>n>>m; make();
	dp[0][0] = 1;
	rep(j,m){
		rep(q,(1<<14)) a[q]=b[q]=c[q]=0;
		rep(i,n+1){
			ll x = dp[i][j] * R[i] % mod;
			a[i] = x;
			if(i != 0){
				b[i] = R[i+2];
			}
		}
		mul(a,b,c,(1<<13));
		rep(i,n+1){
			dp[i][j+1] = 1LL*c[i]%mod*F[i+2]%mod;
			dp[i][j+1] += dp[i][j]*(C(i+1,2)+1)%mod;
			dp[i][j+1] %= mod;
		}
	}
	ll ans = 0;
	rep(i,n+1){
		ans += dp[i][m] * C(n,i) % mod;
	}
	cout << ans%mod << endl;
}


Measured memory_bytes: 13696
def solve():
  while True:
    m, n  = int(input()), int(input())
    if not m:
      break
    ices = [[0] + list(map(int,input().split())) + [0] for _ in range(n)]
    ices.insert(0, [0] * (m + 2),)
    ices.append([0] * (m + 2))
    score = [[0] * (m + 2) for _ in range(n + 2)]
    
    for x in range(1, n + 1):
      for y in range(1, m + 1):
        if ices[x][y]:
          score[x][y] += (ices[x - 1][y] + ices[x + 1][y] + ices[x][y - 1] + ices[x][y + 1])
    
    def bfs(x, y, imap, acc):
      imap[x][y] = 0
      acc += 1
      a = b = c = d = 0
      if imap[x - 1][y]:
        a = bfs(x - 1, y, imap, acc)
      if imap[x + 1][y]:
        b = bfs(x + 1, y, imap, acc)
      if imap[x][y - 1]:
        c = bfs(x, y - 1, imap, acc)
      if imap[x][y + 1]:
        d = bfs(x, y + 1, imap, acc)
      imap[x][y] = 1
      return max(acc, a, b, c, d)
    
    ans = 0
    for x in range(1, n + 1):
      for y in range(1, m + 1):
        if score[x][y] in [1, 2]:
          a = bfs(x, y, ices, 0)
          if ans < a:
            ans = a
    
    print(ans)

solve()


Measured memory_bytes: 5812
# ABC086-C

declare -r PREPROCESS='
BEGIN {
    t = 0; x = 0; y = 0;
}
{
    dx = ($2 > x) ? ($2 - x) : (x - $2)
    dy = ($3 > y) ? ($3 - y) : (y - $3)
    print ($1 - t) " " dx " " dy
    t = $1; x = $2; y = $3;
}'

read # N
while read dt dx dy; do
    if (( dx + dy > dt || (dx + dy) % 2 != dt % 2 )); then
        echo No
        exit
    fi
done < <(awk "${PREPROCESS}")

echo Yes    


Measured memory_bytes: 688
fun main(args: Array<String>) {
    val (a, b, k) = readLine()?.split(" ")?.map(String::toLong) ?: return
    val aRemain = if (a <= k) {
        0
    } else {
        a - k
    }
    val remain = k - a
    val bRemain = when {
        b <= remain -> {
            0
        }
        remain <= 0 -> {
            b
        }
        else -> {
            b - remain
        }
    }
    println("$aRemain $bRemain")
}


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


int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<vector<int> > X(m);
  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    X[x%m].push_back(x);
  }
  vector<int> K(m);
  for(int i=0;i<m;i++){
    sort(X[i].begin(),X[i].end());
    K[i]=0;
    for(int j=0;j<X[i].size();j++){
      if(j+1<X[i].size()&&X[i][j]==X[i][j+1]){
	K[i]++;
	j++;
      }
    }
  }
  int C=0;
  for(int i=0;2*i<=m;i++){
    if(i==0||2*i==m){
      C+=X[i].size()/2;
    }
    else{
      if(X[i].size()>=X[m-i].size()){
	C+=X[m-i].size();
	C+=min((int)(X[i].size()-X[m-i].size())/2,K[i]);
      }
      else{
	C+=X[i].size();
	C+=min((int)(X[m-i].size()-X[i].size())/2,K[m-i]);
      }
    }
  }
  printf("%d\n",C);
  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a, b;
vector<vector<ll>> g;
bool use[100008], even[100008][2];

void dfs(ll at, ll mod){
	use[at] = true;
	
	zep(i, 0, g[at].size()){
		ll nx = g[at][i];
		even[nx][1-mod] = true;
		
		if(!use[nx]){
			dfs(nx, 1-mod);		
		}
	}
	return;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	g.resize(n);
	zep(i, 0, m){
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	memset(use, 0, sizeof(use));
	memset(even, 0, sizeof(even));
	dfs(0, 0);
	
	ll e = 0;
	ll o = 0;
	zep(i, 0, n){
		if(even[i][0]){e++;}
		if(even[i][1]){o++;}
	}
	if(e+o == n){
		print(e*o-m)
	}
	else{
		print(n*(n-1)/2-m)
	}
	return 0;
}

Measured memory_bytes: 6912
#include"bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define RREP(i, n) RFOR(i, 0, n)
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define rrep(i, a, b) for (auto i = a; i > b; i--)
#define fs first
#define sc second
#define ll long long
string s;

ll dfs(int start, int end) {
	stack<int> st;
	priority_queue<ll> q;
	bool flag = true;
	rep(i, start + 1, end) {
		if (s[i] == '[') {
			flag = false;
			st.push(i);
		} else if (s[i] == ']') {
			if (st.size() == 1) {
				q.push(-dfs(st.top(), i));
				st.pop();
			}
			else {
				st.pop();
			}
		}
	}
	if (flag) {
		int tmp = 0;
		rep(i, start + 1, end) {
			tmp *= 10;
			tmp += (int)(s[i] - '0');
		}
		//cout << tmp << endl;
		return (tmp + 1) / 2;
	}
	else {
		ll tmp = 0;
		int k = (q.size() + 1) / 2;
		rep(i, 0, k) {
			tmp += -q.top();
			q.pop();
		}
		//cout << tmp << endl;
		return tmp;
	}
}


int main() {
	int n; cin >> n;
	rep(i, 0, n) {
		cin >> s;
		//dfs(0, s.size() - 1);
		cout << dfs(0, s.size() - 1) << endl;
	}
}


Measured memory_bytes: 3276
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int park_time;
    int pay_per_use;
    int fix_price;
    int min_price;


    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      park_time   = Integer.parseInt(in_str_split[0]);
      pay_per_use = Integer.parseInt(in_str_split[1]);
      fix_price   = Integer.parseInt(in_str_split[2]);

      min_price = pay_per_use * park_time;

      if(fix_price < min_price)
      {
        min_price = fix_price;
      }

      UtilLog.ans_ln("" + min_price);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


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

int main(){
  int n,q,ans,cnt=0;cin>>n>>q;string s;cin>>s;
  vector<int> l(q,0),r(q,0),ac(1,0);
  REP(i,q) cin>>l.at(i)>>r.at(i);
  for(int i=1;i<s.size();i++){
    if(s.at(i-1)=='A'&&s.at(i)=='C') cnt++;
    ac.push_back(cnt);
  }
  REP(i,q) cout<<(ac.at(r.at(i)-1)-ac.at(l.at(i)-1))<<endl;
}

Measured memory_bytes: 2296
fun ans (a: List<String>): Int {
    var sum = 0
    for (i in 0..a.lastIndex-1) {
      sum = sum + (a[i+1].toInt() - a[i].toInt())
    }
    return sum
}

fun main (args: Array<String>) {
  val N = readLine()!!.toInt()
  var a = readLine()!!.split(" ")
  println(ans(a.sorted()))
}


Measured memory_bytes: 37876
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>

using namespace std;
typedef long long int ll;

vector<vector<bool>> s;
vector<ll> p(11);
ll N, m;

ll solve(ll n, vector<bool> q) // 1 <= n <= N + 1
{
	if (n == N + 1)
	{
		for (ll i = 0; i < m; i++)
		{
			ll sum = 0;
			for (ll t = 1; t <= N; t++)
			{
				if(s[i][t] && q[t]) 
					sum++;
			}

			if (sum % 2 != p[i])
			{
				return 0;
			}
		}

		return 1;
	}

	q[n] = true; // s[n]がオン
	ll a1 = solve(n + 1, q);
	q[n] = false; // s[n]がオフ
	ll a2 = solve(n + 1, q);

	return a1 + a2;
}

int main(int argc, char const *argv[])
{
	cin >> N >> m;

	for (ll i = 0; i < m; i++)
	{
		ll k;
		cin >> k;
		vector<bool> a(11, false);
		for (ll t = 0; t < k; t++)
		{
			ll temp;
			cin >> temp;
			a[temp] = true;
		}
		s.push_back(a);
	}

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

	vector<bool> q(11, 0);
	cout << solve(1, q) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int k;
    cin>>k;
    int z=0;
    if(k%7==0)
    {
        k/=7;
    }
    bool l=1;
    bool w[1000001]= {0};
    for(int i=1;; i=i*10+1)
    {
        z++;
        if(i%k==0)
        {
            break;
        }
        else
        {
            i=i%k;
            if(w[i])
            {
                l=0;
                break;
            }
            else
            {
                w[i]=1;
            }
        }
    }
    if(l)
        cout<<z<<endl;
    else
        cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 4616
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
int main(){
    string s;
    ll k;
    cin>>s>>k;
    if(k<=s.size()){
        for(ll i=0;i<k;i++){
            if(s.at(i)!='1'){
                cout<<s.at(i)<<endl;
                return 0;
            }
        }
        cout<<'1'<<endl;
    }
    else {
        ll x=0;
        while(x<s.size()&&s.at(x)=='1'){
            x++;
        }
        cout<<s.at(x)<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s, w;
    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe") << '\n';
    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;
    double m;
    cin >> n>> m;
    priority_queue <int> data;
    double sum=0;
    rep(i,0,n){
        int a;
        cin >> a;
        data.push(a);
        sum += a;
    }
    double kiju;
    int check = 0;
    kiju = sum/(4*m);
    //cout << kiju << endl;
    rep(i,0,m){
        int a = data.top();
        if(a<kiju){
            check = 1;
        }
        data.pop();
    }
    if(check==1){
        cout<< "No" << endl;
    }else{
        cout <<"Yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
ans = []
for i in range(l,min(r+1,l+2019)):
    for j in range(i+1,min(r+1,i+1+2019)):
        if i*j%2019 not in ans:
            ans.append(i*j%2019)
        else:
            break
print(min(ans))

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<stdlib.h>
#include<cstring>
#include<string.h>
using namespace std;
struct ma
{
	int x;
	int y;
};
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
char m[1200][1200];
int map[1200][1200];
int main()
{
	int ans = 0;
	int tate, yoko;
	int n;
	cin >> tate >> yoko >> n;
	
	ma sta;
	for (int i = 0; i < tate; i++)
	{
		for (int k = 0; k < yoko; k++)
		{
			cin >> m[i][k];
			if (m[i][k] == 'S')
			{
				sta.x = k;
				sta.y = i;
			}
		}
	}
	int HP = 1;
	queue<ma> hoge;
	for (int i = 0; i < n; i++)
	{
		hoge.push(sta);
		
		memset(map, -1, sizeof(map));
		map[sta.y][sta.x] = 0;
		while (!hoge.empty())
		{
			ma now;
			now = hoge.front();
			hoge.pop();
			for (int k = 0; k < 4; k++)
			{
				if (now.y + dy[k] >= tate || now.x + dx[k] >= yoko)continue;
				if (now.y + dy[k] < 0 || now.x + dx[k] < 0)continue;
				if (m[now.y + dy[k]][now.x + dx[k]] != 'X')
				{
					if (map[now.y + dy[k]][now.x + dx[k]] != -1)
					{
						continue;
					}
					map[now.y + dy[k]][now.x + dx[k]] = map[now.y][now.x] + 1;
					if (m[now.y + dy[k]][now.x + dx[k]] - '0' == HP)
					{
						m[now.y + dy[k]][now.x + dx[k]] = '.';
						ans += map[now.y + dy[k]][now.x + dx[k]];
						while (!hoge.empty())hoge.pop();
						HP++;
						sta.x = now.x + dx[k];
						sta.y = now.y + dy[k];
						break;
					}
					else
					{
						ma hage;
						hage.x = now.x + dx[k];
						hage.y = now.y + dy[k];
						hoge.push(hage);
					}
				}
			}

		/*	for (int i = 0; i < tate; i++)
			{
				for (int k = 0; k < yoko; k++)
				{
					cout << map[i][k] << " ";
				}
				cout << endl;
			}
			cout << endl;*/
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 8020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
    }
    else
    {
        cout<<((n/x)+1)*t;
    }
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

string col = "RGB";
int w, h;
char v[11][11];

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

int best;

int fill(char col){
	queue<P> q;
	q.push(MP(0, 0));
	char c = v[0][0];
	int cnt = 0;
	while(!q.empty()){
		P p = q.front();
		q.pop();
		if(v[p.Y][p.X] != c) continue;
		v[p.Y][p.X] = col;
		cnt++;

		rep(d, 4){
			int nx = p.X + dx[d], ny = p.Y + dy[d];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			q.push(MP(nx, ny));
		}
	}
	return cnt;
}

int visit[11][11];
int count(){
	memset(visit, 0, sizeof(visit));
	queue<P> q;
	q.push(MP(0, 0));
	char c = v[0][0];
	int cnt = 0;
	while(!q.empty()){
		P p = q.front();
		q.pop();
		if(visit[p.Y][p.X]) continue;
		visit[p.Y][p.X] = 1;
		cnt++;

		rep(d, 4){
			int nx = p.X + dx[d], ny = p.Y + dy[d];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			if(v[ny][nx] == c) q.push(MP(nx, ny));
		}
	}
	return cnt;
}

int dfs(int cnt, int depth){
	if(best <= depth) return INF;
	if(cnt == w*h) return best = depth;

	int res = INF;
	char c = v[0][0];
	char tmp[11][11];
	memcpy(tmp, v, sizeof(v));
	rep(i, 3){
		char next = col[(i+depth)%3];
		if(c == next) continue;
		fill(next);
		int ncnt = count();
		if(cnt != ncnt) res = min(res, dfs(ncnt, depth+1));
		memcpy(v, tmp, sizeof(v));
	}
	return res;
}

int main(void){
	while(cin >> w >> h, w|h){
		best = w+h;
		rep(i, h) rep(j, w) cin >> v[i][j];
		cout << dfs(count(), 0) << endl;
	}


    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"

#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}

#define SHOW(x) std::cout << #x << " = " << x << std::endl;

inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for(int& x : a)
        cin >> x;
    cout << *max_element(begin(a), end(a)) - *min_element(begin(a), end(a)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>  
#define vf vector<float>
#define vb vector<bool>
#define pi pair<int,int>
#define vpi vector<pair<int,int>>
#define vs vector<string>
#define mp make_pair
#define ll long long
#define vc vector<char>
#define rng(x) x.begin(),x.end()
#define b(x) x.begin()
#define e(x) x.end()
#define F first
#define S second
#define me max_element
#define ne min_element  
const int N = int(1e5+3);
using namespace std;

int main()
{ 
  ios::sync_with_stdio(0);
  cin.tie(0);
     
  int r,g,b,k;
  cin>>r>>g>>b>>k;
  while(k--)
  {
    if(g<=r)
    {
      g*=2;
      continue;
    }
    if(b<=g)
    {
      b*=2;
      continue;
    }
  }
  if(b>g && g>r) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3664
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);

echo join(' ', qsort(array($a, $b, $c)))."\n";

function qsort($nums)
{
    if (count($nums) <= 1) {
        return $nums;
    }

    if (2 == count($nums)) {
        return $nums[0] <= $nums[1] ? $nums : array_reverse($nums);
    }

    $last = count($nums) - 1;

    $lhs = array();
    $rhs = array();
    $pivot = $nums[$last];

    for ($i = 0; $i < $last; $i++) {
        if ($nums[$i] <= $pivot) {
            $lhs[] = $nums[$i];
        }
        else{
            $rhs[] = $nums[$i];
        }
    }

    return array_merge(qsort($lhs), array($pivot), qsort($rhs));
}

Measured memory_bytes: 6624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int main(){
	int q,n;
	cin>>q;
	REP(i,q){
		cin>>n;
		int ret=0;
		while(1){
			int div=10;
			if(n<10)break;
			int tmp = 0;
			while(n/div){
				tmp = max(tmp, (n/div)*(n%div));
				div*=10;
			}
			n=tmp;
			ret++;
		}
		cout << ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	bool f = false;
	for (int i = 0; i < 26&&!f; i++) {
		for (int j = 0; j < 15&&!f; j++) {
			if (n == 4 * i + 7 * j) {
				f = true;
				break;
			}
		}
	}
	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

    def f(self, p, q):
        return self.fact[p + q] * self.factInv[p] * self.factInv[q] % MOD


X, Y = map(int, input().split())
MOD = 10**9 + 7

if (X + Y) % 3 != 0:
    print(0)
    exit()

time = (X + Y) // 3
ans = 0
comb = Combination(time + 10)

for y in range(time + 1):
    x = time - y

    if X == x * 2 + y and Y == y * 2 + x:
        ans += comb.f(x, y)
        ans %= MOD

print(ans % MOD)

Measured memory_bytes: 71920
n = gets.to_i
hs = gets.chomp.split.map(&:to_i)
dp = Array.new(n,10**18)
dp[0] = 0
dp[1] = (hs[1] - hs[0]).abs
(2..n-1).each do |i|
  dp[i] = [dp[i],dp[i-1] + (hs[i] - hs[i-1]).abs].min
  dp[i] = [dp[i],dp[i-2] + (hs[i] - hs[i-2]).abs].min
end
puts dp[-1]

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

int main(){
	vector<int> ABC(3);
  int K;
  cin>>ABC.at(0)>>ABC.at(1)>>ABC.at(2)>>K;
  sort(ABC.begin(),ABC.end());
  cout<<ABC.at(2)*pow(2,K)+ABC.at(0)+ABC.at(1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


int main()
{
	int N;
	cin >> N;
	map<int, int> mp;

	for (int i = 0; i < N; ++i)
	{
		int a; cin >> a;
		if (mp.count(a)) { mp[a]++; }
		else { mp[a] = 1; }
	}

	if (mp.size() > 3)
	{
		cout << "No" << endl;
		return 0;
	}
	
	if (mp.size() == 1)
	{
		if (mp.count(0)) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
		return 0;
	}
	if (mp.size() == 2)
	{
		if (!mp.count(0))
		{
			cout << "No" << endl;
			return 0;
		}
		
		auto itr = mp.begin();
		itr++;

		if (itr->second == mp[0]*2)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}

		return 0;
	}
	
	int num = mp.begin()->second;

	for(auto & itr : mp)
	{
		if(num!=itr.second)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	auto itr = mp.begin();
	int a1 = itr->first; ++itr;
	int a2 = itr->first; ++itr;
	int a3 = itr->first;
	if ((a1^a2) == a3)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


//overflowするときは1を返す
int is_mul_overflow(long long a, long long b) {
	float mul_log;

	if (a == 0 || b == 0) {
		return 0;
	}

	mul_log = log10f(a) + log10f(b);


	if (mul_log > 18.0) {
		return 1;
	}
	else {
		return 0;
	}
}

int main() {

	long long A,Bint;
	string B, ans;

	cin >> A >> B;

	int len;

	len = B.length();

	B.erase(len - 3, 1);

	for (int i = 0; i < 2; i++) {
		if (B[0] == '0') {
			B.erase(0, 1);
		}
	}

	Bint = stoi(B);

	ans = to_string(A*Bint);

	int lenans;

	lenans = ans.length();

	if (lenans >= 3) {
		ans.erase(lenans - 2, 2);
	}
	else {
		ans = "0";
	}

	cout << ans << endl;

	cin >> ans;

	return 0;


}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int p[20000];
int a[20000];
int b[20000];
int main(void)
{
	int N;
	cin >> N;
	Rep(i, N) cin >> p[i];
	Rep(i, N){
		a[i] = 1 + 30000 * i;
		b[i] = 1000000000 - 30000 * i;
	}
	Rep(i, N){
		a[p[i] - 1] += i;
	}
	Rep(i, N - 1) cout << a[i] << " ";
	cout << a[N - 1] << endl;
	Rep(i, N - 1) cout << b[i] << " ";
	cout << b[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
typedef long long ll;

ll __gcd(ll a,ll b){
    while(1){
        if(a<b) swap(a,b);
        if(!b) break;
        a%=b;
    }
    return a;
}

int main(){
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll n=b/c-(a-1)/c,m=b/d-(a-1)/d;
    ll lcm=c*d/__gcd(c,d);
    ll l=b/lcm-(a-1)/lcm;
    cout<<b-a+1-n-m+l<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S = sc.next();
        String ans;

        StringBuilder sb = new StringBuilder(N);
        for(int i = 0; i < N; i++){
            if(i == K - 1){
                sb.append(S.substring(i, i + 1).toLowerCase());
            }else{
                sb.append(S.substring(i, i + 1));
            }
        }
        ans = sb.toString();
        System.out.println(ans);
    }
}

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

int main(){
    string S;
    cin >> S;
    for(int i = 0; i < S.size() - 1; i++){
        if(S[i] == 'A' && S[i + 1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 764
#include <stdio.h>
int main(int argc, char *argv[]){
	int A, B, C, sum, max, min, result;
	scanf("%d %d %d", &A, &B, &C);
	sum = A+B+C;
	max = A>B?(A>C?A:C):(B>C?B:C);
	min = A>B?(B>C?C:B):(A>C?C:A);
	A=min, C=max, B=sum-max-min;
	result = C-B;
	if((C-(A+result))%2==0){
		result += (C-(A+result))/2;
	} else {
		result += (C-(A+result))/2+1;
		result++;
	}
	printf("%d", result);
	return 0;
}

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

using namespace std;

int main(){
    int H, W;
    char c[101][101];
    cin >> H >> W;

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cout << c[i][j];
        }
        cout << endl;
        for(int j = 0; j < W; ++j){
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import itertools

N, M, X = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(N)]
list_N = [i for i in range(N)]

ans = []
for num_book in range(1, N + 1):
    for i in itertools.combinations(list_N, num_book):
        #print(i)
        temp = 0
        for j in range(1, M + 1):
            sum_line = sum([s[i[k]][j] for k in range(num_book)])
            if sum_line < X:
                break
            temp += 1
            if temp == M:
                score=sum([s[i[k]][0] for k in range(num_book)])
                #print(score)
                ans.append(score)
    #if len(ans) != 0:
    #    break
if len(ans)==0:
    print(-1)
else:
    #print(ans)
    print(min(ans))


Measured memory_bytes: 9264
calcStam :: Int -> [Int] -> Int
calcStam i x = sum $ map (\a -> (a-i) ^ 2) x

main = do
   n <- (read :: String -> Int) <$> getLine
   x <- map (read :: String -> Int) . words <$> getLine
   putStrLn $ show $ minimum $ map (\a -> calcStam a x) [1..100]

Measured memory_bytes: 1020
//Simple Calculator

#include <iostream>
#include <cassert>

namespace {

bool is_operator(char op)
{
  switch (op) {
  case '+':
  case '-':
  case '*':
  case '/':
  case '?':
    return true;
  }
  return false;
}

template <class T>
T operate(char op, T& a, T& b)
{
  switch (op) {
  case '+':
    return a + b;
  case '-':
    return a - b;
  case '*':
    return a * b;
  case '/':
    assert(b != 0);
    return a / b;
  }

  return T(0);
}

} // unnamed namespace

int main()
{
  while (1) {
    char op;
    int a, b;
    std::cin >> a >> op >> b;

    assert(a >= 0 && a <= 20000);
    assert(b >= 0 && b <= 20000);
    assert(is_operator(op));

    if (op == '?') break;

    std::cout << operate<int>(op, a, b) << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1160
S = input()
# S = '?'*100000

num_mod = 10 ** 9 + 7
dp = [1] + [0]*12

for i in range(len(S)):
  nextdp = [0] * 13
  if S[i] == '?':
    for j in range(13):
      for k in range(10):
        nextdp[(j*10 + k)%13] += dp[j]
  else:
    for j in range(13):
      nextdp[(j*10 + int(S[i]))%13] += dp[j]
  for j in range(13):
    nextdp[j] %= num_mod
  dp = nextdp
  # print(dp)
print(dp[5])

Measured memory_bytes: 44316
N = int(input())
A = list(map(int, input().split()))
left = 0
right = 2 * A[0] + 2
while left < right:
    rain = [0] * N
    rain[0] = (left + right) // 4 * 2
    for i in range(N-1):
        rain[i+1] = 2 * A[i] - rain[i]
    rain0 = 2 * A[-1] - rain[-1]
    if rain[0] > rain0:
        right = rain[0]
    elif rain[0] < rain0:
        left = rain[0] + 2
    else:
        print(' '.join(map(str, rain)))
        exit()


Measured memory_bytes: 19140
n = gets.chomp!

s = n.size
n = n.to_i

if s == 1
  puts n
elsif s == 2
  puts 9
elsif s == 3
  puts 9 + (n - 99)
elsif s == 4
  puts 909
elsif s == 5
  puts 9 + 900 + (n - 9999)
elsif s == 6
  puts 90909
end


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int x[100005];
//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int n;cin >> n;
	int maxx = 0;

	rep(i,n) 
	{
		cin >> x[i];
		maxx = max(maxx,x[i]);
	}
	
	int k = 900000000000000;
	int idx;
	rep(i,n)
	{	
		if(x[i] == maxx) continue;

		if(k > abs(maxx/2 - x[i]))
		{
			k = abs(maxx/2 - x[i]);
			idx = i;
		}
	}

	cout << maxx << " " << x[idx] << endl;

	//
	// your code finished


	return 0;
}

Measured memory_bytes: 1532
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .map(function (line) { return line.split(' ').map(Number); });

n = line[0][0];
m = line[0][1];
q = line[m+1][0];

adj = new Array(n);
for (i = 0; i < n; i++) adj[i] = [];
for (i = 1; i <= m; i++) {
  adj[line[i][0]].push(line[i][1]);
  adj[line[i][1]].push(line[i][0]);
}

d = new Array(n);
for (i = 0; i < n; i++) d[i] = null;
stack = new Array(n*2);

function dfs(from, stack, adj, d) {
  var sp = 0, cur = from, rest = adj[from].length, next;
  d[from] = from;
  while (sp >= 0) {
    while (rest !== 0) {
      rest--;
      next = adj[cur][rest];
      if (d[next] !== null) continue;
      d[next] = from;
      stack[sp++] = cur;
      stack[sp++] = rest;
      cur = next;
      rest = adj[next].length;
    }
    rest = stack[--sp];
    cur = stack[--sp];
  }
}

for (i = 0; i < n; i++)
  if (d[i] === null) dfs(i, stack, adj, d);

for (i = m+2; i < (m+2) + q; i++)
  console.log((d[line[i][0]] === d[line[i][1]]) ? 'yes' : 'no');

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

using namespace std;
using i64 = int64_t;

int main()
{
    int n;
    cin >> n;
    vector<i64> l(n);
    for (auto &&x : l)
        cin >> x;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k])
                    continue;
                if(abs(l[i] - l[j]) < l[k] && l[k] < abs(l[i] + l[j]))ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int N;
    cin >> N;

    int max_4=N/4;
    for(int i=0;i<=max_4;i++){
        int max_7 = (N-i*4)/7;
        for(int j=0;j<=max_7;j++){
            if(i*4+j*7==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
card = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bingo = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        card[i][j] = "o" if card[i][j] in bingo else card[i][j]

ans = "No"
if card[0][0] == card[0][1] == card[0][2] \
    or card[1][0] == card[1][1] == card[1][2] \
    or card[2][0] == card[2][1] == card[2][2] \
    or card[0][0] == card[1][0] == card[2][0] \
    or card[0][1] == card[1][1] == card[2][1] \
    or card[0][2] == card[1][2] == card[2][2] \
    or card[0][0] == card[1][1] == card[2][2] \
    or card[0][2] == card[1][1] == card[2][0]:
    ans = "Yes"

print(ans)

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int h,w,count;
  string temp;
  cin >> h >> w;
  int s[h+2][w+2];
  count = h;
  for (size_t i = 0; i < h+2; i++) {
    for (size_t j = 0; j < w+2; j++) {
      s[i][j] = '.';
    }
  }
  for (size_t i = 0; i < h; i++) {
    cin >> temp;
    for (size_t j = 0; j < count; j++) {
      s[i+1][j+1] = temp[j];
    }
  }
  for (size_t i = 0; i < h; i++) {
    for (size_t j = 0; j < w; j++) {
      if (s[i+1][j+1] == '#') {
        if (s[i][j+1] == '.' && s[i+1][j] == '.' && s[i+1][j+2] == '.' && s[i+2][j+1] == '.' ) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<int> x(n),y(n);
    vector<int> xary,yary;

    REP(i,n){
        cin>>x[i]>>y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    VSORT(xary);
    VSORT(yary);

    ll ans= 1LL *(xary[n-1]-xary[0])*(yary[n-1]-yary[0]);
    REP(xi,n){
        for(int xj=xi+1;xj<n;xj++){
            REP(yi,n){
                for(int yj=yi+1;yj<n;yj++){
                    int num=0;
                    ll lx=xary[xi],rx=xary[xj];
                    ll by=yary[yi],uy=yary[yj];
                    for(int i=0;i<n;i++){
                        if(lx<=x[i]&&x[i]<=rx&&by<=y[i]&&y[i]<=uy) num++;
                    }
                    if(num>=k) ans=min(ans,1LL*(rx-lx)*(uy-by));
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
S = input()


ans = S.count('R') * S.count('G') * S.count('B')

SN = []

for s in S:
    if s == 'R': SN.append(-1)
    elif s == 'G': SN.append(0)
    else: SN.append(1)

rem2 = ['RRR', 'GGG', 'BBB']

count = 0
for i in range(1, N-1):
    index = i
    left = i - 1
    right = i + 1
    f = True
    while f:
        if left == -1 or right == N:
            break
        if SN[left] == SN[index] and SN[index] == SN[right] == 0 : pass
        elif SN[left] + SN[index] + SN[right] == 0 :
            count+= 1
        
        left -= 1
        right += 1

print(ans-count)


Measured memory_bytes: 9284
class Dice:
    def __init__(self,pips):
        self.top = pips[0]
        self.south = pips[1]
        self.east = pips[2]
        self.west = pips[3]
        self.north =pips[4]
        self.bottom=pips[5]
    def show_top(self):
        print(self.top)
    def n(self):
        tmp = self.top
        self.top = self.south
        self.south = self.bottom
        self.bottom = self.north
        self.north = tmp
    def s(self):
        tmp = self.top
        self.top = self.north
        self.north = self.bottom
        self.bottom = self.south
        self.south = tmp
    def e(self):
        tmp = self.top
        self.top = self.west
        self.west = self.bottom
        self.bottom = self.east
        self.east = tmp
    def w(self):
        tmp = self.top
        self.top = self.east
        self.east = self.bottom
        self.bottom = self.west
        self.west = tmp

pips = [int(x) for x in input().split()]
dice = Dice(pips)
move = input()
for m in move:
    if m == "N":
        dice.n()
    if m == "S":
        dice.s()
    if m == "E":
        dice.e()
    if m == "W":
        dice.w()

dice.show_top()

Measured memory_bytes: 7792
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    cout << (a - (s == u)) << ' ' << (b - (t == u));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[1000000]={0},dp[1000000];
ll fun(ll n)
{
    if(n>0)
    {
        if(dp[n]!=-1)
        return dp[n];
    }
    if(n==1)
    return 0;
    if(n<=0)
    return INT_MAX;
    else
    {
        ll f,s;
       // return min((h[n]-h[n-1]+fun(n-1)),(h[n]-h[n-2]+fun(n-2)));
       if(n-1>0)
       f=abs(a[n]-a[n-1])+fun(n-1);
       if(n-2>0)
       s=abs(a[n]-a[n-2])+fun(n-2);
       return dp[n]=min(f,s);
    }
}
int main()
{
    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++)
    cin>>a[i];
    cout<<fun(n)<<endl;
}

Measured memory_bytes: 16824