akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 5956
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  // vector<int> vecA (N,0);
  // vector<int> vecB (N,0);
  map<int,int> mpA,mpB;

  for (int i = 0; i < N; i++)
  {
    mpA[vec[i] + i+1]++;
    mpB[-1*vec[i]+ i+1]++;
  }
  int ANS = 0;
  for (auto &&i : mpA)
  {
    // DEBUG(i.first,i.second,mpB[i.first],"\n");
    ANS += i.second*mpB[i.first];
  }
  cout<<ANS<<endl;
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int>a(n), b(n), c(n);
	for (auto&& x : a)cin >> x;
	for (auto&& x : b)cin >> x;
	for (auto&& x : c)cin >> x;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long ans = 0;
	for (long long i = 0,aN,cN; i < n; i++) {
		cN = c.end() - upper_bound(c.begin(), c.end(), b[i]);
		aN = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		ans += cN * aN;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main()
{
	long int k, a, b;
	long long int ans,x,y;
	cin >> k >> a >> b;

	if (k > a - 1) {
		ans = a;
	}
	else {
		cout << k + 1 << endl;
		return 0;
	}
	if (((double)(b - a) / 2) > 1) {
		x = b - a;
		y = (k - a + 1) / 2;
		ans += x * y;
		ans += (k - a + 1) % 2;
	}
	else {
		ans = k + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
s1 = s[0:(n-1)//2]
s2 = s[(n+3)//2-1:n]
S = []
S1 = []
S2 = []
i = -1
j = -1
k = -1
while i >= n * -1:
    S.append(s[i])
 
    i -= 1
while j >= len(s1) * -1:
    S1.append(s1[j])
    j -= 1
while k >= len(s2) * -1:
    S2.append(s2[k])
    k -= 1
if s == S and s1 == S1 and s2 == S2:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        s = s + s[0];
        s = s.substr(1);
        if (s == t) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	int maxI = max(a, max(b, c));
	int ans = 0;
	while (a + 2 <= maxI) {
		a += 2;
		++ans;
	}
	while (b + 2 <= maxI) {
		b += 2;
		++ans;
	}
	while (c + 2 <= maxI) {
		c += 2;
		++ans;
	}

	int cnt = 0;
	if (a == maxI - 1) ++cnt;
	if (b == maxI - 1) ++cnt;
	if (c == maxI - 1) ++cnt;

	if (cnt == 1) ans += 2;
	if (cnt == 2) ++ans;

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  l = i
  while l >= 1:
    p = l%10
    l = l//10
    S = S + p
  if A <= S <= B:
    k = k + i
print(k)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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

const int N = 3005;
const int MOD = int(1e9)+7;
const int INF = int(2e9)+5;
const ll INF64 = 1e18;


double dp[N][N];

int main () {
    int n;cin>>n;
    double p;cin>>p;
    memset(dp,0,sizeof(dp));
    dp[1][1] = p;dp[1][0] = 1 - p;
    for (int i=2;i<=n;i++) {
    	cin>>p;
    	dp[i][0] = dp[i-1][0] * (1-p);
    	for (int j=i;j>0;j--) {
    		dp[i][j] = dp[i-1][j] * (1-p) + dp[i-1][j-1] * p;
    	}
    }
    double ans = 0;
    int m = (n+1)/2;
    for (int i=m;i<=n;i++) {
    	ans += dp[n][i];
    }
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 70912
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline
from decimal import *
from collections import Counter


def solve(n):
    cnt = Counter()
    n_int = 0
    for _ in range(n):
        getcontext().prec = 22
        a = input().rstrip()
        da = Decimal(a)
        ia = int(da.shift(9))
        #print(a,ia)
        if ia%10**9 == 0:
            n_int += 1
        pmul_2 = 0
        pmul_5 = 0
        ia2 = ia
        while ((ia2 & 1) == 0 and pmul_2 < 18): 
            ia2 = ia2 >> 1
            pmul_2 += 1
        ia5 = ia
        while 1:
            if (ia5 % 5 ==0 and pmul_5 < 18):
                pmul_5 += 1
                ia5 = ia5//5
            else:
                break
        cnt[(pmul_2,pmul_5)] += 1
    ans = 0
    #print(cnt)
    for pm2_1 in range(0,19):
        for pm2_2 in range(18-pm2_1,19):
            for pm5_1 in range(0,19):
                for pm5_2 in range(18-pm5_1,19):
                    ans += cnt[(pm2_1,pm5_1)]*cnt[(pm2_2,pm5_2)]
    ans -= n_int
    ans = ans//2
    
    print(ans)
                






def main():
    n = int(input())
    solve(n)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
int n,k,tot;
int a[100010];
int main(){
	cin>>n>>k;
	k--;
	int t;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==1)t=i;
	}
	int ll=t,rr=t;
	while(ll>0){
		ll-=k,tot++;
	}
	rr=rr-ll+1;
	while(rr<n){
		rr+=k,tot++;
	}
	cout<<tot<<endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll countA = 0, countB = 0;
    vector<ll> base;
    vector<ll> temp;
    vector<ll> P, Q;
    cin >> N;
    base.resize(N);
    for(ll i = 0;i < N;i++) base[i] = i + 1;
    P.resize(N);
    for(ll i = 0;i < N;i++) cin >> P[i];
    Q.resize(N);
    for(ll i = 0;i < N;i++) cin >> Q[i];
    temp = base;
    while(temp != P && next_permutation(temp.begin(), temp.end())) countA++;
    temp = base;
    while(temp != Q && next_permutation(temp.begin(), temp.end())) countB++;
    cout << abs(countA - countB) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        String A = in.next(), B = in.next();
        long a = in.longNext(), b = in.longNext();

        if (in.next().equals(A)) out.printf("%d %d", a - 1, b);
        else out.printf("%d %d", a, b - 1);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

void solve()
{
    lli cnt[10001]={0};

    loopl(i,1,101)
    {
        loopl(j,1,101)
        {
            loopl(k,1,101)
            {
                lli ans=i*i+j*j+k*k+i*j+j*k+k*i;

                if(ans < 10001) cnt[ans]++;
            }
        }
    }

    lli n;
    cin>>n;

    loopl(i,1,n+1) cout<<cnt[i]<<endl;
    
}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3692
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        
        while( str != null){
        String[] strs = str.split("\\s");
        int H = Integer.parseInt(strs[0]);
        int W = Integer.parseInt(strs[1]);

        //parts
        StringBuilder kisu = new StringBuilder();
        StringBuilder gusu = new StringBuilder();
        
        if( H == 0 || W == 0){
            break;
        }else{    
            for(int i =0;i<W;i++){
                if(i == 0 || i % 2 ==0){
                    kisu.append("#");
                    gusu.append(".");
                }else{
                    kisu.append(".");
                    gusu.append("#");                           
                }
            }

            String kg = kisu.toString();
            String gg = gusu.toString();
            
            for(int i=0;i<H;i++){
                if(i==0 || i % 2 ==0){
                    System.out.println(kg);
                }else{
                    System.out.println(gg);
                }
            }

            System.out.println("");
            str = br.readLine();
            }
        }
        br.close();
    }

    
}

Measured memory_bytes: 25644
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
Ad = [0] * N
tmp = 0

for i in range(N):
	tmp = A[i]
	while True:
		if tmp % 2 == 0:
			Ad[i] += 1
			tmp = tmp / 2
		else:
			tmp = 0
			break
print(min(Ad))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	if(n==1) n=100;	if(m==1) m=100;
	if(n==m) cout<<"Draw"<<endl;
	else if(n>m) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
 
if n == 0:
    print(1 if a[0] == 1 else -1)
    exit()

if a[0] != 0:
    print(-1)
    exit()
 
ans = 1
sm = sum(a)
limit = 1
for i in range(1, n):
    ans += a[i]
    limit = 2*limit - a[i]
    if limit <= 0:
        print(-1)
        exit()
    else:
        sm -= a[i]
        if limit <= sm:
            ans += limit
        else:
            ans += sm

if 2*limit < a[-1]:
    print(-1)
    exit()

ans += a[-1]
 
print(ans)


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

using namespace std;
int N, W;
const int MAX_N = 100, MAX_W = 10000;
int v[MAX_N],w[MAX_N];
int dp[MAX_N + 1][MAX_W + 1]; //dp????????????

void solve() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
}

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	solve();
	return 0;
}

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

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

const int MOD = 1000000007; // 998244353
const ll INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 40;

vector<pll> vt;
vector<ll> vt2;
int N;
ll T;
ll mn[MAX_N+1];

bool sf(pll x, pll y){
	return (x.first)*(y.second+1LL) > (y.first)*(x.second+1LL);
}


int main(){
	scanf("%d%lld", &N, &T);
	for(int i=1; i<=N; i++){
		ll a, b; scanf("%lld%lld", &a, &b);
		if(a!=0)	vt.pb({a, b});
		else	vt2.pb(b);
	}
	sort(vt.begin(), vt.end(), sf);
	sort(vt2.begin(), vt2.end());
	if(!vt2.empty())	vt2[0]++;
	for(int i=1; i<vt2.size(); i++){
		vt2[i]+=vt2[i-1]+1LL;
	}
	for(int i=1; i<=MAX_N; i++){
		mn[i] = INF;
	}
	for(int i=0; i<vt.size(); i++){
		for(int j=MAX_N-1; j>=0; j--){
			if(mn[j]==INF)	continue;
			ll nt = mn[j]+1LL+(mn[j]+1LL)*vt[i].first + vt[i].second;
			//cout<<i<<" "<<j<<" "<<nt<<endl;
			if(nt<=T){
				mn[j+1] = min(mn[j+1], nt);
			}
		}
	}
	int ans = 0;
	for(int i=0; i<=MAX_N; i++){
		//cout<<i<<endl;
		if(mn[i]<=T){
			ll lft = T-mn[i];
			if(vt2.empty()){
				ans = max(ans, i);
				continue;
			}
			int idx = (int)(upper_bound(vt2.begin(), vt2.end(), lft) - vt2.begin());
			ans = max(ans, idx+i);
		}
	}
	printf("%d", ans);
	return 0;
}


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

int main(){
  int a, b,c, count=0;
  cin>>a>>b;
  c=b;
  if(b==1){
    cout<<0<<endl;
    exit(0);
  }
  for(int i=0;i<1000;i++){
    if(c-a<=0){
      count++;
      break;
    }
    c-=(a-1);
    count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 99999999.
       01 B PIC 99999999.
       01 C PIC 99999999.
       01 temp1 PIC 999999.
       01 temp2 PIC 999999.
       01 temp3 PIC 999999.
       01 temp4 PIC 999999.
       01 N PIC 999999.
       01 S PIC 999999.
       01 T PIC 999999.
       01 NOW1 PIC 999999.
       01 NOW2 PIC 999999.
       01 NOW3 PIC 999999.
       PROCEDURE DIVISION.
       MAIN.
        ACCEPT S.
        PERFORM VARYING T FROM 1 BY 1 UNTIL T > S
            ACCEPT INP
            PERFORM VARYING temp1 FROM 1 
                BY 1 UNTIL INP(temp1:1)=SPACE
            END-PERFORM
            SUBTRACT 1 FROM temp1
            MOVE INP(1:temp1) TO A
            ADD 2 TO temp1
            PERFORM VARYING temp2 FROM temp1 
                BY 1 UNTIL INP(temp2:1)=SPACE
            END-PERFORM
            COMPUTE N=temp2 - temp1
            MOVE INP(temp1:N) TO B
            ADD 1 TO temp2
            PERFORM VARYING temp1 FROM temp2 
                BY 1 UNTIL INP(temp1:1)=SPACE
            END-PERFORM
            COMPUTE N=temp1 - temp2
            MOVE INP(temp2:N) TO C
            COMPUTE temp1 = A - NOW1
            COMPUTE temp2 = B - NOW2
            COMPUTE temp3 = C - NOW3
            COMPUTE temp2 = temp2 + temp3
            IF temp1 < temp2 THEN
                DISPLAY "No"
                STOP RUN
            END-IF
            COMPUTE temp2 = temp1 / 2
            COMPUTE temp1 = temp1 - temp2 * 2
            COMPUTE temp2 = B - NOW2
            COMPUTE temp3 = temp2 / 2 
            COMPUTE temp2 = temp2 - temp3 * 2
            COMPUTE temp3 = C - NOW3
            COMPUTE temp4 = temp3 / 2
            COMPUTE temp3 = temp3 - temp4 * 2
            COMPUTE temp2 = temp2 + temp3
            COMPUTE temp2 = temp2 - 2
            IF temp2 = 2 THEN
                MOVE 0 TO temp2
            END-if
            IF temp1 NOT = temp2 THEN
                DISPLAY "No"
                STOP RUN
            END-IF
            MOVE A TO NOW1
            MOVE B TO NOW2
            MOVE C TO NOW3
        END-PERFORM.
        DISPLAY "Yes"
        STOP RUN.



Measured memory_bytes: 384
N=int(input())
def x(N):
    lis= []
    for i in range(N):
        lis.append([])
    return lis
W=x(N)
W[0]=input()
flag=1
a=list(W[0])
start=a.pop()
def panduan():
    for i in range(1,N):
        W[i]=input()
        global flag
        for each in range(i):
            if W[i]==W[each]:
                flag=0
        a=list(W[i])
        start=a.pop(0)
        if flag!=0 and W[i-1].endswith(start):
            flag=1
        else:
            flag=0
panduan()
if flag==1:
    print('Yes')
else:
    print('No')

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

double length(lli x1,lli y1,lli x2,lli y2){
    lli diffX = x1-x2;
    lli diffY = y1-y2;
    return sqrt(diffX*diffX + diffY*diffY);
}

void func(long long N, std::vector<long long> x, std::vector<long long> y){

    vector<lli> per;
    REP(i,0,N)per.push_back(i);

    double ans=0;
    lli cnt=0;
    do{
        REP(i,0,N-1)ans += length(x[per[i]],y[per[i]],x[per[i+1]],y[per[i+1]]);
        cnt++;
        LOG2(ans,cnt);
    }while(next_permutation(per.begin(),per.end()));

    cout<<setprecision(15);
    cout<<(ans/(double)cnt)<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    func(N, std::move(x), std::move(y));
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),K=sc.nextInt();
		int[] array = new int[N];
		int sum=0;
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}

		Arrays.parallelSort(array);
		for(int i=N-1;i>=N-K;i--) {
			sum += array[i];
		}
		System.out.println(sum);
	}
	public static int sample() {
		return 1;
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  cin>>s1;
  cin>>s2;
  int l;
  l=s2.size();
  char c;
  c=s2[l-1];
  s1=s1+c;
  if(s1==s2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    double N; cin >> N;
    for (int i = 1; i <= 500000; ++i) {
        int x = i * 1.08;
        if (N == x) {
            printf("%d\n", i); return 0;
        }
    }
    printf("%s\n", ":(");
    return 0;
}


Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

 
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
	    int n=Integer.parseInt(reader.readLine());
	    int result=0;
	    
		result=n/25;
		n=n%25;
		result+=n/10;
		n=n%10;
		result+=n/5;
		n=n%5;
	    
		
	    System.out.println(result+n);
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    static int gcd (int a, int b){
	return b>0?gcd(b,a%b):a;
    }
    static int lcm (int a, int b) {
	return a*b/gcd(a,b);
    }
}


Measured memory_bytes: 24456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string a,b,c; cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 3620
package main

import (
        "fmt"
)

func solution(n, m int, matrix [][]int) int {
        var ans int = 1000
        for i := 0; i < 1000; i++ {
                s := fmt.Sprint(i)
                if n != len(s) {
                        continue
                }
                if m == 0 {
                        ans = min(ans, i)
                        continue
                }
                if isCond(s, matrix) {
                        ans = min(ans, i)
                }
        }
        if ans == 1000 {
                return -1
        }
        return ans
}
func isCond(str string, matrix [][]int) bool {
        for i := range matrix {
                s := matrix[i][0]
                c := matrix[i][1]
                if int(str[s-1])-48 != c {
                        return false
                }
        }
        return true
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        matrix := make([][]int, m)

        for i := 0; i < m; i++ {
                var s, c int
                fmt.Scan(&s, &c)
                matrix[i] = []int{s, c}
        }
        fmt.Println(solution(n, m, matrix))
}

Measured memory_bytes: 512
H,W=map(int,input().split())
S = [ input() for _ in range(H) ]
for h in range(H):
  l = ''
  for w in range(W):
    if S[h][w] == '#':
      l += '#'
    else:
      x = 0
      for dh in [ -1, 0, 1]:
        for dw in [-1, 0, 1]:
          if 0 <= h + dh < H and 0 <= w + dw < W and S[h+dh][w+dw] == '#':
            x += 1
      l += str(x)
  print(l)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<cstring>
#define eps 1e-8
#define pi acos(-1)
#define mp make_pair
#define PH push
#define pb push_back
#define PII pair<ll,ll>
#define VI vector<int>
#define fi first
#define se second
#define N(a,b) a=N(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define all(n) n.begin(),n.end()
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
#define prn(x) printf("%d\n",x)
typedef long long ll;
typedef unsigned long long ull;
ll expow(ll a,ll b,ll p) {ll v=1; for (; b; b>>=1,a=a*a%p)if (b&1)v=v*a%p; return v;}
ll inv(ll a,ll p) {return expow(a,p-2,p);}
using namespace std;
const int N=1000+10;
int a[N];
int main(){
    a[1]=1;
    for(int j=2;j<=1000;j++){
        int cnt=j*j;
        while(cnt<=1000){
            a[cnt]=1;
            cnt*=j;
        }
    }
    int n;
    cin>>n;
    while(a[n]==0) n--;
    printf("%d\n",n);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    val a, b = sc.nextInt()
    if (a > 9 || b > 9) {
      pw.println(-1)
    } else {
      pw.println(a * b)
    }

    pw.flush()
  }
}

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

