akhauriyash/Code-Regression huggingface dataset:
use proconio::{
    input, 
    fastout,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        aa: [usize; n],
    }

    let mut max = aa.iter().copied().max().unwrap();
    let mut min = 1;
    let mut ans = max;

    while min < max {
        let mid = (min + max) / 2;
        let mut count = 0;
        for &a in aa.iter() {
            if a <= mid {
                continue;
            }
            count += a / mid;
        }
        if count <= k {
            max = mid;
            ans = mid;
        } else {
            min = mid + 1;
        }
    }

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


Measured memory_bytes: 5392
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvl vector<vector<ll>>
#define v(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<1000, std::int64_t>> fl;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;

  fl d = (4*m);
  d = 1.0/d;
  vll a(n);
  fl s = 0;
  re(i, n){
    std::cin >> a[i];
    s += a[i];
  }
  fl S = s;
  S *= d;
  ll c = 0;
  re(i, n){
    if(a[i]>=S) c++;
  }
  std::cout << (c>=m?"Yes":"No") << '\n';

  return 0;
}


Measured memory_bytes: 1144
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {


	int x;
	cin>>x;

	if(x==4||x%7==4){
		cout<<"mon"<<endl;
	}else if(x==5||x%7==5){
		cout<<"tue"<<endl;
	}else if(x==6||x%7==6){
		cout<<"wed"<<endl;
	}else if(x%7==0){
		cout<<"thu"<<endl;
	}else if(x==1||x%7==1){
		cout<<"fri"<<endl;
	}else if(x==2||x%7==2){
		cout<<"sat"<<endl;
	}else if(x==3||x%7==3){
		cout<<"sun"<<endl;
	}




}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

vector<int> num(2010); //num[i]は２点間の距離がiの個数
vector<int> d(2010, 0); //距離
vector<bool> seen(2010, false);

//vスタートのbfs 
void bfs(const Graph &G, int v) {
	seen[v] = true;
	d[v] = 0;
	queue<int> que;
	que.push(v);

	while (que.size()) {
		int iTop = que.front();
		que.pop();

		for (auto next_iTop : G[iTop]) {
			if (seen[next_iTop] == false) {
				seen[next_iTop] = true;
				d[next_iTop] = d[iTop] + 1;
				num[d[next_iTop]]++;
				que.push(next_iTop);
			}
		}
	}

}

int main() {
	int N, X, Y;
	cin >> N >> X >> Y;

	Graph G(N + 1);
	G[1].push_back(2);
	G[N].push_back(N - 1);
	G[X].push_back(Y);
	G[Y].push_back(X);

	for (int i = 2; i <= N - 1; i++) {
		G[i].push_back(i - 1);
		G[i].push_back(i + 1);
	}

	for (int v = 1; v <= N; v++) {
		bfs(G, v);
		for (int i = 0; i < d.size(); i++) d[i] = 0;
		for (int i = 0; i < seen.size(); i++) seen[i] = false;
	}
	for (int k = 1; k <= N - 1; k++) {
		cout << num[k] / 2 << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<deque>
using namespace std;
int main()
{
	int n,r,c,p,i;
	while(cin>>n>>r,n)
	{
		deque<int>d(n);
		deque<int>::iterator x,y,z;
		for(i=0;i<n;++i)d[i]=n-i;
		while(r--)
		{
			cin>>p>>c;
			x=d.begin();y=x+p-1,z=y+c;
			deque<int>_(y,z);
			d.erase(y,z);
			d.insert(d.begin(),_.begin(),_.end());
		}
		cout<<d[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N, = list(map(int, input().split()))

ABC = [list(map(int, input().split())) for i in range(N)]

dp = [[0] * 3 for i in range(N)]

for i in range(N):
  for j in range(3):
    if i - 1 < 0:
      dp[i][j] += ABC[i][j]
    else:
      x = (j + 1) % 3
      y = (j + 2) % 3
      dp[i][j] = max(dp[i-1][x], dp[i-1][y]) + ABC[i][j]

print(max(dp[N-1]))


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

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  K--;
  if (S.at(K) == 'A') {
    S.at(K) = 'a';
  }
  else if (S.at(K) == 'B') {
    S.at(K) = 'b';
  }
  else if (S.at(K) == 'C') {
    S.at(K) = 'c';
  }
  cout << S << endl;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int n = Integer.parseInt(tmpArray[0]);
			int a = Integer.parseInt(tmpArray[1]);
			int b = Integer.parseInt(tmpArray[2]);
			int c = Integer.parseInt(tmpArray[3]);
			int x = Integer.parseInt(tmpArray[4]);
			
			if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0){
				break;
			}
			
			int[] randNum = new int[n];
			tmpArray = br.readLine().split(" ");
			for(int i = 0; i < n; i++){
				randNum[i] = Integer.parseInt(tmpArray[i]);
			}
			
			RandGenerator rg = new RandGenerator(x, a, b, c);
			
			int currentReel = 0;
			int turn = -1;
			
			if(x == randNum[0]){
				currentReel++;
				if(n == 1){
					turn = 0;
				}
			}
			
			for(int i = 1; i <= 10000 && currentReel < n ; i++){
				int tmpRand = rg.getRand();
				if(tmpRand == randNum[currentReel]){
					currentReel++;
					if(currentReel == n){
						turn = i;
						break;
					}
				}
			}
			
			System.out.println(turn);
		}
	}

}

class RandGenerator {
	private int x;
	private int a;
	private int b;
	private int c;
	
	public RandGenerator(int x, int a, int b, int c){
		this.x = x;
		this.a = a;
		this.b = b;
		this.c = c;
	}
	
	public int getRand(){
		x = (a*x + b)%c;
		return x;
	}
}

Measured memory_bytes: 28116
#include <stdio.h>

void print(int *, int, int);
void Bubble(int A[], int n)
{
    int pass, i, temp, swapped = 1, times = 0;
    for (pass = n - 1; pass >= 0 && swapped; pass--)
    {
        swapped = 0;
        for (i = 0; i < pass; i++)
        {
            if (A[i] > A[i + 1])
            {
                temp = A[i];
                A[i] = A[i + 1];
                A[i + 1] = temp;
                swapped = 1;
                times += 1;
            }
        }
    }
    print(A, n, times);
}
int main()
{
    int N, A[100], i;
    scanf("%d", &N);
    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);
    Bubble(A, N);
    return 0;
}
void print(int A[], int n, int times)
{
    int i = 0;
    for (i = 0; i < n; i++)
    {
        printf("%d", A[i]);
        if (i < n - 1)
            printf(" ");
    }
    printf("\n");
    printf("%d\n", times);
}


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

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

  int n, k;
  cin >> n >> k;

  vector < int >a(n);
  for (auto & x:a)
    cin >> x;
  a.insert(a.begin(), 0);

  ll ans = 0;
  map < int, int >cnt;
  for (int i = 1; i <= n; ++i)
    a[i] = (a[i] + a[i - 1] - 1) % k;

  for (int i = 0; i <= n; ++i) {
    if (i >= k)
      --cnt[a[i - k]];
    ans += cnt[a[i]]++;
  }

  cout << ans;
}


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

