akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    cin>>str;
    ll sum = 0;
    for(char ch : str){
        sum += ch - '0';
    }
    if(sum%9){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 3768
#include <iostream>
#define mod 1000000007
using namespace std;
int x, y;
long long pow(long long a, int n)
{
	if (n==1)	return a%mod;
	long long tmp=pow(a,n/2);
	tmp=tmp*tmp%mod;
	if (n%2) tmp=tmp*a%mod;
	return tmp;
}
int main()
{
	cin>>x>>y;
	if ((x+y)%3!=0 || min(x,y)<(x+y)/3)	cout<<0;
	else{
		int m=(2*y-x)/3,	n=(2*x-y)/3;
		long long tu=1, mau=1;
		for(int i=m+1;i<=m+n;i++)	tu=tu*i%mod;
		for(int i=2;i<=n;i++)	mau=mau*i%mod;
		cout<<tu*pow(mau,mod-2)%mod;
	}	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool is_same(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int n,m; cin >> n >> m;
    vector<int> l(m),r(m),d(m);
    UnionFind<int> uf(n);
    rep(i,m){
        cin >> l[i] >> r[i] >> d[i];
        l[i] --; r[i]--;
    }
    rep(i,m){
        if(uf.is_same(l[i], r[i])){
            if(uf.diff(l[i], r[i]) != d[i]){
                cout << "No" << endl; 
                return 0;
            }    
        }
        else uf.merge(l[i], r[i], d[i]);
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3712
-- ?????????
-- http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109

import Control.Monad

data Tree a = Leaf a | Branch Char (Tree a) (Tree a) deriving Show

mylex :: String -> [String]
mylex xs = case head (lex xs) of
    ([] , []) -> []
    (x , y) -> x : mylex y

parse_factor :: [String] -> (Tree Int , [String])
parse_factor ("(":xs) = case parse_expr xs of
    (t , ")" : rest) -> (t , rest)
    (_ , _) -> error "'(' is not closed."
parse_factor ("-":x:xs) = (Leaf $ negate $ read x , xs) -- number ?
parse_factor (x:xs) = (Leaf $ read x , xs) -- number ?
parse_factor [] = error "The empty string is not an expression."

parse_term :: [String] -> (Tree Int , [String])
parse_term xs = case parse_factor xs of
    (t , rest) -> parse_term' t rest

parse_term' :: Tree Int -> [String] -> (Tree Int , [String])
parse_term' t ("*":xs) = let rest' = parse_factor xs in parse_term' (Branch '*' t (fst rest')) (snd rest')
parse_term' t ("/":xs) = let rest' = parse_factor xs in parse_term' (Branch '/' t (fst rest')) (snd rest')
parse_term' t xs = (t , xs)

parse_expr :: [String] -> (Tree Int , [String])
parse_expr xs = case parse_term xs of
    (t , rest) -> parse_expr' t rest

parse_expr' :: Tree Int -> [String] -> (Tree Int , [String])
parse_expr' t ("+":xs) = let rest' = parse_term xs in parse_expr' (Branch '+' t (fst rest')) (snd rest')
parse_expr' t ("-":xs) = let rest' = parse_term xs in parse_expr' (Branch '-' t (fst rest')) (snd rest')
parse_expr' t xs = (t , xs)

parse :: [String] -> Tree Int
parse xs = case parse_expr xs of
    (t , ["="]) -> t
    (_ , []) -> error $ "The end of expression must be '='"
    (_ , ys) -> error $ "failed to parse. " ++ show ys

calc :: Tree Int -> Int
calc (Leaf x) = x
calc (Branch '+' x y) = calc x + calc y
calc (Branch '-' x y) = calc x - calc y
calc (Branch '*' x y) = calc x * calc y
calc (Branch '/' x y) = calc x `quot` calc y
calc (Branch op _ _) = error $ "unknown operator '" ++ [op] ++ "'."

solve :: String -> IO ()
solve s = -- print t >> 
    print (calc t)
    where t = parse $ mylex s

main :: IO ()
main = readLn
    >>= (\ n -> replicateM n getLine)
    >>= mapM_ solve

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

#define In inline
#define Op operator
#define Rg register
#define St static

typedef long long ll;

const int mxN=666, p=1000000007;

In void add(int& x, ll y) {x=(x+y)%p;}

int main()
{
    St int q[mxN], g[mxN][mxN], f[mxN][mxN]; St bool flag[mxN], fix0[mxN], fix[mxN];
    int n, m=0;
    scanf("%d", &n);
    for(Rg int i=0; i<n; ++i)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        if(~a && ~b)
            flag[a]=flag[b]=1;
        else
        {
            if(~a)
                fix0[a]=1;
            else
            {
                if(~b)
                    fix0[b]=1;
                else
                    ++m;
            }
        }
    }
    Rg int t=0;
    for(Rg int i=1; i<=2*n; ++i)
        if(!flag[i])
            q[t++]=i;
    for(Rg int i=1; i<=2*n; ++i)
        if(fix0[i])
            fix[lower_bound(q, q+t, i)-q+1]=1;
    n=t;
    f[0][0]=1;
    for(Rg int i=1; i<=n; ++i)
    {
        Rg bool opt=fix[i];
        memset(g, 0, sizeof g);
        for(Rg int j=0; j<i; ++j)
            for(Rg int k=0; k+j<i; ++k)
            {
                Rg ll f0=f[j][k];
                if(opt)
                {
                    if(j)
                        add(g[j-1][k], j*f0%p);
                }
                else
                {
                    if(k)
                        add(g[j][k-1], f0);
                    add(g[j+1][k], f0);
                }
                add(g[j][k+1], f0);
            }
        swap(f, g);
//        printf("? %d\n", f[0][0]);
    }
//    printf("%lld\n", ans);
/*    Rg int c[mxN];
    c[0]=1;
    for(Rg int i=1; i<=m; ++i)
    {
        for(Rg int j=0; j<i; ++j)
            add(c[i], (ll)c[j]*c[i-j-1]%p);
    }*/
    Rg ll ans=(ll)f[0][0]%p;
//    printf("%d\n", c[m]);
    for(Rg int i=1; i<=m; ++i)
        ans=ans*i%p;
    printf("%lld\n", (ans+p)%p);
    return 0;
}


