akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
const int INF = 1e9;
int main() {
	int n, m, t;
	cin >> n >> m >> t;
	vector<int>c(n);
	vector<vector<int>>a(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			int buf;
			cin >> buf;
			a[i].push_back(buf);
		}
	}
	int ans = INF;
	for (int i = 0; i <(1<<n); ++i) {
		vector<int>x(m);
		int cnt(0);
		int sum(0);
		
		rep(j, n) {
			
			if ((i >> j) & 1) {
				//cout << i << " " << j << endl;
				sum += c[j];
				rep(k, m)x[k] += a[j][k];
			}
		}
		rep(k, m) {
			if (x[k] >= t) {
				cnt++;
			}
		}
		if (cnt == m)ans = min(ans, sum);
	}
	if (ans == INF)cout << "-1";
	else cout << ans;
	return 0;
}

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

int n;
vector<vector<int>> tree;
vector<vector<int>> dp;

const int MOD = 1e9 + 7;

long long solve(int node, int parent, bool is_white) {
    if (dp[node][is_white] == 0) {
        long long res = 1;
        for (int child : tree[node]) {
            if (child != parent) {
                if (is_white) {
                    res *= (solve(child, node, true) + solve(child, node, false)) % MOD;
                } else {
                    res *= solve(child, node, true);
                }
                res = res % MOD;
            }
        }

        dp[node][is_white] = (res + MOD) % MOD;
    }

    return dp[node][is_white];
}

int main() {
    cin >> n;

    tree.resize(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        tree[x - 1].push_back(y - 1);
        tree[y - 1].push_back(x - 1);
    }

    dp.resize(n, vector<int>(2));
    cout << (solve(0, -1, true) + solve(0, -1, false)) % MOD;
}

