akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(){
    ull n,a,b;
    cin >> n >> a >> b;
    ull c=a+b;
    ull ret=n/c;
    n%=c;
    if(n<=a){
        cout << ret*a+n;
    }
    else{
        cout << ret*a+a;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

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

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

int H,W;
cin >> H >> W;
vector<string> fi(H);
rep(h,H) cin >> fi[h];

int ans = 0;
rep(h,H) rep(w,W) {
    if(fi[h][w] == '#') continue;

    vvi dist(H,vi(W,-1));
    queue<pii> que;

    dist[h][w] = 0;
    que.push(make_pair(h,w));

    while(!que.empty()) {
        pii p = que.front();
        que.pop();

        rep(i,4) {
        int nph = p.first + dx[i];
        int npw = p.second + dy[i];
        if(nph < 0 || nph >= H || npw < 0 || npw >= W) continue;
        if(dist[nph][npw] != -1 || fi[nph][npw] == '#') continue;
        dist[nph][npw] = dist[p.first][p.second] + 1;
        chmax(ans, dist[nph][npw]);
        que.push(make_pair(nph, npw));
        }
    }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int X = intRead();
        int max = 0;
        int t = 0;
        for (int i = 1; i < 1000; i++) {
            for (int j = 2; j < 1000; j++) {
                t = (int)Math.Pow(i, j);
                if (t > X) break;
                else if (t > max) max = t;
            }
        }
        Console.WriteLine(max);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    long T1, T2;
    cin >> T1 >> T2;
    long A1,A2,B1,B2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    if(((T1*A1-T1*B1)>0 && ((T1*A1 + T2*A2) - (T1*B1 + T2*B2)) > 0) || 
    ((T1*A1-T1*B1)<0 && ((T1*A1 + T2*A2) - (T1*B1 + T2*B2)) < 0)){
        cout << 0 << endl;
        return 0;
    }
    if((T1*A1 + T2*A2) == (T1*B1 + T2*B2)){
        cout << "infinity" << endl;
        return 0;
    }
    long s = T1*A1-T1*B1;
    if(s < 0){s = -s;}
    long p = (T1*A1 + T2*A2) - (T1*B1 + T2*B2);
    if(p < 0){p = -p;}
    long ans;
    if(s % p == 0){
        ans = (long(s/p) + 1)*2-2;
    }else{
        ans = (long(s/p)+1)*2-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math

a1=list(input().split( ))
a=list(map(int, a1))

b = [input().split() for l in range(a[0])]
g=0
for j in range(a[0]):
 for k in range( a[0] - j  - 1 ):
  c=0
  for m in range(a[1]):
   c  +=  ( int(b[j][m]) - int(b[j + k+1][m]) )**2
  d = float(math.sqrt(c))
  e = float(int(d))
  if e==d:
   g += 1

print(g)   

Measured memory_bytes: 3064
#include<iostream>

int main() {
	
	int time;
	
	while( std::cin >> time) {
	
	int h, m, s;
	
	h = time / 3600;
	m = ( time - h * 3600 ) / 60;
	s = ( time - h * 3600 - m * 60 );
	
	std::cout << h << ":" << m << ":" << s << "\n";
	
	}
	return 0;
}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, d;
int a[20][20];
signed main() {
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ld sum = 0;
			for (int z = 0; z < d; z++) {
				sum += (a[i][z] - a[j][z]) * (a[i][z] - a[j][z]);
			}
			if (floor(sqrt(sum)) == sqrt(sum)) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy
k, n = map(int, input().split())

# a = []
ans = []
le = 0
a = list(map(int, input().split()))

# for i in range(n):
# a.append(input())

for i in range(n):
    if i == 0:
        ans.append(k - a[n-1] + a[i])
    else:
        ans.append(a[i]-a[i-1])

mx = numpy.argmax(ans)

for i in range(n):
    if i != mx:
        le = le + ans[i]


print(le)


Measured memory_bytes: 43216
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b;
    cin >> a >>b;
    a--;b--;
    QECHO(a*b);QECHO("\n");
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    for(;;){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0)break;

        int stage[1024]={0};
        for(int i = 1;i <= n; i++)scanf("%d",&stage[i]);

        int move[1024] = {0};
        for(int i = 0;i < m ;i++)scanf("%d",&move[i]);

        int cnt = 0,x = 1;
        for(int i = 0;i <= m; i++){
            x = stage[move[i]+x] + (move[i]+x);
            cnt++;
            if(x >= n)break;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

#define M_PI 3.141592653589793

int main(void) {

	int i = 0, j, k, l;
	int H[10000], W[10000];

	while (1) {
		scanf("%d %d", &H[i], &W[i]);
		if (H[i] == 0 && W[i] == 0) {
			break;
		}
		else {
			i++;
		}
	}

	for (l = 0; l < i; l++) {
		for (j = 0; j < H[l]; j++) {
			if (j % 2 == 0) {//??¶??°???
				if (W[l] % 2 == 0) {
					for (k = 0; k < W[l] / 2; k++) {
						printf("#.");
					}printf("\n");
				}
				else {
					for (k = 0; k < (W[l] - 1) / 2; k++) {
						printf("#.");
					}
					printf("#");
					printf("\n");
				}
			}
			else {//?\???°???
				if (W[l] % 2 == 0) {
					for (k = 0; k < W[l] / 2; k++) {
						printf(".#");
					}printf("\n");
				}
				else {
					for (k = 0; k < (W[l] - 1) / 2; k++) {
						printf(".#");
					}
					printf(".");
					printf("\n");
				}
			}
		}printf("\n");
	}

	return 0;

}

Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

int main() {
	Int n; cin >> n;
	vector<Int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	Int x1 = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) x1 += a[i];
		else x1 -= a[i];
	}
	cout << x1<<" ";
	Int x = x1;
	for (int i = 1; i < n; i++) {
		x = 2 * a[i - 1] - x;
		cout <<x ;
		if (i != n - 1)cout << " ";
	}
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, bool> pib;

typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

typedef vector<double> vf;

typedef long double ld;

#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

#define printItr(A) for(auto itr = A.begin(); itr != A.end(); ++itr){cout << * itr << ", ";}cout << endl;

const double PI = 3.141592653589793;

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

bool isOK(vi& a, ll k, ll index) {
	return a[index] < k * (index + 1);
}

ll binary_search(vi& a, ll k) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = (ll)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;

		if (isOK(a, k, mid))
			right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

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

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;
	cin >> N;
	vi A(N);

	rep(i, N) {
		cin >> A[i];
	}

	ll ans = 0;
	rep(d, 60) {
		ll zero = 0;
		ll one = 0;
		ll o = 1;
		rep(i, N) {
			if ((A[i] & (o << d)) == 0) {
				zero++;
			}
			else {
				one++;
			}
		}
		// cout << d << ": " << zero <<  ", " << one << endl;

		ans += ((zero * one) % mod) * ((o << d) % mod);
		ans %= mod;
	}

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

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int a,b,m; cin >> a >> b >> m;
    vector<int> va(a),vb(b);
    rep(i,a) cin >> va[i];
    rep(i,b) cin >> vb[i];
    int ma = INT_MAX, mb = INT_MAX;
    rep(i,a) ma = min(va[i],ma);
    rep(i,b) mb = min(vb[i], mb);
    int ans = ma + mb;
    rep(i,m){
        int x,y,c;cin >> x >> y >> c;
        ans = min(ans, va[x-1]+vb[y-1]-c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int m = 2019;

int powm(int x, int p) {
  if (p == 0) return 1;
  int tmp = x * x % m;
  if (p % 2 == 0) {
    return powm(tmp, p/2);
  } else {
    return x * powm(tmp, (p-1)/2) % m;
  }
}

int main() {
  string s;
  cin >> s;
  int N = s.size();
  
  vector<int> r(N);
  
  int res = 0;
  for (int i = 0; i < N; i++) {
    int ss = (int) s[N-1-i]-'0';
    if (i == 0) {
      r[0] = ss*powm(10, i) % m;
      continue;
    }
    r[i] = (r[i-1]+ss*powm(10, i)) % m;
  }

  map<int, int> m;
  m[0] = 1;
  for (int i = 0; i < N; i++) {
    int k = r[i];
    if (m.count(k) == 0) {
      m[k] = 1;
    } else {
      m[k]++;
    }
  }

  long long result = 0;
  for (auto a = m.begin(); a != m.end(); a++) {
    int aa = a->second;
    result += aa * (aa-1) / 2;
  }
  cout << result << endl;
  return 0;
}

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

int main() {
  string text1;
  string text2;
  cin >> text1 >> text2;
  if(text1.compare(text2.substr(0,text2.size()-1)) == 0) {cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int n,m,T,dp[3001],a[3001],b[3001],ans;
int main(){
	cin>>n>>m>>T;
	r(i,n)cin>>b[i]>>a[i];
	r(i,n)for(int j=m-a[i];j>=0;j--)
		if(T<=j||j+a[i]<=T)dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
	r(i,m+1)ans=max(ans,dp[i]);
	cout<<ans<<endl;
}

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

vector<vector<int>> field;
vector<bool> visited;

void dfs(int node);

int main() {
    int n, m, a, b, ans = 0;
    cin >> n >> m;
    field.resize(n, vector<int>(n, 0));
    visited.resize(n);
    vector<pair<int, int>> edge(m);
    rep(i, m) {
        cin >> a >> b;
        edge.at(i) = make_pair(a - 1, b - 1);
        field.at(a - 1).at(b - 1) = field.at(b - 1).at(a - 1) = 1;
    }
    bool bridge;
    rep(i, m) {
        field.at(edge.at(i).first).at(edge.at(i).second) = field.at(edge.at(i).second).at(edge.at(i).first) = 0;
        bridge = false;
        rep(i, n) visited.at(i) = false;
        dfs(0);
        rep(i, n) if(!visited.at(i)) bridge = true;
        if(bridge) ans++;
        field.at(edge.at(i).first).at(edge.at(i).second) = field.at(edge.at(i).second).at(edge.at(i).first) = 1;
    }
    cout << ans << endl;
}

void dfs(int node) {
    visited.at(node) = true;
    rep(i, field.size()) {
        if(field.at(node).at(i) == 1 && (!visited.at(i))) dfs(i);
    }
}

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

#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9+7;
const int N = 3e5 + 9;
const int MAXNODES = 1e5+9;

int main() {

	int h, n;
	cin >> h >> n;
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		h -= x;
	}
	if(h <= 0)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
    int N;
    cin >> N;
    int D;
    cin >> D;
    int X;
    cin >> X;X += N;
    int A[110];
    int B[110];
    for(int i = 1;i <= N;i++){
        cin >> A[i];
        B[i] = A[i];
    }
    for(int i = 2;i <= D;i++){
        for(int j = 1;j <= N;j++){
            if(A[j] + 1 == i){X++;A[j] += B[j];}
        }
    }
    cout << X;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


def main():
    N, M = map(int, input().split())
    uni = UnionFind(N)
    for _ in range(M):
        X, Y, Z = map(int, input().split())
        X -= 1
        Y -= 1
        uni.union(X,Y)

    print(len(uni.roots()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 62684
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int left[n]={}, right[n]={};
  right[0]=(s[0]=='#');
  for(int i=0;i<n-1;i++){
    right[i+1]=right[i]+(s[i+1]=='#');
  }
  left[0]=(s[n-1]=='.');
  for(int i=0;i<n-1;i++){
  	left[i+1]=left[i]+(s[n-2-i]=='.');
  }
  int ans=min(right[n-1], n-right[n-1]);
  for(int i=0;i<n;i++){
  	ans=min(ans, right[i]+left[n-2-i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2180
/*input 
atcoder
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
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<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#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 trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

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

	cin >> S;

	F0R(i, sz(S)) {
		if ((i + 1) < sz(S) && S.at(i) == S.at(i + 1)) {
			cout << (i + 1) << " " << (i + 2) << '\n';
			return 0;
		}
		if ((i + 2) < sz(S) && S.at(i) == S.at(i + 2)) {
			cout << (i + 1) << " " << (i + 3) << '\n';
			return 0;
		}
	}

	cout << -1 << " " << -1 << '\n';
}




Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());

        String localMinC = "TLE";
        int c_; int t_;
        for(int i=0; i<n; i++){
            c_ = Integer.parseInt(sc.next());
            t_ = Integer.parseInt(sc.next());
            if (t_ <= t &&
                (localMinC.equals("TLE") ||
                Integer.parseInt(localMinC)>c_)) {
                localMinC = String.valueOf(c_);
            }
        }

        System.out.print(localMinC);

    }

}



Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> x >> y >> k;
    cout << (x * y) / 2;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
  while(x->left != NIL)
    {
      x = x->left;
    }
  return x;
}

/*Node treeSearch(Node u, int k){
  

 }*/

Node treeSuccessor(Node x)
{
  Node y;

  if(x->right != NIL) return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right)
    {
      x = y;
      y = y->parent;
    }
  return y;
}

/*void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y


}*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL)
    {
      y = x;

      if(z->key < x->key) x = x->left;
      else x = x->right;
    }

  z->parent = y;

  if(y == NIL) root =z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u != NIL)
    {   
      inorder(u->left); 
      printf(" %d",u->key);
      inorder(u->right);
    }
}

void preorder(Node u){
  if(u != NIL)
    {
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    /* if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");*/

    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
    /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    */
    
  }
  return 0;
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> b(n); for (auto&& e : b) cin >> e;
  priority_queue< pair<int, int> > pque;
  for (int i = 0; i < n; ++i) {
    if (a[i] > b[i]) return cout << -1 << '\n', 0;
    if (b[i] > a[i]) {
      pque.emplace(b[i], i);
    }
  }
  auto _ = [&](int i) -> int { return (n + i) % n; };

  lint res = 0;
  while (!pque.empty()) {
    int x, i;
    tie(x, i) = pque.top(); pque.pop();
    int s = b[_(i - 1)] + b[_(i + 1)];
    int q = (b[i] - a[i]) / s;
    if (!q) return cout << -1 << '\n', 0;
    b[i] -= q * s;
    res += q;
    if (b[i] > a[i]) {
      pque.emplace(b[i], i);
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 3956
import sys
input = sys.stdin.readline

H,W = list(map(int,input().split()))
S = H*W
s1 = 0
ans = 10**10
for i in range(1,H):
    s1 += W
    s2 = (H-i)*(W//2)
    s3 = S - s1 -s2
    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

    s2 = ((H-i)//2)*W
    s3 = S - s1 -s2
    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

s1 = 0
for i in range(1,W):
    s1 += H
    s2 = (W-i)*(H//2)
    s3 = S - s1 -s2
    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

    s2 = ((W-i)//2)*H
    s3 = S - s1 -s2
    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))

print(ans)


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

int main(){
    vector<string> s(7);
    s.at(0)="MON";
    s.at(1)="TUE";
    s.at(2)="WED";
    s.at(3)="THU";
    s.at(4)="FRI";
    s.at(5)="SAT";
    s.at(6)="SUN";
    string d;
    cin >> d;
    int i;
    int h=0;
    for(i=0;i<7;i++){
        if(s.at(i)==d){
            h=i;
        }
    }
    if(h==6){
        cout << 7 << endl;
    }
    else{
        cout << 6-h <<endl;
    }
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	/* #ifndef ONLINE_JUDGE
	freopen("inputf.in",  "r",   stdin);
	freopen("outputf.in", "w",  stdout);
	#endif */
	FastIO
	string s;
	string t;
	cin >> s;
	cin >> t;
	lld sum = 0;
	for(lld i = 0; i < 3; i++){
		if (s[i] == t[i]){
			sum+=1;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
move = [[-1, 2], [0, 2], [1, 2],
        [-1, -2], [0, -2], [1, -2],
        [2, 1], [2, 0], [2, -1],
        [-2, 1], [-2, 0], [-2, -1]]

spraing_range = [[-1, 1], [0, 1], [1, 1],
                 [-1, 0], [0, 0], [1, 0],
                 [-1, -1], [0, -1], [1, -1]]


def main():
    while True:
        px, py = map(int, input().split())
        if px is 0 and py is 0:
            break

        n = int(input())
        tmp = list(map(int, input().split()))
        sprinklers_x = tmp[::2]
        sprinklers_y = tmp[1::2]

        fields = make_fields(sprinklers_x, sprinklers_y)
        if bfs(fields, px, py, n):
            print("OK")
        else:
            print("NA")


def make_fields(sprinklers_x, sprinklers_y):
    fields = []
    for x, y in zip(sprinklers_x, sprinklers_y):
        field = [[0] * 10 for _ in range(10)]
        for dx, dy in spraing_range:
            nx = x + dx
            ny = y + dy
            if nx < 0 or ny < 0 or nx > 9 or ny > 9:
                continue
            field[ny][nx] = 1

        fields.append(field)

    return fields


def bfs(fields, init_px, init_py, n):
    q = [[init_px, init_py, 0]]  # [px, py, count]
    while len(q) is not 0:
        px, py, count = q.pop(0)

        if count is n:
            return True

        for dx, dy in move:
            nx = px + dx
            ny = py + dy
            if nx < 0 or ny < 0 or nx > 9 or ny > 9 or \
                    fields[count][ny][nx] is 0:
                continue

            q.append([nx, ny, count + 1])

    return False


if __name__ == '__main__':
    main()

Measured memory_bytes: 7768
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")
 
#include <bits/stdc++.h>
using namespace std;
 
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ost tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define    int                      long long int
#define    ld                       long double
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL),cout.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int ttt; cin >> ttt; while(ttt--)
#define    ff                       first
#define    ss                       second
#define    all(container)            container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    sp(x)                    setprecision(x)
#define    bp(x)                    __builtin_popcount(x)
#define    endl                     "\n"
int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    speed upp
    int n,a,b;
    cin>>a>>b>>n;
    if(n<b-1)
        cout<<(a*n)/b;
    else if(a<=b)
        cout<<a-1;
    else    
        cout<<a-(a+b-1)/b;
}

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

int main() {
    int x,y;
    cin >> x >>y;
    int count=0;
    if(x==1&&y==1){
        count += 400000;
    }
    if(x==1){
        count += 300000;
    }
    else if(x==2){
        count += 200000;
    }
    else if(x==3){
        count += 100000;
    }
    if(y==1){
        count += 300000;
    }
    else if(y==2){
        count += 200000;
    }
    else if(y==3){
        count += 100000;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

const int MX = 200005, MOD = 1E9 + 7;

int m, n, k;
long long ans = 0, fct[MX], ivf[MX], inv[MX], d[MX], c[MX];
            //n giai thua, nghich dao modulo tung vi tri i, nghich dao modulo nhan lai voi nhau
void gener()
{
    fct[0] = ivf[0] = 1;
    fct[1] = ivf[1] = inv[1] = 1;
    for (int i = 2; i <= m * n; i++)
    {
        fct[i] = fct[i - 1] * i % MOD;
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
        ivf[i] = ivf[i - 1] * inv[i] % MOD;
    }
}

void solve()
{
    for (int i = 1; i <= max(m, n); i++)
    {
        c[i] = (c[i - 1] + (i - 1)) % MOD;
        d[i] = (c[i] + d[i - 1]) % MOD;
    }
    ans += d[m] * n % MOD * n % MOD;
    ans += d[n] * m % MOD * m % MOD;
}

int main()
{
    scanf("%d%d%d", &n, &m, &k);
    gener();
    solve();
    cout << ans * fct[m * n - 2] % MOD * ivf[k - 2] % MOD * ivf[m * n - k] % MOD;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int> > g(N + 1, vector<int>(N + 1, 0));
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    g[a][b] = 1;
    g[b][a] = 1;
  }
  vector<int> perm(N);
  for(int i = 0; i < N; i++){
    perm[i] = i + 1;
  }

  int cnt = 0;
  do{
    if(perm[0] != 1)continue;
    bool flag = true;
    for(int i = 0; i < N - 1; i++){
      if(g[perm[i]][perm[i + 1]] != 1)flag = false;
    }
    if(flag)cnt++;
  }while(next_permutation(perm.begin(), perm.end()));
  cout << cnt << endl;
}


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

int main() 
{
    string S;
    cin >> S;
    bool flag = false;
    for (int i = (int)S.size()-1; i >= 0; i--) {
        string str1 = S.substr(0,S.size()/2);
        string str2 = S.substr(S.size()/2, S.size()-1);
        if (str1 == str2 && flag) {
            cout << S.size() << endl;
            return 0;
        }
        S.erase(i);
        flag = true;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	if(s>"2019/04/30") cout<<"TBD";
	else cout<<"Heisei";
	re 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, R, r[8], INF = 1e8;

int main() {
	cin >> n >> m >> R;
	inc(i, R) { cin >> r[i]; r[i]--; }
	
	int d[200][200];
	fill(d[0], d[200], INF);
	
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	
	inc(k, n) {
	inc(i, n) {
	inc(j, n) {
		setmin(d[i][j], d[i][k] + d[k][j]);
	}
	}
	}
	
	sort(r, r + R);
	int ans = INF;
	do {
		int sum = 0;
		inc(i, R - 1) { sum += d[r[i]][r[i + 1]]; }
		setmin(ans, sum);
	} while(next_permutation(r, r + R));
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
import sys
import os


N,M= map(int, input().split())
L=[0]*M
R=[0]*M
for i in range(M):
    L[i], R[i] = map(int, input().split())
Lmax=max(L)
Rmin=min(R)
if Rmin>=Lmax:
    print(Rmin-Lmax+1)
else:
    print(0)

Measured memory_bytes: 10868
def hasTri(arrs):
    k = [arrs[0][0], arrs[1][1], arrs[2][2]]
    l = [arrs[0][2], arrs[1][1], arrs[2][0]]
    if not False in k:
        return True
    if not False in l:
        return True
    return False
def hascol(arrs):
    for i in range(3):
        k = [arrs[0][i], arrs[1][i], arrs[2][i]]
        if not False in k:
            return True
    return False
def hasrow(arrs):
    for i in arrs:
        arr = [x for x in i if x != False]
        if len(arr)==3:
            return True
    return False
A = [[0,0,0],[0,0,0],[0,0,0]]
B = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int, input().split())
N = int(input())
Al = [i for x in A for i in x]
have = []
for _ in range(N):
    a = int(input())
    if a in Al:
        have.append(a)
indexs = [[]]
for k in have:
    index = [[ix,iy] for ix, row in enumerate(A) for iy, j in enumerate(row) if j == k]
    if len(index[0]) == 2:
        indexs = indexs + index
        B[index[0][0]][index[0][1]] = k
if hasTri(B) or hasrow(B ) or hascol(B):
    print("Yes")
else:
    print("No")





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

void swap(int a, int b){
  int tmp;
  tmp = b;
  b = a;
  a = tmp;
}

class Dice
{
private:
  int d[6];
public:
  Dice();
  void CreateDice(int n1, int n2, int n3, int n4, int n5, int n6);
  void disp();
  void Roll_The_Dice(char order);
};

Dice::Dice(){
  for(int i = 0; i < 6; i++){
    d[i] = 0;
  }
}

void Dice::CreateDice(int n1, int n2, int n3, int n4, int n5, int n6){
  d[0] = n1;
  d[1] = n2;
  d[2] = n3;
  d[3] = n4;
  d[4] = n5;
  d[5] = n6;
}

void Dice::disp(){
  // for(int i = 0; i < 6; i++){
  //   cout << d[i] << " ";
  // }
  cout << d[0] <<endl;
}

void Dice::Roll_The_Dice(char order){
  int tmp;
  if(order == 'S'){
    tmp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = tmp;
  } else if(order == 'W'){
    tmp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = tmp;
  } else if(order == 'E'){
    tmp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = tmp;
  } else if(order == 'N'){
    tmp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = tmp;
  }
}

int main(){
  int n[6];
  string order;
  for(int i = 0; i < 6; i++){
    cin >> n[i];
  }
  Dice dice1;
  dice1.CreateDice(n[0],n[1],n[2],n[3],n[4],n[5]);
  cin >> order;
  for(int j = 0; j < order.length(); j++){
    char s = order[j];
    dice1.Roll_The_Dice(s);
  }
  dice1.disp();
}



Measured memory_bytes: 3216
// I am Varun Das from Jadavpur University
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define INF 1e9+5
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//cout<<fixed<<setprecision(12);
int n;
cin>>n;
vector<int>v(n);
for(int& x : v){
    cin>>x;
}
vector<int>dp(n , INF);
dp[0]=0;
for(int i=0;i<n;i++){
    for(int j :{i+1,i+2}){
        if(j < n){
            dp[j]=min(dp[j],dp[i] + abs(v[i] - v[j]));
        }
    }
}
cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

struct Culc {

    vector<long long> factorial;
    long long p;

    //階乗
    Culc(long long N, long long p_) {
        long long ans = 1;
        p=p_;
        factorial.push_back(ans);
        for (long long i = 1; i <= N; i++) {
            ans = ans * i % p;
            factorial.push_back(ans);
        }
    }

    long long extgcd(long long a, long long b, long long &x, long long &y) {
        long long g = a;
        if (b) {
            g = extgcd(b, a % b, y, x);
            y -= x * (a / b);
        } else {
            x = 1;
            y = 0;
        }
        return g;
    }

    long long gcd(long long a, long long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

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

    long long inverse(long long a, long long p) {
        long long x, y;
        extgcd(a, p, x, y);
        return ((x % p) + p) % p;
    }

//nCk mod p
//
    long long combination(long long n, long long k, long long p) {
        //set_factを呼んでから
        return factorial[n] * (inverse(factorial[k] * factorial[n - k] % p, p)) % p;
    }

};

int main(){

    int H,W,A,B;
    cin>>H>>W>>A>>B;
    LL INF=1e9+7;
    Culc culc(H+W,INF);
    LL ans=0;

    REP(i,H-A){
        LL c=(culc.combination(B-1+i,B-1,INF)*culc.combination(W-B-1+H-(i+1),W-B-1,INF))%INF;
        ans+=c;
        ans%=INF;
    }


    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2420
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct node {
    ll counter = 0;
    vector<int> link;
};
node nd[200002];

void count(int cnd, int p) {
    if(p != 0) nd[cnd].counter += nd[p].counter;
    for(int i = 0; i < nd[cnd].link.size(); ++i) {
        if(nd[cnd].link[i] == p) continue;
        count(nd[cnd].link[i], cnd);
    }
}

int main() {
    int n, q, a, b;
    cin >> n >> q;
    rep(i,n-1) {
        cin >> a >> b;
        nd[a].link.push_back(b);
        nd[b].link.push_back(a);
    }
    rep(i, q) {
        cin >> a >> b;
        nd[a].counter += b;
    }

    count(1, 0);

    for(int i=1; i<=n; ++i) {
        cout << nd[i].counter << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <algorithm>
#include <functional>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


int n;
int a[110];


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

	sort(&a[0], &a[n], greater<int>());

	int alc = 0, bob = 0;

	rep(i, 0, n){
		if(i % 2 == 0) alc += a[i];
		else bob += a[i];
	}

	cout << alc - bob << endl;;

	return 0;
}

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

int main(){

  string S;
  cin >> S;

  int time = 0;

  for(int i = 0 ; i < 4 ; ++i){

    for(int j = 0 ; j < i ; ++j){
      if(S[i] == S[j]) time++;
    }
  }

  // cout << time << endl;
  if(time == 2) cout << "Yes" << endl;
  else if(time != 2) cout << "No" << endl;

  return 0;
  
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
  string s;cin >> s;
  sort(s.begin(),s.end());
  if(s[1] == s[0] and s[2] == s[0]){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(10) << x

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n; ll ans=0;
    ll l[n+1]; for(ll i=0;i<n;i++) cin>>l[i];
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            for(ll k = j+1;k<n;k++)
            {
                ll a = l[i]; ll b = l[j]; ll c = l[k];
                if(a==b || b==c || c==a) continue;
                if(a+b>c && b+c>a && c+a>b) ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h> 
#include<string>
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define IN insert
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define NL cout<<endl
#define ll long long int
#define ld long double
#define vl vector<ll>
#define sl set<ll>
#define ml map<ll,ll>
#define sc set<char>
#define li list<ll>
#define vp vector<pair<ll, ll> >
#define vs vector<string>
#define ss set<string>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define REPIT(it,a) for(auto it=a.begin();it!=a.end();it++)
#define DB(x) cout<<"Debug "<<x<<endl
#define N (ll)100004
#define mod (ll)1000000007
using namespace std;
ll a[N],b[N],c[N];
int main()
{

ios::sync_with_stdio(0);
cin.tie(0);
ll n,w;
cin>>n>>w;
ll weight[n],val[n];
REP(i,0,n) cin>>weight[i]>>val[i];
ll dp[n+1][w+1]; memset(dp,0,sizeof(dp));
REP(i,0,n+1){
 REP(j,0,w+1){
 	if(i==0||w==0) dp[i][j]=0;
 	else if(weight[i-1]<=j)
 	 dp[i][j]=max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
 	else
 	 dp[i][j]=dp[i-1][j];
 }
}
cout<<dp[n][w]<<endl;
return 0;
}

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

int main(){
  string S;
  cin >> S;
  int judge = 0;
  for(int i=0;i<4;i++){
    for(int j=i+1;j<4;j++){
      if(S.at(i)==S.at(j)){
        judge++;
        break;
      }
    }
  }
    if(judge == 2){
      cout << "Yes" <<endl;
    }
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n,k;
    cin >> n >> k;

    double ans = 0;

    srep(i,1,n+1){
        int count = 0;
        int ii = i;
        while(ii<k){
            count++;
            ii *= 2;
        }
        ans += ((double)1/n)*(double)pow(2,-count);
    }
    
    cout << fixed << setprecision(10) << ans << endl; 
    return 0;
}
 
 


Measured memory_bytes: 256