akhauriyash/Code-Regression huggingface dataset:
import Data.Char
main = do
  w <- getLine
  t <- getContents
  print $ f1 w (map f2 (words t))
  
f1 w t_w | head t_w == "END_OF_TEXT" = 0
         | (map toLower $ head t_w) == w = 1 + (f1 w (tail t_w))
         | otherwise = f1 w (tail t_w)
f2 w = [c |c<-w, elem c $ ['A'..'z']]


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

int main(){
  while(1){
    int n,l;
    cin >> n >> l;
    if(n==0) break;

    vector<int> dir(n), pos(n);
    int step=0;
    for(int i=0; i<n; i++){
      char d;
      int p;
      cin >> d >> p;
      if(d=='L'){
        dir[i] = -1;
        step = max(step, p);
      }else{
        dir[i] = 1;
        step = max(step, l-p);
      }
      pos[i] = p*2;
    }

    for(int i=0; i<step*2; i++){
      for(int j=0; j<n; j++){
        pos[j] += dir[j];
      }
      for(int j=0; j<n; j++){
        for(int k=j+1; k<n; k++){
          if(i%2==1 && pos[j]==pos[k]){
            dir[j] = -dir[j];
            dir[k] = -dir[k];
          }
        }
      }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
      if(pos[i] == l*2) ans = i;
    }
    for(int i=0; i<n; i++){
      if(pos[i] == 0) ans = i;
    }
    cout << step << " " << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
int main(void){
	int n,m;
	int i;
	V v;
	cin>>n>>m;
	for(i=m-(n-1);i<=m+(n-1);i++)	v.push_back(i);
	for(i=0;i<(int)v.size();i++){
		if(i)	cout<<" ";
		cout<<v[i];
	}
	cout<<endl;
	return 0;
}

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

int main(void){

    long long N,ax,ay,ah,idx=0;
    cin >> N;
    vector<long long> x(N),y(N),h(N);

    for(int i=0;i<N;++i){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]!=0){
            idx=i;
        }
    }
  //cout<<"idx="<<idx<<endl;
    for(ax=0;ax<=100;++ax){
        for(ay=0;ay<=100;++ay){
            ah = h[idx] + abs(ax-x[idx])+abs(ay-y[idx]);
            int i;
            for(i=0;i<N;++i){
                if(h[i] != max(ah - abs(ax-x[i])-abs(ay-y[i]),0LL) ){
                    break;
                }
            }
            if(i==N && ah > 0){
                cout << ax << " " << ay << " " << ah;
                return 0;
            }
        }
    }


    return 0;
}


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

const int maxn = 1e4 + 5;
long long sum;
int num[maxn];

int main(){
	long long n,m; cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> num[i];
		sum += num[i];
	}
	
	if(n - sum < 0) cout << -1 << endl;
	else cout << n - sum << endl;


}


Measured memory_bytes: 3672
from scipy.sparse.csgraph import dijkstra as di

inf = float('INF')
n,m,l = map(int,input().split())

route = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b,c = map(int, input().split())
    route[a-1][b-1] = route[b-1][a-1] = c

p_route = di(route)
p_route[p_route == 0] = inf
p_route[l >= p_route] = 1
p_route[l < p_route] = 0
p_route = di(p_route)

# print(p_route)
query = []
q = int(input())
ans = []
for _ in range(q):
    s,t = map(int, input().split())
    print(-1 if p_route[s-1][t-1] == inf else int(p_route[s-1][t-1]) - 1)


Measured memory_bytes: 19488
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int count=0;
  for(int i=0;i<n;i++){
    count+=(s[i]=='R');
  }
  cout<<(n/2<count?"Yes":"No")<<endl;
}


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