Measured memory_bytes: 19584
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sun Oct 22 21:02:34 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int32_t main()
{
  string str;
  cin >> str;

  for(uint32_t i =0; i < str.size() -1;i++){
    if(str[i] == 'A' && str[i+1] == 'C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.Array.IO (IOUArray)
import qualified Data.Array.IO as I

main :: IO()
main = do
    n <- read <$> getLine
    h <- I.newListArray (1, n) =<< map read . words <$> getLine :: IO (IOUArray Int Int)
    print =<< length . filter id <$> mapM (hoge h) [1..n]
    where hoge ls n = do
              h <- I.readArray ls n
              null . filter (\(i, e) -> i <= n && e > h) <$> I.getAssocs ls


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;


int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> last_day(26, 0);
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i][j];
  rep(i,D) cin >> t[i], t[i]--;

  int score = 0;
  auto Scoring = [&](int d, int id) {
    score += s[d - 1][id];
    last_day[t[d - 1]] = d;
    for (int i = 0; i < 26; i++) score -= c[i] * (d - last_day[i]); 
  };
 
  for (int i = 0; i < D; i++) {
    Scoring(i + 1, t[i]);
    cout << score << endl;
  }
  return 0;
} 

Measured memory_bytes: 3676
#include<iostream>
#include<unordered_set>
#include<vector>

int main(){
   int n;
  std::vector<int> an;
  std::unordered_set<int> selected;
 std::cin >> n;
  for(int i=0;i<n;++i){
    int t;
	std::cin >> t;
    an.push_back(t);
  }
  int s = 0;
  int count = 0;
  while (true){
    if(selected.count(s) ){
      count = -1;
      break;
    }
    selected.insert(s);
  	s = an[s] - 1;
    count += 1;
    if (s == 1){
      break;
    }
  }
  std::cout << count << std::endl;
}

Measured memory_bytes: 4580
/*
    @uthor: Amit Kumar
    user --> CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define PI 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        ld a,b,h,m;
        cin>>a>>b>>h>>m;
        ld rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
        cout<<fixed<<setprecision(20)<<(ld)sqrtl((a*a)+(b*b) - (2*a*b*cosl(rad)));
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 4140
let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0], k = nl[1]
var a = [[Int]](repeating: [Int](), count: n)
for di in 1..<k+1 {
  _ = readLine()
  let nr = readLine()!.split(separator: " ").map { Int($0)! }
  for i in nr {
    a[i-1] = a[i-1] + [di]
  }
}
print(a.filter { $0.isEmpty }.count)

Measured memory_bytes: 8328
#include <iostream>
#include <string>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    int judge;
    for (int i = 0; i < s.size(); i++) {
        judge += s[i]-'0';
        judge = judge%9;       
    }
    if (judge % 9 == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn = 1e5+5;

ll n;
ll pre[maxn];
ll c[maxn<<1], s[maxn];

ll lowbit(ll x) {return x&(-x);}

ll query(ll x){
	ll res = 0;
	for(ll i = x; i ; i -= lowbit(i)){
		res += c[i];
	}
	return res;
}

void add(ll x){
	for(ll i = x; i <= 2*n; i += lowbit(i)){
		c[i] += 1;
	}
}

bool check(ll x){
	memset(c, 0, sizeof(c));
	s[0] = 0;
	for(ll i = 1; i <= n; i++) {
		s[i] = pre[i]>=x?1:-1;
		s[i] += s[i-1];
	}	
	ll sum = 0;
	for(ll i = 0; i <= n; i++){
		sum += query(s[i]+n);
		add(s[i]+n);
	}
	//printf("sum = %lld \n", sum);
	if (sum >= n*(n+1)/4) return true;
	return false;
}

int main () {
	cin >> n;
	
	ll l = 1, r = 1;
	for(ll i = 1; i <= n; i++) {
		scanf("%lld", &pre[i]);
		if (pre[i] > r) r = pre[i];	
	}
	
	
	ll ans;
	while(l <= r){
		//printf("l = %lld r = %lld \n", l, r);
		ll mid = (l+r)>>1;
		if (check(mid)) ans = mid, l = mid+1;
		else r = mid-1;
	}
	
	printf("%lld\n", ans);	
	
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,k;cin>>n>>k&&n|k;){
		vi xs(n);
		rep(i,n) cin>>xs[i];
		int res=0;
		rep(i,n) res+=2*min(xs[i],k-xs[i]);
		cout<<res<<endl;
	}
}


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

using namespace std;

const int INF = 1e9 + 5;
int main(){
    int n;
    scanf("%d",&n);
    int k;
    scanf("%d",&k);    
    vector<int> v(n);
    for(int& x: v) scanf("%d",&x);
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<=i+k;++j){
           if(j<n) dp[j] = min(dp[j],dp[i] + abs(v[i]-v[j]));
        }
    }
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
#define N 110
using namespace std;

char s[N],a[N],S[N];
int n,ans;

bool judge(char e,int l){
  for(int i=1;i<=l;i++) if(s[i]!=e) return 0;
  return 1;
}

int main(){
  scanf("%s",S+1);
  n=strlen(S+1);
  ans=n;
  for(char e='a';e<='z';e++){
    int l=n;
    for(int i=1;i<=n;i++) s[i]=S[i];
    while((!judge(e,l))&&(l>1)){
      for(int i=1;i<l;i++){
        if(s[i]==e||s[i+1]==e) a[i]=e;
        else a[i]=s[i];
      }
      for(int i=1;i<l;i++){
        s[i]=a[i];
      }
      for(int i=l;i<=n;i++) s[i]=0;
      l--;
    }
    ans=min(ans,n-l);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<ll,ll>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

/*-----------------------------------------------------------------*/


int main(){
  int w, a, b;
  cin >> w >> a >> b;
  if(a < b && a+w < b) cout << b - (a+w) << endl;
  else if(a > b && b+w < a) cout << a - (b+w) << endl;
  else cout << 0 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    ll n, ans, i, j;
    cin >> n;
    ans = n;
    i = sqrt(n);
    while(i>0){
        if(n%i==0){
            j = n/i;
            // cout<<j<<endl; 
            ans = min(ans, i + j - 2);
            break;
        }
        i--;
    }    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define N 100001
#define M 200001
int hd[N], nx[M], e[M], n;
ll f1[N], f2[N];
void dfs(int x, int fa) {
    f1[x] = f2[x] = 1;
    for (int i = hd[x]; i; i = nx[i])
        if (e[i] != fa) {
            dfs(e[i], x);
            f1[x] = f1[x] * (f1[e[i]] + f2[e[i]]) % mod;
            f2[x] = f2[x] * f1[e[i]] % mod;
        }
}
int main() {
    scanf("%d", &n);
    for (int i = 1, Num = 0, x, y; i < n; i++) {
        scanf("%d%d", &x, &y);
        nx[++Num] = hd[x], hd[x] = Num, e[Num] = y;
        nx[++Num] = hd[y], hd[y] = Num, e[Num] = x;
    }
    dfs(1, 0);
    printf("%lld\n", (f1[1] + f2[1]) % mod);
    return 0;
}

Measured memory_bytes: 7936
import sys
sys.setrecursionlimit(100000)

def DFS(i,a,b):
    if i not in done:
        done.append(i)
        for f in g[i]:
            if [i,f]==[a,b] or [i,f]==[b,a]:
                continue
            else:
                DFS(f,a,b)
    else:
        return

N,M=map(int,input().split())
g=[[] for _ in range(N)]
edge=[]
for _ in range(M):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    edge.append([a-1,b-1])

ans=0
for i in range(M):
    done=[]
    DFS(0,edge[i][0],edge[i][1])
    if len(done)<N:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[110];
int tot=0x7fffffff,ans;
int main(){
//	freopen(".in","r",stdin);
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len-2;i++){
		int ans=0;
		for(int j=i;j<=i+2;j++)
			ans=(ans<<1)+(ans<<3)+s[j]-'0';
		tot=min(tot,abs(ans-753));
	}
	printf("%d\n",tot);
	return 0;
}


Measured memory_bytes: 128
n = int(input())
raw = []
for _ in range(n):
  raw.append(input())
raw.sort()
raw2 = [[-1,raw[0]]]
for i in range(1,n):
  if raw[i] == raw[i-1]:
    raw2[-1][0] -= 1
  else:
    raw2.append([-1,raw[i]])
raw2.sort()
maxi = raw2[0][0]
for x in raw2:
  if x[0] == maxi:
    print(x[1])
  else:
    break

Measured memory_bytes: 39112
S = input()
max_l = 0
temp_l = 0

for s in S:
    if s == 'A' or s=='G' or s=='C' or s=='T':
        temp_l += 1
        max_l = max(max_l, temp_l)
    else:
        temp_l = 0

print(max_l)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
    int n;
    int money=1000;
    cin>>n;
    while(true){
        if (money>=n){
            break;
        }
        money+=1000;
    }
    cout<<money-n<<endl;
}