using namespace std;
struct node{
	long long y;
	long long n;
	int data;
}p[2000+5];
const int mod = 1e9+7;
long long poi[2000+5];
long long poiy[2000+5];
int main(){
	int n;
	long long m;
	cin>>n>>m;
	for(int i = 0;i < n;i++){
		cin>>p[i].data;
	}
	long long ans = ((1ll+m)*m)/2%mod;
	long long ans1 = ((m-1ll)*m)/2%mod;
	long long sum = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			if(p[i].data > p[j].data){
				sum = (sum+ans)%mod;
			}
		}
		for(int j = 0;j < i;j++){
			if(p[i].data > p[j].data){
				sum = (sum+ans1)%mod;
			}
		}
	}
	cout<<sum<<endl;
} 

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct Edge
{
	int a,b,c;
	Edge(int a, int b, int c) : a(a),b(b),c(c) {}
};

signed main() {
	int l;
	std::cin >> l;
	int n = 32-__builtin_clz(l);
	std::vector< Edge > edges;
	rep(i,n-1) edges.emplace_back(i,i+1,0);
	rep(i,n-1) edges.emplace_back(i,i+1,1<<(n-i-2));
	rep(i,n-1) {
		if(l>>i&1) {
			edges.emplace_back(0,n-i-1,(l>>(i+1))<<(i+1));
		}
	}
	std::cout << n << ' ' << edges.size() << ENDL;
	for(auto e:edges) {
		std::cout << e.a+1 << ' ' << e.b+1 << ' ' << e.c << ENDL;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
using namespace std;

typedef long long ll;
static const double PI = 4.0 * atan(1.0);
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)
#define EPS (1e-8)
bool ISINT(double x){return fabs(x-(ll)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll n){stringstream ss;ss<<n;return ss.str();}

int main() {
  int n, a, b;

  while (cin >> n >> a >> b) {
    cout << min(a, b) << " " << max(0, a + b - n) << endl;
  }
}


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

const int MAXN = 500 + 50;
ll f[MAXN + 1][MAXN + 1], res[MAXN + 1][MAXN + 1];

void no() {
    printf("No\n");
    exit(0);
}

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(h == 1 && w == 1) {
        no();
    }
    for(int i = 1; i <= H; i += h) {
        for(int j = 1; j <= W; j += w) {
            if(i + h - 1 <= H && j + w - 1 <= W)
                f[i + h - 1][j + w - 1] = -1e9;
        }
    }
    ll sum = (1000 * 1000 * 1000 - 1) / (h * w - 1);
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            if(f[i][j] == 0)
                f[i][j] = sum;
            res[i][j] = f[i][j];
        }
    }
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            f[i][j] += f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
        }
    }
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            if(i + h - 1 <= H && j + w - 1 <= W) {
                ll cur = 0;
                cur += f[i + h - 1][j + w - 1];
                cur -= f[i - 1][j + w - 1];
                cur -= f[i + h - 1][j - 1];
                cur += f[i - 1][j - 1];
                if(cur >= 0) {
                    no();
                }
            }
        }
    }
    if(f[H][W] <= 0)
        no();
    printf("Yes\n");
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  vi like(100001,1);
  like[0] = 0; like[1] = 0;
  // 素数を残す
  FOR(i,2,sz(like))
    if(like[i])
      for(ll j = 2 * i; j < sz(like); j += i)
	like[j] = 0;
  // (n + 1) / 2も素数のものを残す
  ROF(i,sz(like),0)
    like[i] = like[i] * like[(i+1)/2];

  // 累積和を求める
  rep(i,sz(like)-1) like[i+1]+= like[i];

  int q; cin >> q;
  rep(i,q){
    int l,r; cin >> l >> r;
    cout << like[r] - like[l-1] << endl;
  }
}

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

