akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int D, G, p[11], c[11];
    int res = 1000;
    cin >> D >> G;
    for (int i = 0; i < D; ++i) {
        cin >> p[i] >> c[i];
    }
    for (int m = 0; m < (1 << D); ++m) {
        int _G = 0, _res = 0;
        for (int i = 0; i < D; ++i) {
            if ((1 << i) & m) {
                _G += 100 * (i + 1) * p[i] + c[i];
                _res += p[i];
            }
        }
        int i = D;
        while (_G < G && i > 0) {
            --i;
            if ((1 << i) & m) {
                continue;
            }
            for (int j = 0; j < p[i]; ++j) {
                _G += 100 * (i + 1);
                ++_res;
                if (_G >= G) break;
            }
        }
        if (_G >= G) {
            res = min(res, _res);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    string s;
    cin>>n>>s;
    for (auto &x:s){
        int o = x-'A';
        o+=n;
        o%=26;
        x = 'A'+o;
    }
    cout<<s<<endl;
}

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

int main(){
	int n,x,y,b,p;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x >> y >> b >> p;
		if(b >= 5 && p >= 2) cout << (x * b + y * p) * 4 / 5 << endl;
		if(b >= 5 && p < 2) cout << min(x * b + y * p,(x * b + y * 2) * 4 / 5) << endl;
		if(b < 5 && p >= 2) cout << min(x * b + y * p,(x * 5 + y * p) * 4 / 5) << endl;
		if(b < 5 && p < 2) cout << min(x * b + y * p,(x * 5 + y * 2) * 4 / 5) << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#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 FILL(Itr,n) fill((Itr).begin(),(Itr).end(),n)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;
#define MOD 1000000007

struct Edge {
    int to; int w;
    Edge(int _to, int _w):to(_to),w(_w) {}
};

vector< vector<Edge> > G;
vector< int > dist;
int Root;

template <class T> struct TreeDiameter {
    
    
    TreeDiameter(int size){
        G.resize(size),dist.resize(size,-1);
    }
    
    void add_edge(int a, int b, T cost){
        G[a].push_back(Edge(b,cost));
        G[b].push_back(Edge(a,cost));
        Root = a;
    }
    
    void dfs(int v){
        stack< Edge > sta;
        sta.push(Edge(v,0));
        while(sta.size()!=0){
            Edge et = sta.top(); sta.pop();
            dist[et.to] = et.w;
            for(int i=0;i<G[et.to].size();i++){
                if(dist[G[et.to][i].to]<0){
                    sta.push(Edge(G[et.to][i].to,G[et.to][i].w+et.w));
                }
            }
        }
    }
    
    T getDiameter(){
        dfs(Root);
        int ver = -1;
        T d = -1;
        for(int i=0;i<dist.size();i++){
            if(dist[i]>d)d = dist[ver = i];
            dist[i] = -1;
        }
        dfs(ver);
        T ret = 0;
        for(int i=0;i<dist.size();i++)ret = max(ret,dist[i]);
        return ret;
    }
    
};

int main(){
    
    TreeDiameter<int> inst(100010);
    int n; cin>>n;
    REP(i,n-1){
        int a,b,s;
        cin>>a>>b>>s;
        inst.add_edge(a,b,s);
    }
    
    cout<<inst.getDiameter()<<endl;
    
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long

const unsigned int BIT_FLAG_0 = (1 << 0);  // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1);  // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2);  // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3);  // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4);  // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5);  // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6);  // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7);  // 0000 0000 1000 0000

const double PI = 3.14159265358979323846;

const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};

#define H_MAX 500
#define W_MAX 500
#define INF 1e9 + 7

int main() {
    int N;
    cin >> N;
    int A;
    rep(i, N) {
        cin >> A;
        if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string s;
    cin >> s;
    REP(i, s.size()){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i] == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){

  int n,m,a;
  scanf("%d %d",&n,&m);
  while(n != 0 || m != 0){
    int sc[101]={};
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	scanf("%d",&a);
	if(a == 1){
	  sc[j]++;
	}
      }
    }
    
    int f=0;
    
    for(int i=n;i>=0;i--){
      for(int j=0;j<m;j++){
	if(sc[j] == i){
	  f++;
	  if(f == m){
	    printf("%d\n",j+1);
	  } else {
	    printf("%d ",j+1);
	  }
	}
      }
    }
    scanf("%d %d",&n,&m);
  }
  return (0);
}

Measured memory_bytes: 2700
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	char S[101] = {0};
	int len = 0, i = 0, ans = 0;
	scanf("%s", S);
	len = strlen(S);
	for (i = 0; i < len/2; i++) {
		//printf("s=%c, e=%c\n", S[i], S[len-1-i]);
		if (S[i] != S[len-1-i]) {
			ans++;
		}
	}
	printf("%d\n",ans);
    return 0;
}


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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> b(M);
    for(int i=0;i < M;i++) cin >> b[i];
    int calc,num;
    int ans = 0;
    for(int i=0;i < N;i++){
        calc = 0;
        for(int j=0;j < M;j++){
            cin >> num;
            calc += num * b[j];
        }
        calc += C;
        if(calc > 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

double cr(double x1, double y1, double x2, double y2) {
	return x1*y2-x2*y1;
}

int main()
{
	for(;;) {
		double x[4], y[4];
		if (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
					x, y, x+1, y+1, x+2, y+2, x+3, y+3)==EOF) {
			return 0;
		}
		else {
			double cr1 = cr(x[3]-x[0], y[3]-y[0], x[3]-x[1], y[3]-y[1]);
			double cr2 = cr(x[3]-x[1], y[3]-y[1], x[3]-x[2], y[3]-y[2]);
			double cr3 = cr(x[3]-x[2], y[3]-y[2], x[3]-x[0], y[3]-y[0]);
			if (cr1*cr2>=0 && cr2*cr3>=0 && cr3*cr1>=0) printf("YES\n");
			else printf("NO\n");
		}
	}
}

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

P1 = sum(X) // len(X)
P2 = -(-sum(X) // len(X))
ans1 = 0
ans2 = 0
for i in X:
    ans1 += (i - P1) ** 2
    ans2 += (i - P2) ** 2
print(min(ans1, ans2))


Measured memory_bytes: 3060
N = int(input())
d = {}
last = None
flag = True

for _ in range(N):
    word = input()
    if word in d.keys():
        flag = False
    else:
        d[word] = 1

    if last is not None and last != word[0]:
        flag = False
    else:
        last = word[-1]

if flag:
    print("Yes")    
else:
    print("No")

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

int main(){
	double r;
	double s, l;
	
	cin >> r;
	
	s=M_PI*r*r;
	l=2*M_PI*r;
	
	cout << fixed << s << ' ' << fixed << l << endl;

	return 0;
}

Measured memory_bytes: 1284
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin)

let ans = 0
for (let i = 1; i <= n; i++) {
  let count = 0

  if (i % 2 !== 0) {
    for (let j = 1; j <= i; j++) {
      if (i % j === 0) count++
    }

    if (count === 8) ans++
  }
}

console.log(ans)


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

int main(){
	int n, num, cnt;
	scanf("%d",&n);
	cnt = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d",&num);
		if (num & 1) cnt++;
	}
	if (cnt & 1) printf("NO\n");
	else printf("YES\n");
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
     cin >> a >> b >> n;
     rep(i,n){
       cin >> c >> d;
       if(c < a && a < d)ans = 1;
       else if(a <= c && b >= d)ans = 1;
       else if(c < b && b < d)ans = 1;
     }
     Cout(ans);
     

       
return 0;
}



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

