akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MAX=1100;

vector<int> v;
long long n;
long long ans=0;
int A[]={3,5,7};

long long cal(){
    long long ans=0;
    for(int i=0;i<v.size();i++){
        ans=ans*10+v[i];
    }
    return ans;
}

bool judge(){
    bool flag1=false,flag2=false,flag3=false;
    for(int i=0;i<v.size();i++){
        if(v[i]==3)
            flag1=true;
        if(v[i]==5)
            flag2=true;
        if(v[i]==7)
            flag3=true;
    }
    return flag1&&flag2&&flag3;
}

void dfs(int step,int depth){
    if(step==depth){
        if(judge() && cal()<=n){
            ans++;
            //printf("%d\n",cal());
        }
        return;
    }
    for(int i=0;i<3;i++){
        v.push_back(A[i]);
        dfs(step+1,depth);
        v.pop_back();
    }
}

int main()
{
    scanf("%lld",&n);
    long long temp=n;
    int len=0;
    while(temp){
        temp=temp/10;
        len++;
    }
    //printf("%d\n",len);
    for(int i=3;i<=len;i++){
        dfs(0,i);
        v.clear();
    }
    printf("%d\n",ans);
    return 0;
}



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

int main(){
  int X, Y;
  cin >> X >> Y;
  bool judge = false;
  for(int i = 0; i <= X; i++){
    if(i*2 + (X-i)*4 == Y){
      judge = true;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - M&#39;s Solution
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 15;
const int NBITS = 1 << MAX_N;
const int INF = 1 << 30;
const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

int xs[MAX_N], ys[MAX_N], ps[MAX_N];
int dxs[NBITS][MAX_N], dys[NBITS][MAX_N];
int hls[MAX_N + 1], vls[MAX_N + 1], hlns[NBITS], vlns[NBITS], vs[MAX_N];
ll minss[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d", xs + i, ys + i, ps + i);
  int nbits = 1 << n;

  for (int bits = 0; bits < nbits; bits++) {
    hls[0] = vls[0] = 0;
    int hln = 1, vln = 1;
    for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
      if (bits & bi) {
	hls[hln++] = ys[i];
	vls[vln++] = xs[i];
      }

    sort(hls, hls + hln);
    hlns[bits] = hln = unique(hls, hls + hln) - hls;
    sort(vls, vls + vln);
    vlns[bits] = vln = unique(vls, vls + vln) - vls;

    for (int i = 0; i < n; i++) {
      int hi = upper_bound(hls, hls + hln, ys[i]) - hls;
      int dy0 = (hi > 0) ? (ys[i] - hls[hi - 1]) : INF;
      int dy1 = (hi < hln) ? (hls[hi] - ys[i]) : INF;
      dys[bits][i] = min(dy0, dy1);

      int vi = upper_bound(vls, vls + vln, xs[i]) - vls;
      int dx0 = (vi > 0) ? (xs[i] - vls[vi - 1]) : INF;
      int dx1 = (vi < vln) ? (vls[vi] - xs[i]) : INF;
      dxs[bits][i] = min(dx0, dx1);
    }
  }

  fill(minss, minss + n + 1, LINF);

  for (int bits = 0; bits < nbits; bits++) {
    int m = 0;
    for (int i = 0, bi = 1; i < n; i++, bi <<= 1)
      if (bits & bi) vs[m++] = i;
    int mbits = 1 << m;

    for (int eits = 0; eits < mbits; eits++) {
      int hbits = 0, vbits = 0;
      for (int i = 0, bi = 1; i < m; i++, bi <<= 1) {
	if (eits & bi) hbits |= (1 << vs[i]);
	else vbits |= (1 << vs[i]);
      }

      ll sum = 0;
      for (int i = 0; i < n; i++)
	sum += (ll)min(dys[hbits][i], dxs[vbits][i]) * ps[i];

      int k = hlns[hbits] + vlns[vbits] - 2;
      if (minss[k] > sum) minss[k] = sum;
    }
  }

  for (int i = 0; i <= n; i++) {
    if (i > 0 && minss[i] > minss[i - 1]) minss[i] = minss[i - 1];
    printf("%lld\n", minss[i]);
  }
  return 0;
}


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    KEYENCE2020A solver = new KEYENCE2020A();
    solver.solve(1, in, out);
    out.close();
  }

  static class KEYENCE2020A {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int h = in.nextInt();
      int w = in.nextInt();
      int n = in.nextInt();
      int m = Math.max(h, w);
      out.println((n + (m - 1)) / m);

    }

  }
}



Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;
ll dp[105][100005];

