akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define Q_LENGTH 200000

void show_maze(int S[][1000], int height, int width, FILE *fp) {
  int h, w;

  for(h = 0; h < height; h++) {
    for(w = 0; w < width; w++) {
      if(S[h][w] == 0) {
        fputc(' ', fp);
        fputc(' ', fp);
      }else
        fprintf(fp, "%2d", S[h][w]);
    }
    fputc('\n', fp);
  }
}

int main(void){
  typedef struct{
	int h;
	int w;
  } point;
  
  int height, width;
  point start;
  point goal;
  int S[1000][1000];
  point queue[Q_LENGTH];
  int qhead = 0, qtale = 0;
  int h, w;
  point current;
  int warp = 0;
 
  scanf("%d%d", &height, &width);
  scanf("%d%d", &start.h, &start.w);
  scanf("%d%d", &goal.h, &goal.w);
  start.h--;
  start.w--;
  goal.h--;
  goal.w--;
  getchar();
  for(h = 0; h < height; h++){
    for(w = 0; w < width; w++){
      S[h][w] = (getchar() == '#');
    }
    getchar();
  }
  
  queue[0] = start;
  qtale = 1;
  S[start.h][start.w] = 1;
  	
  while(qhead != qtale || current.h != goal.h || current.w != goal.w){
    point tmp[24] = {{0,1}, {1,0}, {0,-1}, {-1, 0}, {2, 2}, {2, 1}, {2, 0}, {2, -1}, {2, -2},{1, 2}, {1, 1}, {1, -1}, {1, -2}, {0, 2}, {0, -2}, {-1, 2}, {-1, 1}, {-1, -1}, {-1, -2}, {-2, 2}, {-2, 1}, {-2, 0}, {-2, -1}, {-2, -2}};
	int i = 0;
    current = queue[qhead];
	qhead = (qhead + 1) %Q_LENGTH;

	for(; i < 4; i++){
      point pt = {current.h + tmp[i].h, current.w + tmp[i].w};

      if(pt.h < 0 || pt.h >= height || pt.w < 0 || pt.w >= width)
        continue;

	  if((!S[pt.h][pt.w]) || S[pt.h][pt.w] > S[current.h][current.w]){
		S[pt.h][pt.w] = S[current.h][current.w];
		queue[qtale] = pt;
		qtale = (qtale + 1)%Q_LENGTH;
	  }
	}

	for(; i < 24; i++){
	  point pt = {current.h + tmp[i].h, current.w + tmp[i].w};
    
      if(pt.h < 0 || pt.h >= height || pt.w < 0 || pt.w >= width)
        continue;

	  if((!S[pt.h][pt.w]) || S[pt.h][pt.w] > S[current.h][current.w]+1){
		S[pt.h][pt.w] = S[current.h][current.w] + 1;
		queue[qtale] = pt;
		qtale = (qtale + 1)%Q_LENGTH;
	  }
	}
    if(qhead == qtale){
      if(S[goal.h][goal.w]) {
        break;
      } else {
        printf("-1\n");
        return 0;
      }
    }
  }

  printf("%d\n", S[goal.h][goal.w]-1);
  
  return 0;
}