void solve(){
	string s;
	cin>>s;
	long long int sum=0;
	for(long long int i=0;i<s.size();i++)
	{
		sum+=s[i]-'0';
	}
	cout<<(sum%9==0?"Yes\n":"No\n"); 
	
}

int main(){
	solve();
}
	


Measured memory_bytes: 3716
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

void solve(ll y1, ll x1, ll y2, ll x2) {
	ll div = 1;
	rep (i, 29) div *= 3;

	ll ans = abs(y1 - y2) + abs(x1 - x2);
	while (div > 0) {
		ll y11 = y1 / div, x11 = x1 / div, y22 = y2 / div, x22 = x2 / div;
		if (y11 == y22 and y11 % 3 == 1 and abs(x11 - x22) >= 2) {
			// DEBUG(div);
			// DEBUG(pll(y11, x11));
			// DEBUG(pll(y22, x22));
			ll y3 = y1 % div, y4 = y2 % div;
			chmax(ans, abs(x1 - x2) + min(1 + y3 + 1 + y4, div - y3 + div - y4));
		}
		if (x11 == x22 and x11 % 3 == 1 and abs(y11 - y22) >= 2) {
			// DEBUG(div);
			// DEBUG(pll(y11, x11));
			// DEBUG(pll(y22, x22));
			ll x3 = x1 % div, x4 = x2 % div;
			chmax(ans, abs(y1 - y2) + min(1 + x3 + 1 + x4, div - x3 + div - x4));
		}

		div /= 3;
	}
	cout << ans << endl;
}

