akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class Main {
    private static final PrintStream ps     = System.out;
    private static final InputStream IS     = System.in;
    private static final byte[]      BUFFER = new byte[1024];
    private static int               ptr    = 0;
    private static int               buflen = 0;

    public static void main(String[] args) {
        long a = nl();
        long b = nl();
        long c = nl();
        long x = nl();
        long y = nl();
        long com = Math.min(x, y);
        x -= com;
        y -= com;
        
        long cost = Math.min(c*2, a+b) * com;
        
        if (x != 0) {
            cost += c*2 < a ? c*2*x : a*x;
        } else {
            cost += c*2 < b ? c*2*y : b*y;
        }
        ps.println(cost);
    }

    private static boolean hasNextByte() {
        if (ptr < buflen)
            return true;
        else {
            ptr = 0;
            try {
                buflen = IS.read(BUFFER);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0)
                return false;
        }
        return true;
    }

    private static int readByte() {
        if (hasNextByte())
            return BUFFER[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(BUFFER[ptr]))
            ptr++;
        return hasNextByte();
    }

    public static String n() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public static long nl() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b)
            throw new NumberFormatException();
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b))
                return minus ? -n : n;
            else
                throw new NumberFormatException();
            b = readByte();
        }
    }

    public static int ni() {
        long nl = nl();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public static double nextDouble() {
        return Double.parseDouble(n());
    }

    private static int[] nia(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = ni();
        return a;
    }
}


Measured memory_bytes: 23252
N,X=map(int,input().split(" "))
L=[int(s) for s in input().split(" ")]

bound_List=[0]
for i in range(N):
    bound_List.append(L[i]+bound_List[i])

count=0
for i in bound_List:
    if i<=X:
        count+=1
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int A,B,C,K;
	cin>>A>>B>>C>>K;
	
	if(A<B){
		int X=A;
		A=B;
		B=X;
	}
	if(A<C){
		int X=A;
		A=C;
		C=X;
	}
	rep1(i,K)A*=2;
	cout<<A+B+C;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S <<endl;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "..."; 
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll dist[MAX][5];
vll edge[MAX];



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


  cin >> n >> m;
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    edge[a].pb(b);
  }
  ll x, y;
  cin >> x >> y;
  rep(i, n + 1) rep(j,3) dist[i][j] = inf;
  dist[x][0] = 0;
  priority_queue<pll, vector<pll>, greater<pll>> pq;

  pq.push(pll(0, x));

  while (!pq.empty()) {
    pll p = pq.top();
    ll cur = p.second, d = p.first;
    pq.pop();
    if (dist[cur][d % 3] < d) continue;
    rep(i, edge[cur].size()) {
      ll to = edge[cur][i];
      if (dist[to][(d + 1) % 3] > dist[cur][d % 3] + 1) {
        dist[to][(d + 1) % 3] = dist[cur][d % 3] + 1;
        pq.push(pll(dist[to][(d + 1) % 3], to));
      }
    }
  }

  if (dist[y][0] != inf) cout << dist[y][0] / 3 << endl;
  else cout << "-1" << endl;

  return 0;
}

Measured memory_bytes: 13824
#include <stdio.h>
#include <string.h>
 
