akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
	int h,n,i,j,a;
	int asum=0;
	scanf("%d %d", &h,&n);

	for (i = 0; i < n; i++) {
		scanf("%d",&a);
		asum += a;
	}
	if(asum >= h) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
X, Y = input().split()

dic = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}

if dic[X] < dic[Y]:
    print('<')
elif dic[X] == dic[Y]:
    print('=')
else:
    print('>')


Measured memory_bytes: 2940
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : z : _) = (x, y, z)

main = do
    n <- getInt
    abcs <- V.fromList . map toTuple <$> replicateM n getIntList
    dp <- VM.replicate (n + 1) (0, 0, 0)
    forM_ [1..n] $ \i -> do
         (pa, pb, pc) <- VM.read dp (i - 1)
         let (na, nb, nc) = abcs V.! (i - 1)
         VM.write dp i $
             ( max (pb + na) (pc + na)
             , max (pc + nb) (pa + nb)
             , max (pa + nc) (pb + nc) )
    (ma, mb, mc) <- VM.read dp n
    print $ maximum [ma, mb, mc]

Measured memory_bytes: 72060
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z <<" "<< X<<" "<< Y << endl;


	return 0;
}

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

using namespace std;

typedef long long ll;

int shop_mask[101];
int p[101][11];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 10; j++){
			int a;
			cin >> a;
			if(a == 1)
				shop_mask[i] |= (1 << j);
		}
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 11; j++)
			cin >> p[i][j];
	int ans = INT_MIN;
	for(int mask = 1; mask < (1 << 10); mask++)
	{
		int cur = 0;
		for(int i = 0; i < n; i++)
			cur += p[i][__builtin_popcount(mask & shop_mask[i])];
		ans = max(ans, cur);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        waru = 4 * h * n - N * n - N * h
        if waru > 0 and (N * h * n) % waru == 0:
                print("{} {} {}".format(h, n, (N * h * n) // waru))
                exit()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll unsigned long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])
#define mod 1000000007;

using namespace std;
// lower_bound
// it returns pos of the elmnt which is not less then the query elmnt
int main() {
	int n, k, count = 0;
	cin >> n >> k;
	while(n != 0){
		count++;
		n = n / k;
	}
	cout << count << endl;
}



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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

void dump(const vector<int> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

int solve(int n, int x)
{
	int count = 0;

	for(int i = 1; i <= n-2; i++){
		for(int j = i+1; j <= n-1; j++){
			for(int k = j+1; k <= n; k++){
				if(i + j + k == x)
					count++;
			}
		}
	}

	return count;
}

int main()
{
	for(;;){
		int n, x;
		cin >> n >> x;

		if(n == 0 && x == 0)
			break;

		cout << solve(n, x) << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
fun main() {
    val (_, _, k) = readInts().map { it.toLong() }
    val a = readInts().map { it.toLong() }.toMutableList()
    val b = readInts().map { it.toLong() }.toMutableList()

    a.forEachIndexed { index, _ -> if (index > 0) a[index] += a[index - 1] }
    b.forEachIndexed { index, _ -> if (index > 0) b[index] += b[index - 1] }

    fun getVal(list: List<Long>, index: Int): Long {
        return if (index in list.indices) list[index] else 0
    }

    var maxRead = 0
    var total = 0L
    var pointerB = b.size - 1
    for (i in -1 until a.size) {
        if (i >= 0) total = a[i]
        while (pointerB >= 0 && total + b[pointerB] > k) pointerB--
        total = getVal(a, i) + getVal(b, pointerB)
        if (total <= k) maxRead = maxOf(i + pointerB + 2, maxRead)
        else break
    }

    println(maxRead)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

Measured memory_bytes: 90352
#include<bits/stdc++.h>
#define N 3
using namespace std;
typedef unsigned long long ull;
bool im[1010][1010],pa[110][110];
int w,h,p,ans;
vector<ull> used;

void ppp(){
 ull a=0;
 ull roll[1001][1001]={};
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)a=a*N+pa[i][j];
 for(int i=0;i<used.size();i++)
   if(used[i]==a)return;
 used.push_back(a);
 for(int j=0;j<h;j++){
   ull b=0,g=1;
   for(int i=0;i<p;i++)b=b*N+im[j][i],g*=N;
   roll[j][p-1]=b;
   for(int i=p;i<w;i++){
     b=b*N+im[j][i]-im[j][i-p]*g;
     roll[j][i]=b;
   }
 }
 for(int j=p-1;j<w;j++){
   ull b=0,g=1,n=1;
   for(int i=0;i<p;i++)n*=N;
   for(int i=0;i<p;i++)b=b*n+roll[i][j],g*=n;
   if(b==a)ans++;
   for(int i=p;i<h;i++){
     b=b*n+roll[i][j]-roll[i-p][j]*g; 
     if(b==a)ans++;
   }
 }
}

void ch(){
 bool npa[110][110];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)npa[i][j]=pa[j][p-i-1];
 for(int i=0;i<p;i++)
   for(int j=0;j<p;j++)pa[i][j]=npa[i][j];
}

void ch1(){
 for(int i=0;i<p;i++)
   for(int j=0;j<p/2;j++)swap(pa[i][j],pa[i][p-j-1]);
}

int main(){
 int D[256];
 for(int i='A';i<='Z';i++)D[i]=i-'A';
 for(int i='a';i<='z';i++)D[i]=i-'a'+26;
 for(int i='0';i<='9';i++)D[i]=i-'0'+52;
 D['+']=62,D['/']=63;
 while(cin>>w>>h>>p,w){
   string s;
   used.clear();
   for(int i=0;i<h;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=6;
	while(a--)im[i][j*6+a]=t%2,t/=2;
     }
   }
   for(int i=0;i<p;i++){
     cin>>s;
     for(int j=0;j<s.size();j++){
	int t=D[s[j]];
	int a=6;
	while(a--)pa[i][j*6+a]=t%2,t/=2;
     }
   }
   ans=0;
    for(int i=0;i<4;i++){
     ppp();
     ch1();
     ppp();
     ch1();
     ch();
   }
   cout<<ans<<endl;
 }

 return 0;
}

Measured memory_bytes: 11820
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const long long N=100005;
long long n,a[N],l=2,r=2;
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(long long i=n;i>=1;i--)
	{
		l=(l+a[i]-1)/a[i]*a[i],r=(r/a[i]+1)*a[i]-1;
		//cout<<l<<" "<<r<<endl;
	}
	if(l>r)
		puts("-1");
	else
		printf("%lld %lld\n",l,r);
	return 0;
}

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

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

    vector<int> a = {};
    int t;
    for(int i = 0; i < n; i++)
    {
        cin >> t;
        a.push_back(t);
    }

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

    int pts[2] = {};
    for(int i = 0; i < n; i++)
    {
        pts[i % 2] += a[n - i - 1];
    }

    cout << pts[0] - pts[1];

}