signed main() {
	fio();
	int q;
	cin >> q;
	while (q--) {
		ll y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		y1--; x1--; y2--; x2--;
		solve(y1, x1, y2, x2);
	}
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    lint a, b, c;
    cin>>a>>b>>c;
    if((b/a)>c) print(c);
    else print(b/a);
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// NextLine reads a line text from stdin, and then returns its string.
func NextLine() string {
	sc.Scan()
	return sc.Text()
}

// NextIntsLine reads a line text, that consists of **ONLY INTEGERS DELIMITED BY SPACES**, from stdin.
// And then returns intergers slice.
func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

func NextStringsLine() []string {
	strs := []string{}
	stringsStr := NextLine()
	tmp := strings.Split(stringsStr, " ")
	for _, s := range tmp {
		strs = append(strs, s)
	}
	return strs
}

// NextRunesLine reads a line text, that consists of **ONLY CHARACTERS ARRANGED CONTINUOUSLY**, from stdin.
// Ant then returns runes slice.
func NextRunesLine() []rune {
	return []rune(NextLine())
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// PowInt is integer version of math.Pow
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

// DeleteElement returns a *NEW* slice, that have the same and minimum length and capacity.
// DeleteElement makes a new slice by using easy slice literal.
func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}
	// appendのみの実装
	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

// Concat returns a *NEW* slice, that have the same and minimum length and capacity.
func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

// sort package (snippets)
//sort.Sort(sort.IntSlice(s))
//sort.Sort(sort.Reverse(sort.IntSlice(s)))
//sort.Sort(sort.Float64Slice(s))
//sort.Sort(sort.StringSlice(s))

// copy function
//a = []int{0, 1, 2}
//b = make([]int, len(a))
//copy(b, a)

/*******************************************************************/

var s string

func main() {
	s = NextLine()
	strs := strings.Split(s, ",")
	fmt.Printf("%s %s %s\n", strs[0], strs[1], strs[2])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mk make_pair
using namespace std;
typedef long long ll;
typedef long double lld;
const ll INF = 1e18;
const ll MOD = 1e9+7;
 
ll fastpowMOD(ll a, ll p,ll MOD);
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; a %= MOD; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
 
ll lcm(ll a,ll b){
	return (a*b)/__gcd(a,b);
}

int main(){
    fastio;
    int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	while(a>0){
      c -= b;
      if(c<=0){
        cout<<"Yes\n";return 0;
      }
      a -= d;
    }
  cout<<"No\n";
}




Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

long long int DP[20001][256];

int main(){
	
	int N, M;
	
	while(true){
		cin >> N >> M;
		if(N == 0){
			break;
		}
		
		int C[20];
		
		for(int i = 0; i < M; i++){
			cin >> C[i];
		}
		
		long long int x[20001];
		
		for(int i = 0; i < N; i++){
			cin >> x[i];
		}
		
		for(int i = 0; i <= N; i++){
			for(int j = 0; j < 256; j++){
				DP[i][j] = 100000000000;
			}
		}
		
		DP[0][128] = 0;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				for(int k = 0; k < 256; k++){
					int index = max(0, min(255, k + C[j]));
					DP[i + 1][index] = min(DP[i + 1][index], DP[i][k] + (x[i] - index) * (x[i] - index));
				}
			}
		}
		
		long long int ans = 100000000000;
		
		for(int i = 0; i < 256; i++){
			ans = min(ans, DP[N][i]);
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 43140
#include <bits/stdc++.h>
using namespace std;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)     array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
/* template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; */

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

struct dsu{
  unordered_map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};


void solve(){
  int n;
  cin>>n;
  int ans = 0;
  for(int i = 1; i<=n; i++){
    int x;
    cin>>x;
    if(i%2 == 1 && x%2 == 1)ans++;
  }
  cout<<ans<<"\n";
}

signed main(){
    fastio();
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
}


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

using namespace std;

int main(){
    int a;
    cin >> a;
    float n[a], temp, t;
    for (int i = 0; i < a; i++)
        cin >> n[i];
    sort(n, n + a);
    int i = 0, j = 2;
    temp = ((n[0] + n[1])/2);
    while(j < a){
        //temp = ((a[i] + a[i + 1])/2);
        temp = (temp + n[j])/2;
        j++;
    }
    cout << temp << endl;
    return 0;
}

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

int main(){
    int m,n,k,max=0,x,y;
    scanf("%d%d",&m,&n);
    for(k=1;k<=n;k++){
        scanf("%d",&x);
        if(x>max) max=x;
    }
    y=m-max;
    x=max;
    if(x<=y+1){
        puts("0");
    }
    else{
        printf("%d",x-y-1);
    }
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
const Int LOG = 20;
const Int MAX = 2e5+10;
Int nx[LOG][MAX]={};
Int sm_nx[LOG][MAX]={};

Int pr[LOG][MAX]={};
Int sm_pr[LOG][MAX]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,k;
  cin>>n>>k;
  auto xs=read(n);
  xs.emplace(xs.begin(),-k);
  xs.emplace_back(Int(xs.back())+k);

  for(Int i=1;i<=n;i++){
    nx[0][i]=lower_bound(xs.begin(),xs.end(),xs[i]+k)-xs.begin();
    pr[0][i]=--upper_bound(xs.begin(),xs.end(),xs[i]-k)-xs.begin();
    sm_nx[0][i]=i;
    sm_pr[0][i]=i+1;
  }

  nx[0][n+1]=n+1;
  pr[0][0]=0;

  for(Int k=0;k+1<LOG;k++){
    for(Int i=0;i<=n+1;i++){
      nx[k+1][i]=nx[k][nx[k][i]];
      pr[k+1][i]=pr[k][pr[k][i]];
      sm_nx[k+1][i]=sm_nx[k][i]+sm_nx[k][nx[k][i]];
      sm_pr[k+1][i]=sm_pr[k][i]+sm_pr[k][pr[k][i]];
    }
  }

  Int q;
  cin>>q;
  for(Int i=0;i<q;i++){
    Int l,r;
    cin>>l>>r;
    // [l, r]
    Int p=l,q=r;
    Int ans=0;
    // cout<<l<<newl;
    // cout<<r<<newl;
    for(Int k=LOG-1;k>=0;k--){
      if(nx[k][p]<=r){
        ans-=sm_nx[k][p];
        p=nx[k][p];
        // cout<<p<<newl;
      }
      if(pr[k][q]>=l){
        ans+=sm_pr[k][q];
        q=pr[k][q];
        // cout<<q<<newl;
      }
    }
    // cout<<":";
    ans-=p;
    ans+=q+1;
    cout<<ans<<newl;
  }

  return 0;
}


Measured memory_bytes: 129800
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);


	char map[110][110];

	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			if (i <= 50)map[i][j] = '#';
			else map[i][j] = '.';
		}
	}

	int a, b;
	cin >> a >> b;
	cout << "100 100" << endl;

	a--;
	b--;

	int i = 2;
	while (a >= 1) {
		for (int j = 2; j <= 98; j += 2) {
			if (a == 0)break;
			else {
				map[i][j] = '.';
				a--;
			}
		}
		i += 2;
	}

	i = 52;
	while (b >= 1) {
		for (int j = 2; j <= 98; j += 2) {
			if (b == 0)break;
			else {
				map[i][j] = '#';
				b--;
			}
		}
		i += 2;
	}

	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			cout << map[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = readline().split()
print(0 if a < b else 10)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  vector<int> cnt(26, 0); // 個数
  vector<int> A(26, -1); // 最後の位置
  vector<int> AA(26, 0); // 間の最大値
  REP(i, N){
    int a = S[i]-'a';
    cnt[a]++;
    AA[a] = max(AA[a], i-A[a]-1);
    A[a] = i;
  }
  int ans = 1e9;
  REP(i, 26){
    if(cnt[i] == 0) continue;
    int res = max(AA[i], N-1-A[i]);
    ans = min(ans, res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void){

	int a, b, tmp;

	do{
		scanf("%d %d", &a, &b);

		if (a == 0 && b == 0){
			break;
		}

		if (a > b){
			tmp = a;
			a = b;
			b = tmp;
		}

		printf("%d %d\n", a, b);
	}while (a != 0 || b != 0);

	return 0;
}

Measured memory_bytes: 600
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] s = new int[H][W];
        for(int i = 0; i<H; i++) {
            String str = sc.next();
            for(int j = 0; j<W; j++) {
                s[i][j] = (str.charAt(j) == '.')?1 : 0;
            }
        }

//        for(int i = 0; i<H; i++) {
//            for(int j = 0; j<W; j++) {
//                System.out.print(s[i][j]);
//            }
//            System.out.println();
//        }
//        System.out.println();

        int[][] a = new int[H][W];
        int[][] b = new int[H][W];

        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                if(s[i][j]==0) continue;
                else if(j==0)a[i][j] = s[i][j];
                else a[i][j] = a[i][j-1] + s[i][j];

            }
        }