int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    for(int i = 0; i< n; i++){
        cin >> w[i] >> v[i];
    }
    dp[0][0] = 0;
    for(int i = 0; i< n; i++){
        for(int sum_w = 0; sum_w <= W; sum_w++){
            if(sum_w-w[i] >= 0){
                dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w-w[i]]+v[i]);
            }
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

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

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	
	if(s.size()!=t.size()){
		cout << "No" << endl;
		return 0;
	}
	
	if(s==t){
		cout << "Yes" << endl;
		return 0;
	}
	
	int x,count;
	for(int i=1;i<s.size();i++){
		count=0;
		for(int j=0;j<s.size();j++){
			x=j+i;
			if(x>=s.size())x=x-s.size();
			if(t[j]==s[x])count++;
		}
		if(count==s.size()){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



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

int N;
vector<int> a;
vector<int> b;
vector<int> c;

int main() {
    cin>>N;
    a.resize(N); b.resize(N); c.resize(N);
    for (int i=0; i<N; i++) cin>>a[i];
    for (int i=0; i<N; i++) cin>>b[i];
    for (int i=0; i<N-1; i++) cin>>c[i];
    int satice=0;
    int temp=-2;
    for (int i=0; i<N; i++) {
        satice+=b[a[i]-1];
        if (temp==a[i]-2) satice+=c[a[i]-2];
        temp=a[i]-1;
    }
    cout<<satice<<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;
typedef pair<int,int> P;

int main(){
  int l;
  cin>>l;
  int n=0;
  rep(bit,25){
    if(l&(1<<bit))n=max(n,bit+1);
  }
  vector<int>u,v,w;
  rep(i,n-1){
    u.push_back(i);
    v.push_back(i+1);
    w.push_back(0);
    u.push_back(i);
    v.push_back(i+1);
    w.push_back(1<<i);
  }
  rep(bit,n-1){
    if(l&(1<<bit)){
      u.push_back(bit);
      v.push_back(n-1);
      w.push_back(l-(1<<bit));
      l-=(1<<bit);
    }
  }
  int m=u.size();
  cout<<n<<" "<<m<<endl;
  rep(i,m){
    cout<<u[i]+1<<" "<<v[i]+1<<" "<<w[i]<<endl;
  }
}

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int count =0;
		Set<Integer> set = new HashSet<Integer>();
		Set<Integer> repeat = new HashSet<Integer>();
		for (int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			if (set.contains(A[i])) {
				repeat.add(A[i]);
			}
			set.add(A[i]);
		}
		Arrays.sort(A);
		for (int i=0;i<N;i++) {
			if (repeat.contains(A[i])) {
				continue;
			}
			boolean b = false;
			if (A[i]!=1) {
				if (set.contains(1)==true) {
					continue;
				}
			}
			for (int j=2;j*j<=A[i];j++) {
				if (A[i]%j==0) {
					if (set.contains(A[i]/j)||set.contains(j)) {
						b = true;
						break;
					}
				}
			}
			if (b==false) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

long long F(long long a, long long b){
    long long l = max(a,b);
    long long k = log10(l) + 1;
    return k;
}

int main(){
    long long n;
    long long a,b;
    long long ans = 10000;
    cin >> n;
    for(long long i = 1; i*i <= n; i++){
        if(n % i == 0){
            a = i;
            b = n / i;
            ans = min(ans,F(a,b));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    cout1((N-1)*(M-1))
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<i64>();
    for h in 1..3501 {
        for j in 1..3501 {
            if 4*h*j - n*j - n*h > 0 && n*h*j % (4*h*j - n*j - n*h) == 0 {
                println!("{} {} {}", h, j, n*h*j/(4*h*j-n*j-n*h));
                return;
            }
        }
    }
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

int main(){
	int n;
	cin >> n;
	if ((n % 1110-n%10) == 0 || (n - (n / 1000) * 1000) % 111 == 0) {
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a+b+c==17)
	{
		if (a==7||b==7||c==7)
		{
			if (a==5||b==5||c==5)
			{
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}else{
			printf("NO\n");
		}
	}else{
		printf("NO\n");
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		for(int i = s.length() - t.length() ; i >= 0  ; i--) {
			boolean ok = true;
			for(int j = 0 ; j < t.length() ; j++) {
				if(s.charAt(i + j) != '?' && s.charAt(i + j) != t.charAt(j)) ok = false;
			}
			if(ok) {
				String temp = s.substring(0, i) + t + s.substring(i + t.length());
				System.out.println(temp.replaceAll("\\?", "a"));
				return;
			}
		}
		System.out.println("UNRESTORABLE");
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
int a[N];
int dp[N];
int n;

int func(int index){
    if(index==n-1){
        return 0;
    }
    if(dp[index]!=-1)   return dp[index];
    int ans=2e9;
    for(int k=1;k<=2 && index+k<n;k++){
        ans=min(ans,abs(a[index]-a[index+k])+func(index+k));
    }
    return dp[index]=ans;
}
main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)    cin>>a[i];
    cout<<func(0)<<"\n";
}

Measured memory_bytes: 9020
n=int(input())
a=list(map(int,input().split()))

time={}
zentai=0
for i in range(n):
  if a[i] in time:
    zentai+=time[a[i]]
    time[a[i]]+=1
  else:
    time[a[i]]=1

for i in range(n):
  ans=zentai-(time[a[i]]-1)
  print(ans)

Measured memory_bytes: 86476
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<bool> visited(N);
    vector<vector<int>> graph(N);
    deque<int> path;
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int curr = 0;
    while (!visited[curr]) {
        visited[curr] = true;
        path.push_back(curr);
        for (int n : graph[curr]) if (!visited[n]) { curr = n; break; }
    }
    curr = 0, visited[0] = false, path.pop_front();
    while (!visited[curr]) {
        visited[curr] = true;
        path.push_front(curr);
        for (int n : graph[curr]) if (!visited[n]) { curr = n; break; }
    }
    cout << path.size() << '\n';
    for (int i = 0; i < path.size(); i++) {
        if (i != 0) cout << ' ';
        cout << path[i] + 1;
    }
    cout << '\n';
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
const int maxL = 2e5+10;
ll L;
ll dp[maxL][5];
int main(){
  cin >> L;
  ll a[L];
  rep(i,L) cin >> a[i];

  rep(i,L){
    //0
    dp[i+1][0] = dp[i][0] + a[i];
    //even
    dp[i+1][1] = min(dp[i+1][0], dp[i][1] + a[i] % 2 + (!a[i])*2 );
    //odd
    dp[i+1][2] = min(dp[i+1][1], dp[i][2] + !(a[i]&1) );
    //even
    dp[i+1][3] = min(dp[i+1][2], dp[i][3] + a[i] % 2 + (!a[i])*2 );
    //0
    dp[i+1][4] = min(dp[i+1][3], dp[i][4] + a[i] );

  }
  cout << dp[L][4] << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,k; cin >>a>>b>>k;

    vector<int> v;

    int i = 1;
    while (i <= min(a,b)) {
        if(a % i == 0 && b % i == 0) {
            v.push_back(i);
        } 
        i += 1;
    }

    cout << v[v.size()-k] << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST int inox,t;cin>>t; for(inox=1;inox<=t;inox++)
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,n) for(i=n-1;i>=0;i--)
#define FAST    ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
#define modd 998244353 
 ll ans=100000000000000;
 void fun(vector<vector<ll>> a, vector<ll> c, ll i, ll x, vector<ll> v, ll cost){
 	ll k,j;
 	if(i>=c.size())return;
 	fun(a,c,i+1,x,v,cost);
 	ll n=a.size(),m=a[0].size(),f=0;
 	rep(j,m){if(v[j]<x){f=1;break;}}
 	if(!f){ans=min(ans,cost); return;}
 	rep(j,m)v[j]+=a[i][j];
 	cost+=c[i];
 	fun(a,c,i+1,x,v,cost);
 	f=0;
 	rep(j,m){if(v[j]<x){f=1;break;}}
 	if(!f){ans=min(ans,cost); return;}
 }
int main(){
FAST;
ll n,m,x; cin>>n>>m>>x;
vector<ll> c(n); ll i,j;
vector<ll> b(m);
vector<ll> v(m,0);
vector<vector<ll>> a(n,b);
rep(i,n){
	cin>>c[i];
	rep(j,m)cin>>a[i][j];
}
fun(a,c,0,x,v,0);
if(ans==100000000000000)ans=-1;

cout<<ans;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n, m, M = 1e9+7;
    cin >> n >> m;
    
    string g[n];
    forn(i, 0, n) {
        cin >> g[i];
    }
    
    int dp[n][m] = {};
    dp[0][0] = 1;
    forn(i, 0, n) {
        forn(j, 0, m) {
            if (i && g[i-1][j] == '.') {
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % M;
            }
            if (j && g[i][j-1] == '.') {
                dp[i][j] = (dp[i][j] + dp[i][j-1]) % M;
            }
        }
    }
    
    cout << dp[n-1][m-1] << endl;
}


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

using namespace std;

int main(){
	long N, K;
	string S;
    cin>>N>>K;
    cin>>S;
    int s_len = S.length();

    vector<int> nums;
    for(int i=0; i<s_len-1;){
        int c=1;
        while(S[i]==S[i+1]){
            c++;
            ++i;
        }
        nums.push_back(c);
        ++i;
    }
    if(S[s_len-2]!=S[s_len-1]){
        nums.push_back(1);
    }

    if(S[0]=='0'){
        nums.insert(nums.begin(), 0);
    }
    if(S[s_len-1]=='0'){
        nums.push_back(0);
    }

    int nums_max=0;
    for(int i=0; i<2*K+1; ++i){
        if(i<nums.size()){
            nums_max += nums[i];
        }else{
            cout<<nums_max<<endl;
            return 0;
        }
    }
    int sum = nums_max;
    for(int i=2*K+1; i<nums.size(); i+=2){
        int value = sum + nums[i] + nums[i+1] - nums[i-(2*K+1)] - nums[i-(2*K+1)+1];
        if(nums_max <= value){
            nums_max = value;
        }
        sum = value;
    }

    cout<<nums_max<<endl;

    return 0;
}

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

int main()
{
int n;
cin>>n;
if(n>=64)
    cout<<64;
else if(n>=32&&n<64)
    cout<<32;
else if(n>=16&&n<32)
    cout<<16;
else if(n>=8&&n<16)
    cout<<8;
else if(n>=4&&n<8)
    cout<<4;
else if(n>=2&&n<4)
    cout<<2;
else cout<<1;

    return 0;
}


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

int main(){
    int n,a;
    cin>>n;
    vector<int>k(100000+1,0);
    for(int i=0;i<n;i++){
        cin>>a;
        if(!k[a])k[a]++;
    }
    int ans=accumulate(k.begin(),k.end(),0);
    cout<<(ans%2?ans:ans-1)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N, M;
	cin >> N >> M;
	int sum = 0;
	rep(i, M) {
		int A;
		cin >> A;
		sum += A;
	}
	if (sum <= N)cout << N - sum;
	else cout << -1;
}

Measured memory_bytes: 3636
h={}
n=gets.chomp.to_i
n.times{
  s=gets.chomp
  h[s]=0 if h[s]==nil
  h[s]+=1
}
m=gets.chomp.to_i
m.times{
  s=gets.chomp
  h[s]=0 if h[s]==nil
  h[s]-=1
}
ma=0
h.each{|k,b|
  ma=[ma,b].max
}
puts ma

Measured memory_bytes: 1788
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

""" 
左側で自分より小さい数字との差
右側で自分より大きい数字の数
石数最大の山で右の物から取り除く
"""
N = ir()
A = lr()
A = [(x, i+1) for i, x in enumerate(A)] + [(0, 0)]
A.sort(reverse=True)
answer = [0] * (N+1)  # 1-indexed
mi = 10 ** 10
mi_index = 10 ** 10
for i, (x, j) in enumerate(A[:-1]):
    diff = A[i][0] - A[i+1][0]
    index = A[i][1]
    if index < mi_index:
        mi_index = index
    answer[mi_index] += diff * (i+1)

print('\n'.join(map(str, answer[1:])))


Measured memory_bytes: 35216
#include <bits/stdc++.h>      
using namespace std;
const int N = 1e5 + 100;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ull unsigned long long
#define ll long long
#define pii pair <int,int>
#define forn(l,i,n) for(int i = l;i <= n;++i)   
#define FOR(l,i,n) for(int i = l;i < n;++i)
#define all(v) v.begin(), v.end()
#define pll pair <ll,ll>
const ll inf = 1e9 + 7;
const ll ll_inf = 1e17 + 100;   
const double pi = 3.14159265358979323;
inline void fr(){
    freopen("gcd.in", "r", stdin);
    freopen("gcd.out", "w", stdout);
}
void boost()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
 
ll binpow (ll a, ll n)
{
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }
        a *= a;
        n >>= 1;
        a %= inf;
    }
    return res;
}
        
int n;
int a[N],b[N],c[N];
int dp[N][5];
 
main()	
{                                                                        
	cin >> n;
	for (int i = 1;i <= n;++i)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	dp[1][1] = a[1];
	dp[1][2] = b[1];
	dp[1][3] = c[1];
	for (int i = 2;i <= n;++i)
	{
		dp[i][1] = max(dp[i - 1][2],dp[i - 1][3]) + a[i];
		dp[i][2] = max(dp[i - 1][1],dp[i - 1][3]) + b[i];
		dp[i][3] = max(dp[i - 1][1],dp[i - 1][2]) + c[i];
	}
	cout << max(dp[n][1],max(dp[n][2],dp[n][3]));
}	 


Measured memory_bytes: 3328
#include <cstdio>
int main()
{
	int s,t,i,j,sum=0,judge=0;
	int n[10001],q[501];
	scanf("%d",&s);
	for(i=0;i<s;i++)
	{
		scanf("%d",&n[i]);
	}
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d",&q[i]);
	}
	for(i=0;i<t;i++)
		for(j=0;j<s;j++)
		{
			if(q[i]==n[j])
			{
				sum++;
				break;
			}
		}
	printf("%d\n",sum);
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
cin>>n;
cout << (n > 29 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620
// Spreadsheet.cc
// 表計算を行う簡単なプログラムを作成します。
// 表の行数rと列数c、r × c の要素を持つ表を読み込んで、
// 各行と列の合計を挿入した新しい表を出力するプログラムを作成して下さい。
// 【入力】
// 最初の行にrとcが空白区切りで与えられます。
// 続くr行にそれぞれc個の整数が空白区切りで与えられます。
// 【出力】
// (r+1) × (c+1) の新しい表を出力して下さい。
// 各行の隣り合う整数は１つの空白で区切って下さい。
// 各行の最後の列としてその行の合計値を、各列の最後の行としてその列の合計値を、
// 最後の行・列に表全体の合計値を挿入して下さい。
// 【制約】
// ・1 ≤ r, c ≤ 100
// ・0 ≤ 要素 ≤ 100
// 【例】
// 入力：
// 4 5
// 1 1 3 4 5
// 2 2 2 4 5
// 3 3 0 1 1
// 2 3 4 4 6
// 出力
// 1 1 3 4 5 14
// 2 2 2 4 5 15
// 3 3 0 1 1 8
// 2 3 4 4 6 19
// 8 9 9 13 17 56
#include<iostream>
using namespace std;

int main( void) {
  int r, c;
  int matrix[ 100 + 1][ 100 + 1] = {};
  
  cin >> r >> c;

  // 表データの入力
  for ( int i = 0; i < r; i++) {
    for ( int j = 0; j < c; j++) {
      cin >> matrix[i][j];
      matrix[i][c] += matrix[i][j];
      matrix[r][j] += matrix[i][j];
      matrix[r][c] += matrix[i][j];
    }
  }

  // 新しい表の出力
  for ( int i = 0; i <= r; i++) {
    for ( int j = 0; j <= c; j++) {
      cout << matrix[i][j];
      if ( j < c) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3136
import math
N=int(input())
List=[list(map(int,input().split())) for i in range(N)]
V=[]
for idx in range(N):
    a=List[idx]
    for idy in range(N):
        if idx == idy:
            continue
        b=List[idy]
        V.append(pow(pow(a[0]-b[0],2) + pow(a[1]-b[1], 2), 1/2))
sum=0
pattern=math.factorial(N)
for i in V:
    sum += i * int(pattern/N)
print(sum/pattern)

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

using namespace std;

#define ll long long
#define f first
#define s second
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define pb push_back

void solve() {
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	for(int i=k;i<n;i++) {
		if(a[i]>a[i-k]) {
			cout<<"Yes\n";
		}
		else cout<<"No\n";
	}
}

int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	//freopen("ou.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--) {
    	solve();
    }
    return 0;
}

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

const int INF = 1e9;

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

  int n, W;
  cin >> n >> W;

  vector<ll> dp(W+1);

  for(int i=0; i<n; i++) {
    int w, v;
    cin >> w >> v;
    for(int j=W-w; j>=0; j--) {
      dp[j+w] = max(dp[j+w], dp[j] + v);
    }
  }

  cout << *max_element(dp.begin(), dp.end()) << '\n';
  
  return 0;
}

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

H, W = map(int, input().split())
S = list(list(map(str, input().split())) for i in range(H))

for i in range(H):
    for j in range(W):
        if S[i][j] == 'snuke':
            print(chr(65 + j) + str(i + 1))
            break


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int mp[111111];
int mo[111111];

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n, m;cin >> n >> m;
	ll ans = 0;
	
	REP(i,n){
		int a;
		cin >> a;
		mp[a]++;
		mo[a%m]++;
	}
	
	REP(i, m){
		if(i == 0 || i == m - i){
			ans += mo[i] / 2;
			mo[i] %= 2;
			continue;
		}
		int pa = m - i;
		int tmp = min(mo[i], mo[pa]);
		ans += tmp;
		mo[i] -= tmp;
		mo[pa] -= tmp;
	}
	
	REP(i, 111111){
		while(mp[i] > 1 && mo[i%m] > 1){
			ans++;
			mp[i] -= 2;
			mo[i%m] -= 2;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if((C+B-1)/B > (A+D-1)/D){
        cout << "No" << enld;
    }else{
        cout << "Yes" << enld;
    }
    return 0;
}

Measured memory_bytes: 3648
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll> >;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    // 座標変換 (x, y) -> (x + y, x - y)
    // |x1 - x2| + |y1 - y2| = max(|z1 - z2|, |w1 - w2|)
    vector<ll> a(N), b(N);
    rep(i, N){
        ll x, y; cin >> x >> y;
        a.at(i) = x + y;
        b.at(i) = x - y;
    }
    ll a_range = *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
    ll b_range = *max_element(b.begin(), b.end()) - *min_element(b.begin(), b.end());
    cout << max(a_range, b_range) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int d[55];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> d[i];
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int s,w;
	std::cin >> s >> w;
	std::cout << ((s>w)?"safe":"unsafe") << std::endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int n;
const int mxN = 210;
int dis[mxN][mxN];
vector<int> G[mxN];
int col[mxN] = {0};

bool dfs(int i, int c) {
    col[i] = c;
    for(auto v : G[i]) {
        if(col[v] == c) return false;
        if(col[v] == 0 && !dfs(v, -c)) return false;
    }
    return true;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++) {
        char p;
        cin >> p;
        int q = p - '0';
        dis[i][j] = q;
        if(dis[i][j] == 1) {
            G[i].push_back(j);
        }else{
            if(i != j) dis[i][j] = INF;
        }
    }
    if(!dfs(0, 1)) {
        cout << -1 << endl;
        return 0;
    }
    for(int k = 0; k < n; k++)for(int i = 0; i < n; i++)for(int j = 0; j < n; j++) {
        chmin(dis[i][j], dis[i][k] + dis[k][j]);
    }
    int ans = 0;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) {
        chmax(ans, dis[i][j]);
    }
    ans++;
    cout << ans << endl;
}

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

int main(void){
    int n,m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<m;i++) cin >> b[i];

    vector<ll> sa(n+1,0);
    for(int i=0;i<n;i++) sa[i+1] = sa[i]+a[i];
    for(int i=0;i<m-1;i++) b[i+1] += b[i];


    int ans = 0;
    for(int i=0;i<=n;i++){
        ll rest = k-sa[i];
        if(rest<0) break;

        auto itr = lower_bound(b.begin(),b.end(),rest);
        int tmp = i+(int)(itr-b.begin());
        if(itr!=b.end() && *itr==rest) tmp++;
        ans = max(ans,tmp);
    }

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

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <algorithm>

using namespace std;

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


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    bool ls[26];
    
    for(int i = 0; i < 26; i++)
    {
        ls[i]=false;
    }
    
    
    for(int i = 0; i < s.size(); i++)
    {
        ls[s[i]-'a'] =true;
    }
    
    for(int i = 0; i < 26; i++)
    {
        if(ls[i]==false)
        {
            cout<<(char)('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    

    return 0;
}

Measured memory_bytes: 512
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p.rbegin(), p.rend());
	p[0] /= 2;

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

}

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;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint comb(ll N, ll a) {
  mint mnum(1);
  mint mden(1);
  for (ll n = N; n > N - a; n--) {
    mnum *= n;
    mden *= (N + 1 - n);
  }
  mnum /= mden;
  return mnum;
}

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  mint m2(2);
  mint mall = m2.pow(N);
  mint nCa = comb(N, A);
  mint nCb = comb(N, B);
  mint m1(1);
  mall -= m1;
  mall -= nCa;
  mall -= nCb;
  cout << mall << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main(){
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    for(ll &a:A)
        cin >> a;
    for(ll &b:B)
        cin >> b;
    for(ll &c:C)
        cin >> c;
    
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    
    vector<ll> AB;
    for(int i=0; i<X; i++){
        for(int j=0; j<Y; j++){
            AB.push_back(A[i]+B[j]);
        }
    }
    
    sort(AB.begin(), AB.end(), greater<ll>());
    vector<ll> ABC;
    for(int i=0; i<min(K, (int)AB.size()); i++){
        for(int j=0; j<Z; j++){
            ABC.push_back(AB[i] + C[j]);
        }
    }
    
    sort(ABC.begin(), ABC.end(), greater<ll>());
    for(int i=0; i<K; i++){
        cout << ABC[i] << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 43240
x, y, a, b, c = map(int,input().split())
p = (list(map(int,input().split())))
q = (list(map(int,input().split())))
r = (list(map(int,input().split())))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
apple = p + q + r
apple.sort(reverse=True)
ans = sum(apple[:x+y])
print(ans)

Measured memory_bytes: 112236
#include <bits/stdc++.h>
#include<string>
#include <iostream>
#include <vector>

using namespace std;

vector<string> split(string str, string separator) {
    if (separator == "") return {str};
    vector<string> result;
    string tstr = str + separator;
    long l = tstr.length(), sl = separator.length();
    string::size_type pos = 0, prev = 0;
    
    for (;pos < l && (pos = tstr.find(separator, pos)) != string::npos; prev = (pos += sl)) {
        result.emplace_back(tstr, prev, pos - prev);
    }
    return result;
}

int main() {
  string input;
  cin >> input;
  
  vector<string> ary = split(input, "hi");
  
  for(auto a: ary){
    if(a != ""){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	bool can=true;
	cin >>n;
	V h(n);
	rep(i,n){
		cin>>h[i];
	}
	for(int i=n-2;i>=0;i--){
		if(h[i] >h[i+1]){
			if(h[i]-1<= h[i+1]){
				h[i]--;
			}else{
				can=false;
			}
		}
	}
	cout<<solve(can)<<endl;
}

Measured memory_bytes: 4052
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/11/20 19:53:47
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> ans(n+1, 0);
  for (ll i = 1; i*i <= n; i++) {
    ll f = i*i;
    for (ll j = 1; j <= n; j++) {
      ll ff = f + j*(i+j);
      if (ff > n)
        break;
      for (ll k = 1; k <= n; k++) {
        ll fff = ff + k * (k + i + j);
        if (fff > n)
          break;
        ans[fff]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

using namespace std;

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

    vector< pair<long long, long long> > v;

    for (int i=0; i<N; i++) {
        long long a;
        cin >> a;
        v.push_back(make_pair(a, 1));
    }

    for (int i=0; i<M; i++) {
        long long b, c;
        cin >> b >> c;
        v.push_back(make_pair(c, b));
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    long long ans=0, idx=0;
    for (int i=0; i<v.size(); i++) {
        if (v[i].second + idx <= N) {
            ans += v[i].first * v[i].second;
            idx += v[i].second;
        } else {
            ans += (N - idx) * v[i].first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6384
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int M=0,i=1,res,D,N,count=0,v,mod,a[10001];
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&a[i]);
  for(i=0;i<N;i++){
    while(a[i] % 2 == 0){
      a[i] = a[i] >> 1;
      count++;
    }
  }
  printf("%d\n",count);
  return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        vector<pair<double, string>> yen(N);
        for (int i = 0; i < N; i++)
        {
                double x;
                string u;
                cin >> x >> u;
                yen[i] = make_pair(x, u);
        }

        double ans = 0;
        for (int i = 0; i < N; i++)
        {
                if (yen[i].second == "JPY")
                {
                        ans += 1. * yen[i].first;
                }
                else if (yen[i].second == "BTC")
                {
                        ans += 1. * 380000 * yen[i].first;
                }
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int N, M;
	int L[100000] = { 0 };
	int R[100000] = { 0 };
	int maxL,minR;
	int ans = 0;
	scanf("%d %d",&N,&M);

	for (int i = 0; i < M; i++) {
		scanf("%d %d", &L[i], &R[i]);
	}
	maxL = L[0];
	minR = R[0];
	for (int i =1; i < M; i++) {
		if (maxL < L[i]) maxL = L[i];
		if (minR > R[i]) minR = R[i];
	}
	if (maxL <= minR) {
		ans = minR - maxL + 1;
	}
				std::cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int n;
  while(cin>>n,n){
    int left=0,right=0;
    int ans=0;
    string pre="a";
    rep(i,n){
      string s;
      cin>>s;
      if(s=="lu"&&pre=="ru")ans++;
      if(s=="ru"&&pre=="lu")ans++;
      if(s=="ld"&&pre=="rd")ans++;
      if(s=="rd"&&pre=="ld")ans++;
      pre=s;
    }
    cout<<ans<<endl;
  }

 return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

const int M=4005,N=2000;

int dp[M][M],ask[M][M]; 
ll fac[M*2],inv[M*2],del,ans; 

ll ksm(ll x,int y){
	ll res=1;
	while(y){
		if(y&1) res=res*x%mod;
		x=x*x%mod,y>>=1; 
	}
	return res;
}

ll C(int n,int m){ 
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
} 

int main(){
	int n;ll del=0;
	scanf("%d",&n);
	fac[0]=inv[0]=1; 
	for(int i=1;i<M*2;i++) fac[i]=fac[i-1]*i%mod;
	inv[M*2-1]=ksm(fac[M*2-1],mod-2);
	for(int i=M*2-2;i;i--) inv[i]=inv[i+1]*(i+1)%mod; 
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		del=(del+C(2*x+2*y,2*x))%mod;
		dp[N-x][N-y]++,ask[N+x][N+y]++; 
	} 
	for(int i=0;i<M;i++) 
		for(int j=0;j<M;j++){
			if(i!=0) dp[i][j]+=dp[i-1][j];
			if(j!=0) dp[i][j]+=dp[i][j-1]; 
			dp[i][j]%=mod;
			ans=(ans+1ll*ask[i][j]*dp[i][j])%mod;
		} 
	ans=(ans-del+mod)%mod;
	printf("%lld",ans*ksm(2,mod-2)%mod);
	return 0;
}


Measured memory_bytes: 95104
program test
implicit none
integer :: i,y
character(3) :: s


read(*,*) s

if(s=='ooo') then
  y = 1000
else if (s=='xoo' .or. s=='oxo' .or. s=='oox') then
  y = 900
else if (s=='xxo' .or. s=='oxx' .or. s=='xox') then
  y = 800 
else
  y = 700
endif
 
 
 write(*,*) y
 
end program

Measured memory_bytes: 768
n,m,c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
a = n.times.map{gets.split.map(&:to_i)}

p n.times.map{|i|m.times.map{|j|a[i][j]*b[j]}.inject(:+)+c}.count{|x|x>0}

Measured memory_bytes: 1916
using System;

public class AtCoder
{
    public static void Main()
    {
        var line = Console.ReadLine();
        var lineWords = line.Split(' ');
        int a = int.Parse(lineWords[0]);
        int b = int.Parse(lineWords[1]);

        string strX = "";
        for (int i = 0; i < b; i++)
        {
            strX += a;
        }

        string strY = "";
        for (int i = 0; i < a; i++)
        {
            strY += b;
        }

        Console.WriteLine(a < b ? strX : strY);
    }
}

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

int main(){
	int d;
	string str;
	while(1){
		int S = 0;
		getline( cin, str );
		if( str.length()==0 )	break;
		sscanf( str.c_str(), "%d", &d );
		for( int x=d; x<600; x+=d ){
			S += d*x*x;
		}
		cout << S << endl;
	}
	return 0;
}

Measured memory_bytes: 0