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


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

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

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

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

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


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

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

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    while (A >= B) {
        B *= 2;
        K--;
    }

    while (B >= C) {
        C *= 2;
        K--;
    }
    if (K >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


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

    solve();


    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (B < A) {
    cout << "Alice" << endl;
  } else if (A < B) {
    cout << "Bob" << endl;
  } else {
    cout << "Draw" << endl;
  }
  return 0;
}


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

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;

ll table[600][600];

int main() {
    std::cin >> n;
    if( ( (ll)sqrt(1+8*n) ) * ( (ll)sqrt(1+8*n) ) != 1+8*n  ){
        std::cout << "No" << std::endl;
    }else{
        ll count =1;
        for (int i = 0; i < 590; i++) {
            for (int j = 0; j <= i; j++) {
                table[j][i] = count;
                count++;
            }
        }
        std::cout << "Yes" << std::endl;
        ll k = ((ll)sqrt(1+8*n)+1)/2;
        std::cout << k << std::endl;
        for (int i = 0; i <= k-2; i++) {
            std::cout << k-1;
            
            for (int j = 0; j <= k-2; j++) {
                std::cout <<" "<< table[min(i,j)][max(i,j)];
            }
            std::cout << std::endl;
        }
        std::cout << k-1;
        for (int j = 0; j <= k-2; j++) {
            std::cout <<" "<< table[j][j];
        }
        std::cout << std::endl;
        
    }
}


Measured memory_bytes: 4096
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

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

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;

    if(u == s) cout << a-1 << ' ' << b << '\n';
    else cout << a << ' ' << b-1 << '\n';


    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    char S[4], buff[20];
    for(int i = 0; i < 3; i++){
        cin >> buff;
        S[i] = buff[0] + 'A' - 'a';
    }
    S[3] = '\0';
    cout << S;
    return  0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 15){
    cout << '+' << endl;
  }
  else if(a * b == 15){
    cout << '*' << endl;
  }
  else{
    cout << 'x' << endl;
  }
}


