akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int N, M, dp[3009][3009][2], mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x-= mod;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=0; i<=N; i++)
    dp[0][i][i == 0] = 1;
for (int i=0; i<M; i++)
    for (int j=0; j<=N; j++)
        for (int k=0; k<2; k++)
            if (dp[i][j][k] > 0)
            {
                int curr = dp[i][j][k];
                if (j > 0) adto (dp[i + 1][j][k | (j == 1)], curr);
                if (j > 0) adto (dp[i + 1][j - 1][k | (j == 1)], curr);
                if (j < N) adto (dp[i + 1][j][k], curr);
                if (j < N) adto (dp[i + 1][j + 1][k], curr);
            }
int ans = 0;
for (int j=0; j<=N; j++)
    ans = add (ans, dp[M][j][1]);
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 2000000000
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, c, d, k;
	cin >> a >> b >> c >> d >> k;
	cout << 60*c+d-60*a-b-k << '\n';
}

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

int main(void){
	int cntS=0,cntT=0;
	string s;
	cin>>s;
	rep(i,(int)s.size()){
		if(s[i]=='S')cntS++;
		else if(cntS==0)cntT++;
		else cntS--;
	}
	cout<<cntS+cntT<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int a[300007];
int main(){
	int n;
	int i,j,k;
	long long int s=0;
	cin>>n;
	for(i=0;i<3*n;i++){
		cin>>a[i];
	}
	sort(a,a+3*n,greater<int>());
	for(i=1;i<2*n;i+=2){
		s+=a[i];
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=[[0]*9 for _ in range(9)]
for i in range(1,n+1):
  s=str(i)
  l=int(s[0])
  r=int(s[len(s)-1])
  if l*r!=0:
    a[l-1][r-1]+=1
x=0
for i in range(9):
  for j in range(9):
    x+=a[i][j]*a[j][i]
print(x)

Measured memory_bytes: 3064
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import math
import itertools
import numpy as np

s = [x for x in range(N + 1)][1:N+1]
strs = [str(s) for s in s]

i = 1
for v in itertools.permutations(strs):
    i = i + 1
    V = [int(v) for v in v]
    if V == P:
        a = i
    if V == Q:
        b = i
print(abs(a - b))


Measured memory_bytes: 12464
#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>
using namespace std;
long long MOD = 1e9 + 7;

int H, W, N;
typedef pair<int, int> pii;
vector<pii> blacks;
map<pii, int> allpoints;
vector<int> ans;

int main() {
	cin >> H >> W >> N;
	blacks.resize(N);
	for (int n = 0; n < N; n++) {
		int x, y;
		cin >> y >> x;
		blacks[n].first = x;
		blacks[n].second = y;
		for (int x0 = max(x - 1, 1); x0 <= min(W, x + 1); x0++) {
			for (int y0 = max(y - 1, 1); y0 <= min(H, y + 1); y0++) {
				if (allpoints.find(pii(x0, y0)) == allpoints.end()) {
					allpoints.insert(pair<pii, int>(pii(x0, y0), 0));
				}
			}
		}
	}
	for (auto point : blacks) {
		int x0 = point.first;
		int y0 = point.second;
		for (int x = max(x0 - 1, 1); x <= min(W, x0 + 1); x++) {
			for (int y = max(y0 - 1, 1); y <= min(H, y0 + 1); y++) {
				allpoints[pii(x, y)]++;
			}
		}
	}
	ans.resize(10, 0);
	for (auto val : allpoints) {
		pii p = val.first;
		if (p.first == 1 || p.first == W || p.second == 1 || p.second == H)continue;
		ans[val.second]++;
	}
	long long sum = 0;
	for (int n = 1; n < 10; n++) {
		sum += ans[n];
	}
	cout << (long long)(W - 2) * (long long)(H - 2) - sum << endl;
	for (int n = 1; n < 10; n++) {
		cout << ans[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 57344
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod = 1e9 + 7;

int main() {
  int r;
  cin >> r;
  double ans = M_PI * 2.0 * r;
  printf("%.16f\n", ans);
  return 0;
}


Measured memory_bytes: 3760
D,N=map(int,input().split())
if D == 0:
  count=0
  for i in range(1,1000):
    if i % 100 != 0:
      count += 1
    if count == N:
      print(i)
      exit()
if D == 1:
  count = 0
  for i in range(100,1000000,100):
    if i % 10000 != 0:
      count += 1
    if count == N:
      print(i)
      exit()
if D == 2:
  count = 0
  for i in range(10000,10000*10000,10000):
    if i % 1000000 != 0:
      count += 1
    if count == N:
      print(i)
      exit()

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin>>a>>b>>c;
	puta(c,a,b);
}


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


int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a+b==3)
            cout<<3<<endl;
        else if(a+b==4)
            cout<<2<<endl;
        else
            cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int N,s,d;
    cin >> N;
    while(N--){
	cin >> s >> d;
	int res = 0;
	for(int i = 0 ; i < 31 ; i++){
	    if(s >> i & 1){
		s += 1<<i;
		res++;
	    }
	    if(d >> i & 1){
		d -= 1<<i;
		res++;
	    }
	    if(s == d) break;
	}
	cout << res << endl;
    }
    return 0;
}

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

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
LL X=20;
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int Q(LL n){
    cout<<"? "<<n<<endl;cout.flush();
    DEBUG {
        if(n<=X&&to_string(n)<=to_string(X))return 1;
        if(n>X&&to_string(n)>to_string(X))return 1;
        return 0;
    }
    string ans;cin>>ans;
    return ans=="Y";
}
void ANS(LL n){
    cout<<"! "<<n<<endl;cout.flush();
    DEBUG {
        assert(n==X);
    }    
}
LL calc(LL len){
    if(len==0)return 0;
    return 1+10*calc(len-1);
}
string getrank(LL r,LL len,int bg=0){
    LL x=calc(len);
    while(r>x){
        r-=x;
        bg++;
    }
    if(r==1){
        return to_string(bg);
    }
    else{
        return to_string(bg)+getrank(r-1,len-1);
    }
}
const LL INF=1e9;
int main(){
    
    if(Q(INF-1)==0&&Q(INF)==1){
        ANS(INF);
        return 0;
    }
    LL lb=0;
    LL ub=INF-1;
    while(ub-lb>1){
        const LL mid=(lb+ub)/2;
        LL x=stoi(getrank(mid,9,1));
        if(Q(x*INF))ub=mid;
        else lb=mid;
    }
    if(ub==1){
        LL k=9;
        LL lid=-1;
        REP(i,10){
            if(Q(k)==0)lid=k/9;
            k*=10;
        }
        if(lid==-1)ANS(1);
        else ANS(lid*10);
    }
    else{
        LL M=stoi(getrank(ub,9,1))-1;
        LL k=M;
        REP(i,10){
            if(Q(k)==0){
                k/=M;k/=10;
                break;
            }
            k*=10;
        }
        ANS((M+1)*k);
    }
    return 0;
}


Measured memory_bytes: 596
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc= new Scanner(System.in);
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] values = new int[w];
    for(int i= 0; i < values.length; i++)
    {
      values[i] = i + 1;
    }
    for(int i= 0; i < n; i++)
    {
      String str= sc.next();
      String[] ab = str.split(",");
      int a = Integer.parseInt(ab[0]) - 1;
      int b = Integer.parseInt(ab[1]) - 1;
      int temp = values[a];
      values[a] = values[b];
      values[b] = temp;
    }
    for(int j = 0; j < w; j++)
    {
      System.out.println(values[j]);
    }
  }
}

