akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll a, b; cin >> a >> b;
  b -= a;
  vecll TOWS(1000);
  RNG(i, 1, 1000) TOWS[i] = (i+1)*(i+2)/2;
  RNG(i, 1, 999) {
    if (TOWS[i+1] - TOWS[i] == b) {
      cout << TOWS[i] - a << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 100000

int arr[M];

void sw(int *,int *);
void partition(int, int);

int main(){
  int n;
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  partition(0,n-1);
  return 0;
}

void sw(int *x,int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

void partition(int p, int r){
  int x;
  int i;
  int j;

  x = arr[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(arr[j] <= x){
      i++;
      sw(&arr[i],&arr[j]);
    }
  }
  sw(&arr[i+1],&arr[r]);
  for(j = p;j <= r;j++){
    if(j != p) printf(" ");
    if(j == i+1) printf("[%d]",arr[j]);
    else printf("%d",arr[j]);
  }
  printf("\n");
}



Measured memory_bytes: 2112
from math import sqrt
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = 0
        for k in range(D):
            dis += (X[i][k] - X[j][k]) ** 2
        r = sqrt(dis)
        if r == int(r):
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int a,b,c;
  cin >> a >> b >>c;
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
  
return 0;
}

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

void dfs(string s,char mx,int n){
	ios::sync_with_stdio(false);
	if(n==0)cout<<s<<"\n"s;
	else for(char c='a';c<=mx+1;++c){
		dfs(s+c,max(mx,c),n-1);
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	dfs("a"s,'a',n-1);
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int N, D;

    cin >> N >> D;

    int r = 2 * D + 1;

    int ans = N / r;

    if (N - (ans * r) > 0)
    {
        ans += 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    set<ll> D;
    for (ll i = 0; i < K; i++) {
        ll d;
        cin >> d;
        D.insert(d);
    }

    auto isOK = [&](ll x) {
        string s = to_string(x);
        for (char c : s) {
            if (D.count(c - '0')) {
                return false;
            }
        }
        return true;
    };

    for (ll i = N; ; i++) {
        if (isOK(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def main():
    X, Y, Z = iip(True)
    print(Z, X, Y)

    #r = solve()
    #print(r)


def solve():
    N = iip(False)
    S = input()


#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_=mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

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

int main(){

    int n,k;
    cin>>n>>k;
    int a[k];
    memset(a,0,sizeof(a));

    for(;n>0;){
        for(int i=0;i<k;i++){
            if(n>0){
                n--;a[i]++;
            }
            else break;
        }
    }
    sort(a,a+k);

    /*for(int i=0;i<k;i++)
        cout<<a[i];*/
    cout<<a[k-1]-a[0]<<endl;
return 0;
}


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

using namespace std;
#define endl "\n"
#define FILEIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define LL long long 
#define mod 1000000007LL
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back
//#define p push
#define I insert
#define bg begin()
#define ed end()
#define sz size()
#define all(v) v.begin(),v.end()
typedef vector<LL> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef map<LL ,LL > mii;
//typedef priority_queue<int> pq;
typedef queue<int>que;
typedef stack<int>stk;
#define Inf 100000005LL
#define f first
#define s second


vi vect_2pow;
void pow_of_2(){
    vect_2pow.assign(32,0);
      for(int i=0;i<=32;i++){
           LL y = 1<<i;
           vect_2pow[i]=y;
      }
}
bool Ispalindrome(string str){
        LL len = str.size();
		bool flag;
		for(int i=0;i<len/2;i++){
				if(str[i]==str[len-i-1])
				     {
						 flag=0;
						 continue;
					 }
					 else 
					    {
							flag=1;
							break;
						}
			}
		if (flag==1)
		  return false;
		else return true;  
		
}
vector<LL> prime_check;
mii get_high_prime;
int high_prime_factor(){
	//cout<<"ecd";
	LL max_prime=0;
	for(int i=2;i<100000;i++)
	{
		LL n=i;
		
		while(n%2==0)
		{
			max_prime=2;
			n>>=1;
		}
		for(int j=3;j<=sqrt(n);j++)
		{
			while(n%j==0){
				max_prime=j;
				n/=j;
			}
		}
		if(n>2)
		  max_prime=n;
		  
		//prime_check.pb(max_prime);
		get_high_prime[i]=max_prime;
	}
	
			
}

LL mod_power(LL a , LL b){
    
	LL ans=1;


	while(b)
	{
		if(b&1)
			ans=(ans*a)%mod;
		b/=2;
		a=(a*a)%mod;
	}
	return ans;
	

}


LL bin_expo(LL x , LL n){
	  
	  if(n==0)
	     return 1;
	  else if(n==1)
	     return x%mod;
		else
		{
			LL temp = bin_expo(x,n/2);
			temp=(temp*temp)%mod;

			if(n%2==0)
			   return temp;
			else
			{
				return ((x%mod)*temp)%mod;
			}
			   
		}
		 	 
}

// std::vector<int> database;
//   std::string text_line;
//   std::getline(std::cin, text_line);
//   std::istringstream input_stream(text_line);
//   int value;
//   while (input_stream >> value)
//   {
//     database.push_back(value);
//   }
// // Edit 1: printing the vector
//   for (auto&& v:database)
//   {
//      std::cout << v << " ";
//   }
//   std::cout << "\n";
//   return EXIT_SUCCESS;

int main(){

	int k,a,b;
	bool flag=0;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0)
		  {
			  flag=1;
			  break;
		  }
	}
	if(flag==0)
	    cout<<"NG\n";
		else
		{
			cout<<"OK\n";
		}
		
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define all(a)						a.begin(), a.end()
#define minimum(a)					*min_element(a.begin(), a.end())
#define maximum(a)					*max_element(a.begin(), a.end())
#define cerr1(a)					cerr << "[ " << a << " ]\n"
#define cerr2(a,b)					cerr << "[ " << a << " , " << b << " ]\n"
#define cerr3(a,b,c)				cerr << "[ " << a << " , " << b << " , " << c << " ]\n"
#define fi 							first
#define se 							second
/*DAM SEHGAL*/
typedef long long ll;typedef long double ld;typedef vector<int> vi;typedef vector<char> vc;
typedef vector<string> vs;typedef vector<ll> vl;typedef set<int> si;typedef set<string> ss;
typedef map<int, int> mii;typedef map<string, int> msi;typedef pair<int, int> pii;
typedef pair<ll, ll> pll;typedef vector<pii> vii;typedef vector<vi> vvi;typedef vector<vii> vvii;
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll add(ll a , ll b , ll mod = MOD){return (a + b) % mod;}
ll sub(ll a , ll b , ll mod = MOD){return ((a-b)%mod + mod)%mod;}
ll mul(ll a , ll b , ll mod = MOD){return (a * b) % mod;}
ll divide(ll a , ll b , ll mod = MOD){return (a * power(b,mod-2,mod))%mod;}
int main()
{
	int a, b;
	cin >> a >> b;
	if  (a == 1)
		a = 14;
	if (b == 1)
		b = 14;
	if (a > b)
		cout << "Alice";
    if (a == b)
    	cout << "Draw";
    if (a < b)
    	cout << "Bob";

	return 0;
}

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

string c;

string solve(){
    int n = c.size();
    string p(n, ' ');
    rep(a,26){
        if(__gcd(a,26) != 1) continue;
        rep(b,26){
            char dic[256];
            rep(x, 26){
                int y = (x*a + b) % 26;
                dic[y + 'a'] = x + 'a';
            }
            dic[(int)' '] = ' ';
            rep(i,n) p[i] = dic[(int)c[i]];
            if(p.find("this") != string::npos || p.find("that") != string::npos) return p;
        }
    }
    assert(false);
}

int main(){
    int n;
    cin >> n;
    cin.ignore();
    rep(i,n){
        getline(cin, c);
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<ll> plus, xy, yx;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        plus.push_back(x+y);
        xy.push_back(x-y);
        // yx.push_back(y-x);
    }
    sort(plus.begin(), plus.end());
    sort(xy.begin(), xy.end());
    // sort(yx.begin(), yx.end());
    ll res=plus[n-1]-plus[0];
    res = max(res, xy[n-1]-xy[0]);
    cout << res << endl;
    return 0;
}

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

const int mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> factors;
    for (int i = 2; i * i <= m; i++) {
        int cnt = 0;
        while (m % i == 0) {
            m /= i;
            cnt++;
        }
        if (cnt > 0) factors.push_back(cnt);
    }
    if (m > 1) factors.push_back(1);

    mint ans(1);
    for (ll power : factors) {
        combination cmb(power + n - 1);
        mint res = cmb(power + n - 1, power);
        ans *= res.x;
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 1860
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin >> N;
	vector<LL> L(100,0);
	L[0] = 2;
	L[1] = 1;
	for(int i=2;i<100;++i){
		L[i] = L[i-1]+L[i-2];
	}
	cout << L[N] << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a,b,c;
  scanf("%ld %ld",&a,&b);
  if (a%3==0) {
    printf("Possible\n");
  }else if (b%3==0) {
    printf("Possible\n");
  }else if ((a+b)%3==0) {
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll n;
    cin >> n;
    ll cnt[10][10] = {{0}};
    for (int i=1; i<=n; i++) {
        int f = (to_string(i)[0] - '0'),
            l = i % 10;
        cnt[f][l]++;
    }
    ll ans = 0;
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  string str;
  cin >> str;
  string a="aiueo";
  int i;
  for(i=0;i<5;i++){
  if(count(str.begin(),str.end(),a[i])>0){
    cout << "vowel" << endl;
    return 0;
  }
  //else b=false;
}
cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>

int edge[100][100];
bool flg[100][100];

int main(void){
	int N, M;
	std::cin >> N;
	std::cin >> M;

	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			edge[i][j] = 1000 * 1000;
			flg[i][j] = false;
		}
		edge[i][i] = 0;
	}
	for(int i=0;i<M;i++){
		int a, b, c;
		std::cin >> a >> b >> c;
		a--;b--;
		edge[a][b] = c;
		edge[b][a] = c;
		flg[a][b] = true;
		flg[b][a] = true;
	}
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				int sum = edge[i][k] + edge[k][j];
				if(sum >= 1000 * 1000)continue;
				if(edge[i][j] > sum){
					flg[i][j] = false;
					edge[i][j] = sum;
				}
			}
		}
	}
	int cnt = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(flg[i][j])cnt++;
		}
	}

	std::cout << M - cnt / 2 << std::endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := getInt(), getInt()

	ans := a - 1
	if a <= b {
		ans = a
	}

	out(ans)
}


Measured memory_bytes: 640
s=input()
k=int(input())
m=0
j=0
if len(set(list(s)))==1:print((len(s)*k)//2);exit()
for i in range(len(s)):
 if len(s)<=j+1:
  if s[-1]==s[len(s)//3]:print(m*k+k-1)
  else:print(m*k)
  break
 if s[j]==s[j+1]:m+=1;j+=1
 j+=1

Measured memory_bytes: 3064
//Volume2-0217
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
    	int    n,p,d,
    	       max_p = -1,
    	       max   = -1;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		n = sc.nextInt();
    		if(n == 0){break;}
    		
    		//calculate
   			max = 0;
    		while(n-- > 0){
    			p = sc.nextInt();
    			d = sc.nextInt() + sc.nextInt();
    			if(max < d){
    				max_p = p;
    				max = d;
    			}
    		}
    		//output
    		System.out.println(max_p + " " + max);
    	}
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    int temp;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }    
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < n-1; i++)
    {
        ans += b[a[i]-1];
        if(a[i]+1==a[i+1])
        {
            ans += c[a[i]-1];
        }
    }
    ans += b[a[n - 1]-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }

int N,Wmax;
vector<ll> V,W;

void input(){
  #ifdef __LOCAL
    fs::path p = __FILE__;
    fs::path input,output;
    input = output = p.parent_path();
    input += string("/input/") + string(p.stem()) + string(".txt");
    output += string("/output/") + string(p.stem()) + string(".txt");
    freopen(input.c_str(), "r", stdin);
    freopen(output.c_str(), "w", stdout);
  #endif
  cin >> N >> Wmax;
  for (int i = 0; i < N; i++)
  {
    ll v,w;
    cin >> w >> v;
    W.push_back(w);
    V.push_back(v);    
  }
}

int solve(){
  vector<vector<ll> > dp(N+1,vector<ll>(Wmax+1,0LL));
  for (int i = 0; i < N; i++)
    for (int j = 0; j <= Wmax; j++)
    {
      if(j-W[i]<0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i][j-W[i]] + V[i]);
    }
  ll ans=dp[N][Wmax];  
  cout << ans << endl;
  return 0;
}

