akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  double pi = acos(-1);
  int a, b;
  cin >> a >> b;
  int h, m;
  cin >> h >> m;
  double th = double(60*h+m)/720*2*pi;
  double tm = double(m)/60*2*pi;
  double d = th -tm;
  d = min(d, 360.0-d);
  printf("%.10f\n", sqrt(a*a+b*b-2.00*a*b*cos(d)));
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
 int lis( int arr[], int n )  
{  
    int lis[n]; 
   
    lis[0] = 1;    
  
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 0; j < i; j++ )   
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)  
                lis[i] = lis[j] + 1;  
    } 
  
    // Return maximum value in lis[] 
    return *max_element(lis, lis+n); 
}  
void computeLPSArray(char* pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 
    
int main()
{
  fastio();
 
ll int T;
T=1;
ll int anscount=1;
while(T--)
{
   double l;
   cin>>l;
   double ans = l*l*l/27;
   cout<<fixed<<std::setprecision(12)<<ans<<endl;
}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n;
  cin >> n;
  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    if (!(i % 3 == 0) && !(i % 5 == 0)) res += i;
  }
  cout << res << endl;
}

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

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll d[100100] = { };

int main(){
	int n, W;
	cin >> n >> W;
	ll w[n], v[n];
	REP(i, n) cin >> w[i] >> v[i];
	FOR(i, 1, 100100) d[i] = INF;
	REP(i, n){
		for(int j = 100099; j >= v[i]; j--){
			d[j] = min(d[j], d[j-v[i]]+w[i]);
		}
	}
	for(int i = 100099; i > 0; i--) d[i-1] = min(d[i], d[i-1]);
	int ans = 0;
	REP(i, 100100){
		if(d[i] > W){
			cout << i-1 << endl;
			return 0;
		}
	}
} 

Measured memory_bytes: 1024
n,k=map(int,input().split())
S=input()+"*"
A=[0,0] if S[0]=="0" else [0]
num,cnt=S[0],0
for i in range(n+1):
    if num==S[i]:cnt +=1
    else:
        A.append(cnt)
        num=S[i]
        cnt=1

ans=0
for i in range(1,len(A)):
    A[i]=A[i]+A[i-1]
for i in range(0,len(A),2):
    ans=max(ans,A[min(i+2*k+1,len(A)-1)]-A[i])
print(ans)

Measured memory_bytes: 45552
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a = l()

a.sort()
co = 0
if any(map(lambda x:x % 2 == 1,a)):
    print(0)
    exit()
if a[0] == a[1] and a[1] == a[2]:
    print(-1)
    exit()
while True:
    a = [(a[2]+a[1])//2,(a[1]+a[0])//2,(a[0]+a[2])//2]
    co += 1
    if any(map(lambda x:x % 2 == 1,a)):
        print(co)
        exit()






Measured memory_bytes: 3316
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,a,b;
	cin>>x>>a>>b;
	int d1=abs(x-a),d2=abs(x-b);
	if(d1<d2)
	{
		cout<<"A\n";
	}
	else cout<<"B\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k;
    scanf("%d",&n);
    if(n==1)
    {
        printf("Hello World");
    }
    else
    {
        scanf("%d%d",&i,&k);
        printf("%d",i+k);
    }
}


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

int main(void){
    long long int i, j, n, x, d, t, s, ans=0, po=0;
    scanf("%lld", &x);
    if(x==0) printf("1");
    else printf("0");
    
}

Measured memory_bytes: 1656
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
  
        static long[] a;
        static long N;
        static long K;
        
        static void Main(string[] args)
        {
          //入力を受け取る
          int N = int.Parse(Console.ReadLine());
          int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          
          var destroyed = 0L;
          var amari = 0;
          
          for(int i = 0; i < N ; i++ ){
            amari = 0;
            //最小値を求める
            var x = Math.Min(A[i],B[i]);
            A[i] -= x;
            B[i] -= x;
            destroyed += x;
            
            var y = Math.Min(A[i+1],B[i]);
            A[i+1] -= y;
            B[i] -= y;
            destroyed += y;
          }
          
          //Console.WriteLine(String.Join(" ",A));
          Console.WriteLine(destroyed);
          
        }
 }


Measured memory_bytes: 34376
<?php
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}

// 配列の各要素をさらに分解します
foreach ($tmp as $key => $value) {
  $array[] = explode(" ", $value);
}