Measured memory_bytes: 3120
/*
 * atcoder/abc142/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

void solve() {
  ll a, b;
  vector<ll> D;
  cin >> a >> b;
  auto a_pf = prime_factorize(a);
  auto b_pf = prime_factorize(b);
  int i=0; int j=0;
  while (i<a_pf.size() and j<b_pf.size()) {
    if (a_pf[i].first == b_pf[j].first) {
      D.push_back(a_pf[i].first);
      i++;j++;
      continue;
    }
    if (a_pf[i].first < b_pf[j].first) i++;
    else j++;
  }
  cout << 1 + D.size() << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
/**
*	created: 23.08.2020 15:49:26
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0) cout << 0 << endl;
    else {
        vector<int> c;
        c.push_back(a);
        c.push_back(b);
        auto f = [](int x, int y) {
            int ret = INF;
            rep2(i,1,y) {
                int up = x * i, res = x * (y - i);
                int d = x/2;
                int r1 = (y - i) * d, r2 = (y - i) *  (x - d);
                int mx = max({up,r1,r2});
                int mn = min({up,r1,r2});
                chmin(ret,mx-mn);
            }
            return ret;
        };
        c.push_back(f(a,b));
        c.push_back(f(b,a));
        sort(all(c));
        cout << c[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
char s[20];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		int cur=0;
		for(int j=i;j<=n;j++){
			++cur;
			if(s[j]!='A'&&s[j]!='G'&&s[j]!='C'&&s[j]!='T'){
				break;
			}
			ans=max(ans,cur);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
H,W,K = map(int,input().split())
init_map = []
for i in range(H):
    row = list(input())
    init_map.append(row)
ans = 0
 
for paint_h in range(2 ** H):
    for paint_w in range(2 ** W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (paint_h >> i)&1 == 0 and (paint_w >> j)&1 == 0:
                    if init_map[i][j] == "#":
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9212
n, m, q = map(int, input().split())
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q
score = [0] * n
ans = 0
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

def calc_score(score):
    ret = 0
    for i in range(q):
        if score[b[i] - 1] - score[a[i] - 1] == c[i]:
            ret += d[i]
    return ret

def dfs(score, i, num):
    global ans
    if i == n:
        ans = max(ans, calc_score(score))
        return 
    for j in range(num, m + 1):
        score[i] = j
        dfs(score, i + 1, j)


dfs(score, 0, 1)
print(ans)

Measured memory_bytes: 9144
#include <iostream>
#include <algorithm>
#include <sstream>
#include <iterator>

using namespace std;

int main(void){
	int n;
	ostringstream stream;
	string s;

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

	reverse(a, a+n);

	copy(a, a+n, ostream_iterator<int>(stream," "));
	s = stream.str();
	s.erase(s.length()-1);
	cout << s << endl;

	return 0;
}



Measured memory_bytes: 3108
using System;
using System.Linq;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');

            if (str2[1] == "1") Console.WriteLine('1');
            else Console.WriteLine('0');

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
       
    cout << (A-1)*(B-1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int i,a,b,t[4]={6000,4000,3000,2000};
	for(i=0;i<4;i++) {
		cin>>a>>b;
		cout<<t[a-1]*b<<endl;
	}
}

Measured memory_bytes: 3068
//パチンコ
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;


int N = 26;
int D;

vector<int> c(N+1);
vector<vector<int>> s;
vector<int> t;

ll now_score = 0;

ll greedy(){
    vector<int> last(N+1, 0);
    ll greedy_score=0;
    for(int d = 1; d <= D; d++){
        ll max_score = -1e9;
        vector<int> max_last;
        for(int n = 1; n <= N; n++){
            ll tmp_score = 0;
            vector<int> tmp_last(N+1);
            tmp_last = last;
            
            tmp_score +=  s[d][n];
            tmp_last[n] = d;
     
            int penalty = 0;
            for(int i = 1; i <= N; i++){
                penalty += c[i]*(d-tmp_last[i]);    
                
            }
            
            tmp_score -= penalty;

            if(max_score < tmp_score){
                max_score = tmp_score;
                max_last = tmp_last;
                t[d] = n;
            }                    
            
        }
        
        last = max_last;
        greedy_score += max_score;
    }

    return greedy_score;
}


ll scoring(){
    vector<int> last(N+1, 0);
    ll score = 0;
    for(int d = 1; d <= D; d++){

        score += s[d][t[d]];
        last[t[d]] = d;

        int penalty = 0;
        for(int i = 1; i <= N; i++){
            penalty += c[i]*(d-last[i]);    
        }
        
        score -= penalty;            
    }
    return score;
}


void exchange(int d, int x){
    swap(t[d], t[d+x]);

    ll swap_score = scoring();
    
    if(now_score >= swap_score){
        swap(t[d], t[d+x]);
    }else{
        now_score = swap_score;
    }

}

void pachinko(){
    srand((unsigned) time(NULL)); /* Use Mersenne Twister */
    for(int i=1; i<=D; i++){
        int pre = t[i];
        t[i] = rand()%26+1;

        ll pachi_score = scoring();
        if(now_score >= pachi_score){
            t[i] = pre;
        }else{
            now_score = pachi_score;
        }        
    }

}