const int MAX = 200001;
int main() {
	static int N, A[MAX];
	cin >> N;
	A[0] = 0;
	for (int i = 1;i <= N;++ i) cin >> A[i];
	int ans = 0, max = N, mid, halfDiff, tmp;
	while(halfDiff = max - ans >> 1) { // 二分探索、O(logN)
		bool check = true;
		mid = ans + halfDiff; // 今回挑戦する文字数
		stack<pair<int, int> > stk;
		for (int j = 1;j <= N;++ j) { // シミュレーション、O(N)
			if (A[j - 1] < A[j]) { // 文字数が増えるパターン、これは簡単
				stk.push(make_pair(A[j], 1));
			} else { // 文字数が減るパターン
				while (!stk.empty() && stk.top().first > A[j]) stk.pop();
				if (stk.empty() || stk.top().first < A[j]) stk.push(make_pair(A[j], 1)); // aaa…の為に保存されてないっぽいのでbを入れておく
				while (++ stk.top().second > mid) {
					tmp = stk.top().first;
					if (tmp == 1) {
						check = false;
						goto break_label;
					}
					stk.pop();
					if (stk.empty() || stk.top().first != tmp - 1) stk.push(make_pair(mid == 1 ? 1 : tmp - 1, 1));
				}
			}
		}
		break_label:;
		cerr << mid << ":" << (check ? "true" : "false") << endl;
		(check ? max : ans) = mid;
	}
	cout << max;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

文字数が増えるのは簡単で、aaaaと増やしていけば良い
減らすときは？
前の文字列のほとんどをコピーし、最後の文字だけ1個インクリメントでいけそう
例えば
2: aa (2, a)
3: aaa (2, a) (3, a)
2: ab (2, b)
1: b (1, b)
2: ba (1, b) (2, a)

みたいな
*/

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

static long long N, A[200000];
map<long long, long long> mp;

bool check(long long X) {
	mp.clear();
	for (int i = 1; i < N; i++) {
		if (A[i - 1] >= A[i]) {
			auto it = mp.upper_bound(A[i]);
			mp.erase(it, mp.end());
			mp[A[i]]++;
			long long NOW = A[i];
			while (mp[NOW] == X) {
				mp.erase(NOW);
				NOW--;
				if (NOW == 0) return false;
				mp[NOW]++;
			}
		}
	}
	return true;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	bool check1 = true;
	for (int i = 0; i < N - 1; i++) {
		if (A[i + 1] <= A[i]) check1 = false;
	}
	if (check1) {
		cout << 1 << endl;
		return 0;
	}
	long long L = 1, R = N + 1;
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		check(MID) ? R = MID : L = MID;
	}
	cout << R << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
bridge = [ list(map(int, input().split())) for _ in range(M)]

bridge.sort(key=lambda x:x[1])

cuts = [bridge[0][1]]
for b in bridge[1:]:
    cut = cuts[-1]
    if b[0]< cut <= b[1]:
        continue
    cuts.append(b[1])

# print(cuts)
print(len(cuts))

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

using namespace std;

typedef long double D;

const int N = 307;

D dp[N][N][N];
bool w[N][N][N];
int n, x, y, z;

D calc(int a, int b, int c)
{
    if(a == 0 && b == 0 && c == 0)
        return 0;
    if(w[a][b][c])
        return dp[a][b][c];
    w[a][b][c] = true;

    D ansa = 0, ansb = 0, ansc = 0;
    if(a > 0)
        ansa = (D)a/(D)(a+b+c)*calc(a-1, b, c);
    if(b > 0)
        ansb = (D)b/(D)(a+b+c)*calc(a+1, b-1, c);
    if(c > 0)
        ansc = (D)c/(D)(a+b+c)*calc(a, b+1, c-1);

    dp[a][b][c] = (D)n/(D)(a+b+c) + ansa + ansb + ansc;

    return dp[a][b][c];
}

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

    cin >> n;
    int a = 0, b = 0, c = 0;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        if(x == 1) a++;
        if(x == 2) b++;
        if(x == 3) c++;
    }

    cout << setprecision(10) << fixed << calc(a, b, c);

    return 0;
}


Measured memory_bytes: 471424
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        for(int &it : a){
            cin >> it;
        }
        int ans = 0, len = 1;
        for(int i = 0; i + 1 < n; i++){
            if(a[i] < a[i + 1]){
                ans = max(ans, len - 1);
                len = 1;
            }else{
                len++;
            }
        }
        ans = max(ans, len - 1);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 32256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, ll>;

struct Edge{
	int to;
	ll a, b;
	Edge(int to, ll a, ll b) : to(to), a(a), b(b){}
};

vector<vector<Edge>> g;
int n, m, s, t;

vector<ll> dijkstra(int start, int flg){
	vector<ll> dist(n, LINF);
  priority_queue<P, vector<P>, greater<P>> que;
  dist[start] = 0;
  que.push({dist[start], start});

  while(!que.empty()){
  	auto v = que.top();
  	que.pop();
    int from = v.second;

  	for(auto nv : g[from]){
  		int cost = (flg ? nv.a : nv.b);
  		if(dist[from] + cost < dist[nv.to]){
  			dist[nv.to] = dist[from] + cost;
        que.push({dist[nv.to], nv.to});
  		}
  	}
  }
  return dist;
}

