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

int main()
{
  int N;

  cin >> N;

  for (int i = 0; i < 3; i++)
  {
    if (N % 10 == 7)
    {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }

  cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card
{
	char suit;
	int value;
};

struct Card L[MAX / 2+2], R[MAX / 2+2];

void merge(struct Card A[] , int n,int left, int mid, int right)
{
	int i,j,k;
	int n1 = mid - left;
	int n2 = right - mid;
	for(i=0;i<n1;i++)L[i] = A[left +i];
	for(i=0;i<n2;i++)R[i] = A[mid +i];
	L[n1].value = R[n2].value = SENTINEL;
	i=j=0;
	for(k = left;k < right;k++)
	{
		if(L[i].value <= R[j].value)
		{
			A[k] = L[i++];
		}
		else
		{
			A[k]=R[j++];
		}
	}
}

void mergeSort(struct Card A[],int n,int left,int right)
{
	int mid;
	if(left+1 < right)
	{
		mid= (left + right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int partition (struct Card A[],int n,int p,int r)
{
	int i,j;
	struct Card t,x;
	x=A[r];
	i=p-1;
	for (j=p; j < r; j++)
	{
		if(A[j].value <= x.value)
		{
			i++;
			t = A[i]; A[i]=A[j]; A[j]=t;
		}
	}
	t=A[i+1]; A[i+1]=A[r]; A[r]=t;
	 return i+1;
}

void quickSort(struct Card A[],int n,int p,int r)
{
	int q;
	if(p<r)
	{
		q = partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main()
{
	int n,i,v;
	struct Card A[MAX],B[MAX];
	char S[10];
	int stable=1;

	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s %d",S,&v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}

	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);

	for(i=0;i<n;i++)
	{
		if(A[i].suit != B[i].suit) stable =0;
	}

	if(stable == 1) printf("Stable\n");
	else printf("Not stable\n");
	for(i=0;i<n;i++)
	{
		printf("%c %d\n", B[i].suit, B[i].value);
	}

	return 0;
}

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

int main() {
    string s[] = {
        "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
    };
    string ans;
    cin >> ans;
    int a = 0;
    for (int i = 0; i < 7; i++)
    {
        if(s[i] == ans) {
            a = 7 - i;
        }
    }
    cout << a << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


Measured memory_bytes: 3636
'use strict'

function main(input) {
    input = input.split('\n')
    const troops = input[1].split('')
    const n = Number(input[0])
    let min, cnt = 0

    let countsE = [0]
    let countsW = [0]
    for (let i = 1; i <= n; i++) {
        countsW[i] = (troops[i - 1] == 'W') ? countsW[i - 1] + 1 : countsW[i - 1];
        countsE[i] = (troops[i - 1] == 'E') ? countsE[i - 1] + 1 : countsE[i - 1];
    }

    for (let i = 0; i < n; i++) {

        cnt = countsW[i] + countsE[n] - countsE[i + 1]
        min = (min < cnt) ? min : cnt
    }

    console.log(min)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    
    int a , b, c;
    cin >> a >> b >> c;
    
    int count = 0;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }
    
    cout << count << endl;
    
    
        
        
    
    
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000

int gcd(int a,int b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
int main(){
//入力
int x[N_MAX];
int N,X;
int ans=0;

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


    for(int i=0;i<N;i++){
        ans= gcd(ans,abs(x[i]-X));
    }

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

Measured memory_bytes: 3808
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

typedef long long ll;

ll func(ll b,ll n)
{
    if(n<b) return n;
    else{
        return func(b, n/b)+n%b;
    }
}

int main()
{
    ll n,s;
    cin >> n >> s;
    if(n==s){
        cout << n+1;
        return 0;
    }
    for(ll i=2; i<=ll(sqrt(n)); i++){
        if(func(i, n)==s){
            cout << i;
            return 0;
        }
    }
    for(ll i=ll(sqrt(n)); i>=1; i--){//上位桁について
        ll b=(n-s)/i+1;
        if(b<2) break;
        if(func(b,n)==s){
            cout << b;
            return 0;
        }
    }
    cout << -1;

    return 0;
}

Measured memory_bytes: 256
# Python3 program to count
# number of factors
# of an array of integers
MAX = 1000005

# array to store
# prime factors
factor = [0]*(MAX + 1)

# function to generate all
# prime factors of numbers
# from 1 to 10^6


def generatePrimeFactors():
    factor[1] = 1

    # Initializes all the
    # positions with their value.
    for i in range(2, MAX):
        factor[i] = i

    # Initializes all
    # multiples of 2 with 2
    for i in range(4, MAX, 2):
        factor[i] = 2

    # A modified version of
    # Sieve of Eratosthenes
    # to store the smallest
    # prime factor that divides
    # every number.
    i = 3
    while(i * i < MAX):
        # check if it has
        # no prime factor.
        if (factor[i] == i):
            # Initializes of j
            # starting from i*i
            j = i * i
            while(j < MAX):
                # if it has no prime factor
                # before, then stores the
                # smallest prime divisor
                if (factor[j] == j):
                    factor[j] = i
                j += i
        i += 1

# function to calculate
# number of factors


def calculateNoOFactors(n):
    if (n == 1):
        return 1
    ans = 1

    # stores the smallest
    # prime number that
    # divides n
    dup = factor[n]

    # stores the count of
    # number of times a
    # prime number divides n.
    c = 1

    # reduces to the next
    # number after prime
    # factorization of n
    j = int(n / factor[n])

    # false when prime
    # factorization is done
    while (j > 1):
        # if the same prime
        # number is dividing
        # n, then we increase
        # the count
        if (factor[j] == dup):
            c += 1

        # if its a new prime factor
        # that is factorizing n,
        # then we again set c=1 and
        # change dup to the new prime
        # factor, and apply the formula
        # explained above.
        else:
            dup = factor[j]
            ans = ans * (c + 1)
            c = 1

        # prime factorizes
        # a number
        j = int(j / factor[j])

    # for the last
    # prime factor
    ans = ans * (c + 1)

    return ans
# Driver Code


if __name__ == "__main__":

    # generate prime factors
    # of number upto 10^6
    generatePrimeFactors()
    # a = [10, 30, 100, 450, 987]
    # q = len(a)
    s=0
    for i in range(1, int(input())):
        s+=(calculateNoOFactors(i))
    print(s)

# This code is contributed
# by mits.


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int H, W, K;
    cin >> H >> W >> K;

    vector< string > s(H);
    cin >> s;

    auto ans = make_vector(H, W, 0);
    int cnt = 0;
    range(i, 0, H) range(j, 0, W) {
        if (s[i][j] == '#') {
            cnt++;
            ans[i][j] = cnt;
        }
    }

    range(i, 0, H) range(j, 1, W) {
        if (!ans[i][j]) ans[i][j] = ans[i][j - 1];
    }
    range(i, 0, H) rrange(j, 1, W) {
        if (!ans[i][j - 1]) ans[i][j - 1] = ans[i][j];
    }

    range(j, 0, W) range(i, 1, H) {
        if (!ans[i][j]) ans[i][j] = ans[i - 1][j];
    }
    range(j, 0, W) rrange(i, 1, H) {
        if (!ans[i - 1][j]) ans[i - 1][j] = ans[i][j];
    }

    range(i, 0, H) cout << ans[i] << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1280
N = int(input())
sum_ = 0
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        sum_ += 0
    elif i % 3 == 0:
        sum_ += 0
    elif i % 5 == 0:
        sum_ += 0
    else:
        sum_ += i
print(sum_)

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1e9+7;

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

#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

int main(){
    int N,R;
    cin>>N>>R;
    if(N>=10){
        cout<<R<<endl;
    }else{
        cout<<R+100*(10-N)<<endl;
    }
    return 0;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;

typedef pair<int,int> pii;
priority_queue<pii,vector<pii>,greater<pii> > q1;
priority_queue<pii,vector<pii>,greater<pii> > q2;
int n,m;
pii a[N];
int vis[N];
int cnt;

int main(){
   scanf("%d%d",&n,&m);
   for(int i = 1;i <= n; ++i){
      scanf("%d%d",&a[i].first,&a[i].second);
   }
   sort(a+1,a+n+1);
   for(int i = 1;i <= n; ++i){
      if(!a[i].first){
         q2.push(pii(a[i].second,a[i].first));
         continue ;
      }
      if(cnt < a[i].first){
         vis[++cnt] = 1;
         q1.push(pii(a[i].second,a[i].first));
      }
      else {
         if(q1.top().first < a[i].second){
            q2.push(q1.top()); q1.pop();
            q1.push(pii(a[i].second,a[i].first));
         } else {
            q2.push(pii(a[i].second,a[i].first));
         }
      }
   }
   int res = cnt;
   for(int i = cnt+1;i <= m; ++i){
      while(i <= m && !q2.empty() && q2.top().first > i)++i;
      if(i > m || q2.empty())break;
      ++res;
      q2.pop();
   }
   printf("%d\n",n-res);
   return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1000111;

const ll MOD = 1000000007LL;

void solve() {

}

int n;
unordered_map<string, ll> mp;

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

    cin >> n;
    for (int i=0; i<n; i++) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0LL;
    for (auto x: mp) {
        ll v = x.second;
        ans += (v*(v-1))/2;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 10660
n = int(input())
h = list(map(int, input().split()))
h = h[::-1]

for i in range(1, n):
    dh = h[i] - h[i - 1]
    if dh == 1:
        h[i] -= 1
    elif dh > 1:
        print('No')
        exit()

print('Yes')     

Measured memory_bytes: 20580
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <sstream>

using namespace std;
typedef long long Long;
typedef long double Double;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef pair<Long,Long> PLL;

int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(Long &x) { return scanf("%lld", &x); }
int read(Long &x, Long &y) { return scanf("%lld%lld", &x, &y); }
int read(double &x) { return scanf("%lf", &x); }
char buff[2000010];
int read(string &s) { int r = scanf("%s", buff); s = buff; return r; }

#define dlog2(n) ((n) == -1 ? 0 : (31-__builtin_clz(n)))

#define sz(a) int(a.size())

struct Math
{
	typedef long long Long;
	static int egcd(int a, int b){
		int x,y;
		return egcd(a,b,x,y);
	}
	// ax + by = c
	static int egcd(int a,int b, int &x, int &y) {
		x = 1, y = 0;
		int nx = 0, ny = 1;
		int nr = b, r = a;
		while(nr != 0) {
			int q = r / nr;
			tie(r, nr) = make_tuple(nr, r - q*nr);
			tie(x, nx) = make_tuple(nx, x - q*nx);
			tie(y, ny) = make_tuple(ny, y - q*ny);
		}
		// bezout = x , y
		// gcd    = o_r
		return r;
	}
	static int MOD;
	static Long modInv(Long a, Long b)
	{
		int x,y; egcd(a,b,x,y);
		return x < 0 ? x + b : x;
	}
	static Long divide(Long a, Long b)
	{
		return a * modInv(b, MOD) % MOD;
	}
	static int fact(int n)
	{
		static vector<int> F;
		if(F.size() <= n)
		{
			int oSZ = F.size();
			F.resize(n+1);
			if(oSZ == 0)F[0] = 1 , oSZ++;
			for(int i = oSZ; i <= n; ++i)
				F[i] = (1LL * F[i-1] * i) % MOD;
		}
		return F[n];
	}
	static int catalan(int n)
	{
		return divide(ncr(2*n,n), n+1);
	}
	static int ncr(int n,int k)
	{
		if(k < 0 || n < 0 || n < k)return 0;
		return divide(fact(n) , (1LL * fact(k) * fact(n-k)) % MOD);
	}
	static int mul(int a,int b){
		return (1LL*(a%MOD)*(b%MOD))%MOD;
	}
	static int  mul(int a,int b,int c){
		return (1LL*mul(a,b)*(c%MOD))%MOD;
	}
	static int  mul(int a,int b,int c,int d){
		return (1LL*mul(a,b)*mul(c,d))%MOD;
	}
	static bool solveDiophantine(int a, int b, int c, int &x, int &y) {
		int gc = egcd(a,b,x,y);
		if(c % gc != 0)return false;
		int d = c / gc;
		x *= d;
		y *= d;
		return true;
	}
	static void moveBezout(int a,int b, int c, int &x, int &y, int pos = 1){
		int gc = egcd(a,b);
		b /= gc;
		a /= gc;
		x += b * pos;
		y -= a * pos;
	}
};
int Math::MOD = 1000000007;

int main() {

	int X, Y;
	read(X, Y);
	if (X < Y) swap(X, Y);
	if (X > 2*Y || (X + Y) % 3 != 0) {
		cout << 0 << endl;
	} else {
		int mvs = (X + Y) / 3;
		int hor = X - Y;
		cout << Math::ncr(mvs, (mvs - hor) / 2) << endl;
	}

}
























Measured memory_bytes: 5480
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    ll n,m,q;cin>>n>>m>>q;
    ll x=min(m,q);
    if(x%m==0)x--;
    ll res=floor((n*x)/m);
    cout<<res;
}


Measured memory_bytes: 3648
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<long long> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define no "NO"
#define yes "YES"
#define con continue;
 

 
int main()
{
    ios_base::sync_with_stdio(false);
    
    LL n;
    cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
		
    return 0;
    
    
 
 
}


Measured memory_bytes: 3604
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.collections.HashSet
import kotlin.math.*
fun main(){
    var fs = CodeForces.FastReader()
    var n = fs.nextInt()
    if(n%1000 == 0) println("0")
    else println(1000 - n%1000)
}

class CodeForces {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 34344
#include<stdio.h>

int BubbleSort(int [],int n);

int main()
{
  int n;
  int i;
  int A[110];
  int cnt=0;
  
  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&A[i]);
  }

  cnt = BubbleSort(A,n);
  printf("%d\n",cnt);
  return 0;
}

int BubbleSort(int A[],int n)
{
  int i,j;
  int cnt = 0;
  int temp;
  
  for(i=0;i < n;i++){
    for(j=n-1;j > i;j--){
      if(A[j-1] > A[j]){
	temp = A[j-1];
	A[j-1] = A[j];
	A[j] = temp;
	cnt++;
      }
    }
  }
  
  for(i=0;i < n;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  
  return cnt; 
}



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

int h,n,a,sum;

int main()
{
	scanf("%d %d",&h,&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a);
		sum+=a;
	}
	printf(sum>=h?"Yes":"No");
}

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

int main() {
  int N , K, totalMoveValue = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    int robotA, robotB;
    robotA = x * 2;
    robotB = abs((x - K) *2);     
    totalMoveValue += min(robotA, robotB);
  }
  
  cout << totalMoveValue << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma warning( disable : 4996 )
#define ll long long
#define pb push_back
#define endl '\n'
#define fastIO cin.tie( 0 );ios_base::sync_with_stdio( false )
#define pii pair<int, int>
#define eps 1e-13
#define N 100005

using namespace std;

int n, num[N];

inline void init()
{
    int tmp = 0, min0 = ((1 << 30) - 1) * 2;
    ll sum = 0;
    cin >> n;
    for ( int i = 0; i < n; ++i ) {
        cin >> num[i];
        min0 = min( min0, abs( num[i] ));
        sum += abs( num[i] );
        if ( num[i] < 0 )
            ++tmp;
    }
    cout << sum - (tmp & 1 ? 2 * min0 : 0) << endl;
}

inline void solve()
{

}

int main()
{
    fastIO;
    init();
    solve();

    return 0;
}

Measured memory_bytes: 640
import Control.Monad
import Data.Char
main = do
    (x:xs) <- map digitToInt <$> getLine
    let exprs = foldM (\(acc,top) cur -> [(acc+top,cur),(acc,10*top+cur)]) (0,x) xs
        ans = sum $ map (uncurry (+)) exprs    
    print ans

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n) {
    if (s[i] == 'R') a[i] = 0;
    if (s[i] == 'G') a[i] = 1;
    if (s[i] == 'B') a[i] = 2;
  }
  vector<ll> cnt(3);
  rep(i,n) cnt[a[i]]++;
  ll ans = 1;
  rep(i,3) ans *= cnt[i];
  rep(j,n)rep(i,j) {
    int k = j + (j-i);
    if (k < n) {
      if (a[i] == a[j]) continue;
      if (a[i] == a[k]) continue;
      if (a[k] == a[j]) continue;
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
}

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

int main(void) {
    ll L, R;
    cin >> L >> R;

    ll ans = 2018;
    for(ll i=L;i<=R;i++) {
        for(ll j=i+1;j<=R;j++) {
            ans = min(ans, (i*j)%2019);
            if(ans==0) {
                cout << ans << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>

using namespace std;

int n,ans;

map<string,int> m;

string wee[1000000],type[1000000];

int con,cnt;

int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    string now;
    cin>>now;
    m[now]++;
    if(m[now]==1)
    {
      type[++con]=now;
    }
    ans=max(ans,m[now]);
  }
  for(int i=1;i<=con;i++)
  {
    if(m[type[i]]==ans) wee[++cnt]=type[i];
  }
  sort(wee+1,wee+cnt+1);
  for(int i=1;i<=cnt;i++)
  {
    cout<<wee[i]<<endl;
  }
}


Measured memory_bytes: 40832
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var nk = Sarray();
            var pn = Sarray().OrderBy(x => x).ToArray();
            var ans = 0;
            for(var i=0;i<nk[1];i++)
            {
                ans += pn[i];
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 19668
#include<bits/stdc++.h>
using namespace std;
struct Node{
	int dad;
	long long cnt;
}node[200005];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n-1;i++){
		int son,f;
		cin>>f;
		cin>>son;
		node[son].dad=f;
		//cout<<son<<node[son].dad<<endl;
	}
	for(int i=0;i<m;i++){
		int ans;
		cin>>ans;
		int b;
		cin>>b;
		node[ans].cnt+=b;
	}
	cout<<node[1].cnt;
	for(int i=2;i<=n;i++){
		node[i].cnt+=node[node[i].dad].cnt;
		
		cout<<" "<<node[i].cnt;
	}
	cout<<endl;
}


Measured memory_bytes: 5504
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
//#include<ext/rope>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
#define maxn 200005
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
const double PI=acos(-1.0);
const double eps=1e-6;
struct Edge
{
	int to,nxt;
}edge[2*maxn];
int K,cnt,head[maxn];
ll col[maxn];
const ll mod=1e9+7;
void addedge(int u,int v)
{
	edge[cnt].to=v;
	edge[cnt].nxt=head[u];
	head[u]=cnt++;
	return;
}
void DFS(int u,int fa,int dep)
{
    if(dep==1){
        int cnt=0;
        for(int k=head[u];k!=-1;k=edge[k].nxt){
            int v=edge[k].to;
            if(v==fa) continue;
            //printf("v=%d\n",v);
            cnt++;
            //printf("cnt=%d\n",cnt);
            col[v]=(ll)K-cnt;
            DFS(v,u,dep+1);
        }
    }
    else{
        int cnt=0;
        for(int k=head[u];k!=-1;k=edge[k].nxt){
            int v=edge[k].to;
            if(v==fa) continue;
            cnt++;
            col[v]=(ll)K-1-cnt;
            DFS(v,u,dep+1);
        }
    }
    return;
}
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
signed main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n=read();
    K=read();
    memset(head,-1,sizeof(head));
    for(int i=1;i<=n-1;i++){
        int u=read(),v=read();
        addedge(u,v);
        addedge(v,u);
    }
    col[1]=(ll)K;
    DFS(1,0,1);
    //for(int i=1;i<=n;i++) printf("%lld ",col[i]);
    //cout<<endl;
    ll ans=1LL;
    for(int i=1;i<=n;i++) ans=((ans%mod)*(col[i]%mod)%mod);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11340
#include <stdio.h>
int main(void) {
  int X;
  int Y;
  int Z;

  int tmp;

  scanf("%d", &X);
  scanf("%d", &Y);
  scanf("%d", &Z);
  tmp = X;
  X = Y;
  Y = tmp;

  tmp = X;
  X = Z;
  Z = tmp;

  printf("%d %d %d\n", X, Y, Z);
  return 0;
}

Measured memory_bytes: 1692
<?php
  fscanf(STDIN,"%d",$n);
function factorial_of($num){

    if($num>0) {
        return $num *= factorial_of($num-1);
    }

    return 1;
}

$chars = array();
$index = '';
 for($i=0;$i<$n;$i++){
   $char_li = str_split(trim(fgets(STDIN)));
   sort($char_li);
   for($j=0;$j<10;$j++) $index.=$char_li[$j];
   $chars[$index]++;
   $index = '';
 }
$sum = 0;

//print_r($chars);
foreach($chars as $v){
  if($v>=2){
    $sum += ($v*($v-1))/2;
    
  }
}

echo ($sum);

  

Measured memory_bytes: 13048
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int n;
cin>>n;
int x,y;
int cnt=0;
int ans=0;
while(n--)
{
cin>>x>>y;
if(x==y)
{
cnt++;
}
else
{
cnt=0;
}
ans=max(ans,cnt);
}
cout<<(ans>=3 ? "Yes" : "No")<<endl;
}

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



int main(){
    int n;
    cin >> n;
    vector<int> a;
    vector<ll> freq(n+1,0);
    rep(i,n){
        int A;
        cin >> A;
        a.push_back(A);
        freq[A]++;
    }

    ll sum = 0;
    rep(i,n+1){
        sum+=(freq[i])*(freq[i]-1)/2;
    }

    rep(i,n){
        if(freq[a[i]]>0)
        cout << sum - (freq[a[i]]*(freq[a[i]]-1))/2 + ((freq[a[i]]-1)*(freq[a[i]]-2))/2 << endl;
        else
        cout << sum - (freq[a[i]]*(freq[a[i]]-1))/2 << endl;
        
    }
}


Measured memory_bytes: 5108
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
using namespace std;
int main()
{
    int n,k;

    cin >> n>>k;

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

    int x = key;
    int y = n - 1 - key;
    int sum = 0;
    if (x >= k - 1) {
       // sum += (x + k-2) / (k-1);
        sum += x / (k - 1);
        if (x % (k - 1) == 0) {
          
        }
        else {
            sum++;
        }
       // sum += (y + k-2) / (k-1);
        sum += y / (k - 1);
        if (y % (k - 1) == 0) {

        }
        else {
            sum++;
        }
    }
    else {
        sum++;
        y -= (k - 1 - x);
        sum += y / (k - 1);
        //sum += (y + k - 2) / (k - 1);
        if (y % (k - 1) == 0) {

        }
        else {
            sum++;
        }
    }

    //cout << sum << endl;
    int ans = 0;
    if ((n - 1) % (k - 1) == 0) {
        ans = (n - 1) / (k - 1);
    }
    else {
        ans = (n - 1) / (k - 1) + 1;
    }

    cout << ans << endl;

    return 0;
    


}



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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    int m, n; cin >> m >> n;
    if (m == n) cout << "Yes";
    else cout << "No";
}

void solveB() {
    int a, b; cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 0; i < b; i++) cout << a;
}

void solveC() {
    int n; cin >> n;
    int minn = 1e9, res = 0;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] <= minn) res++;
        minn = min(a[i], minn);
    }
    cout << res;
}

const int maxN = 1e6 + 1;
const long long MOD = 1e9 + 7;
int prime[maxN];

void Seive() {
    for (int i = 2; i < 1000; i++) {
        if (prime[i] == 0) {
            for (int j = i * i; j < maxN; j += i) prime[j] = i;
        }
    }
    for (int i = 2; i < maxN; i++) {
        if (prime[i] == 0) prime[i] = i;
    }
}

long long Pow(int b, int e = MOD - 2){
    if (e == 0) return 1LL;
    long long x = Pow(b, e / 2);
    if (e % 2 == 0) return x * x % MOD;
    return (x * x % MOD) * b % MOD;
}

void solveE() {
    Seive();
    int n; cin >> n;
    int arr[n];
    map<int, int> M;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        int tmp = arr[i];
        while (tmp != 1) {
            int c = 0;
            int p = prime[tmp];
            while (tmp % p == 0) {
                tmp /= p;
                c++;
            }
            M[p] = max(M[p], c);
        }
    }
    long long lcm = 1;
    for (auto i : M) {
        //cout << i.first << ' ' << i.second << '\n';
        lcm = lcm * Pow(i.first, i.second) % MOD;
    }
    long long res = 0;
    //cout << lcm << ' ';
    for (int i = 0; i < n; i++) {
        res = (res + lcm * Pow(arr[i])) % MOD;
    }
    cout << res;
}

int getFirst(int a) {
    while (a >= 10) a /= 10;
    return a;
}

int getLast(int a) {
    return a % 10;
}

void solveD() {
    int n; cin >> n;
    int arr[100];
    memset(arr, 0, sizeof(arr));
    for (int i = 1; i <= n; i++) {
        int ff = getFirst(i);
        int ll = getLast(i);
        arr[ff * 10 + ll]++;
    }
    long long res = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            res += arr[i * 10 + j] * arr[j * 10 + i];
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveD();
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[]=new int[n+1];
		for(int i=1;i<n;i++)arr[sc.nextInt()]++;
		for(int i=1;i<n+1;i++)System.out.println(arr[i]);
	}
}

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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A+N);
  int res = true;
  for (int i = 0; i < N-1; i++) {
    if (A[i] == A[i+1]) {
      res = false; break;
    }
  }
  if (res) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

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

typedef pair<int, int> P;
using ll = long long;
const int INF = 1e8;

int main() {
  string N;
  cin >> N;
  int idx = N.size() - 1;
  if (N[idx] == '3') {
    cout << "bon" << endl;
    return 0;
  }
  if (N[idx] == '0' || N[idx] == '1' || N[idx] == '6' || N[idx] == '8') {
    cout << "pon" << endl;
    return 0;
  }

  cout << "hon" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b, c, d, ans=0;
	cin >> a >> b >> c >> d;
	vi v(101, 0);
	range(i, a, b + 1)v[i]++;
	range(i, c, d + 1)v[i]++;
	rep(i, 101) {
		if (v[i] == 2)ans++;
	}
	cout << max(ans-1,0) << endl;
}

Measured memory_bytes: 256
import numpy as np
S = input().split(" ")
N = int(S[0])
M = int(S[1])

ARR = np.array([int(s) for s in input().split(" ")])


criterion = np.sum(ARR) / (4 * M)

res = ARR >= criterion

result = np.sum(res)

if result >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12444
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
 int r, tmp;
 if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
int main()
{
 	int n;
  	cin >> n;
  	cout << n*2/gcd(2,n) << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int T = sc.nextInt();
		int a[] = new int[T];
		for (int i=0;i<T;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.parallelSort(a);
		int start =0;
		int end =T-1;
		while (start!=end) {
			if (a[start]<a[end]) {
				a[end]-=a[start];
				a[start]=0;
			} else {
				a[start]-=a[end];
				a[end] =0;
			}
			if (a[start]==0&&a[end]==0&&start+1==end) {
				break;
			}
			if (a[start]==0) {
				start++;
			}
			if (a[end]==0) {
				end--;
			}
		}
		if (a[start]>1) {
			System.out.println(a[start]-1);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 35820
def func():
    N = int(input())
    B = list(map(int, input().split()))

    sum = 0
    for i in range(N):
        if i == 0:
            sum += B[0]
        elif i == N - 1:
            sum += B[N - 2]
        else:
            sum += min(B[i], B[i-1])

    print(sum)

if __name__ == '__main__':
    func()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#define lli long long int
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n, a, b;
    cin>>n>>a>>b;
    //8,3,4
    //7->3
    //8->4
    cout<<min(a, n%(a+b))+((n/(a+b))*a)<<endl;
    return 0;
}


Measured memory_bytes: 256
D, G = map(int, input().split())
prob = []
for i in range(D):
    p, c = map(int, input().split())
    prob.append((p, c))

ans_min = 10 ** 10
for i in range(2 ** D):
    flag = bin(i)[2:].zfill(D)
    p_max = [0] * D
    score = 0
    ans = 0
    for j in range(D):
        if flag[j] == '1':
            p_max[j] = 0
            ans += prob[j][0]
            score += prob[j][1] + 100 * (j + 1) * prob[j][0]
        else:
            p_max[j] = prob[j][0] - 1
    p_use = D
    while score < G:
        p_use -= 1
        if p_use == -1:
            ans = 10 ** 10
            break
        solve = min((G - score - 1) // (100 * (p_use + 1)) + 1, p_max[p_use])
        ans += solve
        score += solve * 100 * (p_use + 1)
    ans_min = min(ans, ans_min)

print(ans_min)


Measured memory_bytes: 41328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderB
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        string s = sc.Next();

        int answer = 0;
        int x = 0;

        for (int i = 0; i < n; i++)
        {
            x += (s[i] == 'I' ? 1 : -1);
            answer = Math.Max(answer, x);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int to;
	T cost;
	int tank;
	Edge() {}
	Edge(int to, T cost, int tank = 0) : to(to), cost(cost), tank(tank) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, L;
	cin >> N >> M >> L;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < M; i++) {
		int u, v, len;
		cin >> u >> v >> len;
		u--, v--;
		if (len > L) continue;
		edges[u].emplace_back(v, len);
		edges[v].emplace_back(u, len);
	}

	auto bfs = [&](int st) {
		vector<pair<int, int>> dp(N, { INF, 0 });
		dp[st] = { 0, -L };
		using ppiii = pair<pair<int, int>,int> ;
		priority_queue<ppiii, vector<ppiii>, greater<ppiii>> que;
		que.emplace(dp[st], st);
		while (!que.empty()) {
			auto now = que.top();
			que.pop();
			if (now.first > dp[now.second]) continue;
			for (const auto &e : edges[now.second]) {

				auto tmp = now.first;
				if (e.cost > -tmp.second) {
					tmp.first++;
					tmp.second = -L + e.cost;
				}
				else tmp.second += e.cost;

				if (tmp < dp[e.to]) {
					dp[e.to] = tmp;
					que.emplace(tmp, e.to);
				}

			}
		}
		return dp;
	};

	vector<vector<pair<int, int>>> memo(N);
	for (int i = 0; i < N; i++) memo[i] = bfs(i);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t;
		s--, t--;
		auto tmp = memo[s][t].first;
		if (tmp != INF) cout << tmp << "\n";
		else cout << -1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
void printmat(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insertionSort(int A[],int N){
  int i,j,insert;
  for(i=0;i<N;i++){
    insert = A[i];
    j=i-1;
    while(j >= 0&& A[j] > insert){
      A[j+1]=A[j];
      j--;
    A[j+1]=insert;
    }
    printmat(A,N);
  }
}
int main(){
  int N,i;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  insertionSort(A,N);
  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, r;
    cin >> n >> r;

    if(n >= 10) {
        out(r);
    }
    else {
        out(r + 100*(10 - n));
    }

    re0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    A, B = map(int, input().split())
    ans = 1
    count = A

    if B == 1:
        print(0)
        exit()

    while count < B:
        count += A-1
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

vector<bool> Prime;
vector<int> PrimeStk;
void initPrime(long num) {
	Prime = vector<bool>(num + 1, true);
	Prime[1] = Prime[0] = false;
	long sq_num = sqrt((double)num);
	for (long i = 2; i < sq_num; i++) {
		if (Prime[i]) {
			for (long j = i + i; j <= num; j += i) {
				Prime[j] = false;
			}
		}
	}
}
void initPrimeStk(long begin) {
	PrimeStk.clear();
	for (long i = begin; i < Prime.size(); i++) {
		if (Prime[i]) {
			PrimeStk.push_back(i);
		}
	}
}

int main(void) {
	initPrime(100000 + 10000);

	int N, P;
	while (cin >> N >> P, N != -1 && P != -1) {
		initPrimeStk(N + 1);
		vector<long> stk;
		for (int i = 0; i < P; i++) {
			for (int j = i; j < P; j++) {
				stk.push_back(PrimeStk[i] + PrimeStk[j]);
			}
		}

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

		cout << stk[P - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1344
import sys
N = int(input())
c = input()

count = 0
rui_red = [0 for _ in range(N)]
rui_white = [0 for _ in range(N)]
now_red = 0
now_white = 0
for i in range(N):
    if c[i] == "W":
        now_white += 1
        rui_white[i] = now_white
    if c[-1-i] == "R":
        now_red += 1
        rui_red[-1-i] = now_red

if N == 2 and c == "WR":
    print(1)
    sys.exit()

left = 0
right = N-1
for i in range(N):
    pre_left = left
    pre_right = right
    
    while rui_white[left] < i:
        left += 1
        if  left >= N:
             break
    while rui_red[right] < i:
        right -= 1
        if right < 0:
            break
    
    if left>=right:
        break
answer = i-1
count = 0
for i in range(pre_left+1, pre_right):
    if c[i] == "W":
        count+=1
    else:
        count-=1

print(answer)

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

int main(){
    string s;
	cin>>s;
	bool flag=false;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1]){
			printf("%d %d\n",i+1,i+2);
			flag=1;
			break;
		}
		else if(i+2<s.size() and s[i]==s[i+2]){
			printf("%d %d\n",i+1,i+3);
			flag=1;
			break;
		}
	}
	if(!flag) printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 512