akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b,c;
	string s;
	cin>>a>>b>>c;
	c=a*b>c?c:a*b;
	cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 



int main(){
    int n;cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(ALL(v));
    double ans=v[0];
    for (int i = 1; i < n; i++) {
        ans = (ans + v[i])/2;
    }
    cout <<setprecision(10) <<  ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  string S;
  cin >> S;
  sort(ALL(S));
  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: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			int T = sc.nextInt();
			if (T < A || B <= T) ++ans;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 10196
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    int x,y,n,m,h,k,max=-100000,min=1000000000,ans=0,sum=0;
    string s;

    cin >> n;
    PQ d;
    rep(i,n){
        cin >> x;
        d.push(x);
	}

    cin >> m;
    PQ t;
    rep(i,m){
        cin >> y;
        t.push(y);
	}


    while(d.empty()==0){
        if(t.top() == d.top()){
            d.pop();
            t.pop();
            if(t.empty()==1){
                break;
            }
        }
        else{
            d.pop();
        }
    }
    
    if(t.empty()==0){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }

    return 0;
}
  


Measured memory_bytes: 2548
n, m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort
bc = m.times.map {gets.split.map(&:to_i)}.sort_by {|b, c| -c}

e = Enumerator.new {|y|
  bc.each do |b, c|
    b.times {y << c}
  end
  loop {y << 0}
}

puts as.map {|a|
  nxt = e.next
  a < nxt ? nxt : a
}.sum

Measured memory_bytes: 25360
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.size();
	int n=l/2;
	int count=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=s[l-1-i]) count+=1;
	}
	cout<<count;
}

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

int H, W;
int mp[1500][1500];
int dp[1500][1500];