$n = $array[0][0];
$a = hantei($array[1]);
$b = hantei($array[2]);
$diff = $a - $b;
if ($diff > 0) {
    echo $diff;
} elseif ($diff == 0) {
    $diff = 0;
    echo $diff;
} else {
    $diff = -1 * $diff;
    echo $diff;
}
function hantei($number_array) {
    global $n;
    $count = 0;
    for ($t = 0; $t < $n; $t++) {
        $number = $number_array[$t];
        $keta = $t + 1;
        $k = $n - $keta;
        $tmp1 = kaizyou($k);
        $tmp2 = check($number_array,$t,$number);
        $result = $tmp1 * $tmp2;
        $count = $count + $result;
    }
  return $count + 1;
}
function kaizyou($k) {
    $result = 1;
    for ($t = $k;$t > 0 ;$t--) {
        $result = $result * $t;
    }
    return $result;
}

function check($number_array,$t,$number) {
    $tmp_array = array_slice($number_array,$t);
    sort($tmp_array);
    $nambann = array_search($number,$tmp_array);
    return $nambann;
}

Measured memory_bytes: 4728
n, m = map(int, input().split())
sc = []
for i in range(m):
    sc.append(list(map(int, input().split())))

for i in range(0, 10**n):
    str_i = str(i)
    # print(str_i)
    tf = True
    if len(str_i) == n:
        for j in range(m):
            if str_i[sc[j][0] - 1] != str(sc[j][1]):
                tf = False
        if tf:
            print(i)
            exit()
print(-1)
exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll f[2000200], finv[2000200];

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

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, 2000200) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
  }
}

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

  init();

  ll k;
  string s;
  cin >> k >> s;

  ll sn = s.length();
  ll n = sn + k;
  ll ans = 0;
  FOR(i, sn, n + 1) {
    ll res = nCr(i - 1, sn - 1) * modpow(25, i - sn) % mod;
    ans = (ans + res * modpow(26, n - i)) % mod;
  }
  cout << ans << '\n';




  




  
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  int c = 0;
  bool f = false;
  rep(i, n){
    int d1,d2;cin>>d1>>d2;
    if(d1==d2)c++;
    else c=0;
    if(c>=3)f=true;
  }

  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3632
n = int(input())
cnt = [0, 0, 0, 0]
for n in range(n):
	s = input()
	if (s == 'AC'):
		cnt[0] += 1
	if (s == 'WA'):
		cnt[1] += 1
	if (s == 'TLE'):
		cnt[2] += 1
	if (s == 'RE'):
		cnt[3] += 1
print('AC x', cnt[0])
print('WA x', cnt[1])
print('TLE x', cnt[2])
print('RE x', cnt[3])

Measured memory_bytes: 69852
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    string s1,s2;
    cin>>s1>>s2;
    ll count=0;
    for(i=0;i<s1.size();i++) if(s1[i]==s2[i]) count++;
    cout<<count;
    
}

