akhauriyash/Code-Regression huggingface dataset:
a,b,c = map(int,input().split())

if a < b:
    if a < c:
        one = a
        if b < c:
            two = b
            three = c
        else:
            two = c
            three = b
    else:
        one = c
        two = a
        three = b
else:
    if b < c:
        one = b
        if a < c:
            two = a
            three = c
        else:
            two = c
            three = a
    else:
        one = c
        two = b
        three = a

print("{0} {1} {2}".format(one,two,three))

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int x, y;
    cin >> x >> y;
    vector<char> px(16100), py(16100);
    x += 8000;
    y += 8000;
    size_t idx = 0;
    while(idx < s.size() && s[idx] == 'F'){ idx++; }
    px[8000 + idx] = true;
    py[8000] = true;
    auto move = [&](vector<char>& p, int num){
        vector<char> p2(16100, 0);
        for(int i = 0; i < 16100; i++){
            if(p[i]){
                p2[i + num] = p2[i - num] = true;
            }
        }
        p.swap(p2);
    };
    while(idx < s.size()){
        idx++;
        int num = 0;
        while(idx < s.size() && s[idx] == 'F'){ num++; idx++; }
        move(py, num);
        idx++;
        num = 0;
        while(idx < s.size() && s[idx] == 'F'){ num++; idx++; }
        move(px, num);
        // printd(px);
        // printd(py);
    }
    cout << (px[x] && py[y] ? "Yes" : "No") << '\n';
}


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

