akhauriyash/Code-Regression huggingface dataset:
import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush
from math import sqrt, sin, cos, pi
from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm
# from bisect import bisect_left as bl, bisect_right as br, bisect
# from time import perf_counter
# from fractions import Fraction

# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353


def data(): return sys.stdin.readline().strip()


def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)


def l(): return list(sp())


def sl(): return list(ssp())


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


inf = 10 ** 20
n, m = sp()
graph = dd(set)
for i in range(m):
    u, v = sp()
    graph[u].add(v)
    graph[v].add(u)
dist = dd(lambda: inf)
dist[1] = 0
answer = dd(int)
vis = dd(lambda: False)
vis[1] = True
stack = deque()
stack.append(1)
while stack:
    temp = stack.popleft()
    for child in graph[temp]:
        if not vis[child]:
            stack.append(child)
            vis[child] = True
        if dist[child] > dist[temp] + 1:
            dist[child] = dist[temp] + 1
            answer[child] = temp
for i in range(1, n+1):
    if not vis[i]:
        out("No")
        exit()
out("Yes")
for i in range(2, n+1):
    out(answer[i])


Measured memory_bytes: 154172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,k,x,y=2,mod=1e9+7,a[4][55][55];
void gao(ll &z){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll t=0;
			for(int l=0;l<n;l++)
				(t+=a[x][i][l]*a[z][l][j])%=mod;
			a[z^1][i][j]=t;
		}
	}
	z^=1;
}
int main(){
	n=read(),k=read();
	for(int i=0;i<n;i++){
		a[2][i][i]=1;
		for(int j=0;j<n;j++)
			a[0][i][j]=read();
	}
	while(k){
		if(k&1)gao(y);
		if(k>>=1)gao(x);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			k+=a[y][i][j];
	print(k%mod);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
double n,m,goukei=0,wariai=0;
cin>>n>>m;
vector<double> tokuhyou(n);
double tokuhyouwariai=1/(4*m);
for (int i = 0; i < n; i++)
{
    cin>>tokuhyou.at(i);
    goukei+=tokuhyou.at(i);
}
sort(ALL(tokuhyou));
reverse(	ALL(tokuhyou));
double bunnbo=tokuhyou.at(m-1)/goukei;
if (tokuhyouwariai>tokuhyou.at(m-1)/goukei)
{
    cout<<"No"<<endl;
}

else if(tokuhyouwariai<=tokuhyou.at(m-1)/goukei)
{
     cout<<"Yes"<<endl;
}
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 112345;

int n, a[maxn];

int main() {
  scanf("%d", &n);
  FOR(i, 1, n) scanf("%d", a + i);
  sort(a + 1, a + n + 1);
  int j = 1;
  while (j + 1 < n && a[j + 1] < 0) j++;
  vector<pii> ops;
  FOR(i, j + 1, n - 1) {
    ops.eb(a[1], a[i]);
    a[1] -= a[i];
  }
  FOR(i, 1, j) {
    ops.eb(a[n], a[i]);
    a[n] -= a[i];
  }
  printf("%d\n", a[n]);
  for (auto it : ops) printf("%d %d\n", it._1, it._2);
}


Measured memory_bytes: 3188
from fractions import gcd
MOD = 10**9+7
N = input()
i = 0
arrs = list(map(int, input().split()))
result = 0
lcms = 1
for number in arrs:
    lcms = (((number * lcms)) //(gcd(number, lcms)))
for arr in arrs:
    result += (lcms//arr)
result = result%MOD
ans = str(result).replace('.0','')
print(ans)

Measured memory_bytes: 6200
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-21T10:41:52+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/
using Graph = vector<vector<int>>;
char table[8][8];

/**************************************/
bool func(vector<int> a, int num){
    int left = 0, right = a.size()-1;
    while(right>=left){
        int mid = (right + left) / 2;
        if(a[mid] == num) return true;
        else if(a[mid]< num) left = mid + 1;
        else right = mid - 1;
    }

    return false;
}

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  int q; cin >> q;
  vector<int> b(q);
  rep(i,q) cin >> b[i];

  int ans = 0;
  rep(i,q){
      if(func(a,b[i])) ans++;
  }

  cout << ans << endl;

  return 0;
}
/********  Main() Ends Here *************/



Measured memory_bytes: 3952
(stdin => {

  const identity = v => v
  const always   = v => _ => v
  const join     = sep => array => array.join(sep)
  const split    = sep => str => str.split(sep)
  const print  = fun => (f, v) => fun(f(v))

  // Define Function
  const power = m => n => Math.pow(n, m)

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const n = parseInt(inputs[0], 10)

  // Main
  const result = power(3)(n)

  // Display
  const display = print(console.log)
  display(identity, result)

})(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define int long long int
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define float long double
#define M 1000000007
int32_t main()
{
	int a,b,c;
	cin >> a >>b >> c;
	
	if(a==b || b==c || a==c)
	{
		if(a==b && b==c) cout<<"No\n";
		else cout << "Yes" ;
	}
	else cout<<"No\n";
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
 
def sum_count(A,B,x):
    # A,B is sorted. 
    # return count(a+b < x)
    p = len(B)-1
    result = 0
    for a in A:
        while p != -1 and a + B[p] >= x:
            p -= 1
        result += p+1
    return result
 
		
def f(t,A,B):
    power = (1<<t)
    AA = [x&(2*power-1) for x in A]
    BB = [x&(2*power-1) for x in B]
    AA.sort()
    BB.sort()
    
    x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
    zero_cnt = x1 + (x3-x2)
    return (N-zero_cnt)%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t
 
print(ans)

Measured memory_bytes: 139148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		while(true) {
			if(n % 10 == 1)cnt++;
			n /= 10;
			if(n == 0) break;
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 22864
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define MOD 1000000007
#define All(x) (x).begin(),(x).end()
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;

int main(void){
  int a,b;
  cin>>a>>b;
  if(a>b){
    REP(i,a)cout<<b;
  }else{
    REP(i,b)cout<<a;
  }
  cout<<endl;
}








Measured memory_bytes: 256
// atcoder/abc17173/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int h, w, k;
  while (cin >> h >> w >> k) {
    const int N = 6 + 1;
    char g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, '@');
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }
    int x = 0;
    for (int bith = 0; bith < (1 << h); ++bith) {
      for (int bitw = 0; bitw < (1 << w); ++bitw) {
        int cnt = 0;
        for (int i = 0; i < h; ++i) {
          for (int j = 0; j < w; ++j) {
            if (bith & (1 << i)) continue;
            if (bitw & (1 << j)) continue;
            cnt += (g[i][j] == '#');
          }
        }
        x += (cnt == k);
      }
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define LL long long
#define M 1000005 
using namespace std;
const int P=1e9+7;
int A[M];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	int ans=0; 
	sort(A+1,A+n+1);
	int m=n/2;
	if(A[m]!=A[m+1])ans=A[m+1]-A[m];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;


int digit(int x){
    int ans = 0;
    while(x > 0){
        ans += x%10;
        x /= 10;
    }
    return ans;
}


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

    if(n%digit(n) == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i=0; i<M; i++) cin >> a[i] >> b[i];

    vector<int> cnt(N+1, 0);
    for(int i=0; i<M; i++)
    {
        cnt[a[i]]++;
        cnt[b[i]]++;
    }
    string ans = "YES";
    for(auto num : cnt)
    {
        if(num%2==1) ans = "NO";
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4520
#include<stdio.h>

int solve(int, int);

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", solve(a, b));
    return 0;
}

int solve(int x, int y) {
    int diff = y - x;
    int h_r = 0;
    while(diff > 0) {
        h_r += diff;
        diff--;
    }
    return h_r - y;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CChocolateBar solver = new CChocolateBar();
        solver.solve(1, in, out);
        out.close();
    }

    static class CChocolateBar {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long h = in.nextInt(), w = in.nextInt();

            if (h * w % 3 == 0) {
                out.println(0);
                return;
            }

            long ans = Math.min(h, w);
            for (int x = 0; x <= w; x++) {
                long s1 = (w - x) * h;
                long s2 = x * (h / 2);
                long s3 = x * ((h + 1) / 2);
                ans = Math.min(ans, Math.max(s1, s3) - Math.min(s1, s2));
            }
            for (int y = 0; y <= h; y++) {
                long s1 = w * (h - y);
                long s2 = (w / 2) * y;
                long s3 = ((w + 1) / 2) * y;
                ans = Math.min(ans, Math.max(s1, s3) - Math.min(s1, s2));
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21844
void main() {
    int n = readln.chomp.to!int;
    int[] p = new int[n];
    foreach (i; 0 .. n) {
        p[i] = readln.chomp.to!int;
    }
    writeln(p.sum - p.reduce!max / 2);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

using namespace std;

int main(){
  long long N;
  long long M;
  cin >> N >> M;
  vector<long long> A(N);
  for(long long i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  
  
  vector<long long> s(200002, 0ll);
  for(long long i = 0; i < N; i++) s[A[i]] += 1ll;
  for(long long i = 200002; i > 0; i--) s[i - 1] += s[i];
  
  
  vector<long long> sum(N + 1);
  sum[N] = 0ll;
  for(int i = N - 1; i >= 0; i--) sum[i] = A[i] + sum[i + 1];
  
  
  long long ng = 200001ll;
  long long ok = 0ll;
  while(ng - ok > 1ll){
    long long mid = (ok + ng) / 2ll;
    long long cnt = 0;
    for(long long i = 0ll; i < N; i++) cnt += s[max(mid - A[i], 0ll)];
    (cnt >= M ? ok : ng) = mid;
  }
  
  
  long long happiness = 0ll;
  
  for(long long i = 0; i < N; i++){
    long long cnt = s[max(ng - A[i], 0ll)];
    happiness += cnt * A[i] + sum[N - cnt];
    M -= cnt;
  }
  
  happiness += M * ok;
  
  
  cout << happiness << endl;
  
  return 0;
}



Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
n = int(input())

# スペース区切りの入力
#n, x = input().split()

# スペース区切りの整数の入力
#a, b = map(int, input().split())
#n, x = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
p = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#print("a", a, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#b = []
#for x in range(m):
#  b.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def ton(n, k, x):
  s = ""
  while n > 0:
    s = str(n%k) + s
    n //= k
  return s


#print("a", a, file=sys.stderr)
#print("b", b, file=sys.stderr)

def getEnergy():
  for y in b:
    yield y

def doit():
  ng = 0
  for i in range(n):
    if i + 1 != p[i]:
      ng += 1
  
  print("", ng, file=sys.stderr)
  return ng == 0 or ng == 2

def yn():
  if doit():
    return "YES"
  else:
    return "NO"

#print(doit([0] * 4))
#doit(a)
#print(doit())
try:
  #doit()
  #print(doit())
  print(yn())
except Exception as e:
  print("e", e, file=sys.stderr)


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

int main(){
  int n; cin >> n;
  int b[n-1];
  int c=0;
  for (int i=0;i<n-1;i++){
    cin>>b[i];
    if (i > 0){
      c += min(b[i-1],b[i]);
    }
  }
  //cout << c << " " << b[0] << " " << b[n-2] <<endl;
  cout << c+b[0]+b[n-2] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  if (n >= k * 2 - 1) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
typedef pair<ll, l_l> lll;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<l_l> ans;
    ll num = (M + 1) / 2;
    for(int i = 0; i < num; i++) {
        ans.push_back({num - 1 - i, num + i});
    }
    ll rest = M - num;
    for(int i = 0; i < M - num; i++) {
        ans.push_back({2*num+rest-1-i, 2*num+rest+1+i});
    }
    for(auto tmp : ans) {
        cout << tmp.first + 1 << " " << tmp.second + 1 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

void solve(){
    string s;
    cin >> s;

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

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe
import           Data.Ord
import qualified Data.Array                    as A
import qualified Data.Array.Unboxed            as AU
import qualified Data.Array.IO                 as AIO



getvuil :: IO (VU.Vector Int)
getvuil = VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readi :: BSC8.ByteString -> Int
readi = fst . fromJust . BSC8.readInt
readil :: BSC8.ByteString -> [Int]
readil = map readi . BSC8.words
geti :: IO Int
geti = readi <$> BSC8.getLine
getil :: IO [Int]
getil = readil <$> BSC8.getLine

getNis :: Int -> IO [(Int, BSC8.ByteString)]
getNis 0 = return []
getisl n = do
    [aFst, aSnd] <- BSC8.words <$> BSC8.getLine
    next         <- (getisl (n - 1))
    return ((readi aFst, aSnd) : next)

il2ss :: [Int] -> String
il2ss = unwords . map show

il2sn :: [Int] -> String
il2sn = unlines . map show

main :: IO ()
main = do
    [aN, aA, aB] <- getil
    let set  = div aN (aA + aB)
        modi = mod aN (aA + aB)

    print (set * aA + (min modi aA))




Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll x;
    cin >> x;
    cout << (x/11)*2 + ((x%11==0)?0:((x%11<=6)?1:2));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double db;
typedef vector<ll> VI;
typedef vector<pair<ll,ll> > VII;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
//
#define M 1000000007
#define INF (ll)0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define itr iterator
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void fileioe(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout); 
	freopen("error.txt","w",stderr);
}

void error_out() { cerr << endl; }
template <typename Head, typename... Tail>
void error_out(Head H, Tail... T) {
  cerr << " " << H;
  error_out(T...);
}
void time_elapsed(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}
#ifndef ONLINE_JUDGE
#define error(...) cerr << "[" << #__VA_ARGS__ << "]:", error_out(__VA_ARGS__)
#define fioe() fileioe()
#define time() time_elapsed()
#else
#define error(...) 1
#define fioe() 1
#define time() 1
#endif


//
int main()
{
	GO
	//fioe();
	ll n,k;
	cin>>n>>k;
	ll arr[n+3];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+n,greater<ll>());
	ll ans=0;
	for(ll i=k;i<n;i++){
		ans+=arr[i];
	}
	cout<<ans<<endl;
	time();
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll mod = 1e9 + 7;

const ll INF = 1e15;

int main() {
	ll n, c;
	cin >> n >> c;
	vector<ll> xs(n,0);
	vector<ll> vs(n,0);
	rep(i, n) {
		cin >> xs[i];
		cin >> vs[i];
	}
	vector<ll> left(n + 1, 0);
	vector<ll> right(n + 1, 0);
	rep(i, n) {
		left[i + 1] = left[i] + vs[i];
		right[i + 1] = right[i] + vs[n-1-i];
	}
	ll u = 0;
	rep(i, n) {
		u = max(u, left[i + 1] - xs[i]);
		u = max(u, right[i + 1] - c + xs[n-1-i]);
	}
	{
		map<ll, ll> ms;
		rep(i, n) {
			ms[left[i + 1] - xs[i]]++;
		}
		rep(i, n) {
			auto key = left[n - i] - xs[n-i-1];
			ms[key]--;
			if (!ms[key]) {
				ms.erase(key);
			}
			ll a = 0;
			if (ms.size()) {
				a = ms.rbegin()->first;
			}
			auto add = right[i + 1] - 2 *(c - xs[n - 1 - i]);
			a += add;
			u = max(u, a);
		}
	}

	{
		map<ll, ll> ms;
		rep(i, n) {
			ms[right[i + 1] - c + xs[n - 1 - i]]++;
		}
		rep(i, n) {
			auto key = right[n - i] - c + xs[i];
			ms[key]--;
			if (!ms[key]) {
				ms.erase(key);
			}
			ll a = 0;
			if (ms.size()) {
				a = ms.rbegin()->first;
			}
			auto add = left[i + 1] - 2 * (xs[i]);
			a += add;
			u = max(u, a);
		}
	}
	cout << u << endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)))
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
int n,kw;
int w;
ll v;
ll dp[105][100005];
/*---main code---*/

int main()
{
	FIO;
	FILL(dp,-1);
	dp[0][0]=0;
	cin>>n>>kw;
	for(int i=0;i<n;i++)
	{
		cin>>w>>v;
		for(int j=0;j<=kw;j++)
		{
			if(dp[i][j]!=-1)
			{
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				if(j+w<=kw)
				{
					dp[i+1][j+w]=max(dp[i+1][j+w],dp[i][j]+v);
				}
			}
		}
	}	
	ll ans=INT_MIN;
	for(int j=0;j<=kw;j++)
	{
		ans=max(ans,dp[n][j]);
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> input;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		input.push_back(tmp);
	}

	int count = 0;
	for (int i = 0; i < n; i++) {
		if (input[i] % 2 == 0) {
			if ((input[i] % 3 != 0) && (input[i] % 5 != 0)) {
				count++;
			}
		}
	}
	if (count == 0) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}

	return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 1;
  int cnt = 0;
  while(cnt < n){
    if(ans * 2 < ans + k){
      ans *= 2;
    }
    else{
      ans += k;
    }
    cnt++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==0)
	{
		cout<<"1"<<endl;
	}
	else
	{
		cout<<"0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<string.h>
int main(){
    int n, i;
    char num[6],a[] = "3",*b;
    scanf("%d",&n);

    for( i = 1; i <= n; i++ ){
        if( i % 3 == 0 ){
            printf(" %d",i);
        }else{
            sprintf( num,"%d",i );
            b = strstr( num, a );
            if( b != NULL ){
                printf(" %d",i);
            }
        }
    }
  printf("\n");
  return 0;
}

Measured memory_bytes: 620
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp = 0
for i in range(1, n):
    if h[i - 1] >= h[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 14224
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>

using ll = long long;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    int count = C - (A - B);
    if(count < 0) count = 0;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        int input;
        cin >> input;
        a.at(i) = input - 1;
    }

    int cnt = 0;
    rep(idx, n) {
        // rabbit i loves a.at(idx)
        int i = a.at(idx);

        // rabbit j loves a.at(idx)
        int j = a.at(i);
        if (idx == j && i < j)
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
using namespace std;

int ans;

struct A{
	int x;
	int y;
}a[10];

bool cmp(A p,A q){
	return p.y>q.y;
} 

int main(void){
	for(int i=1;i<=5;i++){
		scanf("%d",&a[i].x);
		if(a[i].x%10!=0)
		a[i].y=a[i].x%10;
		else a[i].y=10;
	}
	sort(a+1,a+1+5,cmp);
	for(int i=1;i<=5;i++){
		ans=(ans+9)/10*10;
		ans+=a[i].x;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));

int main(){
	int arr[3];
	cin>>arr[0]>>arr[1]>>arr[2];
	sort(arr,arr+3);
	int sum=0;
	sum+=(arr[2]-arr[0])/2;
	arr[0]+=(arr[2]-arr[0])/2*2;
	sum+=(arr[2]-arr[1])/2;
	arr[1]+=(arr[2]-arr[1])/2*2;
	sort(arr,arr+3);
	if(arr[0]==arr[2]){
		cout<<sum<<endl;
	}
	else{
		if(arr[0]==arr[1]){
			cout<<sum+1<<endl;
		}
		else{
			cout<<sum+2<<endl;
		}
	}
} 

Measured memory_bytes: 256
#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;
const double PI = acos(-1);
const double EPS = 1e-9;
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 V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp((1 << V), vector<int>(V, INF));
	dp[(1 << V) - 1][0] = 0;
	for (int bits = (1 << V) - 1 - 1; bits >= 0; bits--) {
		rep(i, 0, V) {
			rep(j, 0, V) {
				if (!(bits&(1 << j)))chmin(dp[bits][i], dp[bits | (1 << j)][j] + G[i][j]);
			}
		}
	}
	cout << (dp[0][0] == INF ? -1 : dp[0][0]) << endl;
	return 0;
}

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

int N,P;
long long ans = 1;

int main()
{
    scanf("%d%d",&N,&P);
    for(int i = 0; i < N; i++)
    {
        int A;
        scanf("%d",&A);
        if(A & 1)
        {
            for(int j = 0; j < N - 1; j++)ans *= 2;
            printf("%lld\n",ans);return 0;
        }
    }
    if(P){printf("0\n");return 0;}
    for(int i = 0; i < N; i++)ans *= 2;
    printf("%lld\n",ans);
    return 0;
}


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

constexpr int INF = 1e9;

struct edge {
    int to, cost, time, r;
};

using edges = vector<edge>;
using graph = vector<edges>;

int main() {
    int N, M, H, K;
    while(cin >> N >> M >> H >> K, N) {
        graph g(N);
        for(int i=0; i<M; ++i) {
            int a, b, c, h, r;
            cin >> a >> b >> c >> h >> r;
            a--; b--; r--;
            g[a].push_back(edge{b, c, h, r});
            g[b].push_back(edge{a, c, h, r});
        }
        int S, T;
        cin >> S >> T;
        S--; T--;
        int P;
        cin >> P;
        vector<int> cost(1 << K, 1e9);
        cost[0] = 0;
        for(int i=0; i<P; ++i) {
            int ticket = 0;
            int l, d;
            cin >> l >> d;
            for(int j=0; j<l; ++j) {
                int k = 0;
                cin >> k;
                ticket |= (1 << (k-1));
            }
            for(int j=0; j<(1 << K); ++j) {
                cost[j | ticket] = min(cost[j | ticket], cost[j] + d);
            }
        }

        int res = INF;
        for(int b=0; b<(1<<K); ++b) {
            vector<vector<int>> d(H+1, vector<int>(N, INF));
            d[0][S] = 0;
            using state = tuple<int, int, int>;
            priority_queue<state, vector<state>, greater<state>> que;
            que.push(make_tuple(0, 0, S));
            while(!que.empty()) {
                int cd, ct, v;
                tie(cd, ct, v) = que.top();
                que.pop();
                if(d[ct][v] < cd) {
                    continue;
                }
                for(auto& e : g[v]) {
                    int c = (b & (1 << e.r) ? 0 : e.cost);
                    int nt = ct + e.time;
                    if(nt > H) {
                        continue;
                    }
                    if(d[nt][e.to] > d[ct][v] + c) {
                        d[nt][e.to] = d[ct][v] + c;
                        que.push(make_tuple(d[nt][e.to], nt, e.to));
                    }
                }
            }
            int mi = INF;
            for(int i=0; i<=H; ++i) {
                mi = min(mi, d[i][T]);
            }
            res = min(res, cost[b] + mi);
        }

        cout << (res == INF ? -1 : res) << endl;
    }
}


Measured memory_bytes: 3204
#include <iostream>
using namespace std;
int main()
{
    int x1, x2, x3, x4, y1, y2, y3, y4; 
    cin >> x1 >> y1 >> x2 >> y2; 
    x3 = x2 + y1 - y2; 
    y3 = y2 - x1 + x2; 
    x4 = x3 - x2 + x1; 
    y4 = y3 - y2 + y1; 
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
    
        BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(std.readLine());
        StringBuilder input = new StringBuilder();
        
        int num = 0;
        
        for(int j = 3; j <= n; j++){
            if(j % 3 == 0){
                input.append(" "+j);
            } else {
                num = j;
                while(num != 0) {
                    if(num %10 == 3){
                        input.append(" "+j);
                        break;
                    } else {
                        num = num /10;
                    }
                }
            }
        }
        System.out.println(input);
    }

}

Measured memory_bytes: 25584
#include<stdio.h>
int main(void){
	int n,i,j,c;
	long long int a[10000],b=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		b+=a[i];
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(a[i]<a[j]){
				c=a[i];
				a[i]=a[j];
				a[j]=c;
			}
		}
	}
	printf("%lld %lld %lld\n",a[0],a[n-1],b);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = ll(b)-1; i >= (a); i--)
#define MAPIT(i,c,k) for (auto i = (c).equal_range((k)).first; i!= (c).equal_range((k)).second; i++)

#define sz(c) ll((c).size())
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second
#define has(c, i) ((c).find(i) != (c).end())
#define DBG(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);

	string c[3], B, C;
	cin >> c[0] >> c[1] >> c[2];

	int n[3];
	n[0] = n[1] = n[2] = 0;

	int act = 0;
	while(1){
		if(n[act] >= sz(c[act])){
		   cout << char(act+'A') << endl;
		   break;
		}
		char ne = c[act][n[act]];
		n[act]++;
		act = ne-'a';
	}
}

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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)

int main(){
    string a, b;
    cin >> a >> b;

    if(b.substr(0, a.size()) == a) cout << "Yes" << endl;
    else cout << "No" << endl;

}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define rev(a) reverse(all(a))
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mod 1000000007
#define inf 100000000
#define limit 200005
#define minval -100000000000000000
#define maxval 1000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
void input()
{
    str s, t;
    cin >> s >> t;
    int ns = s.length(), nt = t.length();

    int ans = ns+1;
    rep(i,ns-nt+1)
    {   
        int ans_ = 0;
        str ss = s.substr(i,nt);
        rep(j,nt)
            ans_ += (ss[j] != t[j]);
        ans = min(ans, ans_);
    }
    cout << ans << '\n';
}
int main()
{
   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   */
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}


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

using namespace std;

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

// 46786 - 106

vector<vector<int>> ed(56);
vector<int> tin(56, -1);
vector<int> tup(56, -1);
int timer = 0;
int b = 0;

void dfs(int node, int p = -1) {
    tin[node] = timer;
    tup[node] = timer;
    ++timer;
    for (auto out : ed[node]) {
        if (out == p) {
            continue;
        }
        if (tin[out] != -1) {
            tup[node] = min(tup[node], tin[out]);
        } else {
            dfs(out, node);
            tup[node] = min(tup[node], tup[out]);
            if (tup[out] > tin[node]) {
                ++b;
            }
        }
    }
}


void oneCase() {
   int n, m;
   cin >> n >> m;
   for (int i = 0; i < m; ++i) {
       int a, b;
       cin >> a >> b;
       --a;
       --b;
       ed[a].pb(b);
       ed[b].pb(a);
   }
   dfs(0);
   cout << b << "\n";


}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n; 
  scanf("%d", &n);
  char s[101];
  scanf("%s", s);
  int same[26] = {0};
  int count = 0;
  int ans = 0;
  
  for(int k = 0; k < n; k++){  
    for(int i = 0; i <= k; i++){
      for(int j = n - 1; j > k; j--){
        if(same[s[i] - 'a'] == 0 && s[i] == s[j]){ 
          count++;
          same[s[i] - 'a']++;
        }
      }
    }
    if(ans < count) ans = count;
    count = 0;
    for(int x = 0; x < 26; x++){
      same[x] = 0;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

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

typedef std::pair <double, int> pr;

pr que[500054];

inline int min(const int x, const int y) {return x < y ? x : y;}

int main() {
	int w, v, h = 0, t = 0, q, Vol, V = 0, delta; double W = 0.;
	for (scanf("%d%d", &q, &Vol); q; --q) {
		scanf("%d%d", &w, &v);
		for (; V + v > Vol; )
			delta = min(V + v - Vol, que[h].second),
			V -= delta, que[h].second -= delta,
			W -= que[h].first * delta, h += !que[h].second;
		printf("%.12lg\n", (W += (double)w * v) / Vol), V += v, que[t++] = pr(w, v);
		for (; h + 1 < t && que[t - 2].first >= que[t - 1].first; --t)
			que[t - 2].second += que[t - 1].second,
			que[t - 2].first -= (que[t - 2].first - que[t - 1].first) * que[t - 1].second / que[t - 2].second;
	}
	return 0;
}

Measured memory_bytes: 14848
n = gets.to_i
a = gets.split.map(&:to_i)
m = 1000


b = 0
s = 0
for i in 1...a.size do
  if a[b]<a[i]&&(i==a.size-1||a[i+1]<a[i])
    s = i
    num = m/a[b]
    m = m-(a[b]*num)+(a[i]*num)
    b = i+1
  elsif a[b]>a[i]
    b = i
  end
end

puts m

Measured memory_bytes: 14344
a = []
for _ in range(3):
    a += list(map(int, input().split()))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a[i] == b:
            a[i] = 0

# print(a)
for i in range(3):
    if sum(a[i*3:i*3+3]) == 0:
        print('Yes')
        exit()
    if sum(a[i:9:3]) == 0:
        print('Yes')
        exit()

if (a[0] + a[4] + a[8]) == 0:
    print('Yes')
    exit()
if (a[2] + a[4] + a[6]) == 0:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 9140
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	int a[100];
	scanf("%d",&n);
	int i,sum;
	sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int ans=0,ans2=0;
	for(i=0;i<n;i++){
		ans+=(sum/n-a[i])*(sum/n-a[i]);
		ans2+=(sum/n-a[i]+1)*(sum/n-a[i]+1);
	}
	if(ans<ans2){
		printf("%d\n",ans);
	}else{
		printf("%d\n",ans2);
	}
	return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;


int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	int firi = 0;
	int fir = 0, sec = 0;
	rep(i, n) if (fir <= a[i]) {
		fir = a[i];
		firi = i;
	}

	double hoge = (double)fir / 2;

	ll min = INF;
	rep(i, n) if (abs(a[i] - hoge) <= min) {
		if (i == firi)continue;
		min = abs(a[i] - hoge);
		sec = a[i];
	}

	cout << fir << " " << sec << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] S = sc.next().split("");
		String[] T = sc.next().split("");
		int answer = 0;

		for (int i = 0; i < S.length; i++) {
			if (S[i].equals(T[i])) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=998244353;


int R[MX];
ll dp[MX][3][2][3][2], n;

ll call(int p, int a, int b, int x, int y)
{
    if(p>n) return 0;
    if(~dp[p][a][b][x][y]) return dp[p][a][b][x][y];

    ll sm=R[p]+call(p+2, a, b, x, y);
    if(x && a<x && !b) sm=max(sm, R[p]+call(p+3, a+1, b, x, y));
    if(y && b<y && x && !a) sm=max(sm, R[p]+call(p+4, a, b+1, x, y));
    return dp[p][a][b][x][y]=sm;
}

int main()
{
    FasterIO;

    cin>>n;
    for(int i=1; i<=n; i++) cin>>R[i];

    mem(dp, -1);
    ll sm;
    if(n&1) sm=max({call(1, 0, 0, 2, 1), call(2, 0, 0, 1, 0), call(3, 0, 0, 0, 0)});
    else    sm=max(call(1, 0, 0, 1, 0), call(2, 0, 0, 0, 0));
    cout<<sm<<endl;

    return 0;
}


Measured memory_bytes: 293500
import java.util.*;
public class Main {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    
	    int N=sc.nextInt();	    
	    int M=sc.nextInt();	    
	    int C=sc.nextInt();
	    
	    int[] B=new int[M];
	    int[][] A=new int[N][M];
	    
	    int sum;
	    int ans=0;
	    for(int i=0;i<M;i++) {
	    	B[i]=sc.nextInt();
	    }
	    
	    for(int i=0;i<N;i++) {
	    	for(int j=0;j<M;j++) {
		    	A[i][j]=sc.nextInt();
		    }
	    }
	    
	    for(int i=0;i<N;i++) {
	    	sum=0;
	    	for(int j=0;j<M;j++) {
		    	sum+=A[i][j]*B[j];
		    }
	    	sum+=C;
	    	if(sum>0) {
	    		ans++;
	    	}
	    }
	    
	    System.out.println(ans);
	    

	}

}

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

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: usize = read();
    let k: usize = read();

    let mut h: Vec<usize> = Vec::new();
    for i in 0..n { h.push(read()); }
    h.sort();

    let mut s = 0;
    if n > k { for i in 0..n-k { s += h[i]; } }

    println!("{}", s);
}


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

int main(){
  string s;
  cin >> s;
  
  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }
  
  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  
  else{
    cout << "Sunny" << endl;
  }
  
}

Measured memory_bytes: 256
package main

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

/*-----------Main-----------*/

func main() {
	maxS, k := readI(), readI()
	a := readIs(maxS)

	for semester := k + 1; semester <= maxS; semester++ {
		if a[semester-k-1] < a[semester-1] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 6192