int main()
{
  input();
  solve();
  return 0;
}


Measured memory_bytes: 80256
# Proble D - Widespread

import math

# input
N, A, B = map(int, input().split())
h_list = [0]*N
for i in range(N):
    h = int(input())
    h_list[i] = h

# initialization
left = 0
right = 10**10

# count
while right-left>1:
    mid = (right + left) // 2

    # check
    count = 0
    for h in h_list:
        h = h - B * mid

        if h<0:
            h = 0

        tmp_count = math.ceil(h / (A - B))
        count += tmp_count

    if count>mid:
        left = mid
    else:
        right = mid

# output
print(right)


Measured memory_bytes: 6900
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#pragma endregion

int main() {
    string s;
    cin >> s;
    string prevs = s.substr(0, 1);

    ll f = 1;
    ll cnt = 1;
    for(size_t i = 1; i < s.size(); i++) {
        string nxts = s.substr(f, i - f + 1);
        // cout << "nxts=" << nxts << endl;
        if(nxts == prevs || i - f + 1 == 0)
            continue;
        else {
            cnt++;
            // cout << nxts << endl;
        }
        prevs = nxts;
        f = i + 1;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int H, W;
    cin >> H >> W;
    
    string a[H];
    REP(i, H) {
        cin >> a[i];
        a[i] = "#" + a[i] + "#";
    }

    REP(i, W+2) cout << '#';
    cout << endl;
    
    REP(i, H) cout << a[i] << endl;
    
    REP(i, W+2) cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    long long a[100000],b[100000];
    long long sum=0,s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int k=0;k<m;k++){
        cin>>b[k];
        s+=b[k];
    }
    cout<<sum*s<<endl;
}