Measured memory_bytes: 7172
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans=0,now=0;
    string s;
    int n;
    cin>>n;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='D') ans--;
        if(s[i]=='I') ans++;
        now=max(now,ans);
    }
    cout<<now<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i = 1;
  int ans = 0;
  int a, b;
  scanf("%d %d", &a, &b);
  while (i < b)
  {
    i += a - 1;
    ans++;
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int a,b;
int main(int argc, char const *argv[])
{
cin>>a>>b;
if(a*b%2==1){
    cout<<"Odd"<<endl;
}else{
    cout<<"Even"<<endl;
}
    return 0;
}


Measured memory_bytes: 256
from collections import deque

S = str(input())
Q = int(input())
t = 0

d = deque()
d.append(S)

for _ in range(Q):
    A = list(input().split())
    if A[0] == "1":
        if t == 0:
            t = 1
        else:
            t = 0

    elif (A[1] == "1" and t == 0) or (A[1] == "2" and t == 1):
        d.appendleft(A[2])
    else:
        d.append(A[2])

l = list(d)
ans = "".join(l)
if t == 1:
    ans = ans[::-1]
print(ans)

Measured memory_bytes: 13204
h, w = map(int, input().split())
lst = []
for i in range(h):
    lst.append(list(input().split()))
    lst[i].insert(0, "#")
    lst[i].append("#")
head = ["#" for i in range(w+2)]
bottom = head

print("".join(head))
for i in range(h):
    print("".join(lst[i]))
print("".join(bottom))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int mult(int x, int y) {
	return 1ll * x * y % mod;
}
void mult_self(int& x, int y) {
	x = mult(x, y);
}
int add(int x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) {
		x += mod;
	}
	return x;
}
void sub_self(int& x, int y) {
	x = sub(x, y);
}
int bin_pow(int x, int y) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		return bin_pow(mult(x, x), y / 2);
	}
	return mult(x, bin_pow(x, y - 1));
}
int inv(int x) {
	return bin_pow(x, mod - 2);
}
int C(int x, int y) {
	int res = 1;
	int yy = y;
	for (int i = x; i >= x - y + 1; --i) {
		mult_self(res, i);
		mult_self(res, inv(yy--));
	}
	return res;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, a, b;
	cin >> n >> a >> b;
	int answer = sub(bin_pow(2, n), 1);
	sub_self(answer, C(n, a));
	sub_self(answer, C(n, b));
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 384
#define rep(i,n)for(int i=0;i<n;i++)
n,h[101],flag,ans=0;main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&h[i]);
	rep(i,10001){
		flag=0;
		rep(j,n)flag+=h[j];
		if(!flag)break;
		flag=0;
		rep(j,n){
			if(!h[j]){flag=0;continue;}
			if(!flag){ans++;flag++;}
			h[j]--;
		}
	}
	printf("%d",ans);
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    string s;
    cin>>s;
    if(s.back()=='s')
        s+="es";
    else
        s+="s";
    cout<<s<<nl;
}


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

int main(){
    int x,y;
    while(cin>>x>>y && (x!=0 || y!=0)){
        if (x>y){
            cout << y << " " << x << endl;
        } else {
            cout << x << " " << y << endl;
        }
    }
    return 0 ;
}


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

const int maxn(1e5 + 5);

struct Edge {  int to, next;  };

int n, m, first[maxn], cnt, sum[maxn], fa[maxn], dsu[maxn], deep[maxn], a, b, ans, val[maxn];
Edge edge[maxn << 1];

inline int Find(int x) {  return (dsu[x] ^ x) ? dsu[x] = Find(dsu[x]) : x;  }

inline void Add(int u, int v) {
	edge[cnt] = (Edge){v, first[u]}, first[u] = cnt++;
	edge[cnt] = (Edge){u, first[v]}, first[v] = cnt++;
}

void Dfs(int u, int ff, int d) {
	int e, v;
	sum[u] = d;
	for (e = first[u]; ~e; e = edge[e].next)
		if ((v = edge[e].to) ^ ff) {
			deep[v] = deep[u] + 1;
			fa[v] = u, Dfs(v, u, -d);
			sum[u] += sum[v];
		}
}