int main(){
  cin >> n >> m >> s >> t;
  --s;
  --t;
  g.resize(n);
  for(int i = 0; i < m; ++i){
  	int u, v;
  	ll a, b;
  	cin >> u >> v >> a >> b;
  	--u;
  	--v;
  	g[u].push_back(Edge(v, a, b));
  	g[v].push_back(Edge(u, a, b));
  }

  vector<ll> dist_s = dijkstra(s, 1);
  vector<ll> dist_t = dijkstra(t, 0);
  vector<ll> ans(n + 1, LINF); // 
  for(int i = n - 1; i >= 0; --i){
  	ans[i] = min(ans[i + 1], dist_s[i] + dist_t[i]);
  }

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


Measured memory_bytes: 13944
#include<stdio.h>
#include<string.h>

int main(void){
	char input[1024];
	int n,i;

	fgets(input,sizeof(input),stdin);
	n=strlen(input);

	for(i=0;i<n;i++){
		if(input[i]<'a' || input[i]>'z'){
			printf("%c",input[i]);
			continue;
		}
		printf("%c",input[i]-32);
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>

int main(){
    int n,i;
    int a,b,c;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&a, &b,&c);
        if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b)
            printf("YES\n");
        else
            printf("NO\n");
    }

	
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    string S;cin >> S;
    int y = 0, m = 0, d = 0;
    rep(i,4){
        y += S[i]-'0';
        y*=10;
    }
    y/=10;
    for(int i=5;i<=6;i++){
        m += S[i]-'0';
        m *= 10;
    }
    for(int i=8;i<=9;i++){
        d += S[i] - '0';
        d *= 10;
    }
    d /= 10;
    m /=10;

    if(y < 2019)cout << "Heisei" << endl;
    else if(y == 2019 && m < 4)cout << "Heisei" << endl;
    else if(y==2019 && m == 4 && d <= 30)cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep01(i, n) for(int i = 0; i < (n) + 1; i++)
#define rep10(i, n) for(int i = 1; i < (n); i++)
#define rep11(i, n) for(int i = 1; i < (n) + 1; i++)
#define all(a) (a).begin(), (a).end()
typedef long long int ll;
typedef struct { int x; int y; } Pos;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    rep10(i, N) {
        if (A[i] < A[i - 1]) {
            sum += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4852
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

int main()
{
	int length,breadth;
	int area, line;
	length = 0 , breadth = 0;
	area = 0, line = 0;

	scanf("%d %d", &length, &breadth);
	if (length >= 1 && breadth <= 100) {
		area = length * breadth;
		line = (length * 2) + (breadth * 2);

		printf("%d %d\n", area, line);
	}

	return 0;
}


Measured memory_bytes: 2076
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        
        int ans = x-a;
        if(ans<1){
          System.out.print("0");
        }else{
           System.out.print(ans);
        }
      
		
      
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		
		String strs[] = sc.nextLine().split(" ");
		int maxLength = 0;
		int indexL = 0;
		int maxFrequency = 0;
		int indexF = 0;
		
		for (int i = 0; i < strs.length; i++)
		{
			if (maxLength < strs[i].length())
			{
				indexL = i;
				maxLength = strs[i].length();
			}
			int count = 0;
			for (int j = i; j < strs.length; j++)
			{
				if (strs[i].equals(strs[j]))
				{
					count++;
				}
			}
			if (maxFrequency < count)
			{
				indexF = i;
				maxFrequency = count;
			}
		}
		System.out.println(strs[indexF] + " " + strs[indexL]);
	}
}

Measured memory_bytes: 12000
from sys import stdin
n = int(stdin.readline().rstrip())

a = []
while n // 26 >= 1:
    if n%26 == 0:
        a.insert(0, 26)
        n = (n - 26) // 26
    else:
        a.insert(0, n%26)
        n = (n - n%26) // 26
if n > 0:
    a.insert(0, n)

i = 1
while i <= len(a):
    t = a[i-1]
    if t == 1:
        a[i-1] = "a"
    elif t == 2:
        a[i-1] = "b"
    elif t == 3:
        a[i-1] = "c"
    elif t == 4:
        a[i-1] = "d"
    elif t == 5:
        a[i-1] = "e"
    elif t == 6:
        a[i-1] = "f"
    elif t == 7:
        a[i-1] = "g"
    elif t == 8:
        a[i-1] = "h"
    elif t == 9:
        a[i-1] = "i"
    elif t == 10:
        a[i-1] = "j"
    elif t == 11:
        a[i-1] = "k"
    elif t == 12:
        a[i-1] = "l"
    elif t == 13:
        a[i-1] = "m"
    elif t == 14:
        a[i-1] = "n"
    elif t == 15:
        a[i-1] = "o"
    elif t == 16:
        a[i-1] = "p"
    elif t == 17:
        a[i-1] = "q"
    elif t == 18:
        a[i-1] = "r"
    elif t == 19:
        a[i-1] = "s"
    elif t == 20:
        a[i-1] = "t"
    elif t == 21:
        a[i-1] = "u"
    elif t == 22:
        a[i-1] = "v"
    elif t == 23:
        a[i-1] = "w"
    elif t == 24:
        a[i-1] = "x"
    elif t == 25:
        a[i-1] = "y"
    elif t == 26:
        a[i-1] = "z"
    i += 1

print(''.join(a))

Measured memory_bytes: 9276
using System;

namespace KitaSoftKoubouEnshuuMondai
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                string[] data = Console.ReadLine().Split(' ');
                int H = int.Parse(data[0]), W = int.Parse(data[1]);

                if (H == 0 && W == 0) break;

                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                        Console.Write((i == 0 || i == H - 1 || j == 0 || j == W - 1) ? '#' : '.');
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8836
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> s(m, vector<ll>(0));
  vector<bool> on(n, false);
  REP(i, m)
  {
    ll k;
    cin >> k;
    REP(j, k)
    {
      ll tmp;
      cin >> tmp;
      s[i].push_back(tmp-1);
    }
  }
  vector<ll> p(m);
  REP(i,m){
    cin >> p[i];
  }
  ll res = 0;
  REP(i, pow(2, n))
  {
    bool ho = true;
    REP(j, m)
    {
    ll cnt = 0;
      for (auto hoge : s[j]){
       if ((i >> hoge)%2 == 1) {
         cnt++;
       }
      }
      if (cnt%2 != p[j]) {
        ho = false;
        break;
      }
    }
    if (ho){

    res++;
    }
  }
cout << res << endl;
  return 0;
}


