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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
string s;
/******* define variable end *******/
ll solve()
{
    cin >> s;
    if (s.substr(2, 1) == s.substr(3, 1) && s.substr(4, 1) == s.substr(5, 1))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 764
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = LIST()

a.sort()

if(a[0]+a[1]==a[2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 71072
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

int gcd(int a,int b){
    if(a<=0||b<=0){
        return 0;
    }
    if(a<b)swap(a,b);
    int r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}


signed main(void){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    A--;
    int G,L;
    G=gcd(C,D);
    L=C*D/G;
    //cout << L << endl;
    int Ans=0;
    Ans+=((int)(B-B/D) + (int)(B-B/C) - (int)(B-B/L));
    //cout << Ans << endl;
    Ans-=((int)(A-A/D) + (int)(A-A/C) - (int)(A-A/L));
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BIronBarCutting solver = new BIronBarCutting();
        solver.solve(1, in, out);
        out.close();
    }

    static class BIronBarCutting {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // それぞれの切れ目でかかる金額を考えてやればいい。
            // |sum(left) - sum(right)|かかるのは自明
            // 累積和でしてやればいい
            int n = in.nextInt();
            long[] l = new long[n];
            long[] acc = new long[n + 1];
            long min = Long.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                l[i] = in.nextLong();
                acc[i + 1] = acc[i] + l[i];
            }

            for (int i = 1; i < n; i++) {
                min = Math.min(min, Math.abs(acc[n] - acc[i] * 2));
            }
            out.println(min);

        }

    }
}



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

int main(){
int a,b,c,k;
  cin >> a >> b >> c >>k;
  for(int i=0;i<k;i++){
  if(a<c&&b<c)c*=2;
  else if(a<b)b*=2;
  else a*=2;
  }
  cout << a+b+c << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
e=0
ans=0
x=0
g=0
for s in range(n):
    while x==g and e<n:
        x^=l[e]
        g+=l[e]
        e+=1
    if e==n and x==g:
        ans+=e-s
    else:
        ans+=e-s-1
        x^=l[s]
        g-=l[s]
print(ans)


Measured memory_bytes: 77900
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> vec(n, 0);
  reps(i, 1, n+1) {
    reps(j, i+1, n+1) {

      int a = abs(j - i);
      int b = abs(j-y) + 1 + abs(x-i);
      vec.at(min(a, b))++;
      
    }
  }
  reps(i, 1, n) {
    cout << vec.at(i) << endl;
  }
  return 0;
}

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

using namespace std;

class BIT {
 private:
  vector<int> tree;
 public:
  BIT(int n) : tree(n+1) {}
  int sum(int i) const {
    int s = 0;
    while (i > 0) {
      s += tree[i];
      i -= i & -i;
    }
    return s;
  }
  void add(int i, int x) {
    while (i < tree.size()) {
      tree[i] += x;
      i += i & -i;
    }
  }
};

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

  int N; cin>>N;
  BIT bit(N);
  long ans = 0;
  for (int i = 0; i < N; i++) {
    int p; cin>>p;
    bit.add(p, 1);
    if (i + 1 - bit.sum(p-1) == i+1)
      ans++;
    cerr << ans << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int h, w; cin >> h >> w;
  auto cnt = 0;
  rep(i, h*w) {
    char c; cin >> c;
    if (c == '#') {
      cnt++;
    }
  }
  if (cnt == h+w-1) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
"use strict";
(function(input){
  input=input.trim();
  input=input.split(/\s+/).map(x=>x-0);
  let L=input[0],R=input[1];
  if((L-L%2019)/2019!==(R-R%2019)/2019){
    console.log(0);
    return;
  }
  let ans=Infinity;
  L=L%2019,R=R%2019;
  for(let i=L;i<R;i++){
    for(let j=i+1;j<=R;j++){
      if((i*j)%2019<ans){
        ans=(i*j)%2019;
      }
    }
  }
  console.log(ans);
})(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 21064
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
int N, M;
vector<vector<int>>A, C;
vector<bool> B;
int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		vector<int> tmp;
		A.push_back(tmp);
		B.push_back(false);
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		A[a].push_back(b);
		A[b].push_back(a);
	}
	for (int i = 0; i < N; i++) sort(A[i].begin(), A[i].end(), greater<int>());

	for (int i = 0; i < N; i++) {
		if (B[i]) continue;
		vector<int>V;
		B[i] = true;
		V.push_back(i);

		queue<int> D;
		D.push(i);
		while (!D.empty()) {
			int tmp = D.front();
			D.pop();
			for (int j = 0; j < A[tmp].size(); j++) {
				if (!B[A[tmp][j]]) {
					D.push(A[tmp][j]);
					B[A[tmp][j]] = true;
					V.push_back(A[tmp][j]);
				}
			}

		}
		C.push_back(V);

	}
	int ANS = 0;
	for (int i = 0; i < C.size(); i++) {
		ANS = max(ANS, int(C[i].size()));
	}
	cout << ANS << endl;
}