int main(){
    cin>> D;

    s.resize(D+1);
    for(int i=0; i<=D; i++){
        s[i].resize(N+1);
    }
    t.resize(D+1);

    for(int i=1; i<=N; i++){
        cin>>c[i];
    }
 
    for(int i=1; i<=D; i++){
        for(int j=1; j<=N; j++){
            cin>>s[i][j];
        }
    }
    for(int i=1; i<=D; i++){
        cin>>t[i];
    }

    now_score = greedy();

    //乱数パチンコ
    pachinko();
    //解交換
    for(int x=1; x<D; x++){
        for(int d=1; d<=D-x; d++){
            exchange(d, x);
        }
    }
    //乱数パチンコ
    pachinko();    
    
    for(int i=1; i<=D; i++){           
        cout<<t[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
map<string,vector<int> > sv;
map<vector<int>,string > vs;
map<string,string> ss;
vector<int> dfs();
int n,m,inp,d,p,f;
string s,t,t2;
bool ans;

vector<int> get(){
  vector<int> res(n);
  res[0]=(1e9);
  if(s[p]=='(')p++,res=dfs(),p++;
  else{
    string str;
    while(('a'<=s[p]&&s[p]<='z')||('A'<=s[p]&&s[p]<='Z'))str+=s[p++];
    res=sv[ss[str]];
  }
  return res;
}

vector<int> cal(){
  vector<int> res=get(),r;
  while(s[p]!=')'){
    if(s[p]=='*'){
      p++;
      r=get();
      for(int i=0;i<n;i++)res[i]+=r[i];
    }
    else if(s[p]=='/'){
      p++;
      r=get();
      for(int i=0;i<n;i++)res[i]-=r[i];
    }else break;
  }
  return res;
}

vector<int> dfs(){
  vector<int> res=cal(),r(n);
  r[0]=(1e9);
  while(p<s.size()&&s[p]!=')'){
    if(s[p]=='+'||s[p]=='-')p++;
    else r=cal();
    if(r[0]!=(1e9)&&res!=r)ans=false;
  }
  return res;
}

int main(){
  while(1){
    cin>>n>>m>>inp;
    if(!n&&!m&&!inp)break;
    for(int i=0;i<m;i++){
      cin>>t;
      for(int j=0;j<n;j++){
	cin>>d;
	sv[t].push_back(d);
      }
      vs[sv[t]]=t;
    }
    cin>>s;
    for(int i=0;i<inp;i++){
      cin>>t>>t2;
      ss[t]=t2;
    }
    s='('+s+')'; p=0;
    ans=true;
    vector<int> r=dfs();
    if(!ans)cout<<"error"<<endl;
    else if(vs.count(r))cout<<vs[r]<<endl;
    else cout<<"undefined"<<endl;
    sv.clear();
    vs.clear();
    ss.clear();
  }
  return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int n; cin >> n;
    string s; cin >> s;
    char pre = s[0];
    int cnt = 0;
    for(int i = 1; i < n; i++) {
        if(s[i] != pre) {
            cnt++;
            pre = s[i];
        }
    }

    cout << cnt+1 << '\n';
}

Measured memory_bytes: 512
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] x = new int[N];
        int[] y = new int[N];
        for(int i = 0; i < N; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
        double sum = 0;
        for(int i=0; i<N-1; i++) {
            for(int j=i+1; j<N; j++) {
                sum += Math.sqrt(Math.pow(x[i]-x[j],2) + Math.pow(y[i] - y[j],2));
            }
        }
        System.out.println(sum * 2 / N);
    }
}

Measured memory_bytes: 23892
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := -int(1e+18)
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := int(1e+18)
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	c := 0
	f := false
	for i := 0; i < n; i++ {
		if iScan() == iScan() {
			c++
			if c == 3 {
				f = true
			}
		} else {
			c = 0
		}
	}
	bPrint(f, "Yes", "No")
}


Measured memory_bytes: 1776
import bisect as bi
n=int(input())
b=[0]*n
c=[0]*n
ans=0
for i in range(n):
    r=int(input())
    b[i]=[r,i%2]
    c[i]=r
c.sort()
for i in range(n):
    j=bi.bisect_left(c,b[i][0])
    #print(j)
    ans+=abs(j%2-b[i][1])