int main(){

   int x;
   cin >> x;
   
   if (x == 0){
      x = 1;
      cout << x << endl;
      return 0;
   }
   if (x == 1){
      x = 0;
      cout << x << endl;
      return 0 ;
   }

}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 998'244'353, INV2 = 499'122'177;
int difference(int a, int b) {
    return (a -= b) < 0 ? a += P : a;
}
int sum(int a, int b) {
    return (a += b) >= P ? a -= P : a;
}
int power(int a, int b) {
    int result = 1;
    while (b > 0) {
        if (b % 2 == 1)
            result = 1LL * result * a % P;
        a = 1LL * a * a % P;
        b /= 2;
    }
    return result;
}
void fwt(vector<int> &a) {
    for (int i = 1; i < a.size(); i *= 2) {
        for (int j = 0; j < a.size(); j += 2 * i) {
            for (int k = 0; k < i; ++k) {
                int u = sum(a[j + k], a[i + j + k]);
                int v = difference(a[j + k], a[i + j + k]);
                a[j + k] = u;
                a[i + j + k] = v;
            }
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> p(1 << n);
    for (int i = 0; i < (1 << n); ++i)
        cin >> p[i];
    int s = accumulate(p.begin(), p.end(), 0);
    s = power(s, P - 2);
    for (int i = 0; i < (1 << n); ++i)
        p[i] = 1LL * p[i] * s % P;
    --p[0];
    fwt(p);
    for (int i = 1; i < (1 << n); ++i)
        p[i] = power(p[i], P - 2);
    p[0] = (P - accumulate(p.begin() + 1, p.end(), 0LL) % P + P) % P;
    fwt(p);
    for (int i = 0; i < (1 << n); ++i)
        cout << p[i] << "\n";
    return 0;
}

Measured memory_bytes: 3840
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		long X = sc.nextInt();
		long[] x = new long[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);

		long[] dist = new long[N];
		for (int i = 0; i < x.length; i++) {
			dist[i] = Math.abs(x[i] - X);
		}

		long ans = Integer.MAX_VALUE;
		if (dist.length == 1) {
			ans = dist[0];
		} else {
			for (int i = 1; i < dist.length; i++) {
				ans = Math.min(ans, gcd(dist[i], dist[i - 1]));
			}
		}

		System.out.println(ans);
	}

	private static long gcd(long x, long y) {
		if (x < y) return gcd(y, x);
		if (y == 0) return x;
		return gcd(y, x % y);
	}
}

Measured memory_bytes: 50332
#include<stdio.h>
int main(void)
{
	int n,m,w,i,j,a[1000000],b[1000000],h,y[1000000];
	scanf("%d %d %d",&w,&h,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	m=10000000;
	for(i=0;i<w;i++) y[i]=0;
	for(i=0;i<n;i++) if(y[a[i]-1]<b[i]) y[a[i]-1]=b[i];
	//for(i=0;i<w;i++) printf("AA%d\n",y[i]);
	for(i=w-2;i>=0;i--) if(y[i]<y[i+1]) y[i]=y[i+1];
	for(i=0;i<w;i++){
		if(i+y[i]<m) m=i+y[i];
	}
	//for(i=0;i<w;i++) printf("BB%d\n",y[i]);
	printf("%d\n",m);
	return 0;
}


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

typedef long long ll;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll flp = 0, rf = 0, i;
	string s;
	cin >> s;
	for (i = s.size() - 1; i >= 0; i--)  {
		if (s[i] == 'W')
			rf++;
		else
			flp += rf;
	}
	cout << flp << endl;
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,ans=0;
	string s;
	cin>>n>>s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		cnt+=(s[i]=='I'?1:-1);
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	for t in r(30):b(p:=i+t+30);a(q:=p+1,n,q);[*map(b,r(q,i+60))];a(i+60,x,i+t,1);b(p);a(q,i+t,q)
p(n:=3933)
a(0,1,n)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5)
d(4,36)
for t in r(59):a(2,2,2);[t-30<s<30!=(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)]

