akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

/**
 * AIZU ONLINE JUDGE
 * 2700 Airport Codes
 *    2018/02/11
 */
public class Main {

    class AirPort {
        String name;
        String code;

        void calcCode() {
            String c = "";
            c += name.charAt(0);
            for(int i = 1; i < name.length(); i++) {
                if ("aiueo".indexOf(name.charAt(i - 1)) >= 0) {
                    c += name.charAt(i);
                }
            }
            code = c;
        }
    }

	// メイン return falseでおしまい
	boolean main() throws IOException {

		int[] ir = readIntArray();
		int N = ir[0];
		if (N == 0)
		    return false;

		log.printf("N = %d\n", N);

		AirPort[] list = new AirPort[N];
		for(int i = 0; i < N; i++) {
		    list[i] = new AirPort();
	        list[i].name = systemin.readLine();
	        list[i].calcCode();
	        log.printf("%s %s\n", list[i].name, list[i].code);
		}

		int res = 0;
		loop:for(int i = 0; i < N; i++) {
		    for(int j = i + 1; j < N; j++) {
		        String s0 = list[i].code;
                String s1 = list[j].code;
                if (s0.equals(s1)) {
                    res = -1;
                    break loop;
                }
                int k;
		        for(k = 0; k < s0.length() && k < s1.length(); k++) {
		            if (list[i].code.charAt(k) != list[j].code.charAt(k))
		                break;
		        }
		        k++;
		        if (k > res) {res = k;}
		    }
		}
		result.printf("%d\n", res);

		return true; // 正常終了 次へ
	}



	static long time0;

    PrintStream log;
    PrintStream result;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        result = System.out;
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

	public static void main(String[] args) throws IOException {

		int N = Integer.MAX_VALUE;
		//int N = readIntArray()[0];

		for(int i = 0; i < N; i++) {
			boolean b = instance.main();
			if (!b)
				break;
		}

        instance.systemin.close();
	}


	// 標準入力より1行分の区切り文字区切りでの整数値を読む
	// EOFの場合はnullを返す
	private int[] readIntArray() throws IOException {

		String s = null;
		for(;;) {
			s = systemin.readLine();
//			log.printf("%s\n", s);
			if (s == null)
				return null;
			s = s.trim();
			if (s.length() != 0) // 突然空行を読むことがある。読み飛ばすとうまくいくらしい。。。。
				break;
		}

		String[] sp = s.split("[ ,]"); // 区切り文字はスペースかカンマ
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}

}






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

ll dfs(bitset<15> b,int k,vector<int> &a,int now){
	ll ans=1e18;
	int n=a.size();
	if(now==n){
		if(b.count()!=k) return ans;
		ll sum{};
		int hi{a.at(0)};
		for(int i=1; i<n; i++){
			if(b.test(i)){
				if(a.at(i)<=hi) {
					sum+=hi-a.at(i)+1;
					hi++;
				}
			}
			hi = max(hi,a.at(i));
		}
		ans = sum;
	}
	else {
		ans=min(ans,dfs(b,k,a,now+1));
		b.set(now);
		ans=min(ans,dfs(b,k,a,now+1));
		b.reset(now);
	}
	return ans;
}
 
int main(){
	
	int n,k; cin>>n>>k;
	vector<int> a(n);
	for(auto &i:a) cin>>i;
	cout <<dfs(bitset<15>(),k,a,0)<<endl;
	
	
}

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

P f(int x){
  int a = x%10;
  int b = 0;
  while(x){
    b = x;
    x /= 10;
  }
  return P(a,b);
}

int main()
{
  int N;
  ll res=0;
  cin >> N;
  map<P, int> freq;
  FOR(i, 1, N){
    P p = f(i);
    freq[p]++;
  }

  FOR(i, 1, N){
    P p = f(i);
    P q = P(p.second, p.first);
    res += freq[q];
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
set<string> p;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string s;
        cin>>s;
        p.insert(s);
    }
    cout<<p.size()<<endl;
} 

Measured memory_bytes: 19204
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

int dx[] = { 0, 1, 0, -1};
int dy[] = {-1, 0, 1,  0};

int main()
{
  long long N, A, B;
  std::cin >> N >> A >> B;
  long long ans = A*(N/(A+B));
  N -= (A+B)*(N/(A+B));
  ans += (A<=N?A:N);
  std::cout << ans << std::endl;
  return 0;
}



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

using i64 = long long int;

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

    if(b < c || a > d)cout << 0 << endl;
    else cout << min(b, d) - max(a, c) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e7+9;