int main(){
  //??\???                                                                                              
  cin>>H>>W;
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      cin>>mp[i][j];

  //?????????                                                                                            
  for(int i=0; i<H; i++){
    if(mp[i][0]==1)dp[i][0]=0;
    else dp[i][0]=1;
  }
  for(int i=0; i<W; i++){
    if(mp[0][i]==1)dp[0][i]=0;
    else dp[0][i]=1;
  }

  //???????¨???????                                                                                        
  for(int i=1; i<H; i++)
    for(int j=1; j<W; j++){
      if(mp[i][j]==1){//???????????????                                                                    
        dp[i][j]=0;
        continue;
      }
      dp[i][j]=min(dp[i-1][j-1], min(dp[i][j-1], dp[i-1][j]))+1;
    }

  int ans=0;
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      ans=max(ans, dp[i][j]);

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

Measured memory_bytes: 18156
#include<bits/stdc++.h>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
# define M_PI           3.14159265358979323846  /* pi */
ll mob=1000000007;
using namespace std;
int main()
{ 

int r;cin>>r;
cout<<fixed<<setprecision(20);
cout<<(double)2*M_PI*r;


return 0;
}











Measured memory_bytes: 3784
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,k=parseMap(split(readline()))
    a=parseMap(split(readline()))
    mod=10^9+7
    cnt1=Vector{BigInt}([0 for i in 1:n])
    cnt2=Vector{BigInt}([0 for i in 1:n])
    for i in 1:n
        for j in 1:n
            if a[i]>a[j]
                if i<j
                    cnt1[i]+=1
                else
                    cnt2[i]+=1
                end
            end
        end
    end
    ans=0
    num1=(k+1)*k÷2
    num2=(k-1)*k÷2
    for i in 1:n
        ans=(ans+num1*cnt1[i]+num2*cnt2[i])%mod
    end
    println(ans%mod)
end
main()

Measured memory_bytes: 176584
#include <iostream>
#include <string>

using namespace std;

int main(){
  string S; cin>>S;
  int ans=100000;
  const int num=753;
  for(int i=0;i<S.size()-2;i++){
    int n=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    if(ans>abs(n-num)) ans=abs(n-num);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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 ll INF = 1LL << 60;
int main(){
    int a,b;
    cin >> a >>b;
    double mindx = max(12.5*a,10.0*b);
    int minx = (int)(mindx+0.1);
    if(abs(mindx - (int)(mindx+0.1))>0.1) minx++;
    double maxdx = min(12.5*(a+1),10.0*(b+1));
    int maxx = (int)(maxdx+0.1);
    if(abs(maxdx - (int)(maxdx+0.1)) < 0.1) maxx--;
    if(minx<=maxx) cout << minx << endl;
    else cout << -1 << endl;
    return 0;
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef tuple<int, int, int> tint;

const int N = 50 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int cnt[N][N];

int main() {
	ios::sync_with_stdio(0);

	ll ans = 0;

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		double s;
		cin >> s;
		s = s * 1e9;
		ll x = round(s);

		int cnt2 = 0, cnt5 = 0;
		while (x % 2 == 0) {
			x /= 2;
			cnt2++;
		}
		while (x % 5 == 0) {
			x /= 5;
			cnt5++;
		}
		cnt[cnt2][cnt5]++;

		if (cnt2 * 2 >= 18 && cnt5 * 2 >= 18)
			ans--;
	}

	for (int a = 0; a < N; a++)
		for (int b = 0; b < N; b++)
			for (int c = 0; c < N; c++)
				for (int d = 0; d < N; d++) {
					int cnt2 = a + c;
					int cnt5 = b + d;
					if (cnt2 >= 18 && cnt5 >= 18)
						ans += 1LL * cnt[a][b] * cnt[c][d];
				}
	cout << ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 3716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

bool dp[100010][15];
int N,M;
int Q;
vector<vector<int>> G;
vector<int> ans;

void solve(int v,int d,int c){
    if(d == -1) return;
    if(dp[v][d]) return;
    bool ok = false;
    rep(i,d+1){
        if(dp[v][i]) ok = true;
        dp[v][i] = true;
    }
    if(!ok) ans[v] = c;
    for(int u : G[v]){
        solve(u,d-1,c);
    }
}


int main(){
    cin >> N >> M;
    G.resize(N);
    ans.resize(N);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cin >> Q;
    vector<int> v(Q),d(Q),c(Q);
    rep(i,Q){
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }
    rep(i,100010)rep(j,15) dp[i][j] = false;

    for(int i = Q-1; i >= 0; i--){
        solve(v[i],d[i],c[i]);
    }
    rep(i,N) cout << ans[i] << endl;

}

Measured memory_bytes: 9592
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn dfs1(v: usize, par: Option<usize>, edges: &[Vec<usize>],
        dp: &mut [Vec<f64>]) -> f64 {
    let mut tot = 0.0;
    let mut trail = 0.0;
    for i in 0 .. edges[v].len() {
        let w = edges[v][i];
        if Some(w) == par { continue; }
        let res = dfs1(w, Some(v), edges, dp);
        tot += res;
        dp[v][i] = res + 1.0;
        trail += 1.0;
    }
    if trail != 0.0 {
        tot / trail + 1.0
    } else {
        0.0
    }
}
fn dfs2(v: usize, par: Option<usize>, edges: &[Vec<usize>],
        dp: &mut [Vec<f64>], promise: f64) {
    let mut tot = 0.0;
    let mut trail = 0.0;
    for i in 0 .. edges[v].len() {
        let w = edges[v][i];
        if Some(w) == par {
            dp[v][i] = promise;
            tot += promise;
        } else {
            tot += dp[v][i];
        }
        trail += 1.0;
    }
    for i in 0 .. edges[v].len() {
        let w = edges[v][i];
        if Some(w) == par { continue; }
        let tmp = tot - dp[v][i];
        dfs2(w, Some(v), edges, dp,
             (if trail != 1.0 { tmp / (trail - 1.0) } else { 0.0 }) + 1.0);
    }
}


fn solve() {
    let n = get();
    let mut edges = vec![Vec::new(); n];
    for _ in 0 .. n - 1 {
        let u = get::<usize>() - 1;
        let v = get::<usize>() - 1;
        edges[u].push(v);
        edges[v].push(u);
    }
    let mut dp = vec![Vec::new(); n];
    for i in 0 .. n {
        dp[i] = vec![-1.0 / 0.0; edges[i].len()];
    }
    dfs1(0, None, &edges, &mut dp);
    dfs2(0, None, &edges, &mut dp, 0.0 / 0.0);
    //println!("dp = {:?}", dp);
    for i in 0 .. n {
        let mut tot = 0.0;
        for &val in dp[i].iter() {
            tot += val;
        }
        println!("{}", tot / edges[i].len() as f64);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 34684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    int c[10][10];
    rep(i,10) {
        rep(j,10) cin >> c[i][j];
    }
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h) {
        rep(j,w) cin >> a[i][j];
    }

    rep(k,10) {
        rep(i,10) {
            rep(j,10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i,h) {
        rep(j,w) {
            if (a[i][j] == -1) continue;
            ans += c[a[i][j]][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
int a[100005];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	sort(a,a+n);
	int po,ne;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=0 && i>=1) break;
		if(i==n-1) break;
		ne=i+1;
	}
	po=n-ne;
	int res=0;
	for(int i=0;i<ne;i++)
	{
		res-=a[i];
	}
	for(int i=ne;i<n;i++)
	{
		res+=a[i];
	}
	cout<<res<<endl;
	int now=0;
	if(ne==po-1)
	{
		cout<<a[0]<<' '<<a[ne]<<endl;
		int now=a[0]-a[ne];
		int ii=1,jj=ne+1,flag=1;
		for(int i=0;i<n-2;i++)
		{
			if(flag==0)
			{
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			}
			else
			{
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		return 0;
	}
	if(ne>=po)
	{
		cout<<a[ne]<<' '<<a[0]<<endl;
		now=a[ne]-a[0];
		int jj=ne+1,ii=1,flag=0;
		for(int i=0;i<po*2-2;i++)
		{
			if(flag==0)
			{
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			}
			else
			{
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		for(int i=po;i<ne;i++)
		{
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		return 0;
	}
	if(ne==1)
	{
		int now=a[0];
		for(int i=1;i<n-1;i++)
		{
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		printf("%d %d\n",a[n-1],now);
	}
	else
	{
		cout<<a[ne]<<' '<<a[0]<<endl;
		now=a[ne]-a[0];
		int jj=ne+1,ii=1,flag=0;
		for(int i=0;i<ne*2-3;i++)
		{
			if(flag==0)
			{
				flag=1;
				printf("%d %d\n",a[ii],now);
				now=a[ii++]-now;
			}
			else
			{
				flag=0;
				printf("%d %d\n",a[jj],now);
				now=a[jj++]-now;
			}
		}
		for(int i=jj;i<n-1;i++)
		{
			printf("%d %d\n",now,a[i]);
			now=now-a[i];
		}
		printf("%d %d\n",a[n-1],now);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 2304
n,m=map(int,input().split())
ab=[[int(x) for x in input().split()] for _ in range(n)]
cd=[[int(x) for x in input().split()] for _ in range(m)]

for a,b in ab:
  ans=list()
  for c,d in cd:
    ans.append(abs(a-c)+abs(b-d))
  print(ans.index(min(ans))+1)


Measured memory_bytes: 9048
#include <bits/stdc++.h>
using namespace std;
 
string sub(string s1, string s2) {
    int l1 = s1.size();
    int l2 = s2.size();
    string res;
    for (int i = 0, c = 0; c || i < max(l1, l2); i++) {
        int tmp = c;
        if (l1 - 1 - i > -1) tmp += (s1[l1 - 1 - i] - '0');
        if (l2 - 1 - i > -1) tmp += (s2[l2 - 1 - i] - '0');
 
        c = tmp / 10;
 
        tmp %= 10;
 
        res = (char)('0' + tmp) + res;
    }
 
    return res;
}
 
int main() {
    string str;
    while (cin >> str) {
        int ans = -1;
        for (int i = 0; i < 10; i++) {
            string tmp = str;
            for (auto& j : tmp) if (j == 'X') j = '0' + i;
            string a, b, c;
            a = string(tmp.begin(), tmp.begin() + tmp.find('+'));
            b = string(tmp.begin() + tmp.find('+') + 1, tmp.begin() + tmp.find('='));
            c = string(tmp.begin() + tmp.find('=') + 1, tmp.end());
 
            string p = sub(a, b);
 
            if (c == p) {
                ans = i;
                break;
            }
        }
        if (ans < 0) cout << "NA" << endl;
        else cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0;
  rep(i, n) {
    if (a[i] > i && a[a[i]] == i) ans++;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Balance | diff Balance.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Balance.cpp && ./a.out

/*
 
 6/9/2019
 
 5:04-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

void solve() {
  LL res=1e6;
  REPE(i,N) {
    LL sum[2]={0};
    REP(j,N) sum[j<=i]+=A[j];
    SMIN(res,abs(sum[0]-sum[1]));
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);
		int[] vs = new int[v];
		String line2 = sc.nextLine();
		String[] k = line2.split(" ");
		for (int i = 0; i < v; i++) {
			vs[i] = Integer.parseInt(k[i]);
		}
		int count = 0;
		for (int i = 0; i < v; i++) {
			int min = i;

			for (int l = i; l < v; l++) {
				if (vs[min] > vs[l]) {
					min = l;
				}
			}
			if (min != i) {
				int a =vs[min];
				int b = vs[i];
				vs[min]=b;
				vs[i]=a;
				count++;
			}
		}
		for (int i = 0; i < v - 1; i++) {
			System.out.print(vs[i]+" ");
		}
		System.out.println(vs[v - 1]);
		System.out.println(count);
	}
}

Measured memory_bytes: 26168
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500 * a + 100 * b + 50 * c == X:
                ans += 1
print(ans)                

Measured memory_bytes: 3060
import sys
import collections

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
S = [ins() for _ in range(N)]


def solve():
    c = collections.Counter(S)

    print("AC x {}".format(c["AC"]))
    print("WA x {}".format(c["WA"]))
    print("TLE x {}".format(c["TLE"]))
    print("RE x {}".format(c["RE"]))


solve()


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

int main() {
  char n[4];
  cin >> n[0] >> n[1] >> n[2] >> n[3];
  if (((n[0] == n[1]) && (n[1] == n[2])) || ((n[1] == n[2]) && (n[2] == n[3])))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
num = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(num):
    a = input()
    if(a == "AC"):
        ac += 1
    elif(a == "WA"):
        wa += 1
    elif(a == "TLE"):
        tle += 1
    else:
        re += 1
        
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 9188
<?php
fscanf(STDIN,"%d %d",$N,$K);
$result = 0.0;
for($i=1;$i<=$N;$i++){
  if($i>=$K){
    $result += 1/$N;
  }else{
    $result += (1/$N)*((1/2)**howMultiply($i,$K,0));
  }
}
echo $result;

//$iが$Kを超えるのは2の何乗を掛けたときかを返す
function howMultiply($i,$K,$counter){
  if($i>=$K){
    return $counter;
  }else{
    return howMultiply($i*2,$K,$counter+1);
  }
}


Measured memory_bytes: 3576
#include <cstdio> 
#include <ctime> 
#include <cmath>   
#include <cstring>
#include <cstdlib>               //a = clock(); b = clock(); time = a - b;
#include <iostream>                                      
#include <map>                   //map<Type, Type>::iterator it;
#include <queue>                 //priority_queue< Type >Name
#include <stack>                 
#include <vector>                //.push_back()
#include <string>  
#include <algorithm>  
#define e 2.718281828459045      //底数
#define pi 3.141592653589793239  //high precision Π
#define swap(a, b) { int temp = a; a = b; b = temp; }
using namespace std;
typedef long long ll;            //>10^18
typedef long double ld;          //3.3621e-4932 ~ 1.18937e4932
typedef unsigned long long ull;  //>10^20
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int INF = 0x3f3f3f3f;      
const int INFS = 0xc0c0c0c0;     //无穷小
const double eps = 1e-8;         //or 1e-10
//const double pi = acos(-1.0);
inline int read(){
    int sgn = 1, cnt = 0;        //sgn表示正负号 cnt表示读取的数字
    char ch = getchar();
    while(ch < '0' || ch > '9'){ //读取非数字的字符，保留负号，忽略其余无关符号
        if(ch == '-') sgn = -sgn;
        ch = getchar();
    }
    while('0' <= ch && ch <= '9'){
        cnt = cnt * 10 + (ch - '0');
        ch = getchar();
    }
    return sgn * cnt;
}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);//使用后无法用scanf, printf
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll x = a * c;
	ll y = a * d;
	ll z = b * c;
	ll p = b * d;
	cout << max(max(max(x, y), z), p);
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

#define dbg(x) { cerr << #x << " - " << x << endl; }

const int maxn = 100005;
const int MOD = 1000000007;
bool ok[maxn];
long long int dp[maxn];

int main() {
	memset(ok, true, sizeof(ok));
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x;
		cin >> x;
		ok[x] = false;
	}
	dp[0] = 1;
	if(ok[1]) 
		dp[1] = 1;
	for(int i = 2; i <= n; i++) {
		if(ok[i - 1]) dp[i] += dp[i - 1];
		if(ok[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= MOD;
	} 
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include <cmath>
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
using namespace std;


int state(int n) {
	long long dp[35];
	int ans = 0;
	rep(i, 35)dp[i] = 0;
	dp[0] = 1;
	rep(i, n) {
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
		dp[i + 3] += dp[i];
	}
	ans = ceil(double(dp[n]) / 3650.0);
	return ans;
}

int main() {
	int n, m, a = 0;
	cin >> n;
	do {
		cout << state(n) << endl;
		cin >> n;
	} while (n > 0);
	return 0;
}



Measured memory_bytes: 3104
#include<stdio.h>
#include<math.h>
/*void cplc(int p0[2],int p1[2],int p2[2],int r,double s[2],double t[2]){
  int x1=p1[0]-p0[0],y1=p1[1]-p0[1],x2=p2[0]-p0[0],y2=p2[1]-p0[1];
  int a=x1*x1+y1*y1,b=x1*x2+y1*y2,c=x2*x2+y2*y2-r*r;
  double d=sqrt(b*b-a*c);
  s[0]=p0[0]+x1*((b+d)/a);
  s[1]=p0[1]+y1*((b+d)/a);
  t[0]=p0[0]+x1*((b-d)/a);
  t[1]=p0[1]+y1*((b-d)/a);
  }//*/
void ashi(int p0[2],int p1[2],int p2[2],double p3[2]){
  int x1=p1[0]-p0[0],x2=p2[0]-p0[0],y1=p1[1]-p0[1],y2=p2[1]-p0[1];
  p3[0]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*x1+p0[0];
  p3[1]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*y1+p0[1];
}
void cplc(int p0[2],int p1[2],int p2[2],int r,double s[2],double t[2]){
  int x1=p1[0]-p0[0],y1=p1[1]-p0[1];
  double p3[2],l,x3,y3;
  ashi(p0,p1,p2,p3);
  x3=p3[0]-p2[0];
  y3=p3[1]-p2[1];
  l=sqrt(r*r-x3*x3-y3*y3);
  s[0]=p3[0]+x1/hypot(x1,y1)*l;
  s[1]=p3[1]+y1/hypot(x1,y1)*l;
  t[0]=p3[0]-x1/hypot(x1,y1)*l;
  t[1]=p3[1]-y1/hypot(x1,y1)*l;
}  
int main(){
  int p[4][2],n,i,r,j=0;
  double a[2][2],e=0.000005;
  scanf("%d %d %d %d",&p[2][0],&p[2][1],&r,&n);
  while(n--){
    for(i=0;i<4;i++)scanf("%d",&p[i/2][i%2]);
    cplc(p[0],p[1],p[2],r,a[0],a[1]);
    if(fabs(a[0][0]-a[1][0])<e)j=a[0][1]+e<a[1][1]?0:1;
    else                       j=a[0][0]+e<a[1][0]?0:1;
    printf("%.9f %.9f %.9f %.9f\n",a[j][0],a[j][1],a[1-j][0],a[1-j][1]);
  }
  return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  if (a * b % 2 == 0){
    cout << "Even\n";
  }
  else{
    cout << "Odd";
  }
  return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())

d = dict([ (i,set()) for i in range(1, N+1)])

for i in range(M):
    s,c = map(int,input().split())
    d[s].add(c)

flag = 1


# if ((0 in d[1]) or (len(d[1]) > 1)) :
#     if 0 in d[1] and N == 1:
#         ans = "0"
#     else:
#         flag = 0
# else:
#     ans = str(list(d[1])[0]) if len(d[1]) else "1"
#     for i in range(2, N+1):
#         if len(d[i]) > 1:
#             flag = 0
#             break
#         elif len(d[i]) == 0:
#             ans += "0"
#         else:
#             ans += str(list(d[1])[0])

ans = ""

for i in range(1, N+1):

    if len(d[i]) > 1:
        flag = 0
        break
    elif len(d[i]) == 1:
        el = str(list(d[i])[0])
        if el =="0" and i == 1:
            if N == 1:
                ans ="0"
            else:
                flag = 0
                break
        else:
            ans += el
    elif len(d[i]) == 0:
        ans += "1" if i == 1 else "0"
    else:
        print("PROBLEMS!")

if flag:
    if N == 1 and M == 0:
        print(0)
    else:
        print(ans)
else:
    print(-1)


Measured memory_bytes: 3064
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,K = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    if A>=K:
        cnt = 1*K
    elif A+B>=K:
        cnt = 1*A
    else:
        cnt = 1*A-1*(K-A-B)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

int main(){

    int N, K;
    cin >> N >> K;

    vector<int> d;
    vector<int> haveList(N);
    vector<vector<int>> A;
    d.resize(K);
    A.resize(K, vector<int>());
    for (int i = 0; i < K; i++){

        cin >> d[i];
        A[i].resize(d[i]);
        for (int j = 0; j < d[i]; j++){
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < N; i++){
        haveList[i] = 0;
    }

    for (int i = 0; i < K; i++){
        for (int j = 0; j < d[i]; j++){
            haveList[A[i][j] - 1]++;
        }
    }
    int count = 0;
    for (int i = 0; i < N; i++){
        if(haveList[i]==0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
function main()
  N=parse(Int,readline())
  ans=0
  i=2
  while i*i<=N
    if N%i==0
      c=0
      while N%i==0
        c+=1
        N=div(N,i)
      end
      x=1
      while c>=x
        c-=x
        ans+=1
        x+=1
      end
    end
    i+=1
  end
  if N>1
    ans+=1
  end
  println(ans)
end
main()

Measured memory_bytes: 156984
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) begin(v), end(v)
#define REV(v) rbegin(v), rend(v)
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

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

int a[25];
int d[15000010];

void debug(int pos, int n){
	rep(i, n){
		cout << pos % 3 << " ";
		pos /= 3;
	}
	cout << endl;
}

int main(){
	a[0] = 1;
	rep(i, 20) a[i + 1] = a[i] * 3;

	int n, m;
	while (cin >> n >> m, n | m){
		int start = 0;
		rep(i, 3){
			int k;
			cin >> k;
			while (k--){
				int x;
				cin >> x;
				start += i*a[x - 1];
			}
		}
		int goal = a[n] - 1;

		MEMSET(d, -1);
		d[start] = 0;
		queue<P> q;
		if (start == 0 || start == goal) goto OK;
		q.push(make_pair(start, 0));
		while (!q.empty()){
			P p = q.front();
			q.pop();

			int pos = p.first;
			int dist = p.second;

			int tmp = pos;
			bool ng[3] = {};
			for (int i = n - 1; i >= 0; --i){
				int x = tmp / a[i];
				tmp = tmp % a[i];
				if (ng[x]) continue;
				ng[x] = 1;
				for (int j = max(x - 1, 0); j <= min(x + 1, 2); ++j){
					if (ng[j]) continue;
					int nxt = pos + ((j - x)*a[i]);
					if (d[nxt] >= 0) continue;
					//debug(nxt, n);
					d[nxt] = dist + 1;
					if (nxt == 0 || nxt == goal) goto OK;
					if(dist + 1 < m) q.push(make_pair(nxt, dist+1));
				}
			}
		}
		cout << -1 << endl;
		continue;
	OK:;
		cout << max(d[0], d[goal]) << endl;
	}


	return 0;
}

Measured memory_bytes: 59804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
    // 隣り合う重複要素を削除し、末尾のゴミを削除
    // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す)
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
*/

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

    if (x == 7 || x == 5 || x == 3) cout << "YES";
    else cout << "NO";

    cout << endl;
}




Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m, k;
	cin >> m >> k;
	if (k>pow(2,m)-1){
		cout << "-1";
		return 0;
	}	
	if (m==1){
		if (k==0)
			cout << "0 0 1 1";
		else
			cout << "-1";
		return 0;
	}
	
	for (int i=0;i<pow(2,m);i++){
		if (i!=k)
			cout << i << " ";
	}
	cout << k << " ";
	for (int i=pow(2,m)-1;i>=0;i--){
		if (i!=k)
			cout << i << " ";
	}
	cout << k;
	return 0;
} 

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

string solve(const int &n, const int &y) {
	for (int i = 0; i * 10000 <= y; ++i) {
		for (int j = 0; i * 10000 + j * 5000 <= y; ++j) {
			int remain = (y - (i * 10000 + j * 5000)) / 1000;
			if (i + j + remain == n) {
				string str = to_string(i) + ' ' + to_string(j) + ' ' + to_string(remain);
				return str;
			}
		}
	}
	return string{"-1 -1 -1"};
}

int main() {
	int n, y;
	cin >> n >> y;
	cout << solve(n, y);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef map<int, int> MI;
typedef set<int> SI;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COUT(x) cout << (x) << endl

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    cout << (N - 2) * 180 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	string O,E;
	cin>>O>>E;
	
	for(int i=0;i<E.size();i++){
		cout<<O[i]<<E[i];
	}
	if(O.size()!=E.size()){
		cout<<O.back()<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var NM = [ ];
    var vec_p = [ ];
    var vec_s = [ ];
    var ary_ks = [];
    var ans = 0;
    var tmpAry, j, tmpNum, tmpSum;
    NM = input[0].map(e => parseInt(e, 10)); 
    vec_p = input[NM[1]+1].map(e => parseInt(e, 10)); 
    for (var ki = 1; ki <= NM[1]; ki++){
    	ary_ks.push(input[ki].map(e => parseInt(e, 10))); 
    }
  var x=0; 
    for (var i = Math.pow(2, NM[0]); i <  Math.pow(2, NM[0]) * 2; i++){
      x++;
    	tmpAry = i.toString(2).substr(1);
    	tmpAry_loop:
    	for (var ki = 1; ki <= NM[1]; ki++){
			tmpSum = 0;
			for (var sij = 1; sij <=  ary_ks[ki-1][0]; sij++){
				tmpNum = parseInt(tmpAry[ary_ks[ki-1][sij]-1], 10);
 				tmpSum +=  tmpNum;
			}
			if (ki == NM[1])  {
            }
		
			if (tmpSum % 2 != vec_p [ki-1]) break tmpAry_loop;
			if (ki == NM[1]) {
              ans ++;
            }
		}
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9512
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int toping, topingPrice;
		int bestPizza = 0, sumPrice = 0, sumCalorie = 0;
		int [] calorie = new int [100];
		boolean flag = false;
		
		for (int i = 0; i < 100; i++) {
			calorie[i] = 0;
		}
		
		toping = sc.nextInt();
		sumPrice = sc.nextInt();
		topingPrice = sc.nextInt();
		
		sumCalorie = sc.nextInt();
		
		for (int i = 0; i < toping; i++) {
			calorie[i] = sc.nextInt();
		}
		
		//カロリーが高い順に単純ソート
		for (int i = 0; i < toping-1; i++) {
			for (int j = i + 1; j < toping; j++) {
				if (calorie[i] < calorie[j]) {
					int shel = calorie[i];
					calorie[i] = calorie[j];
					calorie[j] = shel;
				}
			}
		}
		
		for (int i = 0; i < toping && !flag; i++) {
			sumCalorie += calorie[i];
			sumPrice += topingPrice;
			
			if (bestPizza > (int)(sumCalorie / sumPrice)) {
				flag = true;
			}else {
				bestPizza = (int)(sumCalorie / sumPrice);
			}
		}
		
		System.out.printf("%d\n", bestPizza);

	}

}

Measured memory_bytes: 19164
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 998244353;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, M, K;
    cin >> N >> M >> K;
    lint ans = 0;
    vector<lint> frac(500000);
    frac[0] = 1;
    FOR(i, 1, 500000) {
        frac[i] = frac[i-1] * i % MOD;
    }
    REP(i, K+1) {
        ans = (ans + M * power(M-1, N-1-i, MOD) % MOD * frac[N-1] % MOD * power(frac[N-1-i], MOD-2, MOD) % MOD * power(frac[i], MOD-2, MOD) % MOD) % MOD;
    }
    cout << ans << endl;
}

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

int main(void){
	string s;
	cin >> s;
	int n = s.length();
	int ans = 1000;

	for(int i=0; i<=n-3; i++){
		int a = s[i]-'0';
		int b = s[i+1]-'0';
		int c = s[i+2]-'0';
		int x = 100*a + 10*b + c;
		ans = min(ans,abs(753-x));
	}
	cout << ans << endl;
	return 0;
}

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

hw_lst = [0 for i in range(h+w)]
lst_map = []
for i in range(h):
  lst_map.append(list(input()))
ans = [0]

def dfs(i, lst, aa):
  if i == h+w:
    count = 0
    for ij in range(h):
      for j in range(w):
        if lst[ij] == 0 and lst[h+j] == 0 and lst_map[ij][j] == '#':
          count += 1
    if count == k:
      aa[0] += 1
    return

  a = lst.copy()
  dfs(i+1, a, aa)
  b = lst.copy()
  b[i] = 1
  dfs(i+1, b, aa)

dfs(0, hw_lst, ans)
print(ans[0])

Measured memory_bytes: 9236
import itertools
n,m = map(int,input().split())
zahyou_list = [i for i in map(int,input().split())]
zahyou_list.sort()
#print(zahyou_list)
kaisa_list = []

#print(sum(kaisa_list))

for i in range(len(zahyou_list)-1):
    kaisa_list.append(zahyou_list[i+1] - zahyou_list[i])
mini = sum(kaisa_list)
kaisa_list.sort()
#print(kaisa_list)
if n >= m:
    print(0)
elif n == 1:
    print(sum(kaisa_list))
else:
    print(sum(kaisa_list[:-(n-1)]))


Measured memory_bytes: 13696
#include <stdio.h>

int main() {
	int a, b, sum, i = 1;

	while (scanf("%d %d", &a, &b) != EOF) {
		i = 1;
		sum = a + b;

		while (sum / 10 != 0) {
			sum = sum / 10;
			i++;
		}

		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;





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

	vector<int> v(n);
	rep(i, 0, n)
		cin >> v[i];

	//max_list[i]:v[i+1]～v[n-1]の中の最大値
	vector<int> max_list;
	int temp;
	for (int i = n - 1; i >= 1; i--) {
		if (i == n - 1) {
			temp = v[i];
			max_list.insert(max_list.begin(),temp);
		}
		else {
			temp = max(v[i], temp);
			max_list.insert(max_list.begin(),temp);
		}
	}

	int temp_ans;
	int ans;

	rep(i, 0, n - 1) {
		if (i == 0) {
			temp_ans = max_list[i] - v[i];
			ans = 1;
		}
		else if (max_list[i] - v[i] > temp_ans) {
			temp_ans = max_list[i] - v[i];
			ans = 1;
		}
		else if (max_list[i] - v[i] == temp_ans) {
			ans += 1;
		}
	}

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



Measured memory_bytes: 1276
#include<iostream>
int main(){int h,b,i,j;std::string r,a;while(std::cin>>r>>a,r!="0"&&a!="0"){for(h=b=i=0;i<4;i++)for(j=4;j-->0;)if(a[i]==r[j])i==j?h++:b++;printf("%d %d\n",h,b);}}

Measured memory_bytes: 916
#include<stdio.h>
#define sz 10000
int main()
{
    long long int n,m;
    int a[sz];

    while(scanf("%lld %lld",&n,&m)!=EOF)
    {
        long long int i,sum = 0;
        for(i=0;i<m;i++)
            {
                scanf("%d",&a[i]);
                sum+=a[i];
            }
        if(n>=sum)
            printf("%lld",n-sum);
        else
            printf("-1");
    }

    return 0;

}


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


void solve(std::string S){
    int n = S.size();
    vector<int> ans(n);
    for(int i = 0; i < 2; ++i){
        {
            int cnt = 0;
            for(int j = 0; j < n; j++){
                if(S[j] == 'R') cnt++;
                else{
                    ans[j] += cnt/2;
                    ans[j-1] += (cnt+1)/2;
                    cnt = 0;
                }
            }
        }

        reverse(ans.begin(), ans.end());
        reverse(S.begin(), S.end());
        for(int j = 0; j < n; j++){
            if(S[j] == 'L') S[j] = 'R';
            else S[j] = 'L';
        }
    }
    
    for(int i = 0; i < n; ++i){
        printf("%d%c", ans[i], i==n-1?'\n':' ');
    }
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> result;
    while (n != 0) {
        int r = abs(n) % 2;
        result.push_back(r);

        n = (n - r) / -2;
    }
    rrep(i, result.size())
    {
        cout << result[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n ,k = I2()
    h = [I() for _ in range(n)]
    h.sort()
    ans = float("inf")
    for i in range(n-k+1):
        a,b = h[i],h[i+k-1]
        #print(a,b)
        ans = min(ans,b-a)
    print(ans)

Measured memory_bytes: 13444
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    string s, t; scan(s, t);
    int a, b; scan(a, b);
    string u; scan(u);

    if (u == s) a--; else b--;
    writeln(a, " ", b);
}


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

typedef long long ll;
const int inf = 1e9;
int l, r, d, u;

int main(){
	cin>>l>>r>>d;
	u = 0;
	for(int i = l; i <= r; ++i){
		if(i % d == 0)u++;
	}
	cout<<u<<endl;	
	return 0;
}


Measured memory_bytes: 3584
IDENTIFICATION DIVISION.
      PROGRAM-ID. 103A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      
      01 A.
      	03 AX PIC 9(3) OCCURS 3 DEPENDING ON CNT.
      01 CNT PIC 9(1) VALUE 3.
      01 ANS PIC ZZ9.
      
      PROCEDURE DIVISION.
      ACCEPT INP.      
      UNSTRING INP DELIMITED BY " "      
      INTO AX(1) AX(2) AX(3).
      
      SORT AX DESCENDING KEY AX.
      
      COMPUTE ANS = ( AX(1) - AX(2) ) + ( AX(2) - AX(3) ).
      
      DISPLAY ANS.
      
      STOP RUN.


Measured memory_bytes: 384
n, w = map(int, input().split())
#0 weight , [1] value
table = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for i in range(n+1)]

def choice_max(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(n):
    for j in range(w+1):
        if(j >= table[i][0]):
            dp[i+1][j] = choice_max(
                            dp[i][j],
                            dp[i][j - table[i][0]] + table[i][1]
                            )
        else:
            dp[i+1][j] = dp[i][j]
#[print(item)for item in dp]
print(dp[n][w])


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

d = {}

for ai in a:
    if ai not in d:
        d[ai] = 0
    d[ai] += 1

f = 1

k = list(d.keys())
k.sort()

# ボッチ猫の数
b = 0

if len(k) > 2:
    f = 0
elif len(k) == 2:
    if k[1] - k[0] != 1:
        f = 0
    b = d[k[0]]

# グループ数
g = k[-1] - b

if g <= 0 or g > d[k[-1]] // 2:
    f = 0

if len(k) == 1 and k[-1] == n - 1:
    f = 1

if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 17396