akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
//const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    //ios::sync_with_stdio(false);cin.tie(0);
    
    int n,t;cin>>n>>t;
    int ans=(int)100000;
    while(n--){
        int x,y;cin>>x>>y;
        if(y<=t){
            ans=min(ans,x);
        }
    }
    if(ans==100000){
        cout<<"TLE"<<endl;
    }else{
        cout<<ans<<endl;
    }
    
    return 0;
}
 //ios::sync_with_stdio(false);cin.tie(0);


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    int i;
    for(i=a;i<=b;i++){
        if(i%k == 0){
            cout<<"OK"<<endl;
            break;
        }
        
    }
    if(i==b+1)cout<<"NG"<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;
map<pa,int>mp;
const int N=1e7+100;
int n,m;
int vis[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    for(int i=2;i<=n;i++){
     //   if(!vis[i]){
            for(int j=1;j*i<=n;j++){
                vis[i*j]++;
            }
        }

    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=1ll*(vis[i]+1)*i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 42676
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

int main() {
  vi results;

  while (true) {
    int w, h;
    cin >> w >> h;
    if (w==0) { break; }
    vvi vertical(h, vi(w+1, 1));
    vvi horizontal((h+1), vi(w, 1));
    
    for (int iw = 1; iw < w; iw++) {
      cin >> vertical[0][iw];
    }
    for (int ih = 1; ih < h; ih++) {
      for (int iw_hor = 0 ; iw_hor < w ; iw_hor++) {
        cin >> horizontal[ih][iw_hor];
      }
      for (int iw_ver = 1; iw_ver < w; iw_ver++) {
        cin >> vertical[ih][iw_ver];
      }
    }

    vvi md(h, vi(w, INT_MAX)); // min_distance, INT_MAX: not reached
    md[0][0] = 1;
    ddi bfs = {{0, 0}};
    while (!bfs.empty()) {
      di current = bfs.front(); // {h, w}
      vvi fq_ver = {{1, 1}, {0, -1}}; // wall, grid
      vvi fq_hor = {{1, 1}, {0, -1}}; // wall, grid
      for (auto dir : fq_ver) {
        if (vertical[current[0]][current[1] + dir[0]] == 0 &&
            md[current[0]][current[1] + dir[1]] == INT_MAX) {
          md[current[0]][current[1] + dir[1]] = md[current[0]][current[1]] + 1;
          bfs.push_back({current[0], current[1] + dir[1]});
        }
      }
      for (auto dir : fq_hor) {
        if (horizontal[current[0] + dir[0]][current[1]] == 0 &&
            md[current[0] + dir[1]][current[1]] == INT_MAX) {
          md[current[0] + dir[1]][current[1]] = md[current[0]][current[1]] + 1;
          bfs.push_back({current[0] + dir[1], current[1]});
        }
      }
      bfs.pop_front();
    }
    if (md[h-1][w-1] == INT_MAX) {
      md[h-1][w-1] = 0;
    }
    results.push_back(md[h-1][w-1]);
  }

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

  return 0;
}

Measured memory_bytes: 3336
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n, k, ans = 0;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < k; i++)
	{
		ans += p[i];
	}
	cout << ans;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  char s[MAX];
  scanf("%s", s);

  int n = strlen(s);
  int ans = 0;
  rep(i, n - 1)
  {
    if (s[i] != s[i + 1])
      continue;
    if (s[i] == '0')
      s[i + 1] = '1';
    else
      s[i + 1] = '0';
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

 const int maxn=100;
 int n,p;
 int a[maxn];
 LL dp[3][maxn];

 int main()
 {
     scanf("%d%d",&n,&p);
     for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
     if(a[1]%2==0){
        dp[1][1]=2;//1为偶数 2为奇数
        dp[2][1]=0;
     }
     else{
        dp[1][1]=1;
        dp[2][1]=1;
     }
    for(int i=2;i<=n;i++){
            if(a[i]%2==0){
                dp[1][i]=2*dp[1][i-1];
                dp[2][i]=2*dp[2][i-1];
            }
            else{
                dp[1][i]=dp[1][i-1]+dp[2][i-1];
                dp[2][i]=dp[1][i-1]+dp[2][i-1];
            }
    }
    if(p==0)
        printf("%lld",dp[1][n]);
    else
        printf("%lld",dp[2][n]);
    return 0;
 }


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

int main() {
  while(true) {
    int ncard, r;
    cin >> ncard >> r;
    if(ncard == 0 && r == 0) break;
    vector<int> cards(ncard);
    for(int i = 0; i < ncard; ++i) cards[i] = ncard - i;
    for(int i = 0; i < r; ++i) {
      int p, c;
      vector<int> results;
      cin >> p >> c;
      for(int j = p - 1; j < p - 1 + c; ++j) {
        results.push_back(cards[j]);
      }
      for(int j = 0; j < p - 1; ++j) {
        results.push_back(cards[j]);
      }
      for(int j = p - 1 + c; j < ncard; ++j) {
        results.push_back(cards[j]);
      }
      cards = results;
    }
    cout << cards[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int par[100001];
int rnk[100001];
int size[100001];
int N;

void shoki(){
    for(int i=0;i<=N;i++) {par[i]=i; rnk[i]=0; size[i]=1;}
}

int sch(int x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

void con(int A,int B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    size[B]+=size[A];
    size[A]=size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

int is_size(int k){
    return size[sch(k)];
}

bool same(int A,int B){
    return sch(A)==sch(B);
}

int main(){
    cin>>N;
    int M; cin>>M;
   
    shoki();
    vector<ll> a(N);
    if(N==1) {
        cout<<0<<endl;
        //exit(1);
    }
    else{
    for(int i=0;i<N;i++) cin>>a.at(i);
    for(int i=0;i<M;i++){
        int x,y; cin>>x>>y;
        con(x,y);
    }

    vector<int> heads;

    ll sum=0;
    for(int i=0;i<N;i++){
        if(sch(i)==i) {
            sum+=(size[i]-2);
            heads.push_back(i);
        }
    }
    int H=heads.size();
    sum+=2;
    if(sum<0) {
        cout<<"Impossible"<<endl;
        //exit(1);
    }
    else if(H==1) cout<<0<<endl;
    else{
    
    vector<vector<ll>> A(H);

    sort(heads.begin(),heads.end());
    for(int i=0;i<N;i++){
        auto itr=find(heads.begin(),heads.end(),sch(i));
        int x=itr-heads.begin();
        A[x].push_back(a.at(i));
    }

    ll ans=0;
    vector<ll> kahen;

    for(int i=0;i<H;i++){
        sort(A[i].begin(),A[i].end());
        ans+=A[i].at(0);
        if(A[i].size()>1) {
            for(int j=1;j<A[i].size();j++) kahen.push_back(A[i].at(j));
        }
    }

    sort(kahen.begin(),kahen.end());
    for(int i=0;i<kahen.size()-sum;i++) ans+=kahen.at(i);
    cout<<ans<<endl;

    
    



    


    }
}
}

Measured memory_bytes: 6268
N, Q = map(int, input().split())
S = input()
countlist = [0]
for i in range(1, N):
	if S[i-1] == 'A' and S[i] == 'C':
		countlist.append(countlist[-1]+1)
	else:
		countlist.append(countlist[-1])
for i in range(0, Q):
	L, R = map(lambda v: int(v)-1, input().split())
	ans = countlist[R]
	if L != 0:
		ans -= countlist[L-1]
		if S[L-1] == 'A' and S[L] == 'C':
			ans -= 1
	print(ans)

Measured memory_bytes: 54860
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,ans;
int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	ans+=n/(a+b)*a;
	ans+=n%(a+b)>a?a:n%(a+b);
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;

int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

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

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,x,y,z,max1=0,ans=0;
    string s,t,u;
    cin>>n;
    for(ll i=1;i*i<=n;i++){
     a=i;  
    }
    
    for(ll i=a;i>0;i--){
     if(n%i==0){
      ans=i+n/i-2;   
         break;
     }
    }
    cout<<ans<<endl;
    
}






Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 2e5 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

int n, m;
vector<int> gr[nn];
int vis[nn];
void BFS(int S)
{
	vector<int> dis(nn, oo);
	vector<int> per(nn, 0);
	queue<pair<int, int> > qq;
	qq.push(make_pair(S, 0));
	dis[S] = 0;
	while (!qq.empty())
	{
		pair<int, int> cur = qq.front();
		qq.pop();
		for (auto it : gr[cur.first])
		{
			if (dis[it] > dis[cur.first] + 1)
			{
				dis[it] = dis[cur.first] + 1;
				per[it] = cur.first;
				qq.push(make_pair(it, dis[it]));
			}
		}
	}
	bool f = 0;
	for (int i = 2; i <= n&&!f; i++)
	{
		if (dis[i] == oo)
			f = 1;
	}
	if (f)
		cout << "No\n";
	else
	{
		cout << "Yes\n";
		for (int i = 2; i <= n; i++)
			cout << per[i] << endl;
	}
}
int main()
{
	fast();
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		gr[u].push_back(v);
		gr[v].push_back(u);
	}
	BFS(1);
	return 0;
}

Measured memory_bytes: 14084
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let digit_sum = format!("{}", n)
        .chars()
        .map(|x| x.to_digit(10).unwrap() as i64)
        .sum::<i64>();
    if n % digit_sum == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m, x, lt=0, rt=0; cin >> n >> m >> x;
    REP(i, m){
        int a; cin >> a;
        if(a < x) ++lt;
        else ++rt; //x==aとなることはない
    }
    cout << min(lt, rt) << endl;
    return 0;
}

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

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

  	if (n == 1) {
      cout << 1 << endl;
      return 0;
    }
	int ans = 0;
	rep(i, 1, n/2 + 1) {
		if (i * i > n) break;
		ans = i * i;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n;
ll Xor, c[N];
ll a[63], b[63];
int tot;
void insert(ll x)
{
	for(int i=62;~i;i--)
	{
		if((x>>i)&1)
		{
			if(!a[i])
			{
				a[i] = x;
				break;
			}
			x ^= a[i];
		}
	}
}
ll Max(ll x)
{
	ll ans = x;
	for(int i=62;~i;i--)
		ans = max(ans,ans^a[i]);
	return ans;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++)
 	{
 		cin >> c[i];
 		Xor ^= c[i];
 	}
 	for(int i=1; i<=n; i++)
 		insert((c[i]&(~Xor)));
 	ll A = Max(0);
 	ll B = Xor^A;
 	ll ans = A + B;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>

typedef struct{
  char c;
  int value;
}Card;

int main(){
  Card C[36],C1[36],C2[36];
  int n,i,j,minj,flag=0,s=35,t=35;
  Card a;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %c%d",&C[i].c,&C[i].value);
    C1[i] = C[i];
    C2[i] = C[i];
     }

  /*BubbleSort*/

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(C1[j].value < C1[j-1].value){
	a = C1[j];
	C1[j] = C1[j-1];
	C1[j-1] = a;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%c%d",C1[i].c,C1[i].value);
  }
  printf("\n");

  for(i=0;i<n-1;i++){
    if(C1[i].value == C1[i+1].value){
      for(j=0;j<n;j++){
	if((C[j].c==C1[i].c)&&(C[j].value==C1[i].value)) s = j;
	if((C[j].c==C1[i+1].c)&&(C[j].value==C1[i+1].value)) t = j;
       }
      if(s>t){
	flag = 1;
	break;
      }
    }
  }
  



  
  if(flag == 0) printf("Stable\n");
  else printf("Not stable\n");
 

 for(i=0;i<n;i++){
   minj = i;
   for(j=i;j<n;j++){
     if(C2[j].value<C2[minj].value) minj =j;
   }
   a = C2[i];
   C2[i] = C2[minj];
   C2[minj] = a;
 }
 
 for(i=0;i<n;i++){
   if(i!=0)printf(" ");
   printf("%c%d",C2[i].c,C2[i].value);
 }
 printf("\n");

 flag = 0;
  for(i=0;i<n-1;i++){
    if(C2[i].value == C2[i+1].value){
      for(j=0;j<n;j++){
	if((C[j].c==C2[i].c)&&(C[j].value==C2[i].value)) s = j;
	if((C[j].c==C2[i+1].c)&&(C[j].value==C2[i+1].value)) t = j;
      }
      if(s>t){
	flag = 1;
	break;
      }
    }
  }

  if(flag == 0) printf("Stable\n");
  else printf("Not stable\n");
 

  

  
  return 0;
}
  



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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

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

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif


#define f first
#define s second
#define endl "\n"
#define pb push_back
#define  oo 0x3f3f3f3f
#define limit 1000000007
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define ll long long
#define two pair<int,int>
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repb(i,a,b) for(int i=(a);i>=(b);i--)
#define fastio std::ios::sync_with_stdio(false)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);

// zero included
int d, ans;
int dp[10005][5][105];
string k;

int getans(int i, int f, int s){
  if(dp[i][f][s] != -1) return dp[i][f][s];
  if(k.size() == i){
    if(s%d == 0) { return dp[i][f][s] = 1; }
    return 0;
  }
  int curr = 0;
  int no = k[i]-'0';
  if(f == 1){
   curr = getans(i+1,1,(s+no)%d)%limit;
   for(int j=0;j<no;j++)
   curr += getans(i+1,0,(s+j)%d), curr %= limit;
  }
  else {
   for(int j=0;j<10;j++)
   curr += getans(i+1,0,(s+j)%d), curr %= limit;
 }
 return dp[i][f][s] = curr;
}

signed main(){
 //input_from_file;
 cin>>k>>d;
 ans = 0;
 memset(dp,-1,sizeof dp);
 cout<<((getans(0,1,0)-1)%limit+limit)%limit<<endl;
}


Measured memory_bytes: 42112
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void execute(int test, istream &in) {
    int n;
    in >> n;
    vector<int64_t> a(n);
    bool hasZero = false;
    for (int i = 0; i < n; i++) {
        in >> a[i];
        if (a[i] == 0)
            hasZero = true;
    }
    int64_t res = 1;
    if (hasZero) {
        res = 0;
    }
    else {
        long double resD = 1;
        for (int i = 0; i < n; i++) {
            res *= a[i];
            resD *= a[i];
            if (resD > (long double)1e18 + 1) {
                res = -1;
                break;
            }
        }
        if (res > (int64_t)1e18)
            res = -1;
    }
    printf("%lld", res);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        execute(test, f);
    }
    return 0;
}


Measured memory_bytes: 4056
import numpy

N, K = map(int, input().split())
P = map(int, input().split())

PP = [(1 + pp) / 2 for pp in P]

S = numpy.cumsum(PP).tolist()

r = -1
for i, ss in enumerate(S[K-1:]):
    r = ss if i == 0 else max(r, ss - S[i - 1])

print(r)

Measured memory_bytes: 32360
#include <iostream>
#include <deque>
#include <string>
#include <algorithm>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	std::string str;

#if INPUT_FROM_FILE
	ifs >> str;
#else
	std::cin >> str;
#endif

	std::deque<std::pair<int, int> > answer;
	std::deque<int> s;
	int sum_area = 0;

	for(unsigned int i = 0; i < str.size(); i++){
		if(str.at(i) == '\\'){
			s.push_back(i);
		}
		else if(str.at(i) == '/' && !s.empty()){
			int sp = s.back();
			int area = i - sp;

			s.pop_back();
			while(!answer.empty() && sp <= answer.back().first){
				area += answer.back().second;
				answer.pop_back();
			}
			answer.push_back(std::pair<int, int>(sp, area));
		}
	}

	for(unsigned int i = 0; i < answer.size(); i++){
		sum_area += answer[i].second;
	}

	std::cout << sum_area << std::endl;
	std::cout << answer.size();
	for(unsigned int i = 0; i < answer.size(); i++){
		std::cout << " " << answer[i].second;
	}
	std::cout << std::endl;

	return 0;
}


Measured memory_bytes: 3264
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, m = list(map(int,ipti().split()))
    l = [0] * m
    r = [0] * m

    for i in range(m):
        l[i], r[i] = list(map(int,ipti().split()))

    lower = -INF
    upper = INF

    for i in range(m):
        lower = max(lower, l[i])
        upper = min(upper, r[i])

    print(max(0, upper-lower+1))

if __name__ == '__main__':
    main()

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

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

    vector<string> arr(H);
    for(int i = 0; i < H; i++){
        cin >> arr[i];
    }

    int checkLineH[H] = {0};
    int checkLineW[W] = {0};

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(arr[h][w] == '#'){
                checkLineH[h] = 1;
                checkLineW[w] = 1;
            }
        }
    }


    for(int h = 0; h < H; h++){
        bool flag = false;
        for(int w = 0; w < W; w++){
            if(checkLineH[h] && checkLineW[w]){
                cout << arr[h][w];
                flag = true;
            }
        }
        if(flag) cout << endl;
    }

}



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