int main()
{
    FASTINOUT;
    int x,y;
    cin>>x>>y;
    int mn=min(x,y);
    int mx=max(x,y);
    for (int i=0;i<mx;i++)
        cout<<mn;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


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


# In[ ]:


count = 1
dis_sum = 0
for l in Ls:
    dis_sum += l
    if dis_sum > X:
        print(count)
        break
    count += 1
else:
    print(count)



Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>

using namespace std;


typedef struct{
	int a,b;
}Line;

void Change(int*n, Line*l){
	if(*n==l->a){
		*n = l->b;
	}else if(*n==l->b){
		*n = l->a;
	}
}

int main(){
	
	int w,n;
	Line *l;
	int *bottom;
	int cur;
	
	
	cin>>w;cin>>n;
	
	l=new Line[n];
	bottom=new int[w];
	
	for(int i=0;i<n;++i){
		scanf("%d,%d",&(l[i].a),&(l[i].b));
	}
	
	for(int i=0;i<w;++i){
		cur = i+1;
		
		for(int j=0;j<n;++j){
			Change(&cur,&(l[j]));
		}
		
		bottom[cur-1] = i+1;
	}
	
	for(int i=0;i<w;++i)
		cout<<bottom[i]<<endl;

	return 0;

}

Measured memory_bytes: 1240
#include <cstdio>
// A - Kth Term

using namespace std;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int K;

    scanf("%d",&K);
    printf("%d\n",a[K - 1]);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
#include<set>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

int main(void)
{
  int r;
  cin >> r;
  printf("%.4f\n", 2 * r * M_PI);
}



Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
using namespace std;

int main(){
    long long int N, K, a, f, start = 1, n = 0;
    vector<long long int> A;
    map<long long int, long long int> mp;
    cin >> N >> K;
    n = K;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(a);
    }
    int next = A[0];
    for (long long int i = 1; i <= K; i++) {
        if (next != 1 && mp[next] == 0) {
            mp[next] = i;
        } else {
            f = i - mp[next];
            n = (K - mp[next]) % f;
            start = next;
            break;
        }
        next = A[next-1];
    }
    for (int i = 0; i < n; i++) {
        start = A[start-1];
    }
    cout << start << endl;
    return 0;
}


Measured memory_bytes: 14860
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m, d, ans; ans = 0;  
	cin >> m >> d; 
	for(int i=22; i<=d; ++i){
		int d1 = i%10; 
		int d2 = i/10; 
		if(d1 >= 2 && d2 >= 2){
			int mm = d1*d2; 
			if(mm <= m) ++ans; 
		}
	}
	cout << ans << endl; 
	return 0; 
}

Measured memory_bytes: 256
from collections import deque
N,M = map(int,input().split())
A = list(map(int,input().split()))
bc = [tuple(map(int,input().split())) for _ in range(M)]
for x in A:
    bc.append((1,x))
bc.sort(key=lambda x:x[1], reverse=True)
A = []
for b,c in bc:
    while len(A) < N and b > 0:
        b -= 1
        A.append(c)
    if len(A) == N:
        break
A.sort(reverse=True)
print(sum(A))

Measured memory_bytes: 37464
import sys
import numpy as np

I = input()
J = input()
E = list(I)
O = list(J)

password = E[0] + O[0]
if len(E) == len(O):
	for i in range(1,len(O)):
		password = password + E[i] + O[i]
else:
	for i in range(1,len(O)):
		password = password + E[i] + O[i]
	password = password + E[len(E) - 1]

print(password)


Measured memory_bytes: 12500
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if(l > r) cout << "Left" << endl;
  else if(r > l) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
# define pb push_back
# define FOR(i,a,n) for(int i=a;i<n;i++)
# define mp make_pair
# define RFOR(i,a,n) for(int i=n;i>a;i--)
# define pii pair<long long int,long long int>
#define ub upper_bound
#define lb lower_bound
#define MOD 1000000007
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> vec;
	ll a;
	ll dp[3001][3001];
	for(int i=0;i<n;i++)
	{
		cin>>a;
		vec.pb(a);
	}
	
	for(int l=n-1;l>=0;l--)
	{
		for(int r=l;r<n ;r++)
		{
			if(l==r)
			dp[l][r]=vec[l];
			else
			dp[l][r]=max(vec[l]-dp[l+1][r],vec[r]-dp[l][r-1]);
		}
	}
	cout<<dp[0][n-1]<<endl;
}

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

#define forn(i,n) for(int i = 0;i<n;i++)
#define forne(i,j,n) for(int i = j;i<n;i++)
const ll mod = 1e9+7;
const ll INF = 1000000001;
const ll N = 1000001;
#define F first
#define pb(a) push_back(a)
#define S second
#define pii pair<int,int>
typedef pair<ll,ll> pll;

