akhauriyash/Code-Regression huggingface dataset:
n = int(input())
def cross_plots(x1, x2, y1, y2, r):
    dx, dy = x2 - x1, y2 - y1
    d = dx ** 2 + dy ** 2
    t = ((4 * (r ** 2) - d) / (4 * d)) ** 0.5
    nx, ny = -t * dy, t * dx

    return ((x1 + x2) / 2 + nx, (y1 + y2) / 2 + ny),\
           ((x1 + x2) / 2 - nx, (y1 + y2) / 2 - ny)

plots = [tuple(map(int, input().split())) for _ in range(n)]
l, r = 0, 2000
while r - l > 10 ** -7:
    R = (r + l) / 2
    cross = []
    flg = False
    for i in range(n):
        for j in range(i+1, n):
            x1, y1 = plots[i]
            x2, y2 = plots[j]
            dx, dy = x2 - x1, y2 - y1
            if dx ** 2 + dy ** 2 > 4 * (R ** 2):
                flg = True
                break

            p1, p2 = cross_plots(x1, x2, y1, y2, R)
            cross.append(p1)
            cross.append(p2)

    if flg:
        l = R
        continue

    for xc, yc in cross:
        if all((xc - x) ** 2 + (yc - y) ** 2 < R ** 2 + 10e-9 for x, y in plots):
            flg = True
            break

    if flg:
        r = R
    else:
        l = R



print(r)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n;
	cin>>n;

	ll ans = sqrt(n);

	cout<<ans*ans<<endl;

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,ans;
    cin>>n;
    vector<int> v(n),dp(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    dp[n-1]=0;
    dp[n-2]=abs(v[n-1]-v[n-2]);
    for(i=n-3;i>=0;i--)
    {
        dp[i]=min(abs(v[i]-v[i+2])+dp[i+2],abs(v[i]-v[i+1])+dp[i+1]);
    }
    cout<<dp[0];
}


Measured memory_bytes: 1024
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
    S=s[i:j+1]
    if len(S)==S.count("A")+S.count("T")+S.count("G")+S.count("C"):
      ans=max(ans,len(S))
print(ans)