int main() {
  long long N;
  cin >> N;
  long long A[N], B[N];
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
  long long count = 0;
  
  for (int i = N - 1; i >= 0; i--){
    if ((A[i] + count) % B[i] != 0) count += B[i] - (A[i] + count) % B[i];
  }
  
  cout << count << endl;
}

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

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

    long long sum=0;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int a=__gcd(i,j);
                a=__gcd(a,k);
                sum+=a;
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
       int a = sc.nextInt()-1;
       int b = sc.nextInt()-1;
       sb.append(sc.next());
       String s1 = sb.substring(b,b+1).toLowerCase();
        sb.setCharAt(b,s1.charAt(0));
        System.out.println(sb);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pb push_back

using namespace std;

int32_t main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<1000*(n/500)+(5*((n%500)/5))<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	//my_io();
	int n;
	cin >> n;
	vector<int>as(n);
	bool c = false;
	for (int i = 0; i < n; i++) {
		 scanf("%lld",&as[i]);
		if (as[i] % 2 == 1) {
			c = true;
		}
	}
	if (c) {
		//cout << "first" << endl;
		printf("first\n");
	}
	else {
		//cout << "second" << endl;
		printf("second\n");
	}
	return 0;
}




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

bool isPrimeNumber(int x) {
    if (x > 2 && x % 2 == 0) { return false; }
    for (int i = 3; i <= sqrt(x); i += 2) {
        if (x % i == 0) { return false; }
    }
    return true;
}