Measured memory_bytes: 3636
import random
d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(d)]

#print(d,c,s)
t=[int(input()) for _ in range(d)]

cnt=0
last=[0]*27

for i in range(d):
    cnt+=s[i][t[i]-1]
    last[t[i]-1]=i+1
    for j in range(26):
        cnt-=c[j]*(i+1-last[j])
    
    print(cnt)








Measured memory_bytes: 9756
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct edge{
  ll to,mai,ti;
};
struct kin{
  ll mai,ti;
};
struct g{
  ll now,mai,ti;
};
ll dp[55][5555];
vector<vector<edge>>E(555);
vector<kin>ki(555);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,s;cin>>n>>m>>s;
  for(int i=0;i<55;i++){
    for(int j=0;j<5555;j++)
      dp[i][j] = llINF;
  }
  s = min(s,5000LL);
  dp[0][s] = 0;
  for(int i=0;i<m;i++){
    ll u,v,a,b;cin>>u>>v>>a>>b;
    E[--u].pb({--v,a,b});
    E[v].pb({u,a,b});
  }
  for(int i=0;i<n;i++){
    cin>>ki[i].mai>>ki[i].ti;
    ki[i].mai = min(ki[i].mai,5000LL);
  }
  priority_queue<pair<ll,pair<ll,ll>>,vector<pair<ll,pair<ll,ll>>>,greater<>>que;
  que.push(mp(0,mp(s,0)));
  while(!que.empty()){
    ll now = que.top().S.S;
    ll mai = que.top().S.F;
    ll ti = que.top().F;
    que.pop();
    ll sum = mai + ki[now].mai;
    sum = min(sum,5000LL);
    if(dp[now][sum] > ti + ki[now].ti){
      dp[now][sum] = ti + ki[now].ti;
      que.push(mp(dp[now][sum],mp(sum,now)));
      //que.push({now,sum,dp[now][sum]});
    }
    for(auto e:E[now]){
      if(mai < e.mai)continue;
      if(dp[e.to][mai-e.mai] > ti + e.ti){
	dp[e.to][mai-e.mai] = ti+e.ti;
	que.push(mp(ti+e.ti,mp(mai-e.mai,e.to)));
	//que.push({e.to,mai-e.mai,ti+e.ti});
      }
    }
  }
 
  for(int i=1;i<n;i++){
    ll mi = llINF;
    for(int j=0;j<5555;j++)
      mi = min(mi,dp[i][j]);
    cout<<mi<<endl;
  }
  return 0;
}


Measured memory_bytes: 11836
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