Measured memory_bytes: 256
//author:satwik_bhv1
#include<bits/stdc++.h>
//datatypes
#define ll long long 
#define ld long double
//loops
#define fr(i,z,n) for(ll i=z;i<n;i++)
#define br(i,z,n) for(ll i=z;i>n;i--)
//operations
#define mp  make_pair
#define ff  first
#define ss  second
#define pub push_back
#define all(v) v.begin(),v.end()
//map
#define mi map<ll,ll>
//vectors
#define vi vector<ll>
#define vpi vector<pair<ll,ll> >
//constants
#define pi 3.1415926535897932384626
#define mod 1000000007 
#define MAXN 100001
/*notes
    Don't use inbuilt fun for power
    Range of longlong=(-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 )
    INT_MAX = 2147483647(aprox 2*10^10)
    INT_MIN = -2147483648
    LLONG_MAX = 9223372036854775807 
    LLONG_MIN = -9223372036854775808
    __gcd is the function in built for hcf
    priority queue is max heap by default
    topological sort -> khan's algo use bfs and indegree of node  
    sssp(positive weighted edges) -> Dijkstras
    apsp -> Floydwarshall
    MST -> kruskal(DSU)
*/
using namespace std;
//functions
ll power(ll x,ll y){ll res=1;while(y){if(y%2){res*=x;}y/=2;x*=x;} return res;}
ll power(ll x,ll y,ll z){ll res=1;while(y){if(y%2){res=(res*x)%z;}y/=2;x=(x*x)%z;} return res;}
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
bool sortbysec(const pair<ll, ll>& a, const pair<ll, ll>& b) { return (a.second > b.second); }
ll ceil(ll x,ll y){return (x/y)+(x%y!=0);}
ll n,w;
vpi v;
ll sum;
ll ans;
vi dp(100005,-1);
void fun()
{
    for(ll pos=0;pos<n;pos++)
    {
        ll val=v[pos].ss;
        ll wt=v[pos].ff;
        for(ll i=sum;i>=val;i--)
        {
            if(dp[i-val]!=-1&&(dp[i]==-1||dp[i-val]+wt<dp[i])&&dp[i-val]+wt<=w)
            {
                dp[i]=dp[i-val]+wt;
                ans=max(ans,i);
            }
        }
    }
}
void solve()
{
    cin>>n>>w;
    fr(i,0,n)
    {
        ll a,b;
        cin>>a>>b;
        v.pub({a,b});
        sum+=b;
    }
    ans=0;
    dp[0]=0;
    sort(all(v));
    //reverse(all(v));
    fun();
    cout<<ans;
}
int main()
{
    fast();
    ll t;
    t=1;
    //cin>>t;
    fr(i,0,t)
    {
        solve();
    }
}
/*





























*/

Measured memory_bytes: 3800
from bisect import bisect_left
from time import time
t0 = time()
def xorshift(seed=123456789):  # 31 bit xorshift
    y = seed
    def randint():
        nonlocal y
        y ^= (y & 0xffffff) << 7
        y ^= y >> 12
        return y# % (b-a+1) + a
    return randint