Measured memory_bytes: 3584
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ (a + b) * h `div` 2
  where [a, b, h] = fmap read (lines s) :: [Int]

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c,ans;
int main()
{
  scanf("%lld%lld%lld",&a,&b,&c);
  if(a%2==0||b%2==0||c%2==0)  printf("0");
  else  ans=min(min(a*b,a*c),b*c),printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	string ans = "";
	cin >> input;

	for (int i = 0; i < input.size(); i += 2)
	{
		ans += input[i];
	}

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main()
{jizz
	int n,h,w;
	cin >> n >> h >> w;
	cout << max(0,(n-h+1)*(n-w+1)) << "\n";
}

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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define rd(inp) scanf("%lld",&inp)
#define rd2(inp1, inp2) scanf("%lld %lld",&inp1, &inp2)
#define rl(inp) scanf("%d",&inp)
#define pf(out) printf("%lld\n", out);

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll fpow(ll base,ll power){
	ll result = 1;
	while (power > 0){
		if (power%2 == 1) result=(result*base);
  		base = (base*base);
  		power /= 2;
  	}
	return result;
}

int c[111][111];
vector<pair<ll, ll> > v;

int main(){
	int H, W, N;
	cin >> H >> W;
	cin >> N;
	for ( int i = 0 ; i < N ; i ++ ){
		ll a; cin >> a;
		v.push_back(make_pair(a, i + 1));
	}
	sort(all(v));
	reverse(all(v));
	int idx = 0;
	for ( int i = 0 ; i < H ; i ++ ){
		if ( i % 2 == 0 ){
			for ( int j = 0 ; j < W ; j ++ ){
				c[i][j] = v[idx].S;
				v[idx].F --;
				if ( v[idx].F == 0 ){
					idx ++;
				}
			}
		}
		else{
			for ( int j = W - 1 ; j >= 0 ; j -- ){
				c[i][j] = v[idx].S;
				v[idx].F --;
				if ( v[idx].F == 0 ){
					idx ++;
				}
			}
		}
	}
	for ( int i = 0 ; i < H ; i ++ ) {
		for ( int j = 0 ; j < W ; j ++ ){
			cout << c[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 640
import itertools
N=int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
PP=tuple(P)
A=list(itertools.permutations(range(1,N+1)))
PW=(A.index(P))
QW=(A.index(Q))
print(abs(PW-QW))


Measured memory_bytes: 8052
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

#define maxs(x,y) (x=std::max(x,y))
#define mins(x,y) (x=std::min(x,y))

int main() {
  ll N;
  cin >> N;
  vector<std::string> S_box(N);
  rep(i, N) cin >> S_box[i];
  rep(i, N) {
    std::sort(S_box[i].begin(), S_box[i].end());
  }
  std::sort(S_box.begin(), S_box.end());

  ll answer {};
  std::string tmp {};
  bool double_find = false;
  ll cnt {};

  rep(i, N) {
    if (double_find == true && tmp == S_box[i]) {
      ++cnt;
    } else if (double_find == true) {
      tmp = S_box[i];
      answer += cnt*(cnt-1)/2;
      double_find = false;
      cnt = 0;
    } else if (tmp == S_box[i]) {
      cnt = 2;
      double_find = true;
    } else {
      tmp = S_box[i];
    }
  }
  answer += cnt*(cnt-1)/2;
  cout << answer << '\n';
}


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

#define ll long long int

int main() {
    int n;
    cin >> n;
    vector< pair<int, int> > w(n);
    for(int i = 0; i < n; i++) cin >> w[i].second >> w[i].first;
    sort(w.begin(), w.end());
    ll time = 0;
    int flag = 1;
    for(int i = 0; i < n; i++) {
        time += w[i].second;
        if(time > w[i].first) {
            flag = 0;
            break;
        }
    }
    cout << (flag == 1 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
string s;
cin >> s;
if(s.size()%2==0){
    string t,z;
    for(int i=0;i<s.size()/2;i++){
        t+=s.at(i);
    }
    for(int i=s.size()/2;i<s.size();i++){
        z+=s.at(i);
    }
    reverse(z.begin(),z.end());
    int ans =0;
    for(int i=0;i<t.size();i++){
        if(z.at(i)!=s.at(i))ans++;
    }
    cout << ans << endl;
}
else{
        string t,z;
    for(int i=0;i<s.size()/2;i++){
        t+=s.at(i);
    }
    for(int i=s.size()/2+1;i<s.size();i++){
        z+=s.at(i);
    }
    int ans = 0;
    reverse(z.begin(),z.end());
    for(int i=0;i<t.size();i++){
        if(t.at(i)!=z.at(i))ans++;
    }
    cout << ans << endl;
}
}
 


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll D, G;
vector<ll>P, C;

int main() {
	ll N, K;
	cin >> N >> K;
	P = vector<ll>(N);
	rep(i,N) {
		cin >> P[i];
	}
	sort(P.begin(), P.end());
	ll ans = 0;
	rep(i,K) {
		ans += P[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
a,b,ab,ax,bx = map(int,input().split())
#a,b,ab,ax,bx = (1500, 2000, 1600, 3, 2)

import math
import sys

abmax = max(ax,bx)*2
candi = list()

for nab in range(abmax,-1,-1):
  na = max(math.ceil(ax - nab * 0.5),0)
  nb = max(math.ceil(bx - nab * 0.5),0)
  candi.append((na,nb,nab))

mincost = candi[0][0]*a + candi[0][1]*b + candi[0][2]*ab

for i in candi:
  cost = i[0]*a + i[1]*b + i[2]*ab
  if(cost < mincost):
    mincost = cost

print(mincost)

Measured memory_bytes: 38040
include Math

a, b, d = gets.split.map(&:to_i)
p a * b * sin(d * PI / 180) / 2
p a + b + (a ** 2 + b ** 2 - 2 * a * b * cos(d * PI / 180)) ** 0.5
p b * sin(d * PI / 180)

Measured memory_bytes: 6208
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, b; scan(a, b);
  string s; scan(s);
  rep (i, a) {
    if (!('0' <= s[i] && s[i] <= '9')) {
      print("No");
      return 0;
    }
  }
  if (s[a] != '-') {
    print("No");
    return 0;
  }
  FOR (i, a+1, a+b+1) {
    if (!('0' <= s[i] && s[i] <= '9')) {
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int temp = 0;
		boolean flag = false;

		while (temp <= B) {
			temp += K;
			if (A <= temp && temp <= B) {
				System.out.println("OK");
				flag = true;
				break;
			}
		}

		if (!flag) System.out.println("NG");
	}
}

Measured memory_bytes: 35804
/*
ID: jerrywcy
TASK: AtCoder ABC 108 Problem D
LINK: https://abc108.contest.atcoder.jp/tasks/abc108_d
LANG: C++
*/
#include <bits/stdc++.h>
     
using namespace std;

int l;
bool te[20];
     
int main() {
    int i,j;
    cin>>l;
     
    int tl=l;
    int dl=0;
    int ce=0;
    while (tl){
    	if (tl&1){
    		te[dl]=1;
    		ce++;
		}
		tl>>=1;
		dl++;
	}
	
	cout<<dl<<' '<<(dl-1)*2+ce-1<<endl;
	
	long long t=1;
	for (i=1;i<dl;i++){
		cout<<i<<' '<<i+1<<' '<<0<<endl;
		cout<<i<<' '<<i+1<<' '<<t<<endl;
		if (te[i-1]){
			cout<<i<<' '<<dl<<' '<<l-t<<endl;
			l-=t;
		}
		t<<=1;
	}
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <fstream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> dp(3);
	for(int d=0; d<n; d++)
	{
		vector<int> chk(3, 0);
		int vals[3];
		for(int j=0;j<3;j++)
			cin>>vals[j];
			
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i!=j)
				{
					//chk[j] = max(chk[j], dp[i] + vals[j]);
					chk[i] = max(chk[i], dp[j] + vals[i]);
				}
			}	
		}	
		dp = chk;
	}
	
	cout<<max({dp[0], dp[1], dp[2]});
    return 0;
}

Measured memory_bytes: 256
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int N=3001;
int dp[N][N];
string s,tt;
void traceback(int i,int j,string seq)
{
    if(i==0 or j==0)
    {
        reverse(all(seq));
        cout<<seq<<endl;
        return;
    }
    if(s[i-1]==tt[j-1])
    {
        seq+=s[i-1];
        traceback(i-1,j-1,seq);
        return;
    }
    else if(dp[i-1][j]==dp[i][j])
        traceback(i-1,j,seq);
    else if(dp[i][j]==dp[i][j-1])
        traceback(i,j-1,seq);
}

void solve()
{
    cin>>s>>tt;
    int n=sz(s);
    int m=sz(tt);
    rep(i,0,n+1)
    {
        rep(j,0,m+1)
        {
            if(i==0 or j==0)
                dp[i][j]=0;
            else if(s[i-1]==tt[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    traceback(n,m,"");

}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 43264
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine
    val mp = scala.collection.mutable.Map[String, Long]()
    for (i <- 0 until n) {
      val s = sc.nextLine.toSeq.sorted.toString
      if (mp.contains(s)) {
        mp(s) = mp(s) + 1
      } else {
        mp(s) = 1
      }
    }
    var count = 0L
    for (key <- mp.keys) {
      val c = mp(key)
      count += c * (c - 1) / 2
    }

    println(count)
  }
}


Measured memory_bytes: 117680
s = gets.chomp
t = gets.chomp

st = {}
ts = {}
s.size.times do |i|
    if st[s[i]].nil? && ts[t[i]].nil?
        st[s[i]] = t[i]
        ts[t[i]] = s[i]
    elsif st[s[i]] == t[i] && ts[t[i]] == s[i]
    else
        puts "No"
        break
    end
end and puts "Yes"

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

int main(){
    int A,B;
    cin >> A >> B;
    if(1<=A && A<=9 && 1<=B && B<=9){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 4e5 + 5;
const long long MNN = 1e3 + 1;
const long long MOD = 10;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int n, m;
llong a[MNN], b[MNN];
llong dp[MNN][5000];

int main(){
    ios;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int l;
        cin >> a[i] >> l;
        for(int j = 1; j <= l; j++){
            int x;
            cin >> x;
            b[i] |= (1 << (x - 1));
        }
    }
    for(int i = 0; i <= m; i++){
        for(int j = 0; j < (1 << n); j++){
            dp[i][j] = OO;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j < (1 << n); j++){
            dp[i][j] = dp[i - 1][j];
        }
        for(int j = 0; j < (1 << n); j++){
            if(j | b[i] < (1 << n)){
                dp[i][j | b[i]] = min(dp[i - 1][j] + a[i], dp[i][j | b[i]]);
            }
        }
    }
    cout << (dp[m][(1 << n) - 1] == OO ? -1 : dp[m][(1 << n) - 1]);
    return 0;
}


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



int main() {

//変数の宣言

	long int a,b,temp;
	long int c[2];
	
	while(cin>>a>>b){
	
		c[0] = a;
		c[1] = b;
		
		if (c[0] < c[1]){
			temp = c[0];
			c[0] = c[1];
			c[1] = temp;
		}
		
		while(1){
			c[0] = c[0] % c[1];
			if (c[0]==0) break;
			temp = c[0];
			c[0] = c[1];
			c[1] = temp;
		}
		c[0] = a/c[1];
		c[0] = c[0]*b;
		
		cout << c[1] << " " << c[0] << endl;
	
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll n,m,a;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<s.size();j++)
			{
				if(s[j]=='F') 
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Map<Long, Long> mp = new HashMap<>();
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextLong();
        }
        System.out.println(helper(A, 0, N/2));
    }
    private static long helper(long[] A, int ofs, int cnt){
        long key = ofs * 3_000_00 + cnt;
        if(mp.containsKey(key)){
            return mp.get(key);
        }
        if(cnt == 0){
            return 0;
        }
        int size = (A.length-ofs);
        if(size == 1 && cnt == 1){
            return A[ofs];
        }
        if(size == 2 && cnt == 1){
            return Math.max(A[ofs], A[ofs+1]);
        }
        if(size % 2 == 1 && size/2+1 == cnt){
            long ans = A[ofs] + helper(A, ofs+2, cnt-1);;
            mp.put(key, ans);
            return ans;
        }
        long use = A[ofs] + helper(A, ofs+2, cnt-1);
        long nouse = helper(A, ofs+1, cnt);
        long ans = Math.max(use, nouse);;
        mp.put(key,ans);
        return ans;
    }
}


Measured memory_bytes: 112796
a = 5.times.map { gets.to_i }
k = gets.to_i

def can_communicate(a, k)
  (0..4).each do |i|
    (0..4).each do |j|
      return false if (a[i] - a[j]).abs > k
    end
  end
  true
end

puts can_communicate(a, k) ? 'Yay!' : ':('

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

string s;

int main(){
  while(cin >> s, s!="0"){
    int n = s.size();
    
    int dp[2][11][2] = {};
    dp[0][0][0] = 1;

    for(int i=0;i<n;i++){
      int now = i&1, nxt = 1-now;
      for(int j=0;j<11;j++)dp[nxt][j][0] = dp[nxt][j][1] = 0;

      int val = s[i] - '0';
      dp[nxt][0][0] += dp[now][0][0] + dp[now][0][1];
      if(val)dp[nxt][val][1]++;
 
      for(int j=0;j<11;j++)dp[nxt][(j*10+val)%11][1] += dp[now][j][1];
    }

    cout << dp[n&1][0][0] + dp[n&1][0][1] -1 << endl;
  }
}

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

using namespace std;

int main(void) {
  int n, K;
  cin >> n >> K;

  vector<int> v[11];
  for (int i = 0; i < n; i++) {
    int g, c;
    cin >> g >> c;
    v[c].push_back(g);
  }

  for (int i = 1; i <= 10; i++) {
    sort(v[i].begin(), v[i].end(), greater<int>());
    for (int j = 1; j < v[i].size(); j++) {
      v[i][j] += v[i][j - 1];
    }
    for (int j = 0; j < v[i].size(); j++) {
      v[i][j] += j * (j + 1);
    }
  }

  int dp[11][2010] = {};
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= K; j++) {
      dp[i][j] = dp[i - 1][j];
      for (int k = 1; k <= j; k++) {
        if (j - k != 0 && dp[i - 1][j - k] == 0 || k > v[i].size()) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][j - k] + v[i][k - 1]);
      }
    }
  }

  cout << dp[10][K] << endl;

  return 0;
}


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

int main(){
  long long A,B,C,X,Y,a=0;
  cin >> A >> B >> C >> X >> Y;
  long long ans=2000000000;
  for(int i=0;i<=2*max(X,Y);i+=2){
    ans=min(ans,i*C+A*max(a,X-i/2)+B*max(a,Y-i/2));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def f(n):
  p=[]
  if n%2==0:
    c=0
    while n%2==0:
      c+=1
      n/=2
    p.append(c)
  for i in range(3,int(n**0.5)+1,2):
    if n%i==0:
      c=0
      while n%i==0:
        c+=1
        n/=i
      p.append(c)
  if n!=1:
    p.append(1)
  return p
  
N=int(input())
p=f(N)
r=0
while p:
  r+=int(((8*p.pop()+1)**0.5-1)/2)
print(r)

Measured memory_bytes: 9356
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_H 51
#define MAX_W 51
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int h, w;
bool s[MAX_H][MAX_W];
signed main(){
	cin >> h >> w;
	REP(i, h){
		REP(j, w){
			char c; cin >> c;
			if(c == '#') s[i][j] = true;
			else s[i][j] = false;
		}
	}
	bool flag = true;
	REP(i, h){
		REP(j, w){
			bool paintable = false;
			if(!s[i][j]) continue;
			if(i > 0) paintable |= s[i-1][j];
			if(i < h-1) paintable |= s[i+1][j];
			if(j > 0) paintable |= s[i][j-1];
			if(j < w-1) paintable |= s[i][j+1];
			flag &= paintable;
		}
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

#include<bits/stdc++.h>
using namespace std;
#define    in_file     freopen("input.txt", "r", stdin)
#define    out_file    freopen("output.txt", "w", stdout)
#define    fast        ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define    F           first
#define    S           second
#define    pb          push_back
#define    popb        pop_back
#define    pf          push_front
#define    popf        pop_front
#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi          2*acos(0)
#define    elif        else if
#define    ll          long long
#define    sp          fixed<<setprecision
#define    nl          '\n'
#define    endl        '\n'
#define    forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define    fora(i,n)   for(int (i)=0; (i) < (n); (i)++)


int Int(){int x;scanf("%d", &x);return x;}
#define    Int         Int()
#define    mx          100010
void dhimanda();
int main()
{
    //fast;
    //in_file;
    //out_file;
    int t=1;
    forr(i,1,t){
        //printf("Case #%d: ", i);
        dhimanda();
    }
    return 0;
}
void dhimanda(){
    ll n;
    cin >> n;
    map <string , int> m;
    map <string , int> :: iterator itr;
    m.clear();
    int mxx= 0;
    for(int i=1; i<= n;i++) {
        string tmp;
        cin >> tmp;
        int c=m[tmp]++;
        //cout << c <<endl;
        if(c > mxx) mxx = c;

    }
    mxx++;
    for (auto itr = m.begin(); itr != m.end(); ++itr){
           if (itr->S == mxx) cout << itr->F <<endl;
    }
}

// Contact : chessdhiman@gmail.com


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

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

  string ans = "No";
  if(N % 2 == 0){
    ans = "Yes";
    rep(i, N / 2) if(S[i] != S[i + N/2]) ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
int main() {
	int a[6], sum[5] = {0};
    int i = 0;
    while(1){
        std::cin >> a[i];

        if (a[i] == 0) {
            break;
        }
		i++;
        
    }
	i = 0;
    while (a[i] != 0) {
        sum[i] += (1000 - a[i]) / 500;
        a[i] = (1000 - a[i]) % 500;
        sum[i] += a[i] / 100;
        a[i] = a[i] % 100;
        sum[i] += a[i] / 50;
        a[i] = a[i] % 50;
        sum[i] += a[i] / 10;
        a[i] = a[i] % 10;
        sum[i] += a[i] / 5;
        a[i] = a[i] % 5;
        sum[i] += a[i];
        i++;
    }
    for (int j = 0; j<i; j++) {
        std::cout << sum[j] << std::endl;
    }
    return 0;
}


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

//ABC 99 c.cpp
int main() {
    int MX = 10000000;
    int n;
    cin >> n;

    int I=0;
    while(pow(6,I+1) <= n) I++;
    // cout << I << endl;
    int J = 0;
    while(pow(9,J+1) <= n) J++;
    // cout << J << endl;

    vector<int> dp(n+1);
    rep(i,n+1) dp[i] = MX;
    dp[0] =  0;
    int ind = 0;
    for(int i =0;i < n;i++){
        dp[i+1] = min(dp[i+1],dp[i] + 1);
        for(int j = 1;j<=J;j++){
            ind = pow(9,j);
            if(i+ind<=n) dp[i+ind] = min(dp[i+ind],dp[i] + 1);
        }
        for(int j = 1;j<=I;j++){
            ind = pow(6,j);
            if(i+ind<=n) dp[i+ind] = min(dp[i+ind],dp[i] + 1);
        }
    }

    int ans = dp[n];
    cout << ans << endl;
}

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

int main() {
	int x,y;cin >> x>>y;
	if(y%2!=0){
		cout << "No" << endl;
		return 0;
	}
	int c = 2*x - y/2;
	int t = (y-2*x)/2;
	if(c>=0&&t>=0){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3596
import sys
from collections import defaultdict
from functools import reduce
input = lambda: sys.stdin.readline().rstrip()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def prime_factorize(n):
    # Return list of prime factorized result
    # O(sqrt(n))
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

case = 3
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(lambda: 0)
f = True
for v in a:
    factors = prime_factorize(v)
    for f in factors:
        if d[f] > 0:
            f = False
            break
        d[f] += 1
    if not f:
        break
if f:
    case = 1

if case != 1:
    g = a[0]
    for v in a[1:]:
        g = gcd(g, v)
    if g == 1:
        case = 2

if case == 1:
    print("pairwise coprime")
elif case == 2:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 195628
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
int f(int a, int b) {
  int ab = abs(a - b);
  return min(b, ab);
}
int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0, num = 0;
  for(int i = 0; i < n - 1; i++) if (num < f(a[n - 1], a[i])) {
    ans = a[i];
    num = f(a[n - 1], a[i]);
  }
  cout << a[n - 1] << " " << ans << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> pii;

bool done[110][110];
double dp[110][110];
int N,T,L,B;
bool isL[110],isB[110];
double rec(int i,int t){
	if(t<0)return 0;
	if(i==N){
		if(t==0)return 1;
		else return 0;
	}
	if(done[i][t])return dp[i][t];
	double ret = 0;
	if(isL[i]){
		FOR(j,1,7){
			int nxt = i+j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-2);
		}
	}
	else if(isB[i]){
		FOR(j,1,7){
			int nxt = j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-1);
		}
	}
	else{
		FOR(j,1,7){
			int nxt = i+j;
			if(nxt>N){
				nxt= N-(nxt-N);
			}
			ret+=(1.0/6)*rec(nxt,t-1);
		}
	}

	done[i][t]=true;
	return dp[i][t]=ret;
}

void init(){
	cin>>N>>T>>L>>B;
	if(N==0)exit(0);
	REP(i,101){
		isL[i]=false;
		isB[i]=false;
		REP(j,101){
			done[i][j]=false;
			dp[i][j]=0;
		}
	}
	REP(i,L){
		int x;cin>>x;
		isL[x]=true;
	}
	REP(i,B){
		int x;cin>>x;
		isB[x]=true;
	}
	REP(t,T+1){
		done[N][t]=true;
		dp[N][t]=0;
	}
	dp[N][0]=1;
	REP(i,N){
		done[i][0]=true;
		done[i][1]=true;
		dp[i][0]=0;
		if(i+6<N){
			dp[i][1]=0;
		}
		else if(isL[i]){
			dp[i][1]=0;
		}
		else if(isB[i]){
			if(N<=6)dp[i][1]=1.0/6;
		}
		else{
			dp[i][1]=1.0/6;
		}
	}
} 

void solve(){
	init();
	double ans = 0;
	REP(t,T+1){
		ans+=rec(0,t);
	}
	cout<<fixed << setprecision(10)<<ans<<endl;
	//printf("%.10lf\n",ans);
}

signed main() {
	while (true) {
		solve();
	}
}


Measured memory_bytes: 3400
#list(map(int, input().split()))
a,b=list(map(int, input().split()))
ls = {1:1,2:3,3:1,4:2,5:1,6:2,7:1,8:1,9:2,10:1,11:2,12:1}
print('Yes') if ls[a]==ls[b] else print('No')

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		long long a[100000];
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
		}
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==i)
			{
				int t=a[i];a[i]=a[i+1];a[i+1]=t;
				sum++;
			}
		}
		cout<<sum<<"\n";
	}
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine() + " ";
        char ans = 0;
        boolean b = true;
        for (char c = 'a'; c <= 'z'; c++) {
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == c) {
                    break;
                } else {
                    if (i == s.length() - 1) {
                        ans = c;
                        b = false;
                    }
                }
            }
            if (b == false)
                break;
        }

        if (b == false) {
            System.out.println(ans);
        } else {
            System.out.println("None");
        }
    }

}


Measured memory_bytes: 28100
//Author- Vaibhav singh
//will be expert soon 
// *#####################################################################################*
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=n;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define mp make_pair
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define re return 0;
// *#######################################################################################*
// *#########################################################################################*
    //      ll ans=0,b[5000005]={0},a[5000005],i,n,x=0;                
    

int main()
{
      
      fast
    ll n;cin>>n;
    ll a[n],i;
    
    f(i,n)
    {
        cin>>a[i];
    }
         
         sort(a,a+n);
         ll z=0;
         if(n%2==1)
         {
             f(i,n-1)
             {
                 if(i%2==0 && a[i+1]!=a[i]+2 || i%2==1 && a[i+1]!=a[i])
                 {
                     z=1;
                 }
             }
             if(a[0]!=0||z==1)
             {
                 o("0")
                 re
             }
             
         }
         
         else
         {
             z=0;
             f(i,n-1)
             {
                 if(i%2==1 && a[i+1]!=a[i]+2 || i%2==0 && a[i+1]!=a[i])
                 {
                     z=1;
                 }

             }
             
             if(a[0]!=1||z==1)
             {
                 o("0")
                 re
             }
             
             
         }
         
         
         
         ll sum=1;
         
         f(i,n/2)
         {
             sum*=2;
             sum=sum%mod;
         }
         
         
         
         
         o(sum%mod)
        
        
	re
}

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
class info {
public:
    ll a, b, c;
};

void testCase() {
    int n;
    cin >> n;
    vector <info> val;
    for (int i=0; i<n; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        info i1;
        i1.a = a;
        i1.b = b;
        i1.c = c;
        val.push_back(i1);
    }
    ll dp[n+2][3];
    dp[n][0] = dp[n][1] = dp[n][2] = 0;
    for (int i=n-1; i>=0; i--) {
        info i1;
        i1.a = val[i].a + dp[i+1][0];
        i1.b = val[i].b + dp[i+1][1];
        i1.c = val[i].c + dp[i+1][2];
        dp[i][0] = max (i1.b, i1.c);
        dp[i][1] = max (i1.a, i1.c);
        dp[i][2] = max (i1.a, i1.b);
    }
    cout << max (dp[0][0], max (dp[0][1], dp[0][2])) << endl;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 5744
package main

import (
	"fmt"
	"sort"
)

func main() {
	var ans int
	as := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scan(&as[i])
	}
	sort.Sort(sort.IntSlice(as))
	for i, _ := range as {
		if i == 0 {
			continue
		}
		ans += as[i] - as[i-1]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 147604
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long int n;
    cin>>n;
    if(n==1){
        cout<<"1"<<endl;
        return 0;
    }
    long int h;
    long int j;
    
    long int mina=2*10000000000;
    for(long int i=1;i*i<=n;i++){
        if(n%i==0){
            long int a=i;
            long int b=n/i;
            int al,bl;
            h=10;
            j=0;
            while(1){
                if(a/h!=0){
                    h*=10;
                    j++;
                }else{
                    al=j+1;
                    break;
                }
            }
            h=10;
            j=0;
            while(1){
                if(b/h!=0){
                    h*=10;
                    j++;
                }else{
                    bl=j+1;
                    break;
                }
            }
            if(mina>max(al,bl))mina=max(al,bl);
        }
    }
    cout<<mina<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[[] for i in range(n)]
for i in range(n):
    s[i]=list(input())
s1=list(set(s[0]))
s1.sort()
#print(s1)

stmin=[50]*len(s1)
for i in range(n):
    st=[0]*len(s1)
    for ii in range(len(s1)):
        for sij in s[i]:
            if s1[ii]==sij :
                st[ii]+=1
        stmin[ii]=min(stmin[ii],st[ii])

t=""
for i in range(len(s1)):
    for ii in range(stmin[i]):        
        t=t+s1[i]
print(t)

Measured memory_bytes: 3064