//        for(int i = 0; i<H; i++) {
//            for(int j = 0; j<W; j++) {
//                System.out.print(a[i][j]);
//            }
//            System.out.println();
//        }
//        System.out.println();

        for(int i = 0; i<H; i++) {
            for(int j = W-2; j>=0; j--) {
                if(a[i][j]==0) continue;
                if(a[i][j+1]==0) continue;
                a[i][j] = a[i][j+1];
            }
        }

//        for(int i = 0; i<H; i++) {
//            for(int j = 0; j<W; j++) {
//                System.out.print(a[i][j]);
//            }
//            System.out.println();
//        }
//        System.out.println();

        for(int i = 0; i<W; i++) {
            for(int j = 0; j<H; j++) {
                if(s[j][i]==0) continue;
                else if(j==0)b[j][i] = s[j][i];
                else b[j][i] = b[j-1][i] + s[j][i];
            }
        }

//        for(int i = 0; i<H; i++) {
//            for(int j = 0; j<W; j++) {
//                System.out.print(b[i][j]);
//            }
//            System.out.println();
//        }
//        System.out.println();


        for(int i = 0; i<W; i++) {
            for (int j = H - 2; j >= 0; j--) {
                if (b[j][i] == 0) continue;
                if (b[j + 1][i] == 0) continue;
                b[j][i] = b[j + 1][i];
            }
        }