randint = xorshift()
D = int(input())
C = list(map(int, input().split()))  # 低下
S = [list(map(int, input().split())) for _ in range(D)]
Last = [-1] * 26
def calc_pena(day):
    res = 0
    for l, c in zip(Last, C):
        res += (day-l)*c
    return res
T2 = [[-1] for _ in range(26)]

def change(day, contest):
    diff = 0
    contest_old = T[day]
    T[day] = contest
    idx = bisect_left(T2[contest_old], day)
    #assert day in T2[contest_old]
    diff -= C[contest_old] * (T2[contest_old][idx+1] - day) * (day - T2[contest_old][idx-1])
    del T2[contest_old][idx]
    idx = bisect_left(T2[contest], day)
    diff += C[contest] * (T2[contest][idx] - day) * (day - T2[contest][idx-1])
    T2[contest].insert(idx, day)
    diff += S[day][contest] - S[day][contest_old]
    return diff
Check = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 9999]
idx_Check = 0
def check():
    global idx_Check, ans
    if Check[idx_Check] < time()-t0:
        idx_Check += 1
        print(ans, Check[idx_Check-1])

T = []
ans = 0
for day, s in enumerate(S):
    best_gain = -999999
    best_gain_contest = None
    pena = 0
    for cont, (l, c, s_) in enumerate(zip(Last, C, s)):
        p = (day-l)*c
        pena += p
        if best_gain < s_ + p:
            best_gain = s_ + p
            best_gain_contest = cont
    T.append(best_gain_contest)
    Last[best_gain_contest] = day
    ans += best_gain - pena
# print(T)
# print(ans)
# ans = 0
# Last = [-1] * 26
# for i, (s, t) in enumerate(zip(S, T)):
#     Last[t] = i
#     ans += s[t]
#     ans -= calc_pena(i)
#     T2[t].append(i)
for i, t in enumerate(T):
    T2[t].append(i)
for i in range(26):
    T2[i].append(D)  # 番兵

#from math import exp
#def prob(gain, remain_time):
#    return exp(-gain / remain_time)

while time()-t0 < 1.9:
    r = randint()
    day = r % D
    r //= D
    contest = r % 26
    contest_old = T[day]
    ch = change(day, contest)
    if ch >= 0 or (time()-t0 < 1.7 and -ch < randint()&0x3ff):
        ans += ch
        #print(ans, time()-t0)
        #check()
    else:
        change(day, contest_old)
#print(ans)
print("\n".join(str(a+1) for a in T))


Measured memory_bytes: 75976
const main = input => {
  const inputs = input.trim().split('\n')
  const n = parseInt(inputs[0])
  const sequence = inputs[1].split(' ').map(a => parseInt(a))

  let count = 0
  for (let i = 1; i < n - 1; i++) {
    if (sequence[i] > Math.min(sequence[i - 1], sequence[i + 1]) && sequence[i] < Math.max(sequence[i - 1], sequence[i + 1])) {
      count++
    }
  }

  console.log(count)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		string a,b;
		cin >> a >> b;
		int ans = 0;
		for(int i=0;i<3;i++){
				if(a[i] == b[i]) ans++;
		}
		cout << ans << endl;
}



