akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 300005;

int n;
int arr[N];
map <int, long long> frn;
map <int, long long> bck;

void rig(int n) {
  multiset <long long> ms;
  long long sum = 0;
  for (int i = 0; i < 3 * n; i++) {
    if (ms.size() < n) {
      ms.insert(arr[i]);
      sum += arr[i];
    } else {
      if (arr[i] > *ms.begin()) {
        sum -= *ms.begin();
        sum += arr[i];
        ms.erase(ms.begin());
        ms.insert(arr[i]);
      }
    }
    if (ms.size() < n) {
      frn[i] = -1;
    } else {
      frn[i] = sum;
    }
  }
}

void lef(int n) {
  multiset <long long> ms;
  long long sum = 0;
  for (int i = 3 * n - 1; i >= 0; i--) {
    if (ms.size() < n) {
      ms.insert(arr[i]);
      sum += arr[i];
    } else {
      if (arr[i] < *(--ms.end())) {
        sum -= *(--ms.end());
        sum += arr[i];
        ms.erase(--ms.end());
        ms.insert(arr[i]);
      }
    }
    if (ms.size() < n) {
      bck[i] = -1;
    } else {
      bck[i] = sum;
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", &arr[i]);
  }
  rig(n);
  lef(n);
  long long ans = -2e18;
  for (int i = 1; i < 3 * n - 1; i++) {
    if (frn[i - 1] != -1 && bck[i + 1] != -1) {
      ans = max(ans, frn[i - 1] - bck[i + 1]);
    }
    if (frn[i] != -1 && bck[i + 1] != -1) {
      ans = max(ans, frn[i] - bck[i + 1]);
    }
    if (frn[i - 1] != -1 && bck[i] != -1) {
      ans = max(ans, frn[i - 1] - bck[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

int main() {
    cin >> a >> b >> c >> k;
    if (a >= k) {
        END(k)
    } else if (a + b >= k) {
        END(a)
    } else {
        END(a - (k - (a + b)))
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long double ld;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

vector<int> adj[200010];
int sum[200010];
bool visit[200010];

void solve(){

    int n,q;
    cin >> n >> q;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].emplace_back(b);
        adj[b].emplace_back(a);
    }
    rep(i,n){
        sum[i]=0;
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        sum[p] += x;
    }

    stack<int> st;
    st.push(0);
    rep(i,n){
        visit[i]=false;
    }
    visit[0]=true;
    while(!st.empty()){
        int tmp;
        tmp = st.top();
        st.pop();
        visit[tmp]=true;
        for(auto e: adj[tmp]){
            if(!visit[e]){
                sum[e] += sum[tmp];
                st.push(e);
            }
        }
    }

    rep(i,n){
        cout << sum[i] << " "; 
    }
    cout << endl;

}

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


Measured memory_bytes: 15732
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,s=0;
    cin>>n;
    for(int i=1;i<=n;i++)
	{
        cin>>a>>b;
        s=s+b-a+1;
    }
    cout<<s<<endl;
    return 0;
}

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

#define PQ priority_queue
#define P pair<int,int>
#define CLA(array) memset(array,0,sizeof array)
#define CLINF(array) memset(array,0x3f,sizeof array)
#define CLF(array) memset(array,-1,sizeof array)
#define DB(a) cout << "DEBUG " << a << endl;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100000 + 50;
const int INF = 1 << 30;
LL gcd(LL a,LL b){
    return b==0?a:gcd(b,a%b);
}
LL lcm(LL a,LL b){
    return a/gcd(a,b)*b;
}
int main(){
    LL a,b;
    while(cin>>a>>b){
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VI Centroid(VVI &graph){
    int n = graph.size();
    VI ret, sz(n);
    function<void (int, int)> dfs = [&](int now, int past){
        sz[now] = 1;
        bool is_centroid = true;
        for (int next : graph[now]){
            if (next == past) continue;
            dfs(next, now);
            sz[now] += sz[next];
            if (sz[next] > n / 2) is_centroid = false;
        }
        if (n - sz[now] > n / 2) is_centroid = false;
        if (is_centroid) ret.push_back(now);
    };
    dfs(0, -1);
    return ret;
}

const int N = 100010;
VI e[N];
VL c[N];
ll sz[N];

ll dfs(int now, int past){
    ll ret = 0;
    sz[now] = 1;
    REP(i,e[now].size()){
        int next = e[now][i];
        if (next == past) continue;
        ret += dfs(next, now);
        sz[now] += sz[next];
        ret += 2 * sz[next] * c[now][i];
        // cout << next << " " << sz[next] << " " << c[now][i] << endl;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    VVI graph(n);
    REP(i,n-1){
        int x = in() - 1, y = in() - 1, z = in();
        e[x].push_back(y);
        c[x].push_back(z);
        e[y].push_back(x);
        c[y].push_back(z);
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    VI cs = Centroid(graph);
    ll ans = 0;
    if (cs.size() == 2){
        int c1 = cs[0], c2 = cs[1];
        ans = dfs(c1, c2) + dfs(c2, c1);
        REP(i,e[c1].size()){
            if (e[c1][i] == c2){
                ans += (n - 1) * c[c1][i];
            }
        }
    }else{
        int c1 = cs[0];
        ans = dfs(c1, -1) - *min_element(ALL(c[c1]));
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n, m, d;
	bool a[100][100] = { false };

	cin >> n >> m >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char temp;
			cin >> temp;
			a[i][j] = (temp == '#');
		}
	}

	int cnt = 0;
	for (int i = 0; i < n; i++) {	// 横向き
		for (int j = 0; j + (d - 1) < m; j++) {
			bool suc = true;
			for (int k = j; k < j + d; k++) {
				if (a[i][k]) {	// 機材あり
					suc = false;
					break;
				}
			}
			if (suc) cnt++;
		}
	}

	for (int j = 0; j < m; j++) {	// 縦向き
		for (int i = 0; i + (d - 1) < n; i++) {
			bool suc = true;
			for (int k = i; k < i + d; k++) {
				if (a[k][j]) {	// 機材あり
					suc = false;
					break;
				}
			}
			if (suc)cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	ll a = -1;
	for (a = 0; a < S.size(); a++) {
		if (S[a] == 'A')break;
	}
	ll z = 0;
	for (z = S.size() - 1; z >= 0; z--) {
		if (S[z] == 'Z')break;
	}
	cout << z - a + 1 << "\n";
	return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    ld sum, val, ans ;
    cin >> sum ;
    val = sum / 3 ;
    ans = val * val * val ;
    cout.precision(12) ;
    cout << ans ;
}


Measured memory_bytes: 256
package main

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

func main() {
	Array := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	fmt.Println(Array[readLineInt()[0]-1])
}

/////////////////////////////////////////
func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n, m;
		n = sc.nextInt();
		m = sc.nextInt();
		sc.close();
		
		long ans = 0;
		
		if(m < n) {
			int tmp = m;
			m = n;
			n = tmp;
		}
		
		long tmp = m - n;
		long r = (long)Math.pow(10,  9) + 7;
		
		if(tmp > 1)ans = 0;
		else{
			ans = 1;
			for(int i = 2; i <= n; ++i) {
				ans %= r;
				ans *= i;
			}
			ans %= r;
			long tmp2 = ans;
			if(tmp == 1) {
				tmp2 *= m;
				tmp2 %= r;
				ans = ans * tmp2;
			}
			else {
				ans *= tmp2;
				ans %= r;
				ans *= 2;
			}
			ans %= r;
		}
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 21076
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int N = Integer.parseInt(tokenizer.nextToken());
		int R = Integer.parseInt(tokenizer.nextToken());
		int L = Integer.parseInt(tokenizer.nextToken());
		Pair[] pairs = new Pair[N];
		Pair[] c = new Pair[N];
		TreeSet<Pair> pointSet = new TreeSet<Pair>();
		TreeSet<Pair> timeSet = new TreeSet<Pair>();
		for (int i = 0; i < N; i++) {
			pairs[i] = new Pair(i, 0);
			c[i] = new Pair(i, 0);
		}
		int now = 0;
		int index = 0;

		for (int i = 0; i < R; i++) {
			tokenizer = new StringTokenizer(reader.readLine());
			int d = Integer.parseInt(tokenizer.nextToken()) - 1;
			int t = Integer.parseInt(tokenizer.nextToken());
			int x = Integer.parseInt(tokenizer.nextToken());
			timeSet.remove(c[index]);
			c[index].point += t - now;
			timeSet.add(c[index]);
			pointSet.remove(pairs[d]);
			pairs[d].point += x;
			pointSet.add(pairs[d]);
			index = pointSet.first().id;
			now = t;
		}
		timeSet.remove(c[index]);
		c[index].point += L - now;
		timeSet.add(c[index]);
		System.out.println(timeSet.first().id + 1);

	}

	class Pair implements Comparable<Pair> {
		int id, point;

		public Pair(int id, int point) {
			super();
			this.id = id;
			this.point = point;
		}

		@Override
		public String toString() {
			return "Pair [id=" + id + ", point=" + point + "]";
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + id;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (id != other.id)
				return false;
			return true;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.point == o.point)
				return this.id - o.id;
			return o.point - this.point;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}
}

Measured memory_bytes: 104556
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = n / 3600;
        int m = n % 3600 / 60;
        int s = n % 3600 % 60;
        System.out.println(h + ":" + m + ":" + s);

    }

}


Measured memory_bytes: 26368
#include<bits/stdc++.h>
using namespace std;
const int mx=123456;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ,m,cnt,s[mx],sum,ls,y;
pair<int,int>pa[mx],pa2[mx];
bool boo1[mx],boo2[mx];
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        pa[i].ff=a;
        pa[i].ss=b;
        pa2[i].ff=b;
        pa2[i].ss=a;
        boo1[a]=1;
        boo2[b]=1;
        if(a>s[b]){
            s[b]=a;
        }
    }
    sort(pa,pa+m);
    for(int i=1;i<=100000;i++){
        if(boo2[i]==1 && y==0){
            ls=i-1;
            y=1;
            sum++;
        }
        else if(boo2[i]==1 && y==1){
            if(s[i]>ls){
                sum++;
                ls=i-1;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> values(n + 1);
  values[0] = 1;
  for (int i = 1; i <= n; i++) {
    values[i] = values[i - 1] * i;
  }
  return values;
}

vector<vector<FiniteField>> MakeStirlingNumberSecondTable(int n, int k) {
  vector<vector<FiniteField>> table(n + 1, vector<FiniteField>(k + 1));
  table[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= min(k, i); j++) {
      table[i][j] = table[i - 1][j] * j + table[i - 1][j - 1];
    }
  }
  return table;
};

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

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

  auto s_table = MakeStirlingNumberSecondTable(n, k);
  FiniteField value = 0;
  for (int i = 0; i <= k; i++) value += s_table[n][i];
  cout << value.Value() << endl;
}



Measured memory_bytes: 10664
recs = []
while True:
    rec = [int(s) for s in input().split()]
    if rec == [0, 0]:
        break
    recs.append(rec)

for rec in recs:
    for h in range(rec[0]):
        ws = ''
        for w in range(rec[1]):
            if (h + w) % 2 == 0:
                ws +='#'
            if (h + w) % 2 == 1:
                ws += '.'
        print(ws)
    print()


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	string a;
	cin>>a;
	
	int se[n],sw[n],minv=1000000;
	
	for(int i=0;i<n;i++)
	{
		se[i]=0;
		sw[i]=0;
	}
	
	if(a[0]=='E')
	{
		se[0]=1;
		se[0]=0;
	}
	else
	{
		sw[0]=0;
		sw[0]=1;
	}
	
	for(int i=1;i<n;i++)
	{
		if(a[i]=='E')
		{
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else
		{
			se[i]=se[i-1];
			sw[i]=sw[i-1]+1;
		}
	}
	
	for(int i=0;i<n;i++)
	{
		int sum=0;
		if(i==0)
		{
			sum=se[n-1]-se[0];
		}
		else if(i==n-1)
		{
			sum=sw[n-2];
		}
		else
		sum=sw[i-1]+(se[n-1]-se[i]);
		
		minv=min(minv,sum);
	}
	cout<<minv;
	return 0;
}

Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int K;
double R, L;
double P, E, T;

#define EPS (1e-5)

typedef long long ll;

double solve(int const kcnt, double ll, double rr, double prob) {
  
  if(T+E < ll || rr+E < T) return 0.;
  if(abs(ll-T) <= E && abs(rr-T) <= E) return prob;
  //if(prob*pow(max(1.-P, P), K-kcnt)*pow(2., K) < EPS) return 0.;
  //if(prob*pow(max(1.-P, P), K-kcnt) < EPS) return 0.;
  
  double H = (ll + rr) / 2.;
  
  if(kcnt == K) {
    if(abs(H - T) <= E) {
      return prob;
    }
    else {
      return 0.;
    }
  }
  
  // step 3.
  double ret = 0.;
  if(H <= T) {
    ret += solve(kcnt+1, H, rr, prob*(1.-P));
    ret += solve(kcnt+1, ll, H, prob*P);
  }
  else {
    ret += solve(kcnt+1, ll, H, prob*(1.-P));
    ret += solve(kcnt+1, H, rr, prob*P);
  }
  
  return ret;
}

int main() {
  
  cin >> K >> L >> R;
  cin >> P >> E >> T;
  
  printf("%.7f\n", solve(0, L, R, 1.));
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;

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

  vector<int> a;
  for (ll m = N; m != 0; m /= 2) {
    a.push_back(m % 2);
  }
  reverse((a).begin(), (a).end());

  unordered_map<ll, unordered_map<ll, ModInt>> memo;
  for (int s = 0; s < (int)(4); ++s) for (int x = 0; x < (int)(4); ++x) memo[s][x] = 0;
  for (int a = 0; a < (int)(4); ++a) for (int b = 0; b < (int)(4); ++b) if (a + b < 4) memo[a + b][a ^ b] += ((a & b) == b);
  for (int i = 0; i < (int)(4); ++i) for (int j = 0; j < (int)(4); ++j) if (j > 0) memo[i][j] += memo[i][j - 1];
  for (int j = 0; j < (int)(4); ++j) for (int i = 0; i < (int)(4); ++i) if (i > 0) memo[i][j] += memo[i - 1][j];

  function<ModInt(ll, ll)> rec = [&](ll s, ll x) {
    if (memo[s].find(x) != memo[s].end()) return memo[s][x];

    return memo[s][x] = rec(s / 2, x / 2) + rec((s - 1) / 2, (x - 1) / 2) +
                        rec((s - 2) / 2, x / 2);
  };

  cout << rec(N, N) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  char s[100001];
  scanf("%s", s);
  
  int ans = 0;
  int count[2] = {0, 0};
  for (char *p = s; *p; ++p)
  {
    char c = *p - '0';
    if (count[c ^ 1] != 0)
    {
      ans += 2;
      count[c ^ 1]--;
    }
    else
    {
      count[c]++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 1000000007;
	static ULL f(ULL a, ULL i) {
		if (i == 0) return 1;
		ULL b = f(a, i / 2), c = (i % 2) ? a : 1;
		return b * b % M * c % M;
	}

	void Solve() {
		UL N; cin >> N;
		UL A, B; cin >> A >> B;
		UL q = max(A, B);
		vector<ULL> F(q + 1), I(q + 1), iF(q + 1);
		F[0] = 1; I[1] = 1; iF[0] = 1;
		rep(i, q) { F[i + 1] = F[i] * (N - i) % M; }
		for (UL i = 2; i <= q; i++) { I[i] = M - M / i * I[M % i] % M; }
		rep(i, q) { iF[i + 1] = iF[i] * I[i + 1] % M; }

		ULL ans = f(2, N) - 1;
		ULL a = M - F[A] * iF[A] % M;
		ULL b = M - F[B] * iF[B] % M;
		ans = (ans + a + b) % M;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 4992
n = int(input())
h = [int(i) for i in input().split()]

#dp[i] = そこに辿り着くまでのコスト
#初期条件 dp[0] = 0, dp[1] = |h[1] - h[0]|, dp[2以上] = 10 ** 9 + 7
dp = [10**9+7] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
if n == 2:
    print(dp[1])
else:
    for i in range(2,n):
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i]-h[i-2]))
    print(dp[n-1])


Measured memory_bytes: 52208
H, W = gets.split.map(&:to_i)
graph = Array.new(10)
10.times do |i|
  graph[i] = gets.split.map.with_index do |ns, j|
    [j, ns.to_i]
  end.reject { |_, j| i == j }
end

board = H.times.map { gets.split.map(&:to_i) }
def shortest_path(s, graph)
  d_list = Array.new(graph.size, 1 << 60)
  d_list[s] = 0
  queue = [[s, 0]]
  while !queue.empty?
    v, d = queue.shift
    next if d > d_list[v]
    graph[v].each do |(u, c)|
      if d_list[u] > d_list[v] + c
        d_list[u] = d_list[v] + c
        queue.push([u, d_list[u]])
      end
    end
  end
  d_list
end

memo = Array.new(10)
ans = 0
board.each.with_index do |row, i|
  row.each do |n|
    next if n == -1
    next if n == 1
    memo[n] ||= shortest_path(n, graph)[1]
    ans += memo[n]
  end
end
puts ans


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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n,k;cin>>n>>k;
  vector<int> x(n, 0);
  for (int i=0; i<n; i++) {
    cin >> x[i];
  }
  k--;
  SORT(x);
  int ans=1e9;
  for (int i=0; i<n-k; i++) {
    int tmp;
    if (x[i]>=0) {
      tmp = abs(x[i+k]);
    } else if (x[i+k]<=0) {
      tmp = abs(x[i]);
    } else {
      tmp = min(abs(x[i])*2+abs(x[i+k]), abs(x[i])+abs(x[i+k])*2);
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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


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

	vector<int> c(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		sum += b;


	}

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

	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1] == a[i] + 1) {
			sum += c[a[i]];
		}
	}
	cout << sum << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
ll GCD(ll a,ll b){
	/*最大公約数*/
	ll r,tmp;
	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
    }
    r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main(){
	ll a,b,n;
	cin>>a>>b;
	n=GCD(a,b);
	vector<ll> an;
	//an.push_back(2);
	int m=sqrt(n)+1;
	for(int i=2;i<=m;i++){
		
		if(n%i==0){
			while(n%i==0){
				n/=i;
			}
			an.push_back(i);
		}
		
	}if(n!=1){
		an.push_back(n);
	}
	ll ans=sz(an)+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<int, pii> pipii;

void solve() {
  int k, a, b;
  cin >> k >> a >> b;
  ll ret = k+1;
  ll curr = 1;
  ll left = k;
  if(a - curr <= left) {
    curr = a;
    left -= a-1;
    ll mostInTwo = max(2, b-a);
    curr += mostInTwo * (left/2);
    left %= 2;
    curr += left;
    ret = max(ret, curr);
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
from collections import deque
N = int(input())
xy = [[0,0]]*N
A = [0]*N
for i in range(N):
    a = int(input())
    A[i] = a
    xy[i] = [list(map(int,input().split())) for _ in range(a)]
Max = 0
for i in range(2**N):
    bitlist = deque()
    for j in range(N):
        if ((i >> j) & 1): #2進数表示のj桁目(0桁目から数える)が1かどうか
            bitlist.appendleft(1)
        else:
          	bitlist.appendleft(0)
    bitlist = list(bitlist)
    cc = 0
    for i in range(N):
        c = 0
        if bitlist[i] == 1:
            for k in range(A[i]):
                if xy[i][k][1] == 1:
                    if bitlist[xy[i][k][0]-1] == 0:
                        c = 1
                        break
                else:
                    if bitlist[xy[i][k][0]-1] == 1:
                        c = 1
                        break
        if c == 1:
            cc = 1
            break
    if cc == 0:
        ss = 0
        for jj in bitlist:
            ss += jj
        Max = max(Max,ss)
print(Max)


    



Measured memory_bytes: 46428
a, b = map(int, input().split())
hw = [["." for i in range(100)] for j in range(50)]
wo = [["#" for i in range(100)] for j in range(50)]
hw += wo
k = 0
for i in range(b-1):
	i = i*2 + 1
	if i%100 == 1 and i//100 > 0:
		k += 2
	hw[k][i%100] = "#"
l = 51
for i in range(a-1):
	i = i*2 + 1
	if i%100 == 1 and i//100 > 0:
		l += 2
	hw[l][i%100] = "."
print (100,100)
for i in range(100):
	print ("".join(hw[i]))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int n, k;
double arr[maxn];
double probs[1005];

int main() {

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

  cin >> n >> k;

  double tot = 0.0;
  for (int i = 1; i <= 1000; i++) {
    tot += (double)(i);
    probs[i] = tot/i;
  }

  for (int i = 0; i < n; i++) {
    int p; cin >> p;
    arr[i] = probs[p];
  }

  double cur = 0;
  for (int i = 0; i < k; i++) {
    cur += arr[i];
  }

  double ans = cur;
  for (int i = k; i < n; i++) {
    cur -= arr[i-k];
    cur += arr[i];
    ans = max(ans, cur);
  }

  cout << fixed << setprecision(12) << ans << "\n";


  return 0;
}


Measured memory_bytes: 1792
from math import ceil
N = int(input())
L = [[int(i) for i in input().split()] for _ in range(N)]
T = 1
A = 1
for l in L:
    k = max((T+l[0]-1)//l[0], (A+l[1]-1)//l[1])
    T = k * l[0]
    A = k * l[1]
print(T+A)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1<<20;
int k;
vector<int> v;
vector<pair<int, int> > g[N];
int store[N];

int32_t main()
{
	IOS;
	cin>>k;
	v.push_back(1);
	int cur=1;
	store[1]=1;
	int idx=2;
	int edges=0;
	for(int i=2;cur*2<=k;i++, cur*=2)
	{
		g[v.back()].push_back({i, 0});
		g[v.back()].push_back({i, cur});
		v.push_back(i);
		store[cur*2]=i;
		idx++;
		edges+=2;
	}
	int weight=0;
	idx--;
	int lastnode=0;
	for(int i=19;i>=0;i--)
	{
		if(k&(1<<i))
		{
			lastnode=store[1<<i];
			weight+=1<<i;
			break;
		}
	}
	for(int i=19;i>=0;i--)
	{
		if(k&(1<<i))
		{
			if(lastnode==store[1<<i])
				continue;
			g[store[1<<i]].push_back({lastnode, weight});
			weight+=1<<i;
			edges++;
		}
	}
	cout<<idx<<" "<<edges<<endl;
	for(int i=1;i<=idx;i++)
	{
		for(auto &it:g[i])
			cout<<i<<" "<<it.first<<" "<<it.second<<endl;
	}
	return 0;
}

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

string s;

int main(void)
{
	int sum = 0;

	cin >> s;

	for (char val : s)
		sum += val - '0';

	if (sum % 9 == 0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3700
n,k=map(int,input().split())
ab=[]
for i in range(n):
  a,b=map(int,input().split())
  ab.append([a,b])
ab.sort()
if k<=ab[0][1]:
  print(ab[0][0])
for i in range(n):
  k-=ab[i][1]
  if k<=0:
    print(ab[i][0])
    exit()

Measured memory_bytes: 20104
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(void) {
    io;
    int n;
    cin >> n;
    vector<long long> vec(n);
    rep(i,n) cin >> vec[i];
    bool odd = false;
    int count = 0;
    while (true) {
        int i;
        for (i = 0; i < n; i++) {
            if (vec[i] & 1) {
                odd = true;
                break;
            } else {
                vec[i] >>= 1;
            }
        }
        if (odd == true) {
            break;
        } else {
            count++;
        }

    }
    cout << count << endl;
    return 0;
}


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

ll N;
ll A[100005];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);
  
  ll sum=A[0],last=0;
  
  for(int i=1;i<N;i++){
    if( sum*2LL >= A[i]){
      sum+=A[i];
    }else{
      last=i;
      sum+=A[i];
    }
  }
  cout<<N-last<<endl;
  return 0;
}


Measured memory_bytes: 1024
'''
締切が早いやつからこなしていきたい
BiでソートしてAiまでの累積時間が時刻Biを超えてないかを
チェックしていけば良さそう
Biについてソートするときには当然ながらAiも
これにしたがってソートしたいので、便宜上これらをXiと
まとめる　Satoooh
'''
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X = sorted(X, key = lambda x: x[1])

# a[i]はA[i]まで終わらせるためにかかる累積時間
a = [0] * N
a[0] = X[0][0]
for i in range(1, N):
	a[i] = a[i - 1] + X[i][0]#累積和
for j in range(N):
	if a[j] > X[j][1]:
		print("No")
		exit()#ダメならオシマイ
print("Yes")

Measured memory_bytes: 58260
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL gcd(LL a, LL b){
	if(a<b)return gcd(b,a);
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	LL A,B;
	cin>>A>>B;
	cout<<A*B/gcd(A,B)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

 int main(void) {
 int n;
 scanf("%d", &n);

 switch (n % 10) {
 case 2:
 case 4:
 case 5:
 case 7:
 case 9:
 puts("hon");
 break;
 case 0:
 case 1:
 case 6:
 case 8:
 puts("pon");
 break;
 case 3:

 puts("bon");
 break;
 }

 return 0;
 }

Measured memory_bytes: 1664
N = int(input())
A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

#print(A)
B = sorted(A, key=lambda x: x[1])
#print(sorted(A, key=lambda x: x[1]))

count = 0
limit = 0
for i in range(N):
    count += B[i][0]
    if count <= B[i][1]:
        continue
    else:
        print("No")
        exit()
print("Yes")


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

int gcd(int a, int b) {
    int c = min(a,b); 
    int d = max(a,b);
    if (c == 0)
        return d;
    else
      return gcd(c, d % c);
}

int main() {
  int N;
  int sum = 0;
  cin >> N;
  for (int i = 1; i <= N; i++){
    for (int j = i; j <= N; j++){
      for (int k = j; k <= N; k++){
        if (i == j && j == k)
          sum += gcd(gcd(i, j ), k);
        else if (i == j || j == k)
          sum += 3 * gcd(gcd(i, j), k);
        else
          sum += 6 * gcd(gcd(i, j), k);
        }
      }
    }
  cout << sum;
}


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

int main() 
{
    int D,T,S;
    cin>>D>>T>>S;

    if((S*T)>=D)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

var (
	x int
	y int
	z int
)

func main() {
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&z)

	if x == y && y == z && z == x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

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

    if(X==3 || X==5 || X==7){
        cout << "YES" <<endl;
    } else{
        cout << "NO" <<endl;
    }
    return 0;
}



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


int main(){
string s;
  cin >> s;
  if( s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

ll md = 1000000007;

int main(int, char**)
{
	ll ans = 0;
	ll t1, t2, a1, a2, b1, b2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

	// a1 > b1
	if (a1 < b1) {
		ll tmp = a1;
		a1 = b1;
		b1 = tmp;
		tmp = b2;
		b2 = a2;
		a2 = tmp;
	}

	if ((a1 * t1 + a2 * t2) > (b1 * t1 + b2 * t2)) {
		cout << 0 << endl;
		return 0;
	}

	if ((a1 * t1 + a2 * t2) == (b1 * t1 + b2 * t2)) {
		cout << "infinity" << endl;
		return 0;
	}
	ll x = (b1 * t1 + b2 * t2) - (a1 * t1 + a2 * t2);
	ll y = (a1 * t1) - (b1 * t1);
	ll z = y / x;
	// cerr << "y=" << y << ", x=" << x << ", z=" << z << endl;
	if (y % x == 0)
		cout << (y / x) * 2 << endl;
	else
		cout << 1 + (y / x) * 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int b = stdIn.nextInt();
			int r = stdIn.nextInt();
			int g = stdIn.nextInt();
			int c = stdIn.nextInt();
			int s = stdIn.nextInt();
			int t = stdIn.nextInt();
			if(b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0)
			{
				break;
			}
			int sum = 100;
			sum += 77 * b;
			t -= 6 * b;
			sum += 51 * r;
			t -= 4 * r;
			sum += 4 * g;
			t -= g;
			sum -= c;
			t -= c;
			sum -= s * 3;
			t -= s * 2;
			sum -= 3 * t;
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
N, M = map(int, input().split())
if N == 1 and M == 0:
  print(0)
  quit()

ans = [''] * N
for i in range(M):
  s, c = map(int, input().split())
  if ans[s-1] == '' or ans[s-1] == c:
    ans[s-1] = c
  else:
    print(-1)
    quit()


if ans[0] == '':
  ans[0] = 1
for i in range(1, N):
  if ans[i] == '':
    ans[i] = 0

ans = ans[::-1]
res = 0
digit = 1
for a in ans:
  res += a*digit
  digit *= 10

if len(str(res)) != N:
  print(-1)
else:
  print(res)

Measured memory_bytes: 3064
import std.algorithm, std.conv, std.range, std.stdio, std.string;

const mod = 10 ^^ 9 + 7;
alias mint = FactorRing!mod;

void main()
{
  auto rd = readln.split.to!(int[]), h = rd[0], w = rd[1], a = rd[2], b = rd[3];

  auto hw = h+w;

  auto fact = new mint[](hw);
  fact[0] = 1;
  foreach (i; 1..hw) fact[i] = fact[i-1] * i;

  auto invFact = new mint[](hw);
  invFact[$-1] = fact[$-1].inv;
  foreach_reverse (i; 1..hw) invFact[i-1] = invFact[i] * i;

  auto ans = fact[h-1+w-1] * invFact[h-1] * invFact[w-1];
  foreach (i; 0..b)
    ans -= fact[h-a-1+i] * invFact[h-a-1] * invFact[i] * fact[a-1+w-1-i] * invFact[a-1] * invFact[w-1-i];

  writeln(ans);
}

struct FactorRing(int m, bool pos = false)
{
  version(BigEndian) {
    union { long vl; struct { int vi2; int vi; } }
  } else {
    union { long vl; int vi; }
  }

  @property int toInt() { return vi; }
  alias toInt this;

  this(int v) { vi = v; }
  this(int v, bool runMod) { vi = runMod ? mod(v) : v; }
  this(long v) { vi = mod(v); }

  ref FactorRing!(m, pos) opAssign(int v) { vi = v; return this; }

  pure auto mod(int v) const
  {
    static if (pos) return v % m;
    else return (v % m + m) % m;
  }

  pure auto mod(long v) const
  {
    static if (pos) return cast(int)(v % m);
    else return cast(int)((v % m + m) % m);
  }

  static if (m < int.max / 2) {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vi + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vi - rhs)); }
  } else {
    pure auto opBinary(string op: "+")(int rhs) const { return FactorRing!(m, pos)(mod(vl + rhs)); }
    pure auto opBinary(string op: "-")(int rhs) const { return FactorRing!(m, pos)(mod(vl - rhs)); }
  }
  pure auto opBinary(string op: "*")(int rhs) const { return FactorRing!(m, pos)(mod(vl * rhs)); }

  pure auto opBinary(string op)(FactorRing!(m, pos) rhs) const
    if (op == "+" || op == "-" || op == "*") { return opBinary!op(rhs.vi); }

  static if (m < int.max / 2) {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vi + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vi - rhs); }
  } else {
    auto opOpAssign(string op: "+")(int rhs) { vi = mod(vl + rhs); }
    auto opOpAssign(string op: "-")(int rhs) { vi = mod(vl - rhs); }
  }
  auto opOpAssign(string op: "*")(int rhs) { vi = mod(vl * rhs); }

  auto opOpAssign(string op)(FactorRing!(m, pos) rhs)
    if (op == "+" || op == "-" || op == "*") { return opOpAssign!op(rhs.vi); }

  pure auto inv() const
  {
    int x = vi, a, b;
    exEuclid(x, m, a, b);
    return FactorRing!(m, pos)(mod(a));
  }
}

pure T exEuclid(T)(T a, T b, ref T x, ref T y)
{
  auto g = a;
  x = 1;
  y = 0;
  if (b != 0) {
    g = exEuclid(b, a % b, y, x);
    y -= a / b * x;
  }
  return g;
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

    int r;
    cin >> r;
    cout << fixed << setprecision(20) << (2 *M_PI*r) << endl;
    return 0;
}


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

int main() {
  int N;
  int sum=0;
  cin>>N;
  for(int i=0; i<N; i++){
    int l,r;
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<<sum<<endl;
}








Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $K);
$arr = [];
for ($i = 0; $i < $K; $i++) {
    fscanf(STDIN, "%d", $dummy);
    $A = explode(' ', trim(fgets(STDIN)));
    foreach ($A as $n) {
        $arr[$n] = 1;
    }
}
printf("%d", $N - count($arr));


Measured memory_bytes: 16308
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let _n: usize = it.next().unwrap().parse().unwrap();
    let mut now = std::collections::BTreeMap::new();
    const MOD: u64 = 1_000_000_007;
    now.insert((0, 0, 0), 1u64);
    for s in it {
        let a: usize = s.parse().unwrap();
        let mut next = std::collections::BTreeMap::new();
        for (k, v) in now.iter() {
            let v = *v % MOD;
            if k.0 == a {
                let mut x = k.clone();
                x.0 += 1;
                *next.entry(x).or_insert(0) += v;
            }
            if k.1 == a {
                let mut x = k.clone();
                x.1 += 1;
                *next.entry(x).or_insert(0) += v;
            }
            if k.2 == a {
                let mut x = k.clone();
                x.2 += 1;
                *next.entry(x).or_insert(0) += v;
            }
        }
        now = next;
    }
    let mut ans = 0;
    for v in now.values() {
        ans += *v;
    }
    ans %= MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    for (ll p = 0; p < N; ++p) {
        // p個を正に固定する
        ll ma = D * p - C * (N - p - 1);
        ll diff = ma - (B - A);
        if (0 <= diff && diff <= (D - C) * (N - 1)) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i],B[i] = map(int, input().split())
  
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

P,Q = [0]*10**5,[0]*10**5
P[2]=True
Q[1]=0
for i in range(3,10**5,2):
  P[i] = is_prime(i)
  if P[i]==True and P[(i+1)//2]==True:
    Q[i]=Q[i-2]+1
  else:
    Q[i]=Q[i-2]
    
ans = []
for i in range(N):
  if A[i]==1:
    ans.append(Q[B[i]])
  else:
    ans.append(Q[B[i]]-Q[A[i]-2])

print(*ans,sep='\n')

Measured memory_bytes: 61144
#include<bits/stdc++.h>
using namespace std;
const int N=205;
int n,m,s[N][N],g[N][N][N],f[N][N][N],f1[N][N][N],g1[N][N][N];
char s1[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)scanf("%s",s1[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)s[i][j]=s1[i][j]=='.';
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)s[i][j]+=s[i-1][j];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)s[i][j]+=s[i][j-1];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			for (int k=j;k<=m;k++)
				for (int l=i;l<=n+1;l++)
					if (l==n+1||(s[l][k]-s[i-1][k]-s[l][j-1]+s[i-1][j-1]!=0&&
					s[l][k]-s[i-1][k]-s[l][j-1]+s[i-1][j-1]!=(l-i+1)*(k-j+1))){
						f[i][j][k]=l;
						break;	
					}
	for (int i=1;i<=m;i++)
		for (int j=1;j<=n;j++)
			for (int k=j;k<=n;k++)
				for (int l=i;l<=m+1;l++)
					if (l==m+1||(s[k][l]-s[k][i-1]-s[j-1][l]+s[j-1][i-1]!=0&&
					s[k][l]-s[k][i-1]-s[j-1][l]+s[j-1][i-1]!=(l-i+1)*(k-j+1))){
						g[i][j][k]=l;
						break;
					}
	for (int ans=0;;ans++){
		if (f[1][1][m]==n+1){
			printf("%d\n",ans);
			return 0;
		}
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++)
				for (int k=1;k<=m;k++){
					if (f[i][j][k]==n+1){
						f1[i][j][k]=n+1;
						continue;
					}
					f1[i][j][k]=f[f[i][j][k]][j][k];
					while (f1[i][j][k]<=n&&g[g[j][i][f1[i][j][k]]][i][f1[i][j][k]]>k)f1[i][j][k]++;
				}
		for (int i=1;i<=m;i++)
			for (int j=1;j<=n;j++)
				for (int k=1;k<=n;k++){
					if (g[i][j][k]==m+1){
						g1[i][j][k]=m+1;
						continue;
					}
					g1[i][j][k]=g[g[i][j][k]][j][k];
					while (g1[i][j][k]<=m&&f[f[j][i][g1[i][j][k]]][i][g1[i][j][k]]>k)g1[i][j][k]++;
				}
		for (int i=1;i<=n;i++)
			for (int j=1;j<=m;j++)
				for (int k=j;k<=m;k++)f[i][j][k]=f1[i][j][k];
		for (int i=1;i<=m;i++)
			for (int j=1;j<=n;j++)
				for (int k=j;k<=n;k++)g[i][j][k]=g1[i][j][k];	
	} 
} 

Measured memory_bytes: 129152