akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	double a,b;
	cin>>a>>b;
	int res=0;
	int ans=0;
	for (int i=1;i<=1000;i++){
		res=i*0.08;
		ans=i*0.1;
		if (res==a && ans==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int z = 1; z <= k; z++) {
				ans += gcd(i, gcd(j, z));
			}
		}
	}
	cout << ans << endl;
}


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

int main() {
  int N;
  bool Y_ex = false;
  cin >> N;
  for(int i = 0; i<N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      Y_ex = true;
      break;
    }
  }
  if(Y_ex){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
/*
・K個のろうそくは連続する
・原点からそのK個すべてのろうそくをめぐるときの最短距離は、
　両端の内より原点に近い方-原点＋両端-両端
*/

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  
  vector<int> coordinates(N);
  for(int i = 0; i < N; ++i)
  {
    cin >> coordinates.at(i);
  }
  
  sort(coordinates.begin(), coordinates.end());
  
  // 座標の小さい方から連続したK点の区間を調べていく
  vector<long> times;
  for(int i = 0; i < N - K + 1; ++i)
  {
    int end1, end2;
    long time;
    end1 = coordinates.at(i);
    end2 = coordinates.at(i + K - 1);
    if(abs(end1) > abs(end2))
    {
      time = abs(end2) + (end2 - end1);
    }
    else
    {
      time = abs(end1) + (end2 - end1);
    }
    times.push_back(time);
  }
  sort(times.begin(), times.end());
  
  cout << times.front() << endl;
  
  return 0;
}


Measured memory_bytes: 1276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = Integer.MAX_VALUE;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int v = in.nextInt();
			int e = in.nextInt();
			int[][] w = new int[v][v];
			int len = w.length;
			for (int i = 0; i < len; i++) {
				Arrays.fill(w[i], INF);
			}
			for (int i = 0; i < len; i++) {
				w[i][i] = 0;
			}
			for (int i = 0; i < e; i++) {
				int s = in.nextInt();
				int t = in.nextInt();
				int d = in.nextInt();
				w[s][t] = d;
			}

			warshallFloyd(w);

			StringBuffer sb = new StringBuffer();
			for (int i = 0; i < v; i++) {
				if (w[i][i] < 0) {
					sb = new StringBuffer();
					sb.append("NEGATIVE CYCLE\n");
					break;
				}
				for (int j = 0; j < v; j++) {
					if (j != 0) {
						sb.append(" ");
					}
					if (w[i][j] == INF) {
						sb.append("INF");
					} else {
						sb.append(w[i][j]);
					}
				}
				sb.append("\n");
			}
			out.print(sb.toString());

		}

		void warshallFloyd(int[][] d) {
			int len = d.length;
			for (int i = 0; i < len; i++) {
				for (int j = 0; j < len; j++) {
					if (d[j][i] == INF) continue;
					for (int k = 0; k < len; k++) {
						if (d[i][k] == INF) continue;
						d[j][k] = Math.min(d[j][k], d[j][i] + d[i][k]);
					}
				}
			}
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1


struct edge{
    int from,to,cost;
};

int n,m,rr;
int r[10];
int a,b,c;
int d[202][202] = {{}};

int answer( bool* hit, int from, int leng = 0 ){
    int ans = INF;


    Rep(i,rr+1){
        if( i == rr ){
            return leng;
        }
        if( !hit[i] ) break;
    }

    Rep(i,rr){
        if(hit[i]) continue;
        hit[i] = true;
        ans = min( answer(hit,r[i],leng+d[from][r[i]]) , ans );
        hit[i] = false;
    }

    return ans;
}

int main() {

    Scd3(n,m,rr);
    n++;
    Rep(i,rr) Scd(r[i]);
    Rep(i,202){
        fill(d[i],d[i]+n,INF);
    }
    Rep(i,m){
        Scd3(a,b,c);
        d[a][b] = c;
        d[b][a] = c;
    }

    Rep(k,n){
        Rep(i,n){
            Rep(j,n){
                d[i][i] = 0;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j] );
            }
        }
    }


    bool hit[10] = {};
    int ans = INF;
    Rep(i,rr) ans = min( ans , answer(hit,r[i]) );
    printf ("%d\n", ans );


    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