ll powm(ll base,ll exp) {
	ll ans=1;
	while(exp){
		if(exp&1) ans=(ans*base)%mod;
		exp>>=1,base=(base*base)%mod;
	}
	return ans;
}
// int maxdepth = INT_MAX;
// vector<int> edgeVector[100000];
// ll minans = 1;
// printf("1 %d D\n",abs(r));
// priority_queue<ll,vector<ll>,greater<ll>> pq;
ll A[N],B[N];
// vector<vector<ll>> adj(N);
// vector<set<ll>> adjs(N);
// ll adj[1001][1001];
// vector<vector<ll>> ans(1001);
// bool visited[N];
// ll cnt[1001];
// ll h,c,t;
// vector<pair<int, pair<int, int> > > g[300043];

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


ll n;
cin>>n;
ll a[n];
forn(i,n) cin>>a[i];
sort(a,a+n);
ll ans = 1;
forn(i,n){
	if(log10(ans) + log10(a[i]) > 18){
		cout<<"-1"<<endl;
		return 0;
	}
	ans*=a[i];
	if(ans > (ll)1e18){
		cout<<"-1"<<endl;
		return 0;
	}
}
cout<<ans<<endl;


}

Measured memory_bytes: 4796
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

const int MX = 1200;
const ll MOD = 1e9 + 7;

ll fc[MX];
ll bfc[MX];
ll dp[MX];
ll dp2[MX];

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while(!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD;
		--b;
	}
	return ans;
}

void init() {
	fc[0] = 1;
	for (int i = 1; i < MX; ++i)
		fc[i] = (fc[i - 1] * i) % MOD;
	for (int i = 0; i < MX; ++i)
		bfc[i] = pw(fc[i], MOD - 2);
}

ll cnk(int n, int k) {
	if (n < k)
		return 0;
	return fc[n] * bfc[k] % MOD * bfc[n - k] % MOD;
}

int n;
int a, b, c, d;
int main() {
	init();
	cin >> n >> a >> b >> c >> d;
	dp[0] = 1;
	for (int i = a; i <= b; ++i) {
		for (int j = 0; j <= n; ++j)
			dp2[j] = dp[j];
		ll bf = 1;
		ll b1 = bfc[i];
		for (int k = 1; k < c; ++k)
			bf = (bf * b1) % MOD;
		for (int k = c; k <= d; ++k) {
			bf = (bf * b1) % MOD;
			ll bk = (bf * bfc[k]) % MOD;
			int cnt = k * i;
			if (cnt > n)
				break;
			for (int j = 0; j + cnt <= n; ++j)
				dp2[j + cnt] = (dp2[j + cnt] + dp[j] * cnk(n - j, cnt) % MOD * fc[cnt] % MOD * bk) % MOD;
		}
		for (int j = 0; j <= n; ++j)
			dp[j] = dp2[j];
	}
	cout << dp[n] << "\n";
	return 0;
}




Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = input()
    q = I()
    K = LI()
    for k in K:
        fa = fb = ok = 0
        ans = 0
        for i in range(k):
            if s[i] == "D":
                fa += 1
            elif s[i] == "M":
                fb += 1
                ok += fa
            elif s[i] == "C":
                ans += ok
        for i in range(k,n):
            pi = s[i-k]
            if pi == "D":
                fa -= 1
                ok -= fb
            elif pi == "M":
                fb -= 1
            if s[i] == "D":
                fa += 1
            elif s[i] == "M":
                fb += 1
                ok += fa
            elif s[i] == "C":
                ans += ok
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 57180
#include <stdio.h>

int N,a,b;

int main()
{
	scanf ("%d",&N);
	long long s = 0, mn = 0x7fffffff; bool ed = true;
	for (int i=0;i<N;i++){
		scanf ("%d %d",&a,&b);
		s += a;

		if (a > b){
			if (mn > b)
				mn = b;
		}
		if (a != b) ed = false;
	}
	printf ("%lld\n",ed?0:s-mn);

	return 0;
}

Measured memory_bytes: 128
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
a = int(input())
x = a/1.08
if not x.is_integer():
    b = math.ceil(x)
    c = math.floor(x)
    if int(c*1.08) == a:
        print(c)
    elif int(b*1.08) == a:
        print(b)
    else:
        print(":(")
