akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
                                                                                                
  
int main(){
                                                                                                
   
    long long n, i, sx;

    long long max = 0;

    long long s = 1000000000;
   
      
    cin >> n;
   
    vector<long long> x(n);

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

         cin >> x.at(i);

         }
   

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


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

         if( fabs( x.at( n - 1 ) / 2.0 - x.at(i) ) < s ){

             s = fabs( x.at( n - 1 ) / 2.0 - x.at(i) );

             sx = x.at(i);

             }             

         }


    cout << x.at( n - 1 ) << " " << sx << endl;


    return 0;
                                                          
}

Measured memory_bytes: 1024
import collections
n = int(input())
v = list(map(int,input().split()))

if len(set(v))==1:
    print(n//2)
    exit()

cv1 = collections.Counter(v[::2])
cv2 = collections.Counter(v[1::2])
num1 = cv1.most_common()[0][0]
num2 = cv2.most_common()[0][0]
cnt1 = cv1.most_common()[0][1]
cnt2 = cv2.most_common()[0][1]
if num1==num2:
  cnt3 = cv1.most_common()[1][1]
  cnt4 = cv2.most_common()[1][1]
  a,b = cnt1+cnt4,cnt2+cnt3
  print(min(n-a,n-b))
  exit()
print(n-(cnt1+cnt2))

Measured memory_bytes: 20180
from collections import deque
import copy
N = int(input())
A = deque(sorted([int(input()) for i in range(N)]))
B = copy.copy(A)
ans = deque([A.popleft()])
while A:
    if A:
        ans.appendleft(A.pop())
    if A:
        ans.append(A.pop())
    if A:
        ans.appendleft(A.popleft())
    if A:
        ans.append(A.popleft())
res_1 = 0
ans = list(ans)
for i in range(N - 1):
    res_1 += abs(ans[i] - ans[i + 1])
ans = deque([B.pop()])
while B:
    if B:
        ans.appendleft(B.popleft())
    if B:
        ans.append(B.popleft())
    if B:
        ans.appendleft(B.pop())
    if B:
        ans.append(B.pop())
res_2 = 0
ans = list(ans)
for i in range(N - 1):
    res_2 += abs(ans[i] - ans[i + 1])
print(max(res_1, res_2))


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


public class Main {
	public static class BinNode {
		public BinNode left = null;
		public BinNode right = null;
	}
	
	public static BinNode intersect(BinNode n1, BinNode n2) {
		if(n1 == null || n2 == null)
			return null;
		BinNode new1 = new BinNode();
		new1.left = intersect(n1.left, n2.left);
		new1.right = intersect(n1.right, n2.right);
		return new1;
	}
	public static BinNode union(BinNode n1, BinNode n2) {
		if(n1 == null && n2 == null)
			return null;
		BinNode new1 = new BinNode();
		BinNode n1left = (n1 == null)? null: n1.left;
		BinNode n1right = (n1 == null)? null: n1.right;
		BinNode n2left = (n2 == null)? null: n2.left;
		BinNode n2right = (n2 == null)? null: n2.right;
		new1.left = union(n1left, n2left);
		new1.right = union(n1right, n2right);
		return new1;
	}
	
	public static String to_string(BinNode root) {
		if(root == null)
			return "";
		return "(" + to_string(root.left) + "," + to_string(root.right) + ")";
	}
	
	public static BinNode parse(char[] buf) {
		return parse(buf, 0, buf.length-1);
	}
	private static BinNode parse(char[] buf, int start, int end) {
		int idx = findNode(buf, start, end);
		//System.out.printf("start=%d end=%d, idx=%d\n", start, end, idx);
		if(idx < 0) return null;
		BinNode node = new BinNode();
		node.left = parse(buf, start+1, idx-1);
		node.right = parse(buf, idx+1, end-1);
		return node;
	}
	private static int findNode(char[] buf, int start, int end) {
		int level = 0;
		for(int i = start; i <= end; i++) {
			if(buf[i] == ',' && level == 1)
				return i;
			if(buf[i] == '(')
				level++;
			else if(buf[i] == ')')
				level--;
		}
		return -1;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String l = null;
		while((l = br.readLine()) != null) {
			String cols[] = l.split(" ");
			BinNode n1 = parse(cols[1].toCharArray());
			BinNode n2 = parse(cols[2].toCharArray());
			BinNode ans = null;
			if(cols[0].equals("i") ) {
				ans = intersect(n1, n2);
			}
			else if(cols[0].equals("u")){
				ans = union(n1, n2);
			}
			System.out.printf("%s\n", to_string(ans));
		}
		/**
		String l1 = "((,(,)),)";
		String l2 = "((,),(,))";
		BinNode node1 = parse(l1.toCharArray());
		BinNode node2 = parse(l2.toCharArray());
		BinNode output1 = intersect(node1, node2);
		BinNode output2 = union(node1, node2);
		
		System.out.printf("intersect= %s\n", to_string(output1));
		System.out.printf("union= %s\n", to_string(output2));
		*/
	}

}

Measured memory_bytes: 17860
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int k;
cin>>k;
int sum = 0;
for(int i= 1; i <= k ; i++){
 for(int j = 1 ; j <= k ;j++){
   for(int x = 1 ; x <= k ; x++){
       sum += __gcd(x , __gcd(i , j));
   }
 }
}
cout<<sum<<endl;
}