Measured memory_bytes: 4668
#include <iostream>
#include <vector>
using namespace std;
int sumVector(vector<int> &vec){
  int sum = 0;
  for(int i = 0;i < vec.size();i++){
    sum += vec[i];
  }
  return sum;
}
int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)break;
    vector<int> tarou(n,0);
    vector<int> hanako(m,0);
    for(int i = 0;i < n;i++){
      cin >> tarou[i];
    }
    for(int i = 0;i < m;i++){
      cin >> hanako[i];
    }
    int half = 0;
    int hSum,tSum;
    tSum = sumVector(tarou);
    hSum = sumVector(hanako);
    /*    half = tSum + hSum;
    if(half %2 == 0)half = half/2;
    else{
      cout << "-1" << endl;
      continue;
      }*/
    int ans1 = 1000;
    int ans2 = 1000;
    for(int i = 0;i < n;i++){
      for(int j = 0;j < m;j++){
	if(tSum - tarou[i] + hanako[j] == hSum - hanako[j] + tarou[i]){
	  if(tarou[i] + hanako[j] == min(ans1+ans2,hanako[j]+tarou[i])){
	    ans1 = tarou[i];ans2 = hanako[j];
	  }
	}
	  
      }
    }
    if(ans1 == 1000)cout <<  "-1" << endl;
    else cout << ans1 << " " << ans2 << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1200
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,n,m;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	m=p-c;
	n=d*m;
	if(p<=c){
		y=b;
	}
	else if(c<=p){
		y=b+n;
	}
	if(x<=y){
			printf("%d\n",x);
	}
	else if(y<=x){
			printf("%d\n",y);
	}
	return 0;
}	


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}