Measured memory_bytes: 19788
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	
	int n;
	cin>>n;
	vi a(n);
	for0(i,n) cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[n-1] - a[0]<<nw;
	return 0;
}

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<int, ll> PIL;
typedef pair<ll, ll> PL;
const ll mod = 1e9 + 7;

const int N = 100100;
int n;
vector<PIL> g[N];
vector<PL> edges;

VI centroid;

ll evenly;

// Returns the size of the subtree whose root is v.
int dfs(int v, int p) {
  int sz = 1;
  bool is_centroid = 1;
  for (PIL wc: g[v]) {
    int w = wc.first;
    ll c = wc.second;
    if (w == p) continue;
    int sub = dfs(w, v);
    sz += sub;
    if (2 * sub >= n) {
      is_centroid = 0;
    }
    if (2 * sub == n) {
      evenly = c;
    }
    int opp = n - sub;
    int times = opp == sub ? 2 * sub - 1 : 2 * min(opp, sub);
    edges.push_back(PL(c, times));
  }
  if (2 * sz < n) {
    is_centroid = 0;
  }
  if (is_centroid) centroid.push_back(v);
  return sz;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  REP(i, 0, n - 1) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--, b--;
    g[a].push_back(PIL(b, c));
    g[b].push_back(PIL(a, c));
  }
  dfs(0, -1);
  sort(edges.begin(), edges.end());
  ll tot = 0;
  REP(i, 0, edges.size()) {
    PL e = edges[i];
    tot += e.first * e.second;
  }
  if (evenly == 0) {
    ll mi = 1e17;
    assert (centroid.size() == 1);
    int v = centroid[0];
    REP(i, 0, g[v].size()) {
      mi = min(mi, g[v][i].second);
    }
    tot -= mi;
  }
  cout << tot << endl;
}


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

int main() {
    int a;
    cin >> a;
    for (int i = 9; i >= 1; --i) {
        if (a % i == 0) {
            a /= i;
            break;
        }
    }
    if (a <= 9) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A_sum = np.inf
if N == 1:
    print(0)
else:
    for x in range(min(A), max(A)+1):
        A_sum_new = sum([(a - x)**2 for a in A])
        if A_sum_new <= A_sum:
            A_sum = A_sum_new

    print(A_sum)


Measured memory_bytes: 12444
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int n;
                    cin>>n;
                    if(n>=30)
                         cout<<"Yes";
                    else
                         cout<<"No";
          }
          return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;

    cin>>n;
    for(ll i=0;i<n;i++){
    	ll l;
    	cin>>l;
    	if(l%2){
    		continue;
    	}
    	if(l%3==0 || l%5 == 0){
    		continue;
    	}
    	cout<<"DENIED";
    	return 0;
    }
    cout<<"APPROVED";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<queue>
using namespace std;

typedef pair<int,int> P;