int main()
{
    string n;
    cin >> n;
    if(n.substr(0,1)=="9" || n.substr(1,1)=="9"){
        cout << "Yes" << endl; 
    } else {
        cout << "No" << endl; 
    }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	cin >> N;
	
	set< string > s;
	
	for_(i,0,N) {
		string str;
		cin >> str;
		s.insert(str);
	}
	
	int M;
	cin >> M;
	
	bool openf = false;
	
	for_(i,0,M) {
		string str;
		cin >> str;
		
		if (s.count(str)) {
			cout << (openf ? "Closed by " : "Opened by ") << str << endl;
			openf = !openf;
		} else {
			cout << "Unknown " << str << endl;
		}
	}
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <algorithm>

struct edge {
	int x;
	int y;
	int cost;
	edge(int x, int y, int cost) { this->x = x; this->y = y; this->cost = cost; }
};

bool operator<(const edge& e, const edge& f) { return e.cost < f.cost; }
bool operator<=(const edge& e, const edge& f) { return e.cost <= f.cost; }
bool operator>(const edge& e, const edge& f) { return e.cost > f.cost; }
bool operator>=(const edge& e, const edge& f) { return e.cost >= f.cost; }
bool operator==(const edge& e, const edge& f) { return e.cost == f.cost; }
bool operator!=(const edge& e, const edge& f) { return e.cost != f.cost; }

int root(int* par, int x)
{
	if (par[x] == x) return x;
	else return root(par, par[x]);
}
	
bool isSame(int* par, int x, int y)
{
	return root(par, x) == root(par, y);
}

void unite(int* par, int x, int y)
{
	if (!isSame(par, x, y)) par[root(par, x)] = root(par, y);
}

int main()
{
	int n; std::cin >> n;
	
	int *par = new int[n];
	for (int i=0; i<n; i++) par[i] = i;
	
	std::vector<edge> edge_list;
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			int cost;
			std::cin >> cost;
			if (i < j && cost >= 0) edge_list.push_back( edge(i, j, cost) );
		}
	}
	
	std::sort(edge_list.begin(), edge_list.end());
	
	int totalcost = 0;
	int num_of_edges = 0;
	for (std::vector<edge>::iterator it = edge_list.begin(); it != edge_list.end(); ++it) {
		if (isSame(par, (*it).x, (*it).y)) continue;
		unite(par, (*it).x, (*it).y);
		totalcost += (*it).cost;
		num_of_edges++;
		// std::cout << (*it).x << "," << (*it).y << " " << (*it).cost << std::endl;
		if (num_of_edges == n-1) break;
	}
	
	std::cout << totalcost << std::endl;

	delete[] par;
	
	return 0;
}



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

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> safe(N + 1, true);
  for(int i = 0; i < M; i++){
    int a;
    cin >> a;
    safe.at(a) = false;
  }
  vector<int> dp(N + 1, 0);
  dp.at(0) = 1;
  if(safe.at(1)){
    dp.at(1) = 1;
  }
  for(int i = 2; i <= N; i++){
    if(safe.at(i - 2)){
      dp.at(i) += dp.at(i - 2);
    }
    if(safe.at(i - 1)){
      dp.at(i) += dp.at(i - 1);
    }
    dp.at(i) %= 1000000007;
  }
  cout << dp.at(N) << endl;
}

Measured memory_bytes: 640
N = int(input())
R = [int(input()) for _ in range(N)]

ans = -float("inf")
mini = R[0]
for i in range(1,N):
    ans = max(R[i]-mini,ans)
    mini = min(R[i],mini)
    #print(ans)
    #print(mini)
print(ans)


Measured memory_bytes: 13620
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i(a); i <= (b); ++i)

#define gc getchar()
struct Reader {
	template <class T> inline operator T() {
		T w; char c, p = 0;
		for(; !isdigit(c = gc); c == '-' && (p = 1));
		for(w = c & 15; isdigit(c = gc); w = w * 10 + (c & 15));
		return p ? -w : w;
	}
}rd;

template <class T> inline bool smin(T&x, const T&y) { return y < x ? x = y, 1 : 0; }
template <class T> inline bool smax(T&x, const T&y) { return x < y ? x = y, 1 : 0; }

typedef long long ll;

const int P(1e9 + 7);
inline void inc(int &x, int y) { if ((x += y) >= P) x -= P; if(x < 0) x += P; }
int n, k, f[100005], g[100005];