Measured memory_bytes: 2940
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]
ans = -(10**9)
for i in range(1,2**10):
  S = [0]*N
  tmp = 0
  for j in range(10):
    for k in range(N):
      if (i >> j) & 1 and F[k][j] == 1:
        S[k] += 1
  for m in range(N):
    tmp += P[m][S[m]]
  ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        /**
        int n = sc.nextInt();
        int[]arr = new int[n];
        for(int i  = 0;i<n;i++)
        {
            arr[i] = sc.nextInt();
        }
         **/
        String s1 =sc.nextLine();
        String s2 =sc.nextLine();
        long res= 0;
        for(int i =  0;i< s2.length();i++)
        {
            if(s2.charAt(i) == s1.charAt(i))
                res++;
        }
        System.out.println(res);

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m),b(m);
	vector<bool> c(n);
	rep(i,m){
		cin >> a.at(i) >> b.at(i);
		a.at(i)--;
		b.at(i)--;
		if(a.at(i) == 0) c.at(b.at(i)) = true;
	}
	rep(i,m){
		if(b.at(i) == n - 1 && c.at(a.at(i))){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
#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>;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

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


mint f(int n) {
    if (n==0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  k = min(k, n-1);

  combination c(n);
  mint ans;
  for(int j = 0; j <= k; ++j) {
    ans += c(n, j) * c(n-1, j);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

int32_t main() {
	int n;
	cin >> n;
	cout << 1 - n << endl;	
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef pair< int , int > Pi;
#define ALL(a) (a).begin(),(a).end()
int n;
const int dy[] = { 1, 1, 1, 0}, dx[] = { -1, 0, 1, 1};
string s[1000];

bool isover(const int& y, const int& x){
  return y >= n || x < 0 || x >= s[y].size();
}

void bfs( int y, int x, vector< Pi >& pt){
  if( isover( y, x) || s[y][x] == ' ') return;
  pt.push_back( Pi( y, x));
  s[y][x] = ' ';
  for(int i = 0; i < 4; i++) bfs( y + dy[i], x + dx[i], pt);
}

map< int, int > solve(){
  map< int , int > ret;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < s[i].size(); j++){
      if(s[i][j] == '*'){
        vector< Pi > res;
        bfs( i, j, res);
        sort( res.begin(), res.end());
        int topline = distance( res.begin(), upper_bound( ALL(res), Pi( i + 1, -1)));
        int downline = distance( upper_bound( ALL(res), Pi( res.back().first, -1)), res.end());
        ret[(topline+downline)*(res.back().first-i+1)/2]++;
      }
    }
  }
  return ret;
}

int main(){
  for(bool flag = false; (cin >> n).ignore(), n; flag++){
    if(flag) cout << "----------\n";
    for(int i = 0; i < n; i++) getline( cin, s[i]);
    map< int, int > ret = solve();
    for(map< int, int >::iterator it = ret.begin(); it != ret.end(); it++){
      cout << it->first << " " << it->second << endl;
    }
  }
}

Measured memory_bytes: 1272
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define mp make_pair
        #define f1 first
        #define f2 second
        #define int long long
        #define int1 int
        #define pb push_back
        using namespace std;
        int dp[10009][19][109];
        main()
        {
            int z=1e9+7;
          string k;
          cin>>k;
          int d;
          cin>>d;
          int n=k.size();
          for(int i=0 ; i<=9 ; i++)
          {
              dp[1][i][(i%d)]=1;
          }
          for(int i=2 ; i<=n ; i++)
          {
              for(int j=0 ; j<10 ; j++)
              {
                  for(int w=0 ; w<d ; w++)
                  {
                      for(int a=0 ; a<10 ; a++)
                      {
                          dp[i][j][w]=((dp[i][j][w]+dp[i-1][a][(((w%d)-(j%d)+d)%d)])%z);
                      }

                  }
              }
          }
          int ans=0;
            int a=1;
            int  e=0;
          for(int i=1 ; i<=n ; i++)
          {
              if(a==-1)
              {
                  for(int j=9 ; j>=k[i-1]-48 ; j--)
                  {
                      ans=((ans-dp[n-i+1][j][e]+z)%z);
                  }

              }
              else
              {      for(int j=0 ; j<=k[i-1]-48 ; j++)
                      {
                          ans=((ans+dp[n-i+1][j][e])%z);
                      }
              }
             a=(-1*a);
             if(i!=n)
             e=((((e%d)-((k[i-1]-48)%d))+d)%d);
          }
         if(a==1)
         ans=((ans+dp[1][k[n-1]-48][e])%z);
         ans=((ans-1+z)%z);
        cout<<ans;

        }


Measured memory_bytes: 161536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		// N = 枚数,K = 人数
		int N = sc.nextInt();
		int K = sc.nextInt();

		Boolean ans = false;

		if(N % K == 0) {
			ans = true;
		}

		System.out.println(ans? 0 : 1);

		sc.close();
	}

}


Measured memory_bytes: 23764
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a[10010];
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a[i]);
    n -= a[i];
  }
  if (n < -1)
    n=-1;
  printf("%d",n);
}

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

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		label:while(true){
			Shop[] s = new Shop[5];
			for(int i = 0;i<5;i++){
				int a = cin.nextInt();
				int b = cin.nextInt();
				if(i+a+b==0){
					break label;
				}
				s[i]=new Shop(a+b, (char)('A'+i));
			}
			Arrays.sort(s);
			System.out.println(s[4].name+" " + s[4].total);
		}

	}

}
class Shop implements Comparable{
	int total;
	char name;
	Shop(int a, char b){
		total=a;name=b;
	}
	