int main(){
  int h,w;
  string g[30],p;
  int t[30][30];

  while(cin >> h >> w , h||w){
    int ay,ax,by,bx;
    for(int i=0;i<h;i++){
      cin >> g[i];
      for(int j=0;j<w;j++){
	if(g[i][j] == 'A'){ay = i; ax = j; g[i][j] = '.';}
	if(g[i][j] == 'B'){by = i; bx = j; g[i][j] = '.';}
	t[i][j] = -1;
      }
    }

    cin >> p;
    int s = p.size();

    t[ay][ax] = 0;
    queue<P> q;
    q.push(P(ay,ax));
    int m;

    while(q.size()){
      P p = q.front();q.pop();
      int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

      for(int i=0;i<4;i++){
	int ty = p.first + dy[i], tx = p.second + dx[i];
	if(ty<0 || tx<0 || h<=ty || w<=tx || g[ty][tx] == '#')continue;
	if(t[ty][tx]<0){
	  m = t[ty][tx] = t[p.first][p.second] + 1;
	  q.push(P(ty,tx));
	}
      }
    }

    bool f = false;
    for(int cnt=0;cnt<100000;cnt++){
      if(p[cnt%s]=='8' && 0<by)by--;
      if(p[cnt%s]=='6' && bx<w-1)bx++;
      if(p[cnt%s]=='4' && 0<bx)bx--;
      if(p[cnt%s]=='2' && by<h-1)by++;
      if(0<=t[by][bx] && t[by][bx]<=cnt+1){
	cout << cnt+1 << " " << by << " " << bx << endl;
	f = true;
	break;
      }
    }
    if(!f)cout << "impossible\n";
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
 
#define PI 3.141592653589793
 
int main(void){
    int a,b,c;
    double s,l,h;
     
    scanf("%d%d%d",&a,&b,&c);
     
    s = sin(c * PI / 180.0)*a*b/2;
    l = a + b + sqrt(a*a + b*b - 2*a*b * cos(c * PI / 180.0));
    h = s/a*2;
     
    printf("%lf %lf %lf\n" ,s,l,h);
     
    return 0;
}


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

struct C{
  C(){};
  C(string ss,vector<int> tt){
    s = ss;
    t = tt;
  }
  string s;
  vector<int> t;
};

struct A{
  A(){};
  A(string ss,int pp){
    s= ss;
    p = pp;
  }
  string s;
  int p;
};

bool operator<(A a,A b){
  if(a.p!=b.p){
    return a.p<b.p;
  }else{
    return a.s<b.s;
  }
}

int N;
vector<int> num;
vector<C> c;
void init(){
  num.clear();
  num.resize(40);
  c.clear();
}

bool input(){
  int n;
  cin>>n;
  if(n==0)return false;
  N=n;
  for(int i=0;i<n;i++){
    string ts;
    cin>>ts;
    int tn;
    cin>>tn;
    vector<int> tv;
    for(int i=0;i<tn;i++){
      int tmp;
      cin>>tmp;
      num[tmp]++;
      tv.push_back(tmp);
    }
    c.push_back(C(ts,tv));
  }
  return true;
}

int cal(vector<int> t){
  int res=0;
  for(int i=0;i<t.size();i++){
    res += max(0,N-num[t[i]]+1);
  }
  return res;
}

void solve(){
  vector<A> ans;
  for(int i=0;i<c.size();i++){
    ans.push_back(A(c[i].s,cal(c[i].t)));
  }
  sort(ans.begin(),ans.end());
  cout<<ans[0].p<<" "<<ans[0].s<<endl;
}


int main(){
  while(init(),input()){
    solve();
  }
}

Measured memory_bytes: 1256
var
	n,m,i,a,b:Longint;
	used:array[1..8]of Boolean;
	c:array[1..8]of Longint;
	G:array[1..8,1..7]of Longint;
function f(u,cnt:Longint):Longint;
var i,ret:Longint;
begin
	if cnt=n then begin
		f:=1;
		exit;
	end;
	ret:=0;
	for i:=1 to c[u] do begin
		if not used[G[u,i]]then begin
			used[G[u,i]]:=True;
			inc(ret,f(G[u,i],cnt+1));
			used[G[u,i]]:=False;
		end;
	end;
	f:=ret;
end;
begin
	read(n,m);
	for i:=1 to m do begin
		read(a,b);
		inc(c[a]);
		inc(c[b]);
		G[a,c[a]]:=b;
		G[b,c[b]]:=a;
	end;
	used[1]:=True;
	writeln(f(1,1));
end.

Measured memory_bytes: 128
s = input()
left = 0
cou = 0
k = 0
l = [0 for i in range(len(s)+1)]
for i in range(len(s)):
  s1 = s[i]
  a1 = l[i]
#  print(s1,l,left,cou,k)
  if s1=='<':
    l[i+1] = l[i]+1
    left = 0
    k = l[i+1]
  else:
    l[i+1] = l[i]-1
    left += 1
    if l[i+1]>=0:
      l[i+1] = 0
    else:
      l[i+1] =0
      if k>=left:
        cou += left-1
      else:
        cou += left
print(cou+sum(l))
    

Measured memory_bytes: 23988
from collections import defaultdict
def main():
    S = input() + 'T'
    x, y = map(int, input().split())
    #データ加工
    moveX, moveY = [], []
    if S[0] == 'T': moveX.append(0)
    move ={0:moveX, 1:moveY}
    direct = 0
    step = 0
    for s in S:
        if s == 'T':
            if step > 0:
                move[direct].append(step)
                step = 0
            direct ^= 1 
        else:
            step += 1
    #判定
    if possible(x, moveX[1:], moveX[0]) and possible(y, moveY):
        print('Yes')
    else:
        print('No')


def possible(target, move, offset=0):
    l = len(move)
    dp = [defaultdict(lambda:False) for _ in range(l+1)]
    #初期化
    dp[0][0] = True
    for i,m in enumerate(move):
        for key in dp[i]:
            dp[i+1][key+m] = True
            dp[i+1][key-m] = True
    return dp[l][target-offset]


main()

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

int main(){

    int N;
    int A[200000];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> A[i];


    for( int i = 0; i < N; i++ ) A[i] -= i+1;
    sort( A, A+N );

    int b = A[(N-1)/2];
    long sum = 0;
    
    for( int i = 0; i < N; i++ ) sum += (long) abs( A[i] - b );
    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 1024
import sys
from collections import deque
from collections import defaultdict
import math
import copy
input = sys.stdin.readline
sys.setrecursionlimit(20000000)
w,h,x,y = map(int,input().split())
if x == w/2 and y == h/2:
        print(w*h/2,1)
else:
        print(w*h/2,0)

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



int main(){
    int a;
    int b;
    int c;
    int d;
    int e;
    int k;

    cin >> a >> b >> c >> d >> e >> k;

    int ab = b - a;
    int ac = c - a;
    int ad = d - a;
    int ae = e - a;
    int bc = c - b;
    int bd = d - b;
    int be = e - b;
    int cd = d - c;
    int ce = e - c;
    int de = e - d;

    vector<int> arr;

    arr = {ab,ac,ad,ae,bc,bd,be,cd,ce,de};

    string s = "Yay!";

    for (int i=0;i < arr.size() ;i++){
        if (arr[i] > k ){
            s = ":(";
            break;
        }
    }
    cout << s << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dist[10][10];

int main() {
  int h,w;
  cin >> h >> w;
  FOR(i,0,9){
    FOR(j,0,9){
      cin >> dist[i][j];
    }
  }

  FOR(k,0,9){
    FOR(i,0,9){
      FOR(j,0,9){
        chmin(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }

  int a;
  int ans = 0;
  FOR(i,0,h-1){
    FOR(j,0,w-1){
      cin >> a;
      if(a>=0) ans += dist[a][1];
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 100005
#define MOD 1000000007

int main()
{
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n;
    cin >> n;
    cout << (n*(n+1))/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define pie 3.141592653589793238
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=(ans%mod)*(x%mod)%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
li r;
cin>>r;
double ans=2*pie*r;
cout<<fixed<<setprecision(20)<<ans;
  return 0;
}


Measured memory_bytes: 3804
// Last Change: 04/26/2020 21:01:40.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll S, W;
  cin >> S >> W;
  cout << ((S > W) ? "safe" : "unsafe") << endl;
}


Measured memory_bytes: 3128
#include <cstdio>

int main(void)
{
  int i,j,H,W;

  for(;;){
    scanf("%d %d", &H, &W);
    if(H==0&&W==0) break;
    for(i=0;i<H;i++){
      if(i%2==1){
	for(j=0;j<W;j++){
	  if(j%2==1&&j!=W-1) printf("#");
	  if(j%2==1&&j==W-1) printf("#\n");
	  if(j%2==0&&j!=W-1) printf(".");
	  if(j%2==0&&j==W-1) printf(".\n");
	}
      }
      if(i%2==0){
	for(j=0;j<W;j++){
	  if(j%2==1&&j!=W-1) printf(".");
	  if(j%2==1&&j==W-1) printf(".\n");
	  if(j%2==0&&j!=W-1) printf("#");
	  if(j%2==0&&j==W-1) printf("#\n");
	}
      }
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 1020
// 2017/07/10 Tazoe

#include <iostream>
using namespace std;

int gcd(int m, int n)
{
	if(n==0)
		return m;

	return gcd(n, m%n);
}


int main()
{
	int W, H, C;
	cin >> W >> H >> C;

	int g = gcd(W, H);

	cout << W/g*H/g*C << endl;

	return 0;
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int r = 0, w = 0;
	vector<char> c(n);
	rep(i,n){
		cin >> c[i];
		if(c[i] == 'R') ++r;
		else ++w;
	}
	int rr = 0, ww = 0;
	rep(i,n){
		if(c[i] == 'R'){
			if(r <= i) ++rr;
		}
		else{
			if(i < r) ++ww;
		}
	}
	int ans = max(rr, ww);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
	int i,x;
	int a,b,c;
	
	a=b=c=0;
	for(i=0;i<10;i++)
	{
		scanf("%d",&x);
		if(a<x)
		{
			if(b<x)
			{
				a=b;
				if(c<x)
				{
					b=c;
					c=x;
				}
				else
				{
					b=x;
				}
			}
			else
			{
				a=x;
			}
		}
	}
	printf("%d\n",c);
	printf("%d\n",b);
	printf("%d\n",a);
	
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  ll S;
  ll x1, y1, x2, y2, x3, y3;

  cin >> S;

  x1 = y1 = 0;

  int s = (int)sqrt(S) + 1;

  debug(s);

  x2 = 1e9;
  y3 = (S + x2 - 1) / x2;
  x3 = 1;

  y2 = (x2 * y3 - S) / x3;

  assert(abs(x2 * y3 - x3 * y2) == S);

  printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=500005;
using namespace std;
typedef pair<int,int> pii;
int dp[4*N],n,ar[N],ans[N],q,pos[N],las[N];
vector<pii>qs[N];
void upd(int i,int l,int r,int pos,int val){
    if(l==r){
        dp[i]=val;
        return;
    }
    int m=(l+r)/2;
    if(pos<=m)upd(i*2,l,m,pos,val);
    else upd(i*2+1,m+1,r,pos,val);
    dp[i]=(dp[i*2]+dp[i*2+1]);
}
int get(int i,int l,int r,int se,int en){
    if(se<=l&&r<=en)return dp[i];
    if(l>en||r<se)return 0;
    int m=(l+r)/2;
    int v1=get(i*2,l,m,se,en);
    int v2=get(i*2+1,m+1,r,se,en);
    return v1+v2;
}
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>ar[i];
    for(int i=1;i<=q;i++){
        int l,r;cin>>l>>r;qs[r].push_back({l,i});
    }
    for(int i=1;i<=n;i++){
        if(las[ar[i]]){
            upd(1,1,n,i,1);
            upd(1,1,n,las[ar[i]],0);
        }else{
            upd(1,1,n,i,1);
        }
        las[ar[i]]=i;
        for(auto el:qs[i]){
            //cout<<el.first<<' '<<el.second<<endl;
            int vl=get(1,1,n,el.first,i);
            ans[el.second]=vl;
        }
    }
    for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 35440
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
  char name[10];
  int t;
} P;

void enqueue(P );
P dequeue(void);
int min(int, int);

P Q[LEN];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for( i = 1 ; i <= n ; i++ ){
    scanf("%s", Q[i].name );
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if( u.t > 0 ){
      enqueue(u);
    }
    else{
      printf("%s %d\n", u.name, elaps);
    }
  }
}

void enqueue(P x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = ( head + 1 ) % LEN;
  return x;
}

int min(int a, int b){
  return a < b ? a : b;
}



Measured memory_bytes: 3308
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/A-MaximizeTheFormula.py
#
a, b, c = map(int, input().split())
if a >= b and a >= c:
    print(10 * a + b + c)
elif b >= a and b >= c:
    print(a + 10 * b + c)
else:
    print(a + b + 10 * c)


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
typedef pair<ll, ll> pll;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	ll ans = (n-m) *100 + m * 1900;
	
	ans *=  1LL<<m;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
typedef long double f80;
 
// #define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ef emplace_front
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

ll pwr(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int N = 105;
int dp[N][N][3 * N];
int W[N], V[N];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int n, w;
    cin >> n >> w;
    fr(i, 1, n) {
        cin >> W[i] >> V[i];
    }
    int w1 = W[1];
    fr(i, 1, n) {
        W[i] -= w1;
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    fr(i, 0, n - 1) {
        fr(j, 0, i) {
            fr(k, 0, 3 * j) {
                if(dp[i][j][k] == -1) continue;
                dp[i + 1][j + 1][k + W[i + 1]] = max(dp[i + 1][j + 1][k + W[i + 1]], dp[i][j][k] + V[i + 1]);
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
    }
    int ans = 0;
    fr(j, 0, n) {
        fr(k, 0, 3 * j) {
            if(dp[n][j][k] == -1) continue;
            if((ll)j * w1 + k <= w) ans = max(ans, dp[n][j][k]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long double ll;
typedef pair<ll,ll> P;
ll n,a,b,INF=1e9,LU=1e9,LD=1e9,LR=1e9,LL=1e9,HU=-1e9,HD=-1e9,HR=-1e9,HL=-1e9,SU=-1e9,SD=1e9,SR=-1e9,SL=1e9,ans=1e18,U,D,L,R;
char c;
vector<ll> v;
int main(void){
    cin>>n;
    v.push_back(0);
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        if(c=='U'){
            LU=min(LU,b);
            HU=max(HU,b);
            SR=max(SR,a);
            SL=min(SL,a);
        }
        if(c=='D'){
            LD=min(LD,b);
            HD=max(HD,b);
            SR=max(SR,a);
            SL=min(SL,a);
        }
        if(c=='R'){
            HR=max(HR,a);
            LR=min(LR,a);
            SU=max(SU,b);
            SD=min(SD,b);
        }
        if(c=='L'){
            HL=max(HL,a);
            LL=min(LL,a);
            SU=max(SU,b);
            SD=min(SD,b);
        }
    }
    if(SU<HD&&SU!=-INF&&HD!=-INF)v.push_back(HD-SU);
    if(HD>HU&&HU!=-INF&&HD!=-INF)v.push_back((HD-HU)/2);
    if(HU<SU&&SU!=-INF&&HU!=-INF)v.push_back(SU-HU);
    
    if(SD<LD&&SD!=INF&&LD!=INF)v.push_back(LD-SD);
    if(LD>LU&&LU!=INF&&LD!=INF)v.push_back((LD-LU)/2);
    if(LU<SD&&SD!=INF&&LU!=INF)v.push_back(SD-LU);
    
    if(SR<HL&&SR!=-INF&&HL!=-INF)v.push_back(HL-SR);
    if(HL>HR&&HL!=-INF&&HR!=-INF)v.push_back((HL-HR)/2);
    if(HR<SR&&SR!=-INF&&HR!=-INF)v.push_back(SR-HR);
    
    if(SL<LL&&SL!=INF&&LL!=INF)v.push_back(LL-SL);
    if(LL>LR&&LR!=INF&&LL!=INF)v.push_back((LL-LR)/2);
    if(SL>LR&&SL!=INF&&LR!=INF)v.push_back(SL-LR);
    for(ll x:v){
        U=max(SU,max(HD-x,HU+x));
        D=min(SD,min(LD-x,LU+x));
        R=max(SR,max(HL-x,HR+x));
        L=min(SL,min(LL-x,LR+x));
        ans=min(ans,(U-D)*(R-L));
    }
    cout<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B ;
  C =A*B%2;
  
  if (C ==0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  
}


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

using namespace std;

int main()
{
    int w[10];
    string str;
 
    while (cin >> str) {
	int num = 10;
	for (int i = 0; i < num; i++) {
            w[i] = str[i] - '0';
        }
        
	int a[10] = {0};
	while (num > 1) {
	    for (int i = 1; i < num; i++) {
		a[i-1] = (w[i-1] + w[i]) % 10;
	    }  
	    for (int i = 0; i < num; i++) {
                w[i] = a[i];
            }
            num--;
	}
	cout << a[0] << endl;
    }    
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> c(10,vector<int>(10));
  int sum=0;
  int k=0;
  for(int k=1;k<=N;k++){
    int last=k%10;
    int first=k;
    while(first>9) first=first/10;
    c.at(first).at(last)++;
  }
  for(int i=0;i<=9;i++){
    for(int j=0;j<=9;j++){
      sum += c.at(i).at(j)*c.at(j).at(i);
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
p = 10 ** 9 + 7
dp = np.zeros((N + 1, 4, 4, 4), dtype = "int64")

# dp[0][c3][c2][c1] = 0 for all *** except c1=c2=c3=3
dp[0][3][3][3] = 1
for len in range(0, N):
    for c3 in range(0, 4):
        for c2 in range(0, 4):
            for c1 in range(0, 4):
                for newchar in range(0, 4):
                    # 条件を満たさないもの
                    if c2 == 0 and c1 == 1 and newchar == 2: continue
                    if c2 == 1 and c1 == 0 and newchar == 2: continue
                    if c2 == 0 and c1 == 2 and newchar == 1: continue
                    if c3 == 0 and c1 == 1 and newchar == 2: continue
                    if c3 == 0 and c2 == 1 and newchar == 2: continue
                    dp[len + 1][c2][c1][newchar] += dp[len][c3][c2][c1]
                    dp[len + 1][c2][c1][newchar] %= p

ans = dp[N].sum() % p
print(ans)

Measured memory_bytes: 12508
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char S[1300020];
char S2[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(S, 1, 1300020, stdin);

	int L = -1;
	int R = 99999;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if (S[H] >= 'a' && S[H + 1] >= 'a') L = H;
		else R = H;
	}
	int N = R + 1;
	char* ci = S + N + 1;
	char ct;
	int Q = 0;
	while ((ct = *ci++) >= '0') Q = Q * 10 + ct - '0';

	L = 0;
	R = Q + 1;
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if (*(ci + H * 4 + 2 * Q - 2) >= '0') L = H;
		else R = H;
	}
	int kazu = L;
	bool dotti = (Q - kazu) % 2;

	ci += 4;
	
	if (dotti) {
		char* smae = S2, * sato = S2 + kazu;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* --sato = c;
				else *smae++ = c;
				ci += 6;
			}
		}
		reverse(S, S + N);
		fwrite(sato, 1, kazu - (sato - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, smae - S2, stdout);
	}
	else {
		char* smae = S2 + kazu, * sato = S2;
		bool gyaku = 0;
		rep(i, Q) {
			char c = *ci;
			if (c < 'a') {
				ci += 2;
				gyaku = !gyaku;
			}
			else {
				bool f = *(ci - 2) - '1';
				if (f ^ gyaku)* sato++ = c;
				else *--smae = c;
				ci += 6;
			}
		}
		fwrite(smae, 1, kazu - (smae - S2), stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, sato - S2, stdout);
	}


	Would you please return 0;
}

Measured memory_bytes: 1920
/*************************************************************************
	> File Name: A.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/19 19:57:23
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
const double pi=acos(-1.0);
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	double r;
	scanf("%lf",&r);
	printf("%.18lf\n",r*pi*2);
	return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int dq[51];
int n,k,ans=0;

int solve(int a,int b,int c){
    int sum=0;
    priority_queue<int, vector<int>, greater<int> > pq;
    for(int i=0;i<a;i++){
        pq.push(dq[i]);
    }
    for(int i=0;i<b;i++){
        pq.push(dq[n-1-i]);
    }
    for(int i=0;i<c;i++){
        if(!pq.empty() && pq.top()<0) pq.pop();
    }
    int size=pq.size();
    for(int i=0;i<size;i++){
        sum+=pq.top();
        pq.pop();
    }
    ans=max(sum,ans);
}

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>dq[i];
    }
    for(int i=0;i<=min(n,k);i++){
        for(int j=0;j<=min(k-i,n-i);j++){
            for(int p=0;p<=min(i+j,k-i-j);p++){
                solve(i,j,p);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 

using namespace std; 


int main(){

    int n,m;
    cin>>n>>m;

    vector<int> a(n);
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=(long long)a[i];
    }
    sort(a.begin(),a.end());

    vector<pair<int,int> > cb(m);
    for(int i=0;i<m;i++){
        int b,c;
        cin>>b>>c;
        cb[i]=make_pair(c,b);
    }
    sort(cb.begin(),cb.end());

    vector<int> d;
    for(int i=m-1;i>=0 && d.size()<n;){
        d.push_back(cb[i].first);
        cb[i].second--;
        if(cb[i].second==0) i--;
    }

    long long res=sum;
    for(int i=0;i<d.size();i++){
        sum=sum-a[i]+d[i];
        res=max(res,sum);
    }

    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define r(i,a,n) for(int i=a;i<n;i++)
int main(){
	int a,b,c;
	cin>>a>>b;
	string s1[a],s2[b];
	r(i,0,a)cin>>s1[i];
	r(i,0,b)cin>>s2[i];
	r(i,0,a-b+1){
		r(j,0,a-b+1){
			if(s1[i][j]==s2[0][0]){
				int c=0;
				r(k,0,b){
					r(l,0,b){
						if(s1[i+k][j+l]==s2[k][l])c++;
					}
				}
				if(c==b*b)goto L;
			}
		}
	}
	cout<<"No"<<endl;
	if(0){L:cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;
 
int D[30001];
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int H, N;
	cin>>H>>N;
	memset(D,0x7f,sizeof(D)); D[0]=0;
	while(N--) {
		int A, B;
		cin>>A>>B;
		for(int i=A;i<=30000;i++) D[i]=min(D[i],D[i-A]+B);
		for(int i=30000;i>0;i--) D[i-1]=min(D[i-1],D[i]);
	}
	cout<<D[H]<<'\n';
	return 0;
}

Measured memory_bytes: 384
MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

K = int(input())
S = input()
N = len(S)

comb = Combination(N + K + 100)

ans = 0
for l in range(K + 1):
    r = K - l
    ans += pow(25, l, MOD) * comb.nhr(N, l) * pow(26, r, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 185120
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		int N;
		cin >> N;

		vector<int> A( N );
		for( int i = 0; i < N; ++i ) { cin >> A[i]; }
		sort( A.begin(), A.end() );

		const int amax = (int)1e6;
		vector<int> tb( amax+1 );
		for( int i = 0; i < N; ++i ) {
			if( tb[A[i]] >= 2 ) { continue; }

			for( int j = A[i]; j <= amax; j += A[i] ) {
				tb[j] += 1;
			}
		}

		int ans = 0;
		for( int i = 0; i < N; ++i ) {
			if( tb[A[i]] == 1 ) { ans += 1; }
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 7972
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int INF = 1e9 + 5;

int main(){
    int n,x;
    cin>>n;
    vector<int> h;
    for(int i=0;i<n;i++){
        cin>>x;
        h.push_back(x);
    }
    
    vector<int> dp(n,INF);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++){
        dp[i] = min( dp[i-1] + abs(h[i]-h[i-1]) ,
                     dp[i-2] + abs(h[i]-h[i-2]) );
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1144
n=int(input())
s=input()
e=s[1:].count("E")
x=e
ans=[]
for i in range(1,n):
	ans.append(x)
	if s[i-1]=="W":
		x+=1
	if s[i]=="E":
		x-=1
ans.append(x)
print(min(ans))

Measured memory_bytes: 15564
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if ((a % 2 == 0) || (b % 2 == 0))cout << "No" << endl;
	else cout << "Yes" << endl;
	return(0);
}


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

int main(){
	int a,b;
	cin>>a>>b;
	int q,w,e;
	q = a + b;
	w = a - b;
	e = a*b;
	if(w>q) q = w;
	if(e>q) q = e;
	cout<<q<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,i,s;
int main() {
  cin>>a;
  d=a%10;
  c=a/10%10;
  b=a/100%10;
  a=a/1000%10;
  for(i=0;;i++){
    s=a;
    if(i/4==0)s+=b;
    else s-=b;
    if(i%4==0||i%4==1)s+=c;
    else s-=c;
    if(i%2==0)s+=d;
    else s-=d;
    if(s==7)break;
  }
  cout<<a;
  if(i/4==0) cout<<'+';
  else cout<<'-';
  cout<<b;
  if(i%4==0||i%4==1)cout<<'+';
  else cout<<'-';
  cout<<c;
  if(i%2==0)cout<<'+';
  else cout<<'-';
  cout<<d<<'='<<7<<endl;
}

Measured memory_bytes: 384
#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(void){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i] ++;
    int ans = 0;
    int s = 0;
    queue<int> q;
    rep(i,n){
        s += p[i];
        q.push(p[i]);
        if ( q.size() > k) {
            s -= q.front();
            q.pop();
        }
        if(q.size()==k) {
            ans = max(ans,s);
        }
    }
    double ans2;
    ans2 = ans / 2.0;
    printf("%.10f\n",ans2);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;
#define lol long long

int GCD(int n, int m) {
	if (m > n) {
		swap(n, m);
	}
	if (n % m == 0) {
		return m;
	}
	else {
		return GCD(m, n%m);
	}
}

int multiGCD(vector<int> n) {
	int ans = n[0];
	for (int i = 0; i < n.size(); i++) {
		ans = GCD(ans, n[i]);
	}
	return ans;
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int GCD = multiGCD(A);
	sort(A.begin(), A.end());
	if ((K % GCD != 0) || (A[N - 1] < K)) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << "POSSIBLE" << endl;
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}


int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='?'){
            s[i]='D';
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3748