Measured memory_bytes: 8968
#include <iostream>

int main() {
	int testcases {};
	std::cin >> testcases;
	double bawahinpt{}, sumbawah{};
	while (testcases--) {
		std::cin >> bawahinpt;
		sumbawah += 1/bawahinpt;
	}
	sumbawah = 1/sumbawah;
	std::cout << sumbawah;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n+1]={};

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

    int num = a[1];
    int count = 1;
    if(a[1]==2){
        cout << 1 << endl;
        return 0;
    }
    
    for(int k=1;k<n+10;k++){
        count++;
        if(a[num]==2) break;
        else num = a[num];
    } 

    if (count>n) cout << -1 << endl;
    else cout << count << endl;
}





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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

MOD = 10 ** 9 + 7
HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    def mass_water(n, m):
        return 100 * n * a + 100 * m * b

    def mass_sugar(k, l):
        return k * c + l * d

    def mass(n, m, k, l):
        return mass_water(n, m) + mass_sugar(k, l)

    def is_within_f(ms, mw):
        return ms + mw <= f

    def is_within_e(ms, mw):
        return ms * 100 <= mw * e

    def density(ms, mw):
        return ms / mw

    a, b, c, d, e, f = map(int, input().split())
    max_n = f // (100 * a)
    max_m = f // (100 * b)
    max_sugar = f * e / 100.0
    max_k = math.ceil(max_sugar // c)
    max_l = math.ceil(max_sugar // d)

    mass_water_set = set()
    for n in range(max_n + 1):
        for m in range(max_m + 1):
            mw = mass_water(n, m)
            if n + m > 0 and is_within_f(0, mw):
                mass_water_set.add(mw)
    mass_sugar_set = set()
    for k in range(max_k + 1):
        for l in range(max_l + 1):
            mass_sugar_set.add(mass_sugar(k, l))


    max_density = -HUGE
    max_mw = 0
    max_ms = 0
    for mw in mass_water_set:
        for ms in mass_sugar_set:
            if not (is_within_f(ms, mw) and is_within_e(ms, mw)):
                continue
            den = density(ms, mw)
            if den > max_density:
                max_density = den
                max_mw = mw
                max_ms = ms

    print(max_mw + max_ms, max_ms)

main()


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
    cin>>a;
  vector<int> vec(a+1);
  for(int i=0;i<a;i++){
    int d;
    cin>>d;
    vec.at(i)+=d;
  }
  int sum=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      if(i<=j)
        break;
      sum+=vec.at(i)*vec.at(j);
    }
  }
  cout<<sum<<endl;
}

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

using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const ll mod = 1e9+7;
const int INF = 1 << 30;

int n, w;
pair <ll, ll> a[101];
ll dp[101][100005];
ll solve(int idx, int w) {
    if (w < 0) {
        return -1e9;
    }
    if (idx >= n) {
        return 0;
    }

    if (dp[idx][w] != -1) return dp[idx][w];
    return dp[idx][w] = max(solve(idx + 1, w - a[idx].first) + a[idx].second, solve(idx + 1, w));
}
int main()
{
    memset(dp, -1, sizeof(dp));
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second; // weight , value
    }
    cout << solve(0, w) << endl;
    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S; cin >> S;
  sort(S.begin(), S.end());
  if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int & x : a)
        cin >> x;
    for (int i = k; i < n; ++i)
        cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3988
# Number_of_donuts:ドーナッツのN個 gram_of_sweets:お菓子のもとXグラム
Number_of_donuts, gram_of_sweets = map(int, input().split())

#各ドーナッツに必要なグラムのリスト
list_gram = []

#最大作れるドーナッツの数(予め一個ずつはつくるからその数はいれておく)
count = Number_of_donuts

#ドーナッツの個数ごとに標準入力を受け付ける
for number in range(Number_of_donuts):
  #あとで計算しやすいのでIntにしておく
  list_gram.append(int(input()))