string a, b;
int n, m;
int dp[3005][3005];

void ans() {
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (a[i - 1] == b[j - 1])dp[i][j] = 1 + dp[i - 1][j - 1];
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
}

string print(int i = n, int j = m) {
    if (i == 0 || j == 0)return "";
    if (a[i - 1] == b[j - 1])return print(i - 1, j - 1) + a[i-1];
    else if (dp[i][j - 1] > dp[i - 1][j])return print(i, j - 1);
    else return print(i - 1, j);
}

int main() {
    fast();
    cin >> a >> b;
    n = a.size();
    m = b.size();
    ans();
    cout<<print();
}


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


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

class Main{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        String strInput = input.nextLine();
        String[] str = new String[3];
        str = strInput.split(" ");
        int[] check = {Integer.parseInt(str[0]),Integer.parseInt(str[1]),Integer.parseInt(str[2])};
       Arrays.sort(check);
       System.out.println(check[0] + " " + check[1] + " " + check[2]);
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;

#ifdef WIN32
    #define LLD "%I64d"
#else
    #define LLD "%lld"
#endif

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 100005;

vector<int> gr[maxn];
int c[maxn];
bool was[maxn];
int cnt[2];
int n, m;
bool can;

void go(int cur, int curc)
{
    if (was[cur])
    {
        if (c[cur] != curc) can = false;
        return;
    }
    was[cur] = true;
    c[cur] = curc;
    cnt[curc]++;
    for (auto t : gr[cur]) go(t, 1 - curc);
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--, b--;
        gr[b].pb(a);
        gr[a].pb(b);
    }
    can = true;
    go(0, 0);
    if (!can) cout << (ll)n * (n - 1) / 2 - m << endl;
    else cout << (ll)cnt[0] * cnt[1] - m << endl;
    return 0;
}

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

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

  int s[M], c[M];
  rep(i,0,M-1) cin >> s[i] >> c[i];

  rep(i,0,1000) {
    int digits = 1;
    int n = i / 10;
    vector<int> d(1, i % 10);
    while (n) {
      digits++;
      d.push_back(n % 10);
      n /= 10;
    }
    if (digits != N) continue;
    bool ok = true;
    reverse(d.begin(), d.end());
    rep(j,0,M-1) {
      if (d[s[j] - 1] != c[j]) ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n, m;
	cin >> n >> m;
	vl a(n);
	rep(i, n) cin >> a[i];

	map<ll, ll> c;
	ll sum = 0;
	c[sum]++;
	rep(i, n) {
		sum += a[i];
		c[sum % m]++;
	}

	ll res = 0;
	REP(itr, c) {
		res += itr->second * (itr->second - 1) / 2;
	}
	cout << res << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, a;
    cin >> n >> a;
    if(n % 500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a>>b>>c;
    if(a>=b&&a>=c){
      if(a*a==(b*b)+(c*c))cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    }else if(b>=a&&b>=c){
      if(b*b==(a*a)+(c*c))cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    }else if(c>=b&&c>=a){
      if(c*c==(b*b)+(a*a))cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    }else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;


int main(){
  int i,j;
  ll h,n;
  cin>>h>>n;
  ll x=0;
  for(i=0;i<n;i++) {
    ll a;
    cin>>a;
    x+=a;
  }
  if(x>=h) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) {}
#endif






const int MAX = 510000;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX]; // 階乗、階乗の逆数、逆数

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main(){
	ll n, m;
	cin >> n >> m;
	COMinit();
	
	// Aの選び方
	ll x = COM(m,n);
	for ( ll i = 1; i <= n; i++ )
		x = x * i %MOD;
	
	// 下降べき
	vector<ll> desc(n+1);
	ll d = 1;
	for ( ll i = 0; i <= n; i++ ){
		desc[i] = d;
		d = (d*(m-n+i+1))%MOD;
	}
	
	// Bの選び方
	ll y = 0;
	ll f = 1;
	for ( ll i = 0; i <= n; i++ ){
		y = (y+MOD+f*(COM(n,i)*desc[n-i])%MOD)%MOD;
		f = -f;
	}
	
	
	
	cout << (x*y)%MOD << endl;
	
	
	return 0;
}




Measured memory_bytes: 19044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String args[]) throws IOException {
		// ??\????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int elementNum = Integer.parseInt(br.readLine());
		String line = br.readLine();
		int[] numArray = parseInt(getSplitLine(line));

		// ???????????????????????????
		int count = 0;
		for (int i = 0; i < numArray.length - 1; i++) {
			// ??????????????????????????????????????????
			int keyIndex = i;
			// ????属?????????蔵?卒蔵??????
			// key??則???????????????????属??????即???????????????????????属?????即??????????????????
			// ????属?????????????????????属???key???????属??????????????????????
			for (int j = i + 1; j < numArray.length; j++) {
				if (numArray[keyIndex] > numArray[j]) {
					// ????属???? i ??即 numArray[j]???????????????j??????????属????????????属???
					// ????属??????即???????即??????????
					keyIndex = j;
				}
			}
			// ????属?????????\???????????贈?????????????????属??属????????\????????????????????????
			if (i == keyIndex) {
				continue;
			}
			//
			int temp = numArray[i];
			numArray[i] = numArray[keyIndex];
			numArray[keyIndex] = temp;
			count++;
		}

		System.out.println(Arrays.toString(numArray)
				.replaceAll("[\\[\\],]", ""));
		System.out.println(count);
	}

	private static String[] getSplitLine(String line) {
		return line.split("\\s");
	}

	private static int[] parseInt(String[] line) {
		int[] numArray = new int[line.length];
		for (int i = 0; i < line.length; i++) {
			numArray[i] = Integer.parseInt(line[i]);
		}
		return numArray;
	}

}