else:
    if int(x*1.08) == a:
        print(int(x))
    else:
        print(":(")

Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int a[3][3], b[3][3] = {0};
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	}
	int n;
	cin >> n;
	while (n --)
	{
		int num;
		cin >> num;
		for (int i = 0; i < 3; ++i)
		{
			for (int j = 0; j < 3; ++j)
			{
				if (num == a[i][j])
					b[i][j] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		if (b[i][0] && b[i][1] && b[i][2])
			ans = 1;
		if (b[0][i] && b[1][i] && b[2][i])
			ans = 1;
	}
	if (b[0][0] && b[1][1] &&  b[2][2])
		ans = 1;
	if (b[0][2] && b[1][1] && b[2][0])
		ans = 1;
	if (ans)
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
 
	return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    string s[2];
    for(int i = 0; i < 2; i++){
        cin >> s[i];
        s[i] = "#" + s[i];
    }
    ll dp[60][4][4] = {};
    dp[0][0][0] = 1;
    for(int now = 1; now <= N; now++){
        for(int f0 = 0; f0 <= 3; f0++){
            for(int f1 = 0; f1 <= 3; f1++){
                for(int t0 = 1; t0 <= 3; t0++){
                    for(int t1 = 1; t1 <= 3; t1++){
                        if((s[0][now] != s[1][now]) && (t0 == t1))continue;
                        if((s[0][now] == s[1][now]) && (t0 != t1))continue;
                        if((s[0][now] != s[0][now - 1]) && (f0 == t0))continue;
                        if((s[0][now] == s[0][now - 1]) && (f0 != t0))continue;
                        if((s[1][now] != s[1][now - 1]) && (f1 == t1))continue;
                        if((s[1][now] == s[1][now - 1]) && (f1 != t1))continue;
                        dp[now][t0][t1] += dp[now - 1][f0][f1];
                        dp[now][t0][t1] %= MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int t0 = 1; t0 <= 3; t0++){
        for(int t1 = 1; t1 <= 3; t1++){
            ans += dp[N][t0][t1];
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <assert.h>
#include <string>
#include <algorithm>
#include <sstream>
#include <iostream>
using namespace std;

typedef long long ll;
const int maxl = 100010;
const int mod = 1e9 + 7;

int n, t, a;
int h[maxl];

int main() {
    while (scanf("%d", &n) != EOF) {
        scanf("%d%d", &t, &a);
        int dif = 0x7f7f7f7f, idx = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%d", &h[i]);
            int tmp = abs(1000 * t - 6 * h[i] - a * 1000);
            if (idx == 0 || tmp < dif) {
                dif = tmp;
                idx = i;
            }
        }
        printf("%d\n", idx);
    }

    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, k;
  cin >> n >> k;
  vector<int>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  int cnt = 1;
  vector<int>asc(n);
  asc[0] = 1;
  for (int i = 1; i < n; i++){
    if (ar[i] > ar[i - 1]){
      cnt++;
    }
    else {
      cnt = 1;
    }
    asc[i] = cnt;
  }
  bool f = false;
  for (int i = 0; i < n; i++){
    if (asc[i] >= k){
      f = true;
    }
  }
  vector<int>mx(n), mn(n);
  set<int, greater<int> >s_max;
  set<int>s_min;
  for (int i = 0; i < n; i++){
    s_max.insert(ar[i]);
    s_min.insert(ar[i]);
    if (i - k >= 0){
      s_max.erase(s_max.find(ar[i - k]));
      s_min.erase(s_min.find(ar[i - k]));
    }
    mx[i] = *s_max.begin();
    mn[i] = *s_min.begin();
  }
  int ans = 0;
  for (int i = k - 1; i < n; i++){
    if (asc[i] >= k){
      continue;
    }
    if (i - k >= 0 && mx[i] == ar[i] && mn[i - 1] == ar[i - k]){
      continue;
    }
    ans++;
  }
  cout << (int) ans + f << "\n";
  return 0;
}


Measured memory_bytes: 22144
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Main().main();
    }

    public void main() {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] line = scanner.nextLine().split(" ", n);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(line[i]);
        }

        System.out.println(this.count(n, arr));
    }

    private int count(int n, int[] arr) {
        int result = 0;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (arr[i] % 2 != 0) {
                    return result;
                }
                arr[i] /= 2;
            }
            result++;
        }
    }
}


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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n,m;
    string s;
    cin>>n>>m>>s;
    vector<int> ans;
    int now=n;
    bool ok;

    while (now>0)
    {
        ok=false;
        int maxDeme=min(now,m);
        for (int deme = maxDeme; deme > 0; deme--)
        {
            if(s[now-deme]=='0')
            {
                now-=deme;
                ans.push_back(deme);
                ok=true;
                break;
            }
        }
        if(ok==false)
        {
            break;
        }
    }
    if(ok)
    {
        for (int i = ans.size() - 1; i >= 0; i--)
        {
            cout<<ans[i];
            if(i==0) cout<<endl;
            else cout<<" ";
        }
    }
    else
    {
        cout<<-1<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using P = pair<int64_t, int64_t>;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    map<P, int> m;
    vector<int64_t> x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            P p = {x[i] - x[j], y[i] - y[j]};
            if(p.first == 0 && p.second == 0) continue;
            if(!m.count(p)) {
                m[p] = 0;
            }
            m[p]++;
        }
    }
    int ans = N;
    for(auto i = m.begin(); i != m.end(); i++) {
        ans = min(N - i->second, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
n, k = map(int,input().split())
d = abs(n-k)
if (n <= k):
  if (n < d):
    print(n)
  else:
    print(d)
else:
  n = n - (n//k) * k
  d = abs(n-k)
  if (n < d):
    print(n)
  else:
    print(d)
  

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());

		int a=Integer.parseInt(st.nextToken());
		int b=Integer.parseInt(st.nextToken());
		int c=Integer.parseInt(st.nextToken());
		if(a<b && b<c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 24284
input()
xs = list(map(int, input().split()))

for i in range(len(xs) - 1):
    xs[i + 1] += xs[i]

res = 1 << 60
for i in range(len(xs) - 1):
    a = xs[i]
    b = xs[-1] - a
    if res > abs(a - b):
        res = abs(a - b)

print(res)


Measured memory_bytes: 24828
#include <stdio.h>
 
class Dice3{
public:
    Dice3(){
        number = new int[6];
        checkTable = new int[101];
        for(int i = 0; i < 101; i++) checkTable[i] = -1;
    };
    ~Dice3(){
        delete[] number;
        delete[] checkTable;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
        checkTable[num] = index;
    };
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isValidMember(int inputed[]){
        for(int i = 0; i < 6; i++)
        {
            if(checkTable[inputed[i]] == -1)
                return false;
        }
        return true;
    }
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* checkTable;
};
 
int main(){
    Dice3 dice3;
    int tmp,inputed[6];
    for(int i = 0; i < 6; i++){
        scanf("%d",&tmp);
        dice3.setLabel(i,tmp);
    }
    for(int i = 0; i < 6; i++) scanf("%d",&inputed[i]);
 
    if(dice3.isValidMember(inputed) && dice3.isSameDice(inputed))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}



Measured memory_bytes: 2628
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int N; int M;
	while (~scanf("%d%d", &N, &M)) {
		vector<vector<int> > g(N);
		for (int i = 0; i < M; ++ i) {
			int u, v;
			scanf("%d%d", &u, &v), -- u, -- v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		int Q;
		scanf("%d", &Q);
		const int D = 10;
		vector<vector<pair<int, int>>> paints(D + 1, vector<pii>(N, make_pair(0, 0)));
		rep(i, Q) {
			int u; int d; int c;
			scanf("%d%d%d", &u, &d, &c), -- u;
			amax(paints[d][u], make_pair(i + 1, c));
		}
		for (int d = D; d > 0; -- d) {
			rep(i, N) {
				auto p = paints[d][i];
				if (p.first == 0) continue;
				amax(paints[d - 1][i], p);
				for (int j : g[i])
					amax(paints[d - 1][j], p);
			}
		}
		rep(i, N)
			printf("%d\n", paints[0][i].second);
	}
	return 0;
}


Measured memory_bytes: 15480
<?php
fscanf(STDIN, "%d %d %d", $c11, $c12, $c13);
fscanf(STDIN, "%d %d %d", $c21, $c22, $c23);
fscanf(STDIN, "%d %d %d", $c31, $c32, $c33);

$k1 = $c11 + $c12 + $c13;
$k2 = $c21 + $c22 + $c23;
$k3 = $c31 + $c32 + $c33;
$m1 = $c11 + $c21 + $c31;
$m2 = $c12 + $c22 + $c32;
$m3 = $c13 + $c23 + $c33;
if ((($k1 - $k2) %3 !== 0) || (($k2 - $k3) %3 !== 0) || (($m1 - $m2) %3 !== 0) || (($m2 - $m3) %3 !== 0)){
    echo "No";
    return;
};
echo "Yes";
return;

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	string s;
	cin >> s;

	string ans="Yes";

	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] != 'h') {
				ans = "No";
				break;
			}
		}
		else {
			if (s[i] != 'i') {
				ans = "No";
				break;
			}
		}
	}

	if (s == "h")	ans = "No";
	if (s[s.size()-1] == 'h')	ans = "No";

	cout << ans << endl;



}

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

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long[] a = new long[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextLong();
        }
        int k = sc.nextInt();
        Arrays.sort(a);
        for (int i = 0; i < k; i++) {
            a[2] *= 2;
        }
        System.out.println(a[0] + a[1] + a[2]);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>H>>W>>M;
    vec hnum(H, 0), wnum(W, 0), h(M), w(M);
    rep(i,M){
        cin>>h[i]>>w[i];
        --h[i];
        --w[i];
        ++hnum[h[i]];
        ++wnum[w[i]];
    }
    int mh = *max_element(ALL(hnum)), mw = *max_element(ALL(wnum));
    int ans = mh + mw, num = (count(ALL(hnum), mh)) * count(ALL(wnum), mw);
    rep(i,M){
        if(hnum[h[i]] + wnum[w[i]] == mh + mw) --num;
    }
    cout<<ans - (num == 0)<<endl;
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, r;
    cin >> n >> r;
    cout << r + (n < 10 ? 100 * (10 - n) : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=2e2+5;
const ll MOD=1e9+7;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll a,b,c,k,dp[N+5][N+5][N+5];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	for(ll i=N;i>=0;i--)for(ll j=N;j>=0;j--)for(ll k=N;k>=0;k--){
		if(i==j&&j==k){dp[i][j][k]=0;continue;}
		dp[i][j][k]=1+min(dp[i+2][j][k],min(dp[i][j+2][k],dp[i][j][k+2]));
		dp[i][j][k]=min(min(dp[i][j][k],dp[i][j+1][k+1]+1),min(dp[i+1][j][k+1]+1,dp[i+1][j+1][k]+1));
	}
	cin>>a>>b>>c;
	cout<<dp[a][b][c]<<"\n";
	return 0;
}


