akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	ll n, k;
	cin >> n >> k;
	ll ans = k*pow(k-1, n-1);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

template< class T >
struct CumulativeSum
{
  vector< T > data;

  CumulativeSum(int sz) : data(sz, 0) {};

  void add(int k, int x)
  {
    data[k] += x;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  T query(int k)
  {
    if(k < 0) return (0);
    return (data[min(k, (int) data.size() - 1)]);
  }
};


int main()
{
  int N, T;
  scanf("%d %d", &N, &T);
  CumulativeSum< int > sum(T + 1);
  for(int i = 0; i < N; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    sum.add(l, 1);
    sum.add(r, -1);
  }
  sum.build();

  int ret = 0;
  for(int i = 0; i < T; i++) {
    ret = max(ret, sum.query(i));
  }

  printf("%d\n", ret);

}

Measured memory_bytes: 3392
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define INF 1000000
using namespace std;
int loop[15] ={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	
int main(){
  int a,b;
  int mn = INF;
  vector<int>ans;
  int n;
  cin >> n;
  while(n-- ){
    cin >> a >>b;
    ans.clear();
    ans.push_back(a);
    for(int i = a+1 ;; i++){

      if(loop[i%15] == a)ans.clear();

      ans.push_back(loop[i%15]);

      if(loop[i%15] == b)break;
    }

    for(int i = 0 ; i < ans.size() ; i++ ){
      if(i == 0)cout << ans[i];
      else cout << ' ' << ans[i];  
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	//ios::sync_with_stdio(false);
	ll N,M,a,b;
	string s;
	while(cin>>N>>M) {
		VI w(N);
		REP(i, M) {
			cin>>a>>b;
			w[a-1]++;
			w[b-1]++;
		}
		bool ok=true;
		REP(i, N) {
			if(w[i]%2) ok=false;
		}
		
		cout<<(ok?"YES":"NO")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;


int n,cnt;
bool is_prime[1000005];

void mk_prime(int n){
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++) is_prime[i]=true;
    for(int i=2;i*i<=n;i++) if(is_prime[i]){
        for(int j=i*i;j<=n;j+=i){
            is_prime[j]=false;
        }
    }
}

int main(){
    mk_prime(1000005);
    while(cin>>n){
        cnt=0;
        for(int i=2;i<=n;i++){
            if(is_prime[i]) cnt++;
        }
        cout <<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 3956
<?php
fscanf(STDIN, "%d %d", $N, $K);
fscanf(STDIN, "%d %d %d", $R, $S, $P);
$pred = str_split(trim(fgets(STDIN)));
$cnt=["r" => 0, "s" => 0, "p" => 0];
for ($i=0; $i<$K; $i++){
    $res=false;
    for($j=$i; $j<$N; $j+=$K){
        if ($j == $i ) {
            $cnt[$pred[$j]]++;
        }else{
            if ($pred[$j] != $prev || $res==true){
                $cnt[$pred[$j]]++;
                $res=false;
            }else{
                $res=true;
            }
        }
        $prev = $pred[$j];
    }
}
echo $cnt["r"] *$P + $cnt["s"] *$R + $cnt["p"] *$S;

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,p;
  cin >> a >> p;
  ll ans = (a*3+p)/2;
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(N int64) int {
	cnt := 0
	for i := 1; i <= int(N); i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		cnt += i
	}
	return cnt
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
string n;int k,ans,ze[10000];
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
bool zero(int a,int b){
  return !(ze[n.size()-b-1]-ze[n.size()-a]);
}
void f(vector<int> &v){
  int yo,giri;
  if(v[0]+1==n.size())yo=n[0]-'0'-1,giri=1;
  else yo=9,giri=0;
  for(int i=1;i<k;i++){
    if(zero(v[i-1],v[i])){
      yo*=9;
      if(n[n.size()-1-v[i]]=='0')giri=0;
      yo+=giri*(n[n.size()-1-v[i]]-'0'-1);
    }
    else{
      yo+=giri;
      giri=0;
      yo*=9;
    }
  }
  ans+=yo+giri;
}
void g(vector<int> &v){
  f(v);
  v[k-1]++;
  for(int i=1;i<k;i++)if(v[k-i-1]==v[k-i])v[k-i]=0,v[k-i-1]++,i=0;
  if(v[0]==n.size())fin(ans);
}
signed main(){
  cin>>n>>k;
  if(n.size()<k)fin(0);
  vector<int> v(k);
  for(int i=0;i<k;i++)v[i]=k-i-1;
  for(int i=0;i<n.size();i++)ze[i+1]=ze[i]+n[i]-'0';
  while(1)g(v);
}


Measured memory_bytes: 256
open String;;let rec g l=if List.exists(fun e->e="the"||e="this"||e="that")l then print_endline(concat" "l)else g(List.map(fun s->map(fun c->if c>'`'&&c<'{'then Char.chr(((Char.code c-96)mod 26)+97)else c)s)l)and f()=f(g(Str.split(Str.regexp" ")(read_line())));;try f()with _->()

Measured memory_bytes: 2044
#include <stdio.h> 
 
int main() {
  int n,x;
  int b,i,j,k,a;
 
  while(1) {
    scanf("%d %d",&n,&x);   
    b = 0;
    if( n == 0 && x == 0){
      break;
    }
    for(k = 1; k <= n ; k++) {
 
 
      for(j = 1; j <= n ; j++) {
 
    for(i = 1; i <= n; i++) {
       
      if(i == j || j == k || i ==k) {
         
      }else{
        a = i + j + k;
        if(a == x) {
          
          b += 1;
  
        }
      }
       
    }//i
     
      }//j
 
    }//k
    printf("%d\n",b/6);
  }
 
 
  return 0;
}  


Measured memory_bytes: 2040
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



bool check_string(string input)
{
	bool ret = true;
	for (int i=0; i<input.length(); i++)
	{
		if (input[i] != input[input.length() - i - 1])
		{
			ret = false;
		}
	}
	
	return ret;
}

int main()
{
	string input;
	int cnt = 0;
	
	while (cin >> input)
	{
		if (check_string(input))
		{
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 1188
import java.util.*;
import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();


	public void run() {
		TCase:while(true){
			int n=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),x=sc.nextInt();
			if(n==0)return;
			int[] y=nextIntArray(n);

			int t=0,ind=0;
			do{
				if(y[ind]==x)ind++;
				if(ind==n){
					ln(t);
					continue TCase;
				}
				x=(a*x+b)%c;
				t++;
			}while(t<=10000);
			ln(-1);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 31616
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0, t1 = 0, t2 = 0;
    rep(i, n){
        if(s[i] == '('){
            cnt++;
        }else if(cnt > 0){
            cnt--;
        }else{
            t1++;
        }
    }
    cnt = 0;
    repr(i, n){
        if(s[i] == ')'){
            cnt++;
        }else if(cnt > 0){
            cnt--;
        }else{
            t2++;
        }
    }
    rep(i, t1){
        s = "(" + s;
    }
    rep(i, t2){
        s = s + ")";
    }
    cout << s << endl;
    return 0;
}

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

int main()
{
	map<string, vector<int>>s;
	string a; int b;
	cin >> a >> b;
	if (cin.fail()) {}
	else {
		vector<int>r(0);
		s.insert(pair<string, vector<int>>(a, r));
		s[a].push_back(b);
		while (1) {
			cin >> a >> b;
			if (cin.fail())break;
			for (auto c = s.begin(); c != s.end(); c++) {
				if (a == c->first) { c->second.push_back(b); break; }
				auto d = c;
				d++;
				if (d == s.end()) { vector<int>r(0); s.insert(pair<string, vector<int>>(a, r));  s[a].push_back(b); break; }
			}
		}
		for (auto e = s.begin(); e != s.end(); e++) {
			sort(e->second.begin(), e->second.end());
			cout << e->first << endl;
			for (int f = 0; f < e->second.size()-1; f++) {
				cout << e->second[f] <<" ";
			}
			cout << e->second[e->second.size() - 1] << endl;
		}
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main()
{
	const int mods = 1000;
	int n = 0, m = 0, h = 0, w = 0;
	cin >> n >> m >> h >> w;
	if((n * m - (n / h * h) * (m / w * w)) * mods <= (n / h) * (m / w))
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(int i = 1; i <= n; i++, putchar('\n'))
		for(int j = 1; j <= m; j++, putchar(' '))
			printf("%d", (i % h == 0 && j % w == 0)? mods - 1 - mods * (h * w): mods);
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    vector<int> g[2005];
    int n,x,y;
    cin >> n >> x >> y;

    for(int i = 1; i < n; i++){
        g[i].pb(i+1);
        g[i+1].pb(i);
    }

    g[x].pb(y);
    g[y].pb(x);

    ll ans[2005];
    memset(ans, 0, sizeof(ans));
    bool mark[2005];
    queue<pii> q;
    for(int node = 1; node <= n; node++) {
        q.push(pii(node,0));
        // cout << "node: " << node << endl;
        memset(mark, 0, sizeof(mark));
        mark[node] = true;
        while(!q.empty()){
            int j = q.front().snd;
            // for(int i = 0; i < q.size(); i++){
            //     cout << q.front().fst << " ";
            //     q.push(q.front());
            //     q.pop();
            // }
            // cout << endl;
            int src = q.front().fst; q.pop();

            for(auto w : g[src]){
                if (!mark[w]){
                    mark[w] = true;
                    ans[j+1]++;
                    q.push(pii(w, j+1));
                }
            }   
        }
    }
    int i = 1;
    // cout << "---" << endl;
    while(i < n){
        cout << ans[i]/2 << endl;
        i++;
    }
    

    return 0;
}

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

int main(void){
    int i,n,m,sum;
    sum = 0;

    cin >> n >> m;
    vector<int> a(m);

    for(i=0; i<m; i++){
        cin >> a.at(i);
        sum += a.at(i);
    }

    if(n >= sum ){
        cout << n - sum << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n;
  cin>>n;
  rep(i,n+1){
    if(i==0)q=2;
    else if(i==1)p=1;
    else{
      p=p+q;
      q=p-q;
    }
  }
  print(p)
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;


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

	string S, XS;
	cin >> S;

	int tx = 0;

	for (char c : S) if (c != 'x') {
		XS.push_back(c);
	} else ++tx;

	string rev = XS;
	reverse(rev.begin(), rev.end());
	if (rev != XS) {
		cout << -1 << endl;
		return 0;
	}
	rev = S;
	reverse(rev.begin(), rev.end());
	if (rev == S) {
		cout << 0 << endl;
		return 0;
	}


	int p = 0, prev, curr;

	int l, r;

	REP(i, S.size()) {
		if (S[i] == XS[p]) {
			prev = curr;
			curr = i;
			++p;
		}
		if (p == XS.size()/2+1) {
			if (XS.size()%2) {
				l = i;
				r = i;
			} else {
				l = prev;
				r = i;
			}
			break;
		}
	}

	// cout << l << " " << r << endl;
	// return 0;

	int ans = 0;

	while (l >= 0 || r < S.size()) {
		char lc = l < 0 ? '@' : S[l];
		char rc = r >= S.size() ? '@' : S[r];
		if (lc == rc) {
			--l;
			++r;
		} else {
			// cout << l << " " << r << endl;
			++ans;
			if (lc == 'x') {
				--l;
			} else {
				++r;
			}
		}
	}

	cout << ans << endl;
	
}

Measured memory_bytes: 720
#include <stdio.h>

int main(void){
    char s[3];

    scanf("%s", s);

    for(int i = 0; i < 2; i ++){
        if(s[i] != s[i + 1]){
            printf("Yes");
            return (0);
        }
    }
    printf("No");
    return(0);
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;

    if (A < B) {
        if (A + V * T < B + W * T) puts("NO");
        else puts("YES");
    } else {
        if (A - V * T > B - W * T) puts("NO");
        else puts("YES");
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define re register
inline int gi(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
int ans=0,vis[100010],a[100010],b[100010],n,sum,del[100010];
void dfs(int i){
	if(i>n){
		int s=0;
		memset(del,0,sizeof(del));
		for(re int j=1;j<=n;j++){
			int k=j;
			while(k<=n && !del[b[k]])s+=a[b[k++]];
			k=j;
			while(k>=1 && !del[b[k]])s+=a[b[k--]];
			ans+=s;del[b[j]]=1;
		}
		return;
	}
	for(re int j=1;j<=n;j++)
		if(!vis[j]){
			vis[j]=1;b[i]=j;
			dfs(i+1);
			vis[j]=0;
		}
}
const int Mod=1e9+7;
int qpow(int a,int b){
	int ret=1;
	while(b){
		if(b&1)ret=(1ll*ret*a)%Mod;
		a=(1ll*a*a)%Mod;b>>=1;
	}
	return ret;
}
int main(){
	n=gi();
	for(re int i=1;i<n;i++){a[i]=(a[i-1]+qpow(i+1,Mod-2))%Mod;}
	ll ans=0;
	for(re int i=0;i<n;i++){
		int x=gi();
		ans=(ans+1ll*x*a[i]%Mod)%Mod;
		ans=(ans+1ll*x*a[n-i-1]%Mod)%Mod;
		ans=(ans+1ll*x)%Mod;
	}
	for(re int i=0;i<n;i++)
		ans=1ll*ans*(i+1)%Mod;
	printf("%lld\n",ans%Mod);
	return 0;
}


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

#define vi vector<int>
#define pb push_back

int mul(int depth);

char s[50][100];
int n;
int g;

int plu(int depth){
    int res = 0;
    while(true){
        g++;
        if(s[g][depth] != '.'){
            g--;
            return res;
        }else if(s[g][depth+1] == '+'){
            res += plu(depth+1);
        }else if(s[g][depth+1] == '*'){
            res += mul(depth+1);
        }else{
            res += (s[g][depth+1]-'0');
        }
        if(g>n) break;
    }
}

int mul(int depth){
    int res = 1;
    while(true){
        g++;

        if(s[g][depth] != '.'){
            g--;
            return res;
        }else if(s[g][depth+1] == '+'){
            res *= plu(depth+1);
        }else if(s[g][depth+1] == '*'){
            res *= mul(depth+1);
        }else{
            res *= (s[g][depth+1]-'0');
        }
        if(g>n) break;
    }
}

int main(){
//    ifstream in("c_in.txt");
//    cin.rdbuf(in.rdbuf());
    while(cin >> n,n){
        rep(i,50)rep(j,100) s[i][j] = ' ';
        g = 0;
        rep(i,n) {
            string ss;
            cin >> ss;
            ss.copy(s[i],ss.size());
        }

        int ans;
        if(s[0][0]=='+'){
            ans = plu(0);
        }else if(s[0][0]=='*'){
            ans = mul(0);
        }else{
            ans = (s[0][0] - '0');
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    class Shi : IComparable<Shi>
    {
        public int P;
        public int Y;
        public int ID;

        public Shi(int P, int Y, int ID)
        {
            this.P = P;
            this.Y = Y;
            this.ID = ID;
        }

        int IComparable<Shi>.CompareTo(Shi other)
        {
            if (P != other.P) return P.CompareTo(other.P);
            else return Y.CompareTo(other.Y);
        }
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int w = 0;
        long ans = 0;
        for (int i = S.Length - 1; i >= 0; i--)
        {
            if (S[i] == 'W') w++;
            else ans += w;
        }
        Console.WriteLine(ans);
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;cin >> N >> M;
    int A[M],B[M];
    int table[1001000] = {};
    REP(i,M){
        cin >> A[i] >> B[i];
        table[A[i]]++;table[B[i]]++;
    }
    REP(i,N+1){
        if(table[i] % 2 != 0){
            cout << "NO" << endl;
			return 0;
        }
    }
    cout << "YES" << endl;
}

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

int f(int x) {
    return (x % 2 == 0 ? x / 2 : 3 * x + 1);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int cnt = 0;
    bool visited[1000001] = {false, };
    int s; cin >> s;
    visited[s] = true;
    while (true) {
        cnt++;
        int next = f(s);
        if (visited[next]) {
            cout << cnt + 1 << '\n';
            break;
        } else {
            visited[next] = true;
            s = next;
        }
    }
    
    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	ll N, Z, W, a[2005];

	cin >> N >> Z >> W;
	rep(i,N) cin >> a[i];

	if( N == 1 ){
		cout << abs(W-a[0]) << endl;
		return 0;
	}

	ll ans = max(abs(W - a[N-1]), abs(a[N-2]-a[N-1]));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int n;
	ll a[100000];

	cin >> n;

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

	sort(a, a + n);
	reverse(a, a + n); //降順

	rep(i, 0, n - 1) {
		if (a[i] % a[i + 1] != 0) {
			int p = a[i + 1], q = a[i] % a[i + 1];//p:割られる数 q:割る数
			while (p%q != 0) {
				int b = p;
				p = q;
				q = b % q;
			}
			a[i + 1] = q;
		}
	}

	cout << a[n-1] << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
from operator import mul
from functools import reduce

mod = 1000000007
N = I()

ans = (10 ** N - 9 ** N - 9 ** N + 8 ** N) % mod
print(ans)

Measured memory_bytes: 11460
#include<stdio.h>
int main(void){
  int a,b,c,i=0;
  scanf("%d %d %d",&a,&b,&c);
  while(b>=a){
    b-=a;
    i++;
    if(i>c){
        printf("%d",c);
      return 0;
    }    
  }
  printf("%d",i);
  return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		
		int n = sc.nextInt();
		int yen = sc.nextInt();
		String ans = "-1 -1 -1";
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n; j++) {
				int x = i;
				int y = j;
				int z = n - x - y;
				if (z>=0) {
					if (10000*x + 5000*y + 1000*z == yen) {
						ans = String.format("%d %d %d", x, y, z);
						break;
					}
				}
			}
		}
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

		double nextDouble() {
			return Double.parseDouble(next());
		}

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

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 24148
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    d,t,s=map(int,input().split())
    if d<= t*s:
        print("Yes")
    else:
        print("No")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62600
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main{

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    long n=in.nextInt();
    w.println((800*n)-((n/15)*200));
    w.close();
    }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

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

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
typedef long long ll;

int main() {
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> b(B);
  int amin=INF; 
  int bmin=INF; 
  rep(i,A){
    cin >> a.at(i);
    amin=min(amin,a.at(i)); 
  }
  rep(i,B){
    cin >> b.at(i);
    bmin=min(bmin,b.at(i));
  }
  int res = INF;
  rep(i,M){
    int x,y,c;
    cin >> x >> y >> c;
    res=min(res,a.at(x-1)+b.at(y-1)-c);
  }
  res=min(res,amin+bmin); 
  cout << res << endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    int N;
    cin >> N;
    vector<long double> vec(N);
    for(int i=0; i<N; i++){
      cin >> vec[i];
    }
    long double j = 0;
    for(int i=0; i<N; i++){
        j += 1/vec[i];
    }
    std::cout << std::setprecision(15) << 1/j;
}

Measured memory_bytes: 256
using System;

class B {
    public static void Main() {
        var line = Console.ReadLine().Split();
        var w = int.Parse(line[0]);
        var h = int.Parse(line[1]);
        var n = int.Parse(line[2]);
        int a1 = 0, a2 = w, a3 = 0, a4 = h;
        for (int i = 0; i < n; ++i) {
            line = Console.ReadLine().Split();
            var x = int.Parse(line[0]);
            var y = int.Parse(line[1]);
            var a = int.Parse(line[2]);
            switch (a) {
                case 1: a1 = Math.Max(a1, x); break;
                case 2: a2 = Math.Min(a2, x); break;
                case 3: a3 = Math.Max(a3, y); break;
                case 4: a4 = Math.Min(a4, y); break;
            }
        }
        var deltaX = Math.Max(0, a2 - a1);
        var deltaY = Math.Max(0, a4 - a3);
        Console.WriteLine(deltaX * deltaY);
    }
}


Measured memory_bytes: 13140
# 頂点sから到達する頂点の集合
def dfs(edge, s):
    use = {s}
    q = [s]
    while q:
        v = q.pop()
        for w in edge[v]:
            if w in use:continue
            use.add(w)
            q.append(w)
    return use

# ベルマンフォード法
def bellman_ford(v, s, t, e):
    # コストをINFで初期化
    d = [10**18] * v
    # 開始頂点は0
    d[s] = 0
    # 負の閉路が無ければ更新はV-1回までで終わる
    for _ in range(v):
        f = False
        for a, b, c in e:
            # aまでのコスト+辺abのコストがbまでのコストより小さければ更新
            cost = d[a] + c
            if cost < d[b]:
                d[b] = cost
                f = True
        # 更新が無ければbreak
        if not f:break
    else:
        # V回目まで更新があったら負の閉路がある
        return -1
    return max(-d[t], 0)

def main():
    import sys
    input = sys.stdin.readline
    n, m, p = map(int, input().split())
    edge = [[] for _ in range(n)]
    edge_rev = [[] for _ in range(n)]
    e = []
    for _ in range(m):
        a, b, c = map(int, input().split())
        edge[a-1].append(b-1)
        # 頂点Nからdfsするため辺の向きを逆にする
        edge_rev[b-1].append(a-1)
        e.append((a-1, b-1, p-c))
    # 頂点1と頂点Nのどちらからも到達できる頂点の集合
    use = dfs(edge, 0) & dfs(edge_rev, n-1)
    # fromとtoがどちらもuseに含まれる辺のみ使う
    # そうすることで負の閉路を検出した場合答えは必ず-1になる
    e=[(a, b, c) for a, b, c in e if a in use and b in use]
    print(bellman_ford(n, 0, n-1, e))   
if __name__ == '__main__':
    main()

Measured memory_bytes: 5348
s = input()
if s.count('B') == 0 or s.count('W') == 0:
    print(0)
    exit()

import re
if s[0] == 'B':
    s = re.sub(r'B+', 'B', s)
    s = re.sub(r'W+', 'W', s)
    ans = s.count('BW')*2-1
    print(ans if s[-1] != 'B' else ans+1)
else:
    s = re.sub(r'B+', 'B', s)
    s = re.sub(r'W+', 'W', s)
    ans = s.count('WB')*2-1
    print(ans if s[-1] != 'W' else ans+1)

Measured memory_bytes: 4548
#include <stdio.h>
#include <string.h>

int main(){
    char S[27];
    int a[27], i, len;

    scanf("%s", S);
    len = strlen(S);

    for(i=0; i<27; i++){
        a[i] = 0;
    }

    for(i=0; i<len; i++){
        if(a[S[i]-'a'] == 0)
            a[S[i]-'a']++;
        else{
            printf("no\n");
            return 0;
        }
    }

    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-29(Wed)
   note   
**********************************************************************/

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

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  }
  else {
    cout << 10 << endl;
  }
}



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

int main(){
    string S;
    cin >> S;
    for(int i=0; i<3; i++){
    	if(S.at(i)=='7'){
        	cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;

int main() {
    int d,n;
    cin >> d >> n;
    int ans;
    if (n<100) ans=pow(100,d)*n;
    else ans=pow(100,d+1)+pow(100,d);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (*--a.end() == b[0] && *--b.end() == c[0])
		YES();
	else
		NO();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,num,sum,ans;
ll a,b,c,d,e,g,h;
//ll x[500005],y[500005],z[500005];
ll dp1[1050000],dp2[1050000];
double x[500005],w[500005]; 

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

void solve(ll a,ll b){
	if(a<b)swap(a,b);
	//a > bにする
	if(b == 1){
		ans += 2 * a - 1;
		return;
	}else if(a == b){
		ans += a;
	}else if(a % b == 0){
		ans += (a/b) * b * 2 - b;
	}else{
		ans += (a/b) * b * 2;
		solve(b,a%b);
	}
}


int main(){
	cin >> n >> k;
	ans = n;
	solve(k,n-k);
	p(ans);

	return 0;
}


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

int main() {
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  vector<ll> b(m);rep(i,m)cin>>b[i];
  ll c=0; ll s=0;
  rep(i,n){
    if(s+a[i]<=k){s+=a[i];c++;}
    else{break;}
  }
  ll d=0;
  rep(i,m){
    if(s+b[i]<=k){s+=b[i];d++;}
    else{break;}
  }
  ll ans=c+d;
  //cout<<c<<"  "<<d<<endl;
  ll c_=c;
  rep(i,c_){
    s-=a[c-1];c--;
    //cout<<c<<"  ";
    if(d<m){
      while(s+b[d]<=k){s+=b[d];d++;if(d==m){break;}}
    }//cout<<d<<endl;
    ans=max(ans,c+d);
  }
  cout<<ans;
  
}



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

#define lld long long
#define pii pair<int,int>
#define pll pair<lld,lld>
#define pb push_back
#define next nextt
#define Inf 1000000000
#define Linf 1000000000000000000LL
#define Mod 1000000007

using namespace std;

int N,M,K; lld ans;
lld fact[900002],inv[900002],three[900002],two[900002];

lld mul(lld x,lld y){
	if(y == 0) return 1;
	lld tmp = mul(x,y/2);
	tmp *= tmp; tmp %= Mod;
	if(y%2 == 1){
		tmp *= x;
		tmp %= Mod;
	}
	return tmp;
}
lld comb(lld x,lld y){
	return (fact[x]*inv[x-y]%Mod)*inv[y]%Mod;
}

int main(){
   // freopen("input.txt","r",stdin);
	scanf("%d %d %d",&N,&M,&K);
	fact[0] = inv[0] = three[0] = two[0] = 1;
	for(int i=1; i<=900000; i++){
		fact[i] = (fact[i-1]*i)%Mod;
		inv[i] = mul(fact[i],Mod-2);
		three[i] = (three[i-1]*3)%Mod;
		two[i] = (two[i-1]*2)%Mod;
	}
	if(M < K) swap(M,K);
	lld t1,t2;
	for(int i=0; i<=M+K; i++){
		lld tmp;
		if(i <= K) tmp = two[i];
		else if(i == M+1){
			t1 = t2 = 0;
			for(int j=0; j<=i-K-1; j++){
				t1 += comb(i,j); t1 %= Mod;
			}
			for(int j=0; j<=i-M-1; j++){
				t2 += comb(i,j); t2 %= Mod;
			}
			tmp = two[i]-(t1+t2);
		}else if(i > M){
			t1 = t1*2+comb(i-1,i-K-1); t1 %= Mod;
			t2 = t2*2+comb(i-1,i-M-1); t2 %= Mod;
			tmp = two[i]-(t1+t2);
		}else if(i == K+1){
		    t1 = 0;
            for(int j=0; j<=i-K-1; j++){
                t1 += comb(i,j);
                t1 %= Mod;
            }
            tmp = two[i]-t1;
		}else{
		    t1 = t1*2+comb(i-1,i-K-1); t1 %= Mod;
            tmp = two[i]-t1;
		}

		tmp *= comb(N-1+i,N-1); tmp %= Mod;
		tmp *= three[M+K-i]; tmp %= Mod;
		ans += tmp; ans %= Mod;
	}
	if(ans < 0) ans += Mod;
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 28416