print(ans//2)


Measured memory_bytes: 17724
N = int(input())
v = list(map(int, input().split()))
d0 = {0: 0}
d1 = {0: 0}
for j, i in enumerate(v):
    if j % 2 == 0:
        if i in d0:
            d0[i] += 1
        else:
            d0[i] = 1
    else:
        if i in d1:
            d1[i] += 1
        else:
            d1[i] = 1

l0 = sorted(d0.items(), key=lambda x: -x[1])
l1 = sorted(d1.items(), key=lambda x: -x[1])

if l0[0][0] == l1[0][0]:
    a = min(N - l0[0][1] - l1[1][1], N - l0[1][1] - l1[0][1])
    print(a)
else:
    print(N - l0[0][1] - l1[0][1])


Measured memory_bytes: 63084
#include<iostream>
#include<algorithm>

using namespace std;

int N, Y;

int maisu[3];
bool f = false;

void dfs(int step) {

	if (f)return;

	if (step == 0) {
		for (int i = 0; i <= min((Y / 10000), N); i++) {
			maisu[step] = i;
			dfs(step + 1);
			maisu[step] = 0;
		}
	}
	else if (step == 1) {
		for (int i = 0; i <= min((Y - maisu[0] * 10000) / 5000, N - maisu[0]); i++) {
			maisu[step] = i;
			dfs(step + 1);
			maisu[step] = 0;
		}
	}
	else {
		int ans = 0;
		ans = maisu[0] + maisu[1] + (Y - maisu[0] * 10000 - maisu[1] * 5000) / 1000;
		if (ans == N)cout << maisu[0] << " " << maisu[1] << " " << N - maisu[0] - maisu[1] << endl, f = true;
	}
}

int main() {
	cin >> N >> Y;
	dfs(0);
	if (f == false)cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, s1, s2;
	int card[2], i;
	
	while (1){
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		s1 = 0;
		s2 = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d %d", &card[0], &card[1]);
			
			if (card[0] == card[1]){
				s1 += card[0];
				s2 += card[1];
			}
			else if (card[0] > card[1]){
				s1 += card[0] + card[1];
			}
			else{
				s2 += card[0] + card[1];
			}
		}
		printf("%d %d\n", s1, s2);
	}
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  
  vector<long long> A(N);
  long long sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= i + 1;
  }
  sort(A.begin(), A.end());
  
  long long b;
  if(N % 2 == 1) {
    b = A[N / 2];
  } else {
    b = (A[N / 2] + A[N / 2 - 1]) / 2;
  }
  
  long long ans = 0;
  for(int i = 0; i < N; i++) {
    ans += abs(A[i] - b);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){

    int a,b,d,r;
    double f;
     
 	  scanf("%d",&a);
	  scanf("%d",&b);   

    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
 
 	printf("%d %d %.5f\n",d,r,f);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(500);
    for (ll i = 0; i < 500; i++) {
        z.at(i) = i * i * i * i * i;
    }
    for (int i = 0; i < 500; i++) {
        int y = 0;
        for (int j = 0; j < 500; j++) {
            if (z.at(i) - z.at(j) == n) {
                cout << i << " " << j << endl;
                y = 1; break;
            }
            if (z.at(i) + z.at(j) == n) {
                cout << i << " " << -1*j << endl;
                y = 1; break;
            }
            if (-1*z.at(i) - z.at(j) == n) {
                cout << -1*i << " " << j << endl;
                y = 1; break;
            }
            if (-1*z.at(i) - z.at(j) == n) {
                cout << -1*i << " " << -1 * j << endl;
                y = 1; break;
            }
        }
        if (y == 1)break;
    }

}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int x;

    cin >> x;

    if(x==0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
    
}

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

// 配列を用いてset風に処理
int main(){
  int N;
  cin >> N;
  vector<int> flag(101);//数は100までなので要素数は0空100で101
  for(int i = 0; i < N; i++){
    int kazu;
    cin >> kazu;
    flag[kazu] = 1;
  }

  int result = 0;
  for(int i = 0; i < 101; i++){
    result += flag[i];
  }

  cout << result  << endl;

}

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

using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    vector<ll> route;

    for (ll i = 1; (i * i) <= (ll) pow(10, 9); i++) {
        route.push_back(i * i);
    }

    int n;
    cin >> n;

    ll i = *(upper_bound(route.begin(), route.end(), n) - 1);

    cout << i << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