int par[10000], d[10000];

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

int main()
{
	int n, q;

	cin >> n >> q;

	for (int i = 0; i < n; i++) {
		par[i] = i;
		d[i] = 1;
	}

	for (int i = 0; i < q; i++) {
		int k, x, y;
		cin >> k >> x >> y;

		if (k == 0) {
			x = find(x);
			y = find(y);
			if (d[x] > d[y])
				par[y] = x;
			else if (d[x] < d[y])
				par[x] = y;
			else {
				par[y] = x;
				d[x]++;
			}
		}
		else if (k == 1) {
			if (find(x) == find(y))
				cout << 1 << endl;
			else
				cout << 0 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b;
	cin >> a >> b;
	if ((a == 0 || b == 0) || (a > 0 && b < 0) || (a < 0 && b > 0))
	{
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0)
	{
		cout << "Positive" << endl;
	}
	else
	{
		cout << (abs(a-b)%2==0?"Negative":"Positive") << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  if(k==1){
    cout<<0;
  }
  else{
    cout<<n-k;
  }
  return(0);
}


Measured memory_bytes: 256
a,b,k = map(int, input().split(" "))

def solv():
    global a, b, k
    n = min(a,b)
    for i in range(n, 0, -1):
        if a%i == 0 and b%i == 0:
            k -= 1
            if k == 0:
                return i

r = solv()
print(r)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
int H ,W ,D , A ;
int Q ,L , R ;
int px [90001] , py [90001];
int d [90001];
int main ()
{
scanf ("%d %d %d" ,&H ,&W ,&D );
for ( int i =0; i < H ; i ++)
{
for ( int j =0; j < W ; j ++)
{
scanf ("%d" ,&A );
px [ A ]= i , py [ A ]= j ;
}
}
for ( int i = D +1; i <= H * W ; i ++)
d[ i ]= d [i - D ]+ abs ( px [ i ] - px [i - D ])+ abs ( py [ i ] - py [i - D ]);
scanf ("%d" ,&Q );
while (Q--)
{
scanf ("%d %d " ,&L ,&R );
printf ("%d\n " , d [ R ] - d [ L ]);
}
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int xdif = tx - sx;
    int ydif = ty - sy;
    char lf1, lf2;
    char ud1, ud2;
    if (xdif >= 0) {
        lf1 = 'R';
        lf2 = 'L';
    } else {
        xdif = abs(xdif);
        lf1 = 'L';
        lf2 = 'R';
    }
    if (ydif >= 0) {
        ud1 = 'U';
        ud2 = 'D';
    } else {
        ydif = abs(ydif);
        ud1 = 'D';
        ud2 = 'U';
    }
    REP(i, xdif) { cout << lf1; }
    REP(i, ydif) { cout << ud1; }
    REP(i, xdif) { cout << lf2; }
    REP(i, ydif) { cout << ud2; }
    cout << ud2;
    REP(i, xdif + 1) { cout << lf1; }
    REP(i, ydif + 1) { cout << ud1; }
    cout << lf2;
    cout << ud1;
    REP(i, xdif + 1) { cout << lf2; }
    REP(i, ydif + 1) { cout << ud2; }
    cout << lf1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main()
{
  int N, M;
  cin >> N >> M;
  priority_queue<P, vector<P>, greater<P>> pq;
  priority_queue<P> usable;
  for (int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    pq.emplace(a, b);
  }
  int64_t ans = 0;
  for (int d = M - 1; d >= 0; d--)
  {
    while (pq.size() && pq.top().first + d <= M)
    {
      usable.emplace(pq.top().second, pq.top().first);
      pq.pop();
    }
    if (usable.size())
    {
      ans += usable.top().first;
      usable.pop();
    }
  }
  cout << ans << endl;
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int a, b;
    cin >> a >> b;
    if (a > 0)
    {
        cout << "Positive" << endl;
        return 0;
    }

    if (b >= 0)
    {
        cout << "Zero" << endl;
        return 0;
    }

    if ((b - a) & 1)
    {
        cout << "Positive" << endl;
    }
    else
    {
        cout << "Negative" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
def main():
    r = []
    for _ in range(int(input())):
        r.append(int(input()))

    n = len(r)
    maxv = -20000000000
    minv = r[0]

    for i in range(1, n):
        maxv = max([maxv, r[i] - minv])
        minv = min([minv, r[i]])
    
    print(maxv)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13592
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ (n - k + 2) * (n * n + n + 6 - 2 * k * k + k * (n + 2)) `div` 6 `mod` modulus

modulus :: Int
modulus = 1000000007

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 3780
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        final int N = in.i();
        long D = in.l();
        D *= D;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            long x = in.l();
            long y = in.l();
            long d = x * x + y * y;
            if (d <= D) {
                ans++;
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader(){
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = super.read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 35744
A,B,C=map(int,input().split())
M=[A,B,C]
M.sort()
kaisuu1=M[2]-M[1]
M[0]+=kaisuu1
M[1]+=kaisuu1
nokori=M[1]-M[0]
q,r=divmod(nokori,2)
sum_kaisuu=kaisuu1+q
if r==1:
    sum_kaisuu+=2
print(sum_kaisuu)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define trace(x)    cerr<<#x<<" : "<<x<<endl;
#define trace2(x,y) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl;
#define trace3(x,y,z) cerr<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl;
#define fast_io 	std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;
int solve(string s,int n)
{
	int val=0;
	unordered_map<char,int> m1,m2;
	for(int i=0;i<n;i++){
		m1[s[i]]=1;
	}
	for(int i=n;i<s.length();i++)
	{
		if(m1[s[i]]){val++;m1[s[i]]=0;}
	}
	return val;
}

int main()
{
	fast_io;
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=1;i<n-1;i++)
	{
		ans=max(ans,solve(s,i));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint w(n);
    rep(i, n) cin >> w[i];
    vint imos(n+1);
    rep(i, n) imos[i+1] = w[i];
    rep(i, n) imos[i+1] += imos[i];
    int ans = 1<<29;
    rep(mid, n+1) {
        int sum1 = imos[mid];
        int sum2 = imos.back() - imos[mid];
        chmin(ans, abs(sum1 - sum2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# 整理番号を入力する
num = input()
# 整理番号の各桁の値を取り出す
A, B, C, D = [int(num[i]) for i in range(4)]
# 演算子のリストを作成する
list_op = ["+", "-"]
# 等式のリストを初期化する
list_equation = []
# op1
for i in range(2):
    # op2
    for j in range(2):
        # op3
        for k in range(2):
            # 計算する
            ans = A + (-1)**i * B + (-1)**j * C + (-1)**k * D
            # 計算結果が7になった場合
            if ans == 7:
                # 等式の文字列を作成する
                equation = str(A) + list_op[i] + str(B) + list_op[j] + str(C) + list_op[k] + str(D) + "=7"
                # 等式のリストに格納する
                list_equation.append(equation)
# 等式のリストの先頭の要素を出力する                
print(list_equation[0])

Measured memory_bytes: 3064
char s[];D(a,b,t){scanf("%d%d",&a,&b);--*s&&D();t=s[a];s[a]=(s[b]+7+b-a)%26+97;s[b]=(t+7+b-a)%26+97;}main(){for(;scanf("%d%s",s,s+1)**s;puts(s+1))D();}

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

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

const int N = 1002;
const ll INF = 1000000000000, mod = 7 + 1e9;

char a[N][N];
int n, m;
ll dp[N][N];

ll ways(int p, int q){
  if(p == n - 1 and q == m - 1) return 1;
  if(p == n || q == m) return 0;
  if(a[p][q] == '#') return 0;
  if(dp[p][q] != -1) return dp[p][q];
  return dp[p][q] = (ways(p + 1, q) + ways(p, q + 1)) % mod;
}

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

  cin >> n >> m;
  for(int i = 0; i < n; i++) cin >> a[i];
  memset(dp, -1, sizeof dp);
  cout << (ways(0, 0) < 0 ? ways(0, 0) + mod : ways(0, 0))<< endl;
}


Measured memory_bytes: 9216
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	// I-1
	// V-5
	// X-10
	// L-50
	// C-100
	// D-500
	// M-100
	// Iツづ個古」V,X
	// Xツづ個古」L,C

	void run(){
		for(; sc.hasNext();){
			String s=sc.next();
			int ans=0;
			for(int i=0; i<s.length(); i++){
				if(s.charAt(i)=='I'){
					if(i<s.length()-1&&s.charAt(i+1)=='V'){
						ans+=4;
						i++;
					}else if(i<s.length()-1&&s.charAt(i+1)=='X'){
						ans+=9;
						i++;
					}else{
						ans+=1;
					}
				}else if(s.charAt(i)=='V'){
					ans+=5;
				}else if(s.charAt(i)=='X'){
					if(i<s.length()-1&&s.charAt(i+1)=='L'){
						ans+=40;
						i++;
					}else if(i<s.length()-1&&s.charAt(i+1)=='C'){
						ans+=90;
						i++;
					}else{
						ans+=10;
					}
				}else if(s.charAt(i)=='L'){
					ans+=50;
				}else if(s.charAt(i)=='C'){
					if(i<s.length()-1&&s.charAt(i+1)=='D'){
						ans+=400;
						i++;
					}else if(i<s.length()-1&&s.charAt(i+1)=='M'){
						ans+=900;
						i++;
					}else{
						ans+=100;
					}
				}else if(s.charAt(i)=='D'){
					ans+=500;
				}else if(s.charAt(i)=='M'){
					ans+=1000;
				}
				// debug(ans);
			}
			// debug();
			println(""+ans);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<long long> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    long long cnt=0, maxi=max(v[0],v[1]);
    for(int i=1; i<n; i++){
        maxi = (v[i]>maxi) ? v[i] : maxi;
        if(v[i] >= v[i-1]) continue;
        else {
            cnt += (maxi-v[i]);
//            cout << cnt <<endl;
            v[i] = maxi;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> left(N + 1, 0), right(N + 1, 0);
  for (int i = 0; i < N; i++) {
    left[i + 1] = gcd(left[i], A[i]);
  }
  for (int i = N - 1; i >= 0; i--) {
    right[i] = gcd(right[i + 1], A[i]);
  }
  int res = 1;
  for (int i = 0; i < N; i++) {
    res = max(res, gcd(left[i], right[i + 1]));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1408
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????

            int[] a = new int[4];
       	 	int[] b = new int[4];
       	 	int count =0;
             String line; // ??\???????????????????????\???
             while ((line = br.readLine()) != null) {
            	 
            	 String[] astr = line.split(" ",0);
            	 String[] bstr = line.split(" ",0);
            	 if(count==0){
            		 count++;
            		 for(int i = 0; i < 4; i++){
                		 a[i] = Integer.parseInt(astr[i]);
                	 };  
            	 }else{
            		 count=0;
            		 for(int i = 0; i < 4; i++){
                		 b[i] = Integer.parseInt(bstr[i]);
                	 };  
                	 hitBlow(a,b);
            	 }            	
             }  
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void hitBlow(int[] a, int[] b) {
    	int hit = 0;
    	int blow = 0;
    	
    	for(int i=0; i<a.length; i++){
    		if(a[i]==b[i]){
    			hit++;
    		}
    	}
    	for(int i=0;i<a.length; i++){
    		for(int j=0; j<b.length; j++){
    			if(a[i]==b[j]){
    				blow++;
    			}
    		}
    	}	
    	blow = blow - hit;
		System.out.println(hit+" "+blow);
     }
}

Measured memory_bytes: 24024
//Atcoder
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        for(int i=0;i<10;i++) {
            int a = r * x - D;
            x = a;
            pw.println(a);
        }

        pw.close();
    }
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ - = + **/


typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
                 tree_order_statistics_node_update>
        new_data_set;

int a[10000001];
void sieve()
{
    a[0]=a[1]=1;
    //a[2]=1;
    for(int i=2;i<=10000000;i++){
        if(a[i])continue;
        for(int j=i*2;j<=10000000;j+=i)
        {
            a[j]=1;
        }
    }
    int co=0;
    for(int i=0;i<=10000000;i++)
    {
        int temp=0;
        if(!a[i])temp=1;
        a[i]=co;
        co+=temp;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    if(str=="SUN")cout<<7<<endl;
    if(str=="MON")cout<<6<<endl;
    if(str=="TUE")cout<<5;
    if(str=="WED")cout<<4;
    if(str=="THU")cout<<3;
    if(str=="FRI")cout<<2;
    if(str=="SAT")cout<<1;
}


Measured memory_bytes: 256