//        for(int i = 0; i<H; i++) {
//            for(int j = 0; j<W; j++) {
//                System.out.print(b[i][j]);
//            }
//            System.out.println();
//        }
//        System.out.println();

        int max = 0;
        for(int i = 0; i<H; i++) {
            for(int j = 0; j<W; j++) {
                max = Math.max(a[i][j]+b[i][j]-1, max);
            }
        }

        System.out.println(max);

    }
}

Measured memory_bytes: 112408
def d_match_matching(N, M, A):
    # num_usedmatch[n]: 数字nを作るのに必要なマッチの本数
    num_usedmatch = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}

    # dp[i]: ちょうどi本のマッチ棒を使って作れる整数の最大値
    dp = [-1] * (N + 1)  # 解説では-∞で初期化しているが、最大値は負にならないので
    dp[0] = 0  # 0本のマッチ棒で作れる整数の桁数は0とする(作れない)
    for i in range(1, N + 1):
        for a in A:
            if i - num_usedmatch[a] >= 0:
                # 数字aは使用できるので、整数の末尾に付け足す
                dp[i] = max(dp[i], dp[i - num_usedmatch[a]] * 10 + a)
    return dp[N]

N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_match_matching(N, M, A))

Measured memory_bytes: 14444
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = i+1;
        }
        Arrays.sort(a, (x, y) -> x[0] - y[0]);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(a[i][1] + " ");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb.toString());
        sc.close();

    }

}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<int> D(N);
    REP(i, N) {
        std::cin >> D[i];
    }

    ll ans = 0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            ans += D[i] * D[j];
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