Measured memory_bytes: 512
#include <functional>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
using namespace std;
 
#define pii pair<int, int>
#define rank asdf
#define ll long long
 
const int mod = (int)1e9 + 7;

int n;
ll a[300300];
int cnt[300300][66]; 

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    long long ans = 0;
    for(int i = n; i >= 1; --i){
        for(ll j = 60; j >= 0; --j){
            if(a[i] & (1ll << j)) cnt[i][j] = 1;
            cnt[i][j] += cnt[i + 1][j];
        }
        for(ll j = 60; j >= 0; --j){
            int len = n - i;
            ll x = (1ll << j) % mod;
            if(a[i] & (1ll << j)){
                ans = (ans + x * (len - cnt[i + 1][j])) % mod;
            }else{
                ans = (ans + x * cnt[i + 1][j]) % mod;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 80000
# 後ろの方を減らした方が次に役立つよねってことね(貪欲法)

N, X = map(int, input().split(" "))
a = list(map(int, input().split(" ")))

a += [0]

count = 0
for i in range(N):
    extra = a[i]+a[i+1] - X
    if extra <= 0:
        continue
    count += extra
    if a[i+1] >= extra:
        a[i+1] -= extra
    else:
        a[i] -= extra-a[i+1]
        a[i+1] = 0
    # print(a)
print(count)

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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define int long long
#define ll unsigned long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define inf 1000000000000000000
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
	std::ios::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);

const int Maxn = 100001;
const ld pi = acos(-1);
const int mod = 998244353;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A)
{
	for (auto x : A)
		out << x << " ";
	return out;
}

int32_t main(){IOS
	int Q=1;	//cin>>Q;
	while(Q--){
		int k, curr;	cin>>k;
		k--;
		queue<int> q;
		fr(i,1,10)	q.push(i);
		while(k--){
			curr = q.front();	q.pop();
			if(curr%10 > 0)	q.push(10*curr + (curr%10) - 1);
			q.push(10 * curr + (curr % 10));
			if(curr%10 < 9)		q.push(10*curr + (curr%10) + 1);
		}
		cout << q.front() << '\n';
	} 
	return 0;
}

Measured memory_bytes: 1792
H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]
direction = (-1, 1)
H -= 1
W -= 1
for h, line in enumerate(grid):
    for w, g in enumerate(line):
        if g == '.':
            continue
        pos = ((h - 1, w), (h + 1, w), (h, w - 1), (h, w + 1))
        for y, x in pos:
            if y < 0 or H < y:
                continue
            if x < 0 or W < x:
                continue
            if grid[y][x] == '#':
                break
        else:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MP make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=4e3+10 , oo= 1e9;

int vb[N], vw[N],n,m , f[N][N], val[N];
char ch[N];
int bb[N], ww[N];
template <class T>
void upmin(T &a, T b){ if ( b<a) a=b;}

void ADD(int *C, int x){	for (; x<=2*n; x+=x&-x) C[x]++;}
int SUM(int *C, int x){
	int s=0;
	for (; x; x-=x&-x) s+=C[x];
	return s;
}
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d\n", &n);
	for (int i=1; i<=2*n; i++){
		scanf("%c %d\n", &ch[i], &val[i]);
		if ( ch[i]=='B') vb[ val[i]]= i;
			else vw[ val[i]] = i;
	}
	for (int i=0; i<=n; i++)
		for (int j=0; j<=n; j++) f[i][j] = oo;
	f[0][0] = 0;
	for (int i=0; i<=n; i++){
		for (int j=0; j<=2*n; j++) ww[j] = 0;
		for (int j=0; j<=n; j++){
			int l= i+j,cost;
			if ( i<n){
				cost = vb[i+1]-SUM(bb,vb[i+1])-SUM(ww,vb[i+1])-1;
				upmin(f[i+1][j], f[i][j] + cost);
			}
			if ( j<n){
				cost= vw[j+1]-SUM(bb, vw[j+1])-SUM(ww,vw[j+1])-1;
				upmin(f[i][j+1], f[i][j]+cost);
			}
			if ( j<n)ADD(ww, vw[j+1]);
		}
		
		if ( i<n ) ADD(bb, vb[i+1] );
	}
	printf("%d\n", f[n][n]);
	return 0;
}