Measured memory_bytes: 71936
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  int ans=INF;
  FOR(c,'a','z'+1){
    string now=S;
    REP(i,100){
      if(count(ALL(now),c)==now.length()){
        chmin(ans,i);
        break;
      }

      string next;
      REP(j,now.length()-1){
        if(now[j]==c||now[j+1]==c){
          next.push_back(c);
        }else{
          next.push_back(now[j]);
        }
      }
      now=next;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);

  for(i = 2;i <= n;i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
      A[j+1] = key;
    }
    trace(A,n);
  } 

  return 0;
}

Measured memory_bytes: 604
N = gets.to_i
S = []
T = []
W = []

N.times do
  w = gets.chomp
  r = 0; l = 0; 
  (0 ... w.size).each do |i|
    c = w[i]
    if c == '('
      l += 1
    elsif l > 0
      l -= 1
    else
      r += 1
    end
  end
  if l.zero? # terminate
    T << [r, l]
  elsif r.zero?
    S << [r, l] # start
  else
    W << [r, l]
  end
end
success = true

l_sum = S.inject(0){|s,(r,l)| s + l }
W.sort_by!{|r,l| r - l }
W.each do |(r,l)|
  if l_sum >= r
    l_sum = l_sum - r + l
  else
    success = false
    break
  end
