akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
int mod=1e9+7;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w,k;
  cin>>h>>w>>k;
  vector<int>ok;
  rep(i,1<<(w-1))
  {
    int ti=i;
    int flag=0;
    rep(j,w)
    {
      if(ti%4==3)flag=1;
      ti>>=1;
    }
    if(flag)continue;
    ok.push_back(i);
  }
  vector<int>dp(w);
  dp[0]=1;
  //for(auto i:ok)//cout<<i<<endl;
  rep(i,h)
  {
    vector<int>ttdp(w,0);
    for(auto j:ok)
    {
      auto tdp=dp;

      int tj=j;
      rep(k,w)
      {
        if(tj%2)swap(tdp[k],tdp[k+1]);
        tj>>=1;
      }
      rep(k,w)
      {
        ttdp[k]+=tdp[k];
        ttdp[k]%=mod;
        ////cout<<tdp[k];
      }
      //cout<<endl;

    }
    dp=ttdp;
  }
  //rep(i,w)//cout<<dp[i]<<endl;
  cout<<dp[k-1]<<endl;


  return 0;

}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::cmp::Ordering;
use std::collections::BinaryHeap;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
struct State {
    cost     : i32,
    node     : i32,
    vismask  : i32
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other.cost.cmp(&self.cost)
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other : &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}


fn main() {

    let n = read_t_in_line::<i64>()[0];
    let mut g = vec![vec![] ; n as usize];

    for _ in 0..n-1 {
        let l = read_t_in_line::<i64>();
        let (mut a, mut b, c) = (l[0], l[1], l[2]);
        a -= 1;
        b -= 1;
        g[a as usize].push((b, c));
        g[b as usize].push((a, c));
    }

    let l = read_t_in_line::<i64>();
    let (q, mut k) = (l[0], l[1]);
    k -= 1;
    
    let qs : Vec<_> =
        (0..q).
        map(|_| read_t_in_line::<i64>()).
        map(|l| (l[0] - 1, l[1] - 1)).collect();

    let mut dist = vec![i64::max_value() ; n as usize];
    let mut pq = BinaryHeap::new();

    pq.push((0 as i64, k));
    dist[k as usize] = 0 as i64;

    while let Some((mut ccost, cpos)) = pq.pop() {
        ccost *= -1;
        if ccost > dist[cpos as usize] {
            continue;
        }
        for &(npos, w) in &g[cpos as usize] {
            let ncost = ccost + w;
            if ncost < dist[npos as usize] {
                dist[npos as usize] = ncost;
                pq.push((-ncost, npos))
            }
        }
    }

    for (x, y) in qs {
        let ans = dist[x as usize] + dist[y as usize];
        println!("{}", ans);
    }

}


Measured memory_bytes: 23804
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define fr first
#define sc second
#define mk make_pair

using namespace std;

int n, ar[1000001];