map<char, int> mp;
void solve() {
    char t; cin >> t; if (t == '#') exit(0);
    array<array<string, 13>, 4> vs; for (int i = 0; i < 4; i++) for (int j = 0; j < 13; j++) cin >> vs[i][j];
    int ns = 0, ew = 0;
    int idx = 0;
    for (int turn = 0; turn < 13; turn++) {
        char c = vs[idx][turn][1];
        vector<ll> s(4);
        for (int i = 0; i < 4; i++) {
            s[i] += mp[vs[i][turn][0]];
            if (vs[i][turn][1] == t) s[i] += INF;
            else if (vs[i][turn][1] == c) s[i] += inf;
        }
        idx = max_element(s.begin(), s.end()) - s.begin();
        if (idx % 2 == 0) ns++;
        else ew++;
    }
    if (ns > ew) printf("NS %d\n", ns - 6);
    else printf("EW %d\n", ew - 6);
}

int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    */
    for (int i = 2; i < 10; i++) mp[(char)('0' + i)] = i;
    mp['T'] = 10;
    mp['J'] = 11;
    mp['Q'] = 12;
    mp['K'] = 13;
    mp['A'] = 14;

	int kkt = 89;
	while (kkt) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);

		int[] va = new int[v];
		List<Integer> klist = new ArrayList<Integer>();

		String line2 = sc.nextLine();
		String[] k = line2.split(" ");
		for (int j = 0; j < k.length; j++) {
			va[j] = Integer.parseInt(k[j]);
			klist.add(va[j]);
		}

		java.util.Collections.reverse(klist);
		int val = 0;
		for (Integer integer : klist) {
			System.out.print(integer);
			if (val != v - 1) {
				System.out.print(" ");
			}
			val++;
		}
		System.out.println("");
	}
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

class UnionFind{
public:
  vector<int> p;		// 親
  vector<int> rank;	// サイズ・各集合の根のみ有効
  UnionFind(int n){
    p.resize(n, -1);
    rank.resize(n, 1);
  }
  int root(int x){
    if(p[x] == -1)return x;
    else return p[x] = root(p[x]); // 深さを 1 にしている
  }
  void unite(int x, int y){
    x = root(x); y = root(y);
    if(x == y)return;
    if(rank[x] > rank[y]) swap(x, y); // rankの小さいものを下につける
    rank[y] += rank[x];
    p[x] = y;
  }
  //xが属すグループのサイズ
  int size(int x){ return rank[root(x)]; }
  bool same(int x, int y){ return (root(x) == root(y)); }
};

void solve()
{
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> p[i];
    p[i]--;
  }

  UnionFind uf(n);
  ll inx, iny;
  for(int i = 0; i < m; ++i)
  {
    cin >> inx >> iny;
    inx--; iny--;
    uf.unite(inx, iny);
  }

  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    if (uf.root(i) == uf.root(p[i])) ans++;
  }
  cout << ans;

  /*
  map<int, vector<int> > mp;
  for(int i = 0; i < n; ++i)
  {
    mp[uf.root(i)].emplace_back(i);
  }

  int ans = 0;
  for(const auto& m : mp)
  {
    vector<int> idxs;
    vector<int> vals;
    for(const auto& v : m.second)
    {
      idxs.emplace_back(v);
      vals.emplace_back(p[v]);
    }
    sort(idxs.begin(), idxs.end());
    sort(vals.begin(), vals.end());
    int ii = 0;
    int iv = 0;
    while(ii < idxs.size() && iv < vals.size())
    {
      if (idxs[ii] == vals[iv])
      {
        ans++;
        ii++;
        iv++;
      }
      else if (idxs[ii] < vals[iv])
      {
        ii++;
      }
      else if (idxs[ii] > vals[iv])
      {
        iv++;
      }
    }
  }
  cout << ans;
  */
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4504
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int y,m,d;
    char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <=4 ? "Heisei" : "TBD") << endl;

    return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	l,r,d = readline() |> split |> parseMap
	x = 0
	k = 0
	while x<=r
		if l<=x<=r
			k += 1
		end
		x+=d
	end
	println(k)