Measured memory_bytes: 3840
/// Author : Nhat Huy
/*

 ∧＿＿∧
(。・ω・)つー☆・ * 。
⊂     ノ         .  ゜
 し————Ｊ      Accepted
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define REP(i,n) for (int i = 0; i < n; ++ i)
#define FOR(i,a,b) for (int i = a; i <= b; ++ i)
#define FORD(i,b,a) for (int i = b; i >= a; -- i)
#define task "Candies"
#define opfin(task) freopen(task".inp", "r", stdin)
#define opfout(task) freopen(task".out", "w", stdout)
#define ms(a) memset(a, 0, sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef vector<int> vi;
typedef vector <ii> vii;
typedef pair <int, double> id;

const int N = 105;
int sum1[N], sum2[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    clock_t begin = clock();
    //opfin(task);
    //opfout(task);
    //Code here !

    int n;
    cin >> n;
    REP(i,n) {
    	int x;
    	cin >> x;
    	sum1[i] = sum1[i-1] + x;
    	if (i == 0) sum1[i] = x;
    }
    REP(i,n) {
    	int x;
    	cin >> x;
    	sum2[i] = sum2[i-1] + x;
    	if (i == 0) sum2[i] = x;
    }
    int res = 0;
    REP(i,n) {
    	if (i == 0) {
    		res = max(res, sum1[i] + sum2[n-1]);
    		continue;
    	}
    	res = max(res, sum1[i] + sum2[n-1] - sum2[i-1]);
    }
    cout << res << endl;
    clock_t end = clock();
    //cerr <<"Time run: "<<(float)(end-begin)/CLOCKS_PER_SEC<<" s"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

// 少し多めに確保すること
// ぴったりだと正しく動かないので注意
const long long MAX_V = 1010101;

struct edge {
  long long to, cost;
};

long long V;
vector<edge> Graph[MAX_V];
long long dist[MAX_V];

void dijkstra(long long s) {
  priority_queue<Pll, vector<Pll>, greater<Pll>> que;

  // 0-indexedと1-indexedの両方に対応
  fill(dist, dist + MAX_V, INF);

  dist[s] = 0;
  que.push(Pll(0, s));

  while (!que.empty()) {
    auto elem = que.top();
    que.pop();

    auto cv = elem.second;

    if (elem.first > dist[cv]) {
      continue;
    }

    for (auto e : Graph[cv]) {
      if (dist[e.to] > dist[cv] + e.cost) {
        dist[e.to] = dist[cv] + e.cost;
        que.push(Pll(dist[e.to], e.to));
      }
    }
  }
}

ll H, W, Ch, Cw, Dh, Dw;
string S[1010];

ll to_num(ll h, ll w) { return w + W * h; }

Pll to_point(ll num) {
  ll h = num / W;
  ll w = num % W;
  return Pll(h, w);
}

ll dh[] = {0, -1, 0, 1};
ll dw[] = {-1, 0, 1, 0};

int main() {
  //
  //
  cin >> H >> W;
  V = H * W;
  cin >> Ch >> Cw;
  Ch--;
  Cw--;
  cin >> Dh >> Dw;
  Dh--;
  Dw--;
  rep(i, 0, H) { cin >> S[i]; }

  rep(i, 0, H) {
    rep(j, 0, W) {
      if (S[i][j] == '#') continue;

      rep(k, 0, 4) {
        ll nh = i + dh[k];
        ll nw = j + dw[k];

        if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
        if (S[nh][nw] == '#') continue;

        Graph[to_num(i, j)].push_back(edge{to_num(nh, nw), 0});
      }

      repe(k, -2, 2) {
        repe(l, -2, 2) {
          ll nh = i + k;
          ll nw = j + l;

          if (nh < 0 || nw < 0 || nh >= H || nw >= W) continue;
          if (S[nh][nw] == '#') continue;

          Graph[to_num(i, j)].push_back(edge{to_num(nh, nw), 1});
        }
      }
    }
  }

  dijkstra(to_num(Ch, Cw));

  ll ans = dist[to_num(Dh, Dw)];
  if (ans == INF) {
    cout << -1;
  } else {
    cout << ans;
  }
}


Measured memory_bytes: 207312
def row(a, b):
    result = ''
    for _ in range(a):
        result += str(b)

    return result


a, b = [int(s) for s in input().split()]

if a > b:
    b_row = row(a, b)
    print(b_row)
else:
    a_row = row(b, a)
    print(a_row)


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

using namespace std;

#ifdef ACMTUYO
struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
#define DBG(X) cerr << #X << " = " << X << '\n';
#else
struct RTC{};
#define DBG(X)
#endif

#define fast_io() ios_base::sync_with_stdio(false)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(c) (c).begin(),(c).end()
#define forn(i, n) for (int i = 0; i < (n); i++)
typedef long long int number;
const int maxn = 1010;
char s[maxn], t[maxn];
int n, m;
int cnt(int ii) {
  int c = 0;
  forn (j, m) {
    if (ii + j < n) {
      if (s[ii + j] != t[j]) {
        c++;
      }
    } else {
      c = INT_MAX;
      break;
    }
  }
  return c;
}
int main() {
  scanf("%s %s", s, t);
  n = strlen(s), m = strlen(t);
  int ans = INT_MAX;
  forn (i, n) {
    ans = min(ans, cnt(i));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 3804
#include<stdlib.h>
#include<stdio.h>
int main()
{
    long long int N,M,n,m;
    while(scanf("%lld %lld",&N,&M)!=EOF)
    {
        n=m=0;
        if(2*N<M)
        {
            n=M-2*N;
            m=n/4;
            printf("%lld\n",N+m);
        }
        else if(M<=2*N)
        {
            printf("%lld\n",M/2);
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    priority_queue<int> a;
    // vector<int> a(n);
    int at;
    for(int i = 0; i < n; ++i) {
        cin >> at;
        a.emplace(at);
    }

    ll ans = a.top();
    a.pop();
    for(int i = 0; i < n - 2; ++i) {
        ans += a.top();
        if(i & 1) a.pop();
    }
    
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 4280
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(K, N, A));
    }

    private static int solve(int K, int N, int[] A) {
        int count = 0;

        int max = 0;
        for (int i=0; i<N; i++) {
            int dist = 0;

            if (i==N-1) {
                dist = A[0] + K-A[N-1];
            } else {
                dist = A[i+1] - A[i];
            }

            max = Math.max(max, dist);
        }

        count = K - max;

        return count;
    }
}

Measured memory_bytes: 84880
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.math.BigInteger;
 
public class Main implements Runnable {
	
	static int mod = 1000000007;
    static boolean[] s;
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 1024 * 1024 * 1024).start();
    }
    
    public void run() {
       	PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int[] d = sc.nextintArray(n);
        
        Arrays.sort(d);
        
        int mae = d[(n/2)-1];
        int usi = d[(n/2)];
        
        out.println(usi - mae);

        out.flush();
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextintArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public long[] nextlongArray(int n){
		long[] a = new long[n];
		for(int i=0;i<n;i++){
			a[i] = nextLong();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public int[][] nextintMatrix(int h, int w){
		int[][] mat = new int[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				mat[i][j] = nextInt();
			}
		}
		return mat;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 28732
n, m = gets.split.map(&:to_i)
relations = []
m.times do
  relations << gets.split.map(&:to_i)
end

graph = Array.new(n) { [] }
relations.each do |a, b|
  graph[a - 1] << b - 1
  graph[b - 1] << a - 1
end

groups = []

0.upto(n - 1) do |leader|
  next if groups[leader]

  queue = [leader]

  until queue.empty?
    current = queue.shift
    next if groups[current]

    graph[current].each do |friend|
      next if groups[friend]

      queue << friend
    end

    groups[current] = leader
  end
end

puts groups.tally.values.max


Measured memory_bytes: 42436
use std::io;
use std::collections::{HashSet, HashMap};

fn main() {
    let line: Vec<i32> = parse_values(2);
    let n= line[0];
    let m = line[1];
    let mut ps: Vec<(i32, String)> = Vec::with_capacity(m as usize);
    for _i in 0..m {
        let ps_line = parse_line::<String>();
        let mut split = ps_line.split_whitespace();
        let p = split.next().unwrap().parse::<i32>().ok().unwrap();
        let s = split.next().unwrap().parse::<String>().ok().unwrap();
        ps.push((p, s));
    }


    let mut cleared: HashSet<i32> = HashSet::new();
    let mut wa_counter = HashMap::new();
    let mut wa_sum = 0;
    for (p, s) in ps {
        //println!("{} {}", p, s);
        if s == "AC".to_string() {
            cleared.insert(p);
            let v = wa_counter.entry(p).or_insert(0);
            wa_sum += *v;
            *v = 0;
        } else {
            if !cleared.contains(&p) {
                let v = wa_counter.entry(p).or_insert(0);
                *v += 1;
            }
        }
        //println!("{:?}", wa_counter);
        //println!("{}", wa_sum);
        //println!()
    }
    println!("{} {}", cleared.len(), wa_sum);


}

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

fn parse_values<T: std::str::FromStr>(n: usize) -> Vec<T> {
    let line = parse_line::<String>();
    let mut split = line.split_whitespace();
    let mut values = Vec::with_capacity(n);
    for _ in 0..n {
        let v = split.next().unwrap().parse::<T>().ok().unwrap();
        values.push(v);
    }
    values
}



Measured memory_bytes: 15556
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    string S;
	cin >> S;
    int N = S.size() + 1;
    vector<ll> Cnt;
    if (S[0] == '>') Cnt.push_back(0);
    ll num = 1;
    rep(i, N-2) {
        if (S[i] == S[i+1]) {
            num++;
        } else {
            Cnt.push_back(num);
            num = 1;
        }
    }
    Cnt.push_back(num);
    if (S[N-2] == '<') Cnt.push_back(0);

    ll ans = 0;
    rep(i, Cnt.size()/2) {
        if (Cnt[2*i]   > 1) ans += (Cnt[2*i]  -1)*(Cnt[2*i])  /2;
        if (Cnt[2*i+1] > 1) ans += (Cnt[2*i+1]-1)*(Cnt[2*i+1])/2;
        ans += max(Cnt[2*i], Cnt[2*i+1]);
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>
int solve(int ,int);

int A[2000];
int n;
int main() {
  int i;
  int m;
  int j;
  int q;
  int mi[2000];
  

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);
  }
  for(i=0;i<q;i++){
    if(solve(0,mi[i])==1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int mi){

  int res;
  if(mi==0) return 1;
  if(i>=n) return 0;

  res= solve(i+1,mi) || solve(i+1,mi-A[i]);
  return res;
}

			   
			     

      

Measured memory_bytes: 588
#include<cstdio>
#include<algorithm>
using namespace std;

const int N = 1e5 + 10;
int n, a[N], b[N];

int main(){
	while(~scanf("%d", &n)){
		for(int i=0; i<n; i++){
			scanf("%d", a+i);
			b[i] = a[i];
		}
		sort(b, b+n);
		int ans = 0;
		for(int i=0; i<n; i++){
			int j = lower_bound(b, b+n, a[i]) - b;
            j ^= i;
            if(j & 1){
				ans++;
            }
		}
		printf("%d\n", ans>>1);
	}
	return 0;
}


Measured memory_bytes: 896
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vi V(3);

signed main(){

    in(V);
    Yn(V[0]==V[1]&&V[1]==V[2]);

    return 0;
}


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

typedef long long ll;

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

ll lcm(int x, int y) {
	return (ll)x / (ll)gcd(x, y) * (ll)y;
}

int main(void) {
	int A, B;
	cin >> A >> B;
	ll ans = lcm(A, B);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
//
// Created by kira09 on 05/03/20.
//


#include "bits/stdc++.h"

using namespace std;

#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;


int main() {
    IOS

    int a[3][3];

    for(auto & i : a){
        for(int & j : i){
            cin>>j;
        }
    }

    int N;
    cin>>N;

    vector<int> b(N);
    for(int& x: b)cin>>x;

    for(int x : b){
        for(auto & i : a){
            for(int & j : i){
                if(x == j)
                    j = 0;
            }
        }
    }

    for(int i = 0; i < 3; i++){
        if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
            cout<<"Yes\n";
            return 0;
        }
    }

    for(int i = 0; i < 3; i++){
        if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0){
            cout<<"Yes\n";
            return 0;
        }
    }

    if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] ==0){
        cout<<"Yes\n";
        return 0;
    }
    if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] ==0){
        cout<<"Yes\n";
        return 0;
    }

    cout<<"No\n";





}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

int main()
{
	string s = "AB";
	CIN(int, x);
	CIN(int, a);
	CIN(int, b);
	cout << s[abs(x-a) > abs(x-b)] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    if(y%2==0 && x*2<=y && x*4>=y)
        cout<<"Yes";
    else
        cout<<"No";




}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        ll n;cin>>n;
	string s;cin>>s;
	ll hash[26]={0};
	rep(i,0,n)
	hash[s[i]-'a']++;
	rep(i,0,26)
	{
		if(hash[i]&1)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>

using namespace std;
const int MAXN = 100001;
int A[MAXN];
int B[MAXN];
int C[MAXN];
int A2[MAXN];
int B2[MAXN];
int C2[MAXN];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i] >> B[i] >> C[i];
    A2[0] = A[0];
    B2[0] = B[0];
    C2[0] = C[0];
    for(int i = 1; i < n; i++)
    {
        A2[i] = A[i] + max(B2[i-1],C2[i-1]);
        B2[i] = B[i] + max(A2[i-1],C2[i-1]);
        C2[i] = C[i] + max(B2[i-1],A2[i-1]);
    }
    cout << max(A2[n-1],max(B2[n-1],C2[n-1]));
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void) {
    int N, Y;
    scanf("%d %d", &N, &Y);

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N - i; j++) {
            for (int k = 0; k <= N - i - j; k++) {
                if (i + j + k == N && (i * 10000) + (j * 5000) + (k * 1000) == Y) {
                    printf("%d %d %d\n", i, j, k);
                    return 0;
                }
            }
        }
    }
    printf("%d %d %d\n", -1, -1, -1);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define For(i,a,b) for(i=(a);i<(b);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const double PI=acos(-1.0);


int main(){
  ll n,Y; cin >> n >> Y;
  ll x,y,z;
  rep(i,(Y/10000)+1){
    x = i;
    y = (Y -(1000*n) - (9000*x))/4000;
    z = n - x - y;
    //cout << x << " " << y << " " << z << endl;
    if(y >= 0 and z >= 0 and 10000*x+5000*y+1000*z == Y){
      cout << x << " " << y << " " << z << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(a: int, b: int, c: int):
    if c - a - b > 0 and 4 * a * b < pow(c - a - b, 2):
        print(YES)
    else:
        print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)

if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;
  vll h(n);
  rep(i, n) {
    cin >> h[i];
  }

  vll dp(n + 10, INF);
  dp[0] = 0;
  rep(i, n - 1) {
    REP(j, k + 1) {
      if (i + j < n) {
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      }
    }
  }

  cout << dp[n - 1] << endl;

  return 0;
}


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

typedef long long ll;

string s;

int main()
{
    cin >> s;
    int n = s.size();
    bool f = 0;

    string s1 = s.substr(0, n / 2), s2 = s.substr(n / 2 + 1, n / 2);

    string s3 = s1, s4 = s2;

    reverse(s3.begin(), s3.end());
    reverse(s4.begin(), s4.end());

    string s5 = s;
    reverse(s5.begin(), s5.end());

    if (s1 == s3 && s2 == s4 && s == s5)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

#define min(a, b) (((a) < (b))? (a) : (b))

int main(void)
{
    int A, B, C, D, E, F;
    int sum;
    
    scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
    
    sum = A + B + C + D + E + F;
    
    sum -= min(min(min(A, B), C), D);
    sum -= min(E, F);
    
    printf("%d\n", sum);
    
    return (0);
}



Measured memory_bytes: 2136
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  const i64 N = S.size();

  if (N == 1) {
    std::cout << 1 << std::endl;
    return 0;
  }

  constexpr i64 N_A = std::numeric_limits<i64>::min();
  constexpr i64 ONE_LETTER = 0;
  constexpr i64 TWO_LETTERS = 1;
  // dp[i][j] ... 直前の分割がj+1文字であるときの、Sのi文字目（0-based indexing）まで見た時点での最大分割数
  std::vector<std::vector<i64>> dp(N, std::vector<i64>(2, N_A));
  dp[0][ONE_LETTER] = 1;
  dp[1][TWO_LETTERS] = 1;
  for (i64 i = 0; i < N; ++i) {
    if (dp[i][ONE_LETTER] != N_A) {
      if (i + 1 < N && !(S[i] == S[i + 1])) {
        dp[i + 1][ONE_LETTER] = std::max(dp[i + 1][ONE_LETTER], dp[i][ONE_LETTER] + 1);
      }
      if (i + 2 < N) {
        dp[i + 2][TWO_LETTERS] = std::max(dp[i + 2][TWO_LETTERS], dp[i][ONE_LETTER] + 1);
      }
    }
    if (dp[i][TWO_LETTERS] != N_A) {
      if (i + 1 < N) {
        dp[i + 1][ONE_LETTER] = std::max(dp[i + 1][ONE_LETTER], dp[i][TWO_LETTERS] + 1);
      }
      if (i + 2 < N && !(S[i - 1] == S[i + 1] && S[i] == S[i + 2])) {
        dp[i + 2][TWO_LETTERS] = std::max(dp[i + 2][TWO_LETTERS], dp[i][TWO_LETTERS] + 1);
      }
    }
  }

  std::cout << std::max(dp[N - 1][ONE_LETTER], dp[N - 1][TWO_LETTERS]) << std::endl;
  return 0;
}

Measured memory_bytes: 11396
import java.util.*;

class Main {
	//?????¢??¢?´¢?????¬???
	public static int search(int[] A, int n, int key) {
		A[n] = key;
		int i = 0;
		while(A[i] != key)i++;
		if(i == n) {
			return -1;
		} else {
			return i;
		}
	}
	
	public static int search2(int[] A, int n, int key) {
		for ( int i = 0; i < n; i++ ) {
			if ( A[i] == key) return i;
		}
		return -1;
	}

	public static void main(String args[]) {

		Scanner scan = new Scanner(System.in);
		int[] arrayS = new int[10001]; //??°???S
		int[] arrayT = new int[501];   //??°???T
		int count = 0;						 //?????°????¨???????????????°

		//????´??????°???????????????ArrayS?????°???S???????????????
		int sNum = scan.nextInt();
		for (int i = 0; i < sNum; i++)
			arrayS[i] = scan.nextInt();

		//????´??????°???????????????ArrayT?????°???T???????????????
		int tNum = scan.nextInt();
		for (int j = 0; j < tNum; j++)
			arrayT[j] = scan.nextInt();

		//??°???T???????´??????°???A????????????????????????????????????
		for (int j = 0; j < tNum; j++)
			if(search2(arrayS, sNum, arrayT[j]) >= 0) count++;

		System.out.println(count);
	}
}

Measured memory_bytes: 39836
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<n;i++){
    	int cnt=0;
    	for(char c='a';c<='z';c++)
		    {
		    bool L=0,R=0;
		    for(int j=0;j<i;j++)
		        if(s[j]==c)
		        {
				    L=true;
					break;
				}
			for(int j=i;j<n;j++)
		        if(s[j]==c)
		        {
				    R=true;
					break;
				}
			if(R&&L)
			    cnt++;
			} 
		if(cnt>ans)
		    ans=cnt;
	}
	cout<<ans;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff(x,a,b) for(int x=a;x<=b;++x)
#define fff(x,a,b) for(int x=a;x>=b;--x)
using namespace std;
typedef long long ll;
void rd(int &v){char ch;for(ch='*';ch<'0'||ch>'9';ch=getchar());for(v=0;ch>='0'&&ch<='9';ch=getchar()) v=v*10+ch-'0';}
ll n;
int main()
{
	cin>>n;
	cout<<3*n*n;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll> >v;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
       // cout<<v[i].first<<" "<<v[i].second<<"\n";
        if(v[i].first==v[i].second)
            cnt++;
        else
            cnt=0;
           // cout<<cnt<<"\n";
        if(cnt==3)
            break;
    }
    if(cnt==3)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3132
n,k = map(int, input().split())
*s, =map(int, input())
mark=[]
for i in range(n):
    if i==0 and s[i]==1:
        mark.append((i,1))
    elif i==0 and s[i]==0:
        mark.append((i,0))
    elif s[i-1]==0 and s[i]==1:
        mark.append((i,1))
    elif s[i-1]==1 and s[i]==0:
        mark.append((i,0))

X=[0]*n
for i in range(len(mark)):
    ist,jst=mark[i]
    if jst==0:
        if i+2*k<len(mark):
            igo, jgo=mark[i+2*k]
            X[ist]=igo-ist
        else:
            X[ist]=n-ist
    if jst==1:
        if i+2*k+1<len(mark):
            igo, jgo=mark[i+2*k+1]
            X[ist]=igo-ist
        else:
            X[ist]=n-ist

print(max(X))

Measured memory_bytes: 90416
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    long long int x,y;
    cin>>x>>y;
    int a=0;
    for(int i=0;i<1000;i++){
        if(y>=x){
            a++;
        }else{
            break;
        }
        x*=2;
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	string s; cin >> s;
    int n = (int)s.size() + 1;
    vector<int> a(n, 0);
    rep(i, n - 1) {
        if(s[i] == '<') chmax(a[i + 1], a[i] + 1);
    }
    per(i, n - 1) {
        if(s[i] == '>') chmax(a[i], a[i + 1] + 1);
    }
    int ans = 0;
    rep(i, n) {
        ans += a[i];
    }
    cout << ans << endl;
    //cout << accumulate(all(a), 0LL) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 4764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 1e5 + 20, inf = 1e9+1;

int n, a[maxn], mn, mx;


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	mn = n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] > mx)
			mx = a[i];
		if (a[i] < mn)
			mn = a[i];
	}
	if (mx - mn > 1)
		return cout << "No" << endl, 0;
	if (mx == mn)
		return cout << (2 * mn <= n || mn == n-1? "Yes" : "No") << endl, 0;
	int tmx = 0, tmn = 0;
	for (int i = 0; i < n; i++)
		if (a[i] == mn)
			tmn ++;
		else
			tmx ++;
	if (mn - tmn + 1 <= tmx && mn - tmn + 1 > 0 && (mn - tmn + 1) * 2 + tmn <= n)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 640
/*
  AtCoder Beginner Contest 086
  B - 1 21
*/