end
T.each do |(r,l)|
  if l_sum >= r
    l_sum = l_sum - r + l
  else
    success = false
    break
  end
end

puts (success && l_sum.zero?) ? 'Yes' : 'No'


Measured memory_bytes: 78112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N,K;
    cin >> N >> K;
    
    ll ansa = 0;
    ll ansb = 0;
    
    for (int i = 1; i <= N; i++) {
        if (i%K == 0) {
            ansa += 1;
        }
        if (K%2 == 0) {
            if (i%K == K/2) {
                ansb += 1;
            }
        }
    }
    
    
  
    cout << ansa*ansa*ansa + ansb*ansb*ansb << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 256
N = input()
M = [map(int, raw_input().split()) for i in xrange(N)]
cache = {}
for i in xrange(N):
    cache[(i, i+1)] = 0
def dfs(left, right):
    if (left, right) in cache:
        return cache[(left, right)]
    min_cost = float("inf")
    for mid in xrange(left+1, right):
        tmp = M[left][0] * M[mid-1][1] * M[right-1][1]
        tmp += dfs(left, mid)
        tmp += dfs(mid, right)
        if min_cost > tmp:
            min_cost = tmp
    cache[(left, right)] = min_cost
    return min_cost
print dfs(0, len(M))

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

using namespace std;

int n;

vector <pair<int,int> > E;
int main() {
	scanf("%d",&n);
	if (!(n & 1)) {
		for (int i = 1;i <= n;i++){
			for (int j = i + 1;j <= n;j++){
				if (i + j != n + 1){
					E.push_back(make_pair(i , j));
				}
			}
		}
	} else {

		for (int i = 1;i <= n;i++){
			for (int j = i + 1;j <= n;j++){
				if (i + j != n){
					E.push_back(make_pair(i , j));
				}
			}
		}


	}
	printf("%d\n",(int)E.size());
	for (size_t i = 0; i < E.size(); i++) printf("%d %d\n",E[i].first,E[i].second);
	return 0;
}

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

using namespace std;

typedef vector <int> vi;

int n, m, k, c;
vector <vi> friends;
vector <vi> blocks;
vi component_ids;
vi visited;
vector < set <int> > components;