int main()
{
    cin >> n;
    for(int i =0 ; i < n * 3; i++)
        cin >> ar[i];
    sort(ar, ar + n * 3);
    long long sum = 0;
    int k = n;
    int t = n * 3;
    while(k--)
    {
        t = t - 2;
        sum += ar[t];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 3194304
bool HA[L];
char T[256];

int main() {
    U n, s, t;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( register U i = 0; i++ < n; ) {
        s = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[s] = true;
        } else {
            puts( HA[s] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
#include <stdio.h>
#define N 1000000
int A[N];
int main(){
  int i,n,p=0,a,b;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  a = A[n-1];

  b = partition(A,p,n-1);

  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",A[i]);
    }
    else if(i == b){
      printf("[%d] ",A[i]);
    }
    else printf("%d ",A[i]);
  }
  return 0;
}

int partition(int *A,int p,int r){
  int x,i,j,hozon;
  x = A[r];
  i = p-1;
  for(j = p;j<=r-1;j++){
    if(A[j] <= x){
      i++;
      hozon = A[i];
      A[i] = A[j];
      A[j] = hozon;
    }
  }
  hozon = A[i+1];
  A[i+1] = A[r];
  A[r] = hozon;
  return i+1;
  
}



Measured memory_bytes: 2128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
char c[10][10];
int l[10],r[10];
signed main(){
	ic(h) ic(w)
	rep(0,i,h)rep(0,j,w)cin>>c[i][j];
	int sum=0;
	rep(0,i,h){
		sum=0;
		if(c[i][0]=='.')sum=-1;
		rep(0,j,w-1)if(c[i][j]!=c[i][j+1])sum++;
		if(sum>=2){
			c("Impossible")
			return 0;
		}
	}
	rep(0,i,h){
		rep(0,j,w){
			if((j==0&&c[i][j]=='#')||(j>=1&&c[i][j-1]=='.'&&c[i][j]=='#'))l[i]=j;
			if((j==w-1&&c[i][j]=='#')||(j<w-1&&c[i][j+1]=='.'&&c[i][j]=='#'))r[i]=j;
		}
	}
	rep(0,i,h-1){
		if(r[i]!=l[i+1]){
			c("Impossible")
			return 0;
			
		}
	}
	c("Possible")			
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll df(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b - (a % b < 0);
}

ll dc(ll a, ll b)
{
    if (b < 0) a = -a, b = -b;
    return a / b + (a % b > 0);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll sol = 0;
    for (ll a = 1; a <= n; ++a)
    {
        if (2 * a % k) continue;
        ll m = dc(1 + a, k);
        ll r = df(n + a, k);
        sol += (r - m + 1) * (r - m + 1);
    }
    cout << sol;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long int i,j,z,n;
    int k;
    cin>>k;
    for(i=-1000;i<=1000;i++){
        for(j=-1000;j<=1000;j++){
            z=i*i*i*i*i;
            n=j*j*j*j*j;
            if((z-n)==k){
                cout<<i<<" "<<j<<endl;
                return 0;
            }


        }
    }


}


Measured memory_bytes: 3184
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split(' '))
records = [tuple(map(int, input().split(' '))) for _ in range(Q)]

max_score = 0

for A in combinations_with_replacement(range(1, M + 1), r=N):
    score = 0
    for a, b, c, d in records:
        if A[b - 1] - A[a - 1] == c:
            score += d
    max_score = max(max_score, score)

print(max_score)


Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long int 

int main(){
  int n ,x;
  ll ans = 0L;
  cin >> n >> x;
  vector< ll > a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    ans += a[i];
  }
  vector< ll > b(a);
  for(int k = 0; k < n; ++k){
    //cout << "-----魔法を" << k << "回使うパターン---------" << endl;
    ll sum_born_cost = 0;
    for(int i = 0; i < n; ++i){
      int c = i - k;
      if(c < 0) c += n;
      //cout << " when (k,i) = " << "(" << k << "," << i << ")" << endl;
      //cout << " c = " << c << endl;
      b[i]  = min( b[i], a[c]);
      sum_born_cost += b[i];
      //cout << "b[" << i << "] = " << b[i] << endl;
    }
    ll temp = k * x + sum_born_cost; 
    ans  = min(ans, temp);
    //cout << "sum_born_cost = " << sum_born_cost << endl;
    //cout << "temp = " << temp << endl;
    //cout << "ans  = " << ans  << endl;
    //cout << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	int n;
	cin >> n;
	vector<int> a;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	reverse(a.begin(), a.end());
	stack<int> now;
	int now_itr = n;
	for (int i = 0; i < n; ++i) {
		s.push_back('(');
		now.push(a[i]);
		while (now.empty() == false && now.top() == now_itr) {
			now_itr--;
			now.pop();
			s.push_back(')');
		}
	}
	if (now_itr != 0) {
		cout << ":(" << endl;
		return 0;
	}
	reverse(s.begin(), s.end());
	REP(i, s.length()) {
		if (s[i] == '(') s[i] = ')';
		else s[i] = '(';
	}
	cout << s << endl;
	return 0;
}


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

typedef long long int ll;



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

    string s;
    cin >> s;
    bool cons = ((s[0]==s[1]) && (s[1]==s[2]) ) || ((s[1]==s[2]) &&(s[2] == s[3]));
    if(cons) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

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

        int n, r, i, j;
        while((n = scan.nextInt()) != 0 && (r = scan.nextInt()) != 0) {
            int data[] = new int[n];
            for(i = 0; i < n; i++) {
                data[i] = n - i;
            }
            for(i = 0; i < r; i++) {
                int p = scan.nextInt();
                int c = scan.nextInt();

                int subData[] = new int[n];
                for(j = 0; j < c; j++) {
                    subData[j] = data[p + j - 1];
                }
                for(j = 0; j < p - 1; j++) {
                    subData[c + j] = data[j];
                }
                for(j = 0; j < n + 1 - p - c; j++) {
                    subData[c + p - 1 + j] = data[c + p - 1 + j];
                }

                for(j = 0; j < n; j++) {
                    data[j] = subData[j];
                }
            }
            System.out.println(data[0]);
        }
    }
}


Measured memory_bytes: 38868
inputs = []
while str = STDIN.gets
  if str.chomp == "0 0" then break end
  inputs << str.chomp
end

def describe_rectangle(h, w)
  # puts "h = #{h}, w = #{w}"
  output = ""
  for j in 1..h do
    for i in 1..w do
      if i == 1 || i == w then
        output += "#"
      elsif j == 1 || j == h then
        output += "#"
      else
        output += "."
      end
    end
    output += "\n"
  end
  puts output
end

# puts inputs
for num in 0..inputs.length - 1 do
  rec = inputs[num].split(" ")
  # puts "rec = #{rec}"
  describe_rectangle(rec[0].to_i, rec[1].to_i)
  puts "\n"
end

Measured memory_bytes: 13864
/*
 * 2658.cc: Pruning
 */

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

/* constant */

const int MAX_N = 1000;

const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;

/* global variables */

int cs[MAX_N];
vi chlds[MAX_N], ps[MAX_N];

/* subroutines */

int rec(int k, int pk = INF) {
  int ret = 0;
  
  if (cs[k] > 0) ret = pk;
  else {
    int cn = chlds[k].size();
    for (int i = 0; i < cn; i++) ret += rec(chlds[k][i], ps[k][i]);
    if (ret > pk) ret = pk;
  }
  //printf("rec(%d,%d)=%d\n", k, pk, ret);
  return ret;
}

/* main */

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

  cs[0] = 0;
  for (int i = 1; i < n; i++) cin >> cs[i];

  for (int i = 0; i < n - 1; i++) {
    int ui, vi, pi;
    cin >> ui >> vi >> pi;
    if (ui > vi) swap(ui, vi);
    chlds[ui].push_back(vi);
    ps[ui].push_back(pi);
  }

  int ans = rec(0);
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1272
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    
    String[] str = in.readLine().split(" ");
    int t = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);

    int[] h = new int[n];
    str = in.readLine().split(" ");
    double diffMin = 10000000;
    int diffMinPoint = 0;
    for(int i=0; i<n; i++) {
      h[i] = Integer.parseInt(str[i]);
      double point = t-h[i]*0.006;
      if(diffMin > Math.abs(point-a)) {
        diffMin = Math.abs(point-a);
        diffMinPoint = i+1;
      }
    }
    
    System.out.println(diffMinPoint);
  }
}
    