int main() {
	int i, u, v, len = 1;
	memset(first, -1, sizeof(first));
	scanf("%d%d", &n, &m);
	if (n & 1) return puts("-1"), 0;
	for (i = 1; i <= n; ++i) dsu[i] = i;
	for (i = 1; i <= m; ++i) {
		scanf("%d%d", &u, &v);
		if (Find(u) ^ Find(v)) Add(u, v), dsu[Find(u)] = Find(v);
		else a = u, b = v;
	}
	if (!a) {
		Dfs(1, 0, 1);
		if (sum[1]) return puts("-1"), 0;
	}
	else {
		Dfs(a, 0, 1);
		if (deep[b] & 1) {
			if (sum[a]) return puts("-1"), 0;
			for (i = b; i ^ a; i = fa[i]) val[++len] = sum[i], sum[i] = 0;
			sort(val + 1, val + len + 1), v = val[(len + 1) >> 1];
			for (i = 1; i <= len; ++i) ans += abs(val[i] - v);
		}
		else {
			if (sum[a] & 1) return puts("-1"), 0;
			v = sum[a] >> 1, ans = abs(v), sum[a] = 0;
			for (i = b; i ^ a; i = fa[i]) sum[i] -= v;
		}
	}
	for (i = 1; i <= n; ++i) ans += abs(sum[i]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10368
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut aseq = vec![0; n];
    for i in 0..n {
        aseq[i] = read::<usize>();
    }
    let mut dp = vec![false; 10200];
    dp[0] = true;
    for i in 0..n {
        for j in (0..10001).rev() {
            dp[j + aseq[i]] |= dp[j];
        }
    }
    let mut ans = 0;
    for i in 0..10001 {
        if !dp[i] || i % 10 == 0 {
            continue;
        }
        ans = i;
    }
    println!("{}", ans);
}


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

int main(){
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i=0;i<N;i++){
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	double ans = vec.at(0);
	for(int i=1;i<N;i++){
		ans = (ans+vec.at(i))/2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int dp[1000005][5];
int main()
{
  string s;
  cin >> s;

  rep(i, 0, 1000005)
  rep(j, 1, 5)
    dp[i][j] = -1;

  rep(i, 1, 5)
    dp[i - 1][i] = 1;

  rep(i, 0, s.size())
  rep(j, 1, 5)
  rep(k, 1, 5)
  {
    if (i + j >= s.size()) continue;
    if (i - k + 1 < 0) continue;
    if (dp[i][k] == -1) continue;
    if (s.substr(i - k + 1, k) == s.substr(i + 1, j)) continue;

    dp[i + j][j] = max(dp[i + j][j], dp[i][k] + 1);
  }

  int ans = 0;
  rep(i, 1, 5)
    ans = max(ans, dp[s.size() - 1][i]);
  cout << ans << endl;
}


Measured memory_bytes: 20100
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
	int n;cin>>n;
  	vector<int> a(n);
  	
  	for(int i=0;i<n;i++){
    	cin>>a.at(i);
    }
  	int mymax=-2000000000,mymin=a.at(0);
  	for(int i=1;i<n;i++){
  		mymax=max(mymax,a.at(i)-mymin);
      	mymin=min(mymin,a.at(i));
    }
     cout<<mymax<<endl;
}


Measured memory_bytes: 3588
// 貪欲法3

// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

struct State {
    vi last;
    vi ans;
};

int D;
int c[26];
int s[366][26];
State state[26];
State next_state[26 * 50];

ll calc(vi& ans) {
    ll score = 0;
    vi last(26);
    forn1(i, D) {
        int t = ans[i - 1];

        last[t] = i;

        score += s[i][t];
        forn(j, 26) {
            score -= (i - last[j]) * c[j];
        }
    }

    return max(TEN(6) + score, 0LL);
}

int main() {
    fastio();

    cin >> D;
    forn(i, 26) cin >> c[i];
    forn1(i, D) forn(j, 26) cin >> s[i][j];

    forn(i, 26) {
        state[i].last = vi(26, 0);
    }

    forn1(i, D) {
        vec<pli> idx;

        int l = 0;
        forn(si, 26) {

            forn(j, 26) {
                State st;
                st.ans = state[si].ans;
                st.last = state[si].last;

                ll x = s[i][j];

                forn(k, 26) {
                    if (k != j) {
                        x -= (i - st.last[k]) * c[k];
                    }
                }

                st.last[j] = i;
                st.ans.push_back(j);

                idx.push_back(mp(x, l));
                next_state[l] = st;
                l++;
            }
        }

        sort(all(idx), greater<pli>());

        forn(j, 26) {
            state[j] = next_state[idx[j].snd];
        }
    }

    int ansi = 0;
    ll score = -1;
    forn(i, 26) {
        if (score < calc(state[i].ans)) {
            ansi = i;
        }
    }

    for (int x : state[ansi].ans) {
        cout << x + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5052
#include <stdio.h>
int main(){
    char x[1001];
    int i, temp, now;
    for(i=0;i<1001;i++)
        x[i]='\0';
    while(1){
        scanf("%s",x);
        if(x[0]=='0')return 0;
        temp=now=0;
        while(x[now]!='\0'){
            temp+=x[now]-'0';
            now++;
        }
        for(i=0;i<now;i++)
            x[i]='\0';
        printf("%d\n",temp);
    }
}


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

int main() {
    ll N;
    cin >> N;
    ll num[] ={0,0,0};
    ll ans =1;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        set<ll> candidates;
        for(int j=0;j<3;j++){
            if(num[j] == A){
                candidates.insert(j);
            }
        }
        int p =*candidates.begin();
        ans*= (candidates.size());
        ans %= MOD;
        num[p]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <numeric>

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

    int d;
    std::vector<int> data;

    while (std::cin >> d && d != 0) data.push_back(d);

    int sum = 0;

    for (int i = 0; i < (data.size() / 10); i++) {
        for (int j = 1; j < 10; j++) sum += data.at(j + i * 10);
        std::cout << data.at(i * 10) - sum << "\n";
        sum = 0;
    }

    return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;cin>>N;
  int S = 0;
  static int I = 1;
  while(true)
  {

    S += I;
    if(S >= N)break;
    I++;
  }
  for (int i = 1; i <= I; i++)
  {
    if(i == S - N)continue;
    cout<<i<<endl;
  }
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
#sys.setrecursionlimit(10**7)
#inf = 10**9
sum=0
N=int(input())
A=int(input())
sum+=A//2
a=A%2
for _ in range(1,N):
    A=int(input())
    if a==1 and A>0:
        sum+=a
        A-=a
        a=0
    sum+=A//2
    a=A%2
print(sum)






Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i;
  vector<int> vec(n);
  int mini,maxi;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(n-1)-vec.at(0);
}


Measured memory_bytes: 256
from heapq import nlargest

x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = nlargest(k, (a + b for a in A for b in B))
ABC = nlargest(k, (ab + c for ab in AB for c in C))
[print(abc) for abc in ABC]

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x, n;
    cin >> x >> n;
    unordered_map<int, bool> seen;
    int p[n];
    for(int i=0; i<n; i++)
    {
        cin >> p[i];
        seen[p[i]] = true;
    }
    int mn_diff = 1000000000, ans = 0;
    for(int xx=1000; xx>=-1000; xx--)
    {
        if(seen[xx])
            continue;
        int t = abs(x-xx);
        if(t <= mn_diff)
        {
            ans = xx;
            mn_diff = t;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    int ans[h][w];
    int ph=0,pw=0;
    rep(i,n){
        rep(j,a[i]){
            ans[ph][pw]=i+1;
            if(ph%2==0){
                if(pw==w-1) ph++;
                else pw++; 
            }
            else{
                if(pw==0) ph++;
                else pw--;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
 int N,M;
  cin >> N;
  cin >> M;
 int s_i[M],c_i[M];
  int hantei=0;
  int answer=0;
  for(int i=0;i<M;i++){
  	cin >> s_i[i] >>c_i[i];
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
  		if(s_i[i]==s_i[j]&&c_i[i]!=c_i[j]){
          hantei=1;
          // cout <<"koko1"<<endl;
        }
      	if(s_i[i]==1&&N>1&&c_i[i]==0){
          hantei=1;
         // cout <<"koko2"<<endl;
        }
    }
  }
  int a[N];
  for(int i=0;i<N;i++){
  	if(i==0)a[i]=1;
    if(i!=0)a[i]=0;
    if(N==1)a[i]=0;
  }
  for(int i=0;i<M;i++){
     for(int j=0;j<N;j++){
     	if(s_i[i]==j+1)a[j]=c_i[i];
     }
  }
  if(hantei==1)cout << -1<<endl;
  else{
    for(int i=0;i<N;i++){
      answer+=a[i]*pow(10,N-i-1);
    }
    cout << answer<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

int N, M, K, Q, i, j, k, l, tmp, ans;

int main(){
    int A, B, H;
    long double h, m;
    cin >> A >> B >> H >> M;

    //時針分針をラジアンに変換
    long double r = PI * 2 * ((long double)H / 12.0 + ((long double)M / 60.0) / 12.0 - (long double)M / 60.0);
    //long double r = h - m;

    // 余弦定理で計算
    long double cm = (long double)(A * A + B * B) - (long double)(2 * A * B) * cos(r);
    printf("%20.20Lf\n", sqrt(cm));
    




    return 0;
}

Measured memory_bytes: 4048
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] s = new int[m];
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            s[i] = in.nextInt() - 1;
            c[i] = in.nextInt();
        }

        int min = n == 1 ? 0 : (int) Math.pow(10, n - 1);
        int max = (int) Math.pow(10, n);

        for (int i = min; i < max; i++) {
            if (check(i, n, s, c)) {
                out.println(i);
                return;
            }
        }
        out.println(-1);
    }

    private static boolean check(int toCheck, int n, int[] s, int[] c) {
        String str = String.valueOf(toCheck);
        if (str.length() != n) {
            return false;
        }

        for (int i = 0; i < s.length; i++) {
            int as = s[i];
            int ac = c[i];

            if ((str.charAt(as) - '0') != ac) {
                return false;
            }
        }
        return true;
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n + 1), r(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
  }
  sort(l.rbegin(), l.rend());
  sort(r.begin(), r.end());

  long long int ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (l[i] > r[i]) {
      ans += 2 * (l[i] - r[i]);
    }
  }
  cout << ans;
}


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

int main(){
  int K;
  
  string S="";
  cin>>K;
  for(int i=0;i<K;i++){
    S+="ACL";
  }
  cout<<S<<endl;
  
}



Measured memory_bytes: 3596
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int t = 0;
        for(int i = 0; i < 4; i++){
            if(s.charAt(i) == '+')t++;
            else if(s.charAt(i) == '-')t--;
        }
        System.out.println(t);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
// #define int long long
#define P pair<int, int>
typedef long long ll;

const int Z = 1e9+7;
const int INF = -1;

struct _chunk {
	int connect;
	int dist;
	int color;
};

signed main(void) {
  int n, k;
    cin >> n >> k;
 
    int sqn = sqrt(n);
 
    int dp0[k+1][sqn+1], dp1[k+1][sqn+1];
    memset(dp0, 0, sizeof(dp0));
    memset(dp1, 0, sizeof(dp1));
    for (int i = 1; i <= sqn; i++) {
        dp0[0][i] = dp1[0][i] = 1;
    }
 
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= sqn; j++) {
            dp0[i][j] = (dp0[i][j-1] + dp1[i-1][j]) % Z;
        }
 
        int s = dp0[i][sqn], lj = sqn;
        for (int j = sqn; j >= 1; j--) {
            s = (s + 1ll * (n / j - lj) * dp0[i-1][j]) % Z;
            dp1[i][j] = s;
            lj = n / j;
        }
    }
 
    cout << dp1[k][1] << endl;
 
    return 0;
}


Measured memory_bytes: 25216
def dfs(l,x):
    if x == 0:
        return 0
    if l == 0:
        return 1
    if x == 1:
        return 0
    if x <= num[l] // 2:
        return dfs(l-1,x-1)
    if x == num[l]:
        x -= 1
    return patty[l-1] + 1 + dfs(l-1,x-num[l]//2-1)
n,x = map(int,input().split())
patty = [1]
num = [1]
for i in range(1,51):
    patty.append(patty[i-1]*2+1)
    num.append(num[i-1]*2+3)
print(dfs(n,x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 


int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<string> choco(h);
  rep(i,h) cin >> choco[i];

  ll ans1 = LINF;
  rep(i, 1<<(h-1)) {
    vi id(h);
    int g=0;
    rep(j, h) {
      id[j] = g;
      if (i>>j&1) g++;
    }
    g++;
    vvi c(g, vi(w));
    rep(j, w) {
      rep(l, h) {
        c[id[l]][j] += choco[l][j]-'0';
      } 
    }
    
    ll ans = g-1;
    vi now(g);
    auto add = [&](int j)->bool {
      rep(l, g) {
        now[l] += c[l][j];
        if (now[l] > k) return false;
      }
      return true;
    };
    rep(j,w) {
      if (!add(j)) {
        ans++;
        now = vi(g, 0);
        if (!add(j)) {
          ans = INF;
          break;
        }
      }
    }
    ans1 = min(ans1, ans);
  }
  cout << ans1 << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

total = sum(A)
cnt = 0
for i in range(len(A)):
    if (A[i] / total) >= (1 / (4 * M)): cnt += 1

if cnt >= M:
    print('{}'.format('Yes'))
else:
    print('{}'.format('No'))



Measured memory_bytes: 3060
from collections import defaultdict as dd, deque

t = int(input())

for _ in range(t):
    n,a,b,c,d = map(int,input().split())

    todo = [(n, 0)]

    best = 10**100
    cheap = dd(lambda: 10**100)
    while todo:
        #print(todo)
        x,cost = todo.pop()
        if x < 0 or cost >= best:
            continue
        if x == 0:
            best = min(best, cost)
            continue
        if x in cheap and cheap[x] <= cost:
            continue
        cheap[x] = cost

        todo.append((0, cost + x*d))
        for i in range(x-1, x+2):
            if i%2 == 0:
                dist = abs(i - x)
                todo.append((i//2, cost + dist*d + a))
        for i in range(x-2, x+3):
            if i%3 == 0:
                dist = abs(i - x)
                todo.append((i//3, cost + dist*d + b))
        for i in range(x-4, x+5):
            if i%5 == 0:
                dist = abs(i - x)
                todo.append((i//5, cost + dist*d + c))
    print(best)




Measured memory_bytes: 79008
#include <stdio.h>

int main (void)

{

int a,b,c;

int count=0;

int i;

scanf("%d %d %d",&a,&b,&c);

for(i=a;i<=b;i++)

{

if(c%i==0)  count++;

}

printf("%d\n",count);

return 0;

}

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

int main() {
  int n, m, o = 0;
  cin >> n >> m;
  vector<int> k(m), p(m), st(n);
  vector<vector<int>> s(m, vector<int>(n));
  for(int i = 0; i < m; i++) {
    cin >> k.at(i);
    for(int j = 0; j < k.at(i); j++)
      cin >> s.at(i).at(j);
  }
  for(int i = 0; i < m; i++)
    cin >> p.at(i);
  for(int i = 0; i < (1 << n); i++) {
    for(int j = 0; j < n; j++) {
      if((i >> j) & 1)
        st.at(j) = 1;
      else
        st.at(j) = 0;
    }
    int f = 1;
    for(int j = 0; j < m; j++) {
      int c = 0;
      for(int sw = 0; sw < k.at(j); sw++) {
        if(st.at(s.at(j).at(sw) - 1))
          c++;
      }
      if(c % 2 != p.at(j))
        f = 0;
    }
    if(f)
      o++;
  }
  cout << o << endl;
}

Measured memory_bytes: 384
class Integer
  
  attr_accessor :mod
  @@mod = 10 ** 9 + 7
  
  alias_method :primitive_add, :+
  def +(other)
    res = self.primitive_add(other)
    res %= @@mod if res < 0 || res >= @@mod
    res
  end
  
  alias_method :primitive_minus, :-
  def -(other)
    res = self.primitive_minus(other)
    res %= @@mod if res < 0 || res >= @@mod
    res
  end
  
  alias_method :primitive_times, :*
  def *(other)
    self.primitive_times(other) % @@mod
  end
  
  def /(other)
    self * other.pow(@@mod-2, @@mod) % @@mod
  end
end

n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.reduce(:+)

puts ans

Measured memory_bytes: 15976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  set<int> st;
  rep (i, n) {
    int x; cin >> x;
    st.insert(x);
  }

  if (st.size() == n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 12964
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n, n){
		cin.ignore();
		pair <int, int> data[40];
		string str;
		for (int i = 0; i < n; i++){
			getline(cin, str);

			stringstream ss(str);
			vector <int> pin;
			for (int x; ss >> x;){
				pin.push_back(x);
			}

			int score = 0;
			for (int frame = 1, j = 1; frame <= 10; frame++){
				if (frame == 10){
					while (j < pin.size()){
						score += pin[j];
						j++;
					}
					break;
				}
				if (pin[j] == 10){
					// st
					score += pin[j] + pin[j + 1] + pin[j + 2];
					j++;
				}
				else {
					score += pin[j] + pin[j + 1];
					if (pin[j] + pin[j + 1] == 10){
						// sp
						score += pin[j + 2];
					}
					j += 2;
				}
			}
			data[i].first = -score;
			data[i].second = pin[0];
		}
		sort(data, data + n);
		for (int j = 0; j < n; j++){
			cout << data[j].second << " " << -data[j].first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

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

	map<string, int> Am;
	vector<string> S(N);
	int max = 0;

	for (int i = 0; i < N; i++) 
	{
		string x;
		cin >> x;

		if (!Am.count(x)) 
		{
			Am[x] = 1;
			if (max < Am[x]) 
			{
				max = Am[x];
			}
		}
		else 
		{
			Am[x]++;
			if (max < Am[x])
			{
				max = Am[x];
			}
		}
	}

	for (auto& i : Am) 
	{
		if (i.second == max) 
		{
			cout << i.first << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 27236
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

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

int main() {
	int A, B;
	cin >> A;
	cin >> B;



	cout << 6 - A - B << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func warshallFloyd(n int, d [][]int) {
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			for k := 0; k < n; k++ {
				t := d[j][i] + d[i][k]
				if t < d[j][k] {
					d[j][k] = t
				}
			}
		}
	}
}

func main() {
	H := readInt()
	W := readInt()

	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = readString()
	}

	n := H * W
	d := make([][]int, n)
	for i := 0; i < n; i++ {
		d[i] = make([]int, n)
		fillInts(d[i], math.MaxInt32)
		d[i][i] = 0
	}

	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if S[y][x] == '#' {
				continue
			}
			if y-1 >= 0 && S[y-1][x] != '#' {
				d[y*W+x][(y-1)*W+x] = 1
			}
			if y+1 < H && S[y+1][x] != '#' {
				d[y*W+x][(y+1)*W+x] = 1
			}
			if x-1 >= 0 && S[y][x-1] != '#' {
				d[y*W+x][y*W+x-1] = 1
			}
			if x+1 < W && S[y][x+1] != '#' {
				d[y*W+x][y*W+x+1] = 1
			}
		}
	}

	warshallFloyd(n, d)

	result := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if d[i][j] < math.MaxInt32 && d[i][j] > result {
				result = d[i][j]
			}
		}
	}

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func fillInts(a []int, x int) {
	for i := 0; i < len(a); i++ {
		a[i] = x
	}
}


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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    std::sort(A.begin(), A.end());
    for(int i=0; i<N-1; i++){
        if(A[i] == A[i+1]){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    std::cout << "YES" << std::endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

static void printQq( void )
{
	int i, j;

	for ( i = 1; i <= 9; i++ ) {
		for ( j = 1; j <= 9; j++ ) {
			std::cout << i << "x" << j << "=" << (i * j) << '\n';
		}
	}
}

int main()
{
	printQq();

	return 0;
}

Measured memory_bytes: 2964
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    struct p {
        public int x1, y1, x2, y2; //(x1,y1):移動前の座標、(x2,y2):移動後の座標
        public p(int X1, int Y1, int X2, int Y2) {
            x1 = X1;
            y1 = Y1;
            x2 = X2;
            y2 = Y2;
        }
    }
    static Scanner cin = new Scanner();
    static void Main() {
        int H = cin.Int();
        int W = cin.Int();
        var a = new int[H, W];
        for (int i = 0; i < H; i++) {
            var tmp = cin.ArrayInt(W);
            for (int j = 0; j < W; j++) {
                a[i, j] = tmp[j];
            }
        }

        var list = new List<p>();
        int cnt = 0;

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W - 1; j++) {
                if(a[i, j] % 2 != 0) {
                    list.Add(new p(j, i, j + 1, i));
                    a[i, j]--;
                    a[i, j + 1]++;
                    cnt++;
                }
            }
        }

        for (int i = 0; i < H - 1; i++) {
            if(a[i, W - 1] % 2 != 0) {
                list.Add(new p(W - 1, i, W - 1, i + 1));
                a[i, W - 1]--;
                a[i + 1, W - 1]++;
                cnt++;
            }
        }

        Console.WriteLine(cnt);
        foreach (var point in list) {
            Console.WriteLine("{0} {1} {2} {3}", point.y1 + 1, point.x1 + 1, point.y2 + 1, point.x2 + 1);
        }
        Console.ReadLine();
    }
}

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

#define int unsigned long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7, mul = (1 << 30);

int n, pw[200005], a[200005], b[200005], hash1[200005], hash2[200005], c[200005], d[200005];
vector<ii> answers;

int hash11(int l, int r){
    return (hash1[r] - (hash1[l - 1] * pw[r - l + 1]) + mod * mod) % mod;
}

int hash22(int l, int r){
    return (hash2[r] - (hash2[l - 1] * pw[r - l + 1]) + mod * mod) % mod;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i < n; i++) c[i] = (a[i] ^ a[i + 1]);
	c[n] = (a[n] ^ a[1]);
	for(int i = 1; i < n; i++) d[i] = (b[i] ^ b[i + 1]);
	d[n] = (b[n] ^ b[1]);
	//for(int i = 1; i <= n; i++) cout << c[i] << " ";
	//cout << "\n";
	//for(int i = 1; i <= n; i++) cout << d[i] << " ";
	//cout << "\n";
	for(int i = 1; i <= n; i++) hash1[i] = (hash1[i - 1] * mul + c[i]) % mod;
	for(int i = 1; i <= n; i++) hash2[i] = (hash2[i - 1] * mul + d[i]) % mod;
	pw[0] = 1;
	for(int i = 1; i <= n; i++) pw[i] = (pw[i - 1] * mul) % mod; 
	for(int i = 1; i <= n; i++){
	    //cout << hash11(1, n - i + 1) << " " << hash22(i, n) << "\n";
	    if(hash11(1, (n - i + 1)) != hash22(i, n) || ((i != 1) && (hash11(n - i + 2, n) != hash22(1, i - 1)))) continue;
	    answers.pb({(n - i + 1) % n, b[i] ^ a[1]});
	}
	sort(answers.begin(), answers.end());
	for(int i = 0; i < answers.size(); i++) cout << answers[i].fi << " " << answers[i].se << "\n";
}

/*
TEST HERE
INPUT #1

OUTPUT #1


INPUT #2

OUTPUT #2


INPUT #3

OUTPUT #3

*/


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

int main()
{
  int N;
  cin >> N;
  vector <int> value(N);
  for (int i=0; i<N; i++) {
    cin >> value[i];
  }

  sort(value.begin(), value.end());
  
  float sum=value[0];

  for (int i=1; i<N; i++) {
    sum = (sum + value[i])/2.0;
  }

  cout << sum << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
  //  cin>>t;
    while(t--){
        int per,n;

        cin>>per>>n;

          int ma=0;
        for(int i=1;i<=n;++i){
            cin>>a[i];
        }
        sort(a+1,a+n+1);

        int r1=a[n]-a[1];

        for(int i=2;i<=n;++i){
            ma=max(ma,a[i]-a[i-1]);
        }

        int r2 = r1 - ma + abs(per-a[n]) + a[1];


        printf("%d\n", min(r1,r2));
        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <numeric>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;

//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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;
}

// int a[10010][10010], b[1000];
// int dp[10010][3];

int S[10][1000];

void chAllVal(int before, int after, int h, int w) {
    rep(i, h * w) {
        if (S[i / w][i % w] == before) {
            S[i / w][i % w] = after;
        }
    }
}

int main() {

    ll N, A, B; cin >> N >> A >> B;
    cout << N/(A+B)*A + min(A, N%(A+B)) << endl;
    return 0;
}


Measured memory_bytes: 256