akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

//#abcde#
// 01234
int SumDigits(int n)
{
    int digits[5];

    for(int i = 0; i < 5; i++){
        digits[i] = n % 10;
        n /= 10;
        //cout << digits[i] << endl;
    }

    if ((digits[0] == digits[4]) && 
        (digits[1] == digits[3])   ) {
        return 1;
    } else {
        return 0;
    }
}

int main()
{
    int A, B;
    int cnt = 0;

    cin >> A >> B;
    
    for(int i = A; i <= B; i++) {
        if (SumDigits(i)) { cnt++; } 
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int numberA,numberB,numberC,numberD;
    int minTrain,minBus;
    scanf("%d",&numberA);
    scanf("%d",&numberB);
    scanf("%d",&numberC);
    scanf("%d",&numberD);

    if(numberA > numberB){
        minTrain = numberB; 
    }else{
        minTrain = numberA;
    }

    if(numberC > numberD){
        minBus = numberD;
    }else{
        minBus = numberC;
    }
    printf("%d",minBus+minTrain);

}

Measured memory_bytes: 128
fun main(args: Array<String>)
{
    val n = readInt()
    val a = readNInts().toLongArray()
    val b = readNInts().toLongArray()
    // val a = Array<Int>(n+1, {0})
    // for (i in 0..n) a[i] = tmp[i]

    // tmp = readNInts()
    // val b = Array<Int>(n, {0})
    // for (i in 0..n-1) b[i] = tmp[i]

    var cnt = 0L

    for (i in n-1 downTo 0) {
        if (a[i+1] >= b[i]) {
            cnt += b[i]
            a[i+1] -= b[i]
            b[i] = 0L
        } else {
            cnt += a[i+1]
            b[i] -= a[i+1]
            a[i+1] = 0L

            if (a[i] >= b[i]) {
                cnt += b[i]
                a[i] -= b[i]
            } else {
                cnt += a[i]
                a[i] = 0L
            }
        }
    }

    println(cnt)
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toLong)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int N, K;
int sumB[1111][1111];
int sumW[1111][1111];

int main() {
   cin >> N >> K;
   rep (i, 0, N) {
      int x, y;
      char c;
      cin >> x >> y >> c;

      int tmp = x/K + y/K;
      x %= K, y%= K;
      if (tmp&1) {
         if (c=='B') c='W';
         else c = 'B';
      }
      if (c=='B') sumB[y+1][x+1]++;
      else sumW[y+1][x+1]++;
   }

   rep (i, 0, K) {
      rep (j, 0, K) {
         sumB[i+1][j+1]+=sumB[i][j+1]+sumB[i+1][j]-sumB[i][j];
         sumW[i+1][j+1]+=sumW[i][j+1]+sumW[i+1][j]-sumW[i][j];
      }
   }

   int ans = 0;
   rep (i, 0, K+1) {
      rep (j, 0, K+1) {
         int tmp = 0;
         tmp += sumB[i][j];
         tmp += sumB[K][K]-sumB[i][K]-sumB[K][j]+sumB[i][j];
         tmp += sumW[K][j]-sumW[i][j];
         tmp += sumW[i][K]-sumW[i][j];
         ans = max(ans, tmp);
         ans = max(ans, N-tmp);
      }
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 9472
#include<stdio.h>
 
#define Ma 100
#define INF (1<<21)
 
int main(){
  int i,j,s,l,n;
  int p[Ma+1],m[Ma+1][Ma+1];
 
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d %d",&p[i-1],&p[i]);
 
  for(i=1;i<=n;i++)
    m[i][i] = 0;
 
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l -1;
      m[i][j] = INF;
      for(s=i;s<j;s++)
    if(m[i][j] > m[i][s] + m[s+1][j] + p[i-1] * p[s] * p[j])
      m[i][j] = m[i][s] + m[s+1][j] + p[i-1] * p[s] * p[j];
    }
  }
 
  printf("%d\n",m[1][n]);
 
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
using namespace std;
int main(void){
    double a,b;
    cin>>a>>b;
    cout<<b-a+b<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
  int i, n, maxv, minv, R[200000];

  scanf("%d", &n);
  for(i=0; scanf("%d", &R[i]) == 1; i++);

  maxv= R[1] -R[0];
  minv = R[0];
  for(i=1; i < n; i++){
    maxv = fmax(maxv, R[i]-minv);
    minv = fmin(minv, R[i]);
  }
  printf("%d\n", maxv);
  return 0;
}

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

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[301],cnt[5];
double dp[301][301][301];
bool used[301][301][301];
double dfs(int i,int j,int k){
	if(i==0&&j==0&&k==0) return 0;
	if(used[i][j][k]) return dp[i][j][k];
	used[i][j][k]=1;
	if(k!=0) dp[i][j][k]+=dfs(i,j+1,k-1)*k/n;
	if(j!=0) dp[i][j][k]+=dfs(i+1,j-1,k)*j/n;
	if(i!=0) dp[i][j][k]+=dfs(i-1,j,k)*i/n;
	dp[i][j][k]++;
	dp[i][j][k]/=1.0*(i+j+k)/n;
	return dp[i][j][k];
}
void init(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	printf("%.10lf",dfs(cnt[1],cnt[2],cnt[3]));
}
int main(){
	init();
	return 0;
}

Measured memory_bytes: 239872
dice ='253416'
def rot(d, k)
  case(k)
  when 0,2
    3.times {rot(d,k | 1) }
  when 1
    d[1], d[5], d[0], d[4]= d[4], d[1], d[5], d[0]
  when 3
    d[3], d[5], d[2], d[4] = d[4], d[3], d[5], d[2]
  else
    d[0], d[2], d[1], d[3] = d[3], d[0], d[2], d[1]
  end
end
loop do
  break if (n=gets.to_i) == 0
  map = Hash.new([])
  n.times do
    t,f = gets.split
    d = dice.clone
    catch(:found) do
      6.times do |i|
        4.times do 
          rot(d, 4)
          throw :found if d[2] == f && d[4] == t
        end
        rot(d, i.even? ? 0 : 2)
      end
    end
    x,y = 0,0
    loop do
      map[[x,y]] = map[[x,y]] + [d[4]]
      dx,dy = [-1,1,0,0],[0,0,1,-1]
      mv, dv = 0, -1
      for i in 0..3
        if map[[x+dx[i],y+dy[i]]].size < map[[x,y]].size - 1 && d[i].to_i > dv
          dv, mv = d[i].to_i,i
        end
      end
      break if dv <= 3
      map[[x,y]].pop
      rot(d,mv)
      x, y = x + dx[mv], y + dy[mv]
    end
  end
  res = [0,0,0,0,0,0]
  map.each {|k,v| res[v.pop.to_i - 1] += 1 } 
  puts res.join(' ')
end

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

#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
}

int main(){
	c_p_c();

	ll n,a,b;
	cin >> n >> a >> b;

	ll ans = (n/(a+b))*a;
  	ll rem = n%(a+b);
  	if(rem>=a) ans += a;
  	else ans += rem;
  
  	cout << ans << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<string>vst(n - 2);
  vector<int>vin(n - 2);
  for (int i = 0; i < n - 2; i++) {
    vst[i] = s.substr(i, 3);
  }
  for (int i = 0; i < n - 2; i++) {
    if (vst[i].at(0) == '1') vin[i] += 100;
    if (vst[i].at(0) == '2') vin[i] += 200;
    if (vst[i].at(0) == '3') vin[i] += 300;
    if (vst[i].at(0) == '4') vin[i] += 400;
    if (vst[i].at(0) == '5') vin[i] += 500;
    if (vst[i].at(0) == '6') vin[i] += 600;
    if (vst[i].at(0) == '7') vin[i] += 700;
    if (vst[i].at(0) == '8') vin[i] += 800;
    if (vst[i].at(0) == '9') vin[i] += 900;
    if (vst[i].at(1) == '1') vin[i] += 10;
    if (vst[i].at(1) == '2') vin[i] += 20;
    if (vst[i].at(1) == '3') vin[i] += 30;
    if (vst[i].at(1) == '4') vin[i] += 40;
    if (vst[i].at(1) == '5') vin[i] += 50;
    if (vst[i].at(1) == '6') vin[i] += 60;
    if (vst[i].at(1) == '7') vin[i] += 70;
    if (vst[i].at(1) == '8') vin[i] += 80;
    if (vst[i].at(1) == '9') vin[i] += 90;
    if (vst[i].at(2) == '1') vin[i] += 1;
    if (vst[i].at(2) == '2') vin[i] += 2;
    if (vst[i].at(2) == '3') vin[i] += 3;
    if (vst[i].at(2) == '4') vin[i] += 4;
    if (vst[i].at(2) == '5') vin[i] += 5;
    if (vst[i].at(2) == '6') vin[i] += 6;
    if (vst[i].at(2) == '7') vin[i] += 7;
    if (vst[i].at(2) == '8') vin[i] += 8;
    if (vst[i].at(2) == '9') vin[i] += 9;
  }
  int ans = 1000;
  for (int i = 0; i < n - 2; i++) {
    if (vin[i] > 753) ans = min(ans, vin[i] - 753);
    else ans = min(ans, 753 - vin[i]);
  }
  cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  rep(i, N) cin >> x[i];

  int ans = 1e9;
  rep(i, N - K + 1) {
    int l = x[i];
    int r = x[i + K - 1];
    int al = abs(l), ar = abs(r);
    int tmp;
    if (l <= 0 && 0 <= r)
      tmp = 2 * min(al, ar) + max(al, ar);
    else
      tmp = max(al, ar);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}

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

int main() {
  long long H, W;
  long long ans;

  cin >> H >> W;

  long long HW = H*W;

  if(H==1 || W==1) ans = 1;
  else if(HW%2==0) ans = HW/2;
  else ans = HW/2 + 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

  ll cnt = 0;
  while (a >= b) {
    b *= 2;
    cnt++;
  }

  while (b >= c) {
    c *= 2;
    cnt++;
  }
  cout << (cnt <= k ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3596
n = int(input())
a = list(map(int, input().split()))

cnt = 1
first = True
increasing = True

for i in range(1, n):
    if (first):
        if (a[i] > a[i-1]):
            first = False
            increasing = True
        elif (a[i] < a[i-1]):
            first = False
            increasing = False
    else:
        if (a[i] > a[i-1]) and (increasing == False):
            cnt += 1
            first = True
        elif (a[i] < a[i-1]) and (increasing == True):
            cnt += 1
            first = True

print(cnt)

Measured memory_bytes: 20204
//created by krishna
#include <bits/stdc++.h>
using namespace std;
#define endl "\n" 
typedef long long ll;
typedef unsigned long long ull;
#define debug(x) cout<<"the value of "<<#x<<" is "<<x<<endl;
int main()
{
    string a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i])
            ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
	int N, Q;
	cin >> N>>Q;
	string S;
	cin >> S;
	vector<int>Left(Q), Right(Q);
	for (int i = 0; i < Q; i++) {
		cin >> Left.at(i) >> Right.at(i);
	}
	vector<int>data(N+1);
	data.at(0) = 0;
	for (int i = 0; i < N-1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			data.at(i + 1) = data.at(i) + 1;
		}
		else {
			data.at(i + 1) = data.at(i);
		}
	}
	for (int i = 0; i < Q; i++) {
		cout << data.at(Right.at(i)-1) - data.at(Left.at(i)-1) << endl;
	}
	return 0;

}

Measured memory_bytes: 4560
h,w = gets.chomp.split(' ').map(&:to_i)

min = 1e+10

# +----------+
# |          |
# +----------+ 
# |          |
# +----------+
# |          |
# +----------+
h.times do |y1|
  y2 = (h - y1) / 2
  
  s = []
  s[0] = y1 * w
  s[1] = y2 * w
  s[2] = (h - (y1 + y2)) * w
  
  s.sort!
  min = [s[2] - s[0], min].min
end

# +----------+
# |          |
# +----+-----+ 
# |    |     |
# |    |     |
# +----+-----+
h.times do |y|
  x = w / 2
  
  s = []
  s[0] = y * w
  s[1] = (h - y) * x
  s[2] = (h - y) * (w - x)
  
  s.sort!
  min = [s[2] - s[0], min].min
end

# +---+------+
# |   |      |
# |   +------+
# |   |      |
# |   |      |
# +---+------+
w.times do |x|
  y = h / 2
  
  s = []
  s[0] = h * x
  s[1] = y * (w - x)
  s[2] = (h - y) * (w - x)
  
  s.sort!
  min = [s[2] - s[0], min].min
end

# +---+---+--+
# |   |   |  |
# |   |   |  |
# |   |   |  |
# |   |   |  |
# |   |   |  |
# +---+---+--+
w.times do |x1|
  x2 = (w - x1) / 2
  
  s = []
  s[0] = h * x1
  s[1] = h * x2
  s[2] = h * (w - (x1 + x2))
  
  s.sort!
  min = [s[2] - s[0], min].min
end

puts min.to_s

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
     string s;
     cin>>s;
     lint x=0;
     rep(i,s.size()){
         lint a=s[i]-'0';
         x+=a;
     }
     if(x%9==0)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
  }
      
    
  