Measured memory_bytes: 32836
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            int inpt = int.Parse(Reader.ReadLine());

            long itemCount = ((long)1<<inpt);

            List<long> items = new List<long>();

            for(int i=0; i<itemCount; i++) {
                items.Add(long.Parse(Reader.ReadLine()));
            }

            long ans = GetInt(items);
            Console.WriteLine(ans);
        }

        private long GetInt(List<long> items) {
            List<long> list = items;
            while(list.Count > 1) {
                List<long> tmp = new List<long>();

                for(int i=0; i<list.Count; i+=2) {
                    long koudo = Math.Abs(list[i] - list[i+1]);
                    if(koudo == 0) {
                        tmp.Add(list[i]);
                    } else {
                        tmp.Add(koudo);
                    }
                }
                list = tmp;
            }
            return list[0];  
        }


        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"







";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 15180
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll l = 0, r = n;
  while (r-l > 1) {
    ll mid = (l+r)/2;
    if (mid < p) {
      l = mid;
      continue;
    }
    if (p-1+n-mid >= v) {
      if (a[mid]+m >= a[p-1])
        l = mid;
      else
        r = mid;
      continue;
    }
    if (a[p-1] > a[mid]+m) {
      r = mid;
      continue;
    }
    ll rem = m*(v-(p-1+n-mid));
    for (int i = mid-1; i >= p-1; i--)
      rem -= min(a[mid]+m-a[i], m);
    if (rem <= 0)
      l = mid;
    else
      r = mid;
  }
  cout << l+1 << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int