end

main()

Measured memory_bytes: 162728
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b){
        swap(a,b);
    }
    if(b > c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout << a << " ";
    cout << b << " ";
    cout << c << endl;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,M;

void solve(){
    ll cost[16]={};
    for(int i=0;i<N;i++){
        ll d,p;
        cin >> d >> p;
        cost[p] +=d;
    }

    ll ans=0;
    for(int i=10;i>=0;i--){
        if(cost[i] <= M){
            M -= cost[i];
        }else{
            cost[i] -= M;
            ans += i*cost[i];
            M=0;
        }
    }
    cout << ans << endl;
}

int main(){
    while(cin>>N>>M){
        if(N==0 && M==0) break;
        solve();
    }
}

Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#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 MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b;
  cin>>a>>b;
  if(a==1)a+=20;
  if(b==1)b+=20;
  if(a<b)
    cout<<"Bob"<<endl;
  else if(a==b)
    cout<<"Draw"<<endl;
  else
    cout<<"Alice"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    int N,M; cin >> N >> M;
    ll ans = 100*(N-M)+1900*M;
    for (int i = 0; i < M; i++)
    {
        ans *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            String line=s.nextLine();
            for(int i=0;i<26;i++){
                String now="";
				StringBuffer sb = new StringBuffer();
                for(int j=0;j<line.length();j++){
                    if(line.charAt(j)>='a'&&line.charAt(j)<='z'){
                        sb.append((char)('a'+(line.charAt(j)-'a'+i)%26));
                    }else sb.append(line.charAt(j));
                }
				now = sb.toString();
                boolean ok=false;
                for(int j=0;j<now.length()-2;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'&&now.charAt(j+2)=='e')ok=true;
                }
                for(int j=0;j<now.length()-3;j++){
                    if(now.charAt(j)=='t'&&now.charAt(j+1)=='h'){
                        if(now.charAt(j+2)=='i'&&now.charAt(j+3)=='s')ok=true;
                        if(now.charAt(j+2)=='a'&&now.charAt(j+3)=='t')ok=true;
                    }
                }
                if(ok){
                    System.out.println(now);
                    break;
                }
            }
        }
    }
}

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

int main() {
    int N;
    cin >> N;
    int c[N];
    int count = 0;
    rep(i, N) {
        char ch;
        cin >> ch;
        if (ch == 'R') {
            c[i] = 0;
            count++;
        } else {
            c[i] = 1;
        }
    }
    int ans = 0;
    rep(i, N) {
        if (i >= count && c[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    string S;
    cin >> S;
    if(S=="SUN") cout << 7 << endl;
    else if(S=="MON") cout << 6 << endl;
    else if(S=="TUE") cout << 5 << endl;
    else if(S=="WED") cout << 4 << endl;
    else if(S=="THU") cout << 3 << endl;
    else if(S=="FRI") cout << 2 << endl;
    else if(S=="SAT") cout << 1 << endl;
    return 0;
    
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    print((n * (n - 1) // 2 + (m * (m - 1)) // 2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    bool flag = false;
    if(N < 13){
        cout << N << endl;
    }
    else{    
        for (int i = 1; i < N; i++)
        {
            if(floor(i * 1.08) == N){
                cout << i << endl;
                flag = true;
            }
        }
        if(flag == false){
            cout << ":(" << endl;
        }
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    int n=s.size();
    string ans="No";
    for(int i=0;i<n-1;i++){
        if(s[i]=='A'&&s[i+1]=='C')ans="Yes";
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580