Measured memory_bytes: 256
from math import ceil
from fractions import Fraction


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = ceil(max(Fraction(t, _t), Fraction(a, _a)))
        t, a = _t * n, _a * n
    print(t + a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5984
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    ans = []
    while len(v) > 0:
        flag = False
        for j in reversed(range(len(v))):
            # print(j)
            if j+1 == v[j]:
                ans.append(v[j])
                del v[j]
                flag = True
                break
        if not flag:
            print(-1)
            return
    for c in reversed(ans):
        print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <stdio.h>

int main(){
	int x , y;
	char s [100];
	scanf ("%d %d", &x , &y);
	scanf ("%s", s ) ;
	if (s[y-1] >= 'A' && s[y-1] <= 'Z'){
		s[y-1] = s[y-1]+32;
	}
	printf ("%s",s);
	
	return 0;
}

Measured memory_bytes: 1724
#include<cstdio>
using namespace std;
const int MaxN = 2e5;
long long a[MaxN + 5];
int N;
long long T, x;

int main()
{
	long long flag = 0;
	scanf("%d %lld", &N, &T);
	for(int i = 1; i <= N; i++)	scanf("%lld", &a[i]);
	for(int i = 1; i <= N; i++)
	{
		if(a[i] <= T)
		{
			flag = a[i];
			x = a[i];
		}
		else if(a[i] - a[i - 1] > T) x = x + T;
		else x = x + a[i] - a[i - 1];
	}
	printf("%lld\n", x + T);
	return 0;
}

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

int main(){
  
  int n;
  cin >>n;
  int a[n],b[n],c[n];
  int sum=0;
  for(int i=0; i<n; i++){
    cin >>a[i];
  }
  for(int i=0; i<n; i++){
    cin>>b[i];
    sum+=b[i];
  }
  for(int i=0; i<n; i++){
    cin>>c[i];
  }
  
  
  for(int i=0; i<n-1; i++){
  	if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int d = 0;
	int c[114514];
	for (int i = 0; i < a; i++)
	{
		cin >> c[i];
	}
	sort(c, c + a);
	for (int l = 0; l < b; l++)
	{
		d += c[a - 1 - l];
	}
	cout << d << endl;
}

Measured memory_bytes: 256
def is_kaibun(string):
    for i in range(int(len(string)/2)):
        if string[i] != string[-i-1]:
            return False
    return True

s=input()
list_s=list(s)
n=len(list_s)
m=int((n-1)/2)
if list_s[0:m] == list(reversed(list_s[m+1:])):
    if is_kaibun(s[0:m]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>          // printf(), scanf()
#include <math.h>           // sqrt()

int
main(int argc, char** argv)
{
	double rx, ry;
	double x1, y1;
	double x2, y2;

	scanf("%lf %lf %lf %lf\n", &x1, &y1, &x2, &y2);
	rx = x2 - x1, ry = y2 - y1;

	printf("%.8f\n", sqrt(rx * rx + ry * ry));
	return 0;
}

Measured memory_bytes: 660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 51
int x[MAX],y[MAX];
int a[MAX][MAX];
bool visited[MAX];
int ans = 0;
int n,m;
void init_visited(){
    for(int i=1;i<=n;i++)visited[i] = false;
}

bool check(){
    for(int i=1;i<=n;i++){
        if(visited[i]==false)return false;
    }
    return true;
}

void dfs(int cn){
    visited[cn] = true;
    //cout << "visiting:" << cn << endl;
    if(check()){ans++;return;}
    for(int i=1;i<=n;i++){
        if(a[cn][i]==1&&visited[i]==false)dfs(i);
    //    else cout << "didn't visit "<< i << endl; 
    }
    return;
}

int main(){
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> x[i] >> y[i];
        a[x[i]][y[i]] = 1;
        a[y[i]][x[i]] = 1;
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=1;j<=n;j++){
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    for(int i=1;i<=m;i++){
        init_visited();
        //cout << "start at " << i << endl;
        a[x[i]][y[i]] = 0;
        a[y[i]][x[i]] = 0;
        dfs(1);
        a[x[i]][y[i]] = 1;
        a[y[i]][x[i]] = 1;
    }
    cout << m-ans << endl;
    return 0;  
}

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

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

int main() {
    int n;
    cin >> n;
    int arr[100009] = {0};

    int temp;
    REP(i, n) {
        cin >> temp;
        if (temp != 0) arr[temp-1]++;
        arr[temp]++;
        arr[temp+1]++;
    }

    int result = 0;
    REP(i, 100009) {
        result = max(result, arr[i]);
    }

    cout << result;
}


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

    #define ll long long
    #define pb push_back
    #define mod 1000000007

    int main() {

      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      
      ll n; cin>>n;
      ll i,j,A[n];
      for(i=0;i<n;i++){
        cin>>A[i];
      }
      map<ll,ll> m;
      for(i=1;i<=n;i++){
        m[A[i-1]]=i;
      }
      ll ctr=0;
      for(i=1;i<=n;i++){
        if(i!=m[i])ctr++;
        if(ctr>2)break;
      }
      if(ctr<=2)cout<<"YES";
      else cout<<"NO";

      return 0;
    } 


    

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        public static List<int> over = new List<int>();

        public static List<List<int>> over2D = new List<List<int>>();

        static void Main(string[] args)
        {

            List<int> countlist = new List<int>();

            while (true)
            {
                string[] Input = Console.ReadLine().Split(' ');

                int usenum = int.Parse(Input[0]);
                int asknum = int.Parse(Input[1]);

                if (usenum == 0 && asknum == 0) break;

                int result = 0;

                List<int> resultlist = new List<int>();

                for (int a = 1; a <= usenum; a++)
                {

                    for (int b = a + 1; b <= usenum; b++)
                    {

                        for (int c = b + 1; c <= usenum; c++)
                        {

                            result = a + b + c;

                            if (result == asknum)
                            {

                                resultlist.Add(result);

                            }


                        }
                    }
                }
            
                countlist.Add(resultlist.Count);
            }


            //????????????
            foreach(var result in countlist)
            {
                Console.WriteLine(result);
            }

        }

    }

}

Measured memory_bytes: 9288
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        double sum = 0.0d;
        for (int i = 0; i < n; i++) {
            double price = sc.nextDouble();
            String unit = sc.next();

            if (unit.equals("BTC")) {
                sum += price * 380000.0d;
            } else {
                sum += price;
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 23124
import sys
import numpy as np
from fractions import gcd
from functools import reduce

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = np.array(lr())
B = A // 2
# Bの要素が全て2の同じ冪乗
# Bの最小公倍数を求める
def merge(a, b):
    g = gcd(a, b)
    a, b = a // g, b // g
    if a%2 == 0 or b%2 == 0:
        return 0
    ret = a * b * g
    if ret > 10 ** 9:
        return 0
    return ret

x = reduce(merge, B)
if x == 0:
    answer = 0
else:
    answer = M // x - M // (2*x)

print(answer)
# 56

Measured memory_bytes: 25020
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;

ll count = 0;
ll N;

void dfs(ll depth, ll n) {
    if (n > N) {
        return;
    }

    ll tmp3 = n;
    bool tmp3flag = false;
    while(tmp3 > 0) {
        if (tmp3 % 10 == 3) {
            tmp3flag = true;
            break;
        }
        tmp3 /= 10;
    }
    ll tmp5 = n;
    bool tmp5flag = false;
    while(tmp5 > 0) {
        if (tmp5 % 10 == 5) {
            tmp5flag = true;
            break;
        }
        tmp5 /= 10;
    }
    ll tmp7 = n;
    bool tmp7flag = false;
    while(tmp7 > 0) {
        if (tmp7 % 10 == 7) {
            tmp7flag = true;
            break;
        }
        tmp7 /= 10;
    }

    if (tmp3flag && tmp5flag && tmp7flag) {
        count++;
    }
    if (depth == 0) {
        depth++;
        dfs(depth, 3);
        dfs(depth, 5);
        dfs(depth, 7);
    } else {
        dfs(depth+1, n+std::pow(10, depth)*3); 
        dfs(depth+1, n+std::pow(10, depth)*5); 
        dfs(depth+1, n+std::pow(10, depth)*7); 
    }
}
 
int main(int argc, char *argv[])
{
    std::cin >> N;

    dfs(0, 0);

    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    long long int b = 0;
    REP(i, 1, n)
    {
        if (a[i] - a[i - 1] > t)
        {
            b += t;
        }
        else
        {
            b += (a[i] - a[i - 1]);
        }
    }
    cout << b + t << endl;
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
#たね：gcdは交換法則がなりたち、どこからでも計算していい
#だけど、逆演算ができない 
#(gcd(x,4)==2　を満たすxは2以上の偶数ならなんでもよく
#つまり一つに定まらない）
#そのかわり、"最後の一個以外"を計算してしまうことはできる

#初見殺しじゃねーか
from fractions import gcd
def resolve():
    N,=pin()
    A=tupin()
    lgcd,rgcd=[0]*(N),[0]*(N)
    ltemp,tempr=A[0],A[-1]
    for g in range(N):
        ltemp=gcd(ltemp,A[g])
        lgcd[g]=ltemp
        #print(tempr,A[N-g-1])
        tempr=gcd(tempr,A[N-g-1])
        
        rgcd[N-g-1]=tempr
    #print(lgcd,A,rgcd)
    ans=1
    for i in range((N)):
        a,t=0,0
        if i==0:
            t=rgcd[1]
        elif i==N-1:
            t=lgcd[N-2]
        else:
            t=gcd(lgcd[i-1],rgcd[i+1])
        ans=max(ans,t)
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 89580
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 K          PIC 9(10).
01 idx        PIC 9(10).
01 ln         PIC X(599).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.
01 A1.
   03 A11 OCCURS 100 DEPENDING ON N.
      05 A    PIC S9(10) VALUE 1.

PROCEDURE DIVISION.
  ACCEPT ln.
  UNSTRING ln DELIMITED BY SPACE INTO N K.
  PERFORM K TIMES
   ACCEPT maxlen
   ACCEPT ln
   MOVE 1 TO cur
   PERFORM maxlen TIMES
     PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
     END-PERFORM
     COMPUTE len = j - cur
     MOVE ln(cur:len) TO idx
     MOVE ZERO TO A(idx)
     COMPUTE cur = j + 1
     ADD 1 TO i
   END-PERFORM
  END-PERFORM.
  PERFORM VARYING j FROM 1 BY 1 UNTIL N < j
    IF ZERO < A(j)
      ADD A(j) TO ans
    END-IF
  END-PERFORM.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3928
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] a = new int[n];
    int sub = 0;
    int dis = 0;
    int max_dis = 0;

    for(int i=0; i<n; i++){
      a[i] = sc.nextInt();
    }

    for(int j=0; j<n; j++){
      if(j<n-1){
        sub = a[j+1]-a[j];
        dis += sub;
      }else if(j==n-1){
        sub = k - a[n-1]+a[0];
        dis += sub;
      }

      max_dis = Math.max(max_dis,sub);
      //System.out.println("MAX_DIS"+max_dis);


    }
    System.out.println(dis - max_dis);





  }
}

Measured memory_bytes: 76072
N = int(input())
P = list(map(int, input().split()))
Q = {}
for i in range(N):
    Q[i + 1] = P[i]

ans = 0
for i in range(1, N):
    if Q[i] == i:
        Q[i], Q[i + 1] = Q[i + 1], Q[i]
        ans += 1
if Q[N] == N:
    ans += 1
print(ans)


Measured memory_bytes: 62252
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		String string = cin.next();
		int K = cin.nextInt();
		//贪心算法的最佳体现
		int i;
		for (i=0;i<string.length()-1;i++){
			//最后一个字符要单独处理
			char c = string.charAt(i);
			if (c == 'a') {
				System.out.print('a');
				continue;
			}
			if (K < 'z' - c + 1) {
				System.out.print(c);
				continue;
			}
			System.out.print('a');
			K -= 'z' - c + 1;
		}
		K %= 26;
		char c = string.charAt(i);
		if (K >= 'z' - c + 1) {
			System.out.print((char)('a' + (K - 'z' + c -1 ) % 26));
		} else {
			System.out.print( (char)(c + K));
		}
	}
}

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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    queue<pair<string,int> > que;
    for(int i=0;i<n;i++){
        string s;
        int in;
        cin >> s >> in;
        que.push(make_pair(s,in));
    }
    int cou=0;
    while(!que.empty()){
        cou+=q;
        pair<string,int> p(que.front()); que.pop();
        p.second-=q;
        if(p.second<=0){
            cout << p.first << " " << cou+p.second << endl;
            cou+=p.second;
        }else{
            que.push(p);
        }
    }
}