Measured memory_bytes: 3852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt()%10 ;
 		if (n==3)	op.println("bon") ;
 		else if (n==0 || n==1 || n==6 || n==8)	op.println("pon") ;
 		else 	op.println("hon") ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

Measured memory_bytes: 32848
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b,c;
  cin >> a >> b >> c;

  if(b+c<=a)cout << 0 << endl;
  else cout << c-(a-b) << endl;

}

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

int main() {

     int A,B,C;
    cin >> A >> B >> C;
    
    if (C - (A - B) >= 0) {
        cout << C - (A - B) << endl;
    }
    
    if (C - (A - B) < 0) {
        cout << 0 << endl;
    }
    
 }

Measured memory_bytes: 256
N = gets.to_i

ans = 0

for i in 1..N do
  next if i.modulo(10) == 0
  if i.to_s[0] == i.to_s[-1] then
    n = i.to_s[0].to_i
  else
    n = (i.to_s[-1] + i.to_s[0]).to_i
  end
  while n <= N do
    if n.to_s.length == 1 then
      ans += 1
    elsif n > 100 && n.to_s[0] == N.to_s[0] && n.to_s.length == N.to_s.length then
      ans += ((N - n) - (N - n).modulo(10)) / 10 + 1
    else
      ans += 10 ** (n.to_s.length - 2)
    end
    n = (n.to_s[0] + "0" * (n.to_s.length - 1) + n.to_s[-1]).to_i
  end