#絶対作る数はNumber_of_donuts,あとは余った粉で最大限つくればいい
print(Number_of_donuts+(gram_of_sweets - sum(list_gram)) // min(list_gram))


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

int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << n - (k - 1) - 1 << endl;
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    ll x = 0;
    cin >> x;
    if (x >= 2000) {
        cout << 1 << endl;
    } else {
        ll low = 0, dif = 0;
        while (x >= low) {
            if (x <= low + dif) {
                cout << 1 << endl;
                return 0;
            } else {
                low += 100;
                dif += 5;
            }
        }
        cout << 0 << endl;
    }
    return 0;
}


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

int main() {
    string S; cin >> S;

    // スタートが 0 か 1 か
    int res = 1<<29;
    for (int start = 0; start <= 1; ++start) {
        int val = start; // それぞれの数値でスタート
        int count = 0;
        for (int i = 0; i < S.size(); ++i) {
            // 目指すものと異なる部分をカウント
            if (S[i] - '0' != val) ++count;

            // 入れ替え
            val = 1 -val;
        }
        res = min(res, count);
    }
    cout << res << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = INF2;
    REP(i, 1, 4000000) {
        if (N % i == 0) ans = min(ans, N / i + i - 2);
    }
    cout << ans << endl;

    return 0;
}


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


int main()
{
	int h, w;

	while (true)
	{
		cin >> h >> w;

		if (h == 0 && w == 0) {
			break;
		}

		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if (i == 0 || i == h-1)
				{
					cout << "#";
				}
				else if (j == 0 || j == w - 1) {
					cout << "#";
				}
				else {
					cout << ".";
				}
			}

			cout << "\n";
		}

		cout << "\n";
	}

    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
//#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<sstream>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
#define asd signed QP;scanf("%d",&QP);while(QP--)
#define alll(x,y) x+1,x+1+y
typedef pair<int,int> PI;
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;}
int lowbit(int x){return x&-x;}
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
//
const int BN=1e5+5;
struct BIT{
    int c[BN];
    void init(){memset(c,0,sizeof c);}
    int lowbit(int i){return i&-i;}
    void add(int i,int t){while(i<BN)c[i]+=t,i+=lowbit(i);}
    int ask(int i){int ans=0;while(i)ans+=c[i],i-=lowbit(i);return ans;}
};
//
const double eps=1e-6;
const int mod=1e9+7;
//const int mod=998244353;
const int modd=mod-1;
//
const int maxm=1e5+5;


void solve(){
    int k=re,a=re,b=re;
    if(a>b)swap(a,b);
    for(int i=a;i<=b;i++){
        if(i%k==0){
            puts("OK");return ;
        }
    }
    puts("NG");
}
signed main(){
//    while(1)
//    asd
        solve();
    return 0;
}
/*

*/