Measured memory_bytes: 6264
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename Abelian>
class potentialized_disjoint_set {
	std::vector <std::pair<int32, Abelian>> tree;
public:
	potentialized_disjoint_set(uint32 size) :tree(size, { -1,Abelian() }) {}
	uint32 find(uint32 x) {
		if (tree[x].first < 0) return x;
		uint32 t = (uint32)tree[x].first;
		tree[x].first = (int32)find(t);
		tree[x].second = tree[t].second + tree[x].second;
		return (uint32)tree[x].first;
	}
	Abelian potential(uint32 x) {
		find(x);
		return tree[x].second;
	}
	Abelian diff(uint32 x, uint32 y) {
		return potential(y) - potential(x);
	}
	bool unite(uint32 x, uint32 y, Abelian d) {
		d = d + diff(y, x);
		x = find(x);
		y = find(y);
		if (x == y) return false;
		if (tree[x].first > tree[y].first) {
			std::swap(x, y);
			d = -d;
		}
		tree[x].first += tree[y].first;
		tree[y] = std::pair<int32, Abelian>(x, d);
		return true;
	}
	bool same(uint32 x, uint32 y) {
		return find(x) == find(y);
	}
};



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, m;
	std::cin >> n >> m;
	potentialized_disjoint_set<int32> T(n);
	uint32 l, r;
	int32 d;
	while (m--) {
		std::cin >> l >> r >> d;
		--l;--r;
		if (T.same(l, r)) {
			if (T.diff(l, r) != d) {
				std::cout << "No\n";
				return 0;
			}
		}
		else {
			T.unite(l, r, d);
		}
	}
	std::cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 1792