end

puts ans


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
    }
    int m = P[0];
    int count = 1;
    rep(i, N) {
        if (P[i] < m) {
            m = P[i];
            count++;
        }
    }
    cout << count << endl;
}


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

int func(int x) {
	if (x % 100 != 0) return 0;
	return func(x / 100) + 1;
}

int main() {
	int d, n;
	cin >> d >> n;
	int cnt = 0;
	for (int x = 1 ;; x++) {
		if (func(x) == d) {
			cnt++;
			if (cnt == n) {
				cout << x << endl;
				return 0;
			}
		}
	}

	return 0;
}


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

using namespace std;


#define MAXN 100001
int sm(int k) {
  int ret = 0;
  while(k) {
    ret += k%10;
    k /= 10;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int ans = 1000;
  for (int i = 1; i < n; ++i) {
    ans = min(ans, sm(i)+sm(n-i));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  vector<int> data(5);
  vector<int> min(5);
  int sum=0;
  for(int i=0; i<5; i++){
    cin >> data.at(i);
    min.at(i) = 10-(data.at(i) % 10);
    if(min.at(i) == 10){
      min.at(i) = 0;
    }
  }
  
  sort(min.begin() , min.end());
  
  for(int i=0; i<4; i++){
    sum += data.at(i);
    sum += min.at(i);
  }
  
  sum += data.at(4);
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import Counter
input = sys.stdin.readline
INF = 10**9

n, k = [int(item) for item in input().split()]
a = [int(item) - 1 for item in input().split()]
cumsum = [0] * (n + 1)
for i in range(n):
    cumsum[i+1] = cumsum[i] + a[i]
    cumsum[i+1] %= k

ls = list(set(cumsum))
dic = dict()
for i, item in enumerate(ls):
    dic[item] = i

cnt = [0] * (n + 10)
num = 0
ans = 0
for i, item in enumerate(cumsum):
    index = dic[item]
    ans += cnt[index]
    cnt[index] += 1
    num += 1
    if num >= k:
        left = cumsum[i - k + 1]
        index = dic[left]
        if cnt[index] > 0:
            cnt[index] -= 1
        num -= 1

print(ans)

Measured memory_bytes: 108836
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=1e9+7;
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
const int N=1010,M=2010;
int head[N],ecnt;
struct ed { int to,next,w; }e[N<<1];
void ad(int x,int y,int w) {
	e[++ecnt]=(ed){y,head[x],w}; head[x]=ecnt;
	e[++ecnt]=(ed){x,head[y],w}; head[y]=ecnt;
}
int gl,qmx;
void dfs(int u,int last,int mx) {
	if(u==gl) { qmx=mx; return; }
	for(int k=head[u];k;k=e[k].next) {
		int v=e[k].to; if(v==last) continue;
		dfs(v,u,max(mx,e[k].w));
	}
}
int Query(int x,int y) {
	gl=y;
	dfs(x,0,0);
	return qmx;
}
struct edge {
	int x,y,w;
	friend bool operator < (edge A,edge B) { return A.w<B.w; }
}E[M];
int used[M];
int fa[N];
int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
bool un(int x,int y) {
	if(find(x)==find(y)) return 0;
	fa[find(x)]=find(y); return 1;
}
ll X;
int n,m;
int main() {
	rd(n),rd(m),rd(X);
	for(int i=1;i<=m;++i) rd(E[i].x),rd(E[i].y),rd(E[i].w);
	sort(E+1,E+m+1);
	for(int i=1;i<=n;++i) fa[i]=i;
	ll ans=0;
	for(int i=1;i<=m;++i)
		if(un(E[i].x,E[i].y)) ad(E[i].x,E[i].y,E[i].w),ans+=E[i].w,used[i]=1;
	int cnt0=0,cnt1=0,cnt2=0;
	ll del=X-ans;
	if(del<0) {
		printf("0"); return 0;
	}
	for(int i=1;i<=m;++i) if(!used[i]) {
		int t=E[i].w-Query(E[i].x,E[i].y);
		if(t>del) cnt2++;
		else if(t==del) cnt1++;
		else cnt0++;
	}
	if(del==0)
		printf("%d\n",((Pow(2,n-1)-2)*(ll)Pow(2,m-(n-1))%mod+2ll*(Pow(2,cnt1)-1)*Pow(2,cnt2)%mod+mod)%mod);
	else
		printf("%d\n",(2ll*Pow(2,cnt2)*(ll)(Pow(2,cnt1)-1)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  map<string, int> map;
  rep(i, n)
  {
    string s;
    cin >> s;
    map[s]++;
  }
  cout << "AC x " << map["AC"] << endl;
  cout << "WA x " << map["WA"] << endl;
  cout << "TLE x " << map["TLE"] << endl;
  cout << "RE x " << map["RE"] << endl;
  return 0;
}

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

int main() {
  string A;
  cin >> A;

  if(A == "SUN"){
      cout << 7 << endl;
  }
  else if(A == "MON"){
      cout << 6 << endl;
  }
  else if(A == "TUE"){
      cout << 5 << endl;
  }
  else if(A == "WED"){
      cout << 4 << endl;
  }
  else if(A == "THU"){
      cout << 3 << endl;
  }
  else if(A == "FRI"){
      cout << 2 << endl;
  }
  else if(A == "SAT"){
      cout << 1 << endl;
  }

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;
const double PI=3.14159265358979323846;

int main(){
    int N;
    cin>>N;
    
    cout<< N*PI*2 <<endl;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	re ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n,k,c,cnt,pre;
int dp1[200010],dp2[200010],ans[200010];
string s;
int main()
{
	n=read(),k=read(),c=read();
	cin>>s;
	s=" "+s;
	pre=-c-1;
    for(int i=1;i<=n;i++)
	{
    	if(s[i]=='x')  dp1[i]=dp1[i-1];
    	else
    	{
    		if(pre+c+1<=i)
			{
    			dp1[i]=dp1[i-1]+1;
    			pre=i;
    		}
    		else dp1[i]=dp1[i-1];
		}
    }
	pre=n+c+1;
    for(int i=n;i>=1;i--)
	{
    	if(s[i]=='x') dp2[i]=dp2[i+1];
    	else 
    	{
    		if(pre-c-1>=i){
    			dp2[i]=dp2[i+1]+1;
    			pre=i;
    		}
    		else dp2[i]=dp2[i+1];
    	}
    }
//	fo(i,1,n) printf("%d %d\n",dp1[i],dp2[i]);
	fo(i,1,n)
	{
		if(dp1[i-1]+dp2[i+1]==k-1&&s[i]=='o')
		{
			ans[++cnt]=i;
		}
	}
	fo(i,1,cnt) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4160
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    D = int(input().strip())
    C = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    S = np.empty((D, 26), dtype=np.int32)
    for i in range(D):
        s = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
        S[i, :] = s[:]
    T = np.array([int(input().strip()) for i in range(D)], dtype=np.int32)
    return D, C, S, T


@njit
def satisfaction(d, C, S, T, last):
    v = 0
    v += S[d, T[d]-1]
    last[T[d]-1] = d+1
    for i in range(26):
        v -= C[i] * ((d+1) - last[i])
    return v


@njit
def solve(D, C, S, T):
    last = np.zeros(26, dtype=np.int32)
    cumsat = 0
    for i in range(D):
        sat = satisfaction(i, C, S, T, last)
        cumsat += sat
        print(cumsat)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 111852
n = int(input())
a = list(map(int, input().split()))

cnt = 0

for i in range(n):
    minj = i
    for j in range(i, n):
        if a[j] < a[minj]:
            minj = j
    a[i], a[minj] = a[minj], a[i]
    if i != minj:
        cnt += 1
print(" ".join(map(str, a)))
print(cnt)


Measured memory_bytes: 5600
#include<iostream>
    #include<cmath>
    #include<string.h>
    #include<stdio.h>
    #include<algorithm>
    using namespace std;
     
    struct node
    {
    	int num,next;
    	long long v;
    };
     
    node e[400011];
    int edge[200011];
    int taile;
     
    void add(int xx,int yy,long long vv)
    {
    	e[taile].num=yy;
    	e[taile].v=vv;
    	e[taile].next=edge[xx];
    	edge[xx]=taile++;
    }
     
     
    int r,c,n;
     
    bool cover[200011];
    long long a[200011];
     
    long long m1,m2;
     
    bool dfs(int now,long long val)
    {
    	cover[now]=1;
    	a[now]=val;
    	if(now<=r)
    	{
    		m1=min(m1,a[now]);
    	}
    	else
    	{
    		m2=min(m2,a[now]);
    	}
    	
    	int i;
    	for(i=edge[now];i!=-1;i=e[i].next)
    	{
    		if(cover[e[i].num]==0)
    		{
    			if(!dfs(e[i].num,e[i].v-a[now]))
    			{
    				return false;
    			}
    		}
    		else
    		{
    			if(e[i].v!=a[now]+a[e[i].num])
    			{
    				return false;
    			}
    		}
    	}
    	return true;
    }
     
    int main()
    {
    	int i,j,k;
    	int xx,yy,zz;
    	
    	scanf("%d %d",&r,&c);
    	scanf("%d",&n);
    	
    	taile=1;
    	memset(edge,-1,sizeof(edge));
    	
    	for(i=1;i<=n;i++)
    	{
    		scanf("%d %d %d",&xx,&yy,&zz);
    		add(xx,yy+r,zz);
    		add(yy+r,xx,zz);
    	}
    	
    	memset(cover,0,sizeof(cover));
    	
    	for(i=1;i<=r+c;i++)
    	{
    		if(cover[i]==0)
    		{
    			m1=m2=0x3f3f3f3f;
    			if(!dfs(i,0))
    			{
    				cout<<"No"<<endl;
    				return 0;
    			}
    			
    			if(m1+m2<0)
    			{
    				cout<<"No"<<endl;
    				return 0;
    			}
    		}
    	}
    	
    	
    	cout<<"Yes"<<endl;
    	return 0;
    }

Measured memory_bytes: 9088
// 1_7_B
#include<stdio.h>

int main(void)
{
	int n, x, i, j, cnt;
	while(1){
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0){
			return 0;
		}

		for(i = 1, cnt = 0; i < n+1; i++){
			for(j = 1; j < n+1; j++){
				if(i < j && j < (x-i-j) && (x-i-j) <= n){
					cnt += 1;
				}
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 600
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    double ans=0;
    while(n--){
        double A;
        string s;
        cin>>A>>s;
        if(s=="JPY"){ans+=A;}
        else{ans+=A*380000;}
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    return 0;
}


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

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

    vector<int> p(N);
    for (int i = 0; i < N; ++i) {
        cin >> p[i];
    }

    vector<int> s(p.begin(), p.end());
    sort(s.begin(), s.end());

    int diff = 0;
    for (int i = 0; diff <= 2 && i < N; ++i) {
        if (s[i] != p[i]) {
            ++diff;
        }
    }

    cout << (diff <= 2 ? "YES" : "NO") << endl;

    return 0;
}



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

#define ll long long
#define ull unsigned long long

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll N;
    string S;
    ll r = 0, g = 0, b = 0;
    ll invalid = 0;
    ll lastI, lastJ, lastK;
    ll count = 0;
    cin >> N;
    cin >> S;
    for(const char &c: S) {
        switch(c) {
            case 'R':
                r += 1;
                break;
            case 'G':
                g += 1;
                break;
            case 'B':
                b += 1;
                break;
        }
    }
    count = r * g * b;
    for(ll i = 0;i < N;i++) {
        for(ll j = i;j < N;j++) {
            char a = S[i];
            char b = S[j];
            ll cIndex = 2 * j - i;
            if(cIndex < N) {
                if(a != b && S[cIndex] != a && S[cIndex] != b) count -= 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3628
using System;

namespace B___Training_Camp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            Console.WriteLine(f(N));
        }

        static long f(int n)
        {
            long sum = 1;

            for (int i = 1; i <= n; i++)
                sum = (sum * i) % (int)(Math.Pow(10, 9) + 7);

            return sum;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	int arr[MaxN];
	pair <int,int> par[MaxN];
	void solve(){
		lli N,i,j,p,q,res=0;
		N=5;
		for(i=0;i<N;i++){
			cin>>arr[i];
			par[i].fst=((10-arr[i]%10))%10;
			par[i].snd=arr[i];
		}
		sort(par,par+N);
		for(i=0;i<N;i++){
			res+=par[i].snd;
			//cout<<par[i].fst<<" "<<par[i].snd<<"\n";
			if(i==N-1)break;
			res+=par[i].fst;
		}
		cout<<res;
		
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 256
import math
import itertools
N = int(input())
P = list(input().split())
Q = list(input().split())

num = []
numset = []
for i in range(N):
    num.append(i + 1)
num = [str(_) for _ in num]
numset = list(itertools.permutations(num, N))
Pn = 1
Qn = 1
cnt = 1
for a in list(itertools.permutations(num, N)):
    if P == list(a):
        Pn = cnt
    if Q == list(a):
        Qn = cnt
    cnt += 1
print(abs(Pn-Qn))


Measured memory_bytes: 12788
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#endif
int main() {
    string str;
    cin >> str;

    string ans;

    for (ll i = 0; i < str.size(); ++i) {
        switch (str[i]) {
            case '0': ans += '0'; break;
            case '1': ans += '1'; break;
            case 'B':
                if (ans.size() > 0) {
                    ans.erase(ans.size() - 1);
                }
                break;
        }
    }

    PR(ans);
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll n,p; string s;
bool pp(string x)
{
	ll y=x.size();
	rep(i,0,y/2)
	if(x[i]!=x[y-i-1])
	return false;
	
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll m,k,g,i,ans,l;
    	cin>>l;
    	cout<<fixed<<setprecision(15);
    	l=l*l*l;
    	lld x=(l*1.00)/(27*1.0);
    	cout<<x;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200100
using namespace std;
const int INF=1008610086;
const int MOD=1e9+7;
inline void read(int &a){
	int f=a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=1;ch=getchar();}
	while(ch<='9'&&ch>='0') a=a*10+ch-'0',ch=getchar();
	if(f) a=-a;
}
struct Node{
	int x,v,l,r;
}a[N];
inline bool cmpx(Node a,Node b){
	return a.x<b.x;
}
inline bool cmpv(Node a,Node b){
	return a.v<b.v;
}
int n,f[N];
int xds[N<<2];
inline int lowbit(int a){return a&-a;}
inline int q(int x){
	int ans=0;
	for(int i=x;i;i-=lowbit(i)) ans+=xds[i],ans%=MOD;
	return ans;
}
inline int query(int x,int y){
	return (q(y)-q(x-1)+MOD)%MOD;
}
inline void xg(int x,int v){
	for(int i=x;i<=n+2;i+=lowbit(i)) xds[i]+=v,xds[i]%=MOD; 
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		read(a[i].x);
		read(a[i].v);
	}
	sort(a+1,a+n+1,cmpv);
	for(int i=1;i<=n;i++) a[i].v=i;
	sort(a+1,a+n+1,cmpx);
	int ma=-INF,mi=INF;
	for(int i=1;i<=n;i++){
		ma=max(ma,a[i].v);
		a[i].r=ma;
	}
	for(int i=n;i;i--){
		mi=min(mi,a[i].v);
		a[i].l=mi;
	}
	int l=0;
	xg(1,1);
	a[0].l=1;
	a[n+1].l=a[n+1].r=n+1;
	for(int i=1;i<=n+1;i++){
		while(l<i&&a[i].l>a[l].r+1) l++;
		f[i]=query(l+1,i+1);
		xg(i+1,f[i]);
	}
	printf("%d\n",f[n+1]);
	return 0;
}

Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,a,b,c,d;
long long
 ue[500005];
long long sita[500005];
int main()
{
	cin>>n>>a>>b>>c>>d;
	b-=a;
	ue[0]=(n-1)*d;
	sita[0]=(n-1)*c;
	rep2(i,1,n)
	{
		ue[i]=ue[i-1]-d-c;
		sita[i]=sita[i-1]-d-c;
	}
	rep(i,n)
	{
		if(sita[i]<=b&&b<=ue[i])
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 8064
N = int(input())
A = list(map(int, input().split())) + [None]
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    a = A[i]
    ans += B[a-1]
    if A[i+1] == a+1:
        ans += C[a-1]
    
print(ans)      


Measured memory_bytes: 38292
N,C=(int(i) for i in input().strip().split(" "))
D=[]
c=[]
for i in range(C):
    D.append([int(i) for i in input().strip().split(" ")])
for i in range(N):
    c.append([int(i) for i in input().strip().split(" ")])
from collections import defaultdict
d0=defaultdict(int)
d1=defaultdict(int)
d2=defaultdict(int)
d=[d0,d1,d2]
for i in range(N):
    for j in range(N):
        d[(i+j+2)%3][c[i][j]]+=1

from itertools import permutations
l=list(range(1,C+1))
k=permutations(l,3)
m=999999999999999999999999
for p in k:
    w=0
    a0,a1,a2=p
    for i in d[0].keys():
        w+=(D[i-1][a0-1]*(d[0][i]))
    for i in d[1].keys():
        w+=(D[i-1][a1-1]*(d[1][i]))
    for i in d[2].keys():
        w+=(D[i-1][a2-1]*(d[2][i]))
    if w<m:
        m=w
print(m)




Measured memory_bytes: 76724
#include<iostream>
#include<cstring>
#include<queue>

using namespace std;

struct enter{
  int x,y,cost;
};

int main()
{
  int use[200][200],wall[200][200];
  int t,n,x,y,sx,sy;
  int dx[] = { 0, 1, 1, 0, -1, -1 };
  int dy[] = { 1, 1, 0, -1, -1, 0 };


  while(cin>>t>>n)
    {
      if(t==0&&n==0)
	break;

      memset(use,0,sizeof(use));
      memset(wall,0,sizeof(wall));

      for(int i=0;i<n;i++)
	{
	cin>>x>>y;
	wall[x+100][y+100]=1;
	}

      cin>>sx>>sy;

      queue<enter> q;
      enter f;
      f.x=sx+100;f.y=sy+100;f.cost=0;
      q.push(f);
      use[f.x][f.y]=1;
      int ans=1;

      while(!q.empty())
	{
	  enter now=q.front();
	  q.pop();

	  for(int i=0;i<6;i++)
	    {
	      int x=now.x+dx[i],y=now.y+dy[i];
	    if(!use[x][y]&&!wall[x][y]&&(t>now.cost))
	      {
		//cout<<x<<' '<<y<<endl;
		ans++;
		enter p__;
		p__.x=x;p__.y=y;p__.cost=now.cost+1;
		q.push( p__ );
		use[x][y]=1;
	      }

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

Measured memory_bytes: 1232
N = int(input())
A = 0
W = 0
T = 0
R = 0
for i in range(N):
  S = input()
  if S == "AC":
    A += 1

  elif S == "WA":
    W += 1
  
  elif S == "TLE":
    T += 1

  else:
    R += 1

print("AC x "+str(A))
print("WA x "+str(W))
print("TLE x "+str(T))
print("RE x "+str(R))

Measured memory_bytes: 9208
l1 = list(map(int,input().split()))
while l1[0] > 0 and l1[2] > 0:
    l1[2] -= l1[1]
    if l1[2] <= 0:
        answer = "Yes"
        break
    l1[0] -= l1[3]
    if l1[0] <= 0:
        answer = "No"
        break
print(answer)

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

void solve() {
    int n, m;
    cin >> n >> m;
    cout << (n * (n - 1) + m * (m - 1))/ 2;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int ans=0;
  string s1;
  cin >> s1;
  REP(i,(s1.length()+1)/2){
    if (s1[i] != s1[s1.length()-i-1]) ans++;
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;
typedef pair<int,int> P;

bool myCompare(P lhs,P rhs){
	return lhs.second < rhs.second;
}

int bridgeList[100000];

void init(){
	for(int i = 0; i < 100000; i++){
		bridgeList[i] = 0;
	}
}

int main()
{
	init();
	vector<P> hostileIslandList;
	int N,M;
	cin>>N>>M;
	for(int i = 0; i < M; i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		hostileIslandList.push_back(P(a,b));
	}
	sort(hostileIslandList.begin(),hostileIslandList.end(),myCompare);
	int count = 0;
	for(int i = 0; i < M; i++){
		int leftEnd = hostileIslandList[i].first;
		int rightEnd = hostileIslandList[i].second;
		for(int j = leftEnd; j < rightEnd; j++){
			if( bridgeList[j] == 1){
				break;
			}else if( j == rightEnd - 1){
				bridgeList[j] = 1;
				count++;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int sum=0;
    while(x>=500)
    {
        x=x-500;
        sum=sum+1000;
    }

    while(x>=5)
    {
        x=x-5;
        sum=sum+5;
    }
    cout<<sum;

}


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

int main(){
  int n; cin >> n;
  ll d; cin >> d;
  vector<ll> x(n), y(n);
  rep(i, n){
    cin >> x[i] >> y[i];
  }
  int ans = 0;
  rep(i, n){
    if(x[i] * x[i] + y[i] * y[i] <= d * d){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<bool> gyou(H,false),retu(W,false);
  vector<vector<char>> table(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> table.at(i).at(j);
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(table.at(i).at(j)=='#'){
        gyou.at(i)=true;
        break;
      }
    }
  }

  for(int j=0;j<W;j++){
    for(int i=0;i<H;i++){
      if(table.at(i).at(j)=='#'){
        retu.at(j)=true;
        break;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(gyou.at(i)==true){
        if(retu.at(j)==true){
          cout << table.at(i).at(j);
        }
      }
    }
    if(gyou.at(i)==false){
      continue;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] pri = new boolean[10001];
		for(int i=2;i<10001;i++) pri[i] = true;
		for(int i=2;i<10001;i++){
			for(int j=i+i;j<10001;j+=i){
					pri[j]=false;
			}
		}

		int[] m = new int[1229];
		int sum = 0;
		for(int i=2;i<10001;i++){
			if(pri[i]==true){
				m[sum] = i;
				sum++;
			}
		}
		
		int[] ans = new int[10001];
		for(int i=0;i<1229;i++){
			sum = 0;
			for(int j=i;j>=0;j--){
				sum += m[j];
				if(sum>10000) break;
				ans[sum]++;
			}
		}
		
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			System.out.println(ans[n]);
		}
	}
	
}

Measured memory_bytes: 20680