main(int argc, char *argv[])
{
  int n; ll c;
  scanf("%d %lld", &n, &c);
  ll x[100000], v[100000];
  REP(i, n) scanf("%lld %lld", &x[i], &v[i]);

  ll vl[100000], sum = 0;
  REP(i, n){
    sum += v[i];
    vl[i] = sum - x[i];
  }

  ll vlmax[100000]; vlmax[0] = vl[0];
  for(int i = 1; i < n; i++){
    vlmax[i] = Max(vlmax[i - 1], vl[i]);
  }

  ll vr[100000]; sum = 0;
  REP(i, n){
    sum += v[n - 1 - i];
    vr[n - 1 - i] = sum - (c - x[n - 1 - i]);
  }
  
  ll vrmax[100000]; vrmax[n - 1] = vr[n - 1];
  for(int i = n - 2; i >= 0; i--){
    vrmax[i] = Max(vrmax[i + 1], vr[i]);
  }
  
  //右回りから始める
  ll ans = Max(0, vlmax[n - 1]);
  for(int i = n - 1; i >= 0; i--){
    if(i - 1 >= 0){
      ans = Max(vr[i] - (c - x[i]) + vlmax[i - 1], ans);
    }
  }
  
  //左回りから始める
  ans = Max(ans, vrmax[0]);
  for(int i = 0; i < n; i++){
    if(i + 1 < n){
      ans = Max(vl[i] - x[i] + vrmax[i + 1], ans);
    }
  }

  printf("%lld\n", ans);

  return 0;
}
    


Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main() {
	int a = 0;
	int b = 0;
	cin >> a >> b;
	int couA = 0;
	int couB = 0;
	for (int i = 0; i < b;i++) {
		couA += a*pow(10.0,i);
	}
	for (int i = 0; i < a; i++) {
		couB += b * pow(10.0, i);
	}
	if (b<=a) {
		cout<<couB<<endl;
	}
	else {
		cout << couA << endl;
	}
}

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