Measured memory_bytes: 17196
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>
#include <set> 
#include <map> 

using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int f = 0, s = 0;
	if (a == 5) f++;
	else if (a == 7) s++;
	if (b == 5) f++;
	else if (b == 7) s++;
	if (c == 5) f++;
	else if (c == 7) s++;
	if (f == 2 && s == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//一括include
using namespace std;
int main()
{
    string s;
    string t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}


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

int n,k;
string s;

int main(){
    cin >> n >> k;
    cin >> s;
    vector<int>len;
    if(s[0]=='0'){
        len.push_back(0);
    }
    int now = 1;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            now++;
        }
        else{
            len.push_back(now);
            now = 1;
        }
    }
    len.push_back(now);
    if(s[n-1]=='0'){
        len.push_back(0);
    }
    int x = len.size();
    int ans = 0;
    assert(x%2==1);
    if(2*k>=x){
        int temp = 0;
        rep(i,x){
            temp+=len[i];
        }
        cout << temp << endl;
        return 0;
    }
    for(int i=0;i+2*k<x;i+=2){
        int temp = 0;
        rep(j,2*k+1){
            temp+=len[i+j];
        }
        chmax(ans,temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
using namespace boost::math;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    std::string str;
    cin >> str;
    CIN(K);
    set<string> ve;
    for(int a = 1;a < K+1;a++){
        for(int b = 0;b < str.size()-a+1;b++){
         //   cout<<a<<" "<<b<<endl;
            ve.insert(str.substr(b,a));
        }
    }
    V<string> vec;
    FOREACH(a,ve){
        vec.pb(a);
    }
    sort(ALL(vec));
    COUT(vec.at(K-1));
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n;
  string s,ans;
  
  cin>>s;
  n=s.length();

  ans="Yes";
  rep(i,n){
    if(i%2==0){
      if(s[i]=='L')ans="No";
    }
    if(i%2==1){
      if(s[i]=='R')ans="No";
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ll INF = 1e15;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	string str;
	ll n, k;
	vector<vector<VLL>> state;

	ll count(ll index, ll tight, ll remainder) {
		if (state[index][tight][remainder] != -1) {
			return state[index][tight][remainder];
		}
		if (index == n) {
			return remainder == 0;
		}

		ll c = 0, thisdigit = str[index] - '0';
		
		ll countto = tight ? thisdigit : 9;

		REP(i, 0, countto + 1) {
			int thistight = (i == thisdigit) ? tight : 0;
			c += count(index + 1, thistight, (remainder + k - (i % k)) % k);
			c %= mod;
		}
		

		state[index][tight][remainder] = c;
		return c;
	}

	void main() {
		

		cin >> str >> k;
		n = str.length();
		state.resize(n + 5, vector<VLL>(2, VLL(k + 5, -1)));

		ll ans = count(0, 1, 0) - 1; // index, tight, remainder
		if (ans < 0) {
			ans += mod;
		}
		cout << ans << endl; // it counts the 0
		

	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 18816
import java.util.Scanner
object Main extends App { 
  val sc = new Scanner(System.in)
  val N = sc.nextInt()
  val W = sc.nextLong()
  val items = (for (i <- 1 to N) yield ((sc.nextLong, sc.nextLong), sc.nextInt)).toList

  type Item  = (Long, Long) // (value, Weight)
  type Items = List[Item]
  type ItemCount = (Item, Int)

  def valuePerWeight(a:Item, b:Item):Boolean = {
    val (va,wa) = a
    val (vb,wb) = b
    va.toDouble/wa > vb.toDouble/wb
  }

  def mkItems(t:ItemCount):List[Item] = {
    def iter(v:Long, w:Long, m:Int, s:Int, acc:List[Item]):(Int, List[Item]) = {
      if (m > 1) {
        iter(v << 1,w << 1,m >> 1, s << 1, (v, w)::acc)
      } else (s,acc)
    }
    val ((v,w),m) = t
    val (s, items) = iter(v, w, m, 1, Nil)
    val k = m - (s -1)
    if (k > 0) (v*k,w*k)::items else items
  }

// Greedy Knapsack solver. items have to be descending by value per weight.  
  def gks(items:Items, weight:Long):Double = {
    def iter(items:Items, weight:Long, ac:Double):Double = {
      if (items.isEmpty || weight <= 0) ac
      else {
        val (v, w) = items.head
        if (weight < w) ac+v*weight.toDouble/w
        else iter(items.tail, weight -w, ac+v)    
      }
    }
    iter(items, weight, 0f)
  }

  def solver(items:Items, weight:Long):Long = {
    if (items.isEmpty || weight == 0) 0
    else {
      val (v, w)= items.head
      if (weight >= w) {
        val v0 = solver(items.tail, weight-w) + v
        if (v0 < gks(items.tail, weight)) v0 max solver(items.tail, weight)
        else v0
      }
      else solver(items.tail, weight)
    }
  }
  
  val list = (for (e <- items) yield mkItems(e)).flatten.toList.sortWith(valuePerWeight)
  println(solver(list, W))

}


Measured memory_bytes: 47364
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}




//-----CODE------//


void solve(void)
{
  int N;
  cin>>N;
  vector<int> INPUT(N+1);
  for (int i = 0; i < N; i++)
  {
    cin>>INPUT[i]>>INPUT[i+1];
  }
  vector<vector<int> > DP(N+1,vector<int>(N+1,INF));
  for (int i = 0; i <= N; i++)
  {
    DP[i][i] = 0;
  }

  for (int l = 2; l <= N; l++)
  {
    for (int i = 1; i <= N - l +1; i++)
    {
      int j = i + l -1;
      for (int k = i; k <= j-1; k++)
      {
        DP[i][j] = min(DP[i][j],DP[i][k] + DP[k+1][j] +INPUT[j]*INPUT[k]*INPUT[i-1]);
      }
    }
  }
  cout<<DP[1][N]<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}


Measured memory_bytes: 3308
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;

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

vector<bool> seen;

void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

bool permutation(vector<int>& vec, vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {

}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    int K, S;
    cin >> K >> S;
    int ans = 0;

    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (S - i - j <= K && S-i-j >=0) {
                ans++;
                //cout << i << " " << j << " " << S - i - j << endl;
            }
        }
    }

    cout << ans << endl;
}


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

int main(){
    long long A, B, K;
    cin >> A >> B >> K;
    if(A<K){
        if(A+B>=K){
            cout << 0 << " " << A + B - K << endl;
        }else{
            cout << 0 << " " << 0 << endl;
        }
    }else{
        cout << A - K << " " << B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, maxa, temp;
    cin >> a >> b >> c;
    
    maxa = max(a, max(b, c));
    
    temp = maxa*3-a-b-c;
    
    if(temp%2 == 1){
        temp = (maxa+1)*3-a-b-c;
    }
    cout << temp/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
int n, k, s;
struct cube { int x, y, z; };
int cap(cube a, cube b) {
	int da = s - abs(a.x - b.x);
	int db = s - abs(a.y - b.y);
	int dc = s - abs(a.z - b.z);
	if (da <= 0 || db <= 0 || dc <= 0)return 0;
	return 2*(da * db +db* dc+dc*da);
}
struct edge { int to,cost; };
int main() {
	while (cin >> n >> k >> s,n) {
		vector<edge> G[2000]; cube a[2000];
		rep(i, n) {
			int x, y, z; cin >> x >> y >> z;
			a[i] = { x,y,z };
		}
		if (k == 1) {
			cout << 6 * s*s << endl; continue;
		}
		rep(i, n) {
			rep(j, n) {
				if (i == j)continue;
				int dis = cap(a[i], a[j]);
				if (dis > 0) {
					G[i].push_back({ j,dis });
					G[j].push_back({ i,dis });
				}
			}
		}
		int ma = 0;
		rep(sta, n) {
			rep(i, (int)G[sta].size()) {
				vector<int> ad;
				int nf = G[sta][i].to;
				int used[2000] = {}; used[sta] = used[nf] = 1;
				bool f = false;
				if (k == 2)f = true;
				ad.push_back(nf); ad.push_back(sta);
				rep(aaa, k - 2) {
					f = false;
					rep(b, (int)G[nf].size()) {
						if (!used[G[nf][b].to]) {
							f = true;
							used[G[nf][b].to] = 1;
							nf = G[nf][b].to; 
							ad.push_back(nf);
							break;
						}
					}
				}
				if (!f)continue;
				int sum = 0;
				int len = ad.size();
				rep(i, len) {
					rep(j, len) {
						if (i < j) {
							sum += cap(a[ad[i]], a[ad[j]]);
						}
					}
				}
				ma = max(ma, sum);
			}
		}
		if (ma == 0) {
			cout << -1 << endl;
		}
		else {
			cout << 6 * s*s*k - ma << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3248
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Maximum Difference
            int n = int.Parse(Console.ReadLine());
            var a = ReadLine();

            int maxDiff = a.Max() - a.Min();
            Console.WriteLine(maxDiff);                     
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;

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

		String nico = sc.nextLine();
		
		int i = nico.length() - 2;

		
		System.out.println("" + nico.charAt(0) + i + nico.charAt(nico.length() - 1));
	}
}

Measured memory_bytes: 21716
import math

n = int(input())

prev = list(map(int, input().split()))
max_disA = -1
max_disB = -1
min_timeA = 10**9
min_timeB = 10**9

for _ in range(n-1):
    curr = list(map(int, input().split()))
    if prev[1] != curr[1] and prev[2] == curr[2]:
        dis = math.sqrt((prev[3] - curr[3])**2 + (prev[4] - curr[4])**2)
        if max_disA < dis and prev[2] == 0:
            max_disA = dis
            min_timeA = curr[0] - prev[0]
        elif max_disB < dis and prev[2] == 1:
            max_disB = dis
            min_timeB = curr[0] - prev[0]
        elif dis == max_disA and prev[2] == 0 and min_timeA > curr[0] - prev[0]:
            max_disA = dis
            min_timeA = curr[0] - prev[0]
        elif dis == max_disB and prev[2] == 1 and min_timeB > curr[0] - prev[0]:
            max_disB = dis
            min_timeB = curr[0] - prev[0]
    prev = curr

if max_disA == -1:
    print(-1, -1)
else:
    print(max_disA, min_timeA / 60)

if max_disB == -1:
    print(-1, -1)
else:
    print(max_disB, min_timeB / 60)


Measured memory_bytes: 5684
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#include<bits/stdc++.h>


using namespace std;
int main() {

	map<char, int> sal{
		{'a',0},{'b',0},{'c',0}
	};
	char c;
	lp(i, 3) {
		cin >> c;
		sal[c]++;
		if (sal[c] != 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[Q];
    long[] B = new long[Q];
    for (int i = 0; i < Q; i++) {
      A[i] = Integer.parseInt(sc.next());
      B[i] = Long.parseLong(sc.next());
    }
    TreeSet<Range> ranges = new TreeSet<>();
    ranges.add(new Range(0, 0));
    ranges.add(new Range(N, -1));
    for (int i = 0; i < Q; i++) {
      Range cur = ranges.lower(new Range(A[i], 0));
      Range next = ranges.higher(cur);
      if (A[i] != next.start) {
        next = new Range(A[i], cur.count);
        ranges.add(next);
      }
      while (true) {
        Range prev = ranges.lower(cur);
        int len = next.start - cur.start;
        if (prev == null || (prev.count - cur.count - 1) * len >= B[i]) {
          cur.count += B[i] / len;
          if (B[i] % len != 0) {
            ranges.add(new Range(cur.start + (int)(B[i] % len), cur.count));
            cur.count++;
          }
          break;
        } else if ((prev.count - cur.count) * len >= B[i]) {
          if (B[i] % len != 0) {
            cur.start += B[i] % len;
            cur.count += B[i] / len;
          } else {
            ranges.remove(cur);
          }
          break;
        } else {
          B[i] -= (prev.count - cur.count) * len;
          ranges.remove(cur);
          cur = prev;
        }
      }
    }
    StringBuilder sb = new StringBuilder();
    ArrayList<Range> rangeList = new ArrayList<>(ranges);
    for (int i = 0; i < rangeList.size() - 1; i++) {
      for (int j = 0; j < rangeList.get(i + 1).start - rangeList.get(i).start; j++) {
        sb.append(rangeList.get(i).count + "\n");
      }
    }
    System.out.print(sb);
  }

  static class Range implements Comparable<Range> {
    int start;
    long count;

    public Range(int start, long count) {
      this.start = start;
      this.count = count;
    }

    @Override
    public int compareTo(Range o) {
      return Integer.compare(this.start, o.start);
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Range range = (Range) o;
      return start == range.start;
    }

    @Override
    public int hashCode() {
      return start;
    }

    @Override
    public String toString() {
      return "Range{" +
          "start=" + start +
          ", count=" + count +
          '}';
    }
  }
}


Measured memory_bytes: 52468
function main(input) {
    const args = input.split('\n');

    var N = parseInt(args[0], 10);
    var s = args[1];

     var red = 0;
     var blue = 0;

     for(var i = 0; i < N; i++) {
        hat = s.charAt(i);
        if(hat === 'R') {
            red++;
        } else {
            blue++
        }
     }

     if(blue < red) {
         console.log('Yes');
     } else {
         console.log('No');
     }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main()
{
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = [int(i) for i in STR()]
l = len(s)
ans = 0
for i in range(2 ** (l - 1)):
    tmp = 0
    for j in range(l):
        tmp *= 10
        tmp += s[j]
        if i >> j & 1:
            ans += tmp
            tmp = 0
    ans += tmp
print(ans)


Measured memory_bytes: 61676
#include<stdio.h>
int main(void){
  int x, y, r;

  scanf("%d %d", &x, &y);

  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

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



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

int main() {
  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n){
    cin>>a[i];
    sum += a[i];
  }
  sum--;
  sum /= (4*m);
  ll count = 0;
  rep(i,n){
    if(a[i]>sum) count++;
  }
  if(count>=m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}



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

int main(void)
{
  char a[12],s[4],d[8];
  scanf("%s",a);
  for(int i=0;i<4;i++){
    s[i]=a[i];
  }
  for(int j=0;j<8;j++){
    d[j]=a[j+4];
  }
  printf("%s %s\n",s,d);
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  if(s[0] != 'A') cout << "WA" << endl;
  else {
    int cnt = 0;
  	for(int i = 2; i+1 < s.size(); i++) cnt += s[i] == 'C';
    if(cnt != 1) cout << "WA" << endl;
    else {
    	bool bad = false;
     	for(int i = 0; i < s.size(); i++) if(s[i] != 'A' && s[i] != 'C'){
        	if(isupper(s[i])){
              cout << "WA" << endl;
              return 0;
            }
        }
      	cout << "AC" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){
	int a,b,c;
	int d[3];
		
	scanf("%d %d %d",&d[0],&d[1],&d[2]);
	
	
		if(d[0] > d[1]){
			a = d[1];
			d[1] = d[0];
			d[0] = a;
		}
		if(d[1] > d[2]){
			b = d[2];
			d[2] = d[1];
			d[1] = b;
		}if(d[0]>d[1]){
			c = d[1];
			d[1] = d[0];
			d[0]=c;
		}
			
		printf("%d %d% d\n",d[0],d[1],d[2]);
	//juge(x,d,e);


return 0;
}


	

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    set<int> st;
    st.insert(n);
    st.insert(n-1);
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    for(int j=2;j<sqrt(n+1000);j++){
        int x=n;
        while(true){
            if(x%j==0)x/=j;
            else x-=x/j*j;
            if(x<j)break;
        }
        if(x==1){
            st.insert(j);
            if((n-1)%j==0){
                int x=(n-1)/j;
                if(x!=1)st.insert(x);
            }
        }
    }
    cout<<st.size()<<endl;
}

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

int main() {
    double a, b, c;
    cin >> a >> b >> c;

    double rad = acos(-1) * c / 180.0;

    double S = a * b * sin(rad) / 2;
    double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
    double h = S * 2.0 / a;

    printf("%f\n%f\n%f\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int r0, w0, c, r;
int main() {
	while (cin >> r0 >> w0 >> c >> r) {
		if (r0 == 0)return 0;
		int cont = 0;
		while (1) {
			if (r0 + cont*r >= c*w0) {
				cout << cont << endl;
				break;
			}
			cont++;
		}
	}
}

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    long long int n, m;
    scanf("%lld%lld",&n, &m);
    if(n==1 && m==1){printf("1"); return 0;}
    else if(n==1) {printf("%lld", m-2); return 0;}
    else if(m==1) {printf("%lld",n-2); return 0;}
    printf("%lld", (n-2)*(m-2));
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll a[6];
int main(){FAST;
for(ll i=0;i<5;i++){
	cin>>a[i];
}
sort(a,a+5);
ll ans=10000000000;
do{
		ll t=0;
	for(ll i=0;i<5;i++){
		if(t%10==0){
			t+=a[i];
		}
		else{
			t=(t/10+1)*10;
			t+=a[i];
		}
	}
	ans=min(ans,t);
}while(next_permutation(a,a+5));
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, i, x, y, h, w, sum;
	
	while (1){
		sum = 0;
				
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d %d %d %d", &x, &y, &h, &w);
			
			if (x + y + h > 160 || w > 25){
				sum += 0;
			}
			else if (x + y + h > 140 || w > 20){
				sum += 1600;
			}
			else if (x + y + h > 120 || w > 15){
				sum += 1400;
			}
			else if (x + y + h > 100 || w > 10){
				sum += 1200;
			}
			else if (x + y + h > 80 || w > 5){
				sum += 1000;
			}
			else if (x + y + h > 60 || w > 2){
				sum += 800;
			}
			else {
				sum += 600;
			}
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
void main(){
	int s, w;
	scanf("%d %d", &s, &w);
	if( s<=w )writeln("unsafe");
	else writeln("safe");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2532
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val a = sc.nextLong()
    val v = sc.nextLong()
    val b = sc.nextLong()
    val w = sc.nextLong()
    val t = sc.nextLong()
    if (v < w) {
      println("NO")
    } else {
      val l = Math.abs(b - a)
      val d = t * (v - w)
      if (l > d) {
        println("NO")
      } else {
        println("YES")
      }
    }
  }

}


Measured memory_bytes: 55252
#include<stdio.h>
int main(void)
{
	int N, M, a[100], b[100], score[100] = {0}, target;
	int i,j;
	scanf("%d",&N);
	scanf("%d",&M);

	for (i = 0; i < M; i++)
		scanf("%d",&a[i]);

	for (i = 0; i < M; i++) {
		target = a[i];
		for (j = 0; j < N; j++) {
			scanf("%d", &b[j]);
			if (b[j] == target)score[j]++;
			else score[a[i]-1]++;
		}
	}
	for (i = 0; i < N; i++)printf("%d\n",score[i]);
	return 0;
}

Measured memory_bytes: 596
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

int id = 1;
vector<int> col;
vector<vector<int>> g, ng;

void dfs(int v, vector<int>& t) {
    t.push_back(v);
    col[v] = id;
    for (int u : g[v]) {
        if (!col[u]) {
            dfs(u, t);
        }
    }
}

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    g.resize(n);
    ng.resize(n);
    for (int i = 0; i < m; i++) {
        int from, to;
        cin >> from >> to;
        from--; to--;
        g[from].push_back(to);
        g[to].push_back(from);
    }

    for (int i = 0; i < k; i++) {
        int from, to;
        cin >> from >> to;
        from--; to--;
        ng[from].push_back(to);
        ng[to].push_back(from);
    }
    vector<int> ans(n);
    col.resize(n);
    for (int i = 0; i < n; i++) {
        if (!col[i]) {
            vector<int> t;
            dfs(i, t);
            int cnt = t.size();
            for (int v : t) {
                ans[v] = cnt - g[v].size() - 1;
                for (int u : ng[v]) {
                    if (col[u] == id) ans[v]--;
                }
            }
            id++;
        }
    }
    for (int i : ans) cout << i << " ";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 15740
count = 0
N = int(input())
dic = {x:[] for x in range(N)}
for i in range(3):
    s = input()
    for j in range(N):
        dic[j].append(s[j])
for item in dic.values():
    s = set()
    for i in item:
        s.add(i)
    count+= len(s)-1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define ff first
#define ss second
signed main()
{
    fast
      int n,m;
  cin>>n>>m;
  cout<<(n*(n-1))/2+(m*(m-1))/2;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	dp[0]=0,dp[1]=1;
	for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+1;
		int po=6;
		while(po<=i){
			dp[i]=min(dp[i],dp[i-po]+1);
			po*=6;
		}
		po=9;
		while(po<=i){
			dp[i]=min(dp[i],dp[i-po]+1);
			po*=9;
		}
		//cout<<dp[i]<<" ";
	}
	//cout<<dp[6]<<endl;
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main(){
    
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    //cout<<A<<":"<<B<<":"<<C<<":"<<K<<endl;
    
    bool ans=false;
    
    
    for(int i=0;i<=K;++i){
        for(int j=0;j<=K;++j){
            for(int k=0;k<=K;++k){
                int a=pow(2,i)*A;
                int b=pow(2,j)*B;
                int c=pow(2,k)*C;
                //cout<<"a:"<<a<<"b:"<<b<<"c"<<c<<endl;
                if((i+j+k)<=K){
                    if((a<b)&&(b<c)){
                        
                        //cout<<"A:"<<2*(i+1)*A<<"B:"<<2*(j+1)*B<<"C:"<<2*(k+1)*C<<endl;
                        ans=true;
                        break;
                        
                    }
                }
                
            }
            if(ans)break;
        }
        if(ans)break;
    }
    
    if(ans){
        cout<<"Yes"<<endl;
        
    }else{
        cout<<"No"<<endl;
    }
}






Measured memory_bytes: 4048
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[200100], b[200100];

ll solve() {
    ll res = 0;
    vector<ll> c(n);
    for (int i = 0; i < 30; i++) {
        for (int j = 0; j < n; j++) {
            c[j] = b[j] & ((1LL<<(i+1))-1);
        }
        sort(ALL(c));

        ll cnt = 0;
        for (int j = 0; j < n; j++) {
            ll d = a[j] & ((1LL<<(i+1))-1);
            cnt += (int)(lower_bound(ALL(c), (1LL<<(i+1))-d) - lower_bound(ALL(c), (1LL<<i)-d));
            cnt += (int)(lower_bound(ALL(c), (1LL<<(i+2))-d) - lower_bound(ALL(c), (3LL<<i)-d));
        }
        if (cnt % 2 == 1) {
            res |= (1LL<<i);
        }
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 7960