int r,g,b,n;
cin>>r>>g>>b>>n;
int ans=0;
for(int i=0;i<=n;i++)
{
	for(int j=0;j<=n;j++)
	{
		int x=r*i+j*g;
		if(n>=x&&(n-x)%b==0)
		ans++;
	}
}
cout<<ans;
}


Measured memory_bytes: 256
N = int(input())
*a,= map(int, input().split())
count={}

for i in range(N):
  count[a[i]]=0
  
def ncn(n):
  return n*(n-1)//2

for i in range(N):
  count[a[i]]+=1

total=0
for key in count.keys():
  kc = count[key]
  total += ncn(kc)
  
def without(k):
  return total-count[a[k]] + 1

for k in range(N):
  print(without(k))

Measured memory_bytes: 26268
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	H, W   int
	answer int
)

func main() {
	readVariables()
	if H != 1 && W != 1 {
		answer = ((H+1)/2)*((W+1)/2) + (H/2)*(W/2)
	} else {
		answer = 1
	}
	fmt.Println(answer)
}

func readVariables() {
	H, W = nextInt(), nextInt()

}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  char s[200];
  cin >> s;
  for(int i=0;i<strlen(s);i++){
    if(i==a&&s[i]!='-'){
      cout << "No";
      return 0;
    }
    if(i!=a&&!(s[i]>='0'&&s[i]<='9')){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


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

int main()
{
    int n, k;
    string s;
    cin >> n >> s >> k;
    char ans = s[k - 1];
    for(int i = 0; i < n; i++){
        if(s[i] != ans){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,cev,b,a[li],k,bas,son,ortak;
string s;
vector<lo> v;

int main(void){
	fio();
	cin>>n;
	FOR{
		cin>>s;
		lo z=(lo)s.size();
		for(lo i=0;i<z-1;i++){
			if(s[i]=='A' && s[i+1]=='B') cev++;
		}
		if(s[z-1]=='A' && s[0]=='B') ortak++;
		else if(s[z-1]=='A') son++;
		else if(s[0]=='B') bas++;
	}
	///////////////////////////////////////////
	//~ lo x=0,xx=0;
	//~ x++;
	//~ lo at=min(bas,son);
	//~ x+=min(bas,son);
	//~ bas-=at;
	//~ son-=at;
	//~ if((son>0 || bas>0) && ortak>0) x+=1;
	//~ if(ortak>0)
		//~ x+=ortak-1;
	////////////////////////////////////////////////
	//~ lo kat=min(bas,min(son,ortak));
	//~ xx+=kat*2;
	//~ bas-=kat;
	//~ son-=kat;
	//~ ortak-=kat;
	//~ lo at=min(bas,son);
	//~ xx+=min(bas,son);
	//~ bas-=at;
	//~ son-=at;
	//~ if((son>0 || bas>0) && ortak>0) xx+=1;
	//~ if(ortak>0)
		//~ xx+=ortak-1;
	//////////////////////////////////////////////
	if(bas>0 && son>0 && ortak>0){
		cev+=ortak-1+2;
		bas--;
		son--;
		cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas==0 && son==0 && ortak==0){cout<<cev<<endl;return 0;}
	if(bas>0 && son>0 && ortak==0){
		//~ cout<<"**\n";
		cev+=min(bas,son);
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas==0 && son>0 && ortak>0){
		cev+=ortak-1+1;
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas>0 && son==0 && ortak>0){
		cev+=ortak-1+1;
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas==0 && son==0 && ortak>0){
		cev+=ortak-1;
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas==0 && son>0 && ortak==0){
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	if(bas>0 && son==0 && ortak==0){
		//~ bas--;
		//~ son--;
		//~ cev+=min(bas,son);
		cout<<cev<<endl;
		return 0;
	}
	//~ cout<<cev<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a,cnt=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		if(a%2==1){
			++cnt;
		}
	}
	if(cnt%2==1){
		printf("NO");
	}else printf("YES");
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	static int l;
	static ll a[200010];
	scanf("%d",&l);
	rep1(i,l)scanf("%lld",&a[i]);
	
	static ll dp[2][5] = {};
	static int t = 0, t_ = 1;
	rep1(i,l){
		rep(j,5){
			dp[t_][j] = 1000000000000000000;
		}
		rep(j,5){
			for(int k = j ; k < 5 ; k ++){
				dp[t_][k] = min( dp[t_][k] , dp[t][j] );
			}
		}
		dp[t_][0] += a[i];
		dp[t_][1] += a[i]%2;
		if(a[i] == 0)dp[t_][1] += 2;
		dp[t_][2] += 1-(a[i]%2);
		dp[t_][3] += a[i]%2;
		if(a[i] == 0)dp[t_][3] += 2;
		dp[t_][4] += a[i];
		swap(t,t_);
	}
	ll ret = 1000000000000000000;
	rep(i,5)ret = min( ret , dp[t][i] );
	cout << ret << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define mmax 1000
using namespace std;

int max_num = 0;

struct cell{
	int num;
	int index;
};
int func(int a[],int left,int midle,int right){
	if(left == midle) return 0;
	int local_min,local_max;
	local_min = a[left]; local_max = a[midle];
	for(int i = left+1; i < midle; i++){
		if(local_min > a[i]) local_min = a[i];
	}
	for(int i = midle+1; i<right; i++){
		if(local_max < a[i]) local_max = a[i];
	}
	int kouho_one = func(a,left,(left+midle)/2,midle);
	int kouho_two = func(a,midle,(midle+right)/2,right);
	int kouho_three = local_max - local_min;
	
	if(kouho_one <= kouho_three && kouho_two <= kouho_three) return kouho_three;
	else if(kouho_three <= kouho_one && kouho_two <= kouho_one) return kouho_one;
	else return kouho_two;
}
/*
int cmp(const void *p, const void *q)
{
	return ((cell*)p)->num - ((cell*)p)->num;
}
*/
int q_sort(cell d[],int left,int right);
int main(void)
{
	int n,t; cin>>n>>t;
	int a[n];
	cell data[n];
	cell p;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		p.num = a[i];
		p.index = i;
		data[i] = p;
	}
	int max = 0;
	int ans = func(a,0,n/2,n);
	//cout<<"ans = "<<ans<<endl;
	/*
	for(int i = 0; i < n; i++){
		cout<<"i = "<<i<<", data_num = "<<data[i].num<<", data[i].index = "<<data[i].index<<endl;
	}
	*/
	//qsort(data,n,sizeof(cell),cmp);
	q_sort(data,0,n-1);
	
	/*
	cout<<"\n"<<endl;
	for(int i = 0; i < n; i++){
		cout<<"i = "<<i<<", data_num = "<<data[i].num<<", data[i].index = "<<data[i].index<<endl;
	}
	*/
	int ans_ans = 0;
	int left = 0,right = 0;
	
	while(left<n){
		//cout<<"left = "<<left<<", right = "<<right<<endl;
		if(left == right){
			right++;
		}
		else{
			if(data[left].num + ans == data[right].num && data[left].index < data[right].index && right < n){
				ans_ans++;
				left++;
				right++;
			}
			else if(data[left].num + ans < data[right].num){
				left++;
			}
			else if(right < n){
				right++;
			}
			else left++;
		}
	}
	cout<<ans_ans<<endl;
	
	return 0;
}


int q_sort(cell d[],int left,int right){
	if(left >= right) return 0;
	cell pipot = d[(left+right)/2];
	cell tmp;
	int l = left, r = right;
	while(l<r){
		while(d[l].num < pipot.num) l++;
		while(d[r].num > pipot.num) r--;
		if( l <=  r){
			tmp = d[l];
			d[l] = d[r];
			d[r] = tmp;
			l++;
			r--;
		}
	}
	q_sort(d,left,r);
	q_sort(d,l,right);
}



Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> L(90);
  L[0] = 2; L[1] = 1;
  FOR(i, 2, 90){
    L[i] = L[i-1]+L[i-2];
  }

  cout << L[N] << "\n";

  return 0;
}

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

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = 0; c = getchar(); }
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 1100;
const int INF = 1e9 + 7;
int n;
int p[MAXN], x[MAXN];
int f[MAXN][5100];

int main() {
	read(n);
	rep(i, 2, n) {
		read(p[i]);
	}
	rep(i, 1, n) read(x[i]);
	for (int i = n; i > 0; --i) {
		int t = INF;
		rep(j, 0, x[i]) {
			t = min(t, f[i][j]);
		}
		if (t >= INF) { printf("IMPOSSIBLE\n"); return 0; }
		int pa = p[i];
		for (int j = x[pa]; j >= 0; --j) {
			int fx = INF;
			if (j >= t) fx = min(fx, f[pa][j - t] + x[i]);
			if (j >= x[i]) fx = min(fx, f[pa][j - x[i]] + t);
			f[pa][j] = fx;
		}
	}
	printf("POSSIBLE\n");
	return 0;
}


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

using namespace std;

int main()
{
    long long n;
    cin>>n;
    vector<tuple<long long,long long,char,long long,string>> a;
    for(long long i=0;i<n;i++)
    {
        long long v,w,d;
        char t;
        string s;
        cin>>v>>w>>t>>d>>s;
        a.emplace_back(v,w,t,d,s);
    }
    sort(a.begin(),a.end());
    for(long long i=0;i<n;i++)
    {
        long long v,w,d;
        char t;
        string s;
        tie(v,w,t,d,s)=a[i];
        cout<<v<<" "<<w<<" "<<t<<" "<<d<<" "<<s<<endl;
    }
  return 0;
}



Measured memory_bytes: 13060
n=int(input())
dp=[1000000]*(n+1)
dp[0]=0
for i in range(1,n+1):
    m=100000
    p=6
    q=9
    while p<=i:
        if m>dp[i-p]+1:
            m=dp[i-p]+1
        p*=6
    while q<=i:
        if m>dp[i-q]+1:
            m=dp[i-q]+1
        q*=9
    dp[i]=min(dp[i-1]+1,m)
print(dp[n])


Measured memory_bytes: 3828
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	for (int i = 0; i < 2; i++) {
		cin >> H >> W >> L >> R;
		N = max(N, H + W + L + R);
	}
	cout << N << endl;
	
	return 0;
}



Measured memory_bytes: 3148
#include <stdio.h>

int main() {
    int n, max, sec, d, maxIndex;
    scanf("%d", &n);
    max = sec = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &d);
        if (d >= max) {
            sec = max;
            max = d;
            maxIndex = i;
        } else if (d >= sec) {
            sec = d;
        }
    }
    for (int i = 0; i < n; i++) {
        if (i == maxIndex) printf("%d\n", sec);
        else printf("%d\n", max);
    }
}