int main(void)
{
  int k;
  int i;
  char s[100];
  char s2[k];
  scanf("%d", &k);
  scanf("%s", s);
  
  for(i=0; i<k; i++){
    s2[i]=s[i];
  }
  if(strlen(s) <= k){
    printf("%s", s2);
  }else{
  printf("%s%s", s2, "...");
  }
  
return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,i,j;
    cin>>n;
    vector<int> h(n);
    vector<long long int> a(n);
    for(i=0;i<n;i++)
        cin>>h[i];
    for(i=0;i<n;i++)
        cin>>a[i];
    set<int> s;
    vector<long long int > beauty(n+1);
    s.insert(h[0]);
    beauty[h[0]]=a[0];

    for(i=1;i<n;i++)
    {
        auto it = s.insert(h[i]);
        auto iter=it.first;
        if(iter == s.begin())
        {
            beauty[h[i]]=a[i];
        }
        else
        {
            beauty[h[i]]=a[i]+beauty[*(--iter)];
        }
        iter=it.first;
        ++iter;
        auto st=iter;
        while(st!=s.end())
        {
            
            if(beauty[*st]<beauty[h[i]])
            {
                ++st;
            }
            else
            {
                break;
            }
            
        }
        if(iter!=s.end())
        {
            s.erase(iter,st);
        }
        
        /**for(auto x=s.begin();x!=s.end();x++)
            cout<<*x<<" ";
        cout<<endl;**/
    }
    auto itr=s.end();
    cout<<beauty[*(--itr)]<<endl;


}

Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        final int n = scanner.nextInt();

        final int[] array = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            array[i] = scanner.nextInt();
        }

        int index = 1;
        int count = array[index];
        final int[][] table = new int[h][w];
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                for (int j = 0; j < w; j++) {
                    if (count == 0) {
                        count = array[++index];
                    }
                    table[i][j] = index;
                    count--;
                }
            } else {
                for (int j = w - 1; j >= 0; j--) {
                    if (count == 0) {
                        count = array[++index];
                    }
                    table[i][j] = index;
                    count--;
                }
            }
        }

        for (final int[] col : table) {
            for (final int value : col) {
                System.out.print(value + " ");
            }
            System.out.println();
        }
    }
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) {
  	for (int i = 0; i < a; ++i) cout << a;
    cout << '\n';
  } else {
  	for (int i = 0; i < max(a, b); ++i) cout << min(a, b);
    cout << '\n';
  }
}

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

using namespace std;