int main() {
	n = rd, k = rd;
	f[0] = 1;
	REP(i, 0, k) g[i] = 1;
	REP(i, 1, n) {
		int x = rd;
		REP(j, 1, x) inc(f[j], g[j - 1]);
		REP(j, x + 1, k) inc(f[j], g[j - 1] - g[j - x - 1]);
		REP(j, 1, k) inc(g[j] = g[j - 1], f[j]);
	}
	std::cout << f[k];
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,ax;
int main()
{
	cin>>a>>b>>x;
	if(a%x==0)
		ax=a/x;
	else
		ax=a/x+1;
	cout<<b/x-ax+1<<endl;
	return 0;
}

Measured memory_bytes: 256
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    i = a.bsearch_index {|y| x <= (y.frozen? ? y: y[0])}
    b = a[i-=1]  if (b=a[i]).frozen? ? x<b: x<b[0]
  end  if b && b=a
  return a.insert(i+1, x)  unless a[i+9]
  i > 9 ? a[i] = [a[i],x] : a.unshift(*a.shift(i+1),x)
end
def deq(a) r=a.shift; a.unshift *a.shift if !a[0].frozen?; r end
def poq(a) r=a.pop; a.push *a.pop if !a[-1].frozen?; r end
N,M,*A = $<.read.split.map{|x| x.to_i}
A.sort!
M.times { break if A[-1]==0; enq A, (poq A)/2 }
p A.flatten.inject(0,:+)

Measured memory_bytes: 87792
N, M = map(int, input().split())
Z = [list(map(int, input().split()))for _ in range(N)]
Z = sorted(Z, key=lambda Z: Z[0])
Z.append([0,0])
q = 0
c = 0
for i in range(len(Z)):
    if q < M:
        q += Z[i][1]
        c += Z[i][0]*Z[i][1]
    else:
        c -= (q- M)* Z[i-1][0]
        print(c)
        exit()

Measured memory_bytes: 29796
A,B = map(int,input().split())
def gcd(a,b):
	if b == 0:
		return a
	else:
		return gcd(b,a%b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

gcd = gcd(A,B)
p = set(prime_factorize(gcd))
print(len(p)+1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
char s[10000];
ll a[100000 + 10];
ll d[200 + 10];
bool dfs(int l, int r, ll sum){
	//cout << l << " " << r << " " << sum << endl;
	if(sum == 0) return true;
	if(l > r) return false;
	rep(i, l, r + 1){
		if(dfs(i + 1, r, sum ^ a[i])) return true;
	}
	return false;
}
void add(ll x)
{
    for(int i=62;i>=0;i--)
    {
        if(x&(1ll<<i))
        {
            if(d[i])x^=d[i];
            else
            {
                d[i]=x;
                break;
            }
        }
    }
}
bool check(ll x){
	for(int i=62;i>=0;i--)
    {
        if(x&(1ll<<i))
        {
            if(d[i])x^=d[i];
            else
            {
                return false;
            }
        }
    }
    return true;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int T;
	cin >> T;
	while(T --){
		int n;
		cin >> n;
		rep(i, 1, n + 1) cin >> a[i];
		cin >> (s + 1);
		//cout << (s+ 1) << endl;
		int flag = 0;
		rep(i, 1, n + 1){
			if(s[i] == '1'){
				/*int l = i + 1;
				while(s[l] == '1' && l <= n) l ++;
				int r = l;
				while(s[r] == '0' && r <= n) r ++;
				/*if(dfs(l, r, a[i])) continue;
				else {
					flag = 1;
					break;
				}*/
				memset(d, 0, sizeof(d));
				rep(j, i, n + 1) {
					if(s[j] == '0'){
						add(a[j]);
					}
				}
				if(!check(a[i])){
					flag = 1;
					break;
				}
			}
			else continue;
		}
		if(flag == 1){
			cout << "1" << endl;
		}
		else{
			cout << "0" << endl;
		}
	}
	return 0;
}
/*
1 6
8 3 4 5 6 7
111000
*/

Measured memory_bytes: 3596
#include<iostream>
#include<bitset>

using namespace std;

int func(long long n){
    int cnt=0;
    while(n>0){
        ++cnt;
        n/=10;
    }
    return cnt;
}

long long func2(int n){
    long long t=1;
    for(int i=0;i<n;++i){
        t*=10;
    }
    return t;
}

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

    int n=func(s);
    long long ans=0;
    for(int bit=0;bit<(1<<(n-1));++bit){
        long long temp=s;
        for(int i=n-2;i>=0;--i){
            if(bit&(1<<i)){
                long long d=func2(i+1);
                ans+=temp/d;
                temp%=d;
            }
        }
        ans+=temp;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

struct parser{
	vector<int> sz;
	vector<map<int, int>> var;
	vector<string> prog;

	parser(vector<string> &vs){
		prog = vs;
		sz.resize(256);
		var.resize(256);
	}

	int parse(){
		for (int i = 0; i < prog.size(); ++i){
			if (!program(prog[i])) return i + 1;
		}
		return 0;
	}

	int get_val(char c, int idx){
		if (sz[c] <= idx) return -1;
		if (!var[c].count(idx)) return -1;
		return var[c][idx];
	}

	int program(const string &s){
		if (s.find("=") == -1) return declaration(s);
		return assignment(s);
	}

	bool declaration(const string &s){
		int len = s.size();
		char ar = s[0];
		sz[ar] = number(s.substr(2, len - 3));
		return true;
	}

	bool assignment(const string &s){
		int eq = 0;
		while (s[eq] != '=') ++eq;

		char ar = s[0];
		int idx = expression(s.substr(2, eq - 3));
		if (idx < 0 || idx >= sz[ar]) return false;
		int asgn = expression(s.substr(eq + 1));
		if (asgn < 0) return false;
		var[ar][idx] = asgn;
		return true;
	}

	int expression(const string &s){
		if (!isalpha(s[0])) return number(s);
		int len = s.size();
		char ar = s[0];
		int idx = expression(s.substr(2, len - 3));
		if (idx < 0 || idx >= sz[ar]) return -1;
		if (!var[ar].count(idx)) return -1;
		return var[ar][idx];
	}

	int number(const string &s){
		return stoi(s);
	}

};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	while (1){
		vector<string> vs;
		string s;
		while (cin >> s, s != "."){
			vs.emplace_back(s);
		}
		if (vs.empty()) break;
		parser p(vs);
		cout << p.parse() << endl;
	}

}

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

int main(){
  int a,b;
  int c[200];

  while(cin >> a >> b){
    for(int i=0;i<200;i++)c[i] = 0;
    c[a]++;
    c[b]++;
    while(a || b){
      cin >> a >> b;
      c[a]++;
      c[b]++;
    }

    bool f = false;
    if( (c[1] & 1) && (c[2] & 1) )f = true;
    for(int i=3;i<200;i++){
      if(c[i] & 1)f = false;
    }
    if(f)cout << "OK" << endl;
    else cout << "NG" << endl;
  }
}
    

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

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

    vector<int> rest(M,0);
    vector<int> pair_(M,0);
    vector<int> stock(100001,0);
    for(int i=0; i<N; i++){
        int x;
        cin >> x;

        pair_[x%M]+=stock[x];
        stock[x]^=1;
        rest[x%M]++;
    }

    int ans=0;
    ans+=rest[0]/2;
    for(int i=1; i<M-i; i++){
        ans+=min(rest[i], rest[M-i]);
        if(rest[i]>rest[M-i]){
            ans+=min((rest[i]-rest[M-i])/2, pair_[i]);
        }else{
            ans+=min((rest[M-i]-rest[i])/2, pair_[M-i]);
        }
        //cout << i << ' ' << ans << endl;
    }
    if(M%2==0){
        ans+=rest[M/2]/2;
    }

    cout << ans << endl;
    //cout_vec(rest);
}

Measured memory_bytes: 1408
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    vector<int> v(4, 0);
    string s;
    rep(i, n) {
        cin >> s;
        if (s == "AC") v[0]++;
        if (s == "WA") v[1]++;
        if (s == "TLE") v[2]++;
        if (s == "RE") v[3]++;
    }


    cout << "AC x " << v[0] << endl;
    cout << "WA x " << v[1] << endl;
    cout << "TLE x " << v[2] << endl;
    cout << "RE x " << v[3] << endl;

    return 0;
}

Measured memory_bytes: 3628
//https://atcoder.jp/contests/dp/tasks/dp_t
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int N;
string s;
using V=vector<LL>;
LL sum[3123];
LL dp[3123];
LL nxt[3123];
constexpr int mod = 1e9+7;
int main(){
    cin>>N>>s;
    for(int i:range(N))dp[i]=1;
    for(int i:range(1,N)){
        char c=s[i-1];
        for(int j:range(3123))sum[j]=nxt[j]=0;
        for(int j:range(3122))sum[j+1]=(sum[j]+dp[j])%mod;

        for(int j:range(N-i)){
            if(c=='<'){
                nxt[j]+=(sum[j+1]-sum[0]+mod);
            }
            else{
                nxt[j]+=(sum[3100]-sum[j+1]+mod);
            }
        }
        //cout<<sum[3100]<<":";
        /*
        12
        13
        23
        14
        24
        34
        132 2
        142 3
        231 2
        241 3
        341 3
        342 
        */
        
        for(int j:range(3123)){
            dp[j]=nxt[j]%mod;
            //cout<<dp[j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.ArrayList;

public class Main
  {
    public static void main(String[] args)
    {
        String[] lines = getStdin();

        String[] inputs = lines[0].split(" ");
        int x = Integer.parseInt(inputs[0]);
        int y = Integer.parseInt(inputs[1]);

        System.out.println(x*y);
    }

    private static String[] getStdin() {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String> lines = new ArrayList<>();
        while (scanner.hasNext()) {
            lines.add(scanner.nextLine());
        }
        return lines.toArray(new String[lines.size()]);
    }

}


Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long l;
#define rep(i,n) for(ll i = 0; i<n ; ++i)
#define repj(j,i,n) for(ll j = i; j<n; ++j)
#define repd(j,i,n) for(ll j = i; j>=n ; --j)
#define vi vector<int>
#define vll vector<ll>
#define vp vector<pair<int,int>>
#define vpl vector<pair<ll,ll>>
#define si set<int>
#define sll set<ll>
#define mp make_pair
#define pb push_back
#define f first
#define sec second
#define len length()
#define mod 1000000007

ll modex(ll a, ll b){ll ans = 1; a%=mod; if(a == 0) return 0; while(b>0){ if(b&1) ans = (ans*a)%mod; b = b>>1; a = (a*a)%mod;} return ans;}
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b);}

void solve(){
    ll a,b,c, k;
    cin>>a>>b>>c>>k;
    if(a+b>=k){
        if(a>=k) cout<<k;
        else cout<<a;
    }
    else cout<<2*a+b-k;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif

    //int q; cin>>q; while(q--)
        solve();

    #ifndef ONLINE_JUDGE
     cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector <int> a(m);
    int s=0;
    for(int i=0;i<m;++i)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s>=n)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long long mod(long long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const long long SIZE=3000;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const long long MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(long long i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(long long i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  long long n,k;
  cin>>n>>k;
  invinit();
  long long res;
  for(long long i=1;i<=k;i++){
    if(n==k){
      if(i==1){
        cout<<1<<endl;
        continue;
      }else{
        cout<<0<<endl;
        continue;
      }
    }
    res = 0;
    
    res += mod(2*mod(comb(k-1,i-1)*comb(n-k-1,i-1)));
    res = mod(res);
    
    res += mod(comb(k-1,i-1)*comb(n-k-1,i-2));
    res = mod(res);
    
    res += mod(comb(k-1,i-1)*comb(n-k-1,i));
    res = mod(res);
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:1024000000")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	map<string, int> mp;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		mp[s]++;
	}
	int max_cnt = INT_MIN;
	for (auto p : mp)
		max_cnt = max(max_cnt, p.second);
	for (auto p : mp)
		if (p.second == max_cnt)
			cout << p.first << "\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll K;
  cin >> K;

  ll A, B;
  cin >> A >> B;

  for (ll i = 0; i < 1001; i++) {
    ll b = i * K;

    if (A <= b && b <= B) {
      cout << "OK" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

bool san(u_int n)
{
    if (n % 3 == 0)
        return true;
    
    while (n) {
        if (n % 10 == 3)
            return true;
        n /= 10;
    }

    return false;
}

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

    for (u_int i = 1; i <= n; i++)
        if (san(i))
            printf(" %d", i);
    puts("");
    
    return 0;
}

Measured memory_bytes: 1136
def read_i
  gets.chomp.split(' ').map(&:to_i)
end

def ng
  puts ':('
end

def ok
  puts 'Yay!'
end

a = []
5.times do |i|
  a << read_i[0]
end

k = read_i[0]

if (a[4] - a[0]) > k
  ng
elsif (a[4] - a[1]) > k
  ng
elsif (a[4] - a[2]) > k
  ng
elsif (a[4] - a[3]) > k
  ng
else
  ok
end


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(void) {

	ll N;
	int min = 0, max = 0;
	cin >> N;
	vector<ll> a(N), color(9);
	REP(i, N) cin >> a[i];
	REP(i, 9) color[i] = 0;

	FOR(i, 0, N) {
		if (1 <= a[i] && a[i] < 400) {
			color[0]++;
		} else if (400 <= a[i] && a[i] < 800) {
			color[1]++;
		} else if (800 <= a[i] && a[i] < 1200) {
			color[2]++;
		} else if (1200 <= a[i] && a[i] < 1600) {
			color[3]++;
		} else if (1600 <= a[i] && a[i] < 2000) {
			color[4]++;
		} else if (2000 <= a[i] && a[i] < 2400) {
			color[5]++;
		} else if (2400 <= a[i] && a[i] < 2800) {
			color[6]++;
		} else if (2800 <= a[i] && a[i] < 3200) {
			color[7]++;
		} else {
			color[8]++;
		}
	}

	FOR(i, 0, 8) {
		if (color[i] != 0) {
			min++;
			max++;
		}
	}

	max += color[8];

	if (min == 0) {
		min++;
	}

	cout << min << " " << max << endl;

	return 0;
}

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

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define emp What is it
#define SORRY FUL Accepted 
#define dimash the top one
#define I wish 
#define you be a little more calm
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 5e3 + 123;                                          
const int NN = 5e5 + 123;
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, m, k, a[NN], cnt, ans;
string s;

inline void Solve () {
	// easy
	ll q, h, s, d;
	cin >> q >> h >> s >> d;
	cin >> n;
	ll min_for_2_liter = min(d, min(s * 2, min(h * 4, q * 8)));
	ll min_for_1_liter = min(s, min(h * 2, q * 4));
	if(n % 2 == 0) {
		cout << (n / 2) * min_for_2_liter;
	} else {
		cout << (n / 2) * min_for_2_liter + min_for_1_liter;
	}
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);	
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}	
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char s[10];
	bool bad = false;
	scanf("%s", s);
	for (int i = 0; i < 3; i++)
		if (s[i] == s[i + 1])
			bad = true;
	if (bad)
		puts("Bad");
	else
		puts("Good");
	return 0;
}

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

int main()
{
  string A, B;
  cin >> A >> B;
  if (A.size() > B.size())
    cout << "GREATER" << endl;
  else if (A.size() < B.size())
    cout << "LESS" << endl;
  else
  {
    bool equal = true;
    for (int i = 0; i < A.size(); i++)
    {
      if (A[i] - '0' > B[i] - '0')
      {
        cout << "GREATER" << endl;
        equal = false;
        break;
      }
      else if (A[i] - '0' < B[i] - '0')
      {
        cout << "LESS" << endl;
        equal = false;
        break;
      }
    }
    if (equal)
      cout << "EQUAL" << endl;
  }
}


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

int main(void){

    int N; cin>>N;
    vector<int> V(N), C(N);

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

    int ans=0;
    for (int i = 0; i < N; ++i) {
        if(V[i]>C[i]) ans += V[i]-C[i];
    }

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

Measured memory_bytes: 256
W, H, c = input().split()
W = int(W)
H = int(H)
for i in range(H) :
    for j in range(W) :
        if (i == 0 and j == 0) or (i == 0 and j == W-1) or (i == H-1 and j == 0) or (i == H-1 and j == W-1) :
            print('+', end='')
        elif i == 0 or i == H-1 :
            print('-', end='')
        elif j == 0 or j == W-1 :
            print('|', end='')
        elif i == ((H-1)//2) and j == ((W-1)//2) :
            print(c, end='')
        else :
            print('.', end='')
    print()


Measured memory_bytes: 5632
#include<stdio.h>

int main (){
  long long a[1000],x,b,c,i,j,n;
  scanf("%lld",&n);
  while(n){
   i=1;
   while(i<=3){
    scanf("%lld",&a[i]);
    i++;
   }

   for(i=1;i<3;i++){
     for(j=1; j <= 3-i; j++){
       if(a[j]>a[j+1]){
        x= a[j];
        a[j] = a[j+1];
        a[j+1] = x;
       }

     }

   }
   if(a[1]*a[1]+a[2]*a[2]==a[3]*a[3]){
    printf("YES\n");
   }
   else{
    printf("NO\n");
   }

   n--;
}

return 0;
}

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

using namespace std;
int main(void)
{
	int x, y; cin >> x >> y;
	if (x == y)
	{
		cout << x + 1 << "\n";
		return 0;
	}
	int hx = x, hy = y;
	if (x < y)
	{
		int c = x;
		x = y;
		y = c;
	}
	int r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	cout << (hx / y + hy / y - 2)*y + y + 1 << "\n";
}



Measured memory_bytes: 3104
n,p = map(int,input().split())
s = input()
l = [0 for i in range(p)]
l[0] = 1
ten = 1
cnt = 0

ans = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i+1
else:
    for i in range(n):
        cnt = (cnt + int(s[-i-1]) * ten) % p
        l[cnt] += 1
        ten = (ten * 10) % p
    for i in l:
        if i > 1:
            ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 3500
import math
x=int(input())
max_b=math.floor(math.sqrt(x))
max_p=math.floor(math.log2(x))
ans=1
for b in range(max_b+1):
    for p in range(2,max_p+1):
        if b**p<=x:
            ans=max(ans,b**p)
        else:
            break
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		long[] x = new long[N];
		
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextLong();
		}
		
		long min = 100000000 * 3;
		
		for(int i = 0; i < N - K + 1; i++) {
			if(x[i + K - 1] >= 0 && x[i] <= 0) {
				if(x[i + K - 1] + x[i] > 0) {
					min = Math.min(x[i + K - 1] - x[i] - x[i], min);
				} else {
					min = Math.min(x[i + K - 1] - x[i] + x[i + K - 1], min);
				}
			} else if(x[i + K - 1] < 0) {
				min = Math.min(min, -x[i]);
			} else if(x[i] > 0) {
				min = Math.min(min, x[i + K - 1]);
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 52312
main = do 
  n <- read <$> getLine :: IO Int
  print $ solve n


solve :: Int -> Int
solve n =
  length $ filter (\x -> (length $ dividers x) == 8) [x | x <- [1..n], odd x]

dividers :: Int -> [Int]
dividers n =
  let sq = until (\x -> x * x > n) (+ 1) 0
  in
    do
      x <- [1..sq]
      y <- return $ n `div` x
      if n `mod` x == 0 then
        if x /= y then
          [x, y]
        else
          [x]
      else
        []
        


Measured memory_bytes: 508
H, W, K = map(int, input().split())

dp = [[0 for _ in range(W)] for _ in range(H + 1)]

dp[0][0] = 1

for i in range(1, H + 1):
    for j in range(W):
        for k in range(2 ** (W - 1)):
            if bin(k).count("11") >= 1:
                continue
            if j + 1 <= W - 1 and (k >> j) & 1:
                dp[i][j] += dp[i - 1][j + 1]
            elif j - 1 >= 0 and (k >> (j - 1)) & 1:
                dp[i][j] += dp[i - 1][j - 1]
            else:
                dp[i][j] += dp[i - 1][j]

print(dp[H][K - 1] % (10 ** 9 + 7))


Measured memory_bytes: 3064