Measured memory_bytes: 1536
while(True):
    try: s = float(input())
    except: break
    if 91.0<s : print("heavy"); continue
    if 81.0<s : print("light heavy"); continue
    if 75.0<s : print("middle"); continue
    if 69.0<s : print("light middle"); continue
    if 64.0<s : print("welter"); continue
    if 60.0<s : print("light welter"); continue
    if 57.0<s : print("light"); continue
    if 54.0<s : print("feather"); continue
    if 51.0<s : print("bantam"); continue
    if 48.0<s : print("fly"); continue
    print("light fly")


Measured memory_bytes: 5576
//AtCoder-agc001E
#include <cstdio>
#include <cctype>
#define rg register

inline void read(int&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

inline void cmax(int&A,int B){A=A>B?A:B;}
const int inv2=500000004,p=1e9+7;
const int bs=2001,N=8007,T=201000;
int fac[N],inv[N],a[T],b[T];
int f[bs+bs+2][bs+bs+2];
int n,ans,ma,mb;

inline int qm(int x){return x<0?x+p:x<p?x:x-p;}
inline int c(int nn,int mm){return 1ll*fac[nn]*inv[mm]%p*inv[nn-mm]%p;}

void init();void work();
int main(){init();work();return 0;}

void work(){
	for(rg int i=bs-ma;i<=bs+ma;++i)
	for(rg int j=bs-mb;j<=bs+mb;++j)
		f[i][j]=qm(f[i][j]+qm(f[i-1][j]+f[i][j-1]));
	for(rg int i=1;i<=n;++i){
		ans=qm(ans+f[a[i]+bs][b[i]+bs]);
		ans=qm(ans-c(a[i]+a[i]+b[i]+b[i],a[i]+a[i]));
	}
	printf("%lld\n",1ll*ans*inv2%p);
}

void init(){
	read(n);
	for(rg int i=1;i<=n;++i){
		read(a[i]),cmax(ma,a[i]);
		read(b[i]),cmax(mb,b[i]);
		++f[bs-a[i]][bs-b[i]];
	}
	fac[0]=inv[0]=1;
	for(rg int i=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=923470334;
	for(rg int i=N-2;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%p;
}

Measured memory_bytes: 64384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int cnt = 0;
            for (int a = 0; a < 10; a++) {
                for (int b = 0; b < 10; b++) {
                    for (int c = 0; c < 10; c++) {
                        for (int d = 0; d < 10; d++) {
                            if (a + b + c + d == n) {
                                cnt++;
                            }
                        }
                    }
                }
            }
            System.out.println(cnt);
        }
    }
}