void dfs(int u)
{
    if (visited[u])
        return;

    visited[u] = 1;

    for (int i = 0; i < (int)friends[u].size(); i++)
    {
        int v = friends[u][i];
        dfs(v);
    }

    components[c].insert(u);
    component_ids[u] = c;
}

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

    int u, v;

    cin >> n >> m >> k;

    friends.assign(n+1, vi());
    blocks.assign(n+1, vi());
    visited.assign(n+1, 0);
    component_ids.assign(n+1, 0);
    components.assign(n+1, set <int>());

    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;

        friends[u].push_back(v);
        friends[v].push_back(u);
    }

    for (int i = 0; i < k; i++)
    {
        cin >> u >> v;

        blocks[u].push_back(v);
        blocks[v].push_back(u);
    }

    for (int i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            c++;
            dfs(i);
        }
    }

    for (int i = 1; i <= n; i++)
    {
        int candidates = components[component_ids[i]].size();
        candidates--;

        for (int j = 0; j < friends[i].size(); j++)
        {
            if (components[component_ids[i]].find(friends[i][j]) != components[component_ids[i]].end())
                candidates--;
        }

        for (int j = 0; j < blocks[i].size(); j++)
        {
            if (components[component_ids[i]].find(blocks[i][j]) != components[component_ids[i]].end())
                candidates--;
        }

        cout << candidates << " ";
    }

    cout << "\n";

    return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }


// MODのべき乗(n の p乗)
ll powMod(ll n, ll p)
{
	ll res = 1;
	while (p) {
		if (p & 1) (res *= n) %= MOD;
		(n *= n) %= MOD;
		p >>= 1;
	}
	return res;
}

// MODの2のべき乗
ll powMod2(ll p)
{
	return powMod(2, p);
}

// MODの逆元
ll invMod(ll n)
{
	return powMod(n, MOD - 2);
}