Measured memory_bytes: 17020
#include <stdio.h>
int S[500000];
int count = 0;

int merge(int,int,int);
int mergeSort(int,int);

int main()
{

  int n,i;
  scanf("%d",&n);

  for(i=0 ; i<n;i++)scanf("%d",&S[i]);
  mergeSort(0, n);
  for(i = 0 ; i<n ; i++)
    {
      if(i == n-1)
	{
	  printf("%d",S[i]);
	  break;
	}
      printf("%d ",S[i]);

    }
  
  printf("\n%d\n",count);
}

merge(int left, int mid , int right)
{
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1] , R[n2];

  for(i = 0 ; i < n1 ; i++)L[i] = S[left + i];
  for(i = 0 ; i < n2 ; i++)R[i] = S[mid +  i];
  L[n1] = 999999999;
  R[n2] = 999999999;

  i = 0;
  j = 0;

  for(k = left ; k <right ; k++)
    {
      
      if(L[i] <= R[j])
	{
	  S[k] = L[i];
	  i++;
	}
      else
	{
	  S[k] = R[j];
	  j++;
	}
      count++;
    }

}

mergeSort(left,right)
{
  int mid;
  
  if(left+1 < right)
    {
      mid =  (left + right)/2;
      mergeSort(left,mid);
      mergeSort(mid,right);
      merge(left,mid,right);
    }

}



Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vi A(M),B(M);
  rep(i,0,M) cin>>A[i]>>B[i];
  int ans=-1;
  int P=pow(10,N-1);
  if(N==1) P=0;
  rep(i,P,pow(10,N)){
    string S=to_string(i);
    bool flag=1;
    rep(j,0,M){
      if(S[A[j]-1]!='0'+B[j]){
        flag=0;
        break;
      }
    }
    if(flag){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

set<int> isi;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int c1=0, c2=0;
    for(int a=1;a<=n;a++)
    {
        int inp;
        cin>>inp;
        if(inp%2==1) c1++;
        else c2++;
    }
    if(c1%2==0)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

using namespace std;
int abs(int a) {
	if (a < 0) {
		return -a;
	} else {
		return a;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	if (n < k) {
		int h1, h2;
		cin >> h1;
		for (int i = 1; i < n; i++) {
			cin >> h2;
		}
		cout << abs(h2 - h1);
		return 0;
	}
	vector<int> heights;
	vector<int> costs = {0};
	int h1;
	cin >> h1;
	heights.push_back(h1);
	for (int i = 1; i < k; i++) {
		int h2;
		cin >> h2;
		heights.push_back(h2);
		costs.push_back(abs(h2 - h1));
	}
	for (int i = k; i < n; i++) {
		int h2;
		cin >> h2;
		int best_cost = costs.back() + abs(heights.back() - h2);
		heights.push_back(h2);
		for (int j = 1; j <= k; j++) {
			int cost = costs[costs.size() - j];
			int h1 = heights[costs.size() - j];
			best_cost = min(best_cost, cost + abs(h2 - h1));
		}
		costs.push_back(best_cost);
	}
	cout << costs.back();
	return 0;
}

Measured memory_bytes: 1276
using System;

namespace TestSpace
{
    class Test
    {
        static void Main(string[] args)
        {
            string[] arrRead;
            arrRead = Console.ReadLine().Split(' ');
            int W, H, x, y, r;
            W = int.Parse(arrRead[0]);
            H = int.Parse(arrRead[1]);
            x = int.Parse(arrRead[2]);
            y = int.Parse(arrRead[3]);
            r = int.Parse(arrRead[4]);

            if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)
            {
                Console.WriteLine("{0}", "Yes");
            }
            else
            {
                Console.WriteLine("{0}", "No");
            }
        }
    }
}


Measured memory_bytes: 18040
import math
N = int(input())
div = []
for i in range(1, int(math.sqrt(N))+1):
  if N%i==0:
    div.append(i)
    if i != N//i:
      div.append(N//i)
ans = 0
for i in range(len(div)):
  if div[i]-1 > 0 and N//(div[i]-1) == N%(div[i]-1):
    ans += div[i]-1
print(ans)
    

Measured memory_bytes: 3288
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
typedef long long ll;


int main(){
int n,m,ans=0,nn=0;
cin>>n>>m;
int x[n]={10000000};
for(int i=m;i<m+n;i++){
  ans+=i;
  x[nn]=abs(i);
  nn++;
}
sort(x,x+n);
if(n+m>0)
cout<<ans-x[0]<<endl;
else
cout<<ans+x[0]<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define m0(x) memset(x, 0, sizeof(x))

using namespace std;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n, t;
int data[200001];

signed main(){
  int in;
  cin >> n >> t;
  
  fill(data, data+200000, 0);
  rep(i, n){
    cin >> data[i];
  }
  
  int end = 0;
  int start = 0;
  int ans = 0;

  rep(i, n){
    if(data[i] < end){ // かぶってた
      end = data[i] + t;
    }else{
      ans += (end - start);
      start = data[i];
      end = data[i]+t;
    }
  }

  ans += (end - start);
  
  cout << ans << endl;
}


Measured memory_bytes: 1024
import scala.io.StdIn.readLine

object Main extends App {

  val str1 = readLine()
  val str2 = readLine()
  println(levenshteinDistance(str1, str2))

  def levenshteinDistance(str1: String, str2: String): Int = {
    val n = str1.length
    val m = str2.length
    val dp = Array.ofDim[Int](m + 1, n + 1)
    for (i <- 0 to m; j <- 0 to n) {
      var cost: Int = 0
      if (i == 0 && j == 0) cost = 0
      else if (i == 0) cost = j
      else if (j == 0) cost = i
      else {
        var substitutionCost = 0
        if (str2.charAt(i-1) != str1.charAt(j-1)) {
          substitutionCost = 1
        }
        substitutionCost = dp(i-1)(j-1) + substitutionCost
        val insertion_cost = dp(i)(j-1) + 1
        val deletion_cost = dp(i-1)(j) + 1
        cost = Math.min(substitutionCost, Math.min(insertion_cost, deletion_cost))
      }
      dp(i)(j) = cost
    }
    dp(m)(n)
  }
}



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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    reverse(S.begin(), S.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < S.size(); )
    {
        bool can2 = false;
        for (int j = 0; j < 4; j++)
        {
            string d = divide[j];
            if(S.substr(i,d.size())==d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2) {
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
       ll n;
       cin>>n;
       if(n%2==0)
        cout<<"-1";
       else
       {
           ll a=7,ans=1;
           while(a%n)
           {
               a=(a*10+7)%n;
               ans++;
               if(ans>n)
               {
                   cout<<"-1";
                   return 0;
               }
           }
           cout<<ans;
       } 
   }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>
#include <queue>
#include <set>

using namespace std;

int main(void){
	int n;
	set<int> s;
	cin >> n;
	for(int i=0;i<n;i++){
		int tmp = 0;
		cin >> tmp;
		s.insert(tmp);
	}

	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(N)]
x=[]
for i in range(N):
  if a[i][1]<=T:
    x.append(a[i])
if len(x)==0:
  print("TLE")
else:
  x.sort(key=lambda x:x[0])
  print(x[0][0])
  

Measured memory_bytes: 3060
#include<iostream>
#include<string>

using namespace std;

int main(){
	int r,g,b;
	cin >> r >> g>> b;
	int sum = r*100+g*10+b;

	if(sum % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int N; cin >> N;
  cout << (1000 - (N%1000) )%1000 << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3644