int main() {
    int N, count;

    scanf("%d", &N);
    count = 0;
    for (int i = 0; i < N; ++i) {
        int x;
        scanf("%d", &x);
        if (isPrimeNumber(x)) {
            ++count;
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
const ll N=3000010;
ll n,pre[N],suc[N],answ=1e9;char s[N];
int main(){
	n=read();readstr(s+1);
	For(i,1,n){
		pre[i]=pre[i-1]+(s[i]=='E');
	}
	FOr(i,n,1)suc[i]=suc[i+1]+(s[i]=='W');
	For(i,1,n)	Min(answ,(i-1-pre[i-1])+(n-i-suc[i+1]));
	writeln(answ);
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;

int main()
{
    ll a,b,i,j,n,t,k;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    ll count=0;
    for(i=0;i<n;i++) for(j=i+1;j<n;j++) for(k=j+1;k<n;k++)
    {
        if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k])
        {
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 3612
a,b,q=map(int,input().split())
s=[]
t=[]
x=[]        

import bisect  

for i in range(a):
    p=int(input())
    s.append(p)
for i in range(b):
    p=int(input())
    t.append(p)
s=[-100000000000000000]+s+[1000000000000000000]
t=[-100000000000000000]+t+[1000000000000000000]
for i in range(q):
    p=int(input())
    n=bisect.bisect_right(s,p)
    m=bisect.bisect_right(t,p)
    l=[p,s[n-1],s[n],t[m-1],t[m]]
    x.append(l)

for i in range(q):
    ans=1000000000000000
    for S in [x[i][1],x[i][2]]:
        for T in [x[i][3],x[i][4]]:
            d1=abs(S-x[i][0])+abs(T-S)
            d2=abs(T-x[i][0])+abs(S-T)
            ans=min(ans,d1,d2)
    print(ans)

    

    






Measured memory_bytes: 28600
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ss := make([]string, n)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	m := make(map[byte]int)
	for _, s := range ss {
		m[s[0]]++
	}

	cs := []byte{'M', 'A', 'R', 'C', 'H'}

	ans := int64(0)
	for i := range cs {
		for j := i + 1; j < len(cs); j++ {
			for k := j + 1; k < len(cs); k++ {
				ans += int64(m[cs[i]]) * int64(m[cs[j]]) * int64(m[cs[k]])
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

double ave(vector<int> v) {
    int sum = 0;
    REP(i,v.size()) {
        sum += v[i];
    }
    return (double) sum / v.size();
}

void solve10c(int a) {
    vector<int> v;
    vector<int> vv;
    REP(i,a) {
        int j;
        cin >> j;
        v.push_back(j);
        vv.push_back(j*j);
    }
    double stdev = sqrt(ave(vv) - ave(v) * ave(v));
    printf("%6f\n", stdev);
}

int main() {
    int a;
    while(cin >> a, a) {
        solve10c(a);
    }
    return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <cstdio>
using namespace std;
int a[300000];

int main()
{
    int n, x;
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        a[x] = i;
    }
    int maxn = 0, now = 1;
    for(int i = 2; i <= n; i ++)
    {
        if(a[i] > a[i - 1])
            now ++;
        else
        {
            maxn = max(maxn, now);
            now = 1;
        }
    }
    maxn = max(maxn, now);
    cout << n - maxn << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

        for {
                h := nextInt()
                w := nextInt()

                if h == 0 && w == 0 {
                        break
                }

                for i := 0; i < h; i++ {
                        fmt.Println(strings.Repeat("#", w))
                }
                fmt.Println()
        }
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main() {
        int n,q;
        cin>>n>>q;
        string s;
        cin>>s;
        int c[n];
        c[0]=0;
        for(int i=0;i<n-1;i++)
        {
            if(s[i]=='A' && s[i+1]=='C')
            c[i+1]=c[i]+1;
            else
            c[i+1]=c[i];
        }
        while(q--)
        {
            int l,r;
            cin>>l>>r;
            l--;
            r--;
            cout<<c[r]-c[l]<<endl;
        }
    }

Measured memory_bytes: 1408
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, A, B, *v = map(int, open(0).read().split())

v.sort(reverse=True)
answer = sum(v[:A]) / A
n = 0

if v[0] == v[A - 1]:
    N = v.count(v[0])
    n = cmb(N, min(N, B))
    tmp_cmb = n
    for i in range(min(B, N) - 1, A - 1, -1):
        tmp = N - i
        tmp_cmb = tmp_cmb * (i + 1) // tmp
        n += tmp_cmb
else:
    n = cmb(v.count(v[A - 1]), A - v.index(v[A - 1]))

print(answer)
print(n)

Measured memory_bytes: 3572
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int main() {
	int n,i,ans=0;
	cin >> n;
	int a[100005],b[100005];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<100005;i++){
		b[i]=0;
	}
	for(i=0;i<n;i++){
		if(a[i]>=1){
			b[a[i]-1] +=1;
			b[a[i]] += 1;
			b[a[i]+1] += 1;
		}else{
			b[a[i]] += 1;
			b[a[i]+1] += 1;
		}
	}
	for(i=0;i<100005;i++){
		if(b[i]>ans){
			ans = b[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
//Goal:s(i , j) = # のときマス s(i , j) を黒色, s(i , j) = . のときマス s( i , j ) を白色にする

#include<iostream>
#include<vector>
#include<string>

using namespace std;

int H, W;

bool canPaint(string S[52]){

  for(int i = 1; i < H+1; i++){
    for(int j = 1; j < W+1; j++){
      int num = 0; //マス周囲の#の数
      if(S[i][j]=='#'){//#のあるマスそれぞれについて判定を行う

        if((S[i][j-1]=='#')||(S[i][j+1]=='#')||(S[i-1][j]=='#')||(S[i+1][j]=='#'))
          num += 1;

        if(num == 0){
            //printf("cor(%d,%d) doesn't meet requirements\n",i,j);
            return false;
          } else{
            //printf("cor(%d,%d) num of #: %d\n",i,j,num);
          }
        }
      }
    }
    return true;
  }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  cin >> H >> W;

  string S[52];
  S[0] = "..................................................";

  for (int i = 1; i < H+1;i++){
    string buff;
    cin >> buff;
    S[i] = "."+buff+".";
  }
  S[51] = "..................................................";

  if(canPaint(S)) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 300
int dy[]={0,1,0,-1};
int dx[]={-1,0,1,0};
int N,ay,ax,by,bx;
int py[MAX],px[MAX];

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    ay=ax=by=bx=0;
    for(int i=1;i<N;i++){
      int a,b;
      cin>>a>>b;
      py[i]=py[a]+dy[b];
      ay=min(ay,py[i]);
      by=max(by,py[i]);
      px[i]=px[a]+dx[b];
      ax=min(ax,px[i]);
      bx=max(bx,px[i]);
    }
    cout<<1+bx-ax<<' '<<1+by-ay<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_M 20

#define SUBMIT

ll M, K;
ll fact[MAX_M]; // 2^i

// vector を print する
void Disp(vector<ll> v) {
    REP(i, v.size()) { printf("%lld%c", v[i], (i == v.size()-1) ? '\n' : ' '); }
}

vector<ll> blute_force() {
    vector<ll> v;
    v.push_back(0);
    v.push_back(0);
    for(int i = 1; i < fact[M]; ++i) {
        v.push_back(i);
        v.push_back(i);
    }

    do {
        bool isAnswer = true;
        // val_to_pos の作成
        vector< pair<ll, ll> > val_to_pos(fact[M], make_pair(-1, -1));
        REP(i, v.size()) {
            if(val_to_pos[v[i]].first < 0) { val_to_pos[v[i]].first = i; }
            else { val_to_pos[v[i]].second = i; }
        }

        REP(i, v.size()) {
            ll tail = val_to_pos[v[i]].second;
            if(i == tail){ continue; }
            ll cur = 0;
            for(int j = i; j <= tail; ++j) {
                cur ^= v[j];
            }
            if(cur != K) {
                isAnswer = false;
                break;
            }
        }
        if(isAnswer) { return v; }
    } while( next_permutation(v.begin(), v.end()) );

    // 条件を満たす v はなかった
    vector<ll> ret = {-1};
    return ret;
}

vector<ll> solve() {
    if(M <= 2) { return blute_force(); }
    vector<ll> ret;
    // K が 2^M 以上なら不可能
    if(K >= fact[M]) {
        ret.push_back(-1);
        return ret;
    }

    // 自分より小さいもので挟む部分を作成
    for(int i = 0; i < K; ++i) { ret.push_back(i); }
    ret.push_back(K);
    for(int i = K-1; i >= 0; --i) { ret.push_back(i); }
    // K より大きいもので順に K をはさむ
    for(int i = fact[M]-1; i > K; --i) { ret.push_back(i); }
    ret.push_back(K);
    for(int i = K + 1; i < fact[M]; ++i) { ret.push_back(i); }

    return ret;
}

signed main()
{
    // fact の作成
    fact[0] = 1;
    for(int i = 1; i < MAX_M; ++i) { fact[i] = fact[i-1] * 2; }

#ifdef SUBMIT
    cin >> M >> K;
    vector<ll> ans = solve();
    Disp(ans);
#else
    // 実験用コード
    const int m_limit = 2;
    const int k_limit = fact[m_limit];
    for(M = 0; M <= m_limit; ++M) {
        printf("M: %lld\n", M);
        for(K = 0; K <= k_limit; ++K) {
            vector<ll> ans = blute_force();
            printf("K: %lld ans: ", K);
            Disp(ans);
        }
    }
#endif
    return 0;
}


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

#define MAX_LEN (100)

using namespace std;

class Dice {
      private:
              int value[6];
              int top;
     
      public:             
              Dice(int value[]) {             
                   for (int i = 0; i < 6; i++) {
                        this->value[i] = value[i];
                   }
                   
                   this->top = value[0];
              }
              
              void swap(int& a, int& b) {
                   int temp = a;
                   a = b;
                   b = temp;
              }

              void move_N() {
                   this->swap(this->value[0], this->value[1]);
                   this->swap(this->value[1], this->value[5]);
                   this->swap(this->value[5], this->value[4]);

                   this->top = this->value[0];
              }

              void move_E() {
                   this->swap(value[0], value[3]);
                   this->swap(value[3], value[5]);
                   this->swap(value[5], value[2]);
 
                   this->top = this->value[0];
              }

              void move_W() {
                   this->swap(this->value[0], this->value[2]);
                   this->swap(this->value[2], this->value[5]);
                   this->swap(this->value[5], this->value[3]);

                   this->top = this->value[0];
              }

              void move_S() {
                   this->swap(this->value[0], this->value[4]);
                   this->swap(this->value[4], this->value[5]);
                   this->swap(this->value[5], this->value[1]);

                   this->top = this->value[0];
              }

              int Get_top() {
                  return (this->top);
              }
};

int main()
{
    int    value[6];  
    string inst;

    for (int i = 0; i < 6; i++) {
         do {
             cin >> value[i];
         } while (value[i] < 0 || value[i] > 100);
    }

    Dice dice(value);

    do {
        cin >> inst;
    } while (inst.length() < 0 || inst.length() > MAX_LEN);
        
    for (int i = 0; inst[i] != '\0'; i++){
         if (inst[i] == 'N') {
             dice.move_N();
         } else if (inst[i] == 'E') {
             dice.move_E();
         } else if (inst[i] == 'W') {
             dice.move_W();
         } else if (inst[i] == 'S') {
             dice.move_S();
         }
    }

    cout << dice.Get_top() << endl;

    return (0);
}

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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

ll inv(ll x){
    // MOD=10e9+7
	ll n=MOD-2,a=1;
	while(n>0){
		if(n%2) a=a*x%MOD;
		x=x*x%MOD;
		n=n/2;
	}
	return a;
}

ll Comb(ll n,ll m){
    ll ans = 1; 
    for(int i=0;i < m; i++){
        ans *= ((n-i)*inv(i+1)) % MOD;
        ans %= MOD;
    }
    while(ans<0)ans+=MOD;
    return ans;
}

ll PowMod(ll N,ll P,ll M){
    ll ans = 1;
    while(P >= 1){
        if(P % 2)ans = ans * N % M;
        N = N*N %M;
        P /= 2;
    }
    ans %= M;
    return ans;
}

int main(){
    ll X,Y;
    cin>>X>>Y;
    if(X<Y)swap(X,Y);

    ll N=X-(X-Y)*2;
    if(N % 3 != 0 || N < 0){
        cout<<0;
        return 0;
    } 
    
    N /= 3;
    cout<<Comb(2*N + (X-Y),N)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		double p = Math.PI;


		System.out.printf("%.6f" + " " + "%.6f",r*r*p,2*p*r);
	}
}

Measured memory_bytes: 28268
while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break;
    for i in range(0, a):
        if i == 0 or i == (a - 1):
            print("#" * b)
        else:
            print("#" + "." * (b - 2) + "#")
    print("")

Measured memory_bytes: 7600
def examA():
    N = S()
    ans = "No"
    if N[1]==N[2]:
        if N[0]==N[1] or N[2]==N[3]:
            ans = "Yes"
    print(ans)


import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()

Measured memory_bytes: 3432
x1, y1 , x2, y2 = list(map(int,input().split()))


vector_x1 = x1 - x2
vector_y1 = y1 - y2

x3 = x2 + vector_y1
y3 = y2 - vector_x1

vector_x2 = x2 - x3
vector_y2 = y2 - y3

x4 = x3 + vector_y2
y4 = y3 - vector_x2

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <string>
using namespace std;


int main()
{
  string s, t;
  getline(cin, s); 
  getline(cin, t); 
  int n = s.length();
  int m = t.length();
  vector<int> arr((n+1)*(m+1), 0);
  for (int j=1; j<n+1; j++){
    for (int i=1; i<m+1; i++){
      arr[i*(n+1) +j] = std::max(arr[(i-1)*(n+1)+j], arr[i*(n+1)+j-1]);
      if (t[i-1] == s[j-1]){
          //arr[i*(n+1) + j] = std::max(arr[i*(n+1)+j], arr[(i-1)*(n+1) + j-1] + 1);
          arr[i*(n+1) + j] = arr[(i-1)*(n+1) + j-1] + 1;
      }
    }
  }

  int i = m;
  int j = n;
  int index = arr[(n+1)*(m+1)-1];
  char result[index+1];
  result[index] = (char) 0;
  while (i > 0 && j > 0){
    if (t[i-1] == s[j-1]){
      result[index-1] = t[i-1];
      i--;
      j--;
      index--;
    }else{
      if (arr[(i-1)*(n+1) + j] < arr[i*(n+1) + j-1]) {
        j--;
      }else{
        i--;
      }
    }
  }
  std::cout << result;
  //printf("%s \n", result);
  //for (int i=0; i<n+1; i++) {
  //  for (int j=0; j<m+1; j++){
  //    printf("%d ", arr[j*(n+1)+i]);
  //  }
  //  printf("\n");
  //}
}


Measured memory_bytes: 35456
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

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

  int m = stoi(s.substr(5, 2));
  if (m > 4) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string s,ans;
  ans="yes";
  cin>>s;
  sort(s.begin(),s.end());
  int n=s.size();
  for(int i=0;i<n-1;i++){
    if(s[i]==s[i+1]){
      ans="no";
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 155;

int dp[2][N][N][N];
int dp2[N][N][N];

int main() {
	fast_cin();
	int n, k, mod;
	cin >> n >> k >> mod;
	ll ans = 0;
	if (k % 2 == 1) {
		dp[0][n + 1][n + 1][n + 1] = 1;
		for (int i = 1; i <= n; ++i) {
			memset(dp[i & 1], 0, sizeof(dp[i & 1]));
			for (int l_cur = 1; l_cur <= n + 1; ++l_cur) {
				for (int l_other = 1; l_other <= n + 1; ++l_other) {
					for (int mx = i; mx <= n + 1; ++mx) {
						int &cur = dp[(i - 1) & 1][l_cur][l_other][mx];
						if (!cur) {
							continue;
						}
						if (mx == n + 1 or mx % 2 != i % 2) {
							dp[i & 1][l_other][n + 1][mx] += cur;
							dp[i & 1][l_other][n + 1][mx] %= mod;
							int new_mx = mx, new_cur = min(l_cur, i);
							if (l_other <= i - k) {
								new_mx = min(new_mx, new_cur + k);
							}
							dp[i & 1][l_other][new_cur][new_mx] += cur;
							dp[i & 1][l_other][new_cur][new_mx] %= mod;
						} else {
							dp[i & 1][l_other][n + 1][n + 1] += cur;
							dp[i & 1][l_other][n + 1][n + 1] %= mod;
							if (i < mx) {
								dp[i & 1][l_other][l_cur][mx] += cur;
								dp[i & 1][l_other][l_cur][mx] %= mod;
							}
						}
					}
				}
			}
		}
		for (int l_cur = 1; l_cur <= n + 1; ++l_cur) {
			for (int l_other = 1; l_other <= n + 1; ++l_other) {
				for (int mx = n; mx <= n + 1; ++mx) {
					ans += dp[n & 1][l_cur][l_other][mx];
					ans %= mod;
				}
			}
		}
	} else {
		dp2[0][n + 1][n + 1] = 1;
		for (int i = 1; i <= n; ++i) {
			for (int l_cur = 1; l_cur <= n + 1; ++l_cur) {
				for (int l_other = 1; l_other <= n + 1; ++l_other) {
					int &cur = dp2[i - 1][l_cur][l_other];
					dp2[i][l_other][n + 1] += cur;
					dp2[i][l_other][n + 1] %= mod;
					if (i < l_cur + k) {
						dp2[i][l_other][min(l_cur, i)] += cur;
						dp2[i][l_other][min(l_cur, i)] %= mod;
					}
				}
			}
		}
		for (int l_cur = 1; l_cur <= n + 1; ++l_cur) {
			for (int l_other = 1; l_other <= n + 1; ++l_other) {
				ans += dp2[n][l_cur][l_other];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
}

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

int main(){
   ll a,b;
   cin >> a >> b;
   vector<ll> g;
   ll GCD = __gcd(a,b);

   for(ll i=1;i*i<=GCD;i++){ 
         if(GCD%i == 0) {
            g.push_back(i);
         if(i*i != GCD)g.push_back(GCD/i);
         }
   }

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

   for(ll i = 0;i<g.size();i++){
      ll yaku = g[i];
      if(yaku==1)continue;

       for(ll k=i+1;k<g.size();k++){
         if(__gcd(g[k],yaku)!=1){
             g.erase(g.begin()+k);
             k--;
          }
       }
   }

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


Measured memory_bytes: 384