void Solve()
{
	ll N;
	cin >>N;
	VL A(N);
	REP(i, N) cin >> A[i];

	ll sum = accumulate(ALL(A), ll(0));
	ll ans = 0;
	REP(i, N) {
		ll sumOne = sum - A[i];
		sumOne %= MOD;
		ll ansOne = sumOne * A[i];
		ansOne %= MOD;
		ans += ansOne;
		ans %= MOD;
	}

	ans = ans * invMod(2);
	ans %= MOD;
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 4772
import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8         as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  (x : a : _) <- readInts
  print $ solve x a

solve x a | x < a     = 0
          | otherwise = 10



Measured memory_bytes: 380
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
const int N=100005;
vector<int> v[N];
int n,ans,f[N],high[N];
void dfs(int p,int fa){
	int mx=0;
	for(unsigned i=0;i<v[p].size();i++)if(v[p][i]!=fa){
		dfs(v[p][i],p);
		int t=f[p]&f[v[p][i]];
		if(t)mx=max(mx,high[t]+1); 
		f[p]|=f[v[p][i]];
	}
	while(f[p]>>mx&1)mx++;
	ans=max(ans,mx);
	f[p]|=1<<mx;
	f[p]^=f[p]&((1<<mx)-1);
	//cout<<p<<" "<<mx<<endl;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		for(int j=20;j>=0;j--)if(i>>j&1){high[i]=j; break;}
	}
	for(int i=1;i<n;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	dfs(1,0);
	cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  ll ans = 0;
  vector<int> a(s.size()+1, 0);
  repd(i, 1, s.size()+1){
    if(s[i-1] == '<'){
      a[i] = a[i-1] + 1;
    }
  }

  for(int i=s.size(); i>0; i--){
    if(s[i-1] == '>'){
      a[i-1] = max(a[i] + 1, a[i-1]);
    }
  }
  
  // rep(i, s.size()+1){
  //   cout << a[i];
  // }
  // cout << endl;
    
  rep(i, s.size()+1){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2808
n = int(input())
h = list(map(int, input().split()))
cost_m = [0]*n
for i in range(1,n):
    if i == 1:
        cost_m[i] = abs(h[1]-h[0])
    else:
        cost_m[i] = min(cost_m[i-1]+abs(h[i]-h[i-1]), cost_m[i-2]+abs(h[i]-h[i-2]))
print(cost_m[n-1])

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int k;
    string s;    
    cin >> k >> s;

    if(s.length()<=k) cout << s << "\n";
    else cout << s.substr(0,k) << "...\n";

    return 0;
}


Measured memory_bytes: 3636
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_edges3(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define endl "\n"

const ll MOD = 1000000007;

vector<pair<ll, ll> > f[1000006];
vector<ll> hsh(1000006, 0);

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    repp(i, 2, 1000000) if(f[i].size() == 0){
        f[i].pb(i, 1);
        for(auto j = 2*i; j <= 1000000; j += i){
            ll x = j, c = 0;
            while(x % i == 0) x /= i, c++;
            f[j].pb(i, c);
        }
    }

    quickio
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(auto &i : v) cin >> i;
    for(auto i : v) for(auto j : f[i]) hsh[j.ff] = max(hsh[j.ff], j.ss);
    
    ll lcm = 1, res = 0;
    repp(i, 1, 1000000) if(hsh[i]) lcm = (lcm * power(i, hsh[i])) % MOD;

    for(auto i : v) res = (res + lcm * power(i, MOD - 2)) % MOD;

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 105380
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	int D;
	cin >> D;
	cout << "Christmas";
	while (D < 25) {
		cout << " Eve";
		D++;
	}
}


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

int main(){
	string s;
	cin >> s;
	ll cnt=0,a=0;
	for (int i=0; i<s.size()-1; ++i){
		if (s[i] == 'B' and s[i+1] == 'C'){
			cnt += a;
			i++;
		}
		else if (s[i] == 'A') ++a;
		else a=0;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stack>
#include<algorithm>
using namespace std;
int t[1000][1000];
int table[1000][1000];
int L[1000][1000];
int R[1000][1000];
char y[1000];
int main(){
	int b,c;
	
	while(scanf("%d%d",&b,&c),b){
		for(int i=0;i<b;i++){
			scanf("%s",y);
			for(int j=0;j<c;j++){
				if(y[j]=='.')t[i][j]=1;
				else t[i][j]=0;
			}
		}
		for(int i=0;i<c;i++){
			int now=0;
			for(int j=0;j<b;j++){
				if(t[j][i])now++;
				else now=0;
				table[j][i]=now;
			}
		}
		for(int i=0;i<b;i++){
			stack<int> S;
			for(int j=0;j<c;j++){
				while(S.size()&&table[i][S.top()]>=table[i][j])S.pop();
				if(S.size()==0)L[i][j]=0;
				else L[i][j]=S.top()+1;
				S.push(j);
			}
			while(S.size())S.pop();
			for(int j=c-1;j>=0;j--){
				while(S.size()&&table[i][S.top()]>=table[i][j])S.pop();
				if(S.size()==0)R[i][j]=c-1;
				else R[i][j]=S.top()-1;
				S.push(j);
			}
		}
		int ret=0;
		for(int i=0;i<b;i++)
			for(int j=0;j<c;j++)
				ret=max(ret,table[i][j]*(R[i][j]-L[i][j]+1));
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 8644
import java.util.*;

class Main {


	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		for(;;){
			int w = in.nextInt(), h = in.nextInt();
			if(w==0 && h==0) break;
			int board[][] = new int[h][w];
			int dp[][] = new int[h+1][w];
			for(int i=0; i<h; i++)for(int j=0; j<w; j++) board[i][j] = in.nextInt();
			for(int j=0; j<w; j++) dp[0][j] = 1;
			for(int i=0; i<h-1; i++){
				for(int j=0; j<w; j++){
					if(board[i][j] == 0){
						if(j>0 && board[i+1][j-1] != 2) dp[i+1][j-1] += dp[i][j];
						if(j<w-1 && board[i+1][j+1] != 2) dp[i+1][j+1] += dp[i][j];
						dp[i+1][j] += dp[i][j];
					}
					else if(board[i][j] == 2){
						dp[i+2][j] += dp[i][j];
					}
				}
			}
			for(int j=0; j<w; j++)if(board[h-1][j] != 1) dp[h][j] += dp[h-1][j];
			int ans = 0;
			for(int j=0; j<w; j++) ans += dp[h][j];
			System.out.println(ans);
		}
	}

}

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

int main(){
	string segments[11] = {"0111111", "0000110", "1011011", "1001111", "1100110", "1101101", "1111101", "0100111", "1111111", "1101111", "0000000"};
	int num;
	int nowSegment;
	int input;

	while(cin >> num, num != -1){
		nowSegment = 10;
		for(int i=0; i < num; i++){
			cin >> input;
			for(int j=0; j < 7; j++){
				if(segments[nowSegment][j] == segments[input][j]) cout << 0;
				else cout << 1;
			}
			cout << endl;
			nowSegment = input;
		}
	}
}

Measured memory_bytes: 1208
n, k = map(int, input().split())
s = input()

def count_diff(a,b):
    cnt = 0
    for c1,c2 in zip(a, b):
        if c1 != c2:
            cnt += 1
    return cnt

s2 = s[1:]
cnt = count_diff(s[:-1], s2)
init = n - cnt - 1

ans = min(n-1, init + (2 * k))

print(ans)

Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>

using namespace std;


int N,M;
int h[201],m[201];
int main(void){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d %d",&h[i],&m[i]);
    }
    scanf("%d",&M);
    for(int i=0;i<M;i++){
        scanf("%d %d",&h[i+N],&m[i+N]);
    }
    int a=0,b=0;
    for(int i=0;i<N+M;i++){
        for(int j=i+1;j<N+M;j++){
            if(h[i]>h[j] || (h[i]==h[j] && m[i]>m[j])){
                swap(h[i],h[j]);
                swap(m[i],m[j]);
            }
        }
    }
    bool flag=false;
    for(int i=0;i<N+M;i++){
        if(i>0 && h[i]==h[i-1] && m[i]==m[i-1])continue;
        if(flag)printf(" ");
        printf("%d:%02d",h[i],m[i]);
        flag=true;
    }
    printf("\n");
}

Measured memory_bytes: 1048