int main(){
  vector<int> vec(3);
  for(int i=0;i<3;i++)
    cin>>vec.at(i);
  sort(vec.begin(),vec.end());
  cout<<vec.at(2)*10+vec.at(0)+vec.at(1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int n,d;
vs s;

bool f(int ind, int g){
    rep(i,d){
        if(ind < n-1 && s[i][ind] == '1')ind++;
        else if(ind && s[i][ind-1] == '1')ind--;
    }
    return ind == g;
}

signed main(void) {
    while(cin >> n, n){
        int m;
        int k;//あたり
        cin >> m >> k >> d;
        m--;k--;
        s = vs(d);
        rep(i,d)cin >> s[i];
        if(f(m,k)){
            cout << 0 << endl;
        }else{
            bool ans = false;
            rep(i,d)rep(j,n-1){
                if(ans)continue;
                bool ng = s[i][j] == '1';
                if(j && s[i][j-1] == '1')ng = true;
                if(j < n-2 && s[i][j+1] == '1')ng = true;
                if(ng)continue;
                s[i][j]++;
                if(f(m,k)){
                    cout << i+1 << " " << j+1 << endl;
                    ans = true;
                    break;
                }
                s[i][j]--;
            }
            if(ans == false)cout << 1 << endl;
        }
    }
}



Measured memory_bytes: 3064
import sys

l = []
result = []
for i in sys.stdin:
    l.append(i)

for i in range(0,len(l)):
    l[i] = l[i].split()
    for j in range(0,len(l[i])):
        l[i][j] = int(l[i][j])

for i in range(1,l[0][0]+1):
    a = []
    for j in range(0,l[0][1]):
        a.append(l[i][j] * l[j+l[0][0]+1][0])
    result.append(sum(a))

for data in result:
    print(data)


Measured memory_bytes: 6032
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

int main() {
	ll N;
	cin >> N;

	ll A[MAX];
	repn(i, N) cin >> A[i];
	repn(i, N) A[i] -= i;

	sort(A + 1, A + N + 1);

	ll b = A[(N + 1) / 2];

	ll ans = 0;
	repn(i, N) ans += abs(A[i] - b);

	cout << ans;
	
	system("PAUSE");
}

Measured memory_bytes: 3704
S = input()
n = len(S)

if n % 2 == 0:
    mihon0 = '01' * (n//2)
    mihon1 = '10' * (n//2)
else:
    mihon0 = '0' + '10' * (n//2)
    mihon1 = '1' + '01' * (n//2)

ans0, ans1 = 0, 0
for i in range(n):
    if S[i] != mihon0[i]:
        ans0 += 1
    if S[i] != mihon1[i]:
        ans1 += 1

print(min(ans0, ans1))

Measured memory_bytes: 3444
#include<stdio.h>

int main()
{
        int N;
        int num, cnt, MAX_cnt, MAX_num, i;

        scanf("%d", &N);

        num = N;
        cnt = 0;
        MAX_cnt = 0;
        while(num>=1)
        {
                cnt = 0;
                i = num;
                while(1)
                {
                        if(i%2==0)
                        {
                                cnt++;
                                i /= 2;
                        }
                        else
                        {
                                break;
                        }
                }

                if(cnt>=MAX_cnt)
                {
                        MAX_cnt = cnt;
                        MAX_num = num;
                }

                num--;
        }

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

        return 0;
}



Measured memory_bytes: 128
import copy
n,m = map(int,input().split())
a = list(map(int,input().split()))

dp = [[] for k in range(n+1)]

cost = [0,2,5,5,4,5,6,3,7,6]

#dpの初期化
for i in range(m):
    if cost[a[i]] <= n:
        dp[cost[a[i]]]= [a[i]]


for i in range(0,n+1):
    for k in range(m):
        if i > cost[a[k]]:
            #print(cost[a[k]])
            tmp = copy.copy(dp[i-cost[a[k]]])
            tmp.append(a[k])
            tmp.sort(reverse = True)
            #print(i,tmp)
            if len(tmp) > len(dp[i]) and len(tmp) != 1:
                dp[i] = tmp
            elif len(tmp) == len(dp[i]) and len(tmp) != 1:
                big = 0

                for s in range(len(tmp)):
                    if tmp[s] > dp[i][s]:
                        big = 1
                        break
                    elif tmp[s] < dp[i][s]:
                        big = 0
                        break
                if(big):
                    dp[i] = tmp
            #print(dp)

ans = ""
for cha in dp[n]:
    ans = ans + str(cha)
print(ans)


Measured memory_bytes: 263176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int q,w,e;
    cin >> q >> w >> e;
    vector<int> hairetu = {q,w,e};
    sort(hairetu.begin(),hairetu.end());
    int answer = 0;
    answer += hairetu.at(1) - hairetu.at(0);
    answer += hairetu.at(2) - hairetu.at(1);
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    ans = 0
    for k, v in c.items():
        if k <= v:
            ans += v - k
        else:
            ans += v
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    int N,A,B,PA,PB;
    scanf("%d %d %d",&N,&A,&B);
    PA = A*N;
    PB  = B;
    if(PA < PB){
        printf("%d",PA);
    } else
        printf("%d",PB);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b, c;
  int n = 0, i;
  scanf("%d %d %d", &a, &b, &c);

  for (i = a; i <= b; i++) {
    if (c % i == 0)
      n++;
  }

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


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


int sub(int a,int  b) {
    for (int i = 100000; i > 0; i--) {
        if(a%i==0){
            if (b%i== 0) {
                return i;
            }
        }
    }
}


int main()
{
    int a,b;
    long c;
    cin >> a >> b;
    c = sub(a, b);
    a = a / c;
    b = b / c;
    c = c * (long)a * (long)b;


    cout <<  c <<endl;
}

Measured memory_bytes: 256
a=int(input())
b=list(map(int,input().split()))
b=b[::-1]
for i in range(a-1):
  if b[i+1]-b[i]>=2:
    print("No")
    exit()
  if b[i+1]>b[i]:
    b[i+1]-=1

print("Yes")

Measured memory_bytes: 14252
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){for(int j=0;j<=b;j++){for(int k=0;k<=c;k++){if(500*i+100*j+50*k==x)ans++;}}}
    cout<<ans<<endl;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] hs = br.readLine().split(" ");
		br.close();

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

		int cnt = h[0];
		for (int i = 1; i < n; i++) {
			if (h[i - 1] < h[i]) {
				cnt += h[i] - h[i - 1];
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 24532
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
p=0
l=0
k=0
A=a[n]
for i in range(n):
  B=a[n-i-1]
  C=b[n-i-1]
  if A>=C:
    ans+=C
    A=B
  elif A<C:
    ans+=A
    C=C-A
    if B>=C:
      ans+=C
      A=B-C
    else:
      ans+=B
      A=0
print(ans)

Measured memory_bytes: 18476
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> PII;
int gcd(int x, int y){
  return (x % y)?(gcd(y, x % y)):y;
}

int main(){
  int p,n;
  while(cin>>p>>n && p){
    double sp = sqrt(p);
    PII p1, p2;
    double val1 = INF, val2 = 0;
    for(int j = 1; j <= n; j++){
      int i = (int)(sp * j);
      double x = (double)(i+1)/j;
      if(gcd(i+1, j) == 1 && i+1 <= n && val1 > x){
        p1 = PII(i+1,j);
        val1 = x;
      }
      x = (double)i/j;
      if(gcd(i, j) == 1 && i <= n && val2 < x){
        p2 = PII(i,j);
        val2 = x;
      }
    }
    printf("%d/%d %d/%d\n",p1.first, p1.second, p2.first, p2.second);
  }
  return 0;
}

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

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n, m, ans;

struct union_find {
	int pr[nsz + 5];
	
	void inline init(int n) {
		cont (i, n) pr[i] = i;
	}
	
	int inline qry(int u) { return u == pr[u] ? u : pr[u] = qry(pr[u]); }
	
	bool inline link(int u, int v) {
		u = qry(u), v = qry(v);
		if (u == v) return 0;
		pr[v] = u;
		return 1;
	}
};
union_find uf;

int main() {
	scanf("%d%d", &n, &m);
	uf.init(n);
	cont (i, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		uf.link(u, v);
	}
	cont (u, n) ans += uf.qry(u) == u;
	ans -= 1;
	printf("%d\n", ans);
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 0;

ll a, b;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> a >> b;
	cout << a * b << '\n';
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N,cnt=0;
 cin >> N;
 vector<int> h(N);
 vector<int> a(N,0);
 for(int i=0;i<N;i++){
   cin >> h.at(i);
 }
 int hani=N;
 while(0<hani){
   for(int i=0;i<N-hani+1;i++){
     for(int j=i;j<hani+i;j++){
       if(a.at(j)==h.at(j)){
         break;
       }
       if(j==hani+i-1){
         cnt++;
         for(int k=0;k<hani;k++){
           a.at(i)++;
           i++;
         }
         i=-1;
       }
      }
   }
  hani--;
 }
 cout << cnt <<endl;
 }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  //入力終了

  //全員同じ数を持っている
  if(A == B && B == C){
    //偶数なら無限ループ
    if((A&1)==0)
      cout << -1 << endl;
    //奇数なら操作を行えない
    else
      cout << 0 << endl;
    return 0;
  }
    
  int ans = 0;
  //A, B，Cが全て偶数であれば続行
  while( (A&1)==0 && (B&1)==0 && (C&1)==0 ){
    int a = A;
    int b = B;
    int c = C;
    A = (b+c)/2;
    B = (c+a)/2;
    C = (a+b)/2;
    ans++;
  }

  //解答
  cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 3624
<?php
    fscanf(STDIN,'%s',$s);
    $ans = 'No';
    if((substr($s,2,1) === substr($s,3,1)) && (substr($s,4,1) === substr($s,5,1))){
        $ans = 'Yes';
    }
    echo $ans.PHP_EOL;
?>

Measured memory_bytes: 3700
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  ll n, a, b;
  scan(n, a, b);
  ll lc = n / (a + b);
  ll bl = min(a, n % (a + b));
  print(bl + lc * a);

  return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(){
    int a,b[3];
    char *t;
    cin >> a;
    b[0]=a/3600;
    b[1]=(a-b[0]*3600)/60;
    b[2]=a%60;
    cout << b[0] << ":" << b[1] << ":" << b[2] <<endl;
    return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    if (n < 105) printf("0\n");
    else if (n < 135) printf("1\n");
    else if (n < 165) printf("2\n");
    else if (n < 189) printf("3\n");
    else if (n < 195) printf("4\n");
    else printf("5\n");
    return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

const int N=3005;
int dp[N][N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin>>s>>t;
    forn(i,sz(s)){
        forn(j,sz(t)){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    int x=sz(s),y=sz(t);
    string ans;
    while(x&&y){
        if(s[x-1]==t[y-1]){
            ans+=s[x-1];
            x--,y--;
        }else if(dp[x][y]==dp[x-1][y]) x--;
        else y--;
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
}



Measured memory_bytes: 38876
/* ALDS1_3_C: Doubly Linked List */

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

/* A node of linked list. */
struct Node
{
    const int key;
    Node *next, *prev;

    public:
        Node(int);
};

Node::Node(int k) : key(k) {};

/* A doubly linked list. */
class DlList
{
    Node *guard;
    void remove(Node*);

    public:
        DlList();
        ~DlList();
        void insert(int);
        void delete_node(int);
        void delete_first();
        void delete_last();
        void print();
};

DlList::DlList()
{
    guard = new Node(-1);
    guard->next = guard->prev = guard;
}

DlList::~DlList()
{
    Node *tmp, *node = guard->next;
    while(node != guard) {
        tmp = node;
        node = node->next;
        delete tmp;
    }
    delete guard;
}

void DlList::insert(int key)
{
    Node *node = new Node(key);
    node->next = guard->next;
    guard->next->prev = node;
    guard->next = node;
    node->prev = guard;
}

void DlList::delete_node(int key)
{
    Node *node = guard->next;
    while( node->key != key && node != guard )
        node = node->next;
    remove(node);
}

void DlList::delete_first()
{
    remove(guard->next);
}

void DlList::delete_last()
{
    remove(guard->prev);
}

void DlList::remove(Node *node)
{
    if (node != guard) {
        node->next->prev = node->prev;
        node->prev->next = node->next;
        delete node;
    }
}

void DlList::print()
{
    Node *node = guard->next;
    if (node == guard)
        return;

    printf("%d", node->key);
    node = node->next;
    while( node != guard ) {
        printf(" %d", node->key);
        node = node->next;
    }
    printf("\n");
}

int main()
{
    DlList list;

    int n_commands;
    cin >> n_commands;

    char command[15];
    int key;
    for (int i = 0; i < n_commands; i++) {
        scanf("%s %d\n", command, &key);
        if (command[0] == 'i') {
            list.insert(key);
        }
        else if (command[0] == 'd') {
            switch( strlen(command) ) {
                case 6:
                    list.delete_node(key); break;
                case 11:
                    list.delete_first(); break;
                case 10:
                    list.delete_last(); break;
            }
        }
    }
    list.print();
    return 0;
}

Measured memory_bytes: 32424
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let x: usize = read().unwrap();
    let v: Vec<usize> = vec![105, 104, 103, 102, 101, 100];
    if x < 100 {
        println!("{}", 0);
    } else {
        let mut res = 0;
        let mut nums: Vec<usize> = vec![0, 0, 0, 0, 0, 0];
        nums[0] = x / v[0];
        for a in 0..nums[0] + 1 {
            nums[1] = (x - v[0] * a) / v[1];
            for b in 0..nums[1] + 1 {
                nums[2] = (x - v[0] * a - v[1] * b) / v[2];
                for c in 0..nums[2] + 1 {
                    nums[3] = ((x - v[0] * a - v[1] * b - v[2] * c) / v[3]);
                    for d in 0..nums[3] + 1 {
                        nums[4] = ((x - v[0] * a - v[1] * b - v[2] * c - v[3] * d) / v[4]);
                        for e in 0..nums[4] + 1 {
                            let price = x - a * v[0] - b * v[1] - c * v[2] - d * v[3] - e * v[4];
                            if price % v[5] == 0 {
                                res = 1;
                                break;
                            }
                        }
                        if res == 1 {
                            break;
                        }
                    }
                    if res == 1 {
                        break;
                    }
                }
                if res == 1 {
                    break;
                }
            }
            if res == 1 {
                break;
            }
        }
        println!("{}", res);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n,k,ans=0;
    cin >> n >> k;
    vector<ll> x(n);
    for (ll i=0;i<n;++i){
        ll a;
        cin >> a;
        x[i]=a;
    }
    sort(x.begin(),x.end());
    for (ll i=0;i<k;++i){
        ans+=x[x.size()-i-1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <cstring>
#include <sstream>
#include <stdlib.h>
#include <iomanip>
//#include <vector>

using namespace std;

int main (void)
{
	long double a = 0.0,b = 1000000.0,p;
	int co = 0;
	while (cin >> p)
	{
		if (a < p)
		{
			a = 0.0;
			a = p;
		}
		if (b > p)
		{
			b = 0.0;
			b = p;
		}
		p = 0;
	}

	cout << a - b << endl;
	return 0;
}






Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int X,Y; cin>>X>>Y;
	for (int i=0; i<=X; i++) {
		if(i*2+(X-i)*4==Y) {
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>

int main()
{
  char s[3],t[3];
  
  scanf("%s",&s);
  scanf("%s",&t);

  int r=0;
  
  for(int i=0;i<3;i++)
  {
   if(s[i]==t[i])
     r++;
  }
  printf("%d\n",r);
  
 return 0; 
}

Measured memory_bytes: 128
N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]
info_new = sorted(info,key=lambda x:(x[0],x[1]))
note = info_new[0][0]
cnt = 1
for i in range(M):
    if info_new[i][0] == note:
        info_new[i][1] = cnt
        cnt += 1
    else:
        note = info_new[i][0]
        cnt = 1
        info_new[i][1] = cnt
        cnt += 1
        
for i in range(M):
    pri = str(info[i][0])
    bir = str(info[i][1])
    number = "0"*(6-len(pri)) + pri + "0"*(6-len(bir)) + bir
    print(number)

Measured memory_bytes: 36260
#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 vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
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 invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<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(){
    int N; cin >> N;
    map<string, int> m;
    string s;
    rep(i, N){
        cin >> s;
        m[s]++;
    }
    int M; cin >> M;
    rep(i, M){
        cin >> s;
        m[s]--;
    }
    int ans = 0;
    for(map<string, int>::iterator iter = m.begin(); iter != m.end(); ++iter){
        ans = max(ans, iter->second);
    }
    COUT(ans);
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] data = new int[3];
        data[0] = scan.nextInt();
        data[1] = scan.nextInt();
        data[2] = scan.nextInt();
        Arrays.sort(data);
        int a = data[2] - data[0];
        int b = data[2] - data[1];
        int c = data[1] - data[0];
        int answer = Integer.MAX_VALUE;
        if (a % 2 == 0 && b % 2 == 0) {
            answer = Math.min(answer, a / 2 + b / 2);
        }
        if (c % 2 == 0) {
            answer = Math.min(answer, b + c / 2);
        }
        if (c % 2 != 0) {
            answer = Math.min(answer, b + 1 + (c + 1) / 2);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22736
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int count[5][4][11];
    for(int i=1;i<=4;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                count[i][j][k]=0;
            }
        }
    }  
    int b,f,r,v;
    for (int i=0;i<n;i++){
       cin >> b >> f >> r >> v;
       count[b][f][r] += v;
    }

    for(int i=1;i<=4;i++){
       for(int j=1;j<=3;j++){
            for(int k=1;k<=10;k++){
                cout  << " "<< count[i][j][k];
            }
            cout << endl;
        }
          if(i<4){
            for(int l=0;l<20;l++){
                cout << "#";
            }
            cout << endl;
            }
    }
        return 0;
}


Measured memory_bytes: 3092