akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int f(int N,int K) {
	int X = N / K;
	int Y = N % K;
	if (!Y)
		return X;
	if (Y >= X + 1)
		Y %= (X + 1);
	else
		Y -= X + 1;
	return f(1ll * X * K + Y,K);
}
int F(int N,int K) {
	if (N % K == 0)
		return N / K;
	else
		return F(1LL * (K - 1) * N / K,K);
}
int main(void)
{
    int n;
    cin>>n;
    int ans = 0;
    while (n --) {
    	int a,k;
    	cin>>a>>k;
    	ans ^= f(a,k);
    }
    if (ans)
    	puts("Takahashi");
    else
    	puts("Aoki");
    return 0;
}

Measured memory_bytes: 256
//これで点数入るの？
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll d;
    cin >> d;
    for (int i = 0; i < d; i++) {
        cout << i % 26+1 << endl;
    }
}


Measured memory_bytes: 3612
package main

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

const (
	MOD = 1000*1000*1000 + 7
	N   = 3*1000*1000*10 + 10
)

func main() {
	in := IOInitialize()
	N, A := Int(in), Int(in)

	st := N / 500
	sk := N - st*500

	if sk <= A {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//////////
//
//

func IOInitialize() *bufio.Scanner {
	t := bufio.NewScanner(os.Stdin)
	t.Split(bufio.ScanWords)
	return t
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("\t\tThere is a FALSE not to want.")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("\t\tError:Failed to convert text to int,")
	}
	return value
}

func IntArray(s *bufio.Scanner, size int) []int {
	deepArray := make([]int, size)
	for i := range deepArray {
		deepArray[i] = Int(s)
	}
	return deepArray
}

func GraphSetByEdge(s *bufio.Scanner, v int) [][]int {
	g := make([][]int, v)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for xxNonUsedInLoopI := 0; xxNonUsedInLoopI < v-1; xxNonUsedInLoopI++ {
		a, b := Int(s)-1, Int(s)-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	return g
}


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

typedef long long int LL;
long long s, w;

string solve() {
	if (s > w)
		return "safe";
	return "unsafe";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	while (cin >> s >> w)
		cout << solve() << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            dfs(G, e.to);
        }
    }
}
int main() {
    int n, m,ans=0;
    cin >> n >> m;
    Graph G(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    seen.assign(n, false);  // 初期化
    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            dfs(G, i);
            ans++;
        }
    }
    cout << ans-1 << endl;
    return 0;
}

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