from collections import defaultdict

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

a_num = defaultdict(int) 
for ak in a:
    a_num[ak] += 1

a_calc = dict()
for k in a_num:
    v = a_num[k]
    a_calc[k] = v * (v -1) // 2

a_sum = 0
for k in a_calc:
    a_sum += a_calc[k]

for k in a:
    v = a_num[k]
    ans = a_sum - a_calc[k] + (v-1)*(v-2) // 2
    print(ans)


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

int v[60],tp[60],ans,N,K;

int main()
{
	cin >> N >> K;
	for(int i = 1; i <= N; i++) cin >> v[i];
	for(int i = 1; i <= K && i <= N; i++){
		for(int l = 0; l <= i; l++){
			int cnt = 0, sum = 0;
			for(int j = 1; j <= l; j++) tp[++cnt] = v[j];
			for(int j = N; j > N-i+l; j--) tp[++cnt] = v[j];
			sort(tp+1,tp+cnt+1);
			for(int j = 1; j <= K-i; j++)
				if(tp[j]>0) break;
					else tp[j]=0;
			for(int j = 1; j <= cnt; j++) 
				sum += tp[j];
			ans = max(ans,sum);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define PI 3.14159265359

void form_float(double value, int n_deci, char *output);

int main(){
   double r, L, S;
   char S_str[16], L_str[16];
   scanf("%lf",&r);
   L=2*PI*r;
   S=PI*r*r;
   form_float(L,6,L_str);
   form_float(S,6,S_str);
   printf("%s %s\n",S_str,L_str);
   return 0;
}

void form_float(double value, int n_deci, char *output){
   int value_int, i;
   double value_deci;
   char *deci_format, *deci_str;
   deci_format=malloc((n_deci+4)*sizeof(char));
   deci_str=malloc((n_deci+2)*sizeof(char));
   deci_format[0]='%';
   deci_format[1]='0';
   sprintf(deci_format+2,"%dd",n_deci);
   value_int=(int)value;
   value_deci=value-value_int;
   for(i=0;i<n_deci;i++) value_deci*=10;
   sprintf(deci_str,deci_format,(int)(value_deci+0.5));
   if(strlen(deci_str)==n_deci+1){
      value_int+=1;
      for(i=0;i<n_deci;i++) deci_str[i]='0';
      deci_str[n_deci]='\0';
   }
   sprintf(output,"%d.%s",value_int,deci_str);
   free(deci_format);
   free(deci_str);
}

Measured memory_bytes: 644
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
res = 0
for i in range(n):
	a = list(map(int, input().split()))
	cnt = 0
	for j in range(m):
		cnt += a[j]*b[j]
	cnt += c
	if cnt > 0:
		res += 1
print (res)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;


int main(){
    double L;cin >> L;
    cout << fixed<< setprecision(15)<<(L * L * L)/27.0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+3;

int n;
int h[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=1;i<=n;i++) {
		if(h[i-1]>h[i]) {
			printf("No\n");
			return 0;
		}
		else if(h[i-1]!=h[i])
			h[i]--;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const double eps = 1e-8;
const int p = 1e9+7;

inline ll qpow(long long a, ll b) {
  ll ans = 1;
  a = (a % p + p) % p;
  for (; b; b >>= 1) {
    if (b & 1) ans = (a * ans) % p;
    a = (a * a) % p;
  }
  return ans;
}

ll fac[N],h,w,a,b,ans;

ll getc(ll x1,ll y1,ll x2,ll y2){  
  ll m = x2 - x1 + y2-y1,n = x2-x1;
  if(m == n || n == 0) return 1;
  ll ans =  ((fac[m]*qpow(fac[n],p-2))%p * (qpow(fac[m-n],p-2))%p)%p;
  return ans;
}

int main(){
  // freopen("input.txt","r",stdin);
  cin>>h>>w>>a>>b;
  fac[0] = 1;
  for(int i = 1;i <= 2e5+3;i++) fac[i] = (fac[i-1]*i)%p;
  for(int i = 1;i <= h-a;i++){
    // cout<<getc(1,1,i,b)<<endl;;
    ans = (ans%p + (getc(1,1,i,b)*getc(i,b+1,h,w))%p)%p;
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1792
# C
H, W = map(int, input().split())
 
res = min(H, W)
# split H
for h in range(H // 3, H // 3 + 3):
    w = W // 2
    s1 = h*W
    s2 = (H-h)*w
    s3 = (H-h)*(W-w)
    res = min(res, max(s1,s2,s3) - min(s1,s2,s3))
# split W
for w in range(W // 3, W // 3 + 3):
    h = H // 2
    s1 = w*H
    s2 = (W-w)*h
    s3 = (W-w)*(H-h)
    res = min(res, max(s1,s2,s3) - min(s1,s2,s3))
 
# 3
if H % 3 == 0 or W % 3 == 0:
    res = 0
print(res)

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        N: usize,
        a: [usize; N]
    }
    let mut l= 1;
    let mut selected = HashSet::new();

    for i in 1..100000 {
        l = a[l - 1];
        if selected.contains(&l) {
            break;
        }
        if l == 2 {
            println!("{}", i);
            std::process::exit(0);
        }
        selected.insert(l);
    }
    println!("-1");
}


Measured memory_bytes: 8444
def main():
    while True:
        N = int(input())
        if N == 0:
            return
        ap, bp = 0, 0
        for i in range(N):
            a, b = map(int, input().split())
            if a > b:
                ap += a + b
            elif a < b:
                bp += a + b
            else:
                ap += a
                bp += b

        print(ap, bp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
#2019/10/25
N, S = open(0).readlines()
S = list(S)
# print(N,S)
# print(S[:2], S[2:], set(S[:2]) & set(S[2:]))
print(max([len(set(S[:i]) & set(S[i:])) for i in range(len(S))]))

Measured memory_bytes: 2940
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<string> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  bool answer=true;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<=n-1;j++){
      if(vec.at(i)==vec.at(j)){
        answer=false;
      }
    }
  }
 for(int i=0;i<n-1;i++){
   int l=vec.at(i).size();
   if(vec.at(i).at(l-1)!=vec.at(i+1).at(0)){
     answer=false;
   }
 }
  
  if(answer)
   cout << "Yes" << endl;
  else
    cout << "No" << endl;

  
  }

Measured memory_bytes: 256
package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100
const WHITE = 0
const GRAY = 1
const BLACK = 2

var time, n int

//隣接行列
var M [MAX][MAX]int

//d[i]: 最初にiを訪問した時刻。発見時刻
//f[i]: iの隣接リストを訪問し終えた時刻。完了時刻
var color, d, f [MAX]int

func dfs_visit(u int) {
	color[u] = GRAY
	time++
	d[u] = time
	//隣接を調べる
	for v := 0; v < n; v++ {
		if M[u][v] == 0 {
			continue
		}
		//隣接するvが、未訪問だった場合
		if color[v] == WHITE {
			dfs_visit(v)
		}
	}
	//訪問完了処理
	color[u] = BLACK
	time++
	f[u] = time
	//訪問完了
}

func dfs() {
	//初期化
	for u := 0; u < n; u++ {
		color[u] = WHITE
	}
	time = 0

	//未訪問のuを始点として、深さ優先探索
	for u := 0; u < n; u++ {

		if color[u] == WHITE {
			dfs_visit(u)
		}
	}

	for u := 0; u < n; u++ {
		fmt.Println(u+1, d[u], f[u])
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		M[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				M[u-1][v-1] = 1

			}
		}

	}

	dfs()

}



Measured memory_bytes: 1148
from collections import Counter


def main():
    MAX = 10 ** 5 + 1

    data = [-1] * (2 * MAX)

    def find(x):
        if data[x] < 0:
            return x
        else:
            data[x] = find(data[x])
            return data[x]

    def union(x, y):
        x, y = find(x), find(y)
        if x != y:
            if data[y] < data[x]:
                x, y = y, x
            data[x] += data[y]
            data[y] = x
        return (x != y)


    N, *XY = map(int, open(0).read().split())

    for x, y in zip(*[iter(XY)] * 2):
        union(x, y + MAX)

    X = Counter(find(i) for i in range(MAX))
    Y = Counter(find(i) for i in range(MAX, MAX * 2))
    res = sum(X[i] * Y[i] for i in range(MAX * 2))

    print(res - N)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38580
h, w = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
a = [list(map(int, input().split())) for i in range(h)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            if c[i][j] > c[i][k] + c[k][j]:
                c[i][j] = c[i][k] + c[k][j]

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += c[a[i][j]][1]
print(ans)

Measured memory_bytes: 40544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(string s){
	ll a=0,b=1;
	bool n=true,w=false;
	int pos=s.size()-4;
	int ca=180,cb=1;
	while(pos>=0){
		if(ca%2==0)ca/=2;
		else cb*=2;
		if(b!=cb){
			a*=(cb/b);
			b=cb;
		}
		if(s.substr(pos,4)=="west"){
			n=false;
			if(!w)a+=ca;
			if(pos==0)w=true;
			pos-=4;
			//cout<<"w"<<ca<<" ";
		}
		else {
			w=false;
			if(!n)a-=ca;
			pos-=5;
		}/*
			cout<<"!"<<a;
	if(b!=1)cout<<"/"<<b;
	cout<<endl;
*/
	}
	cout<<a;
	if(b!=1)cout<<"/"<<b;
	cout<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s,s!="#")solve(s);
}


Measured memory_bytes: 3092
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = ReadInt();
            var AB = ReadInts();
            var ans = "NG";
            for (int i = AB[0]; i <= AB[1]; i++)
            {
                if (i % K == 0)
                {
                    ans = "OK";
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27528
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)

typedef long long ll;
pair<int,int> A[200010];
int ans[200010];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    cin>>n;
    fr(i,n){cin>>A[i].f;A[i].s=i;}
    sort(A,A+n);
    int num = n/2;
    fr(i,n)
    {
        int prv = i;
        if (prv >= num)ans[A[i].s]=A[num-1].f;
        else 
        {
        ans[A[i].s]=A[num].f;
        }

    }
    fr(i,n)cout<<ans[i]<<"\n";

    
    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    string s; cin >> s;
    if(s[0] == s[1] && s[2] == s[3] && s[3] == s[0]) no();
    else if(s[0] == s[1] && s[2] == s[3]) yes();
    else if(s[0] ==s[2] && s[1] == s[3]) yes();
    else if(s[0] ==s[3] && s[1]==s[2]) yes();
    else no();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	pi cur = {0, 0};
	int prev = 0;
	rep(i, n){
		int t, x, y;
		cin >> t >> x >> y;
		int d = abs(x - cur.fi) + abs(y - cur.se);
		if(d > (t - prev) || ((t - prev) - d) % 2 == 1){
			cout << "No" << endl;
			return 0;
		}
		cur = {x, y};
		prev = t;
	}
	cout << "Yes" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

long int a, b;
long int s, t, u, v;

int main(){
    cin >> a >> b;
    long int r = 0;
    for(long int i = a; i <= b; i++){
        s = i % 10; t = i / 10000;
        u = (i % 100) / 10; v = (i % 10000) / 1000;
        if(s == t && u == v)
            r++;
    }
    cout << r;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	int n, a;
	cin >> n >> a;
	cout << (n % 500 > a ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, d, a; scanf("%d%d%d", &n, &d, &a);
	std::vector<i64> x(n), h(n);
	for(int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &h[i]);

	std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++) vec.push_back({x[i], i});
	sort(begin(vec), end(vec));

	i64 ans = 0, now = 0;
	std::queue<std::pair<i64, i64>> qu;
	for(auto e: vec) {
		int i = e.second;
		while(!qu.empty() and qu.front().first < x[i]) {
			now -= qu.front().second;
			qu.pop();
		}
		
		i64 rem = h[i] - now;
		if(rem < 0) continue;
		i64 cnt = (rem + a - 1) / a;
		qu.push({x[i] + 2 * d, cnt * a});
		now += cnt * a;
		ans += cnt;
	}
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6640