Measured memory_bytes: 3544
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  if (N >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#coding:utf-8
n=int(input())
count=False
if(n%7==0):
	count=True
for i in range(int(n/7)+1):
	if(n%4==0):
		count=True
	else:
		n-=7
if(count==False):
	print("No")
else:
	print("Yes")

Measured memory_bytes: 3060
K = int(input())-1
al = [chr(i) for i in range(97, 97+26)]
S_arr = [al[0]]
for i in range(K):
  new_S_arr = []
  for S in S_arr:
    for j in range(len(set(list(S)))+1):
      new_S_arr.append(S + al[j])
  S_arr = new_S_arr

for S in S_arr:
  print(S)


Measured memory_bytes: 12968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		for(int i = s.length() - 2; i > 0; i -= 2) {
			s = s.substring(0, i);
			String s1 = s.substring(0, i/2);
			String s2 = s.substring(i/2, i);
				if(s1.equals(s2)) {
				System.out.println(i);
				return;	
				} 
		 	}

	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,m,e,res1,res2,head[111111],c[111111],to[222222],link[222222];
bool flag;
void add(int u,int v){to[++e]=v,link[e]=head[u],head[u]=e;}
void dfs(int u){
	if(flag)return;
	for(int i=head[u];i;i=link[i]){
		if(!c[to[i]])c[to[i]]=-c[u],dfs(to[i]);
		else if(c[to[i]]==c[u])flag=1;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	c[1]=1,dfs(1);
	if(flag){printf("%lld",1ll*n*(n-1)/2-m);return 0;}
	for(int i=1;i<=n;i++)c[i]>0?res1++:res2++;
	printf("%lld",1ll*res1*res2-m);
}

Measured memory_bytes: 2816
#include<stdio.h>
#include<string.h>
#define MAX 10001

int LCSLength(char [MAX] , char [MAX]);
int A[MAX][MAX];

int main(){

  int i,j,n,Z[150];
  char X[MAX],Y[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    
    scanf("%s",X);
    scanf("%s",Y);
    Z[i]=LCSLength(X,Y);
     

  }
   for(i=0;i<n;i++)printf("%d\n",Z[i]);

  return 0;
}


int LCSLength(char X[MAX] , char  Y[MAX]){

  int m,n,i,j,max=0;

  m=strlen(X);
  n=strlen(Y);
  
  for(i=1;i<=m;i++)A[i][0]=0;
  for(j=0;j<=n;j++)A[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      A[i][j]=0;
      if(X[i-1]==Y[j-1]){
	A[i][j]=A[i-1][j-1]+1;
	
      }
      else if(A[i-1][j]>=A[i][j-1])
	A[i][j]=A[i-1][j];
      else A[i][j]=A[i][j-1];
    }
    }
  
  return A[m][n];
}

Measured memory_bytes: 39944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;



int main() {
    string o,e; cin >> o >> e;
    string ans;
    for(int i = 0;i < e.length();i++){
        ans += o[i];
        ans += e[i];
    }
    if(o.length()>e.length()){
       
        ans+=o[o.length()-1];
    }
    cout << ans;
}




Measured memory_bytes: 3628
S=input()

for i in range(len(S)):
    if i%2==0 and S[i]=='R' or S[i]=='U' or S[i]=='D':
        pass
    elif i%2==1 and S[i]=='L' or S[i]=='U' or S[i]=='D':
        pass
    else:
        print('No')
        break
else:
    print('Yes')

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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			int weeks = Integer.parseInt(in.readLine());
			
			int d = 100000;
			for (int i = 0; i < weeks; i++) {
				d = (int)((double)d * 1.05 + 999) / 1000 * 1000;
			}
			
			System.out.println(d);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24028
N = input()
a = input().split()
a = list(map(int, a))

a.sort()
a.reverse()

alice = 0
bob = 0

a_num = len(a)

for i in range(a_num):
  if i % 2 == 0:
    alice += int(a[i])
  else:
    bob += int(a[i])

print(alice - bob)




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

int main()
{

        vector<int> m;
        vector<int> f;
        vector<int> r;

        while (1) {

                int t;
                int mm;
                int p;
                cin >> t >> mm >> p;
                if (t == -1 && mm == -1 && p == -1) {
                        break;
                }
                m.push_back(t);
                f.push_back(mm);
                r.push_back(p);
        }
        int n = m.size();
        for (int i = 0; i < n; ++i) {
                if (m[i] == -1 || f[i] == -1) {
                        cout << "F" << endl;
                }
                else if (m[i] + f[i] >= 80) {
                        cout << "A" << endl;
                }
                else if (m[i] + f[i] >= 65 && m[i] + f[i] < 80) {
                        cout << "B" << endl;
                }
                else if (m[i] + f[i] >= 50 && m[i] + f[i] < 65) {
                        cout << "C" << endl;
                }
                else if (m[i] + f[i] >= 30 && m[i] + f[i] < 50) {
                        if (r[i] >= 50) {
                                cout << "C" << endl;
                        }
                        else {
                                cout << "D" << endl;
                        }
                }
                else {
                        cout << "F" << endl;
                }
        }


}



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

long long N,K,D;

long long absolutein(long long N){
	if(N>0)return N;
	return -N;
}

void Input(){
	cin>>N>>K>>D;
}

void Solve(){
	N=absolutein(N);
	long long bigzer=N%D,bagiBig=N/D;
	long long smallzer=bigzer-D,bagiSmall=N/D+1;
	if(bagiBig>K){
		cout<<N-K*D<<'\n';
	}else{
		if(bagiBig%2==K%2){
			cout<<bigzer<<'\n';
		}else{
			cout<<absolutein(smallzer)<<'\n';
		}
	}
}

int main(){
	Input();
	Solve();
}

Measured memory_bytes: 3640
//   https://atcoder.jp/contests/abc110/tasks/abc110_a


#include<stdio.h>   //AA06( 31/ 07/ 20) If u see my code, Have a Good Day! (^_^)

int main()
{
    int A[3], Sum = 0, i, Ans, Max = -1;

    for(i = 0; i < 3; ++i) {

        scanf("%d", &A[i]);

        Sum += A[i];

        if(A[i] > Max)
            Max = A[i];
    }

    Ans = (Max * 10) + Sum - Max;

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

    return 0;
}





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

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

    int A[M], B[M];
    vector<int> E[N+1];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        E[A[i]].push_back(B[i]);
        E[B[i]].push_back(A[i]);
    }

    vector<int> is_search(N+1, 0);
    queue<int> q;
    q.push(1);
    is_search[1]=1;

    vector<int> ans(N+1, 0);
    ans[1]=1;
    while(!(q.empty())){
        int num=q.front();
        q.pop();
        rep(i, E[num].size()){
            if(is_search[E[num][i]]==0){
                q.push(E[num][i]);
                is_search[E[num][i]]=1;
                ans[E[num][i]]=num;
            }
        }
    }

    rep(i, N+1){
        if(i==0) continue;
        if(is_search[i]==0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i, N+1){
        if(i==0 || i==1) continue;
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 12132
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    ll S, W;
    cin >> S >> W;
    if(S<= W){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3128
#include<stdio.h>
#include<math.h>
int main(void){
	
	int x, y, t;
	
	scanf("%d %d", &x, &y);
	
    if(x < y){
        t = x;
        x = y;
        y = t;
    }
    while(y > 0){
        t = x % y;
        x = y;
        y = t;
    }
    printf("%d\n", x);
    
return 0;
}

Measured memory_bytes: 592
n = int(input())
hs = map(int, input().split())
hsrev = list(hs)[::-1]

for i in range(len(hsrev)-1):
    if hsrev[i] < hsrev[i+1]:
        hsrev[i+1] -= 1
        if hsrev[i] < hsrev[i+1]:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 14252
N, K = map(int, input().split())
P = [(int(x)+1)/2 for x in input().split()]

Q=[0]*(N+1)
for n in range(N):
  Q[n+1]=Q[n]+P[n]

ans=0
for n in range(K,N+1):
  ans=max(ans, Q[n]-Q[n-K])

print(ans)

Measured memory_bytes: 31876
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    string s;
    int ans=0;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='+'){
            ans++;
        }else{
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Problem : C - Multiplication 3
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sc scanf
#define pr printf

#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sqr(x) ((x) * (x))

#define sci(n) sc("%d", &n);
#define sci2(n, m) sc("%d%d", &n, &m);
#define scl(n) sc("%I64d", &n);
#define scl2(n, m) sc("%I64d%I64d", &n, &m);

#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1000000000;

int main() {
	// ull a;
	// double b;
	// cin >> a >> b;
	//
	// ull c = b * 100ll;
	// xatop(c);
	//
	// ull jv = a * c;
	// string s = to_string(jv);
	//
	// if (!s.empty()) s.pop_back();
	//
	// if (!s.empty()) s.pop_back();
	//
	// if (s.empty()) s = "0";
	//
	// cout << s << endl;

	ld a, b;
	cin >> a >> b;

	ld c = a * b;

	cout << (ull)c << endl;

	return 0;
}


Measured memory_bytes: 3728
import java.util.Scanner;

/**
 * TITLE : Otoshidama
 * URL : https://atcoder.jp/contests/abc085/tasks/abc085_c
 */
public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		for (int i = N; i >= 0; i--) {
			if (i * 10000 > Y) continue;
			for (int j = (N - i) * 2; j >= 0; j--) {
				if (i * 10000 + j * 5000 > Y) continue;
				int k = (Y - (i * 10000) - (j * 5000)) / 1000;
				int count = i + j + k;
				if (count != N) continue;
				if (((i * 10000) + (j * 5000) + (k * 1000)) == Y) {
					System.out.println(i + " " + j + " " + k);
					sc.close();
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
		sc.close();
	}
}

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

int main(){
  string S;
  cin>>S;
  
  int max=0;
  int tmp=0;
  for(int i=1;i<=S.size();i++){
    for(int j=0;j<=S.size()-i;j++){
      for(int k=0;k<i;k++){
        //cout<<S[j+k];
        if(S[j+k]=='A'|S[j+k]=='C'|S[j+k]=='G'|S[j+k]=='T'){
          tmp++;
        }
        else{
          break;
        }
      }
      //cout<<endl;
      if(max<tmp){
        max=tmp;
      }
      tmp=0;
    }
  }
  cout<<max;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d", &N);

    int sum =0;
    int tmp = N;

    while (tmp > 0){
        sum += tmp % 10;
        tmp = tmp / 10;
    }

    if (N % sum == 0){
        printf("%s\n", "Yes");
    }
    else {
        printf("%s\n", "No");
    }

    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

typedef vector<vector<int>> graph;

// SCC Strongly Connected Component 強連結成分分解
struct SCC {
	int V;
	int cV;
	graph G;
	graph cG;
	vector<int> cmp;
	vector<int> vs;
	vector<bool> used;

	SCC(int V_):V(V_), G(V_), cmp(V_), used(V_) {}
	SCC(const graph &G_):V(G_.size()), G(G_), cmp(V), used(V) {}

	void add_edge(int from, int to) {
		G[from].emplace_back(to);
	}

	void dfs(int v) {
		used[v] = true;
		for(const auto &to : G[v]) {
			if(!used[to]) dfs(to);
		}
		vs.emplace_back(v);
	}

	void rdfs(int v, int k, graph &rG) {
		used[v] = true;
		cmp[v] = k;
		for(const auto &to : rG[v]) {
			if(!used[to]) rdfs(to, k, rG);
		}
	}

	int scc() {
		vs.clear();
		fill(used.begin(), used.end(), false);

		for(int v = 0; v < V; ++v) {
			if(!used[v]) dfs(v);
		}

		graph rG(V);
		for(int v = 0; v < V; ++v) {
			for(const auto &to : G[v]) {
				rG[to].emplace_back(v);
			}
		}

		fill(used.begin(), used.end(), false);
		int k = 0;
		for(int i = static_cast<int>(vs.size()) - 1; i >= 0; --i) {
			if(!used[vs[i]]) rdfs(vs[i], k++, rG);
		}
		return k;
	}

	void construct() {
		cV = scc();
		cG.clear();
		cG.resize(cV);

		for(int v = 0; v < V; ++v) {
			for(const auto &to : G[v]) {
				if(cmp[v] != cmp[to]) cG[cmp[v]].emplace_back(cmp[to]);
			}
		}

		for(auto &es : cG) {
			sort(es.begin(), es.end());
			es.erase(unique(es.begin(), es.end()), es.end());
		}
	}
};

constexpr long long mod = 1000000007;

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

	int n, m;
	cin >> n >> m;

	SCC scc(n);
	for(int i = 0; i < m; ++i) {
		int s, d;
		cin >> s >> d;
		scc.add_edge(s - 1, d - 1);
	}

	scc.construct();

	const int V = scc.cV;

	vector<int> in(V, 0);
	for(int v = 0; v < V; ++v) {
		for(const auto &to : scc.cG[v]) {
			++in[to];
		}
	}

	queue<int> que;
	for(int v = 0; v < V; ++v) {
		if(in[v] == 0) que.push(v);
	}

	vector<long long> dp(V, 1);
	long long ans = 1;

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		++dp[v];

		if(scc.cG[v].empty()) {
			ans = (ans * dp[v]) % mod;
			continue;
		}

		for(const auto &to : scc.cG[v]) {
			dp[to] = (dp[to] * dp[v]) % mod;
			if(--in[to] == 0) que.push(to);
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> cnt(10);
  for(int i=0; i<4; i++){
    int n;
    cin >> n;
    cnt.at(n)++;
  }
  if(cnt.at(1)==1 && cnt.at(9)==1 && cnt.at(7)==1 && cnt.at(4)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

ll dp[100000];

ll count(ll a[], ll n, ll k)
{
	if(n<=1)
	{
		return 0;
	}
	if(dp[n-1]!=-1)
	{
		return dp[n-1];
	}
	else
	{
			ll mini = MAXX;
			for(int i=1;i<=k;i++)
			{
				if(n-i-1>=0)
				mini =  (min(abs(a[n-1]-a[n-i-1])+count(a,n-i,k),mini));
			}
			dp[n-1] = mini;
		return dp[n-1];
	}

}


void solve()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll ans = count(a,n,k);
	cout<<ans<<endl;
	//cout<<a<<" "<<b<<" "<<c<<endl;
}

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif*/

    //main code starts here//
    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }


    //code ends///
    /*#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif*/
	return 0;

		
}


Measured memory_bytes: 9600
<?php
$n = trim(fgets(STDIN));
$array = explode(" ", fgets(STDIN));
$array = array_map("trim", $array);
$flg = false;
$count = 0;
while($flg!==true){
	if(is_all_not_odd($array)){
		$count += 1;
		$array = calculate_array($array);
	}else{
		$flg = true;
	}
}
echo $count . "\n";

function is_all_not_odd($array){
	$ret = true;
	foreach ($array as $arr) {
		if($arr%2!==0){
			$ret = false;
			break;
		}
	}
	return $ret;
}

function calculate_array($array){
	return array_map("calculate", $array);
}

function calculate($num){
	 $num=$num/2;
	 return $num;
}

?>

Measured memory_bytes: 4604
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
int main()
{

   int n;
   cin>>n;
   long long int arr[n],cum_sum[n];
   
   
   for(int i=0;i<n;i++)
    {cin>>arr[i];

    }
    cum_sum[0]=0;
    for(int j=1;j<=n;j++)
    {
        cum_sum[j]=arr[j-1]+cum_sum[j-1];
    }
   long long int dp[n][n];
  // cout<<INT64_MAX<<endl;
    for(int i=0;i<n;i++)
    {   fill(dp[i],dp[i]+n,INT64_MAX);
        dp[i][i]=0;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i+j>=n)
            continue;
            for(int k=j;k<i+j;k++)
            {
                dp[j][i+j]=min(dp[j][k]+dp[k+1][i+j]+cum_sum[i+j+1]-cum_sum[j],dp[j][i+j]);
                //cout<<dp[j][k]+dp[k+1][i+j]+cum_sum[i+j+1]-cum_sum[j]<<endl;
            }
             
        }
    }
    
    cout<<dp[0][n-1]<<endl;
    



}

Measured memory_bytes: 1536