Measured memory_bytes: 32512
import java.util.BitSet;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		BitSet p = prime(300000);
		while(true){
			int n = in.nextInt();
			if(n == 0) return;
			System.out.println(p.get(n+1, 2*n+1).cardinality());
		}
	}
	
	public static BitSet prime(int max){
		BitSet p = new BitSet(max);
		p.set(2, max);
		for(int i=p.nextSetBit(0); i!=-1; i=p.nextSetBit(i+1)){
			for(int j=2; j*i<=max; j++){
				p.clear(j*i);
			}
		}
		return p;
	}
}

Measured memory_bytes: 24488
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  cin >>N;
  
  vl a(N);
  vl b(N);
  rep(i,N) {
    cin >>a.at(i)>>b.at(i);
  }
  
  vector<pl> vec(N);
  rep(i,N) {
    vec.at(i).fi=b.at(i);
    vec.at(i).se=a.at(i);
  }
  
  
  
  sort(all(vec));
  
  ll t=0;
  bool ans=true;
  rep(i,N) {
    t+=vec.at(i).se;
    if(t<=vec.at(i).fi) {
      continue;
    }
    else if(t>vec.at(i).fi) {
      ans=false;
      break;
    }
    
    
  }
  
  
  if(ans) {
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
}
  


Measured memory_bytes: 6528
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