int main() {
    long long int N, X;
    //cin >> N >> X;
    scanf("%lld%lld",&N,&X);
    long long int A = N;
    N -= X;
    while(true){
        if(N > X) swap(N,X);
        if(X%N == 0){
            A += (2*(X/N)*N - N);
            break;
        }
        A += (2*(X/N)*N);
        X %= N;
    }



    cout << A << endl;

    return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string sa, sb, sc; cin >> sa >> sb >> sc;
    
    string x = "a";
    while (true) {
        if (x == "a") {
            if (LEN(sa) == 0) break;
            x = sa.substr(0, 1);
            if (LEN(sa) > 0) sa = sa.substr(1, LEN(sa)-1);
        } else if (x == "b") {
            if (LEN(sb) == 0) break;
            x = sb.substr(0, 1);
            if (LEN(sb) > 0) sb = sb.substr(1, LEN(sb)-1);
        } else if (x == "c") {
            if (LEN(sc) == 0) break;
            x = sc.substr(0, 1);
            if (LEN(sc) > 0) sc = sc.substr(1, LEN(sc)-1);
        }
    }
    
    cout << (char)(x[0] - 'a' + 'A') << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline
from collections import defaultdict

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N, D = map(int, input().split())

K = D * 2 + 1

print((N + K - 1) // K)


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

int main(){
    int r;
    double ans;
    double PI = 3.14159265359;
    cin >> r;
    ans = 2 * r * PI;
    cout << ans << endl;
}


Measured memory_bytes: 3788
N = gets.chomp.to_i
H = gets.chomp.split().map(&:to_i)

s = 0
N.times do |i|
  if i == 0
    s += H[0]
  elsif H[i-1] < H[i]
    s += H[i] - H[i-1]
  end
end

puts s


Measured memory_bytes: 14352
function Main(input){
	input = input.split("\n");
  var HW = input.shift().split(" ");
  
  var h = Array.from({length:HW[0]},()=>0);
  var w = Array.from({length:HW[1]},()=>0);
  
  for(var i = 0 ; i < HW[0] ; i++){
  	for(var j = 0; j < HW[1] ; j++){
    	if(input[i][j] == "#")h[i] = w[j] = 1;
    }
  }
  
  var result = "";
  
  for(var i = 0 ; i < HW[0] ; i++){
    var aaaaa = 0;
  	for(var j = 0; j < HW[1] ; j++){
    	if(h[i]*w[j]){
      	result += input[i][j];
        aaaaa++;
      }
    }
    if(aaaaa != 0 && i != HW[0]-1)result += "\n";
  }
  
  return result;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
7 6
......
....#.
.#....
..#...
..#...
......
.#..#.
`);

Measured memory_bytes: 7628
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll memoall[103];
ll memoac[103];
ll memog[103];

ll rec_all(int);
ll rec_ac(int);
ll rec_g(int);

ll rec_all(int n){
    if(n < 0){
        return 0;
    }
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return 4;
    }
    if(n == 2){
        return 16;
    }
    if(memoall[n] != 0){
        return memoall[n];
    }
    else{
        return memoall[n] = ((rec_all(n - 1) - (rec_all(n - 3) + rec_ac(n - 1) + rec_g(n - 2) + rec_all(n - 4) * 3)) * 4 + (rec_all(n - 3) + rec_ac(n - 1) + rec_g(n - 2)) * 3 + rec_all(n - 4) * 9) % MOD;
    }
}

ll rec_ac(int n){
    if(n < 2){
        return 0;
    }
    if(memoac[n] != 0){
        return memoac[n];
    }
    else{
        return memoac[n] = rec_all(n - 2) - rec_g(n - 2);
    }
}

ll rec_g(int n){
    if(n < 1){
        return 0;
    }
    if(memog[n] != 0){
        return memog[n];
    }
    else{
        return memog[n] = rec_all(n - 1) - rec_ac(n - 1);
    }
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        memoall[i] = 0;
        memoac[i] = 0;
        memog[i] = 0;
    }
    cout << rec_all(n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		float T = sc.nextFloat()+0.5f;
		int res = 0;

		while(A<=T) {
			res+=B;
			T -= A;
		}
		System.out.println(res);


	}

}

Measured memory_bytes: 23888
#include <iostream>

using namespace std;
int flag=0;
int gcd(int a,int b)
{
    while(a^=b^=a^=b%=a);
    return b;
}
long long gcd_(int a,int b)
{
    int t=gcd(a,b);
    if((a/t)%2==0||(b/t)%2==0)
        flag=1;
    return 1L*a/t*b;
}
int main()
{
    int n,m;
    int judge_first=1;
    long long ans=1;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        if(judge_first==1)
        {
            cin>>ans;
            ans=ans/2;
            judge_first=0;
        }
        else
        {
            int x;
            cin>>x;
            if(ans<=m)
            {
                ans=gcd_((int)ans,x/2);
            }
            else
                flag=1;
        }
    }
    if(flag==1)
        cout<<0;
    else
    {
        int count_=0;
        int temp=2*ans;
        while(ans<=m)
        {
            ans=ans+temp;
            count_++;
        }
        cout<<count_;
    }
    return 0;
}


Measured memory_bytes: 256
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string str;
    cin>>str;
    vector<int> ans(3, 0);
    ans[0] = str[0]=='R';
    for(int i = 1; i < 3; i++){
        ans[i] = ans[i-1];
        if(str[i] == 'R')
            ++ans[i];
        else
            ans[i] = 0;
    }
    cout<<max(ans[0], max(ans[1], ans[2]));
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)

using namespace std;

int main() {

		
	int sx, sy, gx, gy;
	cin >> sx >> sy >> gx >> gy;

	int ud, rl;
	ud = abs(gy - sy);
	rl = abs(gx - sx);

	rep(i,0,ud)	cout << 'U';
	rep(i, 0, rl)cout << "R";
	
	rep(i, 0, ud)cout << "D";
	rep(i, 0, rl)cout << "L";

	cout << "L";
	rep(i, 0, ud + 1)cout << "U";
	rep(i, 0, rl + 1)cout << "R";
	cout << "D";

	cout << "R";
	rep(i, 0, ud + 1)cout << "D";
	rep(i, 0, rl + 1)cout << "L";
	cout << "U";
	cout << endl;

	
	return 0;
}

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

using namespace std;

int main() {
    string arr[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin>>s;
    int count=7;
    for (int i = 0; i <7 ; ++i) {
        if (s==arr[i])
            count=7-i;
    }
    cout<<count;


}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((c - b) % 2 == 1) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] col = new int[9];
        for(int i = 0;i < N;i++){
            int a = sc.nextInt();
            if(a/400 <= 7)  col[a/400]++;
            else    col[8]++;
        }
        int m1 = 0;
        int m2 = 0;
        for(int i = 0;i < 8;i++){
            if(col[i] > 0){
                m1++;
                m2++;
            }
        }
        if(col[8] > 0){
            if(m1 == 0) m1 = 1;
            m2 += col[8];
        }
        System.out.println(m1+" "+m2);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	
	int p[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	
	int ans=0;
	for(int i=0;i<n-2;i++){
		if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2]))
			ans++;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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! {
        x: usize, y: usize, z: usize, k: usize,
        mut a: [usize; x],
        mut b: [usize; y],
        mut c: [usize; z],
    }
    c.sort();
    c.reverse();

    let mut ab = vec![];
    for a_ in &a {
        for b_ in &b {
            ab.push(a_ + b_)
        }
    }
    ab.sort();
    ab.reverse();

    let mut ans = vec![];
    for i in 0..min(k, ab.len()) {
        for j in 0..min(k, z) {
            ans.push(ab[i] + c[j])
        }
    }
    ans.sort();
    ans.reverse();

    for i in 0..k {
        println!("{}", ans[i])
    }
}


Measured memory_bytes: 44276
h, w = map(int, input().split())

while h != 0:
    s1 = "#"
    s2 = "."
    for i in range(h):
        if i % 2 == 0:
            for j in range(w):
                if j % 2 == 0:
                    print(s1, end="")
                else:
                    print(s2, end = "")
            print()
                    
        else:
            for j in range(w):
                if j % 2 == 0:
                    print(s2, end="")
                else:
                    print(s1, end = "")
            print()
        
    print()    
    h, w = map(int, input().split())



Measured memory_bytes: 7000
import string
d = {}
alph = string.ascii_lowercase
for i in range(len(alph)):
    d[alph[i]] = i
s = list(input())


count = [0 for _ in range(len(alph))]
for letter in s:
    count[d[letter]] += 1
# print(count)

target = []
for i in range(len(alph)):
    if count[i] == max(count):
        target.append(alph[i])

# print(target)
answer = []
for t in s:
    time = 0
    size = len(s)
    line = list(s)
    ifOK = True
    while ifOK:
        # print("".join(line))
        ifOK = False
        new_line = ""
        for i in range(size-1):
            if (line[i] == t or t == line[i+1]) and not line[i] == line[i+1]:
                new_line += t
                ifOK = True
            else:
                new_line += line[i]
        line = list(new_line)
        size -= 1
        time += 1
    answer.append(time)
print(min(answer)-1)


Measured memory_bytes: 9940
def calc_cost cycle, min_num
  x = cycle.sum + (cycle.length - 2) * cycle.min
  y = cycle.sum + cycle.min + (cycle.length + 1) * min_num
  [x, y].min
end

n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)
min_num = as.min
bs = as.sort
cycles = []
while !as.empty?
  a = as.shift
  b = bs.shift
  next if a == b
  cs = [a, b]
  while fb = as.find_index(b)
    b = bs[fb]
    cs << b
    as.delete_at(fb)
    bs.delete_at(fb)
  end
  cycles << cs
end

cost = 0
cycles.each do |c|
  c.pop
  cost += calc_cost(c, min_num)
end
puts cost


Measured memory_bytes: 6916
#include <stdio.h>
#include <stdlib.h>
typedef struct data *node;
struct data{
    int key;
    node par;
    node left;
    node right;
};

void insert(int);
node makenode(int);
void Preorder(node);
void Inorder(node);

node root;

int main (){
    int n,i,x;
    char com[10];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&x);
            insert(x);
        }
        else if(com[0]=='p'){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }
    return 0;
}
void insert(int z){
    node x,y,t;
    y=NULL;
    x=root;
    while(x!=NULL){
        y=x;
        if(z<x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    t=makenode(z);
    t->par=y;
    if(y==NULL){
        root=t;
    }
    else if(z<y->key){
        y->left=t;
    }
    else{
        y->right=t;
    }
}
node makenode (int z){
    node x;
    x=(node)malloc(sizeof(struct data));
    x->key=z;
    x->left=NULL;
    x->right=NULL;
    return x;
}
void Preorder(node u){
    if(u==NULL){
        return;
    }
    printf(" %d",u->key);
    Preorder(u->left);
    Preorder(u->right);
}
void Inorder(node u){
    if(u==NULL){
        return;
    }
    Inorder(u->left);
    printf(" %d",u->key);
    Inorder(u->right);
}



Measured memory_bytes: 25148
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for val in al:
    dic[val]=dic.get(val,0)+1

for i in range(1,n+1):
    print(dic.get(i,0))





Measured memory_bytes: 33476
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
struct k{
	int x,y,cnt;
};
int i,i2,xx,yy,X,Y,map[1001][1001],b[1001][1001],mi,st[11][3],t,cntsum=0,aaa,bbb;
int main(){
	k ii;
	queue<k> Q;
	char d,z[1001][1001];
	for(i=0;i<Y;i++){
		for(i2=0;i2<X;i2++){
			map[i2][i]=0;
			switch (d){
				case 'S':
					st[0][1]=i2;
					st[0][2]=i;
					break;
				case '.':
					break;
				case 'X':
					map[i2][i]=-1;
					break;
				case '1':
					st[1][1]=i2;
					st[1][2]=i;
					break;
				case '2':
					st[2][1]=i2;
					st[2][2]=i;
					break;
				case '3':
					st[3][1]=i2;
					st[3][2]=i;
					break;
				case '4':
					st[4][1]=i2;
					st[4][2]=i;
					break;
				case '5':
					st[5][1]=i2;
					st[5][2]=i;
					break;
				case '6':
					st[6][1]=i2;
					st[6][2]=i;
					break;
				case '7':
					st[7][1]=i2;
					st[7][2]=i;
					break;
				case '8':
					st[8][1]=i2;
					st[8][2]=i;
					break;
				case '9':
					st[9][1]=i2;
					st[9][2]=i;
					break;
			}
		}
	}
	/*for(i=0;i<Y;i++){
		for(i2=0;i2<X;i2++){
			cout<<map[i2][i]<<' ';
		}
	cout<<endl;
	}
	cout<<endl;*/
	int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
	for(int w=0;w<t;w++){
		for(int ww=0;ww<Y;ww++)for(int www=0;www<X;www++)b[www][ww]=0;
		mi=999999999;
		ii.x=st[w][1];
		ii.y=st[w][2];
		ii.cnt=0;
		Q.push(ii);
		b[st[w][1]][st[w][2]]=1;
		map[st[w+1][1]][st[w+1][2]]=2;

		while(!Q.empty()){
			for(int I=0;I<4;I++){
				ii=Q.front();
				xx=ii.x+dx[I];
				yy=ii.y+dy[I];
				if(xx>=0&&yy>=0&&xx<X&&yy<Y&&map[xx][yy]!=-1&&b[xx][yy]!=1){
					ii.x=xx;
					ii.y=yy;
					ii.cnt++;
					Q.push(ii);
					b[xx][yy]=1;
		
					/*for(i=0;i<Y;i++){
						for(i2=0;i2<X;i2++){cout<<b[i2][i]<<' ';
						}
						cout<<endl;
					}
					cout<<"x="<<ii.x<<' '<<"y="<<ii.y<<' '<<"cnt="<<ii.cnt<<endl;*/
		
				}
				if(map[ii.x][ii.y]==2){
					mi=min(mi,ii.cnt);
					//cout<<"x="<<ii.x<<' '<<"y="<<ii.y<<' '<<"cnt="<<ii.cnt<<endl;
				}
			}
			Q.pop();
		}

		map[st[w+1][1]][st[w+1][2]]=0;
		cntsum+=mi;
	}
	cin>>aaa>>bbb;
	cout<<aaa*bbb<<' '<<(aaa*2)+(bbb*2)<<endl;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }

int dp[3001][3001];

int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  string s1,s2,ans=""; cin>>s1>>s2; int n=s1.size(),m=s2.size();
  for (int i = 0; i < n; i++){
    for (int j = 0; j < m; j++){
      if(s1[i]==s2[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        chmax(dp[i+1][j+1],max(dp[i+1][j],dp[i][j+1]));
      }
    }
  }
  while(dp[n][m]){
    if(dp[n][m]==dp[n-1][m])n--;
    else if(dp[n][m]==dp[n][m-1])m--;
    else if(dp[n][m]-1==dp[n-1][m-1]){n--; m--; ans+=s1[n];}
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<'\n';
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    int P[3];
    cin >> P[0] >> P[1] >> P[2];
    sort(P,P+3);
    cout << P[0]+P[1] << endl;
    return 0;
}



Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class P
{
    public long c { get; set; }
    public long cm1 { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        var d = new Dictionary<int, int>();
        var d2 = new Dictionary<int, P>();
        for (int i = 0; i < n; i++)
            if (d.ContainsKey(a[i])) d[a[i]]++;
            else d[a[i]] = 1;
        var total = 0L;
        foreach (var x in d)
        {
            var t = x.Value * (x.Value - 1L) / 2L;
            total += t;
            d2[x.Key] = new P { c = t, cm1 = (x.Value - 1L) * (x.Value - 2L) / 2L };
        }
        var ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = total - d2[a[i]].c + d2[a[i]].cm1;
        Console.WriteLine(string.Join("\n", ans));
    }
}


Measured memory_bytes: 53544
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
	int n, m;
	int table[250];
	pair<int, int> data[250];

	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++)
			cin >> data[i].first >> data[i].second;

		cin >> m;
		for (int i = 0; i < m; i++)
			cin >> data[n+i].first >> data[n+i].second;

		for (int i = 0; i < n + m; i++)
		{
			for (int j = i + 1; j < n + m; j++)
			{
				if (data[i].first > data[j].first)
					swap(data[i], data[j]);
			}
		}

		int ans = 0;
		for (int i = 0; i < n + m; i++)
		{
			table[i] = 1;
			for (int j = 0; j < i; j++)
			{
				if (data[i].first > data[j].first && data[i].second > data[j].second)
					table[i] = max(table[i], table[j] + 1);
			}
			ans = max(ans, table[i]);
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] num = new int[100001];
        long sum = 0;
        for (int i = 0 ;i < n; i++) {
            int a = sc.nextInt();
            sum += a;
            num[a]++;
        }

        int q = sc.nextInt();
        for (int i = 0 ;i < q; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();

            int diff = c - b;
            sum += diff * num[b];
            num[c] += num[b];
            num[b] = 0;

            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 61720
N, K = map(int, input().split())
P = list(map(int, input().split()))

sum_p = [0]

for p in P:
    sum_p.append(sum_p[-1] + p)

max_sum = 0
for i in range(K, N+1):
    buf = sum_p[i] - sum_p[i-K]
    if buf > max_sum:
        max_sum = buf

print((max_sum + K) / 2)

Measured memory_bytes: 25060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int n = sc.nextInt();
            double sum = 0;
            for (int i = 0; i < n; i++) {
                double ii = sc.nextInt();
                sum += 1.0 / ii;
            }
            System.out.println(1.0 / sum);
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>

using namespace std;

int main ()
{
    int x,i,n;
    cin>>n;

    for(i = 1; i <= n; i++)
    {
        x = i;

        if(i%3 ==0)
            cout<<" "<<i;
        else
        {
            do
            {
                if(x%10 == 3)
                {
                    cout<<" "<<i;
                    break;
                }
                x = x/10;
            }while(x);
        }
    }
    cout<<endl;

}




Measured memory_bytes: 3084
#!/usr/bin/env python3

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    e = ii()
    if e == 0 or e % 2 == 1:
        print(0)
    else:
        ans = e // 10
        d = 50
        while d <= e:
            ans += e // d
            d *= 5
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;
  cin >> s;

  if(s=="SUN"){
    cout << 7 << "\n";
  }
  else if(s=="MON"){
    cout << 6 << "\n";
  }
  else if(s=="TUE"){
    cout << 5 << "\n";
  }
  else if(s=="WED"){
    cout << 4 << "\n";
  }
  else if(s=="THU"){
    cout << 3 << "\n";
  }
  else if(s=="FRI"){
    cout << 2 << "\n";
  }
  else if(s=="SAT"){
    cout << 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int32_t main() 
{ 
    fastio
    int n, k;
    cin>>n>>k;
    vector<int> vec(n);
    for(auto& it : vec) cin>>it;
    sort(all(vec));
    cout<<accumulate(vec.begin(), vec.begin()+k, 0)<<endl;
}

Measured memory_bytes: 3648
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

#にぶたん
def search(arr, num):
    l = 0
    r = len(arr) - 1
    if arr[r] <= num:
        return r
    if arr[l] > num:
        return -1
    while r - l > 1:
        c = (r + l) // 2
        if arr[c] > num:
            r = c
        elif arr[c] < num:
            l = c
        else:
            r = c
            l = c
    return l

n, m, k = MAP()
a = LIST()
b = LIST()
aarr = [a[0]]
for i in range(1, n):
    aarr.append(aarr[-1] + a[i])
barr = [b[0]]
for i in range(1, m):
    barr.append(barr[-1] + b[i])

#print(aarr)
#print(barr)

ans = 0
a_n = 0
b_n = 0
tim = 0
while tim <= k:
    if a_n == -1 and b_n == -1:
        break
    elif a_n == -1:
        pls = b[b_n]
        mode = 1
    elif b_n == -1:
        pls = a[a_n]
        mode = 0
    else:
        tmp1 = k - tim + aarr[a_n - 1] if a_n != 0 else k - tim
        tmp2 = k - tim + barr[b_n - 1] if b_n != 0 else k - tim
        anum = search(aarr, tmp1) - a_n + 1
        bnum = search(barr, tmp2) - b_n + 1
        #print(tim, anum, tmp1, bnum, tmp2)
        if anum > bnum:
            pls = a[a_n]
            mode = 0
        else:
            pls = b[b_n]
            mode = 1
    #print(pls, mode)
    if tim + pls <= k:
        ans += 1
        tim += pls
        if mode == 0:
            a_n += 1
            if a_n >= n:
                a_n = -1
        else:
            b_n += 1
            if b_n >= m:
                b_n = -1
    else:
        break
print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N) cin >> d[i];
    sort(d.begin(),d.end(),greater<int>());
    int ans =0;
    for(int i=1;i < N+1;i++){
        if(d[i] < d[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Frog 2

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main {
	public static int frogJumpCost2(int[] arr, int n, int k) {
		int[] dp = new int[n];
		dp[n-1] = 0;
		dp[n-2] = Math.abs(arr[n-1]-arr[n-2]);
		for(int i = n-3; i >= 0; i--) {
			int min = Integer.MAX_VALUE;
			for(int j = 1; j <= k && (i+j) < n; j++) {
				int x = dp[i+j]+Math.abs(arr[i]-arr[i+j]);
				if(x < min)
					min = x;
			}
			dp[i] = min;
		}
		return dp[0];
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		String[] s1 = br.readLine().split(" ");

		int n = Integer.parseInt(s[0]);
		int k = Integer.parseInt(s[1]);

		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(s1[i]);
		}

		System.out.println(frogJumpCost2(arr, n, k));

	}
	public static int min(int...arr) {
		int min = Integer.MAX_VALUE;
		for(int i: arr) {
			if(i < min)
				min = i;
		}
		return min;
	}
}

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

using namespace std;

int h[1000000];
vector<vector<int>> g;
// bool vis[1e5+1];

int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    int n, m, a, b, cnt = 0;
    cin >> n >> m;

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

        g.resize(n+2);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 1; i <= n; i++) {
        bool y = true;
        for (int x: g[i]) {
            if (h[i] <= h[x]) y = false;
        }
        if (y) cnt++;
    }
    cout << cnt;
}



Measured memory_bytes: 8748
def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    A.sort()
    B.sort()
    if N % 2 == 0:
        mn = A[N//2-1] + A[N//2]
        mx = B[N//2-1] + B[N//2]
    else:
        mn = A[N//2]
        mx = B[N//2]
    ans = (mx-mn) + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 82356
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,ll> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;
int l[300001]={};
int r[300001]={};
int x[100001]={};
int n,m;
int addx(int k){
	int s=l[k];
	while(s<=m){
		x[s]++;
		s+=s&-s;
	}
	s=r[k]+1;
	while(s<=m){
		x[s]--;
		s+=s&-s;
	}
	return 0;
}
int sumx(int s){
	int r=0;
	while(s>0){
		r+=x[s];
		s-=s&-s;
	}
	return r;
}

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

	vector<int> v[100001];
	for(int i=1;i<n+1;++i){
		cin>>l[i]>>r[i];
		v[r[i]-l[i]+1].push_back(i);
	}
	int ln=n;
	for(int i=1;i<m+1;++i){
		ln-=v[i-1].size();
		int t=ln;
		for(auto it:v[i-1])addx(it);
		for(int j=1;(i*j)<=m;++j)t+=sumx(i*j);
		cout<<t<<endl;
	}
	return 0;
}


Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i = 0, num = 0;
		String str;
		try (Scanner sc = new Scanner(System.in)) {
			while(true) {
				int count = 0;
				str = sc.nextLine();

				for(i = 0; i < str.length(); i++) {
					num = Integer.parseInt(str.substring(i,i + 1));
					count += num;
				}
				if(num == 0 && i == 1) {
					break;
				}
				System.out.println(count);
			}
		}
	}
}



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

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> A(n, vector<int>(m));
    vector<int> b(m);
    for(int i=0; i<A.size(); i++){
        for(int j=0; j<A.at(0).size(); j++){
            cin >> A.at(i).at(j);
        }
    }
    for(int i=0; i<b.size(); i++){
        cin >> b.at(i);
    }
    vector<int> c(n);
    for(int i=0; i<c.size(); i++){
        for(int j=0; j<b.size(); j++){
            c.at(i)+=A.at(i).at(j)*b.at(j);
        }
        cout << c.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define i64 long long
using namespace std;


int nprime;
vector<int>v;
int mark[1000002];
void sieve(int n)
{
    int i,j,limit=sqrt(n*1.00)+2;
    mark[1]=1;
    for(i=4;i<=n;i+=2) mark[i]=1;
    v.push_back(2);
    for(i=3;i<=n;i+=2)
    {
        if(!mark[i])
        {
            v.push_back(i);
            if(i<=limit)
            {for(j=i*i;j<=n;j+=i*2)
                {mark[j]=1;}}}
    }
}















//ull bigmod(ull N,ull P,int M)
//{
//
//	if(P==0) return 1;
//	if(P%2==0)
//	{
//		ull ret=bigmod(N,P/2);
//		return ((ret%M)*(ret%M))%M;
//	}
//	else return ((N%M)*(bigmod(N,P-1)%M))%M;
//
//}






int main()
{
    int x,n=1000002;
    cin>>x;
    sieve(n);
    for(int i=0;i<v.size();i++) {if(v[i]>=x) {cout<<v[i]<<endl;break;}}

    return 0;
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (not (c < a) and not(c > b) ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

template<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;
    
    SegTree(int n, const Func f, const Monoid &unity): F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* update a, a is 0-indexed */
    void update(int a, const Monoid &v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k*2], dat[k*2+1]);
    }
    
    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }                                                                                                              
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R-1) cout << ",";
        }
        cout << endl;
    }
};

//--------------------------- Solve ---------------------------//

const int INF = 1000000000;
const int MAX = 600005;

void solve() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    SegTree<int> seg(MAX, [](int a, int b){ return max(a, b); }, 0);
    for (int i = 0; i < N; i++) {
        seg.update(A[i], seg.get(max(0, A[i]-K), A[i]+K+1)+1);
    }

    cout << seg.get(0, MAX) << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 12704
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::vector<intmax_t>> A(N, std::vector<intmax_t>(N));
  for (auto& ai: A)
    for (auto& aij: ai) scanf("%jd", &aij);

  auto B = A;
  for (size_t k = 0; k < N; ++k)
    for (size_t i = 0; i < N; ++i)
      for (size_t j = 0; j < N; ++j)
        B[i][j] = std::min(B[i][j], B[i][k]+B[k][j]);

  if (A != B)
    return puts("-1"), 0;

  intmax_t res = 0;
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < N; ++j) {
      bool found = false;
      for (size_t k = 0; k < N; ++k) {
        if (k == i || k == j) continue;
        if (B[i][j] < B[i][k]+B[k][j]) continue;
        found = true;
        break;
      }
      if (!found)
        res += B[i][j];
    }

  printf("%jd\n", res/2);
}


Measured memory_bytes: 1664