int main()
{
    int a1[] = {1,3,5,7,8,10,12};
    int a2[] = {4,6,9,11};
    int a, b, c1 = 0, c2 = 0;
    cin >> a >> b;

    for(int i = 0; i < 7; i++)
    {
        if(a1[i] == a || a1[i] == b) c1++;
    }
    for(int i = 0; i < 4; i++)
    {
        if(a2[i] == a || a2[i] == b) c2++;
    }

    if(a == 2 && b == 2) cout << "Yes" << endl;
    else if(c1 == 2 || c2 == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        if(N==1){
            System.out.println(1);
        }else{
            int ans =0;
            for (int i=2;i<=N;i=i*2){
                ans=i;
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n,m,d;
int main()
{
	scanf("%d%d%d",&n,&m,&d);
	if(d) printf("%.7f\n",1.0*(n*2-d*2)*(m-1)/n/n);
	else printf("%.7f\n",1.0*n*(m-1)/n/n);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) {
   if (a < b) {
      a = b;
      return 1;
   }
   return 0;
}
template<class T>bool chmin(T &a, const T &b) {
   if (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

ll gcd (ll a, ll b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll A, B;

int main()
{
   cout << fixed << setprecision(10);
   cin >> A >> B;
   cout << A * B / gcd(A, B) << endl;
   return 0;
}



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

using namespace std;

int main()
{
    int N, A[200005], dp[1000005] = {0};

    cin >> N;
   
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    for (int i = 1; i <= N; i++) {
        if (dp[A[i]] != 0) {
            dp[A[i]] = 2;
            continue;
        }
        for (int j = A[i]; j <= 1000000; j += A[i]) {
            dp[j]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (dp[A[i]] == 1) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8324
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	s := IOInitialize()
	str1 := String(s)
	str2 := String(s)
	str3 := String(s)
	str1s := strings.Split(str1, "")
	str2s := strings.Split(str2, "")
	str3s := strings.Split(str3, "")
	fmt.Println(fmt.Sprintf("%s%s%s", str1s[0], str2s[1], str3s[2]))
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}


Measured memory_bytes: 640
open Batteries

module IntSet = Set.Make (struct
  let compare = Pervasives.compare

  type t = int
end)

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

let rec read_list_nl n =
  if n = 0 then [] else (read_line () |> int_of_string) :: read_list_nl (n - 1)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f d a n = if n > d then 0 else 1 + f d a (n + a)

let rec total acc = function [] -> acc | x :: rest -> total (acc + x) rest

let () =
  let a, b, m = read_three () in
  let fs = read_list () |> Array.of_list
  and bs = read_list () |> Array.of_list in
  let min_f =
    Array.fold_left (fun acc x -> if acc > x then x else acc) 100000000 fs
  and min_b =
    Array.fold_left (fun acc x -> if acc > x then x else acc) 100000000 bs
  in
  let ans = ref (min_f + min_b) in
  for i = 1 to m do
    let x, y, c = read_three () in
    let now = fs.(x - 1) + bs.(y - 1) - c in
    ans := min !ans now
  done;
  print_int !ans;
  print_newline ()


Measured memory_bytes: 17536
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  ll z, w;
  ll a[MAX];

  cin >> n >> z >> w;

  FOR(i, 0, n) {
	cin >> a[i];
  }

  n == 1 ? ans = llabs(a[0] - w) : ans = max(llabs(a[n - 1] - w), llabs(a[n - 1] - a[n - 2]));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# Problem A - DDCC Finals

# input process
X, Y = map(int, input().split())

# initialization
cost_ans = 0

if X==1:
    cost_ans += 300000
elif X==2:
    cost_ans += 200000
elif X==3:
    cost_ans += 100000

if Y==1:
    cost_ans += 300000
elif Y==2:
    cost_ans += 200000
elif Y==3:
    cost_ans += 100000

if X==1 and Y==1:
    cost_ans += 400000

print(cost_ans)


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

typedef long long lnt;

const int N = 4e5 + 10;

struct T { int k, v; };

T a[N], b[N];

#define lson st, (st + en) >> 1, rt << 1
#define rson ((st + en) >> 1) + 1, en, rt << 1 | 1

// struct {

int x[N << 2];

void pu (int rt) {
	x[rt] = min(x[rt << 1 | 1], x[rt << 1]);
}

void modify (int p, int v, int st, int en, int rt) {
	if (st == en) { x[rt] = 1; return; }
	if (p <= ((st + en) >> 1)) modify(p, v, lson);
	else modify(p, v, rson);
	pu(rt);
}

int query (int l, int r, int st, int en, int rt) {
	if (l > en || r < st) return 1;
	if (l <= st && en <= r) return x[rt];
	return min(query(l, r, lson), query(l, r, rson));
}

void build (int st, int en, int rt) {
	x[rt] = 0;
	if (st == en) return;
	build(lson); build(rson); pu(rt);
}

// } st;

lnt solve (T * a, int n) {
	if (n == 0) return 0;
	sort(a + 1, a + n + 1, [&](T x, T y){
		if (x.v != y.v) return x.v > y.v;
		return x.k > y.k;
	});
	lnt ret = 0;
	build(1, n, 1);
	for (int i = 1; i <= n; i ++) {
		int st = 1, en = a[i].k;
		if (a[i].k > n) {
			ret += a[i].v;
			continue;
		}
		if (a[i].k == 0) 
			continue;
		if (query(st, en, 1, n, 1) != 0) 
			continue;
		while (st != en) {
			int md = (st + en) >> 1;
			if (query(md + 1, en, 1, n, 1) == 0)
				st = md + 1;
			else 
				en = md;
		}
		ret += a[i].v;
		modify(st, 1, 1, n, 1);
		// cout << st << "!!" << endl;
	}
	return ret;
}

int main (void) {
	int kase;
	scanf("%d", &kase);
	while (kase --) {
		int n;
		scanf("%d", &n);

		lnt sum = 0;
		int na = 0, nb = 0;
		for (int i = 1, k, l, r; i <= n; i ++) {
			scanf("%d%d%d", &k, &l, &r);
			sum += min(l, r);
			if (l > r)
				a[++ na] = { k, l - r };
			else if (r > l)
				b[++ nb] = { n - k, r - l };
		}
		// cout << na << " " << sum << endl;
		sum += solve(a, na);
		// cout << nb << " " << sum << endl;
		sum += solve(b, nb);
		// cout << sum << endl;
		printf("%lld\n", sum);
	}
}

Measured memory_bytes: 6392
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

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

func main() {
	a, b, c := readInt(), readInt(), readInt()
	switch {
	case a == b && b == c:
		fmt.Println("No")
	case a == b || b == c || c == a:
		fmt.Println("Yes")
	default:
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: i64,
    }
    let t:i64 = (n as i64-1)*(n as i64-2)/2 - k;
    if t<0 {
        println!("-1");
    }else{
        // star
        println!("{}", n as i64+t-1);
        for i in 0..n-1 {
            println!("{} {}", 1, i+2);
        }
        // star bridge
        let mut count = 0;
        for i in 2..n+1 {
            for j in 2..n+1 {
                if i >= j {
                    continue;
                }
                if count >= t {
                    continue;
                }
                println!("{} {}", i ,j);
                count+=1;
            }
        }
    }
}

Measured memory_bytes: 4352
N = int(input())
S = []
T = []

for _ in range(N):
    s, t = input().split()
    S.append(s)
    T.append(int(t))
x = input()

C = [0] * (N+1)
for i in range(N):
    C[i+1] = C[i] + T[i]

print(C[N] - C[S.index(x)+1])

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

int main(){
  int a,b,c,a2,b2;
  while(cin>>a>>b){
    a2=a;
    b2=b;
    while(1){
      if(a2%b2==0)break;
      else {
	c=a2%b2;
	a2=b2;b2=c;
      }
    }
    c=b2;
    c*=a/b2;
    c*=b/b2;
    cout <<b2<<" "<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 20;
int main()
{
  int n,m,a,c,t,i,j,res=0;
  int b[N_MAX];
  cin >> n >> m >> c;
  for(i=0;i<m;i++)
    cin >> b[i];
  for(i=0;i<n;i++){
    t=c;
    for(j=0;j<m;j++){
      cin >> a;
      t+=a*b[j];
    }
    if(t>0) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
N= input()
x=int(N)
if x<1000:
    print(1000-x)
if x==1000:
    print(0)
if x > 1000:   
    while True: #0 1 2 4 5が出力される
	    x -= 1000
	    if x < 1001:
		    break      
    print(1000-x)


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

int main(){
	int n,a,b,c,d,x,y,x1,y1;
	cin>>n>>a>>b>>c>>d;
	x=y=x1=y1=0;
	while(x<n){
		x+=a;
		x1++;
	}
	while(y<n){
		y+=c;
		y1++;
	}
	if(x1*b<=y1*d) cout<<x1*b<<endl;
	else cout<<y1*d<<endl;
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    long long H;
    long long ans = 0;
    cin >> H;
    for(int i=0;H > 0;i++){
        H /= 2;
        long long num = 1;
        num = num << i;
        ans += num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define f first
#define s second
#define mp make_pair
#define pb push_back
int mod;
int power(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
unordered_map<int, int> cnt;
int32_t main(){
	int n;
    cin >> n;
    vector<int> v(n);
    rep(i,0,n)
    {
        cin >> v[i];
        ++cnt[v[i]];
    }
    int total =0;
    for(auto&p : cnt)
    {
        long long m = p.s;
        total += m*(m-1)/2;
    }
    rep(i,0,n)
        cout << total-cnt[v[i]]+1<< endl;
    return 0;
}



Measured memory_bytes: 10568
from collections import deque

N = int(input())
tree = [[0, 0] for _ in range(N+1)] # [parent, depth(e or o)]
edge = [set() for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edge[a].add(b)
    edge[b].add(a)

queue = deque([1])
d, even_or_odd = 1, [1, 0]
while len(queue) > 0:
    newq = set()
    for _ in range(len(queue)):
        p = queue.pop()
        for q in edge[p]:
            if q != tree[p][0]:
                newq.add(q)
                tree[q][0], tree[q][1] = p, d % 2
    even_or_odd[d % 2] += len(newq)
    d += 1
    queue = deque(list(newq))

stock = [N//3] * 3
for i in range(N%3):    stock[i] += 1

if min(even_or_odd) > N//3:
    i, j, k, ans = 0, 0, 1, []
    for l in range(1, N+1):
        if tree[l][1] == 0 and i <= stock[0] - 1:
            ans.append(3*i + 1)
            i += 1
        elif tree[l][1] != 0 and j <= stock[1] - 1:
            ans.append(3*j + 2)
            j += 1
        else:
            ans.append(3*k)
            k += 1
elif even_or_odd[0] <= stock[0] - 1:
    ans, num = [], [3*i for i in range(1, N//3 + 1)] + [i for i in range(N+1) if i % 3 != 0]
    i, j = 0, -1
    for k in range(1, N+1):
        if tree[k][1] == 0:
            ans.append(num[i])
            i += 1
        else:
            ans.append(num[j])
            j -= 1
else:
    ans, num = [], [3*i for i in range(1, N//3 + 1)] + [i for i in range(N+1) if i % 3 != 0]
    i, j = 0, -1
    for k in range(1, N+1):
        if tree[k][1] != 0:
            ans.append(num[i])
            i += 1
        else:
            ans.append(num[j])
            j -= 1
print(' '.join(map(str, ans)))

Measured memory_bytes: 111744
#include <cstdio>
#include <map>
using namespace std;
typedef long long LL;
const int N=250010;
const LL MOD=1000000000000000031ll,B=1000000000000000003ll,REVB=821428571428571454ll;
int n;
char str[N];
LL f[N],p[N];
LL mul(LL x,LL y){
	return (LL)((__int128)x*y%MOD);
}
void readData(){
	scanf("%d",&n);
	scanf("%s",str+1);
}
map<LL,int> mp;
void solve(){
	f[0]=0;
	p[0]=1;
	for(int i=1;i<=n;i++){
		f[i]=f[i-1];
		p[i]=p[i-1];
		if(str[i]=='>')
			p[i]=mul(p[i],B);
		else if(str[i]=='<')
			p[i]=mul(p[i],REVB);
		else if(str[i]=='+')
			(f[i]+=p[i])%=MOD;
		else
			(f[i]-=p[i])%=MOD;
		if(f[i]<0)
			f[i]+=MOD;
	}
	LL ans=0;
	for(int i=n;i>=1;i--){
		mp[f[i]]++;
		ans+=mp[(mul(f[n],p[i-1])+f[i-1])%MOD];
	}
	printf("%lld\n",ans);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 35584
Scanf.scanf "%d %d %d" (fun a b q ->
    let s = Array.init a (fun _ -> Scanf.scanf " %d" (fun s -> s)) in
    let t = Array.init b (fun _ -> Scanf.scanf " %d" (fun t -> t)) in
    let co x y z = abs (x - y) + abs (y - z) in
    let calc l = List.fold_left min max_int l in
    let find arr v =
        let rec bin l r =
            if l = r then l - 1 else
                let m = (l + r) / 2 in
                if arr.(m) <= v then bin (m + 1) r else bin l m
        in
        let n = Array.length arr in
        if n = 1 then arr.(0), arr.(0) else
            let x = bin 0 n in
            if x = n - 1 then arr.(x - 1), arr.(x)     else
            if x = -1    then arr.(x + 1), arr.(x + 2) else
                         arr.(x), arr.(x + 1)
    in
    for i = 1 to q do
        Scanf.scanf " %d" (fun x ->
            let a1, a2 = find s x in
            let b11, b12 = find t a1 in
            let b21, b22 = find t a2 in
            let c1, c2 = find t x in
            let d11, d12 = find s c1 in
            let d21, d22 = find s c2 in

            calc [
                co x a1 b11; co x a1 b12; co x b11 a1; co x b12 a1;
                co x a2 b21; co x a2 b22; co x b21 a2; co x b22 a2;
                co x c1 d11; co x c1 d12; co x d11 c1; co x d12 c1;
                co x c2 d21; co x c2 d22; co x d21 c2; co x d22 c2
            ] |> Printf.printf "%d\n"
        )
    done
)

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[s.size()-1]=='s') s+="es";
  else s+="s";
  cout<<s<<endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <numeric>

using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    while(x - b >= 0){ x -= b ; }
    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
def f(s,p):
    p.append(s.pop(0))
    for i,num in enumerate(s):
        if num % p[-1] == 0:
            s.pop(i)
    return 0

def vol44(k):
    for i in range(len(p)):
        if p[i] == k:
            print(p[i-1],p[i+1])
            break
        elif p[i] > k:
            print(p[i-1],p[i])
            break

primes = list(range(2,50100))
arr = []
while not arr or arr[-1] ** 2 < primes[-1]:
    f(primes,arr)
p = arr+primes

n = []
while True:
    try:
        n.append(int(input()))
    except EOFError:
        break

for i in range(len(n)):
    vol44(n[i])

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200010];
int main()
{
	cin>>n;
	long long max=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		max+=a[i];
	}
	long long min=1234567891234567890;
	long long now=a[0];
	for(int i=1;i<=n-1;i++)
	{
		if(labs(max-now-now)<min)
		{
			min=labs(max-now-now);
		}
		now+=a[i];
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int a, b;

    while (true) {
      a = scan.nextInt();
      b = scan.nextInt();
      if (a == 0 && b == 0) {
        break;
      }
      System.out.printf("%d %d\n", Math.min(a, b), Math.max(a, b));
    }
  }
}


Measured memory_bytes: 41620
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s,t;cin>>s>>t;
    int ans=0;
    rep(i,0,s.size()){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int a,b;
    cin >> a >> b;
    if(a>b){
        swap(a,b);
    }
    if((b-a)%2==1){
        cout << "IMPOSSIBLE";
    }else{
        ll ans = (b-a)/2 + a;
        cout << ans << endl;
    }

    
    return 0;
}
 
 


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

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

  //kをnで割って0になるまで処理する
  int ans = 0;
  while (n > 0) {
    n /= k;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;




	
int32_t main()
{
	string s;cin>>s;
	int ans1=0,ans2=0;
	for(int i=0;i<(int)s.length();i++)
	{
		if(i&1)
		{
			if(s[i]=='0')ans1++;
			else ans2++;
		}
		else
		{
			if(s[i]=='1')ans1++;
			else ans2++;
		}
	}
	cout<<min(ans1,ans2)<<endl;
}
				
				   
	

	


Measured memory_bytes: 512
S = input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
else :
  print(1)

Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		
		Set<Integer> ans = new HashSet<Integer>();
		ans.add(a);
		ans.add(b);
		ans.add(c);
		System.out.println(ans.size());
	}
}


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

ll arr[100005];
int main()
{
    ll n, a, x; cin >> n;
    for (ll i=0; i<n;i++) cin >> arr[i];
    x = arr[0];
    for (ll i = 1; i < n; i++)
    {
        if(i % 2) x -= arr[i];
        else x += arr[i];
    }
    x = abs(x); arr[0] -= x / 2; arr[n-1] -= x / 2;
    cout << x << ' ';
    for (ll i = 0; i < n-1; i++)
    {
        cout << arr[i] * 2 << ' ';
        arr[i+1] -= arr[i];
    }
    cout << endl;
}

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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < H; i++) {
    if (i < B) {
      for (int j = 0; j < W; j++) {
        if (j < A) cout << 0;
        else cout << 1;
      }
    }
    else {
      for (int j = 0; j < W; j++) {
        if (j < A) cout << 1;
        else cout << 0;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 3524
// glory be to the sky
#include<cstdio>
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, M;
	cin >> N >> M;
	if (N >= M) cout << M / 2 << endl;
	else {
		ll ans = min(N, M / 2);
		N -= ans, M -= (ans * 2);
		// cout << "DEB" << " " << ans << endl;
		if (M >= 0) ans += M / 4;
		cout << ans << endl;
	} 
	return 0;	
}

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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

bool can(const string& s, int i, int j) {
	int cnt = 0;
	for (int idx = i; idx <= j; ++idx) {
		if (s[idx] == '#') {
			++cnt;
		} else {
			cnt = 0;
		}
		if (cnt >= 2) {
			return false;
		}
	}
	return true;
}

int main() {
	int n = nxt(), a = nxt() - 1, b = nxt() - 1, c = nxt() - 1, d = nxt() - 1;
	string s;
	cin >> s;

	if (!can(s, a, c) || !can(s, b, d) || c == d) {
		puts("No");
		return 0;
	}
	if (c > d) {
		for (int i = b; i <= d; ++i) {
			if (i > 0 && i < n - 1 && s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
				puts("Yes");
				return 0;
			}
		}
		puts("No");
		return 0;
	}
	puts("Yes");

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s, t; cin >> s >> t;
  rep(i, n) cout << s[i] << t[i];
  cout << endk;
  return 0;
}


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

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

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



int main(){
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}

Measured memory_bytes: 256
N = int(input())
w = list(map(int,input().split()))
s1 = w[0]
s2 = 0
i=1
while(i<N):
    s2 += w[i]
    i+=1
min = abs(s1-s2)
i=1
while(i<N):
    s1 += w[i]
    s2 -= w[i]
    tmp = abs(s1-s2)
    if tmp < min:
        min = tmp
    i += 1
print(min)

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

int main()
{
  string S;
  cin >> S;
  if(S[2] != S[3]){
   cout << "No" << endl;
    return 0;
  }
  
  if(S[4] != S[5])
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, ans;
    ans = inf;
    cin >> n >> k;
    vll h(n, 0);
    REP(i, n)cin >> h[i];
    sort(h.begin(), h.end());
    FOR(i, k, n) ans = min(ans, h[i-1]-h[i-k]);
    cout << ans <<"\n";
	return 0;
}

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

int main() {
  // ここにプログラム
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> vex(n);
  vector<int> vey(m);
  for(int i = 0; i < n; i++) {
    cin >> vex.at(i);
  }
  for(int i = 0; i < m; i++) {
    cin >> vey.at(i);
  }
  sort(vex.begin(), vex.end());
  sort(vey.begin(), vey.end());
  if(vex.at(n - 1) < vey.at(0) && x < vey.at(0) && vex.at(n - 1) < y) {
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }
  
  return 0;
}

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

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

  rep(i, a.size())
    if(a[i] != b[i]) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3916
/*
First, solve the problem.Then write the code. - John Johnson
@author: returnAC
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define need_for_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // Thanks Joshua :)
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	need_for_speed;
	char a;
	cin>>a;
	if(a=='A')cout<<"T"<<endl;
	if(a=='T')cout<<"A"<<endl;
	if(a=='C')cout<<"G"<<endl;
	if(a=='G')cout<<"C"<<endl;
}

Measured memory_bytes: 256
r, c =[int(i) for i in input().split()]

date =[]
sum_row = [0] * (c + 1)

for ri in range(r):
    date.append([int(i) for i in input().split()])
    date[ri].append(sum(date[ri]))
    print(" ".join([str(d) for d in date[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += date[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7744
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 
const int mxN = 1e5 + 7;
vector<pair<int,int>> adj[mxN];
bool visited[mxN],ans[mxN];
int n;

void dfs(int i, ll s){
	if(!visited[i]){
		visited[i] = 1;
		if(s&1) ans[i] = 0;
		else ans[i] = 1;
		for(auto neigh : adj[i]) dfs(neigh.first, s+neigh.second);
	}
}

void solve(){
	cin >> n;
	FOR(n-1){
		int u,v,w; cin >> u >> v >> w;
		--u, --v;
		adj[u].pb({v,w});
		adj[v].pb({u,w});
	}
	
	dfs(0,0);
	FOR(n) cout << ans[i] << '\n';
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 10596
n, k = map(int,input().split())
s = list(input())

if (s[k-1] == "A"):
    s[k-1] = "a"
elif (s[k-1] == "B"):
    s[k-1] = "b"
else:
    s[k-1] = "c"

ans = ""
for tmp in s:
    ans += tmp
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

int N;
int A[114514];

int main(void) {
	int i;
	int64_t fukuennmisato = 0;
	int nakamurayuuiti = 1111111111, mizuhasikaori = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		int sakagutidaisuke = abs(A[i]);
		if (A[i] < 0) mizuhasikaori++;
		fukuennmisato += sakagutidaisuke;
		if (nakamurayuuiti > sakagutidaisuke) nakamurayuuiti = sakagutidaisuke;
	}
	if (nakamurayuuiti > 0 && mizuhasikaori % 2 != 0) fukuennmisato -= nakamurayuuiti * 2;
	printf("%" PRId64 "\n", fukuennmisato);
	return 0;
}

/*

操作を任意の回数できる → マイナスのやつを0個か1個残して全部プラスにできる
0個なのか1個なのかは、もとのデータ中のマイナスの数の偶奇による
0があったら、どっちとみなしてもよい

*/


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
    
vector<int> L(100001);

int main() {

    int N , X;
    cin >> N >> X;
    for (int i = 0; i < N; i ++) {
        cin >> L[i];
    }
    for (int i = 1; i < N; i++) {
        L[i] += L[i-1];
    }
    
    int ans = 1;

    for (int i = 0; i < N; i++) {
        if (L[i] <= X) ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    s = input()
    print(s.count("1"))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38512
#include <cstdio>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200;
const int mod=998244353;

struct point
{
  int x,y;
};

point p[maxn+10];
int n,ans;

int quickpow(int a,int b,int m)
{
  int res=1;
  while(b)
    {
      if(b&1)
        {
          res=1ll*res*a%m;
        }
      a=1ll*a*a%m;
      b>>=1;
    }
  return res;
}

int in_line(point a,point b,point c)
{
  return (b.y-a.y)*(c.x-a.x)==(c.y-a.y)*(b.x-a.x);
}

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      p[i].x=read();
      p[i].y=read();
    }
  for(int i=1; i<=n; ++i)
    {
      for(int j=i+1; j<=n; ++j)
        {
          int cnt=0;
          for(int k=j+1; k<=n; ++k)
            {
              if(in_line(p[i],p[j],p[k]))
                {
                  ++cnt;
                }
            }
          ans+=quickpow(2,cnt,mod);
          if(ans>=mod)
            {
              ans-=mod;
            }
        }
    }
  ans+=n+1;
  if(ans>=mod)
    {
      ans-=mod;
    }
  ans=quickpow(2,n,mod)-ans;
  if(ans<0)
    {
      ans+=mod;
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int k = sc.nextInt();
    long[] a = new long[x];
    long[] b = new long[y];
    long[] c = new long[z];
    long[] ab = new long[x * y];
    for(int i = 0; i < x; i++){
      a[i] = sc.nextLong();
    }
    for(int i = 0; i < y; i++){
      b[i] = sc.nextLong();
    }
    for(int i = 0; i < z; i++){
      c[i] = sc.nextLong();
    }
    Arrays.sort(a);
    Arrays.sort(b);
    Arrays.sort(c);
    int index = 0;
    for(int i = 0; i < x; i++){
      for(int j = 0; j < y; j++){
        ab[index] = a[i] + b[j];
        index++;
      }
    }
    Arrays.sort(ab);
    long[] abc = new long[Math.min(x*y, 3000) * z];
    index = 0;
    for(int i = 0; i < Math.min(x*y, 3000); i++){
      for(int j = 0; j < z; j++){
        abc[index] = ab[x*y-1-i] + c[z-1-j];
        index++;
      }
    }
    Arrays.sort(abc);
    for(int i = 0; i < k; i++){
      System.out.println(abc[abc.length-1-i]);
    }
  }
}

Measured memory_bytes: 81932
#include<bits/stdc++.h>
#define p5 100005
#define ll long long
using namespace std;
ll ar[p5];
int main()
{
    int n,k,i,j,l;
    cin>>n>>k;
    int w[n+1],v[n+1];
    for(i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
    }
    for(i=1; i<=p5; i++)
    {
        ar[i]=p5*p5;
    }
    for(i=1; i<=n; i++)
    {
        for(j=p5; j>=v[i]; j--)
        {
            ar[j]=min(ar[j],ar[j-v[i]]+w[i]);

        }
    }
    for(i=p5; i>=0; i--)
    {
        if(ar[i]<=k)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}
/*
3 8
3 3
4 5
5 6
*/


Measured memory_bytes: 1024
// B - TAKOYAKI FESTIVAL 2019
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vi D(N);
	rp(i, 0, N) cin>>D[i];
	int ans = 0;
	rp(j, 0, N) rp(i, 0, j) ans += D[i] * D[j];
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long N,N_,n,ans=0LL;
int main(void){
    cin>>N;
    if(N==2){cout<<1<<endl;return 0;}
    N_=N-1LL;
    for(long long K=2LL;K<=sqrt(N_);K++)if(N_%K==0LL)ans+=1LL+(K!=sqrt(N_));
    for(long long K=2LL,k;K<=sqrt(N);K++){
        if(N%K==0LL){
            n=N;
            while(n%K==0LL)n/=K;
            ans+=(n%K==1LL);
            if(K==sqrt(N))continue;
            n=N;
            k=N/K;
            while(n%k==0LL)n/=k;
            ans+=(n%k==1LL);
        }
    }
    cout<<ans+2LL<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n,i,c=0,r=0;
    scanf("%d", &n);
    for(i=1;i<=n;++i)
    {
        c=i;
        r+=i;
        if(r>=n)
        {
            printf("%d", c);
            return 0;
        }
    }
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  string s, t;
  cin >> s >> t;
  int c = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3816
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>

int main (int argc, char **argv)
{
  int n = 0;
  int a = 0;
  int b = 0;

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

  printf("%d\n", ((a * n) < b ? (a * n) : b));

  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
s = input()
k = int(input())
n = len(s)
b = [0] * n
c = [0] * n
c[0] = 1

for i in range(n):
    if s[i - 1] == s[i] and not c[i - 1]:
        c[i] = 1
    if i and s[i - 1] == s[i] and not b[i - 1]:
        b[i] = 1
s1 = sum(b)
s2 = sum(c)
if s[-1] != s[0] or b[-1]:
    print(s1 * k)
else:
    if c[-1]:
        print((s1 + s2) * (k // 2) + s1 * (k % 2))
    else:
        print(s1 + (k - 1) * s2)


Measured memory_bytes: 9188
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: i32 = read();
    let K: usize = read();
    let mut vec: Vec<i32> = vec![];
    for _ in 0..N {
        vec.push(read());
    }
    let mut now_val = 0;
    let mut max = 0;
    let mut ans = 0.0;
    for (i, &v) in vec.iter().enumerate() {
        now_val += v;
        if i >= K {
            now_val -= vec[i - K];
        }
        if max < now_val {
            max = now_val;
            ans = K as f64 / 2.0 + max as f64 / 2.0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	long long  x;
	long long y;
	scanf("%lld%lld",&x,&y);
	for(long long i=0;i<=x;i++)
		for(long long  j=0;j<=x-i;j++)
		{
			if((y-i*10000-j*5000)%1000==0)
			{
				long long z=(y-i*10000-j*5000)/1000;
				if(i+j+z==x)
				{
					printf("%lld %lld %lld\n",i,j,z);
					return 0;
				}
			}
			
			
		}
	printf("-1 -1 -1\n");
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,x,d,ret;
signed main(){
    cin >> n >> x >> d;
    map<int,vpi> rem;
    if (!d){
        cout << (x ? n+1 : 1) << endl;
        return 0;
    }

    REP(i,n+1){
        int ama = x * i % d;
        if (ama < 0) ama += d;
        int sho = (x * i - ama) / d;

        // 0, 1, ..., i-1
        int mini = i * (i-1) / 2;
        // (n-i), ..., n-1
        int maxi = i * (2*n-1-i) / 2;
        
        rem[ama].eb(mini+sho, maxi+sho+1);
        // cerr << ama << " : [" << mini+sho << ", " << maxi+sho+1 << ")\n";
    }
    for(auto& p : rem){
        auto event = p.second;
        sort(all(event));
        int lev = sz(event);
        int mini = INT64_MIN + 2;
        int maxi = INT64_MIN + 2;
        for(auto ev: event){
            if (ev.first > maxi){
                ret += maxi - mini;
                mini = ev.first;
                maxi = ev.second;
            } else {
                maxi = max(maxi, ev.second);
            }
        }
        ret += maxi - mini;
    }
    cout << ret << endl;
}

Measured memory_bytes: 22144
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

//5-3 二分探索
public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		ArrayList<Integer> S = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			S.add(Integer.parseInt(sc.next()));
		}
		int q = Integer.parseInt(sc.next());
		ArrayList<Integer> T = new ArrayList<>();
		for(int i = 0; i < q; i++) {
			T.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		//二分探索
		int i = 0;
		int count = 0;
		while(i != T.size()) {
			int left = 0;
			int right = S.size();
			int key = T.get(i);
			while(left < right) {
				int mid = (left + right) / 2;
				if(S.get(mid) == key) {
					count++;
					break;
				}else if(key < S.get(mid)) {
					right = mid;
				}else {
					left = mid + 1;
				}
			}
			i++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 72168
#ceilevenoddformula
import math
import bisect
import copy
import time
from collections import Counter
from itertools import combinations
#map(int,input().split())
#int(x) for x in input().split()
n=int(input())
l=[int(x) for x in input().split()]
ans=[0]*n
l=l[::-1]
ans[0]=l[0]
for i in range(1,n):
	ans[i]=l[i]+ans[i-1]
l=l[::-1]
c=0
M=10**9+7
ans=ans[::-1]
for i in range(1,n):
	c+=(ans[i]*l[i-1])%M
	c=c%M
print(c)









































Measured memory_bytes: 100116