	public int compareTo(Object o){
		Shop s = (Shop)o;
		return this.total-s.total;
		
	}
	
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

void ProblemA();
void ProblemB();
void ProblemC();
void ProblemD();

int main() {
  ProblemA();
  return 0;
}

void ProblemA() {
  uint32_t a;
  string s;

  cin >> a >> s;

  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int n = b - a;
    System.out.println(n * (n + 1) / 2 - b);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
// typedef __uint128_t u128;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> ii;
typedef vector<pair<ll, ll>> vii;
typedef vector<vector<pair<ll, ll>>> vvii;
typedef long double ld;
typedef vector<long double> vld;
typedef vector<vector<long double>> vvld;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;
#define ff first
#define ss second
#define pb push_back
#define all(c) (c).begin(), (c).end()
const long long MOD = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    set<string> st;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 19240
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N, K;
    cin>>N>>K;
    string s;
    cin>>s;
    cout << s.substr(0,K-1);
    if(s[K-1]=='A') cout << "a";
    if(s[K-1]=='B') cout << "b";
    if(s[K-1]=='C') cout << "c";
    cout << s.substr(K, N-K) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
typedef pair <int, int> P;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char f[1001][1001];
int vd[1001][1001];
int esax[10], esay[10];
int h, w, n;
int bfs(int sx, int sy, int gx, int gy){
    rep(i, h + 1) rep(j, w + 1) vd[i][j] = INF;
    queue <P> opt;
    opt.push(P(sx, sy));
    vd[sy][sx] = 0;
    while(opt.size()){
        P p = opt.front(); opt.pop();
        if(p.first == gx && p.second == gy)
          return vd[gy][gx];
        rep(i, 4){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if(0 <= nx && 0 <= ny && vd[ny][nx] == INF && f[ny][nx] != 'X'){
                opt.push(P(nx, ny));
                vd[ny][nx] = vd[p.second][p.first] + 1;
            }
        }
    }
}
int main(){
    cin >> h >> w >> n;
    rep(i, h) rep(j, w){
        cin >> f[i][j];
        if(f[i][j] == 'S')
          esax[0] = j, esay[0] = i;
        if('1' <= f[i][j] && f[i][j] <= '9'){
            int num = f[i][j] - '0';
            esax[num] = j, esay[num] = i;
        }
    }
    rep(j, w) f[h][j] = 'X';
    rep(i, h) f[i][w] = 'X';
    int ans = 0;
    rep(i, n)
      ans += bfs(esax[i], esay[i], esax[i + 1], esay[i + 1]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(void)
{
  string s;
  vector<char>res;
  string sout;

  cin>>s;

  for(int i=0;i<3;i++)
  {
    res.push_back(s[i]);
  }

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

  for(int i=0;i<3;i++)
  {
    sout+=res[i];
  }

  if(sout=="abc")
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int x;
	cin >> x;
	if(x % 2 == 0){
		cout << x << endl;
	}
	else cout << x * 2 << endl;
	
	
	

						
	return 0;
}


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

using namespace std;

void solve()
{
	int as[5];
	for (int i = 0; i < 5; i++)
	{
		cin >> as[i];
	}
	int k;
	cin >> k;
	sort(as, as + 5);
	cout << ((as[4] - as[0] <= k) ? "Yay!" : ":(") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,a,b,x[101010]={};
	cin>>n>>a>>b;
	LL ans=0LL;
	FOR(i,0,n){
		cin>>x[i];
	}
	FOR(i,1,n){
		if((x[i]-x[i-1])*a>b){
			ans+=b;
		}else{
			ans+=(x[i]-x[i-1])*a;
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int gcd(long long s,long long t){
    if(s%t==0){
        return t;
    }
    else{
        return gcd(t,s%t);
    }
}
int main(){
    long long n,x;
    cin>>n>>x;
    long long a[n];
    f(i,0,n){
        cin>>a[i];
        a[i]=abs(a[i]-x);
    }
    long long ans=a[0];
    f(i,0,n){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4280
MAX = 10**6
is_prime = [True for i in range(MAX)]
is_prime[0] = False
is_prime[1] = False
primes = []
for i in range(MAX):
    if is_prime[i]:
        primes.append(i)
        for j in range(2*i, MAX, i):
            is_prime[j] = False

def solve(n, p):
    if n == 1:
        return p
    D = {}
    i = 0
    m = len(primes)
    while (i < m) and (p > 1):
        q = primes[i]
        while (p % q == 0):
            p //= q
            if not q in D:
                D[q] = 0
            D[q] += 1
        i += 1
    ans = 1
    for q, num in D.items():
        ans *= q**(num // n)
    return ans

n, p = map(int, input().split())
print(solve(n, p))

Measured memory_bytes: 14140
import io.StdIn._
object Main extends App {
    val n = readInt
    val as = for(_ <- 1 to n) yield readInt

    def rec(index: Int, acc: Map[Int, Int]): Map[Int, Int] = {
        if(n-1 < index) return acc
        else {
            val a = as(index)
            acc.get(a) match {
                case Some(value) =>  rec(index+1, acc.updated(a, value+1))
                case None        =>  rec(index+1, acc+(a -> 1))
            }
        }
    }

    val map = rec(0, Map.empty)
    println(map.values.count(_%2==1))
}

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

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=2e5+1, mod=1e9+7;

ll power(int a,int n){
	if(n==0) return 1;
	ll x=power(a,n/2);
	x=(x*x)%mod;
	if(n&1) return (x*a)%mod;
	return x;
}

ll comb(int n,int r){
	ll num=1,den=1;
	for(int i=r+1;i<=n;i++) num=(num*i)%mod;
	for(int i=2;i<=n-r;i++) den=(den*i)%mod;
	
	return num*power(den,mod-2)%mod;
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int x,y;
	cin>>x>>y;
	if( y>=(x+1)/2 &&y<=2*x && (2*x-y)%3==0 ){
		cout<<comb( (x+y)/3,(2*x-y)/3);
		
	}else cout<<0;
	
    yogeshk972();
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")

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

using namespace __gnu_pbds;
using namespace std;

//smaller names
#define int long long
#define double long double
#define Int signed
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define pii pair<int, int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define mii map<int, int>
#define unordered_map gp_hash_table

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, b) for(int i = a; i < b; i++)
#define repd2(i, a, b) for(int i = b - 1; i >= a; i--)
#define repd(i, n) for(int i = n-1; i >= 0; i--)

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(),v.end()

const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acosl(-1);

//order_of_key(k) - number of elements e such that func(e, k) returns true, where func is less or less_equal
//find_by_order(k) - kth element in the set counting from 0

typedef tree <
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update
> 
ordered_set;

typedef tree <
    int,
    null_type,
    less_equal<int>,
    rb_tree_tag,
    tree_order_statistics_node_update
>
ordered_multiset;

const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
const int maxa = 1e6 + 5;
const int logmax = 25;

//fast exponentiation

template <typename T>
T power (T a, int n = 1, T id = 1) {
    T ans = id;
    while(n) {
        if(n & 1) ans *= a;
        a *= a;
        n >>= 1;
    }
    return ans;
}

//custom hash

struct custom_hash {
    // http://xorshift.di.unimi.it/splitmix64.c
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int sumdigs (int n) {
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}


void solve() {
    int a; cin >> a;
    cout << a * (1 + a * (1 + a)) << endl;
}

signed main(){
    fastio;
    cout << setprecision(6) << fixed;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3596
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }

    const MAX_NUM: usize = 1000000;
    let mut g = 0;
    // let is_set_wise = a.iter().fold(0, |acc, ai| acc.gcd(ai)) == 1;

    let era = Eratosthenes::new(MAX_NUM);
    let mut divisor_counter = [0; MAX_NUM + 1];
    
    let mut flag = false;

    for ai in a {
        g = g.gcd(&ai);

        let hm = era.factorization(ai);

        for (k, _v) in hm {
            divisor_counter[k] += 1;
            if divisor_counter[k] >= 2 {
                flag = true;
                break;
            }
        }
    }

    let is_set_wise = g == 1;

    let is_pair_wise = !flag || *divisor_counter.iter().max().unwrap() <= 1;

    let ans = if is_pair_wise {
        "pairwise coprime"
    } else if is_set_wise {
        "setwise coprime"
    } else {
        "not coprime"
    };

    println!("{}", ans);
}

use itertools::Itertools;
use num::Integer;
use rustc_hash::FxHashMap;
use smallvec::alloc::collections::BTreeMap;
use std::collections::HashMap;
use std::mem::swap;

/// 二分累乗法
pub fn pow(x: isize, n: usize) -> isize {
    if n == 0 {
        1
    } else if n == 1 {
        x
    } else if n % 2 == 1 {
        x * pow(x, n - 1)
    } else {
        pow(x * x, n / 2)
    }
}

/// エラトステネスの篩
/// 構築 O(N log log N)
/// 素因数分解 O(log N)
/// 素数判定 O(log N)
pub struct Eratosthenes {
    smallest_prime_factors: Vec<usize>,
}

impl Eratosthenes {
    pub fn new(n: usize) -> Self {
        let mut smallest_prime_factors = (0..=n).collect_vec();

        for i in 2..n {
            if i * i > n {
                break;
            }

            if smallest_prime_factors[i] != i {
                continue;
            }

            let mut j = i * i;
            while j <= n {
                if smallest_prime_factors[j] == j {
                    smallest_prime_factors[j] = i;
                }

                j += i;
            }
        }

        Self {
            smallest_prime_factors,
        }
    }

    pub fn factorization(&self, mut i: usize) -> FxHashMap<usize, usize> {
        assert_ne!(i, 0);

        let mut factors = FxHashMap::default();

        while i != 1 {
            let divisor = self.smallest_prime_factors[i];
            *factors.entry(divisor).or_insert(0) += 1;

            i /= divisor;
        }

        factors
    }

    pub fn is_prime(&self, i: usize) -> bool {
        i >= 2 && self.smallest_prime_factors[i] == i
    }
}


Measured memory_bytes: 29220
n=int(input())
start=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b,f,r,v=[int(i) for i in input().split()]
    start[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" ",end="")
            print(start[i][j][k],end="")
        print()
    if i<=2:
        for m in range(20):
            print("#",end="")
        print()  


Measured memory_bytes: 5644
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;

int n,a,b;
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	if (a>b) printf("0\n");
	else if (n==1) 
	{
		if (a==b) printf("1\n");
		else printf("0\n");
	}
	else printf("%lld\n",(1ll*(n-2)*b)-(1ll*(n-2)*a)+1);
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "strconv"
  "math"
)

func main() {
  var a, b string
  fmt.Scan(&a, &b)
  c, _ := strconv.Atoi(a + b)
  d := float64(c)
  ans := "No"
  if math.Pow(math.Floor(math.Sqrt(d)), 2) == d {
    ans = "Yes"
  }
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define rollcall cout<<"I'm Sucu."<<endl
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl
 
signed main(){
    string S;int w;
    cin >> S >> w;
    for(int i=0;i<S.size();i+=w){
        cout << S[i];
    }
    cout << Endl;
    return 0;
}   


Measured memory_bytes: 256
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] inputs = readln.chomp.split.to!(int[]);
  std.algorithm.sort!"a<b"(inputs);
  writeln(inputs == [5,5,7] ? "YES" : "NO");
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<queue>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin,(x).end
using namespace std;
int main(){
  int n,j=0;
  long long h=0,ans=0;
  scanf("%d",&n);
  int a[200001];
  for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(int i=0;i<n;i++){
    for(j;j<n;j++)
      if((h|a[j])!=h+a[j])
        break;
      else
        h=h+a[j], 
    ans+=j-i+1;
    h-=a[i];
  }
  cout<<ans;
  system("pause");
  return 0;
}

Measured memory_bytes: 1272
#include<stdio.h>

int main(void){
  int n, m, a[100][100], b[100];

  scanf("%d %d", &n, &m);

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

  for(j=0;j<m;j++){
    scanf("%d", &b[j]);
  }

  int c[100];

  for(i=0;i<n;i++){
    c[i] = 0;
  }
    
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i] +=  a[i][j] * b[j];
    }
  }

  for(i=0;i<n;i++){
     printf("%d\n", c[i]);
  }

  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

vector<vector<pair<int,int>>> tree;
vector<int> col;

void solve(int v,int n,int n_col){
  for(auto nv : tree.at(v)){
    if(col.at(nv.second)!=-1){
      continue;
    }
    n_col++;
    n_col%=n;
    col.at(nv.second)=n_col;
    solve(nv.first,n,n_col);
  }
}

int main(){
  int N;
  cin>>N;
  tree.resize(N);
  col.resize(N-1,-1);
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    tree.at(b).push_back(make_pair(a,i));
    tree.at(a).push_back(make_pair(b,i));
  }
  int k=0;
  for(int i=0;i<N;i++){
    if(tree.at(i).size()>tree.at(k).size()){
      k=i;
    }
  }
  int n=tree.at(k).size();
  solve(k,n,0);

  cout<<n<<endl;
  for(int i=0;i<N-1;i++){
    cout<<col.at(i)+1<<endl;
  }
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
typedef long long ll;
using namespace std ;
 
int main() {
    const ll MOD = 1e9+7;
    int N;
    cin>>N;
    int M;
    cin>>M;
    unordered_set<int> ob;
    vector<ll> dp(N+2); 
    for(int i=0;i<M;i++){
       	int tmp;
        cin>>tmp;
        ob.insert(tmp);
    }
  	dp[0]=0;
    dp[1]=1;
    for(int i=2;i<=N+1;i++){
    	if(ob.count(i-1)>0)
          dp[i]=0;
      	else{
        	dp[i]=dp[i-1]+dp[i-2];
        }
      	dp[i] %= MOD;
    }
  	cout<<(dp.back())<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    ll T;
    cin >> n >> T;
    ll t[n];
    rep(i, n) cin >> t[i];
    ll res = 0;
    res += T;
    for (int i = 1; i < n; i++)
    {
        ll step = t[i] - t[i - 1];
        res -= MAX(0, T - step);
        res += T;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
#define LL  long long
#define LIM 100000
#define mx  1000000007

int dp[LIM+5], vis[LIM+5];
int n, k, ara[LIM+5];

int f(int pos){
    if(pos == n) return 0;
    if(pos > n) mx;
    if(vis[pos]) return dp[pos];
    vis[pos] = 1;

    int mn = mx;
    for(int i = 1; i <= k; i++){
        if(pos+i > n) break;
        mn = min(mn, abs(ara[pos]-ara[pos+i]) + f(pos+i));
    }
    return dp[pos] = mn;
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", ara+i);
    int res = f(1);

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


Measured memory_bytes: 12700
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://arc078.contest.atcoder.jp/tasks/arc078_b>
 問題文============================================================
 フェネックとすぬけくんがボードゲームで遊んでいます。
 
 このボードゲームには 1 番から N 番までの番号がついた N 個のマスと、
 マスどうしをつなぐ N−1 本の道が存在しています。
 ai 番のマスと bi 番のマスは i 番目の道を介して隣り合っています。
 どの 2 つのマスも隣接するマスをいくつか辿って必ず辿り着くことが可能です。
 すなわち、グラフ理論の言葉を用いると、マスと道から構成されるグラフは木です。
 
 はじめに 1 番のマスは黒く、N 番のマスは白く塗られています。
 その他のマスはまだ色が塗られていません。
 先手のフェネックと後手のすぬけくんは残りのマスに交互に色を塗ります。
 自分の手番において、2 人はそれぞれ以下のような行動を行います。
 
 フェネック：黒く 塗られたマスに隣接したマスであって、色が塗られていないマスを 1 つ選んで 黒く 塗る。
 すぬけくん：白く 塗られたマスに隣接したマスであって、色が塗られていないマスを 1 つ選んで 白く 塗る。
 
 手番のプレイヤーがマスに色を塗ることができなかったとき、敗者となります。
 フェネックとすぬけくんが最適に行動したとき勝者はどちらか判定してください。
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
ll N;

void dfs(ll n,ll dep,vector<ll>& checked,vector<vector<ll>>&G){
    checked[n] = dep;
    for(ll next : G[n]){
        if(checked[next] != -1) continue;
        dfs(next,dep+1,checked,G);
    }
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    vector<vector<ll>> G(N);
    for(int i = 0; i < N-1;i++){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<ll> Fennec(N,-1),Snuke(N,-1);
    dfs(0,0,Fennec,G);
    dfs(N-1,0,Snuke,G);
    
    ll Fennec_have = 0, Snuke_have = 0;
    for(int i = 0; i < N;i++){
        //cout << i+1 << " : " << Fennec[i] << " " << Snuke[i] << endl;
        if(Fennec[i] <= Snuke[i]) Fennec_have++;
        else Snuke_have++;
    }
    //cout << Fennec_have << " " << Snuke_have << endl;
    if(Fennec_have > Snuke_have){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}


Measured memory_bytes: 12032
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    ll n,m;
    cin >> n >> m;
    mpll mp;
    for (int i = 0; i < m; ++i)
    {
    	int a;
    	cin >> a;
    	mp[a]++;
    }
    for(int i=n;i<=1000000;i++)
    {
    	ll nn=i;
    	ll impos=0;
    	while(nn)
	    {
	    	int r=nn%10;
	    	if(mp[r]!=0)impos++;
	    	nn/=10;
	    }
	    if(!impos)
	    {
	    	cout<<i<<endl;
	    	return 0;
	    }

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[2][2019];
int mod=2019;
int main(){
    int res=0;
    string S;cin>>S;
    //cout<<"hi"<<endl;
    for(int i=0;i<S.size();i++){
        int m=S[i]-'0';
        for(int j=0;j<2019;j++){
        dp[1][(j*10+m)%mod]+=dp[0][j];
        //if(dp[1][j]>0)cout<<i<<" "<<j<<" "<<dp[1][j]<<endl;
        }
        dp[1][m]+=1;
        res+=dp[1][0];
        //if(dp[i+1][0]>0)cout<<i<<" "<<dp[i+1][0]<<endl;
            for(int j=0;j<2019;j++){
                dp[0][j]=dp[1][j];
                dp[1][j]=0;
        }
        

    }
    cout<<res<<endl;
    
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll P = 998244353;

class C {
public:
  int n;
  vector<long long> fac, inv, facInv;

  long long power(long long e, long long x) {
    if (x == 0)
      return 1;
    if (x == 1)
      return e;
    if (x % 2 == 0)
      return power((e * e) % P, x / 2);
    return (e * power(e, x - 1)) % P;
  }

  C(int n_) {
    n = n_;
    fac.resize(n + 1);
    inv.resize(n + 1);
    facInv.resize(n + 1);
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= n; i++)
      fac[i] = (i * fac[i - 1]) % P;
    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
      inv[i] = power(i, P - 2);
    facInv[0] = facInv[1] = 1;
    for (int i = 2; i <= n; i++)
      facInv[i] = (inv[i] * facInv[i - 1]) % P;
  }

  long long comb(int N, int K) {
    if (N < K || K < 0 || N < 0)
      return 0;
    if (N == 0 || K == 0 || K == N)
      return 1;
    return ((fac[N] * facInv[K]) % P * facInv[N - K]) % P;
  }

  long long hcomb(int N, int K) {
    if (N == 0 && K == 0)
      return 1;
    return comb(N + K - 1, K);
  }

  long long mul(long long a, long long b) { return (a * b) % P; }

  long long add(long long a, long long b) { return (a + b) % P; }

  // find c
  // where a^c = b (mod P)
  long long dlp(long long a, long long b) {
    long long m = ceil(sqrt(P));
    map<long long, long long> mp;
    for (int i = 0; i < m; i++)
      mp[power(a, i)] = i;
    long long ainvm = power(power(a, m), P - 2);
    cout << m << endl;
    for (int i = 0; i < m; i++) {
      if (mp.find(b) != mp.end()) {
        return i * m + mp[b];
      }
      b = mul(b, ainvm);
    }
    return -1;
  }
};

C cmb(202020);

ll f(ll l, ll sum) {
  ll two = sum - l;
  ll one = l - two;
  if (two < 0 || one < 0) return 0;
  return ((cmb.fac[one + two] * cmb.facInv[one]) % P * cmb.facInv[two]) % P;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int s = 0; s < x; s++) {
      ll temp = ((cmb.fac[n] * cmb.facInv[i]) % P * cmb.facInv[n - i]) % P;
      ans += (temp * f(i, s)) % P;
      ans %= P;
    }
  }
  for (int i = 1; x + i <= 2 * n; i += 2) {
    if (i + 1 >= x - 1) {
      if (x % 2) {
        ans += ((cmb.fac[n] * cmb.facInv[(x + i) / 2]) % P * cmb.facInv[n - (x + i) / 2]) % P;
        ans %= P;
      }
    } else {
      for (int j = 0; j <= n; j++) {
        ans += (f(j, x - i - 2) * cmb.comb(n, i + j + 1));
        ans %= P;
      }
    }
  }

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


Measured memory_bytes: 4992
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  
  ll h,w,k;cin>>h>>w>>k;
  ll sg,sr,gg,gr;cin>>sg>>sr>>gg>>gr;
  sg--;sr--;gg--;gr--;

  V<string> v(h);
  rep(i,0,h)cin>>v[i];

  VV<V<int>> c(h,VV<int>(w,V<int>(4,INF)));//cost

  deque<int> q;
  q.push_back(sg);
  q.push_back(sr);
  q.push_back(0);
  q.push_back(0);
  q.push_back(0);
  rep(i,0,4)c[sg][sr][i]=0;

  while(q.size()){
    int ng,nr,dir,con,cost;//行位置、列位置、前回進んだ方向、同じ方向に連続で進んだ回数、累計の移動コスト
    ng=q.front();q.pop_front();
    nr=q.front();q.pop_front();
    dir=q.front();q.pop_front();
    con=q.front();q.pop_front();
    cost=q.front();q.pop_front();

    int neg,ner;
    rep(i,0,4){
      neg=ng+dx[i],ner=nr+dy[i];

      if(neg<0 || neg>=h || ner<0 || ner>=w)continue;
      if(v[neg][ner]=='@')continue;

      if(1<=con && con<=k-1 && i==dir){
        if(cost>=c[neg][ner][i])continue;
        q.push_front(cost);
        q.push_front(con+1);
        q.push_front(i);
        q.push_front(ner);
        q.push_front(neg);
        c[neg][ner][i]=cost;
      }else{
        if(cost+1>=c[neg][ner][i])continue;
        q.push_back(neg);
        q.push_back(ner);
        q.push_back(i);
        q.push_back(1);
        q.push_back(cost+1);
        c[neg][ner][i]=cost+1;
      }
    }
  }
  

  ll ans=INF;
  rep(i,0,4)chmin(ans,c[gg][gr][i]);
  if(ans==INF)cout<<-1<<ENDL;
  else cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 113540
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 15
#define M 5010
using namespace std;
ll n,m,cga[N],cgb[N],caa=0,cab=0;
string sts[N],stc[N];
int main(){
	ll i,j,cnt;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>sts[i];
	}
	for(i=0;i<m;i++)
	{
		stc[i]="";
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			stc[j]+=sts[i][j];
		}
	}
	for(i=0;i<n;i++)
	{
		sort(sts[i].begin(),sts[i].end());
	}
	for(i=0;i<m;i++)
	{
		sort(stc[i].begin(),stc[i].end());
	}
	for(i=0;i<n;i++)
	{
		cnt=0;
		for(j=0;j<n;j++)
		{
			if(sts[i]==sts[j])
			{
				cnt++;
			}
		}
		cga[cnt]++;
	}
	for(i=0;i<m;i++)
	{
		cnt=0;
		for(j=0;j<m;j++)
		{
			if(stc[i]==stc[j])
			{
				cnt++;
			}
		}
		cgb[cnt]++;
	}
	for(i=1;i<12;i+=2)
	{
		caa+=cga[i]/i;
	}
	for(i=1;i<12;i+=2)
	{
		cab+=cgb[i]/i;
	}
	if(caa>n%2||cab>m%2)
	{
		puts("NO");
	}
	else if((n%2==0&&caa)||(m%2==0&&cab))
	{
		puts("NO");
	}
	else if(n>=7&&n<=9&&m>=7&&m<9&&cga[n]&&cgb[m])
	{
		puts("NO");
	}
	else
	{
		puts("YES");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;

#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define swap2(x, y) x=x^y; y=x^y; x=x^y;
#define print(x) if (false) {cout << "[" << #x << " = " << x << "] ";}
#define printNL() if (false) {cout << endl;}

int main() {
    int d, t, s; cin >> d >> t >> s;
    if ((d+s-1)/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


namespace ConsoleApplication22
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] cs = s.ToCharArray();
            for (int i = 0; i < cs.Length; i++)
            {
                if (char.IsUpper(cs[i]))
                {
                    cs[i] = char.ToLower(cs[i]);
                }
                else if (char.IsLower(cs[i]))
                {
                    cs[i] = char.ToUpper(cs[i]);
                }
            }
            string s2 = new string(cs);
            Console.WriteLine(s2);
            Console.ReadLine();

        }
    }
}

Measured memory_bytes: 9212