int main(void){
string S;
cin>>S;
int cnt1=0,cnt2=0,i;
for(i=0;i<S.length();i++){
if(i%2==0){
if(S[i]=='1') cnt2++;
else cnt1++;
} else {
if(S[i]=='1') cnt1++;
else cnt2++;
}
}
if(cnt1>cnt2) printf("%d\n",cnt2);
else printf("%d\n",cnt1);
return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
   
int main(){
    const std::string wrong_word("Hoshino");
    const std::string right_word("Hoshina");
     
    int num;
    std::cin >> num;
    std::cin.ignore(); // ignore next newline character
       
    for(int i = 0; i < num; ++i){
        std::string str;
        std::getline(std::cin, str);
         
        std::size_t pos = str.find(wrong_word);
        while(pos != std::string::npos){
            str.replace(pos, wrong_word.length(), right_word);
            pos = str.find(wrong_word);
        }
         
        std::cout << str << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3116
n=int(input())
s=input()
r=[0]*n
b=[0]*n
g=[0]*n
cb=0
cg=0
cr=0
for i in range(n-1,-1,-1):
  if s[i]=='R':
    cr+=1
  elif s[i]=='G':
    cg+=1
  else:
    cb+=1
  r[i]=cr
  g[i]=cg
  b[i]=cb
  
fr=[0]*n
fb=[0]*n
fg=[0]*n
cb=0
cg=0
cr=0
for i in range(n):
  if s[i]=='R':
    cr+=1
  elif s[i]=='G':
    cg+=1
  else:
    cb+=1
  fr[i]=cr
  fg[i]=cg
  fb[i]=cb
  
p=0
for i in range(1,n-1):
  if s[i]=='B':
    p+=fg[i-1]*r[i+1]+fr[i-1]*g[i+1]
    j=i-1
    k=i+1
    while (j>-1 and k<n):
      if (s[j]=='G' and s[k]=='R' or s[j]=='R' and s[k]=='G'):
        p-=1
      j-=1
      k+=1
      
  if s[i]=='G':
    p+=fb[i-1]*r[i+1]+fr[i-1]*b[i+1]
    j=i-1
    k=i+1
    while (j>-1 and k<n):
      if (s[j]=='B' and s[k]=='R' or s[j]=='R' and s[k]=='B'):
        p-=1
      j-=1
      k+=1
      
  if s[i]=='R':
    p+=fb[i-1]*g[i+1]+fg[i-1]*b[i+1]
    j=i-1
    k=i+1
    while (j>-1 and k<n):
      if (s[j]=='B' and s[k]=='G' or s[j]=='G' and s[k]=='B'):
        p-=1
      j-=1
      k+=1
  
print(p)


Measured memory_bytes: 9344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		sc.close();

		long diff = c - (a + b);
		if (diff <= 0) {
			// 負の場合はNG
			System.out.println("No");
			return;
		}

		long left = 4 * a * b;
		if (left < diff * diff) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23508
program shift
  implicit none
  integer(8), parameter :: modu = 998244353
  character(301) :: s
  integer :: k, n, a(302) = 0, m = 1, x = 0, h = 0, r, d, w, c, b, i, j
  integer(8) :: dp(0:300, 0:301) = 0
  read(*,*) s, k
  n = len_trim(s)
  s(n + 1:n + 1) = '0'
  do i = 1, n + 1
    if (s(i:i) == '0') then
      m = m + 1
      a(m) = x
    else
      x = x + 1
    end if
  end do
  k = min(k, x)
  dp(0, 0) = 1
  do i = 1, m - 1
    do j = h, 0, -1
      r = min(k - j, a(i + 1) - a(i))
      do d = 1, r
        w = j + d
        b = a(m) - a(i + 1) + d
        do c = 0, a(m) - a(i + 1)
          b = c + d
          dp(w, c) = dp(w, c) + dp(j, b)
          if (dp(w, c) > modu) dp(w, c) = dp(w, c) - modu
        end do
      end do
      do c = 1, a(m) - a(i + 1)
        dp(j, c) = dp(j, c) + dp(j, c - 1)
        if (dp(j, c) > modu) dp(j, c) = dp(j, c) - modu
      end do
    end do
    h = min(k, h + a(i + 1) - a(i))
  end do
  write(*,'(i0)') mod(sum(dp(0:h, 0)), modu)
end program shift

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

int dp[100001][3];

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

Measured memory_bytes: 5928
#include<iostream>

using namespace std;

int dp[1001][8];
int sekininn[1001];

int main() {
	int n;
	cin >> n;
	for (int i = 1;i <= n;i++) {
		char c;
		cin >> c;
		if (c == 'J')sekininn[i] = 1;
		else if (c == 'O')sekininn[i] = 2;
		else if (c == 'I')sekininn[i] = 4;
	}
	for (int i = 0;i < 8;i++) {
		if (i&sekininn[1] && i & 1)dp[1][i] = 1;
	}
	for (int i = 2;i <= n;i++) {
		for (int j = 0;j < 8;j++) {
			if (sekininn[i] & j) {
				for (int k = 0;k < 8;k++) {
					if(j & k)dp[i][j] += dp[i - 1][k];
					dp[i][j] %= 10007;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0;i < 8;i++)ans += dp[n][i];
	ans %= 10007;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
using ll = long long;
 
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<vector<int>> next_table(20, vector<int>(n + 1, n));
	for(int s = 0; s < 20; ++s){
		int last = n;
		for(int i = n - 1; i >= 0; --i){
			next_table[s][i] = last;
			if(a[i] & (1 << s)){ last = i; }
		}
	}
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		int tail = n;
		for(int s = 0; s < 20; ++s){
			if(a[i] & (1 << s)){
				tail = min(tail, next_table[s][i]);
			}else{
				tail = min(tail, next_table[s][next_table[s][i]]);
			}
		}
		answer += tail - i;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 17536
import bisect
N=int(input())
A=[int(s) for s in input().split()]
B=[int(s) for s in input().split()]
C=[int(s) for s in input().split()]
B.sort()
C.sort()
Bls=[0 for _ in range(N)]
for i in range(N):
  x=B[i]
  index = bisect.bisect_right(C,x)
  Bls[i]=N-index
Bls_sum=[0 for _ in range(N)]
Bls_sum[N-1]=Bls[N-1]
for i in range(1,N):
  Bls_sum[N-i-1]=Bls_sum[N-i]+Bls[N-i-1]
#[22, 17, 12, 8, 5, 2] Bls_sum
Bls_sum.append(0)
ans=0
for i in range(N):
  y=A[i]
  index = bisect.bisect_right(B,y)
  ans+=Bls_sum[index]
print(ans)
  


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

using namespace std;

int N;
char s[10101][11];

int main() {
	scanf("%d",&N);
	int ans = 0;
	int cntb = 0,cnta = 0,cntba = 0;
	for (int i=1;i<=N;i++) {
		scanf("%s",s[i]); 
		int len = strlen(s[i]);
		for (int j=0;j<len-1;j++) {
			if (s[i][j] == 'A' && s[i][j+1] == 'B') {
				ans++;
			}
		}
		if (s[i][0] == 'B' && s[i][len - 1] == 'A') {
			cntba++;
		} else if (s[i][0] == 'B') {
			cntb++;
		} else if (s[i][len - 1] == 'A') {
			cnta++;
		}
	}
	//printf("%d %d %d %d\n",ans,cntba,cntb,cnta);
	bool hasa = false;
	while(cntba > 0 || cnta > 0 || cntb > 0) {
		if (hasa) {
			if (cntba > 0) {
				//puts("ba");
				ans++;
				cntba--;
			} else if (cntb > 0) {
				//puts("b");
				ans++;
				cntb--;
				hasa = false;
			} else {
				//puts("a");
				cnta--;
			}
		} else {
			if (cnta > 0) {
				//puts("a");
				hasa = true;
				cnta--;
			} else if (cntba > 0) {
				//puts("ba");
				hasa = true;
				cntba--;
			} else {
				//puts("b");
				cntb--;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,n,s;
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&n);
    for (i=0;i<=a;i++)
     for (j=0;j<=b;j++)
      if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) ++s;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int num[110] = {};
    int a, b, c;
    int ans = 0;
    
    cin >> a >> b >> c;

    num[a]++; num[b]++; num[c]++;

    for (int i = 0; i <= 100; i++) {
        if (num[i] > 0) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int n,a[100010],t=0;
  cin >> n;
  REP1(i,n){
    cin >> a[i];
  }
  REP1(i,n){
    if (i==a[a[i]]) t++;
  }
  cout << t/2;
}

Measured memory_bytes: 640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;


int main(){
    int n, m , a, b;
    cin >> n >> m;
    int amount[n+1];
    rep( i , n) amount[i] = 1;
    bool red[n+1];
    red[1] = true;
    rep(i , m){
        cin >> a >> b;
        amount[a]--;
        amount[b]++;
        if ( red[a]) red[b] = true;
        if ( amount[a] == 0) red[a] = false;
        
        
    }
    int ans = 0;
    rep( i , n){
        if ( red[i] ) ans++;
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 4020
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        h: [u64; n],
    }

    let mut before = h[0] - 1;
    for i in h.iter().skip(1) {
        let mut now = *i - 1;
        if before > now + 1 {
            println!("No");
            return;
        } else if before > now {
            now = now + 1;
        }
        before = now;
    }

    println!("Yes")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll x; cin>>x;
		if(x>=30) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}

	signed main()
	{

	fast;
	#ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
     #endif

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3636
//1_6B	1??????30???

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
	char tmp[1000];
	//?????¨?????????????????°?????°????????????
	fgets(tmp, sizeof(tmp), stdin);
	int loop = atoi(tmp);

	int spade[13] = {0};
	int heart[13] = {0};
	int dia[13] = {0};
	int club[13] = {0};

	int i;
	//??????????????°?????????
	for (i = 0; i < loop; i++) {

		//???????????¨??°????????\????????????
		char card[10];
		fgets(card, sizeof(card), stdin);
		char mark;
		int num;
		sscanf(card, "%c%d", &mark, &num);
		
		//???????????§??????
		//??????????????°?????????????????¨??§????¶???§??????????????¨????¢????
		switch (mark) {
		case 'S':
			spade[num - 1] ++;
			break;
		case 'H':
			heart[num - 1] ++;
			break;
		case 'C':
			club[num - 1] ++;
			break;
		case 'D':
			dia[num - 1] ++;
			break;
		}

	}
	//??????????????°???????????????

	//???????????§????????????
	for (i = 1; i<=13; i++) if (spade[i-1] != 1) printf("S %d\n", i);
	for (i = 1; i<=13; i++) if (heart[i-1] != 1) printf("H %d\n", i);
	for (i = 1; i<=13; i++) if (club[i-1] != 1) printf("C %d\n", i);
	for (i = 1; i<=13; i++) if (dia[i-1] != 1) printf("D %d\n", i);
		//???????????????
	
	//???????????§??????????????????
	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vs = vector<string>;
#define all(x) x.begin(), x.end()
// int di[] = {0, 1, 0, -1};
// int dj[] = {1, 0, -1, 0};
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main(int argc, char **argv) {
	ios::sync_with_stdio(false), cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n; cin >> n;
	vi a(n);
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		sum -= a[i];
		sum += MOD;
		sum %= MOD;
		ans += a[i] * sum;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4740
#include<iostream>
using namespace std;
int main(){
  
  char s[3][105];
  for(int i=0;i<3;i++){
    cin>>s[i];
  }
  int play=0;
  int pos[3]={0,0,0};
  char ans;
  while(1){
    pos[play]++;
    play=s[play][pos[play]-1]-'a';
    if(s[play][pos[play]]=='\0'){
      ans='A'+play;
      break;
    }
  }
  
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/agc039/tasks/agc039_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn solve(s: &Vec<char>, limit: usize) -> i64 {
    let mut last = false;
    let mut count = 0;
    for i in 1..limit {
        if !last && s[i-1] == s[i] {
            last = true;
            count += 1;
        } else {
            last = false;
        }
    }
    count
}

fn main() {
    input! {
        s: chars,
        n: i64
    };

    let m = s.len();
    let mut ns = vec![' '; 10*m];
    for i in 0..10*m {
        ns[i] = s[i%m];
    }

    if n <= 10 {
        println!("{}", solve(&ns, (n as usize)*m));
        return;
    }
    let eight = solve(&ns, 8*m);
    let nine = solve(&ns, 9*m);
    let ten = solve(&ns, 10*m);
    let ans = if n % 2 == 0 {
        ((n - 10) / 2) * (ten - eight) + ten
    } else {
        ((n - 9) / 2) * (ten - eight) + nine
    };

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


Measured memory_bytes: 4352
from collections import deque

N, M = map(int, input().split())
dist = [-1] * N
dist[0] = 0
G = [[] for i in range(N)]
prev = [0] * N

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)
    

que = deque([0])

while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
        prev[w] = v
print("Yes")
for i in range(1, len(prev)):
    print(prev[i]+1)

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

int fuc(int n,int a[]){
    int flag=1;
    int ans=0;
    int j=0;
    while (flag!=0) {
        flag=0;
        for(int i=n-1;i>j;i--){
            if (a[i]<a[i-1]) {
                swap(a[i], a[i-1]);
                flag=1;
                ans++;
            }
        }
        j++;
    }
    for (int i=0; i<n-1; i++) {
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl;
    return ans;
}

int main(){
    int n,a[100];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    cout<<fuc(n,a)<<endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if (s.back() == 's') s += "es";
  else s += "s";
  cout << s << endl;
  return 0;
}

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

int main(void) {
    int x; cin >> x;
    if(x==0) cout << 1 << endl;
    else if(x==1) cout << 0 << endl;
    return 0;
}

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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	ll r = 0, g = 0, b = 0;

	for (int i = 0; i < N; i++) {
		if (S.at(i) == 'R') {
			r++;
		}
		if (S.at(i) == 'G') {
			g++;
		}
		if (S.at(i) == 'B') {
			b++;
		}
	}

	ll ans = r * g * b;

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			int k = j + (j - i);
			if (k >= N) {
				continue;
			}
			if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
				ans--;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
 
int main(void) {
	int n, l; cin >> n >> l;
	int i;
	string s[n];
 
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
 
	sort(s, s + n);
 
	for (i = 0; i < n; i++) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(br.readLine());
		call(n);
	}

	private static void call(long n) {
		write(n);
		System.out.println();
	}

	private static void write(long n) {
		if (n > 1){
			write(n - 1);
		}
		if(n % 3 == 0 || String.valueOf(n).indexOf("3") != -1){
			System.out.printf(" %d", n);
		}
	}

}

Measured memory_bytes: 34228
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  
  int ans = 0;
  
  for (int i=0, current, prev, temp; i<N; ++i) {
    std::cin >> current;
    
    if (i != 0 && current <= prev) {
      ++temp;
      ans = std::max(ans, temp);
    } else {
      temp = 0;
    }
    
    prev = current;
  }
  
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,j,n,k,q,a[100005]={0},w;
    scanf("%d %d %d",&n,&k,&q);
    for(i=0;i<q;i++){
        scanf("%d",&w);
        a[w]++;
    }
    for(i=1;i<=n;i++){
        if((k-q+a[i])<=0)printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int n, m;
	while(cin >> n >> m, n || m) {
		vector<int> t;
		for(int i = 0; i < n; ++i) {
			int tmp;
			cin >> tmp;
			t.push_back(tmp);
		}
		for(int i = 0; i < m; ++i) {
			int tmp;
			cin >> tmp;
			t.push_back(tmp);
		}
		sort(t.begin(), t.end());
		int ans = t[0];
		for(unsigned int i = 0; i < t.size() - 1; ++i) {
			ans = max(ans, t[i+1] - t[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int x, y;
    cin >> x >> y;

    int legs = (4 * x - y);
    if(legs < 0) {
        cout << "No" << endl;
        return 0;
    }

    int crane = legs / 2;
    if(crane > x) {
        cout << "No" << endl;
        return 0;
    }
    
    if(crane * 2 + (x - crane) * 4 == y) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  int n;
  cin >> n;
  int v[n],c[n];
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  ll sum = 0;
  for(int i=0;i<n;i++){
    sum += max(0,v[i]-c[i]);
  }
  cout << sum;
}


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

int main(){
  ll n, a, b; cin >> n >> a >> b;
  ll x[n+1];
  for(int i=1; i<=n; i++) cin >> x[i];

  ll ans = 0;
  for(int i=1; i<n; i++){
    //歩く
    if((x[i+1]-x[i])*a <= b){
      ans += (x[i+1]-x[i])*a;
    }
    //テレポート
    else{
      ans += b;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
 
public class Main {
     
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         
        int n = sc.nextInt();
        int[] m = new int[n];
        int[] d = new int[n];
        int[] w = new int[n];
        for(int i=0;i<n;i++){
            m[i] = sc.nextInt();
            d[i] = sc.nextInt();
            w[i] = 20*sc.nextInt();
        }
         
        double[][] dp = new double[1<<n][n];
        int[][] pre = new int[1<<n][n];
        for(int i=0;i<(1<<n);i++) Arrays.fill(dp[i], Integer.MAX_VALUE);
         
        for(int i=0;i<n;i++) dp[(int)Math.pow(2,i)][i] = 0;
         
        double p, q;
        for(int k=1;k<1<<n;k++){
            int j = k;
            int sum = 0;
            for(int i=0;i<n;i++){
                if((j>>i&1)==1) sum+=w[i]; 
            }
             
            for(int v=0;v<n;v++){
                if(dp[j][v]!=Integer.MAX_VALUE && (j>>v&1)==1){
                    for(int u=0;u<n;u++){
                        if(u!=v && (j>>u&1)==0){
                            p = dp[j|(1<<u)][u];
                            q = dp[j][v] + Math.abs(d[v]-d[u])/(2000.0/(double)(70+sum));
                            if(p>q){
                                dp[j|(1<<u)][u] = q;
                                pre[j|(1<<u)][u] = v;
                            }
                        }
                    }
                }
            }
        }
 
        double min = Integer.MAX_VALUE;
        int num = -1;
        for(int i=0;i<n;i++){
            if(min > dp[(1<<n)-1][i]){
                min = dp[(1<<n)-1][i];
                num = i;
            }
        }
         
        LinkedList<Integer> list = new LinkedList<Integer>();
        int s = (1<<n)-1;
        int t;
        for(int i=0;i<n;i++){
            list.push(num);
            t = num;
            num = pre[s][num];
            s = s&~(1<<t);
        }
         
        for(int i=0;i<n;i++){
            if(i!=0) System.out.print(" ");
            System.out.print(m[list.pollFirst()]);
        }
        System.out.println();
    }   
}

Measured memory_bytes: 30260
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--;
  b--;
  c--;
  d--;

  bool flag = true;
  if (c < b) {
    rep(i, n) {
      if (a < i && i < c) {
        if (s[i] == '#' && s[i + 1] == '#') flag = false;
      }
      if (b < i && i < d - 1) {
        if (s[i] == '#' && s[i + 1] == '#' && i < n) flag = false;
      }
    }
  } else if (c < d) {
    rep(i, n) {
      if (a < i && i < b) {
        if (s[i] == '#' && s[i + 1] == '#') flag = false;
      }

      if (b < i && i < d - 1) {
        if (s[i] == '#' && s[i + 1] == '#' && i < n) flag = false;
      }
    }
  } else {
    bool f = false;
    rep(i, n) {
      if (a < i && i < b) {
        if (s[i] == '#' && s[i + 1] == '#') flag = false;
      }

      if (b - 1 <= i && i <= d - 1) {
        if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
          f = true;
        }
      }
      if (b < i && i < d) {
        if (s[i] == '#' && s[i + 1] == '#') flag = false;
      }

      if (d < i && i < c - 1) {
        if (s[i] == '#' && s[i + 1] == '#' && i < n) flag = false;
      }
    }
    if (!f) flag = false;
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    int x, a;
    cin >> x >> a;
    if (x >= a) cout << "10" << endl;
    else cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 3636
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int max1 = 100, max2 = 100, max3 = 100, a[] = new int[9];
        for (int i = 0; i < 3; i++) {
            max1 = Math.min(max1, a[i * 3] = scanner.nextInt());
            max2 = Math.min(max2, a[i * 3 + 1] = scanner.nextInt());
            max3 = Math.min(max3, a[i * 3 + 2] = scanner.nextInt());
        }

        System.out.println((a[0] - max1 == a[1] - max2 && a[1] - max2 == a[2] - max3) &&
                (a[3] - max1 == a[4] - max2 && a[4] - max2 == a[5] - max3) &&
                (a[6] - max1 == a[7] - max2 && a[7] - max2 == a[8] - max3) ? "Yes" : "No");
    }
}

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

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

using namespace std;

using ll = long long;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string)s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) res += ", ";
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() {
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void(0)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<int> v(n + 1, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '<') v[i + 1] = v[i] + 1;
  }
  debug(v);
  ll ans = v[n];
  for (int i = n - 1; ~i; i--) {
    if (s[i] == '>') v[i] = max(v[i], v[i + 1] + 1);
    ans += v[i];
  }
  debug(v);
  cout << ans;
  return 0;
}

Measured memory_bytes: 5820
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x,y;
    cin>>n>>m;
    int a[n];
    bool b[n];
    b[0]=true;
    a[0]=1;
    for(int i=1;i<n;i++){
        a[i]=1;
        b[i]=false;
    }
    for(int i=0;i<m;i++){
        cin>>x>>y;
        x--;
        y--;
        if(b[x]==true){
            if(a[x]==1){
                b[x]=false;

            }
            
            b[y]=true;
        }
        a[x]--;
        a[y]++;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(b[i]==true){
            ans++;
        }
    }
    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    int n;
    cin>>n;
    int k;
    cin>>k;
    int b = 0;
    rep(i, k) {
        int m;
        cin>>m;
        b += 1<<m;
    }

    rep(i, 1<<n) {
        if ((i&b) != i) continue;
        cout<<i<<":"<<(i != 0 ? ' ' : '\n');
        int temp = i;
        vector<int> res;
        rep(j, n) {
            if (temp & 1) res.push_back(j);
            temp = temp >> 1;
        }
        rep(j, res.size()) cout<<res[j]<<(j != res.size() - 1 ? ' ' : '\n');
    }
}


Measured memory_bytes: 3236
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 123456
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

int n;
ll dp[123456][2];
vector <int> g[123456];

ll memo(int u, int p, int c) {
	if(dp[u][c] != -1) return dp[u][c];
	ll res = 1;
	if(c == 1) {
		for(int v : g[u]) {
			if(v == p) continue;
			res = mul(res, memo(v, u, 0));
		}
	}
	else {
		ll res0 = 1, res1 = 1;
		for(int v : g[u]) {
			if(v == p) continue;
			res0 = mul(res0, memo(v, u, 0));
			res1 = mul(res1, memo(v, u, 1));
		}
		res = add(res0, res1);
	}
	return dp[u][c] = res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i=1; i<n; i++) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	memset(dp, -1, sizeof dp);
	cout << memo(1, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 16512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {

    string s;
    cin >> s;

    const int N = s.size();

    vector<int> jun(2);
    for(auto p : s) {
        if (p == 'g') {
            jun[0]++;
        } else {
            jun[1]++;
        }
    }

    cout << (N/2)-jun[1] << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;


char dp[1<<24];
int n;
int x[24],y[24],r[24],c[24];

int square(int a){
	return a*a;
}
bool overlap(int i,int j){
	return square(x[i]-x[j])+square(y[i]-y[j]) < square(r[i]+r[j]);
}
bool top(int s,int k){
	for(int i=0;i<k;i++){
		if(s&1<<i){
			if(overlap(k,i))return false;
		}
	}
	return true;
}
int dfs(int s){
	if(dp[s]!=-1)return dp[s];
	int res=0;
	for(int i=0;i<n;i++){
		if((s&1<<i)==0 || !top(s,i))continue;
		for(int j=i+1;j<n;j++){
			if((s&1<<j)==0 || !top(s,j))continue;
			if(c[i]==c[j])res = max(res,dfs(s&~(1<<i)&~(1<<j))+2);
		}
	}
	return dp[s]=res;
}
int main(){
	while(cin>>n&&n){
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i]>>r[i]>>c[i];
		}
		memset(dp,-1,sizeof(dp));
		cout<<dfs((1<<n)-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 17552
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

class TEST{
private:
  int x,a,b;
  void input(){ cin >> x >> a >> b; }
  void calc_a(){ x -= a; }
  void calc_b(){ while(x >= b) x -= b; }
  void ans(){ cout << x << endl; }
public:
  void func(){
    input();
    calc_a();
    calc_b();
    ans();
  }
};

int main(){
  TEST test;
  test.func();
  return 0;
}

/**/

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  int K,N;cin>>K>>N;
  if(!(K&1)){
    cout << K/2;
    repeat(i,N-1){
      cout << " "<<K;
    }
    cout << endl;
    return 0;
  }
  vint ans(N);
  int r=N-1;
  for(int i=N-1;i>=0;i--){
    debug(r);
    ans[i]=(K+1)/2;
    if(!((N-1-i)&1))continue;
    if(ans[r]==1){
      ans[r]=0;
      r--;
      continue;
    }
    for(int j=N-1;j>r;j--){
      ans[j]=K;
    }
    ans[r]--;r=N-1;
  }
  cout << ans[0];
  for(int i=1;i<N&&ans[i]!=0;i++){
    cout << " "<< ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;
int p[11];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    sort(p,p+n);
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        ans += p[i];
    }
    ans += p[n-1]/2;
    cout << ans << endl;
}

Measured memory_bytes: 256