Measured memory_bytes: 26344
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    vector<ll> A(N,0);
    rep(i,N) cin>>A[i];
    
    ll l=0,r=0;
    ll tmp_sum=A[0],tmp_xor=A[0];
    while(1){
        if(r==N-1){
            ans+=((r-l+2)*(r-l+1))/2;
            cout<<ans<<endl;
            return 0;
        }
        
        while(tmp_sum+A[r+1] <= (tmp_xor^A[r+1])){
            tmp_sum+=A[r+1];
            tmp_xor^=A[r+1];
            r++;
            if(r==N-1){
                ans+=((r-l+2)*(r-l+1))/2;
                cout<<ans<<endl;
                return 0;
            }
        }
        ans+=(r-l+1);
        
        tmp_sum-=A[l];
        tmp_xor^=A[l];
        l++;
        if(chmax(r,l)){
            tmp_sum+=A[r];
            tmp_xor^=A[r];
        }
    }
    cout<<ans<<endl;
}



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

int main(){
    int N;
    cin >> N;
    int n;
    n = N;
    int S;
    while (n != 0){
        S += n % 10;
        n /= 10;
    }
    if (N % S == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
long long gcd(long long a, long long b);
long long clk[100];
int N;
int main(void){
    long long head,next;
    std::cin>>N;
    for(int i=0;i<100;i++){
        clk[i]=-1;
    }
    for(int i=0;i<N;i++){
        std::cin>>clk[i];
    }
    for(int i=0;i<N-1;i++){
        head=clk[i];
        next=clk[i+1];
        if(head>next){
            clk[i+1]=head/gcd(head,next)*next;
        }else{
            clk[i+1]=head/gcd(next,head)*next;
        }
    }
    std::cout<<clk[N-1]<<std::endl;
    return 0;
}


long long gcd(long long a,long long b){
    long long rem;
    while(1){
        rem=a%b;
        a=b;
        b=rem;
        if(b==0){
            break;
        }
    }
    return a;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	public int pasta() {
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			int input = sc.nextInt();
			if(i == 0 || ans > input) ans = input;
		}
		return ans;
	}
	public int juice() {
		int ans = 0;
		for(int i = 0; i < 2; i++) {
			int input = sc.nextInt();
			if(i == 0 || ans > input) ans = input;
		}
		return ans;
	}
	public void set() {
		int p = pasta();
		int j = juice();
		int ans = p+j-50;
		System.out.println(ans);
	}
	public static void main(String[] args) {
		new Main().set();
	}

}

Measured memory_bytes: 17164