int main(void)
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    SORT(L);
    int ans = 0;
    REP(i, N){
        Rep(j, i+1, N){
            Rep(k, j+1, N){
                if(L[i]<L[j]+L[k] && L[j]<L[i]+L[k] && L[k]<L[i]+L[j]) ans++;
            }
            
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int num;
    int *digital;
    scanf("%d",&num);
    digital=(int *)malloc(sizeof(int)*num);
    int i;
    int miss_count=0;
    for(i=0;i<num;i++){
        scanf("%d",&digital[i]);
        if(digital[i]!=i+1){
            miss_count++;
        }
    }
    if(miss_count<=2){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
using namespace std;

int read(){
	int x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
ll readll(){
	ll x=0; char ch=getchar(); bool flag=0;
	while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); }
	while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
	return flag?-x:x;
}
int n,a[2009][2];
int main(){
	scanf("%d",&n);
	int m=(n+3>>2)<<1;
	int i,j;
	for (i=0; i<2; i++)
		for (j=0; j<m; j++){
			if (n){
				a[j][i]=n--;
			} else a[j][i]=a[j][i-1];
		}
	printf("%d\n",m);
	for (i=1; i<=m; i++)
		for (j=1; j<=m; j++) printf("%d%c",max(1,a[(i+j)%m][i&1]),j<m?' ':'\n');
	return 0;
}


Measured memory_bytes: 1152
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll H, W;
    cin >> H >> W;
    vector<bool> is_room(H * W);
    rep(i,0,H*W) {
        char c;
        cin >> c;
        if (c == '.') {
            is_room[i] = true;
        } else {
            is_room[i] = false;
        }
    }
    auto dist = make_vec_nd(numeric_limits<ll>::max(), H*W, H*W);
    rep(i,0,H*W) {
        dist[i][i] = 0;
    }
    rep(i,0,H*W) {
        rep(j,i+1,H*W) {
            if (!is_room[i] || !is_room[j]) {
                continue;
            }
            ll ix = i % W;
            ll iy = i / W;
            ll jx = j % W;
            ll jy = j / W;
            if ((iy == jy && abs(ix - jx) <= 1) || (ix == jx && abs(iy - jy) <= 1)) {
                dist[i][j] = 1;
                dist[j][i] = 1;
            }
        }
    }
    rep(k,0,H*W) {
        rep(i,0,H*W) {
            rep(j,0,H*W) {
                if (dist[i][k] == numeric_limits<ll>::max() || dist[k][j] == numeric_limits<ll>::max()) {
                    continue;
                }
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i,0,H*W) {
        rep(j,0,H*W) {
            if (dist[i][j] == numeric_limits<ll>::max()) {
                continue;
            }
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1536
#include<stdio.h>

int main(){
	int x,y,z,na=0,nb=0;
	while(scanf("%d,%d,%d",&x,&y,&z)!=-1){
		if(x+y>=z){
			if(x*x+y*y==z*z)na++;
			else if(x==y)nb++;
		}
	}
	printf("%d\n%d\n",na,nb);
	return 0;
}

Measured memory_bytes: 596
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		int[] h=new int[26];
		var ans="Yes";
		for(int i = 0;i<4;i++) {
			h[t[i]-'A']++;
		}
		for(int i = 0;i<h.Length;i++) {
			if(h[i]!=0&&h[i]!=2){ans="No";}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main()
{
  std::int64_t N,K;
  std::cin >> N >> K;

  // R = log2(11)
  // log_k(N) = log_e(N) / log_e(k)
  std::int64_t res = static_cast<std::int64_t>(log(N) / log(K))+1;

  std::cout << res;

}

Measured memory_bytes: 256
X = int(input())

dp = [0] * (100200)
dp[0] = 1

for i in range(X + 1):
    if dp[i] == 1:
        for j in range(6):
            dp[i + 100 + j] = 1
            if i + 100 + j == X:
                print(1)
                exit()
print(0)


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

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> as;
    vector <ll> memo1 = {0};
    vector <ll> memo2 = {0};
    REP(i, n){
        ll a; cin >> a;
        as.push_back(a);
        if (i % 2 == 0){
            memo1.push_back(memo1[i] + a);
            memo2.push_back(memo2[i] - a);
        } else {
            memo1.push_back(memo1[i] - a);
            memo2.push_back(memo2[i] + a);
        }
    }
    dumparr(memo1)
    dumparr(memo2)
    REP(i, n){
        ll ans;
        if (i%2 == 0){
            ans = -memo1[i] + memo1[n] + memo2[i];
        } else {
            ans = -memo2[i] + memo2[n] + memo1[i];
        }
        cout << ans;
        if (i<n-1){
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
}

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

typedef vector<int> vi;
typedef bitset<16> MASK;
#define ll long long
#define PI 3.14159265359
//#define x first
//#define y second
#define point pair<double,double>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int main(){
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    int n; cin>>n;
    int ans = 0;

    while(n%1000 != 0){
        n++;
        ans++;
    }


    cout<<ans;
}


Measured memory_bytes: 3604
import numpy as np
x=int(input())
if x<=99:
    print(0)
    exit()
elif x==100 or x==101 or x==102:
    print(1)
    exit()
a=[100,101,102,103,104,105]
m=[1000000]*6
dplist = np.ones((7,x+1))*(-1)
dplist[0,0] = 0
for i in range(6):
    for j in range(x+1):
        if dplist[i,j] >= 0:
            dplist[i+1,j] = m[i]
        elif dplist[i+1,j-a[i]]<= 0:
            dplist[i+1,j] = -1
        elif j - a[i] < 0:
            dplist[i+1,j] = -1
        else:
            dplist[i+1][j] = dplist[i+1,j-a[i]] -1

if dplist[6,x] >= 0:
    print(1)
else:
    print(0)


Measured memory_bytes: 23368
# coding: utf-8
# Your code here!

n,k = list(map(int,input().split()))	


if k%2!=0:
    print((n//k)**3)
else:
    k=k//2
    a = n//k
    gu = n//(2*k)
    ki = a-gu
    print((ki)**3+(gu)**3)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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

int a,b,c,d;
int calc(int x0,int y0,int x1,int y1){
    int ans1=abs(x0-x1)+abs(y0-y1);
    int ans2=0;
    int flag=0;
    if(!(a<=x0&&x0<=c)){
        ans2+=min(abs(a-x0),abs(c-x0));
        flag=1;
    }
    if(!(b<=y0&&y0<=d)){
        ans2+=min(abs(b-y0),abs(d-y0));
        flag=1;
    }
    ans2-=flag;
    if(!(a<x1&&x1<c)){
        ans2+=min(abs(a-x1),abs(c-x1));
    }
    if(!(b<y1&&y1<d)){
        ans2+=min(abs(b-y1),abs(d-y1));
    }
    return min(ans1,ans2);
}
int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        cin>>a>>b>>c>>d;
        int x,y;
        cin>>x>>y;
        int ret=0;
        REP(i,n){
            int x1,y1;
            cin>>x1>>y1;
            ret+=calc(x,y,x1,y1);
            x=x1,y=y1;
        }
        cout<<ret<<endl;
    }
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
using namespace std;

const int INF = (int)1e9 + 1;

int main() {

    int n, q;
    cin >> n >> q;

    vector< pair<int,int> > tmp( n );
    for ( int i=0; i<n; ++i ) {
	cin >> tmp[i].first;
	tmp[i].second = i;
    }
    sort( tmp.begin(), tmp.end() );

    vector<int> s( n );//下からi番目のスコア: s[i]
    vector<int> f( n );//i番の人がスコア何番目か: f[i]
    for ( int i=0; i<n; ++i ) {
	s[i] = tmp[i].first;
	f[tmp[i].second] = i;
    }

    set<int> leader;//リーダーの番号
    while ( q-- ) {

        string op;
        int arg;
	cin >> op >> arg;

        if      ( op == "ADD" )    leader.insert( f[arg-1] );
        else if ( op == "REMOVE" ) leader.erase( f[arg-1] );
        else {//CHECK

            int fail_r = -1, succ_r = INF;//条件を満たさない最大のr と 満たす最小のr

            while ( succ_r - fail_r > 1 ) {
		
                int mid = (succ_r + fail_r)/2;//新しいr

                int count = 0; //リーダーによってカバーされる生徒の総数
		int prev = -1; //リーダーのうちスコアが一つ下の人のインデックス
                for ( int idx : leader ) {

		    //全スコア中でリーダーからr引いたスコアの人のインデクス
                    int l_idx = lower_bound( s.begin(), s.end(), s[idx]-mid ) - s.begin();

		    //全スコア中でリーダーのスコアのすぐ下の人のインデクス
                    int r_idx = upper_bound( s.begin(), s.end(), s[idx] ) - s.begin()-1;

                    if ( l_idx <= prev ) l_idx = prev + 1;//一つ下のリーダーの手前まで

                    count += r_idx - l_idx + 1;//カウントにリーダー自身を含める
		    
                    prev = r_idx;
                }

                if ( n - count <= arg ) succ_r = mid;
                else fail_r = mid;
            }

	    if ( succ_r == INF ) cout << "NA" << endl;
	    else cout << succ_r << endl;
        }

    }

    return 0;
}



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

int main(){
    string S;
    cin >> S;
    int count =0;
    rep(i,S.size()){
        if (S.at(i) !=S.at(S.size()-(1+i)) ) {
            S.at(i) = S.at(S.size()-(1+i));
            count++;
        }
    }
    cout << count << endl;
}

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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin (),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp
//tgamma(i+1) is 1!


void solve(){
    string s;
    cin >> s;
    bool can = 0;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7')
        can = 1;
    cout << (can?"Yes":"No");
}

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

    solve();
}








Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
   long long n,i,j,k,s1=0,a1=0,b1=0,c1=0;
   string s;
   cin>>n>>s;

   for(i=0;s[i];i++)
   {
       if(s[i]=='R')
       {

           a1++;
       }
       else if(s[i]=='G')
       {

          b1++;
       }
       else if(s[i]=='B')
       {

           c1++;
       }
   }
   s1=a1*b1*c1;
  for(i=0;i<n;i++)
  {
      for(j=i+1;j<n;j++)
      {
          k=2*j-i;
          if(k<n)
          {
              if((s[i]!=s[j])&&(s[i]!=s[k])&&(s[j]!=s[k]))
                s1--;
          }
      }
  }
   cout<<s1;
    return 0;
}




Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main
{
	static void merge(int arr[], int l, int m, int r) 
    { 
        int n1 = m - l + 1; 
        int n2 = r - m; 
        int L[] = new int [n1]; 
        int R[] = new int [n2]; 
        for (int i=0; i<n1; ++i) 
            L[i] = arr[l + i]; 
        for (int j=0; j<n2; ++j) 
            R[j] = arr[m + 1+ j]; 
        int i = 0, j = 0; 
        int k = l; 
        while (i < n1 && j < n2) 
        { 
            if (L[i] <= R[j]) 
            { 
                arr[k] = L[i]; 
                i++; 
            } 
            else
            { 
                arr[k] = R[j]; 
                j++; 
            } 
            k++; 
        } 
        while (i < n1) 
        { 
            arr[k] = L[i]; 
            i++; 
            k++; 
        } 
        while (j < n2) 
        { 
            arr[k] = R[j]; 
            j++; 
            k++; 
        } 
    } 
    static void sort(int arr[], int l, int r) 
    { 
        if (l < r) 
        { 
            int m = (l+r)/2; 
            sort(arr, l, m); 
            sort(arr , m+1, r); 
            merge(arr, l, m, r); 
        } 
    } 
    static int gcd(int a, int b) 
    { 
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    } 
    static long power(long n,long m)
    {
    	if(m==0)
    		return 1;
    	long ans=1;
    	while(m>0)
    	{
    		ans=ans*n;
    		m--;
    	}
    	return ans;
    }
	static int binarySearch(ArrayList<Integer> arr, int x) 
    { 
        int l = 0, r = arr.size() - 1,m=l + (r - l) / 2; 
        while (l <= r) { 
            m = l + (r - l) / 2; 
            if (arr.get(m) == x) 
                return m; 
            if (arr.get(m) < x) 
                l = m + 1; 
            else
                r = m - 1; 
        } 
        return (int)Math.max(l, m); 
    } 
	public static void main(String args[])throws Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=1;//Integer.parseInt(br.readLine());
	    outer:for(int i=1;i<=t;i++)
	    {
	        double n=Double.parseDouble(br.readLine());//,k;
	        double ans=n*44/7;
	        System.out.println(ans);
	    }
	}
}


Measured memory_bytes: 33252
n, w = map(int, input().split())
items = []
 
for i in range(n):
    items.append(list(map(int, input().split())))
 
 
def knapsack(n, w, items):
    c = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
    g = [[0 for _ in range(w + 1)] for _ in range(n + 1)]
 
    for i in range(w + 1):
        c[0][i] = 0
        g[0][i] = 1
 
    for i in range(n + 1):
        c[i][0] = 0
 
    for i in range(1, n + 1):
        for j in range(1, w + 1):
            c[i][j] = c[i - 1][j]
            g[i][j] = 0
            item = items[i - 1]
            if item[0] > j:
                continue
            if item[1] + c[i - 1][j - item[0]] > c[i - 1][j]:
                c[i][j] = item[1] + c[i - 1][j - item[0]]
                g[i][j] = 1
 
    max_value = c[n][w]
    routes = []
    for i in range(n, 0, -1):
        if g[i][w] == 1:
            routes.append(i)
            w -= items[i - 1][0]
    return max_value, routes
 
 
result, _ = knapsack(n, w, items)
print(result)

Measured memory_bytes: 261128
import sys
input = sys.stdin.readline
from collections import *

class Unionfind:
    def __init__(self, n):
        self.par = [-1]*n
        self.rank = [1]*n
    
    def root(self, x):
        r = x
        
        while not self.par[r]<0:
            r = self.par[r]
        
        t = x
        
        while t!=r:
            tmp = t
            t = self.par[t]
            self.par[tmp] = r
        
        return r
    
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        
        if rx==ry:
            return
        
        if self.rank[rx]<=self.rank[ry]:
            self.par[ry] += self.par[rx]
            self.par[rx] = ry
            
            if self.rank[rx]==self.rank[ry]:
                self.rank[ry] += 1
        else:
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
    
    def is_same(self, x, y):
        return self.root(x)==self.root(y)
    
    def count(self, x):
        return -self.par[self.root(x)]

N, M = map(int, input().split())
uf = Unionfind(N)

for _ in range(M):
    A, B = map(int, input().split())
    uf.unite(A-1, B-1)

ans = 0
r = set()

for i in range(N):
    r.add(uf.root(i))
    
for ri in r:
    ans = max(ans, uf.count(ri))

print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

vpint calc(vint X){
    map<int,int>m;
    rep(i,X.size())m[X[i]]++;
    vector<pint>ret;
    for(auto &p:m)ret.pb({X.size()-p.se,p.fi});
    ret.pb({X.size(),114514});
    return ret;
}

signed main(){
    int N;cin>>N;
    vint X,Y;
    rep(i,N){
        int a;cin>>a;
        if(i&1)X.pb(a);
        else Y.pb(a);
    }

    vpint x=calc(X);
    vpint y=calc(Y);

    sort(all(x));sort(all(y));
    int ans=1001001001;
    rep(i,2)rep(j,2)if(x[i].se!=y[j].se)chmin(ans,x[i].fi+y[j].fi);
    cout<<ans<<endl;
}


Measured memory_bytes: 6888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}

ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}

int main() {
  cout << fixed << setprecision(30);
  ll h;
  cin>>h;
  ll count=0;
  while(h>0){
    h/=2;
    count++;
  }
  putout((ll)(pow(2,count)-1ll));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0;
  cin>>n;
  int a[n];
  for(int i=1; i<=n; i++)
    cin>>a[i];
  for(int i=1; i<=n; i++)
  {
    if(i%2!=0 && a[i]%2!=0)
      count++;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3532
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;



int main(int argc, char *args[]) {
	int A, B;
	cin >> A >> B;
	int counter = 0;
	for (int i = 0; i < 2; i++) {
		if (A > B) {
			counter += A;
			A--;
		}
		else {
			counter += B;
			B--;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}

void solve(){
	int A[3][3], m = INT_MAX;
	rep(i,0,3) 
		rep(j,0,3) 
			cin>>A[i][j];
	rep(j,0,3)	m = min(A[0][j], m);
	int b[3];
	while(m>=0){
		set<int>s2, s3;
		int a22, a33;
		rep(j,0,3) b[j] = A[0][j] - m;
		rep(j,0,3) {s2.insert(A[1][j]-b[j]);a22= A[1][j]-b[j];}
		rep(j,0,3) {s3.insert(A[2][j]-b[j]);a33= A[2][j]-b[j];}
		if(sz(s2) == 1 && sz(s3) == 1 && a22>=0 && a33>=0){
			cout<<"Yes"<<endl;
			return;
		}
		s2.clear(); s3.clear();
		m--;
	}
	cout<<"No"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

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

    if (A >= K){
        cout << K << endl;
    }
    else if ((A+B) >= K){
        cout << A << endl;
    }
    else{
        cout << A - (K-(A+B)) << endl;
    }
}

Measured memory_bytes: 3620
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[12];
int N;
int main(){
  int i, j;
  long long k, res=0;
  N = rd(S);
  for(i=0;i<(N);i++){
    S[i] -= '0';
  }
  for(i=0;i<(N);i++){
    k = 0;
    for(j=(i);j<(N);j++){
      k = 10* k + S[j];
      res += (k << (max_L(0, i-1)+max_L(0, N-j-2)));
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190829-1

// --- original code ---
// char S[12];
// int N;
// {
//   int i, j;
//   ll k, res = 0;
//   rd(S@N);
//   rep(i,N) S[i] -= '0';
//   
//   rep(i,N){
//     k = 0;
//     rep(j,i,N){
//       k = 10 k + S[j];
//       res += (k << (max(0,i-1) + max(0,N-j-2)));
//     }
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		while(true){

			C = C - B;
			if (C <= 0){
				System.out.println("Yes");
				break;
			}

			A = A - D;
			if (A <= 0){
				System.out.println("No");
				break;
			}


		}
	}

}


Measured memory_bytes: 35880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, p;
	cin >> a >> p;
	a *= 3;
	int ans = (a + p) / 2;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))


class SegmentTree(object):

    def __init__(self, A, e, fn):  # O(N)
        """
        :param A: 区間クエリの対象となる配列
        :param e: 単位元 fn(a, e) = fn(e, a) = a
        :param fn: (a, b) -> x な関数 a, bは交換則を満たす
        """
        self.e = e
        self.fn = fn
        self.length = 2 ** (len(A) - 1).bit_length()
        self.tree = [e] * 2 * self.length
        for i in range(len(A)):
            self.tree[i + self.length - 1] = A[i]
        for i in range(self.length - 2, -1, -1):
            self.tree[i] = self.fn(self.tree[2 * i + 1], self.tree[2 * i + 2])

    # 配列のi番目をxに更新する
    def update(self, i, x):  # O(logN)
        i += self.length - 1
        self.tree[i] = x
        while i:
            i = (i - 1) // 2
            self.tree[i] = self.fn(self.tree[i * 2 + 1], self.tree[i * 2 + 2])

    # 区間[p, q)に関するクエリに答える
    def query(self, p, q):  # O(logN)
        if q <= p:
            return self.e
        p += self.length - 1
        q += self.length - 2
        res = self.e
        while q - p > 1:
            if p & 1 == 0:
                res = self.fn(res, self.tree[p])
            if q & 1 == 1:
                res = self.fn(res, self.tree[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = self.fn(res, self.tree[p])
        else:
            res = self.fn(self.fn(res, self.tree[p]), self.tree[q])
        return res


N = I()
S = input()
Q = [tuple(input().split()) for _ in range(I())]

A = [2 ** (ord(c) - 97) for c in S]
seg = SegmentTree(A, 0, lambda a, b: a | b)


for t, i, c in Q:
    if t == '1':
        i = int(i) - 1
        seg.update(i, 2 ** (ord(c) - 97))
    else:
        l, r = int(i) - 1, int(c)
        bit = seg.query(l, r)
        print(bin(bit).count('1'))


Measured memory_bytes: 84916
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


#define INF 1e+9



int main(){

  int n,m;
  cin >> n >> m;
  vector<int> c(m+1,0);
  for(int i=1; i<=m; i++)
    cin >> c[i];


  // dp[i][j]: i???????????????????????§??§???j??????????????????????????????????°??????°
  vvi dp(m+2,vi(n+1,INF));
  dp[0][0] = 0;
  for(int i=0; i<=m; i++){
		for(int j=0; j<=n; j++){
			  if(dp[i][j] != INF){ // dp[i][j] ????????????
					dp[i+1][j] = min(dp[i][j], dp[i+1][j]); // i?????????????????????????????????
					if(j+c[i] > n) continue;
					dp[i][j+c[i]] = min(dp[i][j]+1,dp[i][j+c[i]]); //i???????????????????????´????????????
					dp[i+1][j+c[i]] = min(dp[i][j]+1,dp[i+1][j+c[i]]); //i???????????????????????´????????????
			  }
		}
  }
  cout << dp[m][n] << endl;
  

  

}

Measured memory_bytes: 5492
N = gets.to_i
C,S,F = (N-1).times.map{gets.split.map(&:to_i)}.transpose
N.times do |i|
  time = 0
  for j in i..(N-2)
    if S[j] >= time
      time += S[j]-time
    elsif (time - S[j]) % F[j] > 0
      time += F[j] - ((time - S[j]) % F[j])
    end
    time += C[j]
  end
  puts time
end

Measured memory_bytes: 14332
#include <iostream>
using namespace std;
int vit[110000],head[110000],l[110000];
int n,m,u,v,cnt;
struct edge
{
    int to;
    int next;
}e[610000];
void add(int u,int v)
{
    cnt++;
    e[cnt].to=v;
    e[cnt].next=head[u];
    head[u]=cnt;
}
void bfs(void)
{
    int h=0,r=1;
    l[h]=1;
    while(h<r)
    {
        for(int i=head[l[h]];i;i=e[i].next)
        {
            int u=l[h],v=e[i].to;
            if(!vit[v])
            {
                vit[v]=l[h];
                l[r++]=v;
            }
        }
        h++;
    }
}
int main(void)
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>u>>v;
        add(u,v);add(v,u);
    }
    bfs();
    for(int i=2;i<=n;i++)
    {
        if(!vit[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++)
    {
        cout<<vit[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 7504
<?php
list($n, $a, $b) = explode(' ', trim(fgets(STDIN)));
$answer = 0;
if ($a == $b) {
    $answer = 1;
} elseif ($a < $b) {
    if ($n == 1) {
        $answer = 0;
    } else {
        $answer = ($b - $a) * ($n - 2) + 1;
    }
}
echo("{$answer}\n");


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int K;
    cin >> K;
    queue<ll> que;
    for (int i = 1; i < 10; ++i) que.push(i);
    for (int i = 0; i < K-1; ++i) {
        ll s = que.front();
        que.pop();
        for (int j = -1; j <= 1; ++j) {
            ll add = (s % 10) + j;
            if (add >= 0 && add <= 9) que.push(s * 10 + add);
        }
    }
    cout << que.front() << endl;
    return 0;
}

Measured memory_bytes: 1792
(defun solve (str)
  (loop for x across str 
        with W = 0 and R = (count #\R str)
        initially (if (zerop R) (return 0))
        do (if (eq x #\R) (decf R) (incf W))
        minimize (max R W)))

(read)
(princ (solve (read-line)))

Measured memory_bytes: 27012
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
    }

    let res = match n % 10 {
        3 => "bon",
        0 | 1 | 6 | 8 => "pon",
        _ => "hon",
    };
    println!("{}", res);
}


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

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

//拡張拡張Euclidの互除法による(階乗)逆元の求め方
//O(N)
void stairs(long long N, vector<long long>& st, long long mod = 1e9 + 7) {
	st.resize(N + 1, 1);
	for (long long n = 2; n <= N; n++) {
		st[n] = (st[n - 1] * n) % mod;
	}
}

LL stair(LL N, LL mod = 1e9 + 7) {
	LL ans = 1;
	for (LL n = 2; n <= N; n++)ans = (ans * n) % mod;
	return ans;
}

void modinvs(long long N, vector<long long>& inv, vector<long long>& sinv, long long mod = 1e9 + 7) {
	inv.resize(N + 1);
	sinv.resize(N + 1);
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv[n] = (sinv[n - 1] * inv[n]) % mod;
	}
}

//(n^(-1),(n!)^(-1))
PLL modinvs(LL N, LL mod = 1e9 + 7) {
	vector<LL> inv(N + 1);
	inv[1] = 1;
	LL sinv = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv = (sinv * inv[n]) % mod;
	}
	return PLL(inv[N], sinv);
}

long long Comb(long long n, long long k, vector<long long>& st, vector<long long>& sinv, long long mod = 1e9 + 7) {
	if (n < 0)return 0;
	if (k > n || k < 0)return 0;
	long long ans = st[n];
	ans = (ans * sinv[n - k]) % mod;
	ans = (ans * sinv[k]) % mod;
	return ans;
}

LL Comb(LL N, LL K, LL mod = 1e9 + 7) {
	if (N < 0)return 0;
	if (K > N || K < 0)return 0;
	if (K == 0 || K == N)return 1;
	LL ans = stair(N, mod);
	ans = (ans * modinvs(N - K).second) % mod;
	ans = (ans * modinvs(K).second) % mod;
	return ans;
}


int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	int K;
	cin >> K;
	cin >> S;
	int N = S.size();
	VLL n25(2e6 + 1, 1);
	for (int n = 1; n <= 2e6; n++) {
		n25[n] = n25[n - 1] * 25;
		n25[n] %= MOD;
	}
	VLL n26(2e6 + 1, 1);
	for (int n = 1; n <= 2e6; n++) {
		n26[n] = n26[n - 1] * 26;
		n26[n] %= MOD;
	}
	VLL st, inv, sinv;
	stairs(2e6, st,MOD);
	modinvs(2e6, inv, sinv, MOD);
	LL sum = 0;
	for (LL k = N - 1; k <= N + K - 1; k++) {
		LL temp = Comb(k, N - 1,st,sinv,MOD);
		temp = temp * n25[k - N + 1];
		temp %= MOD;
		temp = temp * n26[N + K - k-1];
		temp %= MOD;
		sum = (sum + temp) % MOD;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 81952
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <vector>
#define N 211
using namespace std;
typedef long long ll;
int a[N][N];
int main()
{
    int inf = 99999999;
    int m, n;
    while (~scanf("%d",&m))//floyd
    {
        if (m == 0)  return 0;
        int i, j, k;
        for (i=0; i<=11; i++)
            for (j=i; j<=11; j++)
                if (i == j)  a[i][j] = 0;
                else  a[i][j] = a[j][i] = inf;

        n = -1;
        for (i=0; i<m; i++)
        {
            int q, w, e;
            scanf("%d%d%d",&q,&w,&e);
            n = max(n,q);
            n = max(n,w);
            if (e < a[q][w])  a[q][w] = a[w][q] = e;
        }

        for (k=0; k<=n; k++)
            for (i=0; i<=n; i++)
                for (j=0; j<=n; j++)
                    a[i][j] = min(a[i][j],a[i][k]+a[k][j]);

        int ans , sum = inf;
        for (i=0; i<=n; i++)
        {
            int temp = 0;
            for (j=0; j<=n; j++)
                temp += a[i][j];
            if (temp < sum)
            {
                sum = temp;
                ans = i;
            }
        }
        cout << ans << " " << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]-a[1]+a[1]-a[0]<<endl;

	return 0;
}

Measured memory_bytes: 256