akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
		//freopen("out.txt","w",stdout);
	#endif
	int k;
	cin >> k ;
	ll sum = 0;
	for(int i = 1;i <= k;i++){
		for(int j = 1;j <= k;j++){
			for(int z = 1;z <= k;z++){
				sum += gcd(i,gcd(j,z));
			}
		}
	}	
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>

int main()
{
int n, a[100000], i, j;
long s;
scanf("%d%d", &n, &a[0]);
s=a[0];
for(i=1; i<n; i++){
    scanf("%d", &a[i]);
    s=s+a[i];
    if(a[i]<a[0]){
        a[0]=a[i];
    }
}
for(j=0; j<n; j++){
    if(a[j]>a[n-1]){
        a[n-1]=a[j];
    }
}
printf("%d %d %ld\n", a[0], a[n-1], s);
return 0; 
}

Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;
typedef long l;
long a,b,c;
int main()
{
    l n,t,x,y,k;
    a = b = c = 0;
    cin>>n;
    while(n--)
    {
        cin>>t>>x>>y;
        k = abs(a - x) + abs(b - y);

        if(c + k > t ) { cout<<"No"<<'\n'; return 0;}
        if(k%2 != (t - c) % 2){ cout<<"No"<<'\n'; return 0;}

        a = x;
        b = y;
        c = t;

    }
    cout << "Yes"<<'\n';
    return 0;
}


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

int main () {
  
  int N;
  cin >> N;
  
  int a = 2;
  
  while (N > 0) {
    
    int p = 2;
    int flag = 0;
    
    while (p * p <= a) {
      
      if (a % p == 0) {
        flag = 1;
        break;
      }
      
      p++;
    
    }
    
    if (flag == 0) {
      cout << a << " ";
      N--;
    }
    
      a += 5;
    
  }
  
}

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

using namespace std;

int n,m;
int a[705][705];
int color[705]={}, isbip=1;
int part[2];
bool dp[705][705]={};
vector <pair <int,int>> pos;

void dfs(int u, int c){
    color[u]=c;
    part[c-1]++;
    for(int i=0;i<n;i++){
        if(!a[u][i]){
            continue;
        }
        if(!color[i]){
            dfs(i,3-c);
        }
        else{
            if(color[i]!=3-c){
                isbip=0;
                return;
            }
        }
    }
    return;
}

int main(){
    for(int i=0;i<705;i++){
        for(int j=0;j<705;j++){
            a[i][j]=1;
        }
        a[i][i]=0;
    }
    cin >> n >> m;
    while(m--){
        int u,v;
        cin >> u >> v;
        u--,v--;
        a[u][v]=0;
        a[v][u]=0;
    }
    for(int i=0;i<n;i++){
        if(!color[i]){
            part[0]=part[1]=0;
            dfs(i,1);
            if(!isbip){
                cout << -1 << endl;
                return 0;
            }
            pos.emplace_back(part[0],part[1]);
        }
    }
    int p=pos.size();
    dp[0][pos[0].first]=1;
    dp[0][pos[0].second]=1;
    for(int i=1;i<p;i++){
        for(int j=0;j<=n;j++){
            if(j>=pos[i].first){
                dp[i][j]|=dp[i-1][j-pos[i].first];
            }
            if(j>=pos[i].second){
                dp[i][j]|=dp[i-1][j-pos[i].second];
            }
        }
    }
    int req=n/2;
    int ans=INT_MAX;
    for(int i=req;i>=0;i++){
        if(dp[p-1][i]){
            ans=(i*(i-1))/2+(((n-i)*(n-i-1))/2);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2688
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] str=Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int M=int.Parse(str[1]);
      
    
        Console.WriteLine(((N*(N-1))/2)+((M*(M-1))/2));

    }
  }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<int> x(n);

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

	int cd = std::ceil((double)sum / (double)n);
	int cd2 = std::floor((double)sum / (double)n);

	int cost1 = 0, cost2 = 0;
	for(int i = 0; i < n; i++) {
		cost1 += (int)std::abs(x[i] - cd) * std::abs(x[i] - cd);
		cost2 += (int)std::abs(x[i] - cd2) * std::abs(x[i] - cd2);
	}

	cout << std::min(cost1, cost2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char *argv[])
{
	int n;
	scanf("%d",&n);
	int a=n/10;
	int b=n%10;
	int f=0;
	if(a==9)
	f=1;
	if(b==9)
	f=1;
	if(f==1)
	printf("Yes");
	else 
	printf("No"); 
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+5;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,r,p,q,s=0;
    cin>>n>>l>>r;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        p=(a[i]-a[i-1])*l;
        s+=min(p,r);
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 1024
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N, Q = geta(int)
    g = [set() for _ in range(N + 1)]
    v = [-1 for _ in range(N + 1)]

    for _ in range(N - 1):
        a, b = geta(int)
        g[a].add(b)
        g[b].add(a)

    d = [0] * (N + 1)
    for _ in range(Q):
        p, x = geta(int)
        d[p] += x

    def dfs(i, c):
        c2 = c + d[i]
        v[i] = c2
        for j in g[i]:
            if v[j] < 0:
                dfs(j, c2)

    dfs(1, 0)

    print(*v[1:], sep=" ")


if __name__ == "__main__":
    main()

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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

int main()
{
    const int   A(cin2var<int>());
    const int   B(cin2var<int>());
    vector<int> datas;
    datas.push_back(A + B);
    datas.push_back(A - B);
    datas.push_back(A * B);
    const auto ite(max_element(datas.cbegin(), datas.cend()));
    const int  max = *ite;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

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

	if (s.size() == 2) {
		cout << s << endl;
	}
	else {
		cout << s[2] << s[1] << s[0] << endl;
	}

}

Measured memory_bytes: 256
N = int(input())
l2 = input().split()
l1 = list(range(1,N+1))
l2 = [int(s) for s in l2]

count = 0
for i in range(N):
  if l1[i]%2==1 and l2[i]%2==1:
    count += 1
    
print(count)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans
long double A, B, H, M;

void solve() {
    long double h, m;
    h = 2 * M_PI * (H + M / 60) / 12;
    m = 2 * M_PI * M / 60;
    long double ans = sqrt(A * A + B * B - 2 * A * B * cos(h - m));
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> A >> B >> H >> M;


    solve();
    return 0;
}


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

int main(){
    string S;
    string T;
    cin>>S;
    cin>>T;
    int distance=0;
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]){
            distance++;
        }
    }
    cout<<distance<<endl;
}

