akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if (b == 100) a*= 1000;
  else if (10 <= b && b < 100) a*= 100;
  else a *= 10;
  a += b;
  for (int i = 1; i*i <= a; i++) {
    if (a == i*i) {
      dump("Yes");
      return 0;
    }
  }
  dump("No");
  return 0;
}


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

typedef long long ll;

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

#define X real()
#define Y imag()
#define x(p) real(p)
#define y(p) imag(p)
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);

typedef double D;
typedef complex<D> P;
namespace std{
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}

struct L : public vector<P> {
  L(const P&a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; D r;
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1; //ccw
  if(cross(b, c) < 0) return -1; //cw
  if(dot(b, c) < 0)   return +2; //c-a-b on line
  if(norm(b) < norm(c)) return -2; //a-b-c on line
  return 0;
}

P projection(const L& l, const P& p) {
  D t = dot(p - l[0], l[0] - l[1]) / norm(l[0]- l[1]);
  return l[0] + t * (l[0] - l[1]);
}
P refrection(const L& l, const P& p) {
  return p + 2.0 * (projection(l, p) - p);
}

bool intersectSS(const L& a, const L& b) {
  return ccw(a[0], a[1], b[0]) * ccw(a[0], a[1], b[1]) <= 0
    && ccw(b[0], b[1], a[0]) * ccw(b[0], b[1], a[1]) <= 0;
}
int main() {
  int n;
  cin >> n;
  while(n--) {
    vector<P> ps(4);
    rep(i, 4) {
      D x, y;
      cin >> x >> y;
      ps[i] = {x, y};
    }
    if(intersectSS(L{ps[0], ps[1]}, L{ps[2], ps[3]}))cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using namespace std;

// テーブルを作る前処理

ll M = 1000000007;
int main()
{
    ll h;
    cin>>h;
    ll crt=h;
    int cnt=0;
    while(crt>0){
        crt/=2;
        if(crt!=0){
            cnt++;
        }else{
            break;
        }
    }
    ll ans=1;
    rep(i,cnt+1){
        ans*=2;
    }
    ans-=1;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
using namespace std;
int n,m;
ll a[100010];
ll po[100010];
ll ne[100010];
ll sum=0;
ll res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		cin >>a[i];
		sum+=a[i];
		if (a[i]>0) po[i+1]=po[i]+a[i];
		else po[i+1]=po[i];
		if (a[i]<0) ne[i+1]=ne[i]+a[i];
		else ne[i+1]=ne[i];
	}
	for (int i=0;i<=n-m;i++)
	{
		ll t=po[i+m]-po[i]+ne[i+m]-ne[i];
		t+=po[i]+po[n]-po[i+m];
		res=max(res,t);
		t=po[i]+po[n]-po[i+m];
		res=max(res,t);
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;

int A[20];
set<int> s;

int check(int a,int n ,int c) {
	if (c == 0) {
		s.insert(a);
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (A[i] != -1) {
			int tmp = A[i];
			A[i] = -1;
			int d;
			if (tmp < 10)
				d = 10;
			else
				d = 100;
			check(a *d+tmp,n,c-1);
			A[i] = tmp;
		}
	}
	return 0;
}

int main()
{
	int N, K;
	while (1) {
		s.clear();
		cin >> N >> K;
		if (N == 0 && K== 0)break;

		for (int i = 0; i < N; i++) {
			cin >> A[i];
		}
		check(0,N,K);
		cout << s.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int z = scanner.nextInt();
            if (z == 0) {
                break;
            }

            int z3 = z * z * z;
            int maximum = 0;
            for (int x = 1; x * x * x < z3; x++) {
                int x3 = x * x * x;
                for (int y = 1; x3 + y * y * y < z3; y++) {
                    int y3 = y * y * y;
                    if (x3 + y3 > maximum) {
                        maximum = x3 + y3;
                    }
                }
            }
            System.out.println(z3 - maximum);
        }            
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstring>

using namespace std;

int main ()
{
	long long dp[101][40];
	memset(dp, 0, sizeof(dp));
	int n, a[101];
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	dp[1][a[1]+10]=1;
	for (int i=1; i<n-1; i++)
	{
		for (int j=10; j<=30; j++)
		{
			dp[i+1][j+a[i+1]]+=dp[i][j];
			dp[i+1][j-a[i+1]]+=dp[i][j];
		}
	}
	cout<<dp[n-1][a[n]+10]<<endl;
	
	return 0;
}




Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());



int main(){
	int n;
	while(cin>>n,n){
		pii lun=mkp(0,0),din=mkp(0,0),mid=mkp(0,0);
		rep(i,n){
			int a,b,c;
			char t;
			cin>>a>>t>>b>>c;
			int la=c-b;
			if(la<0){
				la=c+60-b;
			}
			if(la<9){
				int tt=a*60+b;
				if(11*60<=tt&&tt<15*60){
					lun.F++;
					lun.S++;
				}
				else if(18*60<=tt&&tt<21*60){
					din.F++;
					din.S++;
				}
				else if(21*60<=tt&&tt<=24*60){
					mid.S++;
					mid.F++;
				}
				else if(0<=tt&&tt<2*60){
					mid.F++;
					mid.S++;
				}
			}
			else{
				int tt=a*60+b;
				if(11*60<=tt&&tt<15*60){
					// lun.F++;
					lun.S++;
				}
				else if(18*60<=tt&&tt<21*60){
					// din.F++;
					din.S++;
				}
				else if(21*60<=tt&&tt<=24*60){
					mid.S++;
					// mid.F++;
				}
				else if(0<=tt&&tt<2*60){
					// mid.F++;
					mid.S++;
				}
			}
		}
		cout<<"lunch ";
		if(lun.S){
			int t=lun.F*100/lun.S;
			cout<<t<<endl;
		}
		else{
			cout<<"no guest\n";
		}
		cout<<"dinner ";
		if(din.S){
			int t=din.F*100/din.S;
			cout<<t<<endl;
		}
		else{
			cout<<"no guest\n";
		}
		cout<<"midnight ";
		if(mid.S){
			int t=mid.F*100/mid.S;
			cout<<t<<endl;
		}
		else{
			cout<<"no guest\n";
		}
	}
}

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

int main()
{
    int w, h;
    while (cin >> h >> w) {
        if (h == 0 && w == 0) break;

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3068
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b&&c!=0)||(a%b==0&&c!=0))
	{
		cout<<"NO"<<endl;
		return 0;
	}
	for(int i=1;i<=1000;i++)
	{
		if(a*i%b==c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
const int inf=1e9+7;
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
int main()
{
	int n,k;
	cin>>n>>k;
	vector<vector<int> >g(n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	vector<vector<int> >mat(n,vector<int>(n,inf));
	for(int r=0;r<n;r++)
	{
		auto &row=mat[r];
		queue<int>q;
		row[r]=0;
		q.push(r);
		while(!q.empty())
		{
			int u=q.front();
			q.pop();
			for(const int v:g[u])
			{
				if(row[v]<inf)
					continue;
				row[v]=row[u]+1;
				q.push(v);
			}
		}
	}
	int ans=inf;
	if(k&1)
		for(int u=0;u<n;u++)
			for(const int v:g[u])
			{
				int cnt=0;
				for(int i=0;i<n;i++)
					if(mat[u][i]+mat[v][i]<=k)
						cnt++;
				ans=min(ans,n-cnt);
			}
	else
		for(int i=0;i<n;i++)
		{
			int cnt=0;
			for(int j=0;j<n;j++)
				if(mat[i][j]<=k/2)
					cnt++;
				ans=min(ans,n-cnt);
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int cnt = 0;
	rep(i, n-1) {
		if (s[i] == s[i + 1])cnt++;
	}
	int ans = min(cnt + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
require 'date'

while line = STDIN.gets
  if line == "0 0\n" then break end
  m, d = line.chomp.split(" ").map { |item| item.to_i }

  dt = Date.new(2004, m, d)

  if dt.sunday? then
    puts "Sunday"
  elsif dt.monday? then
    puts "Monday"
  elsif dt.tuesday? then
    puts "Tuesday"
  elsif dt.wednesday? then
    puts "Wednesday"
  elsif dt.thursday? then
    puts "Thursday"
  elsif dt.friday? then
    puts "Friday"
  elsif dt.saturday? then
    puts "Saturday"
  end
end

Measured memory_bytes: 8880
n,k = map(int,input().split())
a = list(map(int,input().split()))
cnt1 = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j],a[j-1] = a[j-1],a[j]
            cnt1 += 1
cnt1 *= k

cnt2 = 0
for i in range(n):
    for j in range(n):
        if i != j:
            if a[i] > a[j]:
                cnt2 += 1
cnt2 = cnt2*(k*(k-1)//2)

print((cnt1+cnt2)%(10**9+7))

Measured memory_bytes: 9160
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << n / k << endl;
  else
    cout << (n / k) + 1 << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int mx = h1 * 60 + m1;
	int my = h2 * 60 + m2;
	if(my < mx)my += 24 * 60;
	cout << max(0, my - mx - k) << '\n';
}

Measured memory_bytes: 3620
s = int(input())
count = 0
if s == 1 or s == 2 or s == 4:
    print(4)
else:
    while(True):
        if s%2 == 0:
            s = int(s/2)
        else:
            s = 3*s +1
        count += 1
        if s == 4:
            print(count+4)
            break
        else:
            pass

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 2000000
#define INFTY (1<<30)
int size, A[MAX];

void maxHeapify(int i){
  int l, r, max, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) max = l;
  else max = i;
  if ( r <= size && A[r] > A[max] ) max = r;
  if ( max != i ){
    t = A[i];
    A[i] = A[max];
    A[max] = t;
    maxHeapify(max);
  }
}

int extract(){
  int maxv;
  if ( size < 1 ) return;
  maxv = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return maxv;
}

void increase(int i, int key){
  int t;
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i/2] < A[i] ){
    t = A[i];
    A[i] = A[i/2];
    A[i/2] = t;
    i = i/2;
  }
}

void insert(int key){
  size++;
  A[size] = -INFTY;
  increase(size, key);
}

main(){
  int key;
  char com[20];
  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }

  return 0;
}






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

bool isEvenString(std::string S){
  if(S.size()%2==1) return false;
  int l = S.size()/2;
  std::string S1 = S.substr(0,l);
  std::string S2 = S.substr(l,l);
  if(S1==S2) return true;
  else return false;
}

int main(){
  std::string S;
  std::cin >> S;
  while(true){
    S.pop_back();
    if(isEvenString(S)){
      std::cout << S.size() << std::endl;
      break;
    }
  }
}

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

int n, nmin, nmax;
int main() {
  while (cin >> n >> nmin >> nmax) {
	if (n == 0) break;
	vector<int> P(n);
	for (int i = 0; i < n; ++i) cin >> P[i];
	sort(P.begin(), P.end(), greater<int>());
	int mgap = 0;
	int res = -1;
	for (int i = nmax; i >= nmin; --i) {
	  int gap = P[i-1] - P[i];
	  if (mgap < gap) {
		mgap = gap;
		res = i;
	  }
	}
	cout << res << endl;
  }
}
	  



Measured memory_bytes: 3148
/* Created by Ishaan Shah on 24-10-2019.
* Problem Name: 
* Problem Link: 
*/

#include <bits/stdc++.h>

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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int n, vis[3005][3005];
double p[3005], memo[3005][3005];

double dp(int i, int h) {
    if (i == 1) {
        if (h == 1)
            return p[1];
        else if (h == 0)
            return 1-p[1];
        else
            return 0;
    }
    double &ans = memo[i][h];
    if (vis[i][h])
        return ans;
    vis[i][h] = 1;
    ans = dp(i-1, h-1)*p[i] + dp(i-1, h)*(1-p[i]);
    return ans;
}

int main() {
    //#ifndef ONLINE_JUDGE
        //freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
    //#endif

    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> p[i+1];
    double ans = 0;
    for (int i = 0; i <= n/2; i++) 
        ans += dp(n, n-i);
    printf("%.10lf", ans);
}

Measured memory_bytes: 105984
#!/usr/bin/env python3
n,m = map(int,input().split())
a = [0]*n
b = [0]*n
x = [0]*m
y = [0]*m
for i in range(n):
    s,t = map(int,input().split())
    a[i],b[i] = s,t
for i in range(m):
    s,t = map(int,input().split())
    x[i],y[i] = s,t

for i in range(n):
    min_idx = 1 #これに足すと添字があう
    min_dist = 10**9
    for j in range(m):
        if abs(x[j]-a[i])+abs(y[j]-b[i]) < min_dist:
            min_dist = abs(x[j]-a[i])+abs(y[j]-b[i])
            min_idx = 1 + j
            #print(x[j],a[i],y[j],b[i])
            #print(min_dist)

    print(min_idx)

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  ll n,m;
  cin >> n >> m;
  ll ans = 0;
  for(int i = 0; i < m; i++){
    ll a;
    cin >> a;
    ans += a;
  }
  if(n - ans >= 0) cout << n - ans << endl;
  else cout << -1 << endl;
}


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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int answer = 1;
  for (int i = 1; i < N; i++) {
    if (S[i] != S[i - 1]) answer++;
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
bool sortDescByFirst(const pair<int,int>&a, const pair<int,int>&b){
    return a.first>=b.first;
}
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int x,a,b;
    while(cin>>x>>a>>b){
        x=x-a;
        x=x%b;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b; scanf("%d%d",&a,&b);
if((a==1 && b==2) || (a==2 && b==1))
    printf("3");
else if((a==1 && b==3) || (a==3 && b==1))
    printf("2");
else
    printf("1");
return 0;
}


Measured memory_bytes: 760
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<algorithm>
#include<set>
#include<map>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORS(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define SORT(v,n) sort(v,v+n)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,n,0)
#define si(n) scanf("%d",&n)
#define sc(s) scanf("%s",s)
#define EPS (1e-7)
#define INF (1e9)

using namespace std;
typedef long long int ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQI;
typedef priority_queue<int,vector<int>,greater<int> > PQSI;
typedef priority_queue<ll> PQL;
typedef priority_queue<ll,vector<ll>,greater<ll> > PQSL;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}

template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

int n;
int p[20];
int main(void){
    cin >> n;
    rep(i,n) cin >> p[i];
    int count = 0;

    rep(i,n-2){
        if(p[i]<=p[i+1]&&p[i+1]<=p[i+2]) count++;
        else if(p[i]>=p[i+1]&&p[i+1]>=p[i+2]) count++;
    }
    cout << count << endl;

    return 0;
}



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

using namespace std;

int main()
{
	string S;
	string ans = "No";
	cin >> S;

	int i;
	for (i = 0; i < S.size(); i++)
	{
		if (S[i] == 'C')
			break;
	}

	for (i++; i < S.size(); i++)
	{
		if (S[i] == 'F')
		{
			ans = "Yes";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#define ll long long
using namespace std;

int n;
ll x, ans, temp, a[100010];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> x;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		temp = max(a[i] + a[i - 1] - x, 0LL);
		ans += temp;
		a[i] -= temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (auto &e : a)
    cin >> e;
  for (auto &e : b)
    cin >> e;
  for (auto &e : c)
    cin >> e;

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

  ll ans = 0;
  for (int i = 0; i < n; ++i)
  {
    auto pre = (lower_bound(a.begin(), a.end(), b[i]) - a.begin());
    auto post = n - (lower_bound(c.begin(), c.end(), b[i] + 1) - c.begin());
    ans += pre * post;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;



int atcoder(){
    //入力
    ll n,k;
    cin >> n >> k;
    ll ans = k*pow(k-1,n-1);
    cout << ans << ENT;
    
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main (String[] args) {
    try{
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      String s = new String(in.readLine());

      int ans = 700;
      if(s.charAt(0) == 'o') {
        ans += 100;
      }
      if(s.charAt(1) == 'o') {
        ans += 100;
      }
      if(s.charAt(2) == 'o') {
        ans += 100;
      }

      System.out.println(ans);
    } catch (IOException e) {
    }
  }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string str;
    cin >> str;
    int q;
    cin >> q;
    string head = "", tail = "";
    bool rev = false;
    while (q--)
    {
        int x;
        cin >> x;
        if (x == 1) rev = !rev, swap(head, tail);
        else
        {
            int y;
            string z;
            cin >> y >> z;
            if (y == 1) head = (!rev) ? z+head : head+z;
            else tail = (!rev) ? tail+z : z+tail;
        }
    }
    if (rev)
    {
        reverse(all(str));
        reverse(all(head));
        reverse(all(tail));
    }
    cout << head << str << tail << '\n';
    return 0;
}

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

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

using namespace std;

int main(){
  int m,n;cin >> m >> n;
  int ans = 0;
  FOR(i,1,m+1){
   FOR(j,1,n+1){
     int d1=j/10;int d2=j%10;
     if(i==(d1*d2) && (d1>1) && (d2>1) ) ans++;
   }
  }
  cout << ans << endl;
}


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

int main() {
  int R;
  cin >> R;
  cout << 2*R*M_PI << endl;
  return 0;
}

Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  int ans = (int)sqrt(n)*(int)sqrt(n);
  
  cout << ans << endl;
  

 return 0;
}

Measured memory_bytes: 256
def chmin(a, b):
    if a > b:
        return b
    return a
def resolve():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [10**10] * n
    dp[0] = 0
    for i in range(n):
        dp[i] = chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[-1])
resolve()

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

bool cmp(pair<int,int> a, pair<int,int> b)
{
	if( a.first == b.first ) return a.second < b.second;
	return a.first > b.first;
}

int main()
{
	int n,m;
	
	while(cin>>n>>m,n|m){
		pair<int,int> memo[100];
		for(int i=0; i<m; i++)memo[i].second = i;
		
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				int a; cin>>a;
				memo[j].first += a;
				//printf(" %d,",a);
			}
			//puts("");
		}
		stable_sort(memo,memo+m,cmp);
		
		if( m>0 )printf("%d",memo[0].second+1);
		for(int i=1; i<m; i++){
			printf(" %d",memo[i].second+1);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "



int main(){
    int a,x;cin>>x>>a;
    x<a?co(0):co(10);
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))

sequence_num=a[0]
sequence_count=1
count=0

for i in range(1,n):
    if a[i]==sequence_num:
        sequence_count+=1
        if sequence_count%2==0:
            count+=1
    else:
        sequence_num=a[i]
        sequence_count=1
print(count)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
X, A, B = map(int, input().split())

if A >= B :
  print ("delicious")
  exit()
if A+X >= B :
  print ("safe")
  exit()
print ("dangerous")




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

int main(void){
	int a,b;
	long long int c;
	int i,j,k;

	scanf("%d %d %lld",&a,&b,&c);
	for(i=0;i<10;i++){
		c=a*c-b;
		printf("%ld\n",c);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int h,w;
	cin >> h >> w;

	char a[h][w];
	bool space=true;
	int hh=0;
	for(int i=0;i<h;i++){
		space=true;
		for(int j=0;j<w;j++){
			cin >> a[i-hh][j];
			if(a[i-hh][j] == '#') space=false;
		}
		if(space) hh++;
	}
	bool ww[w];
	for(int j=0;j<w;j++){
		space=true;
		for(int i=0;i<h-hh;i++){
			if(a[i][j]=='#') space=false;
		}
		if(space) ww[j] = true;
		else		ww[j] = false;
	}

	for(int i=0;i<h-hh;i++){
		for(int j=0;j<w;j++){
			if(ww[j]) continue;
			cout << a[i][j];
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
int a[100005];
int n,ant;
int extgcd(int a,int b,int& x,int& y)
{
    int d=a;
    if(b!=0)
    {
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }
    else
    {
        x=1;
        y=0;
    }
    return d;
}
void trace()
{
    for(int i=0;i<n;i++)
    {
        if(i)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}
void bubble()
{
    bool flag=1;
    for(int i=0;flag;i++)
    {
        flag=0;;
        for(int j=n-1;j>=i;j--)
        {
            if(a[j]<a[j-1])
            {
                swap(a[j],a[j-1]);
                flag=1;
                ant++;
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    bubble();
    trace();
    printf("%d\n",ant);
    return 0;
}



Measured memory_bytes: 3228
import heapq

n, m = map(int, input().split())
if n >= m:
    print(0)
else:
    x = sorted([int(i) for i in input().split()])
    diff = []
    for i in range(m-1):
        diff.append(x[i]-x[i+1])
    heapq.heapify(diff)

    for _ in range(n-1):
        heapq.heappop(diff)
    print(-sum(diff))

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using ld = long double;
using ui = unsigned int;
using ull = unsigned long long;
using ui128 = __uint128_t;
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e5 + 2, LOG = 17, INF = 1e8;
struct Circle {
	int x,y,r;
	ld dist (const Circle &o) {
		return max((ld)0,sqrtl((ll)(x-o.x)*(x-o.x) + (ll)(y-o.y)*(y-o.y)) - r - o.r);
	} 
};
int main () { 
	int sx,sy,ex,ey,n;
	scanf ("%d %d %d %d %d",&sx,&sy,&ex,&ey,&n);
	vector<Circle> circles(n+2); vector<ld> dist(n+2);
	for (int i = 1; i <= n; i++) scanf ("%d %d %d",&circles[i].x,&circles[i].y,&circles[i].r);
	circles[0] = {sx,sy,0}; circles[n+1] = {ex,ey,0};
	for (int i = 1; i <= n+1; i++) dist[i] = 1e18;
	dist[0] = 0;
	vector<bool> done(n+2);
	for (int iter = 1; iter <= n+2; iter++) {
		int mn = -1;
		for (int i = 0; i <= n+1; i++) if (!done[i] && (mn == -1 || dist[i] < dist[mn])) mn = i;
		done[mn] = 1;
		for (int i = 0; i <= n+1; i++) if (!done[i] && dist[mn] + circles[mn].dist(circles[i]) < dist[i]) {
			dist[i] = dist[mn] + circles[mn].dist(circles[i]);
		}
	}
	printf ("%.10Lf\n",dist[n+1]);
    return 0;
}


Measured memory_bytes: 3916
# AGC021A - Digit Sum 2
def main():
    N = input().rstrip()
    f = int(N[0])  # first digit
    ds1 = sum(map(int, str(N)))  # ds: digit sum
    ds2 = (f - 1) + 9 * (len(N) - 1)
    print(max(ds1, ds2))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
    using namespace std;
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < int , int >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 1000005

    int main()
    {

      // unordered_map< pair<char,int> ,ll> :: iterator itr;
      map<ll,ll>m1,m2;
      map<ll,ll> :: iterator itr;
        string s;
        cin>>s;
        forl(i,0,n,s.size())
        {
            if(s[i]==s[i+1]&&i+1<s.size()){cout<<"Bad"<<endl;return 0;}
        }
cout<<"Good"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# input
N = int(input())

# solve
l = [0] * (N + 1)
l[0] = 2
l[1] = 1
for i in range(2, N + 1):
    l[i] = l[i - 1] + l[i - 2]

# output
print(l[-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int main() {
#ifdef LOCAL
  freopen("a.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  int n, m, k, a, ans = 0;
  cin >> n >> m;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> k;
    while (k--) {
      cin >> a;
      mp[a]++;
    }
  }
  for (pii x : mp) {
    ans += (x.S == n);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    string s; cin >> s;
    ll n = s.size();
    ll res = 0;
    rep(i,0,n/2){
        if(s[i] == s[n-i-1])
            continue;
        else
            res++;
    }
    cout << res << ednl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];
int prim();

int main(){
  int i,j,e;
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d",&e);
      M[i][j] = (e ==-1) ? INFTY : e;
    }
  }

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

  return 0;
}

int prim(){
  int u, k,d[MAX],p[MAX],color[MAX],v,i;
  int sum = 0;

  for(i = 0; i < n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    k = INFTY;
    u = -1;
    for(i = 0; i < n; i++){
      if(k > d[i] && color[i] != BLACK){
	u = i;
	k = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    if(p[i] != -1) sum +=M[i][p[i]];
  }

  return sum;
}
 



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main(){

string s;
cin>>s;
bool x=1;
for(int i=0;i<4;i++)
{
    if(s[i]==s[i+1])
        x=0;
}


if(x==1)
    cout<<"Good";
else cout<<"Bad";
return 0;

}



Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
d = {}
cnt = 0
for v in a:
  if not v in d:
    d[v] = 1
    cnt += 1
  else:
    d[v] += 1
if cnt - K < 0:
  print(0)
else:
  s = sorted(d.items(), key=lambda x:x[1])
  ans = 0
  for i in range(cnt - K):
    ans += s[i][1]
  print(ans)

Measured memory_bytes: 38964
#include <iostream>
#include <cmath>

using namespace std;

int n;
int c[500];
int s[500];
int f[500];

int fastest(int i, int t) {
    if (s[i] >= t) { return s[i]; }
    return ceil(static_cast<double>(t) / f[i]) * f[i];
}

int solve(int stanum) {
    int elapsed = 0;
    for (int i = stanum; i < n; i++) {
        elapsed = fastest(i, elapsed) + c[i];
    }
    return elapsed;
}

int main() {
    cin >> n;

    for (int i = 1; i < n; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 1; i < n; i++) {
        cout << solve(i) << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());

		int dif = A - B;
		if (dif < 0) {
			dif = dif * -1;
		}

		if (dif % 2 != 0) {
			System.out.println("IMPOSSIBLE");
		} else if (A < B) {
			System.out.println(B - (dif / 2));
		} else {
			System.out.println(A - (dif / 2));
		}
	}

}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong X, A;
	cin >> X >> A;
	if (X < A)
		cout << 0 << endl;
	else
		cout << 10 << endl;

	return 0;
}

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

int main() {
		
	string sa, sb, sc; cin >> sa >> sb >> sc;

	int na = sa.size();
	int nb = sb.size();
	int nc = sc.size();
	int tmp_a = 0;
	int tmp_b = 0;
	int tmp_c = 0;
	char who = 'a';
	while (true) {
		if (tmp_a == na + 1|| tmp_b == nb + 1 || tmp_c == nc + 1) {
			break;
		}
		if (who == 'a') {
			who = sa[tmp_a++];
		}
		else if (who == 'b') {
			who = sb[tmp_b++];
		}
		else { // who == 'c'
			who = sc[tmp_c++];
		}
	}
	
	if(tmp_a == na + 1) cout << 'A' << endl;
	else if (tmp_b == nb + 1) cout << 'B' << endl;
	else if (tmp_c == nc + 1) cout << 'C' << endl;	
	return 0;
}

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

int top, S[1000];
void push(int x){
	S[++top] = x;
}
int pop(){
	top --;
	return S[top+1];
}

int main() {
	int top = 0;
	int a, b;
	char s[100];
	while (scanf("%s", s) != EOF) {
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}else if(s[0] == '-'){
			a = pop();
			b = pop();
			push(b - a);
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

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

int main(){
    int N; cin >> N;
    map<string, int> memo;
    for (int i = 0; i < N; i++)
    {
        string x; cin >> x;
        memo[x]++;
    }
    int maxv = 0;
    for (const auto x : memo){
        int v = x.second;
        if (v > maxv){
            maxv = v;
        }
    }
    for (const auto x : memo){
        if (x.second == maxv){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, r;
    cin >> n >> r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout << r+100*(10-n) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=2*1e5+2,M=201;

void solve()
{
	int a,b;
	cin>>a>>b;
	if(a>0&&b>0)
	{
		cout<<"Positive\n";
	}
	else if(a<=0)
	{
		if(b>=0)
		{
			cout<<"Zero\n";
		}
		else{
			if((b-a+1)%2==1)
			{
				cout<<"Negative\n";
			}
			else cout<<"Positive\n";
		}
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    string a,b,c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#a = int(input())
n, m, k = map(int, sys.stdin.readline().split())
#s = input()
A = list(map(int, sys.stdin.readline().split()))

B = list(map(int, sys.stdin.readline().split()))

a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
    
for i in range(m):
    b.append(b[i] + B[i])

ans = 0
p = m
for i in range(n+1):
    if a[i] > k:
        break

    while ((k - a[i]) < b[p]):
        p -= 1

    ans = max(ans, i+p)

print(ans)












Measured memory_bytes: 50152
BTC_yen = 380000.0

n = int(input())
kazu = []
tani = []
kazu_tani = [[i for i in input().split()] for i in range(n)] 

goukei = 0.0
for kt in kazu_tani:
  if kt[1] == 'JPY':
    goukei += int(kt[0])
  elif kt[1] == 'BTC':
    goukei += float(kt[0]) * BTC_yen
  
print(goukei)

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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    string s;
    cin >> s;

    ll k;
    cin >> k;

    int n = s.size();

    ll rep = 0;
    vector<int> v;
    int p = 1;
    int sz = 1;
    while (p<n) {
        if (s[p-1]!=s[p]) {
            v.push_back(sz);
            if (v.size()>1) {
                rep += sz / 2;
            }
            sz = 1;
        } else {
            sz += 1;
        }

        p += 1;
    }

    if (v.empty()) {
        // all the same
        cout << k * n / 2 << endl;
        return;
    }

    ll tail = 0;
    if (s[p-1]==s[0]) {
        tail = sz;
        v.push_back(sz+v.front());
    } else {
        v.push_back(sz);
        rep += sz / 2;
        v.push_back(v.front());
    }

    ll cnt = v.front() / 2;
    cnt += rep * k;
    cnt += (k - 1) * (v.back() / 2);
    cnt += tail / 2;

    cout << cnt << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

#define fin stdin
#define fout stdout

int a[100009];

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

    for(int i = 1; i <= n; i ++)
        std::cin >> a[i];

    long long ans = 0;
    for(int i = 1; i <= n; i ++){
        ans += a[i] / 2;
        if(i < n && a[i] % 2 && a[i + 1] > 0)
            ans ++, a[i + 1] --;
    }

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 1148