Measured memory_bytes: 3656
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let k: usize = sc.read();
    let r: usize = sc.read();
    println!("{}", if k >= 10 { r } else { r + 100 * (10 - k) });
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

llint s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	make_fact();
	
	cin >> s;
	
	llint ans = 0;
	for(int i = 1; i <= s; i++){
		if(s-3*i < 0) continue;
		ans += comb(s-3*i + i-1, i-1), ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

vector <int> graf[1000005];
int res[1000005];
int val[1000005];

void dfs(int v, int par, ll tren){
    tren += val[v];
    res[v] = tren;
    for(auto c : graf[v]){
        if(c == par) continue;
        dfs(c, v, tren);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n, q;
    cin >> n >> q;
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    while(q--){
        int a, b;
        cin >> a >> b;
        val[a] += b;
    }
    dfs(1, 0, 0);
    for(int i=1; i<=n; i++){
        cout << res[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 47872
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)
using ll = long long;
using ull = unsigned long long;
using llv = vector<long long>;


int main(void){
    ll n;
    cin >> n;
    vector<string> s (n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    
    vector<string> result (0);
    string current_str = "";
    
    ll count = 0;
    ll max_count = 0;
    for(int i = 0;i < n;i++){
        if (current_str == s[i]){
            count++;
        } else {
            if(count > max_count){
                result = vector<string> (0);
                result.push_back(current_str);
                max_count = count;
            } else if (count == max_count){
                result.push_back(current_str);
            } 
            current_str = s[i];
            count = 1;
        }
    }

    if(count > max_count){
        result = vector<string> (0);
        result.push_back(current_str);
        max_count = count;
    } else if (count == max_count){
        result.push_back(current_str);
    }

    for(auto &str : result){
        cout << str << endl;
    }
}

Measured memory_bytes: 13772
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, t;
  cin >> n >> t;
  V x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int et = 0;
  for (int i = 0; i < n-1; i++) x[i+1]-x[i] > t ? et+=t : et+=x[i+1]-x[i];
  dump(et+t);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
  int N;
  string s;
  cin >> N >> s;
  long long ans = 0;
  map<char,vector<int>> M;
  for(int i = 0; i < N; ++i){
    M[s[i]].push_back(i);
  }
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < i; ++j){
      if(s[i] == s[j]) continue;
      char c = 'R';
      if(s[i] != 'G' and s[j] != 'G') c = 'G';
      if(s[i] != 'B' and s[j] != 'B') c = 'B';
      int t = lower_bound(M[c].begin(), M[c].end(), i) - lower_bound(M[c].begin(), M[c].end(), j);
      if(i%2 == j%2 and s[(i+j)/2] == c) --t;
      ans += t;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <map>
#define STA 1000000
using namespace std;

int main(){
    int n;
    long long num,price,value;
    bool judge;
    while(1){
        cin >> n;
        if(n == 0) break;
        map <int,long long> data;
        map <long long,long long> data1;
        map <long long,long long>::iterator itr;
        data.clear();
        data1.clear();
        for(int i=1;i<=n;i++){
            cin >> num >> price >> value;
            itr = data1.find(num);
            if(itr != data1.end()) data1[num] += price * value;
            else {
                data.insert(map<int,long long>::value_type(i,num));
                data1.insert(map<long long,long long>::value_type(num,price*value));
            }
        }
        judge = false;
        for(int i=1;i<=n;i++){
            if(data1[data[i]] >= STA){
                cout << data[i] << endl;;
                judge = true;
            }
        }
        if(!judge) cout << "NA" << endl;
    }
}

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

#define CodeTyper main
#define Bye return 0
typedef long long ll;

using namespace std;

void solve(){
    int n; cin>>n;
    for (int i=1; i<=n; i++)
        cout<<"ACL";
}

int CodeTyper(){
    solve();
    Bye;
}

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

signed  main(){
	int n;
	cin>>n;
	int x,y;
	cin>>x>>y;
	for(int i=1;i<n;i++){
		int t1,t2;
		cin>>t1>>t2;
		int t=max(x/t1,y/t2);
		while(t*t1<x||t*t2<y) t++;
		x=t1*t;
		y=t2*t;
	}
	cout<<x+y;
    return 0;
}
/*

3
111 131
131 111
3 2

18 12 

30
*/

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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
    int n;
	cin >> n;
	int ans = 0;
	for(int i=0;i<n;i++){
	    int a;
	    cin >> a;
	    ans += a-1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    int ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    cout << ans << '\n';
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define LOG1(a)			  cerr<< #a << " = " << (a) << "\n"
#define LOG2(a, b)		  cerr<< #a << " = " << (a) << ", " << #b << " = " << (b) << "\n"
#define endl "\n"

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int n, arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    ll n, a;
    cin >> n >> a;
    n %= 500;
    if(n > a) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  vi a;
  string s;
  while(cin >> s){
    if(!isdigit(s[0])){
      int b,c;
      b = a.back();
      a.pop_back();
      c = a.back();
      a.pop_back();
      if(s[0]=='+') c += b;
      else if(s[0]=='-') c -= b;
      else if(s[0]=='*') c *= b;
      a.push_back(c);
    }else{
      int b = stoi(s);
      a.push_back(b);
    }
  }
  cout << a.back() << endl;
}




Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
int main(){
    int r,g,b,n,now,ans=0;
    cin >> r>>g>>b>>n;
    for(int i=0;i<=n/r;i++){
        for(int j=0;j<=n/g;j++){
            now=n-i*r-j*g;
            if(now%b==0&&now>=0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod1 998244353
#define mod2 1000000007

#ifdef LL
const ll INF = 1e18;
#else 
const ll INF = 1e9;
#endif

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point curTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T max3(T a, T b, T c) { return max((max(a,b), max(b,c))); }
template <typename T>
T min3(T a, T b, T c) { return min((min(a,b), min(b,c))); }
template <typename T>
T mid3(T a, T b, T c) { return a+b+c-max3(a,b,c)-min3(a,b,c); }
template <typename T>
T mid(T a, T b) { return min(a,b)+((max(a,b)-min(a,b))/2); }
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T set_bits(T a)
{ return __builtin_popcount(a); }
template <typename T>
T add_self(T& a, T b, T mod){ a+=b; if(a>=mod){ a-=mod; } }
template <typename T>
T to_upper(T s){ return transform(s.begin(), s.end(), s.begin(), ::toupper); }
template <typename T>
T to_lower(T s){ return transform(s.begin(), s.end(), s.begin(), ::tolower); }
vvi adj;
vi dp;
vi vis;

void dfs(int u)
{
    for(auto v : adj[u])
    {
        if(!vis[v])
        {
            vis[v]=1;
            dfs(v);
        }
        dp[u] = max(dp[u], dp[v]+1);
    }
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = curTime();

    int n,m;
    cin>>n>>m;
    adj.resize(n);
    dp.resize(n,0);
    vis.resize(n,0);

    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].pb(v);
    }

    for(int i=0;i<n;i++)
    {
        dfs(i);
    }

    ll mx=0;
    for(int i=0;i<n;i++) mx = max(mx, dp[i]);

    cout<<mx<<endl;
    auto stopTime = curTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  int L=t.size();
  string u="";
  for(int i=0; i<L; i++){
    u=t.at(i)+u;
  }
  if(s<u){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 0x7FFFFFFF
using namespace std;
int x[MAXN+5];
int main()
{
	int n,k;
	int ans=0;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	int pos=upper_bound(x+1,x+1+n,0)-x;
	pos--;
	if(pos==0)
	{
		ans=x[k];
		printf("%d\n",ans);
	}
	else if(pos==n)
	{
		ans=-x[n-k+1];
		printf("%d\n",ans);
	}
	else
	{
		int ansn;
		ans=INF;
		for(int lnum=0;lnum<=pos&&lnum<=k;lnum++)
			if(pos+k-lnum<=n)
			{
				if(lnum==0)
					ansn=x[pos+k-lnum]-0;
				else if(lnum==k)
					ansn=0-x[pos-lnum+1];
				else
					ansn=min(2*x[pos+k-lnum]-x[pos-lnum+1],x[pos+k-lnum]-2*x[pos-lnum+1]);
				ans=min(ans,ansn);
			}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc137c
int main(){
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0LL;
    for(auto tmp: mp){
        ans += (ll)(tmp.second*(tmp.second-1)/2LL);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
vector<ll> ko(12345678);
void divisor(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		ll a = 0;
		while (n % i == 0) {
			a++;
			n /= i;
		}
		if (a > 0) { ko.push_back(a); }
	}
	if (n != 1) { ko.push_back(1); }
	return;
}
signed main() {
	ll n, cnt = 0, ans = 0;
	cin >> n; divisor(n);
	for (ll h = 0; h < ko.size(); h++) {
		cnt = 1;
		while (ko[h] >= cnt) {
			ko[h] -= cnt; ans++; cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 196156
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<P>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 ll dp[100005]  ;
int main(){
 ll n;cin>> n ;
 vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
  dp[1]=0 ;
   dp[2]=abs(A[1]-A[0]) ;
   rep(i,n-2){
     dp[i+3]=min(dp[i+1]+abs(A[i]-A[i+2]),
     dp[i+2]+abs(A[i+1]-A[i+2])) ;
   }
   cout<<dp[n]<<endl ;
  return 0;
  }

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

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

ll gdb(ll a, ll b) {
  if (a < b) std::swap(a, b);
  if (a == 0 || b == 0) return -999999999;
  return gdb_exec(a, b);
}

ll lcm(ll a, ll b) {
  ll gdb_val = gdb(a, b);
  if (a % gdb_val == 0) {
    return (a / gdb_val) * b;
  }
  return (b / gdb_val) * a;
}

int main(int argc, char* argv[])
{
  ll a, b;
  std::cin >> a >> b;

  ll height = 0;

  for (int i = 1; i < b-a; i++) {
    height += i;
  }
  std::cout << height - a << std::endl;

  return 0;
}


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

typedef pair<int, int> P;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int counter(int left, int right, int k)
{
    int right_side;
    if (right <= 0)
    {
        right_side = 0;
    }
    else
    {
        right_side = (right - 1) / (k-1) + 1;
    }
    int left_side;
    if (left <= 0)
    {
        left_side = 0;
    }
    else
    {
        left_side = (left - 1) / (k-1) + 1;
    }

    return right_side + left_side;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int one_index;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] == 1)
        {
            one_index = i;
        }
    }

    int left, right;
    left = one_index - 0;
    right = (n - 1) - one_index;

    int ans = INF;
    int temp;

    for (int i = 0; i <= k-1; i++)
    {
        temp = counter(left-i, right-(k-1-i),k)+1;
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

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

int main(){
	cout<<fixed<<setprecision(7);
	
	while(true){
		int n, w, v, count[110] = {}, ma = 0, ma2 = 0;
		double ans = 0.01;
		
		cin>>n>>w;
		
		if(!n&&!w) break;
		
		for(int i = 1; i <= n; i++){
			cin>>v;
			
			count[v/w]++;
			
			ma = max(ma, count[v/w]);
			ma2= max(ma2, v/w);
		}
		
		for(int i = 0; i <= ma2; i++)
			ans += ((double)count[i]/ma)*(double)(ma2-i)/ma2;
		
		cout<<ans<<endl;
		
	}
}


Measured memory_bytes: 3116
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    VEC(int) A(3);
    READVEC(A);
    sort(ALL(A));
    cout << (A[2] == A[1] + A[0] ? "Yes" : "No") << endl;
    return 0;
};

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

using namespace std;

int gcd(int x,int y){
  return y?gcd(y,x%y):x;
}
int main(){
  int i,n,flag=0,A[105000],c=1000000000;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>A[i];
  }
  sort(A,A+n);
  for(i=1;i<n;i++){
    if(A[i]%A[0]==0) continue;
    flag=1;
    c=(c,gcd(A[i],A[0]));
  }
  if(flag) cout<<c<<endl;
  else cout<<A[0]<<endl;
  return 0;
}


Measured memory_bytes: 640
N,M = (int(i) for i in input().split())
table = [1 for _ in range(N)]
h = list(map(int, input().split()))
for _ in range(M):
  u,v = (int(i) for i in input().split())
  u-=1
  v-=1
  if h[u]==h[v]:
    table[u] = 0
    table[v] = 0
  else:
    if h[u]>h[v]:
      table[v] = 0
    if h[v]>h[u]:
      table[u] = 0

ans = sum(table)
print(ans)


Measured memory_bytes: 20912
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main() {
  string s; cin >> s;

  int ans = 0;
  for(const auto& c: s) {
    switch (c){
      case '+':
        ans++;
        break;
      case '-':
        ans--;
        break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(len(a)-1):
  if(a[i+1] == a[i] + 1):
    ans += c[a[i]-1]
print(ans)

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

struct UnionFind {
	int n;
	vector<int> U;
	UnionFind() {}
	
	UnionFind(int n_): n(n_), U(n, -1) {}
	
	int root(int x){
		if (U[x] < 0)
			return x;
		return U[x] = root(U[x]);
	}
	
	int link(int x, int y){
		x = root(x);
		y = root(y);
		if(x == y)
			return x;
		if(U[y] < U[x])
			swap(x, y);
		U[x] += U[y];
		n--;
		return U[y] = x;
	}
	
	bool same(int x, int y){
		return root(x) == root(y);
	}
	
	int size(){
		return n;
	}
	
	int count(int x){
		return -U[root(x)];
	}

};


int main() {
	int N, M, K,x;
	scanf("%d%d", &N, &M);
	UnionFind U(N + M);
	
	for(int i=0;i<N;i++){
		scanf("%d", &K);
		for(int j=0;j<K;j++){
			scanf("%d", &x);
			x--;
			U.link(i, x + N);
		}
	}

	bool ok = true;
	for(int i=0;i<N;i++){
		if(!U.same(0, i))
			ok = false;
	}

	puts(ok? "YES": "NO");
	return 0;
}

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

int main() {
    int n, x, y; cin >> n >> x >> y;
    int dist[n+1][n+1];
    for (int i = 1; i < n+1; i++){
        for (int j=1; j < n+1; j++){
            dist[i][j] = abs(j - i);
        }
    }
    int ans[n-1];
    for (int i = 1; i < n; i++){
        ans[i] = 0;
    }
    dist[x][y] = 1;
    dist[y][x] = 1;
    for (int i = 1; i < n+1; i++){
        for (int j=1; j < n+1; j++){
            dist[i][j] = min(
                dist[i][j],
                min(dist[i][x] + 1 + dist[y][j],
                dist[i][y] + 1 + dist[x][j])
                );
            if (dist[i][j] <= n-1){
                ans[dist[i][j]] ++;
            }
        }
    }
    for (int i = 1; i < n; i++){
        cout << ans[i]/2 << endl;
    }

}


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

ll p5 (ll n){
    return n*n*n*n*n;
}

int main(){
    int x;
    cin >> x;
    for(int i = 1;i*i<=x;i++){
        if(x%i==0){
            int k=i;
            for(ll b=-200;b<200;b++){
                if((p5(b+k)-p5(b))==x){
                    cout << b+k << " " << b << endl;
                    return 0;
                }
            }
        }
    }
}

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

int main() { 
  vector<vector<int>> bingo(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo.at(i).at(j);
    }
  }
  
  int n;
  cin >> n;
  
  vector<int> num(n);
  vector<vector<int>> card(3, vector<int>(3));
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
    for (int k = 0; k < 3; k++) {
     for (int j = 0; j < 3; j++) {
      if(num.at(i)==bingo.at(k).at(j))
        card.at(k).at(j)++;
     }
    }
  }
  if(card.at(0).at(0)!=0 && card.at(0).at(1)!=0 && card.at(0).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(1).at(0)!=0 && card.at(1).at(1)!=0 && card.at(1).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(2).at(0)!=0 && card.at(2).at(1)!=0 && card.at(2).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(0).at(0)!=0 && card.at(1).at(0)!=0 && card.at(2).at(0)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(0).at(1)!=0 && card.at(1).at(1)!=0 && card.at(2).at(1)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(0).at(2)!=0 && card.at(1).at(2)!=0 && card.at(2).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(0).at(0)!=0 && card.at(1).at(1)!=0 && card.at(2).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  if(card.at(2).at(0)!=0 && card.at(1).at(1)!=0 && card.at(0).at(2)!=0){
   cout << "Yes" << endl;
    return 0;
  }
  cout << "No" <<endl; 
}


Measured memory_bytes: 256
from math import sin,cos,radians

a,b,C=map(int,input().split())
radian = radians(C)
S = 0.5 * a* b * sin(radian)

L2 = a**2 + b**2 - 2*a*b*cos(radian)
L = L2**0.5
around = a + b + L

h = b*sin(radian)

print(S, around, h, sep="\n")


Measured memory_bytes: 5724
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int k,n;
    cin >> k >> n;
    vector <int> A(n,0);
    int max=0;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    for(int i=1;i<n;i++){
        int temp= A[i]-A[i-1];
        if(max<temp){
            max=temp;
        }
    }
    if(max<(k-A[n-1]+A[0])){
        max=(k-A[n-1]+A[0]);
    }
    int ans=k-max;
    cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
using namespace std;
typedef long long ll;
ll a,b,c;
signed main()
{

    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>a>>b)
    {
        cout<<max({a+b,a-b,a*b})<<"\n";
    }

    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>
using namespace std;

struct Node {
	long long next, id, dist;
};
long long v[100001], d[100001];
bool used[100001];
Node e[1000000];
int cur = 0;

bool dfs(int root) {
	for (int next = v[root]; next != 0; next = e[next].next) {
		if (used[e[next].id]) {
			if (d[root] + e[next].dist != d[e[next].id]) {
				return false;
			}
		} else {
			d[e[next].id] = d[root] + e[next].dist;
			used[e[next].id] = true;
			if (!dfs(e[next].id)) { return false; }
		}
	}
	return true;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	memset(v, sizeof(v), 0);
	memset(used, sizeof(used), false);
	for (int i = 0; i < m; i++) {
		int x, y, dist;
		scanf("%d%d%d", &x, &y, &dist);
		cur++;
		e[cur].id = y;
		e[cur].dist = dist;
		e[cur].next = v[x];
		v[x] = cur;
		cur++;
		e[cur].id = x;
		e[cur].dist = -dist;
		e[cur].next = v[y];
		v[y] = cur;
	}

	bool ans = true;
	for (int i = 1; i <= n; i++)
	if (!used[i]) {
		used[i] = true;
		d[i] = 0;
		ans = dfs(i);
		if (!ans) { break; }
	}
	printf("%s\n", ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 14848
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = s[0];
        int m = s[1];
        int[][] ab = new int[n][];
        for (int i = 0; i < n; i ++) {
            ab[i]  = Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        Array.Sort(ab, (a, b) => a[0] - b[0]);
        long sum = 0;
        for (int i = 0; i < n; i ++) {
            sum += (long)ab[i][0] * (long)ab[i][1];
            m -= ab[i][1];
            if (m<0) {
                while (m<0) {
                    sum -= ab[i][0];
                    m ++;
                }
            }
            if (m == 0) break;
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 21820
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)
        swap(a,b);
    if(a>c)
        swap(a,c);
    if(b>c)
        swap(b,c);
    cout<<c-a<<endl;
        return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc111/tasks/abc111_a
n = input()
print(1, end="") if n[0] == "9" else print(9, end="")
print(1, end="") if n[1] == "9" else print(9, end="")
print(1) if n[2] == "9" else print(9)


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
import java.util.stream.*;
import java.math.*;
 
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int res=0;
        
        for(int i=1;i<=n;i++){
            res+=i;
        }
        
        System.out.println(res);
    }
}




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

using namespace std;

long long mod = 1000000007;
int main(){
    int n;
    cin >> n;
    vector<long long>v(n);
    vector<long long>f(n);
    long long  sum = 0;
    for(int i = 0;i < n;i++){
        int item;
        cin >> item;
        v[i] = item;
        sum += item;
        sum %= mod;
        f[i] = sum;
    }
    long long ans = 0;
    for(int i = 0;i < n - 1;i++){
        long long add = f[n - 1] - f[i] + mod;
        ans += (v[i] * add)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}



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

int main() {
  int strLen;
  cin >> strLen;
  char a[strLen], b[strLen];
  cin >> a >> b;
  for (int i = 0; i < strLen; ++i)
  {
    cout << a[i] << b[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 384
h, w = gets.split.map(&:to_i)
s = Array.new(h + 1).map{Array.new(w + 1, 0)}
1.upto(h) do |i|
  c = 0
  l = 1
  b = gets
  1.upto(w) do |j|
    if b[j - 1] == '.'
      l = j if c == 0
      c += 1
    elsif c > 0
      l.upto(j - 1) do |k|
        s[i][k] = c
      end
      c = 0
    end
    if j == w && c > 0
      l.upto(j) do |k|
        s[i][k] = c
      end
    end
  end
end
ans = 0
1.upto(w) do |j|
  c = 0
  l = 1
  1.upto(h) do |i|
    if (s[i][j] > 0)
      l = i if c == 0
      c += 1
    elsif c > 0
      l.upto(i - 1) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
      c = 0
    end
    if i == h && c > 0
      l.upto(i) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
    end
  end
end
puts ans - 1

Measured memory_bytes: 47324
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    map<ll,ll> mp;
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    auto itr = mp.begin();
    while(itr != mp.end()){
        if(itr->second >= k){
            cout << itr->first << endl;
            break;
        }else{
            k -= itr->second;
            itr++;
        }
    }
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
     
    int main(void) {
      int A;
      int B;
      int C;
      int K;
      scanf("%d", &A);
      scanf("%d", &B);
      scanf("%d", &C);
      scanf("%d", &K);
      int s_max = 0;
      if (A >= K) {
        s_max = K;
      } else if (A + B >= K) {
        s_max = A;
      } else {
        s_max = A - (K - (A + B));
      }
      printf("%d\n", s_max);
      return 0;
    }

Measured memory_bytes: 1732
n=int(input())
li=[float(k) for k in input().split()]
dp=[[0 for i in range(len(li)+1)] for j in range(len(li)+1)] 
x=len(li)
dp[0][0]=1
for a in range(1,x+1):
  ph=li[a-1]
  pt=1-li[a-1]
  dp[a][0]=pt*dp[a-1][0]
  
  for b in range(1,a+1):
    dp[a][b]=dp[a-1][b-1]*ph+pt*dp[a-1][b]
ans=0
for i in range(x//2+1,x+1):
  ans=ans+dp[x][i]
print(ans)  
  

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

int main() {
//	int ti = clock();
	int n, x, y; cin >> n >> x >> y;
	vector<int> res(n, 0);
	for (int i = 1; i <= n; i++)
	{
		for (int j = i+1; j <= n; j++)
		{
			int m = min(j - i, abs(x - i) + 1 + abs(y - j));
			res[m]++;
		}
	}

	for (int i = 1; i < n; i++)
	{
		cout << res[i] << endl;
	}

//	cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
	return 0;
}


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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    string s = to_string(n);
    bool flag = false;
    for(int i=0; i<s.length(); i++){
        if(flag){
            s[i] = '9';
        }else if(i < s.length()-1 && s[i+1] != '9'){
            s[i]--;
            flag = true;
        }
    }
    ll m = stoll(s), sum = 0;
    while(m > 0){
        sum += m%10;
        m /= 10;
    }
    cout << sum << endl;
    return 0;
}

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

using ll = int64_t;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	int n; std::cin >> n;
	bool ok = false;
	rrep(i, 9) rrep(j, 9) {
		if (i * j == n)
			ok = true;
	}
	if (ok)
		std::cout << "Yes" << "\n";
	else
		std::cout << "No" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 300 + 10;

vector<int> penting;
int n, h[mx], di[mx];
long long dep[mx][mx][mx];

long long dp(int now, int tadi, int sisa){
    sisa = min(sisa, n - now);
    if(now == n) return 0;
    long long &ret = dep[now][tadi][sisa];
    if(ret != -1) return ret;
    ret = 1e18;
    // gak ngubah
    if(penting[tadi] <= h[now]){
        ret = min(ret, dp(now + 1, di[now], sisa) + h[now] - penting[tadi]);
    }
    else{
        ret = min(ret, dp(now + 1, di[now], sisa));
    }
    //ngubah
    if(sisa > 0) ret = min(ret, dp(now + 1, tadi, sisa - 1));
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < n; i++) penting.pb(h[i]);
    penting.pb(0);
    sort(ALL(penting));
    for(int i = 0; i < n; i++){
        di[i] = lower_bound(ALL(penting), h[i]) - penting.begin();
        // debug(di[i]);
    }
    reset(dep, -1);
    cout << dp(0, 0, k) << endl;
}

Measured memory_bytes: 233088
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int INF = 99;
typedef pair<int, int> P;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

#define N_MAX 100
#define M_MAX 100

int N, M;
string maze[N_MAX];
int sx, sy, gx, gy;

int d[N_MAX][M_MAX];

bool isOK(int x, int y, int N, int M){
    return ( 0<=x and x<N  and  0<=y and y<M );
}

int bfs(){
    
    queue<P> que;
    for(int i=0; i<N; i++)
        for(int j=0; j<M; j++)
            d[i][j]=INF;
            
    que.push(P(sx,sy));
    d[sx][sy]=0;
    
    while(que.size()){
        P p = que.front(); que.pop();
        // if(p.first==gx and p.second==gy) break;
        
        for(int i=0; i<4; i++){
            int nx=p.first+dx[i], ny=p.second+dy[i];
            if(isOK(nx,ny,N,M) and maze[nx][ny]!='#' and d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    
    if(sx==0 && sy==0){
        // for(int i=0;i<N;++i) cout << maze[i] << endl;
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                // cout << d[i][j] << ' ';
            }
            // cout << endl;
        }
    }
        
    int ret = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            if( d[i][j] != INF && ret <= d[i][j] ){
                ret = d[i][j];
                // cout << sx << sy << i << j << ret << endl;
            }
        }
    }
    
    return ret;
}

int main(){
    
    cin>>N>>M;
    for(string &s:maze) cin >> s;
    // for(int i=0;i<N;++i) cout << maze[i] << endl; // 地図の出力
    
    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            sx=i, sy=j;
            // cout << i << j << endl;
            if(maze[i][j] == '#') continue;
            int tmp = bfs();
            // if(i==0 && j==0) cout << tmp << endl; 
            if( ans < tmp ){
                ans = tmp;
                // cout << i << j << ans << endl;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
using namespace std;

int get() {
    int x = 0; char s = getchar();
    while (s < '0' || s > '9') s = getchar();
    while (s >= '0' && s <= '9') x = (x << 3) + (x << 1) + (s ^ 48), s = getchar();
    return x;
}

const int M = 2e5 + 5;
int n;
long long ans;
map<int, int> mp;

int main() {
    n = get();
    for (int i = 1, a; i <= n; ++i) {
        a = get();
        ans += mp[i - a];
        ++mp[i + a];
    }
    printf("%lld", ans);
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> y(n);
	rep(i, n) cin >> y.at(i);
	int a = 0;
	rep(i, n) {
		rep(j, n) {
			if (i != j) a += y.at(i) * y.at(j);
		}
	}
	cout << a / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,x=0;
	char a[8][6];
	for(i=0;i<8;++i)
		a[i][5]='\0';
	char t[] = "* ";
	while(scanf("%d",&n)>0)
	{
		for(i=4;i>=0;--i)
		{
			a[0][i] = t[n%10>=5];
			a[1][i] = t[a[0][i]=='*'];
			a[2][i] = '=';
			a[3][i] = t[n%5==0];
			a[4][i] = t[n%5==1];
			a[5][i] = t[n%5==2];
			a[6][i] = t[n%5==3];
			a[7][i] = t[n%5==4];
			n /= 10;
		}
		printf("%s",(x++?"\n":""));
		for(i=0;i<8;++i)
			printf("%s\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

//I imitated Ant-Book version 1.0 P.120

int func(int a,int b,int& ans_x,int& ans_y){
	if(b == 0){
		ans_x = 1;
		ans_y = 0;
		return a;
	}else{
		int ret = func(b,(a%b),ans_y,ans_x);
		ans_y -= (a/b)*ans_x;
		return ret;
	}
}

int main(){

	int A,B,ans_x,ans_y;

	scanf("%d %d",&A,&B);

	func(A,B,ans_x,ans_y);

	printf("%d %d\n",ans_x,ans_y);

	return 0;
}

Measured memory_bytes: 2756