Measured memory_bytes: 3852
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
constexpr auto oorret = 0;
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	string s;
	cin >> s;
	int pre = ((s[0] - '0') * 10) + (s[1] - '0');
	int ato = ((s[2] - '0') * 10) + (s[3] - '0');
	bool flag1;
	if (1 <= pre && pre <= 12)flag1 = true;
	else flag1 = false;
	bool flag2;
	if (1 <= ato && ato<= 12)flag2 = true;
	else flag2 = false;
	if (flag1) {
		if (flag2) {
			put("AMBIGUOUS");
		}
		else {
			put("MMYY");
		}
	}
	else {
		if (flag2) {
			put("YYMM");
		}
		else {
			put("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int N = 1005;
const ll INF = 1e9;
using namespace std;
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
     int n;
     cin>>n;
     int arr[n];
     forn cin>>arr[i];
     forn
     {
               if(arr[i]%2==0) 
               {
                         if(arr[i]%3==0 || arr[i]%5==0) continue;
                         else cout<<"DENIED";
                         return 0;
               }
     }
     cout<<"APPROVED";
     
      
        
        
        
        
        
        return 0;
        
        
        
        
        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int MOD  =1e9+7;
char a [MAXN][MAXN];
int dp[MAXN][MAXN],vis[MAXN][MAXN];
int h,w;
int solve(int x,int y)
{
	if(x>=h || y>=w)
		return 0;
	if(a[x][y] == '#') return 0;

	if(vis[x][y]) return dp[x][y];
	if(x == h - 1 && y == w - 1) return dp[x][y] = 1;

	vis[x][y] = 1;
	return dp[x][y] = (solve(x+1,y) + solve(x,y+1)) % MOD;

}
int main()
{
	
	cin>>h>>w;
      for(int i = 0;i<h;i++)
      {
      	cin>>a[i];
      }
      cout<<solve(0,0);
      return 0;
  }

Measured memory_bytes: 9344
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, N; cin >> W >> H >> N;
	vector<int> x(N), y(N); rep(i, 0, N) { cin >> x[i] >> y[i]; }
	int ans = 0;
	rep(i, 0, N - 1) {
		int dx = x[i + 1] - x[i], dy = y[i + 1] - y[i];
		if (dx*dy > 0) {
			dx = abs(dx), dy = abs(dy);
			ans += min(dx, dy) + abs(dx - dy);
		}
		else {
			ans += abs(dx) + abs(dy);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  if (a+b+c>21) printf("bust\n");
  else printf("win\n");
  return 0;
}


Measured memory_bytes: 128
use proconio::input;

fn main() {
	input!(n: usize);
	input!(a: [u128; n]);

	let mut result = 1;
	for i in 0..n {
		if a[i] == 0 {
			println!("0");
			return;
		}
	}
	for i in 0..n {
		result *= a[i];
		if result > 1000000000000000000 {
			println!("-1");
			return;
		}
	}
	println!("{}", result);
}


Measured memory_bytes: 5312
N = int(input())
L = [tuple( map(int, input().split() ) ) for i in range(N) ]
#print(L)

A = [L[i][0] for i in range(N)]
A.sort()
B = [L[i][1] for i in range(N)]
B.sort()

if N % 2 == 1:
  m = A[(N-1)//2]
else: 
  m_2 = A[N//2 - 1] + A[N//2]
  
if N % 2 == 1:
  M = B[(N-1)//2]
else: 
  M_2 = B[N//2 - 1] + B[N//2]
  
  
# Conjecture
if N % 2 == 1:
  print(M-m+1)
else:
  print(M_2 - m_2 + 1)

Measured memory_bytes: 39696
n,m = map(int,input().split())
ac = [0]*n
wa = [0]*n
pena = 0

for i in range(m):
    p,s = map(str,input().split())
    p = int(p)-1 
    if s == "WA" and ac[p] == 0:
        wa[p] += 1
    elif s == "AC" and ac[p] == 0:
        ac[p] = 1
        pena += wa[p]   #waのみの問題はペナルティカウントされないため、acして初めてwaの回数を加算する
    elif ac[p] == 1:
        continue

print(str(sum(ac)) + " " + str(pena))

Measured memory_bytes: 4596
#include<stdio.h>

int main()
{
    int s,h,m,sec;
    scanf("%d",&s);
    h = s/3600;
    m = (s%3600)/60;
    sec = (s%3600)%60;
    printf("%d:%d:%d\n",h,m,sec);
    return 0;
}

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll m1,d1,m2,d2; cin >> m1 >> d1 >> m2 >> d2;
    if(d1 + 1 == d2)out(0);
    else out(1);
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	long long int k;
	long long int a[5000];
	scanf("%d %lld", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
	}
	sort(a, a+n);
	int i1=0, i2=n;
	while(i1!=i2){
		int imid=(i1+i2)/2;
		int s[5001]={};
		s[0]=1;
		for(int i=0; i<n; i++){
			if(i==imid) continue;
			for(int j=k-1;j>=0; j--){
				if(s[j]!=0 && j+a[i]<k) s[j+a[i]]++;
			}
		}
		int e=0;
		int j0=k-a[imid];
		if(k-a[imid]<=0) j0=0;
		for(int j=j0; j<k; j++){
			if(s[j]>0){
				e=1;
				break;
			}
		}
		if(e==1){
			i2=imid;
		}else{
			i1=imid+1;
		}
	}
	printf("%d\n", i1);
	return 0;
}

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

int main()
{
	int a,b,k,i=0,count=0;
	cin >> a >> b >> k;
	while(1)
	{
		if(count==k)
			break;
		if(i==0)
		{
			if(a/2==1)
				a--;
			b+=(a/2);
			a/=2;
			i++;
		}
		else
		{
			if(b/2==1)
				b--;
			a+=(b/2);
			b/=2;
			i--;
		}
		count++;
	}
	cout << a << " " << b;
	return 0;
}


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

using namespace std;

const int INF = numeric_limits<int>::max();
const int MAXN = 5000+ 5;
const int MOD = 1e9 + 7;
const double res = 1e-9;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int dp[MAXN][MAXN][2];

signed main() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    multiset <double> q;
    while(n--) {
        int x;
        cin >> x;
        q.insert(x);
    }
    while(q.size() > 1) {
        double f = *q.begin();
        q.erase(q.begin());
        double s = *q.begin();
        q.erase(q.begin());
        q.insert((f + s) / 2);
    }
    cout << *q.begin();
    return 0;
}

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

int main() {
	int b,f,r,v;
	int a[1+12][1+10+1] = {0}; //1indexed
	int n;
	
    cin >> n;
	for ( int i = 0; i < n; i++ ) {
	    cin >> b >> f >> r >> v;
	    a[3*b-2 + (f-1) ][r] += v;
	}
	for ( int k = 1; k <= 4; k++ ) {
	   if ( k > 1 ) cout << "####################" << endl;
	   for ( int i = 1; i <= 3; i++ ) {
	       for ( int j = 1; j <= 10; j++ ) {
	           cout << " " << a[3*k-2 + (i-1) ][j];
	       }
	       cout << endl;
	   }
	}
	return 0;
}


Measured memory_bytes: 3136
#include<stdio.h>
int dp[11][2001];
int main(void)
{
	int i,j,k,l,n,m,hon[11][2001],c,g,sum,temp,max,flg,jan;
	scanf("%d %d",&n,&m);
	for(i=0;i<=10;i++){
		for(j=0;j<=n;j++){
			hon[i][j]=0;
			dp[i][j]=-1;
		}
	}
	jan=0;
	for(i=1;i<=n;i++){
		scanf("%d %d",&c,&g);
		hon[g][i]=c;
		if(jan<g) jan=g;
	}
/*	for(i=0;i<=jan;i++){
		for(j=0;j<=m;j++) printf("%d ",hon[i][j]);
		printf("\n");
	}*/
	for(i=1;i<=jan;i++){
		for(j=1;j<n;j++){
			for(k=j+1;k<=n;k++){
				if(hon[i][j]<hon[i][k]){
					temp=hon[i][j];
					hon[i][j]=hon[i][k];
					hon[i][k]=temp;
				}
			}
		}
	}
	dp[0][0]=0;
	for(i=0;i<jan;i++){
		for(j=0;j<=m;j++){
			if(dp[i][j]!=-1){
				for(k=0;k<=m;k++){
					if(j+k<=m){
						sum=0;
						flg=1;
						if(k<2){
							for(l=1;l<=k;l++){
								if(hon[i+1][l]==0){
									flg=0;
									break;
								}
								sum+=hon[i+1][l];
							}
							if(dp[i+1][j+k]<dp[i][j]+sum&&flg!=0){
								if(dp[i+1][j+k]==-1)dp[i+1][j+k]=0;
								dp[i+1][j+k]=dp[i][j]+sum;
							}
						}
						else {
							for(l=1;l<=k;l++){
								if(hon[i+1][l]==0){ 
									flg=0;
									break;
								}
								sum+=hon[i+1][l]+(k-1);
							}
							if(dp[i+1][j+k]<dp[i][j]+sum&&flg!=0){
								if(dp[i+1][j+k]==-1)dp[i+1][j+k]=0;
								dp[i+1][j+k]=dp[i][j]+sum;
							}
						}
					}
				}
			}
		}
	}
/*	for(i=0;i<=jan;i++){
		for(j=0;j<=m;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	max=-1;
	for(i=0;i<=m;i++){
		if(max<dp[jan][i]) max=dp[jan][i];
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 2916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

const ll C = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<ll> M(N+1);

    for(int i=2; i<=N; i++) {
        ll num = i;
        for(int j=2; j/2<=i; j++) {
            while(num % j == 0) {
                M[j]++;
                num /= j;
            }
            if(num <= 1) {
                break;
            }
        }
    }

    ll ans = 1;
    for(int i=0; i<N+1; i++) {
        ans *= M[i]+1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

using namespace std;

int f(Int mid, Int x, vector<Int>& v) {
	if (x * v.back() <= mid) { return v.size(); }
	int ok = v.size(), ng = -1;
	while (ok - ng > 1) {
		int m = (ok + ng) / 2;
		(x * v[m] > mid ? ok : ng) = m;
	}
	return ok;
}

bool check(Int mid, Int K, vector<Int>& a, vector<Int>& ra) {
	Int cnt = 0;
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] < 0) {
			cnt += f(mid, -a[i], ra);
		} else {
			cnt += f(mid, a[i], a);
		}
		cnt -= (a[i] * a[i] <= mid);
	}
	return cnt / 2 >= K;
}

int main() {
	Int N, K;
	cin >> N >> K;
	vector<Int> a(N), ra(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		ra[i] = -a[i];
	}

	sort(a.begin(), a.end());
	sort(ra.begin(), ra.end());

	Int ok = 1e18, ng = -1e18 - 1;
	while (ok - ng > 1) {
		Int mid = (ok + ng) / 2;

		(check(mid, K, a, ra) ? ok : ng) = mid;
	}
	cout << ok << endl;

	return 0;
}


Measured memory_bytes: 3456
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

class UnionFind{
public:
    int n;
    vector<int> v;

    UnionFind():n{0}{}
    UnionFind(int n_in):n{n_in}{
        v.assign(n,-1);
    }
    
    int find(int x){
        assert(0<=x && x<n);
        if(v[x]<0) return x;
        v[x]=find(v[x]);
        return v[x];
    }
    
    bool same(int a,int b){
        assert(0<=a && a<n);
        assert(0<=b && b<n);
        if(find(a)==find(b)) return true;
        return false;
    }
    
    int merge(int a,int b){
        assert(0<=a && a<n);
        assert(0<=b && b<n);
        int a_p=find(a),b_p=find(b);
        if(a_p==b_p) return a_p;
        if(a_p>b_p) swap(a_p,b_p);
        v[a_p]+=v[b_p]; v[b_p]=a_p;
        return a_p;
    }
    
    int size(int a){
        assert(0<=a && a<n);
        return -v[find(a)];
    }

    int group_cnt(){
        int res=0;
        for(auto p:v)if(p<0) res++;
        return res;
    }

    vector<std::vector<int>> groups(){
        vector<int> leader_buf(n),group_size(n);
        for (int i=0;i<n;i++){
            leader_buf[i]=find(i);
            group_size[leader_buf[i]]++;
        }
        vector<vector<int>> result(n);
        for (int i=0;i<n;i++){
            result[i].reserve(group_size[i]);
        }
        for (int i=0;i<n;i++){
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            remove_if(result.begin(),result.end(),
                           [&](const vector<int>& v) {return v.empty();}),
            result.end());
        return result;
    }
};


int main(){
    int n,q; cin>>n>>q;
    UnionFind uf(n);
    rep(_,q){
        int t,u,v; cin>>t>>u>>v;
        if(t==0){
            uf.merge(u,v);
        }
        else{
            printf("%d\n",(int)uf.same(u,v));
        }
    }
}

Measured memory_bytes: 3992
#include<iostream>
#include<cstring>

using namespace std;

// http://d.hatena.ne.jp/Nekonyan/20110508 
// Nekonyanツつウツづアツづ個コツーツドツづーツ参ツ考ツづ可つオツづ慊つオツつスツ。

int table[10+1][9900];
int memo[10];

void numnum (int size, int depth, int sum )
{
	if (size + 1 == depth ) {
		table[size][sum]++;
	}else{
		for (int i = 0; i <= 9; ++i ){
			if ( memo[i] == 0 ) {
				memo[i] = 1;
				numnum (size, depth + 1, sum + i*depth );
				memo[i] = 0;
			} // end if
		} // end for
	} // end if
}

int main()
{
	memset(table, 0, sizeof (table ) );

	for (int i = 1; i <= 10; ++i ) {
		memset (memo, 0, sizeof (memo ) );
		numnum (i, 1, 0 );
	} // end for

	int n, s;
	while ( cin >> n >> s ) {
		cout << table[n][s] << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    int a;
    cin >> a;

    cout << 3 * a * a << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try (Scanner sc = new Scanner(System.in)){
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for(int i =0;i < length;i++){
                char ch = line.charAt(i);
            if(Character.isLowerCase(ch) == true){
                ch = Character.toUpperCase(line.charAt(i));
            }else if(Character.isLowerCase(ch) == false){
                ch = Character.toLowerCase(line.charAt(i));
            }
            answer = answer + ch;
            }
            System.out.println(answer);
        }
    }
}



Measured memory_bytes: 31332
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;

template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


const int INF = 1e9;


void solve() {
    int N, M; cin >> N >> M;

    vector<pair<int, int>> key(M);

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;

        int s = 0;
        for (int j = 0; j < b; j++) {
            int c; cin >> c; c--;
            s |= 1<<c; 
        }

        key[i] = make_pair(a, s);
    }

    vector<vector<int>> dp(M+1, vector<int>(1<<N, INF));

    dp[0][0] = 0;

    for (int i = 0; i < M; i++) {
        for (int s = 0; s < 1<<N; s++) {
            // not use
            chmin(dp[i+1][s], dp[i][s]);

            // use
            int cost = dp[i][s] + key[i].first;
            chmin(dp[i+1][s|key[i].second], cost);
        }
    }

    int ans;
    if (dp[M-1][(1<<N) - 1] == INF) ans = -1;
    else ans = dp[M-1][(1<<N) - 1];

    cout << ans << endl;
}


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

Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){
    string S;
    ll K;
    cin >> S >> K;
    
    ll l = S.length();
    for(ll i = 0; i < min(l, K); i++){
        if(S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
    }
    
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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



// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  ll N,K;
  cin >> N >> K;

  string S;
  cin >> S;


  vint Nums;
  ll cnt = 0;
  ll now = 1;


  rep(i, N){
    if(S[i] == (char)('0'+now)){
      cnt++;
    }else{
      Nums.pb(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }

  if(cnt!=0) Nums.pb(cnt);
  if(Nums.size()%2 == 0) Nums.pb(0);

  // rep(i,Nums.size()) cout << Nums[i];
  // cout << endl ;

  vint cum(Nums.size()+1,0);

  rep(i,Nums.size()){
    cum[i+1] = cum[i] + Nums[i];
  }


  ll ans = 0;

  // K = min(K, (ll)(cum.size()/2));

  for(ll i=0;i<cum.size();i+=2){
    ll tmp;
    tmp = cum[min(i+K*2+1, (ll)(cum.size()-1))]-cum[i];

    ans = max(ans,tmp);
  }


  cout << ans << endl;

}

















//


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
int H,W;
cin>>H>>W;
char A[H][W];
bool bl_r[H],bl_c[W];
rep(i,H){
    bl_r[i]=false;
}
rep(i,W){
    bl_c[i]=false;
}
rep(i,H){
    rep(j,W){
        cin>>A[i][j];
        if(A[i][j]=='#'){
            bl_r[i]=true;
            bl_c[j]=true;
        }

    }
}
rep(i,H){
    if(bl_r[i]){
    rep(j,W){
        if(bl_c[j]){
        cout<<A[i][j];

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

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;
    multimap<Int, Int> x;
    vector<Int> xx;
    for (Int i = 1; i <= n; i++) {
        Int X;
        cin >> X;
        x.insert({X, i});
        xx.push_back(X);
    }
    sort(xx.begin(), xx.end());
    Int a = xx[n / 2], b = xx[n / 2 - 1];

    vector<Int> ans(n);
    Int index = 1;
    for (auto e : x) {
        if (index <= n / 2) {
            ans[e.second - 1] = a;
        } else {
            ans[e.second - 1] = b;
        }

        index++;
    }

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

    return 0;
}


Measured memory_bytes: 17776
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
ll calc(ll H, ll W){
    ll mini = INF;
    rep(h,1,H){
        ll s1 = h * W;
        ll s2 = (H-h) * (W/2);
        ll s3 = (H-h) * ((W+1)/2);

        mini = min(mini, max({s1, s2, s3}) - min({s1, s2, s3}) );
        if(h==H-1)continue;
        s2 = (H-h)/2 * W;
        s3 = (H-h+1)/2 * W;
        mini = min(mini, max({s1, s2, s3}) - min({s1, s2, s3}));
    }
    
    return mini;
}
main(){
    ll H,W;
    cin >> H >> W;
    if (H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << min(calc(H,W), calc(W,H)) << endl;
}

Measured memory_bytes: 256
require 'pp'
require 'prime'

n = gets.chomp!.to_i

0.upto(25) do |i|
    0.upto(100 / 7) do |j|
        if i * 4 + j * 7 == n
            puts "Yes"
            exit 0
        end
    end
end

puts "No"


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n; cin >> n;
	vi v(n*2);
	REP(i, n*2) cin >> v[i];
	sort(ALL(v));
	int ans = 0;
	REP(i, n) ans += v[i * 2];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

ll modll (ll i, ll j) {
    if (i < 0) return (i % j + j) % j;
    else return i % j;
} 
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n), b(n); rep (i, n) cin >> a[i];
    rep (i, n) b[i] = a[(i + 1) % n] - a[i];
    int k = modll(b[0], n);
    for (ll i : b) {
        if (k != modll(i, n)) {
            cout << "NO\n";
            return 0;
        }
    }

    ll m = b[0]; for (ll i : b) chmax(m, i);
    vector<ll> c(n); rep (i, n) c[i] = (m - b[i]) / n;
    for (ll i : c) eprintf("%lld ", i);
    ll x = 0; rep (i, n) x += (n - i) * c[i];
    eprintf(": %lld ", x);
    ll y = n * (n + 1) / 2LL;
    if (a[0] >= x && (a[0] - x) % y == 0) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M;
	int min, max;
	min = 10000000;
	max = 0;
	cin >> N >> M;
	vector<int>L(M);
	vector<int>R(M);
	vector<int>C(N,1);
	int cnt = 0;
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
		if (L[i] > 1) {
			if (C[L[i] - 2] == 1) {
				for (int j = 0; j < L[i] - 1; j++) {
					C[j] = 0;
				}
			}
		}
		if (R[i] < N) {
			if (C[R[i]] == 1) {
				for (int j = R[i]; j < N; j++) {
					C[j] = 0;
				}
			}
		}
	}
	for (int i = 0; i < N; i++)
		cnt = cnt + C[i];
	cout << cnt;
	return 0;
}

Measured memory_bytes: 1408
n, a, b = map(int, input().split())
s = input()

i = 0
j = 0
for n in s:
  if n == "a":
    if i + j < a + b:
      i += 1
      print("Yes")
    else:
      print("No")
  elif n == "b":
    if (i + j < a + b) and j < b:
      j += 1
      print("Yes")
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 4016
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] x = new int[N];
    int[] y = new int[N];
    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
    }
    double d = 0;

    for (int[] p : perm(N)) {
      for (int i = 1; i < p.length; i++) {
        int p1 = p[i - 1];
        int p2 = p[i];
        d += dist(x[p1], y[p1], x[p2], y[p2]);
      }
    }
    System.out.println(d / fact(N));
  }

  static int fact(int n) {
    int ans = 1;
    while (n > 0) {
      ans *= n--;
    }
    return ans;
  }

  static double dist(int x1, int y1, int x2, int y2) {
    return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  }

  static List<int[]> perm(int n) {
    List<int[]> res = new ArrayList<>();
    int[] nums = new int[n];
    for (int i = 0; i < n; i++) {
      nums[i] = i;
    }
    helper(0, nums, res);
    return res;
  }

  private static void helper(int start, int[] nums, List<int[]> result) {
    if (start == nums.length - 1) {
      result.add(Arrays.copyOf(nums, nums.length));
      return;
    }

    for (int i = start; i < nums.length; i++) {
      swap(nums, i, start);
      helper(start + 1, nums, result);
      swap(nums, i, start);
    }
  }

  private static void swap(int[] nums, int i, int j) {
    int temp = nums[i];
    nums[i] = nums[j];
    nums[j] = temp;
  }
}


Measured memory_bytes: 24660
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val x = readLine()!!.toInt()
    val y = readLine()!!.toInt()
    if (n <= k) println(x * n)
    else println(x * k + y * (n - k))
}

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

int main(){
    int n;
    cin >> n;
    vector<int> d(10000001,0);
    for(int i = 1; i <= n;i++){
        for(int j = i; j <=n;j+=i) d.at(j)++;
    }
    ll ans = 0;
    for(int i = 0; i < 10000001;i++) ans += (ll)i * d.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 42340
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

char fi[1010][1010];
int d[1010][1010];

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

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w; cin >> h >> w;
	int sx,sy; cin >> sx >> sy;
	int tx,ty; cin >> tx >> ty;
	sx--; sy--; tx--; ty--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> fi[i][j];
			d[i][j]=1e9;
		}
	}
	d[sx][sy]=0;
	priority_queue<pair<int,pair<int,int>>> q;
	q.push(make_pair(0,make_pair(sx,sy)));
	while(q.size()){
		auto p=q.top(); q.pop();
		int x=p.second.first,y=p.second.second;
		if(-p.first!=d[x][y])continue;
		for(int i=0;i<4;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&fi[nx][ny]=='.'&&d[nx][ny]>d[x][y]){
				d[nx][ny]=d[x][y];
				q.push(make_pair(-d[nx][ny],make_pair(nx,ny)));
			}
		}
		for(int i=-2;i<=2;i++){
			for(int j=-2;j<=2;j++){
				int nx=x+i,ny=y+j;
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&fi[nx][ny]=='.'&&d[nx][ny]>d[x][y]+1){
					d[nx][ny]=d[x][y]+1;
					q.push(make_pair(-d[nx][ny],make_pair(nx,ny)));
				}
			}
		}
	}
	if(d[tx][ty]==1e9){
		d[tx][ty]=-1;
	}
	printf("%d\n",d[tx][ty] );
}

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#define optimize ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define INF 2000000020LL
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define POS(n, x) (lower_bound(ALL(n), x) - (n).begin())
#define ll long long
#define ld long double
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define PB push_back
#define EB emplace_back
#define MOD 1000000007
#define PRIME 101 
#define MAXN 110
#define MAXP 100010
#define MAXL 23
#define endl '\n'

using namespace std;

// (1 + sqrt(5)) / 2
const ld GOLDEN_RATIO = 1.6180339887498949025257388711906969547271728515625;
const ld PI = 2.0 * acos(0.0);
const int BLOCK = 333;

ll dp[MAXN][MAXP], peso[MAXN], ganho[MAXN];
int N, W;

ll solve(int i, int v)
{
	if(dp[i][v] != -1) return dp[i][v];
	if(i == N) return dp[i][v] = (v == 0 ? 0 : INF);

	dp[i][v] = solve(i + 1, v);

	if(ganho[i] <= v) dp[i][v] = min(dp[i][v], peso[i] + solve(i + 1, v - ganho[i]));

	return dp[i][v];
}

int main(int argc, char const *argv[])
{
	optimize;

	memset(dp, -1, sizeof dp);

	cin >> N >> W;

	for(int i = 0; i < N; i++)
		cin >> peso[i] >> ganho[i];

	int ans = 0;

	for(int i = 1; i < MAXP; i++)
		if(solve(0, i) <= W)
			ans = i;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 89560
S=input()
T=input()
s=len(S)
t=len(T)
ans=10**9
for i in range(s-t+1):
    count=0
    for j in range(t):
        if S[i+j]!=T[j]:
            count+=1
        if count>=ans:
            break
    ans=min(ans,count)
    if ans==0:
        break
print(ans)

Measured memory_bytes: 8960
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	string s;
	cin >> s;
	if(s[5] == s[4] && s[3] == s[2])
		cout << "Yes";
	else
		cout << "No";
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}	


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

using namespace std;

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    vector<vector<int>> tree(n + 1);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
    }
    queue<pair<int, int>> q;
    q.emplace(make_pair(v, 0));
    vector<int> dis(n + 1, -1);
    dis[v] = 0;
    while (!q.empty()) {
        auto front = q.front();
        q.pop();
        for (auto e: tree[front.first]) {
            if (dis[e] < 0) {
                dis[e] = front.second + 1;
                q.emplace(make_pair(e, front.second + 1));
            }
        }
    }
    vector<pair<int, int>> vs(n);
    for (int i = 1; i < n + 1; i++) {
        vs[i - 1] = make_pair(dis[i], i);
    }
    sort(vs.begin(), vs.end());
    reverse(vs.begin(), vs.end());
    vector<bool> reached(n + 1, false);
    queue<tuple<int, int, pair<int, int>>> qt;
    qt.emplace(make_tuple(u, 0, make_pair(dis[u], 0)));
    while (!qt.empty()) {
        auto front = qt.front();
        qt.pop();
        reached[get<0>(front)] = true;
        for (auto e: tree[get<0>(front)]) {
            if (!reached[e]) {
                int cost = get<1>(front);
                if (dis[e] < get<2>(front).first) {
                    if (dis[e] > cost + 1) {
                        qt.emplace(make_tuple(e, cost + 1, make_pair(dis[e], cost)));
                    }
                } else {
                    qt.emplace(make_tuple(e, cost + 1, get<2>(front)));
                }
            }
        }
    }
    for (auto v: vs) {
        int ver = v.second;
        if (reached[ver]) {
            cout << v.first - 1 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	long long n, m;
	long long ans = 0;
	cin >> n >> m;
	if (n*2 <= m) {
		ans += n;
		m -= n * 2;
	}
	else {
		ans += m / 2;
		m -= ans * 2;
	}
	ans += m / 4;
	cout << ans << endl;
	return 0;
}

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

// Data Type
#define ull             unsigned long long int
#define ll              long long int

// Loops
#define loop(i,s,e)     for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    for(ll i=(s);i>=(e);i--)

// Stl
#define pb              push_back
#define eb              emplace_back
#define pf              push_front
#define popb            pop_back
#define popf            pop_front
#define mp              make_pair
#define ff 				first
#define ss 				second

// Maths
#define PI              (2*acos(0.0))
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        (((a)*(b))/(__gcd((a),(b))))
#define log(x,b)		(log(x)/log(b))
#define INF 			LLONG_MAX

// Big data
const int Mod = 1e9+7;
#define mul(a,b) 		((a%Mod)*(b%Mod))%Mod
#define sum(a,b) 		((a%Mod)+(b%Mod))%Mod

// Bit-Manipulation
#define setbit(n,pos) 	n |= (1LL<<pos)
#define resetbit(n,pos) n &= (~(1LL<<pos))
#define toogle(n,pos)	n ^= (1LL<<pos)
#define atpos(n,pos)	((n&(1LL<<pos))!=0)

// Extra
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; nl;
#define nl              cout<<'\n'
#define endl            '\n'

void solve()
{
	ll a,b,c;
  	cin>>a>>b>>c;
  	if(a+b+c>=22)
      cout<<"bust";
 	else
      cout<<"win";
}

int main()
{
	try
    {			
		ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t = 1;
		while(t--)
			solve();
	}
    catch(...)
    {
    	// nothing.
    }
	return 0;
}

Measured memory_bytes: 256