def eratosthenes(n):
    is_prime = [True] * n
    is_prime[0] = is_prime[1] = False
    is_prime[4::2] = [False] * (n // 2 - 2)
    m = int(n**.5) + 1
    for i in range(3, m, 2):
        if is_prime[i]:
            is_prime[i*i::2*i] = [False] * ((n - i*i - 1) // (2*i) + 1)
    # return [2] + [i for i in range(3, n, 2) if is_prime[i]]
    return is_prime

# prime = eratosthenes(2*10**6+10)
l = [0] * (10**6+1)
for a in A:
    l[a] += 1
ans = 0
for i in range(10**6+1):
    if l[i] == 1:
        # print(i)
        ans += 1
    if l[i] >= 1:
        for j in range(i, 10**6+1, i):
            l[j] = 0
print(ans)


Measured memory_bytes: 110668
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    writeln((N - 2) * 180);
}


Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<algorithm>
#include<vector>
#include<cstdio>
#define MAX 50001
using namespace std;
struct Query
{
  int A,B,order;
  Query(int A=-1,int B=-1,int order=-1):A(A),B(B),order(order){}
};
int r,c,q;
bool used[2][MAX];

int main()
{
  while(true)
    {
      scanf("%d %d %d",&r,&c,&q);
      if(r+c+q == 0)break;
      for(int i=0;i<r;i++)used[0][i] = false;
      for(int j=0;j<c;j++)used[1][j] = false;
      Query queries[q];
      for(int i=0;i<q;i++)
	scanf("%d %d %d",&queries[q-(i+1)].A,&queries[q-(i+1)].B,&queries[q-(i+1)].order);
	
      int ru,rd,cu,cd,total;
      ru = rd = cu = cd = total = 0;

      for(int i=0;i<q;i++)
	{
	  Query qw = queries[i];
	  if(used[qw.A][qw.B])continue;
	  used[qw.A][qw.B] = true;

	  if(qw.order)
	    {
	      if(!qw.A)
		{
		  total += c - (ru+rd);
		  cu++;
		}
	      else 
		{
		  total += r - (cu+cd);
		  ru++;
		}
	    }
	  else
	    {
	      if(!qw.A)
		  cd++;
	      else 
		  rd++;
	    }
	}
      cout << total << endl;
    }
  return 0;
}

Measured memory_bytes: 1888
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll ma = 1e11, n, d, i;
    cin >> n >> d;
    set <ll> s;
    i = 0;
    while(1)
    {
        ll val = pow(i, 2);
        if(val >= ma)
            break;
        i++;
        s.insert(val);
    }
    ll a[n][d];
    for(i = 0; i < n; i++)
    {
        for(ll j = 0; j < d; j++)
            cin >> a[i][j];
    }
    ll ans = 0;
    for(i = 0; i < n; i++)
    {
        for(ll j = i + 1; j < n; j++)
        {
            ll sum = 0;
            for(ll k = 0; k < d; k++)
                sum += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
            if(d == 1 || s.find(sum) != s.end())
                ans++;
            // cout << sum << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15104
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    setp(20);
    ll n=in();
    cout<<((n+1)/2)/(double)n<<endl;
}


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

#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         ll          long long
#define         ST          stack
#define         V           vector
#define         Q           queue
#define         S           set
#define         M           map

using namespace std;

///ISNNJB
int ara[100010];

int main()
{
    ll int a,b,k,mid;
    cin>>a>>b;
    mid=a+b;
    if(mid%2==0)
        cout<<mid/2<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


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

int INF = 100000000;

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

  int ans = INF;
  for (int i = 1; i <= n / 2; i++) {
    vector<int> id(6);
    vector<int> jd(6);
    int k = i, j = n - i;

    for (int m = 0; m < 6; m++) {
      id[m] = k % 10;
      k /= 10;
      jd[m] = j % 10;
      j /= 10;
    }

    int sum = 0;
    rep(m, 6) sum += id[m] + jd[m];

    if (sum < ans) ans = sum;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (a, b, c) = read_tuple::<i64>();

    let ans = if c - a - b >= 0 && 4 * a * b < (c - a - b).pow(2) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T,T) {
    let temp = read_vec();
    (temp[0], temp[1], temp[2])
}



Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#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 INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll k,q;cin>>k>>q;
  vector<ll> D(k);
  rep(i,k){
    cin>>D[i];
  }

  rep(t, q){
    ll n,x,m;cin>>n>>x>>m;
    ll n_ = n-1;
    n--;
    ll sum = 0;
    ll count0 = 0;
    rep(i, k){
      sum += D[i] % m;
      if(D[i]%m == 0){
        count0++;
      }
    }
    sum *= n/k;
    count0 *= n/k;
    n %= k;
    rep(i, n){
      sum += D[i] % m;
      if(D[i]%m == 0){
        count0++;
      }
    }
    sum += x%m;
    cout << n_ - sum / m - count0 << endl;

  }

  return 0;
}

Measured memory_bytes: 384
n = int(input())
h_list = list(map(int,input().split()))
l = []
for i in range(n):
    if i == 0:
        l.append(h_list[i])
    else:
        if h_list[i] >= h_list[i-1] and h_list[i] >= max(l):
            l.append(h_list[i])
print(len(l))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> x(n), y(n);
    rep(i,n) cin>>x[i]>>y[i];
    double res=0;
    vector<ll> v(n);
    rep(i,n) v[i]=i;
    ll cnt=0;
    do{
        double tmp=0;
        rep(i,n-1){
            tmp+=sqrt( (x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]) + (y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]) );
        }
        res+=tmp;
        cnt++;
    }while(next_permutation(v.begin(), v.end()));

    cout<<fixed<<setprecision(10)<<res/cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  string s;
  cin >> s;
  
  bool result = true;
  
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0 && s[i] == 'L') {
      result = false;
    } else if (i % 2 == 1 && s[i] == 'R') {
      result = false;
    }
  }
  
  cout << (result ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int result = 0;
		
		//データを入力
		Scanner sc = new Scanner(System.in);
		
		//計算のループ
		loop:while(true){
			//データの入力
			int firstNumber = sc.nextInt();
			String operator = sc.next();
			int secondNumber = sc.nextInt();
			
			//演算子の判定と計算
			switch (operator){
				case "+":
					result = firstNumber + secondNumber;
					break;
				
				case "-":
					result = firstNumber - secondNumber;
					break;
				
				case "*":
					result = firstNumber * secondNumber;
					break;
				
				case "/":
					result = firstNumber / secondNumber;
					break;
					
				case "?":
					//演算子が?の時には、ループから抜ける
					break loop;
			}
			
			//計算結果の出力
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 26300
#include <cstdio>
#include <cstring>
#define MEM(x, y) memset((x), (y), sizeof(x))
typedef long long lld;
const int MAXC = 5005;
const int MOD  = 1E9+7;
char buff[MAXC]{ };
lld    dp[MAXC][MAXC]{ };
int K, L;

lld dfs(const int& k, const int& l)
{	/* Keystrokes Remaining, Length of Current String */
	lld& ret = dp[k][l];
	if(ret >= 0)
		return ret;
	if(k == K)
	{	// Keystrokes Maxed
		if(l == 0) // Empty String: Valid
			return 1;
		return 0;
	}
	ret = 0;
	/* Case: Backspace */
	if(l == 0) // Empty String
		ret += dfs(k+1, l); // Consume Keystroke
	if(l+1 < MAXC)
		ret += dfs(k+1, l+1) << 1; // Upperbound [x2: 0, 1]
	/* Case: Digit Key */
	if(l >= 1)
		ret += dfs(k+1, l-1);
	return ret %= MOD;
}

int main()
{
	scanf("%d", &K);
	scanf(" %s", &buff);
	L = strlen(buff);
	MEM(dp, -1);
	printf("%lld\n", dfs(0, L));
	return 0;
}

Measured memory_bytes: 196352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    char c[3][3];
    REP(i,3){
        REP(j,3){
            cin >> c[i][j];
        }
    }
    REP(i,3)cout << c[i][i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
AB = [list(map(int, input().split())) for i in range(N)]
 
AB.sort()
Ans = 0
for i in AB:
  if i[1] >= M:
    Ans += i[0] * M
    break
  else:
    Ans += i[0] * i[1]
    M -= i[1]
 
print(Ans)

Measured memory_bytes: 27756
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int fib[1002] = {};
  fib[0] = 1; fib[1] = 2;
  FOR(i,2,1002)fib[i] = (fib[i-1]+fib[i-2])%1001;
  int v,d;
  while(cin>>v>>d){
    vector<int> vect(fib + 1, fib + v + 1);
    sort(vect.begin(), vect.end());
    int ans = 1;
    FOR(i,1,v){
      if(vect[i]-vect[i-1] >= d) ans ++;
    }
    cout<<ans<<endl;
  }



  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0;
    char S[200001];
    bool flag=false,ended=false;
    ll fir,las;

int main(){
    scanf("%s\n",&S);
    REP(i,200001){
        if(S[i]=='A'&&!flag){
            flag=true;
            fir=i;
        }
        if(S[i]=='Z'){
            las=i;
        }
    }

    cout<<las-fir+1;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main{
 
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        
        int count = 0;
        for(int i = 0; i <= K; i++){
          for(int j = 0; j <= K; j++){
            if(i+j == S){
              count++;
            }else{
              int s = S-i-j;
                 if(s >= 0 && s <= K){
                     count++;
              }  
            }
          }
        }
      
      
      
       System.out.println(count);
   }
}

Measured memory_bytes: 35460
#include<cstdio>
#include<algorithm>
const int MAXN=100000+10;
int n,h;
int sum;
bool flag;
int maxn;
int ans;
struct node{
	int a,b;
}s[MAXN];
bool cmp(node x,node y){
	return x.b>y.b;
}
int main(){
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&s[i].a,&s[i].b);
		maxn=std::max(maxn,s[i].a);
	}
	std::sort(s+1,s+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(s[i].b>maxn){
			ans++;
			sum+=s[i].b;
		}
		if(sum>=h){
			flag=1;
			break;
		}
	}
	if(flag){
		printf("%d\n",ans);
		return 0;
	}
	ans+=(h-sum)/maxn;
	if((h-sum)%maxn!=0) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
H = int(input())

count = 0
for i in range(99999999999999999999999):

    # 攻撃の実施
    count += 2 ** i

    q, r = divmod(H, 2)

    # モンスター消滅
    if q == 0:
        print(count)
        exit(0)

    H = q


Measured memory_bytes: 2940
#include <stdio.h>

int gcd(int,int);
void swap(int*,int*);
int main(){

  int x,y,i;

  scanf("%d%d",&x,&y);

  i = gcd(x,y);
  printf("%d\n",i);

  return 0;
}

int gcd(int x, int y){
  int n;

  if(x < y){
    swap(&x,&y);
  }
  while(y > 0){
    n = x%y;
    x = y;
    y = n;
  }
  return x;
}

void swap(int *x,int *y){
  int *ch;

  ch = x;
  x = y;
  y = ch;
}


Measured memory_bytes: 2052
import java.util.*;

public class Main{
  
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();
    char[] list = S.toCharArray();
    
    int ans = 700;
    for(int i = 0 ; i < list.length; i++){
      if(list[i] == 'o'){
        ans += 100;
      }
    }
    
    System.out.println(ans);  
    
  }  
}

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

int main() {
    int a, b;
    cin >> a >> b;

    int ans = max({a + b, a - b, a * b});

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
struct UnionFind
{
	int parent[N],rnk[N];
	UnionFind(int n)
	{
		for(int i=0;i<=n;i++)
		{
			parent[i]=i;
			rnk[i]=1;
		}
	}
	int root(int x)
	{
		if(parent[x]!=x)
			parent[x]=root(parent[x]);
		return parent[x];
	}
	void connect(int x,int y)
	{
		int rx=root(x),ry=root(y);
		if(rx==ry)
			return;
		if(rx>ry)
		{
			parent[ry]=rx;
			rnk[rx]+=rnk[ry];	
		} 
		if(rx<=ry)
		{
			parent[rx]=ry;
			rnk[ry]+=rnk[rx];
		}
	}
};
long long a[N],d;
vector<pair<long long,pair<int,int>>>edge;
void solve(int l,int r)
{
	if(l==r)
		return;
	int m=(l+r)/2;
	long long mn=LLONG_MAX;
	int pl=-1;
	for(int i=l;i<=m;i++)
	{
		long long vl=a[i]-d*i;
		if(mn>vl)
		{
			mn=vl;
			pl=i;
		}
	}
	mn=LLONG_MAX;
	int pr=-1;
	for(int i=m+1;i<=r;i++)
	{
		long long vl=a[i]+d*i;
		if(mn>vl)
		{
			mn=vl;
			pr=i;
		}
	}
	for(int i=l;i<=m;i++)
	{
		long long vl=a[i]-d*i;
		long long vr=a[pr]+d*pr;
		edge.push_back(make_pair(vl+vr,make_pair(i,pr)));
	}
	for(int i=m+1;i<=r;i++)
	{
		long long vl=a[pl]-d*pl;
		long long vr=a[i]+d*i;
		edge.push_back(make_pair(vl+vr,make_pair(pl,i)));
	}
	solve(l,m);
	solve(m+1,r);
}
int main()
{
	int n;
	scanf("%d%lld",&n,&d);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	solve(1,n);
	sort(edge.begin(),edge.end());
	UnionFind uf(n);
	long long ret=0;
	for(int i=0;i<edge.size();i++)
	{
		pair<int,int> p=edge[i].second;
		if(uf.root(p.first)!=uf.root(p.second))
		{
			uf.connect(p.first,p.second);
			ret+=edge[i].first;
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 69472
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<long double> p;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
		//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int N;
		cin>>N;
		long double a;
		for(int i=0;i<N;i++){
      cin>>a;
      p.push_back(a);
		}
		sort(p.begin(),p.end());
		long double sol=(p[0]+p[1])/2;
		for(int i=2;i<N;i++)sol=(sol+p[i])/2;
		cout<<sol;
		return 0;
}


Measured memory_bytes: 256
H , W =map(int, input().split())
a = []
for i in range(H):
    s = input()
    if '#' in s:
        a.append(s)

new_a =[]

for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '#':
            s = ""
            for k in range(len(a)):
                s += a[k][i]
            new_a.append(s)
            break

for i in range(len(new_a[0])):
    s = ""
    for j in range(len(new_a)):
        s += new_a[j][i]
    print(s)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    string s;
    cin>>n>>s;
    vll v[20];
    ll ans=0;
    rep(i,n){
        v[s[i]-'0'].pb(i);
    }
    rep(i,10){
        if(lb(all(v[i]),0)==v[i].end()) continue;
        ll s=*lb(all(v[i]),0);
        rep(j,10){
            if(lb(all(v[j]),s+1)==v[j].end()) continue;
            ll t=*lb(all(v[j]),s+1);
            rep(k,10){
                if(lb(all(v[k]),t+1)!=v[k].end()){
                    // cout<<s<<" "<<t<<" ";
                    // cout<<i<<" "<<j<<" "<<k<<endl;
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> nbr(N);
  REP(i, M) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    nbr[s].push_back(t);
  }
  vector<double> dp(N);
  IREP(i, N-1) {
    double sum = 0;
    int cnt = 0;
    for(int x : nbr[i]) {
      sum += dp[x];
      cnt++;
    }
    dp[i] = sum / cnt + 1;
  }
  double ans = dp[0];
  REP(i, N-1) {
    vector<double> dp2(dp);
    double sum = 0;
    double ma = 0;
    int cnt = 0;
    for(int x : nbr[i]) {
      sum += dp2[x];
      ma = max(ma, dp2[x]);
      cnt++;
    }
    if(cnt <= 1) continue;
    dp2[i] = (sum - ma) / (cnt - 1) + 1;
    IREP(j, i) {
      sum = 0;
      cnt = 0;
      for(int x : nbr[j]) {
        sum += dp2[x];
        cnt++;
      }
      dp2[j] = sum / cnt + 1;
    }
    ans = min(ans, dp2[0]);
  }
  cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 4752
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int cnt_digit(ll n) {
	int cnt = 0;
	while (n > 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}

int main() {
	ll n;
	cin >> n;
	int cnt = 0;
	int ans = cnt_digit(n);
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0)
			cnt = max(cnt_digit(i), cnt_digit(n/i));
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}

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

int gcd(int a,int b){
  int  r,tmp;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
  return b;

}

int main(){
  int64_t a,b,c,d;cin>>a>>b>>c>>d;
  int64_t div1;
  int64_t div2;
  int64_t div3;
  int64_t f=(c*d)/gcd(c,d);
  div1=b/c - (a-1)/c;
  div2=b/d - (a-1)/d;
  div3=b/f - (a-1)/f;
  cout<<b-a+1-(div1+div2-div3)<<endl;
} 

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

int main() {
  int n;
  long k;
  cin >>n >>k;
  vector<long> a(100001);
  for(int i =0;i<n;i++){
    int A,B;
    cin >> A>>B;
    a.at(A-1) +=B;
  }
  long sum=0;
  for(int i=0;;i++){
    sum +=a.at(i);
    if( sum >=k){
      cout << i+1;
      return 0;
    }
  }
    
    
  
}


Measured memory_bytes: 1152
#include <iostream>
#include <cstdlib>

#define CHECK(expr) if (expr) cout << #expr << endl

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  CHECK(a < b);
  else CHECK(a > b);
  else CHECK(a == b);
  return 0;
} 



Measured memory_bytes: 3096
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	var (
		a   []string
		row string
	)
	for i := 0; i < h; i++ {
		fmt.Scan(&row)
		if strings.ContainsRune(row, '#') {
			a = append(a, row)
		}
	}
	h = len(a)

	r := make([]string, h)
	for i := 0; i < w; i++ {
		noBlank := false
		for j := 0; j < h; j++ {
			if a[j][i] == '#' {
				noBlank = true
				break
			}
		}
		if noBlank {
			for j := 0; j < h; j++ {
				r[j] += string(a[j][i])
			}
		}
	}

	for i := 0; i < h; i++ {
		fmt.Println(r[i])
	}
}


Measured memory_bytes: 1280