akhauriyash/Code-Regression huggingface dataset:
console.log((args=>{
  const [[N],...tmp] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const rp = [], bp = [];
  for ( let i = 0; i < N; i++ ) {
    rp.push(tmp[i]);
    bp.push(tmp[N+i]);
  }
  bp.sort(([a],[b])=>a-b);
  let count = 0;
  const test = [];
  for ( let i = 0; i < N; i++ ) {
    const [bx,by] = bp[i];
    let max = [-1,-1];
    for ( let j = 0; j < rp.length; j++ ) {
      const [rx,ry] = rp[j];
      if ( bx < rx ) continue;
      if ( by > ry && ry > max[1] ) max = [j,ry];
    }
    if ( max[1] >= 0 ) {
      rp.splice( max[0], 1 );
      count++;
    }
  }
  return `${count}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 30508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <climits>
#include <functional>

using namespace std;

#define int long long
#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(a) begin(a),end(a)

signed main()
{
	string s; cin >> s;
	int len = s.length();

	rep(i, len - 1) {
		if (s[i] == s[i+1]) {
			cout << i + 1 <<' '<<i + 2<<endl;
			return 0;
		}
	}

	rep(i, len - 2) {
		if (s[i] == s[i+2]) {
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}

	puts("-1 -1");
}


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

char a;
int F[52][52];
int H,W;

bool check(){
    rep(i,H)rep(j,W)if(F[i+1][j+1]==1 && F[i][j+1]==0 && F[i+1][j]==0 && F[i+1][j+2]==0 && F[i+2][j+1]==0)return false;
    return true;
}

int main(void){
    cin >> H >> W;
    rep(i,H){
        rep(j,W){
            cin >> a;
            if(a=='.')F[i+1][j+1]=0;
            else F[i+1][j+1]=1;
        }
    }

    if(check())cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::map<char, int> countup(std::string S) {
  std::map<char, int> cnt;
  for (char c : S) {
    ++cnt[c];
  }
  return cnt;
}

int main() {
  int N; std::cin >> N;
  int ans[26];
  for (int i = 0; i < 26; ++i) ans[i] = INT_MAX;

  for (int n = 0; n < N; ++n) {
    int cnt[26] = {};
    std::string S; std::cin >> S;
    for (char c : S) {
      ++cnt[c - 'a'];
    }

    for (int i = 0; i < 26; ++i) {
      ans[i] = std::min(ans[i], cnt[i]);
    }
  }

  for (int i = 0; i < 26; ++i) {
    char c = 'a' + i;
    for (int k = 0; k < ans[i]; ++k) std::cout << c;
  }
  std::cout << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >> a >> b;
    
    cout << a * b - (a+b-1) << endl;


    return 0;
}

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

typedef long long ll; 
#define sz(a) ((int)(a.size()))

const int mod=1e9+7; 
int mul(int a, int b){
  return (ll)a*b%mod; 
}
void add_self(int &a, int b){
  a+=b; 
  if(a>= mod) a-=mod; 
}
void mul_self(int &a, int b){
  a=(ll)a*b%mod; 
}
void sub_self(int &a, int b){
  a-=b; 
  if(a<0) a+=mod;
}
int exp(int a, int b){
  int ret=1; 
  while(b){
    if(b%2){
      mul_self(ret,a); 
    }
    mul_self(a,a); 
    b/=2; 
  }
  return ret; 
}
//--------------------------------------------------
int n,m; 
string s; 
int dp[5005][5005]; 

int get_num(int n,int m){
  if(n==m ) return 1;
  if(n<m) return 0; 
  if(n==1 && m==0) return 1; 
  if(dp[n][m]!=-1) return dp[n][m]; 
  int ans=0;
  if(m==0) ans=get_num(n-1,0); 
  if(m>0){
    ans=get_num(n-1,m-1);
  }
  add_self(ans,2*get_num(n-1,m+1)%mod); 
  return dp[n][m]=ans; 
}

void solve(){ 
  cin>>n; 
  cin>>s; 
  m=sz(s); 
  for(int i=0;i<=n;i++) s.push_back('*'); 
  memset(dp,-1,sizeof(dp)); 
  cout<<get_num(n,m)<<endl; 
}

int main(){
  clock_t beg=clock(); 
  solve(); 
  clock_t end=clock(); 
  fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
}

Measured memory_bytes: 98304
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int a[22][22];
int b[22];

int main()
{
    int n, m, c;
    cin>>n>>m>>c;
    REP(i,m) cin>>b[i];
    REP(i,n) REP(j,m) cin>>a[i][j];

    int ans = 0;
    REP(i,n) {
        int val = c;
        REP(j,m) {
            val += a[i][j] * b[j];
        }
        if (val > 0)
            ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int turn = int.Parse(Console.ReadLine());
        int TaroPoint = 0;
        int HanakoPoint = 0;

        for (int i=0;i< turn;i++)
        {
            string[] cards = Console.ReadLine().Split(' ');

            char[] Tarocard = cards[0].ToCharArray();
            char[] Hanakocard = cards[1].ToCharArray();

            int judge = 7;

            if (Tarocard.GetLength(0) >= Hanakocard.GetLength(0)) //Taro????????????????????°????????¨???
            {
                 judge = Battle(Tarocard, Hanakocard);
                switch (judge)
                {
                    case -1: HanakoPoint = HanakoPoint + 3; break;
                    case 0: HanakoPoint++; TaroPoint++; break;
                    case 1: TaroPoint = TaroPoint + 3; break;
                }
            }


            if (Hanakocard.GetLength(0) > Tarocard.GetLength(0)) //??±???????????????????????°????????¨???
            {
                judge = Battle(Hanakocard, Tarocard);
                switch(judge)
                {
                    case 1: HanakoPoint = HanakoPoint +3; break;
                    case 0 : HanakoPoint++;TaroPoint++; break;
                    case -1: TaroPoint = TaroPoint + 3; break;
                }
            }

                    
        }

        Console.WriteLine("{0} {1}", TaroPoint,HanakoPoint);

    }

    static int Battle(char[] x,char[] y)  //x??????????????????????????¨??????  x?????????=1,y?????????=-1,????????????=0
    {
        for (int i=0;i < y.GetLength(0);i++)
        {
            if (x[i] > y[i])
                return 1;

            else
            {
                if (x[i] < y[i])
                    return -1;
            }
        }

        if (x.GetLength(0) != y.GetLength(0))
            return 1;
        else
        return 0;
    }
}

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define nyan "(=^･ω･^=)"
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;

struct segtree {
    int tree[4*maxn];

    void build(int at, int L, int R) {
        if(L == R) return void(tree[at] = 0);
        int mid = L + R >> 1;
        build(at<<1, L, mid); build(at<<1|1, mid+1, R);
        tree[at] = tree[at<<1] + tree[at<<1|1];
    }

    void add(int at, int L, int R, int idx) {
        if(L == R) {tree[at]++; return;}
        int mid = L + R >> 1;
        if(idx <= mid) add(at<<1, L, mid, idx);
        else add(at<<1|1, mid+1, R, idx);
        tree[at] = tree[at<<1] + tree[at<<1|1];
    }

    int query(int at, int L, int R, int l, int r) {
        if(L >= l && R <= r) return tree[at];
        if(L > r || R < l) return 0;
        int mid = L + R >> 1;
        return query(at<<1, L, mid, l, r) + query(at<<1|1, mid+1, R, l, r);
    }
} s;

ll a[maxn], pos[maxn];

int s1(int i, int n) {
    int lo = 1, hi = i;

    while(lo <= hi) {
        int mid = lo + hi >> 1;
        int k = s.query(1, 1, n, mid, i);

        if(k >= 1) lo = mid+1;
        else hi = mid-1;
    } return hi;
}

int s2(int i, int n) {
    int lo = 1, hi = i;

    while(lo <= hi) {
        int mid = lo + hi >> 1;
        int k = s.query(1, 1, n, mid, i);

        if(k > 1) lo = mid+1;
        else hi = mid-1;
    } return hi;
}

int s3(int i, int n) {
    int lo = i, hi = n;

    while(lo <= hi) {
        int mid = lo + hi >> 1;
        int k = s.query(1, 1, n, i, mid);

        if(k >= 1) hi = mid-1;
        else lo = mid+1;
    } return lo;
}

int s4(int i, int n) {
    int lo = i, hi = n;

    while(lo <= hi) {
        int mid = lo + hi >> 1;
        int k = s.query(1, 1, n, i, mid);

        if(k > 1) hi = mid-1;
        else lo = mid+1;
    } return lo;
}


int main() {
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i], pos[a[i]] = i;
    s.build(1, 1, n);

    ll res = 0;
    for(ll i = n; i >= 1; i--) {
        ll a, b, x, y;

        a = s1(pos[i], n); x = s3(pos[i], n);
        b = s2(pos[i], n); y = s4(pos[i], n);

        res += i * ((a - b) * (x - pos[i]) + (y - x) * (pos[i] - a));

        s.add(1, 1, n, pos[i]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2816
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    input = args.split("\n");
    const N = parseInt(input[0]);
    var tmp;
    var result = 0;
    
    for(var i=1; i<=N; i++){
        tmp = input[i].split(" ");
        result += (parseInt(tmp[1]) - parseInt(tmp[0]) + 1);
    }

    console.log(result);
}

Measured memory_bytes: 7612
#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<double, 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);
struct edge { int to, cost; };
int V;
vector<edge> G[100000];
int d[100000];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, (int)MOD);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < (int)G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main() {
	cin >> V;
	rep(i, V) {
		int d; cin >> d;
		if (d != 0) {
			G[i].push_back({ i + d,0 });
		}
		else {
			rep1(j, 6) {
				if (i + j < V) {
					G[i].push_back({ i + j,1 });
				}
			}
		}
	}
	dijkstra(0);
	cout << d[V - 1] << endl;
	return 0;
}


Measured memory_bytes: 10588
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

//二分累乗法 xのe乗
ll binpow(ll x, ll e)
{
  ll a = 1, p = x;

  while(e > 0) {
    if(e%2 == 0) {p = (p*p) % MOD; e /= 2;}
    else {a = (a*p) % MOD; e--;}
  }

  return a % MOD;
}

signed main(void)
{
	ll n, a, b;
	cin >> n >> a >> b;

	if(n == 1) {
		if(a == b) cout << 1 << endl;
		else cout << 0 << endl;
	}
	else if(a < b)	cout << b*(n-1)-(a*(n-2)+b) + 1 << endl;
	else if(a == b) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int L;
string s,t;
main()
{
	cin>>L>>s>>t;
	if(s+t>t+s)swap(s,t);
	for(int i=L/s.size();;i--)
	{
		if((L-s.size()*i)%t.size()==0)
		{
			string ans="";
			for(int j=0;j<i;j++)ans+=s;
			while(ans.size()<L)ans+=t;
			cout<<ans<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R, X;
string S, T;

int main(){
  cin >> N;
  ll ans = 0;
  for(ll i=1; i<=N; i++){
    for(ll j = i; j<=N; j += i){
      ans += j;
    }
  }
  
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    long ans = 0, d = 0;
    for (int i = 1; i <= n; i++){
        ans += !(i % k);
        d += (k % 2 == 0 && i % (k / 2) == 0 && i % k != 0);
    }
    cout << ans * ans * ans + d * d * d << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 1000
struct node
{
    long long A,B,C;
}a[MAXN+5];
int n,m;
long long stk[MAXN+5];
long long Xans;
long long slove(int i,int j,int k)
{
    long long sum=0;
    for(int p=1;p<=n;p++)
    {
        stk[p]=a[p].A*i+a[p].B*j+a[p].C*k;
    }
    sort(stk+1,stk+n+1);
    for(int p=n;p>=n-m+1;p--)
    {
        sum+=stk[p];
    }
    return sum;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld%lld",&a[i].A,&a[i].B,&a[i].C);
    }
    for(int i=-1;i<=1;i+=2)
        for(int j=-1;j<=1;j+=2)
            for(int k=-1;k<=1;k+=2)
            {
                Xans=max(Xans,slove(i,j,k));
            }
    printf("%lld",Xans);
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
def gcd(x,y):
  if x==0:
    return y
  else:return gcd(y%x,x)

def f(a,s,d):
  x=s*d//gcd(s,d)
  return a-a//s-a//d+a//x

print(f(b,c,d)-f(a-1,c,d))

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

int main(){
    int Q;
    cin >> Q;
    while(Q--){
        int64_t A, B;
        cin >> A >> B;
        if(A > B) swap(A, B);
        int64_t ok = 0, ng = B;
        while(ng-ok>1){
            int64_t mid = (ng+ok)/2;
            int64_t res = max(A+mid, mid*(A+1));
            if(A <= mid){
                int64_t s = A+1+mid;
                res = max(res, s/2*(s-s/2));
            }
            (res < A*B ? ok : ng) = mid;
        }
        int64_t ans = A-1+ok;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let a = in_vec[0];
    let b = in_vec[1];
    let c = in_vec[2];
    let d = in_vec[3];

    let t_score = c / b + (c % b != 0) as usize;
    let a_score = a / d + (a % d != 0) as usize;

    if t_score <= a_score {
        println!("Yes");
    } else {
        println!("No");
    }
    // loop {
    //     c -= b;
    //     if c <= 0 {
    //         println!("Yes");
    //         break;
    //     }

    //     a -= d;
    //     if a <= 0 {
    //         println!("No");
    //         break;
    //     }
    // }
}


Measured memory_bytes: 2104
import java.util.Scanner;

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

    	Scanner scanner=new Scanner(System.in);

    	String input=scanner.next();

    	String[] data=input.split("");

    	StringBuilder sb =new StringBuilder();

    	int index=0;

    	while(true) {

    		if(index<=input.length()-1) {
    			sb.append(data[index]);
    			index+=2;
    		}else {
    			break;
    		}
    	}



    	String result=sb.toString();

    	System.out.println(result);

    	scanner.close();


    }

}

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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
const ll MOD = 1e9 + 7;
const int MAX = 5000010;
int lastInc[MAX] = {};

int cnt[100010] = {}, cnt1[100010] = {};

main()
{
    int n;
    cin >> n;
    int v[n], c[n];
    for (auto &x : v)
        cin >> x;
    for (auto &x : c)
        cin >> x;

    int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (v[i] > c[i])
            ans += v[i] - c[i];
    }
    cout << ans << endl;
}

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


int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    string str;
    int N;
    int count = 0;
    int ConsecutiveOnes = 0;
    int Max_Ones = 0;
    int ThisNum;
    while(getline(cin, str)){
        stringstream ss;
        ss << str;
        if(count == 0){
            ss >> N;
        }
        else{
            for(int i = 0;i < N;i++){
                ss >> ThisNum;
                if(ThisNum){
                    ConsecutiveOnes++;
                }
                else{
                    ConsecutiveOnes = 0;
                }
                if(ConsecutiveOnes > Max_Ones){
                    Max_Ones = ConsecutiveOnes;
                }
            }
        }
        
        
        count++;
    }
    
    
    
    cout << Max_Ones + 1 << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;

long long func(long long n)
{
	long long tmp = n * (n- 1);
	return tmp / 2;
}

int main()
{
	int N;
	cin >> N;
	vector<string> S(N);

	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
		sort(S[i].begin(), S[i].end());
	}

	sort(S.begin(), S.end());

	string tmp = S[0];
	long long cnt = 1;
	long long ans = 0;
	for (int i = 1; i < N; i++)
	{
		if (S[i - 1] == S[i])
		{
			cnt++;
		}
		else
		{
			if (cnt > 1)
			{
				ans += func(cnt);
			}

			cnt = 1;
		}
	}

	if (cnt > 1)
	{
		ans += func(cnt);
	}

	cout << ans << endl;

	return 0;
 
}

Measured memory_bytes: 7296
#include<stdio.h>
#define INF 10000000
int min(int,int);
void warshall_floyd(void);

int graph[21][21];
int V;

int main(void){
  int i,j,road,a,b,c,d;
  int x1,x2,y1,y2;
  for(i=0;i<21;i++)
    for(j=0;j<21;j++)
      graph[i][j]=INF;
  
  scanf("%d",&V);
  scanf("%d",&road);
  for(i=0;i<road;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    graph[a][b]=c;
    graph[b][a]=d;
  }
  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

  warshall_floyd();

    printf("%d\n",y1-graph[x1][x2]-graph[x2][x1]-y2);

  return 0;
}

int min(int x,int y){
  return (x>y)?y:x;
}

void warshall_floyd(){
  int i,j,k;
  for(k=0;k<=V;k++)
    for(i=0;i<=V;i++)
      for(j=0;j<=V;j++)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }
#define N 1000
const lli mod = 1e9+7;
lli n;
vector<bool> p(N+10, true);

void setPrime(){
    p[0] = p[1] = false;
    for(int i = 2; i*i <= N; i++){
        if(!p[i]) continue;
        for(int j = i+i; j <= N; j+=i){
            p[j] = false;
        }
    }
}

int main(void){
    cin >> n;
    vector<lli> a(N+10);
    setPrime();
    for(int i = 2; i <= N; i++){
        lli x = i;
        if(!p[x]) continue;
        while(x <= n){
            a[i]+=n/x;
            x*=i;
        }
    }
    lli ans = 1;
    for(int i = 2; i <= N; i++){
        ans*=a[i]+1;
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double p = 1.0 / N;
        //cout << setprecision(10) << p << endl;
        int j = i;
        while (j < K) {
            p /= 2;
            j *= 2;
        }
        ans += p;
    }
    cout << setprecision(18) << ans << endl;
}

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

int main() {
    int b1, b2, b3; cin >> b1 >> b2 >> b3;
    if (b1 == 0 && b2 == 0 && b3 == 1)  cout << "Open" << endl;
    else if (b1 == 1 && b2 == 1 && b3 == 0)  cout << "Open" << endl;
    else cout << "Close" << endl;
}


Measured memory_bytes: 3104
/*******************************************c#
*********************************************/
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>
using System.Reflection; //PropertyInfo[], GetProperties[]
using static System.Console; using static NNN.CInput;

namespace Nalgo {
    public class combination {
        public long combs(int n, int r) {
            if (n == r || r == 0) return 1L;
            else return combs(n-1, r-1) + combs(n-1, r);
        }
    }
    
}

namespace NNN {
    
    public class CRun{
        private static class gv{
            public static int N = 0;
            public static int M = 0;
        }
        
        public void build(){
            var input = _inta;
            gv.N = input[0];
            gv.M = input[1];
        }
    
        public void solve(){ StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
            var algo = new Nalgo.combination();
            
            long ans = 0;
            ans += gv.N >= 2 ? algo.combs(gv.N, 2) : 0;
            ans += gv.M >= 2 ? algo.combs(gv.M, 2) : 0;
            WriteLine(ans);
        }
    }

    class Program { 
        static void Main() { 
            var run = new CRun();
            run.build();
            run.solve();
        } 
    }

    public static class CInput{
        public static string _string{get{return Console.ReadLine();}}
        public static string[] _stringa{get{return (Console.ReadLine().Split());}}
        public static int _int{get{return int.Parse(Console.ReadLine());}}
        public static int[] _inta{get{return Console.ReadLine().Split().Select(x=>int.Parse(x)).ToArray();}}
        public static long _long{get{return long.Parse(Console.ReadLine());}}
        public static long[] _longa{get{return Console.ReadLine().Split().Select(x=>long.Parse(x)).ToArray();}}    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(){
  int i,j,k,n,v,A[1000];
  scanf("%d",&n);
  for(i=0;n>i;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;n-1>=i;i++){
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k+1<n) printf(" ");
    }
    printf("\n");
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    } 
  }
  for(j=0;n>j;j++){
    printf("%d",A[j]);
    if(j+1<n) printf(" ");
  } 
  printf("\n");
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  
  int64_t ans = 0;
  int64_t now = 0;
  int l = 0, r = 0;
  while (l < n) {
    while (r < n && (now ^ as[r]) == now + as[r]) {
      now ^= as[r++], ans++;
     }
    now ^= as[l++];
    ans += r - l;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 1400
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a, c = IN()
	ss = [input() for _ in range(a)]
	ss.sort()
	ret = ''.join(ss)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main (){
  string S;
  cin >> S;
  char m;
  m=S[0];
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(m==S[i]){
      continue;
    }
    else{
      ans++;
      m=S[i];
    }
  }
  cout << ans;
}

Measured memory_bytes: 512
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<String>();
    let v = n.chars().map(|c| c as i8 + 48).collect::<Vec<i8>>();
    let mut f = false;
    for i in 0..3 {
        if v[i] == v[i+1] {
            f = true;
        }
    }
    if f {
        println!("Bad");
    } else {
        println!("Good");
    }
}


Measured memory_bytes: 4352
#!/usr/bin/ruby 
#encoding: utf-8

LucasAry = Array.new(100,-1)

def lucas(n)
  if n == 0
    LucasAry[0] = 2
    return LucasAry[0]
  elsif n == 1
    LucasAry[1] = 1
  else
    if LucasAry[n] == -1 then
      LucasAry[n] = lucas(n-1) + lucas(n-2)
      return LucasAry[n]
    else
      return LucasAry[n]
    end
  end
end

n = gets.to_i
puts lucas(n)


Measured memory_bytes: 1788
import java.io.InputStream;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Main S = new Main();

        System.out.println(S.div(n, arr));;
    }

    public int div(int n, int[] arr){
        Arrays.sort(arr);
        if (n==0) return 0;
        if (n%2==1) return 0;
        int middle = n/2 - 1;
        if (arr[middle] == arr[middle+1]){
            return 0;
        }

        return arr[middle+1] - arr[middle];
    }
}


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

int paint(int N,int K){
  if(N==1) return K;
  else return paint(N-1,K)*(K-1);
}

int main(){
  int N,K,a;
  cin>>N>>K;
  cout<<paint(N,K)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long x = sc.nextLong();
    long ans = 0;
    if(a % x == 0) {
      ans = b / x - a / x + 1;
    } else {
      ans = b / x - a / x; 
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cmath>

const static long long INF = 1e13;
int main(void){
    long long n;
    std::cin >> n;
    long long ub = std::sqrt(n);
    long long ans = INF;
    for(int i = 1; i <= ub; i++){
        if(n % i == 0){
            long long tmp = (i - 1) + (n / i - 1);
            ans = std::min(ans, tmp);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 3652
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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


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


int dp[1000][10000];

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) {
		cout << a - 1 << " " << b << endl;
	}
	else
	{
		cout << a << " " << b-1 << endl;
	}




	return 0;
}



Measured memory_bytes: 256
n = int(input())
lis = [[0] * 10 for i in range(10)]
for i in range(1, n+1):
    val = list(str(i))
    lis[int(val[-1])][int(val[0])] += 1
#     print(val[-1],val[0])
#     print(val,lis)
    
ans = 0
for i in range(10):
    for j in range(10):
        ans += lis[i][j] * lis[j][i]

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,i,n,m,a,b,c;
    while(~scanf("%d %d %d",&n,&m,&x))
    {
        if(x>=n&&x<=n+m)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}


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

int main(){
	int N; cin >> N;
	vector<int> t(N), x(N), y(N);
	for(int i = 0; i < N; ++i){
		cin >> t[i] >> x[i] >> y[i];
	}

	int nt = 0, nx = 0, ny = 0;
	int abst = 0, dist = 0;
	for(int i = 0; i < N; ++i){
		abst = t[i] - nt;
		dist = abs(x[i]-nx)+abs(y[i]-ny);
		// cout << i << " " << abst << " " << dist << endl;

		if((abst%2 != dist%2) || abst < dist){
			cout << "No" << endl;
			return 0;
		}
		nt = t[i]; nx = x[i]; ny = y[i];
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int T=stdIn.nextInt();
		A=T/A;
		System.out.println(B*A);
	}
}

Measured memory_bytes: 23892
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define double long double
#define en "\n"
#define no 1e5
#define big 1e7+1
#define fi first
#define se second
#define modulo 1e9+7
#define MP make_pair
#define PB push_back
typedef vector<int> vi;
typedef pair<int,int> vii;

signed main()
{
    night_rider
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);

    int n;
    cin>>n;
    int sum=0;
    for(int i=1 ; i<=n ; i++)
    {
        if(i%15!=0&&i%3!=0&&i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
int main(){
    int N , K ;
    cin >> N >> K ;
    int arr[N] ;
    for( int i = 0 ; i < N ; i++ ) cin >> arr[i] ;
    int dp[N+1] ;
    memset(dp, 0, sizeof(dp)) ;
    dp[1] = abs( arr[1]-arr[0] ) ;
    for( int i = 2 ; i < N ; i++ ){
        dp[i] = abs(arr[i]-arr[i-1]) + dp[i-1] ;
        for( int j = 2 ; j <= K ; j++ ){
            if( i - j < 0 ) break ;
            dp[i] = min( dp[i-j] + abs(arr[i]-arr[i-j]) , dp[i]) ;
        }
    }
    cout << dp[N-1] << "\n" ;
    return 0 ;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

const int MAX_N = 20;

int main(int argc, char const *argv[])
{
    int n, d, x[MAX_N][MAX_N];
    cin >> n >> d;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int sum = 0;
            for (int idx = 0; idx < d; ++idx) {
                sum += pow(x[i][idx]-x[j][idx], 2);
            }
            double sq = sqrt(sum);
            if (sum==((int)sq)*((int)sq)) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [usize; n - 1]);
    let mut b = vec![0; n];
    for ai in a {
        b[ai - 1] += 1;
    }
    for bi in b {
        println!("{}", bi);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 5428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  ll n;
  cin >> n;
  if (n == 0) {
    cout << 0 << endl;
  }
  vector<int> ans(0);
  ll div = 1;
  while (n != 0) {
    if (n % abs(div * -2) != 0) {
      ans.push_back(1);
      n -= div;
    } else {
      ans.push_back(0);
    }
    div *= -2;
  }
  REVERSE(ans);
  EACH(v, ans) {
    cout << v;
  }
  cout << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <sstream>

using namespace std;

using Array = basic_string<pair<char, int>>;
Array a, b, c;

void output(const Array &xs){
    for(auto &x : xs){
        cout << '[' << x.first << ',' << x.second << ']';
    }
};

void input(Array &a) {
    string c; int l;
    while (cin >> c, c[0] != '$') {
        cin >> l;
        a += make_pair(c[0], l);
    }
}

int main(){
    input(a);
    input(b);
    input(c);
    a = make_pair('0', 0) + a + make_pair('0', 0);
    if (b.size() == 1) {
        for (int i = 0; i < a.size(); ++i) {
            if (a[i].first == b[0].first && a[i].second >= b[0].second) {
                a[i].second -= b[0].second;
                a = a.substr(0, i) + c + a.substr(i);
                break;
            }
        }
    } else {
        for (int i = 1; i + b.size() - 2 <= a.size(); ++i) {
            if (b.substr(1, b.size() - 2) == a.substr(i, b.size() - 2)) {
                if (a[i - 1].first == b[0].first && a[i - 1].second >= b[0].second &&
                    a[i + b.size() - 2].first == b.back().first && a[i + b.size() - 2].second >= b.back().second) {
                    // cout << i << endl;
                    a[i - 1].second -= b[0].second;
                    a[i + b.size() - 2].second -= b.back().second;
                    a = a.substr(0, i) + c + a.substr(i + b.size() - 2);
                    break;
                }
            }
        }
    }

    a.erase(remove_if(a.begin(), a.end(), [](pair<char,int> x){ return x.second == 0; }), a.end());
    for (int i = 0; i < a.size(); ++i) {
        int j = i + 1;
        while(j < a.size() && a[i].first == a[j].first){
            a[i].second += a[j].second;
            a.erase(a.begin() + j);
        }
    }
    for (int i = 0; i < a.size(); ++i) {
        cout << a[i].first << ' ' << a[i].second << ' ';
    }
    cout << '$' << endl;
}

Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

int main()
{
  int n; cin >> n;
  int64_t x = 100;
  while(n--)
    x = ceil(x * 1.05);
  cout << x << "000" << endl;

  return 0;
}

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

using namespace std;

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

#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    string s;
    cin >> s;

    sort(s.begin(),s.end());

    if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vll = vector<long long>;
using vpi = vector<pair<int, int>>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)

const char nl = '\n';
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

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

    int h, w; cin >> h >> w;
    vector<string> g(h);
    F0R (i, h) cin >> g[i];

    ll dp[h][w];
    F0R (i, h) F0R (j, w) dp[i][j] = 0;
    dp[0][0] = 1;
    FOR (i, 1, w - 1) if (g[0][i - 1] != '#') dp[0][i] = dp[0][i - 1];
    FOR (i, 1, h - 1) if (g[i - 1][0] != '#') dp[i][0] = dp[i - 1][0];
    FOR (i, 1, h - 1) {
        FOR (j, 1, w - 1) {
            if (g[i - 1][j] != '#') dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            if (g[i][j - 1] != '#') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
        }
    }
    cout << dp[h - 1][w - 1] << endl;

    return 0;
}


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

long long int min(long long int a, long long int b) {
    return a > b? b: a;
}

long long int max(long long int a, long long int b) {
    return a > b? a: b;
}

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    long long int V = 0;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    long long int ans = 0;
    const long long int INF = 1e18L + 5;
    vector<vector<long long int>> mem(n+1, vector<long long int>(V+1, INF));
    for(int i = 0; i <= n; i++) {
        mem[i][0] = 0;
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= V; j++) {
            if(v[i-1] <= j) {
                mem[i][j] = min(mem[i-1][j-v[i-1]] + w[i-1], mem[i-1][j]);
            }
            else {
                mem[i][j] = mem[i-1][j];
            }
        }
    }

    // for(int i = 0; i <= n; i++) {
    //     for(int j = 0; j <= V; j++) {
    //         cout << mem[i][j] <<" ";
    //     }
    //     cout <<endl;
    // }
    for(int i = 0; i <= V; i++) {
        if(mem[n][i] <= W) {
            ans = max(ans, i);
        }
    }
    cout << ans;
    return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t m = sqrt(n);

    vector ans(n, 0L);
    for (auto x : irange(1L, m + 1)) {
        for (auto y : irange(1L, m + 1)) {
            for (auto z : irange(1L, m + 1)) {
                int64_t a = x * x + y * y + z * z + x * y + y * z + z * x;

                if (1 <= a && a <= n) {
                    ++ans[a];
                }
            }
        }
    }

    for (auto i : irange(1L, n + 1)) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
	unsigned int n, a, b;

	cin >> n >> a >> b;

	string str;

	cin >> str;

	int i;

	int qoute = a+b;
	int overseas = 0;
	for(i = 0; i < n && qoute > 0; ++i) {
		
		switch(str[i]) {
			
			case 'a' : 
			{
				cout << "Yes" << endl;
				qoute--;
				break;
			}
			case 'b' : 
			{
				if(overseas < b) {
					cout << "Yes" << endl;
					overseas++;
					qoute--;
					break;
				}
			}
			case 'c' :
			{
				;
			}

			default: cout << "No" << endl; 
		}
	}

	while(i < n)	{
		cout << "No" << endl;
		i++;	
	}
	return 0;
}

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

int main()
{
    int date;

    cin >> date;

    int y,m;
    y = date/100;
    m = date%100;

    if(y>12||y==0)//not mm
    {
        if (m>12 || m == 0)
            cout << "NA"<<endl;
        else
            cout << "YYMM" << endl;

    }
    else
    {
        if (m>12 || m == 0)
            cout << "MMYY"<<endl;
        else
            cout << "AMBIGUOUS" << endl;
    }

    return 0;
}


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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    cin>>N;
    int C[N][N];
    rep(i,N)rep(j,N)cin>>C[i][j];
    ll res=0;
    rep(i,N)rep(j,i)res+=min(C[i][j],C[j][i]);
    cout<<res<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


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

using namespace std;

int A[4], B[4], Sum[4];


void solve() {

	Sum[0] = A[0] * B[0] - A[1] * B[1] - A[2] * B[2] - A[3] * B[3];
	Sum[1] = A[0] * B[1] + A[1] * B[0] + A[2] * B[3] - A[3] * B[2];
	Sum[2] = A[0] * B[2] - A[1] * B[3] + A[2] * B[0] + A[3] * B[1];
	Sum[3] = A[0] * B[3] + A[1] * B[2] - A[2] * B[1] + A[3] * B[0];
	
	cout << Sum[0] << " " << Sum[1] << " " << Sum[2] << " " << Sum[3] << endl;
}

int main() {
	int n;

	while (cin >> n, n) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < 4; ++j) {
				cin >> A[j];
			}
			for (int j = 0; j < 4; ++j) {
				cin >> B[j];
			}
			solve();
		}
		
	}

	return 0;
}



Measured memory_bytes: 3080
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc073_a.cpp
 * time   : Wed Apr 29 00:35:53 2020
 * quest  : A - September 9
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (((n % 10 == 9) || (n / 10 == 9)) ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
s = input()
words_r = ['eraser', 'erase', 'dreamer', 'dream']
for word_r in words_r:
    s = s.replace(word_r, '')
    #コードの意味:
    #s.replace(p,q) :文字列sにpという文字があればそれを先頭から順にqに置換していく
    #sはwords_rに含まれる文字列を''に置換した文字列になる
    #->条件に合うならｓは最終的に''に,そうでないならそれ以外になる
if (len(s) > 0):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    char ch[20];
    int i,l;
    scanf("%s",ch);
    l=strlen(ch);
    int flag=0,num=0;
    for(i=0;i<l;i++)
    {
        if(i==0&&ch[i]!='A')
        {
            flag=1;
            break;
        }
        if(i==1&&ch[i]=='C')
        {
            flag=1;
            break;
        }
        if(i==l-1&&ch[i]=='C')
        {
            flag=1;
            break;
        }
        if(ch[i]=='C')
            num++;
        else if(i!=0&&ch[i]>'A'&&ch[i]<='Z')
        {
            flag=1;
            break;
        }

    }
    if(flag==1||num!=1)
        printf("WA\n");
    else printf("AC\n");
    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

def solve(aaa:String): String={
  val seq = aaa.split(" ").map(_ .toInt)
  (seq.sum - seq.max).toString
}
}


Measured memory_bytes: 27200