#include<iostream>
#include<cmath>
using namespace std;

bool check(int x) {
  int i = 1;
  while (1) {
    if (i * i > x || i * i > 100100) return false;
    if (i * i == x) return true;
    i += 1;
  }
}

int a, b;

int main() {
  scanf("%d%d", &a, &b);

  int n = a;
  int nDigits;
  if (b == 0) nDigits = 1;
  else nDigits = log10(b) + 1;

  for (int i = 0; i < nDigits; ++i) {
    n *= 10;
  }
  n += b;

  if (check(n)) printf("Yes\n");
  else printf("No\n");

  return 0;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    int Max = 0;
    int Min = INF;
    int Max_pos, Min_pos;
    bool all_positive = true;
    bool all_negative = true;

    rep(i, n) {
        cin >> a[i];
        if (a[i] > Max) {
            Max = a[i];
            Max_pos = i + 1;
        }
        if (a[i] < Min) {
            Min = a[i];
            Min_pos = i + 1;
        }
        if (a[i] < 0) all_positive = false;
        if (a[i] > 0) all_negative = false;
    }

    if (all_positive) {
        printf("%d\n", n - 1);
        for (int i = 1; i < n; ++i) printf("%d %d\n", i, i + 1);
    } else if (all_negative) {
        printf("%d\n", n - 1);
        for (int i = n; i > 1; --i) printf("%d %d\n", i, i - 1);
    } else if (Max >= -Min) {
        printf("%d\n", 2 * n - 1);
        for (int i = 1; i <= n; ++i) printf("%d %d\n", Max_pos, i);
        for (int i = 1; i < n; ++i) printf("%d %d\n", i, i + 1);
    } else {
        printf("%d\n", 2 * n - 1);
        for (int i = 1; i <= n; ++i) printf("%d %d\n", Min_pos, i);
        for (int i = n; i > 1; --i) printf("%d %d\n", i, i - 1);
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int n;
    int h, w;
    cin >> n >> h >> w;
    int a, b;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (h <= a)
        {
            if (w <= b)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int r,c,a[110][110],i,t,S;
	
	scanf("%d %d",&r,&c);
	
	for(i=0;i<r;i++){
		
		for(t=0;t<c;t++){
			
			scanf("%d",&a[i][t]);
			
		}
	}
	
	for(i=0;i<r;i++){
		
		S=0;
		
		for(t=0;t<c;t++){
			
			S=S+a[i][t];
		}
		
		for(t=0;t<c+1;t++){
			
			if(t!=c){
				
				printf("%d ",a[i][t]);
			}
			
			else printf("%d\n",a[i][t]=S);
		}
	}
	
	for(t=0;t<c;t++){
		
		S=0;
		
		for(i=0;i<r;i++){
			
			S=S+a[i][t];
		}
		printf("%d ",S);
	}
	S=0;
	for(i=0;i<r;i++){
		
		S=S+a[i][c];
	}
	printf("%d\n",S);
	
	return 0;
}

Measured memory_bytes: 2676
import sys
import numpy as np

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

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

MOD = 10 ** 9 + 7
U = 10 ** 5 + 10 # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
N = ir()
X = np.array(lr())

inv = np.zeros(U, np.int64)
inv[1:] = fact_inv[1:] * fact[:-1] % MOD
coef = inv[1:N].cumsum() % MOD
answer = (np.diff(X) * coef % MOD).sum() % MOD
answer *= fact[N-1]
print(answer % MOD)
# 35

Measured memory_bytes: 26632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int maxi = 0;
    int cnt = 0;
    rep(i, N){
        if(S[i] == 'I'){
            cnt++;
            maxi = max(cnt, maxi);
        }
        else if(S[i] == 'D'){
            cnt--;
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
n = int(input())
count = [0, 0, 0, 0]
for _ in range(n):
    s = input()
    if s == "AC":
        count[0] += 1
    elif s == "WA":
        count[1] += 1
    elif s == "TLE":
        count[2] += 1
    else:
        count[3] += 1

print("AC x", count[0])
print("WA x", count[1])
print("TLE x", count[2])
print("RE x", count[3])

Measured memory_bytes: 69880
package main

import (
	"fmt"
)

func main() {
	var N uint8
	var D uint8
	fmt.Scan(&N, &D)

	ranges := 1 + D*2
	d := N / ranges
	m := N % ranges

	if d < 1 {
		fmt.Println(1)
	} else {
		if m == 0 {
			fmt.Println(d)
		} else {
			fmt.Println(d + 1)
		}
	}

}


Measured memory_bytes: 512
#include<iostream> 
using namespace std;
 int main() { int a=0,b=0,n; string A,B;
 cin>>n; 
for(int i=0;i<n;i++){ cin>>A>>B; if(A==B){ a++; b++; } else if(A>B)a+=3; else b+=3; } cout<<a<<" "<<b<<endl; return 0; } 


Measured memory_bytes: 3160