akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    long long int x, y;
    cin >> x >> y;
    
    if (x >= 0 && abs(x) < abs(y) && y >= 0) {
        cout << y - x << endl;
    } else if (x >= 0 && abs(y) <= abs(x) && y > 0) {
        cout << 1 + (x - y) + 1 << endl;
    } else if (x >= 0 && abs(y) <= abs(x) && y <= 0) {
        cout << y + x + 1 << endl;
    } else if (x >= 0 && abs(y) > abs(x) && y <= 0) {
        cout << -y - x + 1 << endl;
    } else if (x < 0 && abs(x) <= y && y > 0) {
        cout << y + x + 1 << endl;
    } else if (x < 0 && abs(y) <= abs(x) && y > 0) { 
        cout << - y - x + 1 << endl;
    } else if (x < 0 && abs(y) < abs(x) && y <= 0) {
        cout << y - x << endl;
    } else {
        cout << 1 + (-y + x) + 1 << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n,k;
        cin>>n>>k;
        lld ar[n+1],br[n+1]={0};
        for(i=1;i<=n;i++)
            cin>>ar[i];
        vector<lld>ans;
        i=ar[1];
        while(br[i]!=1)
        {
            ans.push_back(i);
            br[i]=1;
            i=ar[i];
        }
        vector<lld>fans;
        for(j=0;j<ans.size();j++)
        {
            if(ans[j]==i)
            {
                for(lld p=j;p<ans.size();p++)
                    fans.push_back(ans[p]);
                    break;
            }
        }
        lld p=ans.size();
        if(k<=j)
            cout<<ans[k-1]<<endl;
        else
        {
            k=k-j;
            lld x=k%(fans.size());
            if(x==0)
                x=fans.size();
            cout<<fans[x-1]<<endl;
        }
    }
}



Measured memory_bytes: 10736
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, i, ans=0;
    string s[200100];
    map<string, long long> mp;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    for(auto x : mp){
        ans++;
    }
    cout << ans <<endl;
    
    return 0;
}

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

#define ll long long
#define mod 1000000007

int n;
int  dp[3005][3005];
int  t;
pair<int,int>p[3005];

int func(int pos,int tot)
{
    if(pos==n)return 0;

    if(dp[pos][tot]!=-1)return dp[pos][tot];

    int re=0,re1=0;

    if(tot+p[pos].first<t)re=p[pos].second+func(pos+1,tot+p[pos].first);
    
    else re=p[pos].second;

    re1=func(pos+1,tot);

    return dp[pos][tot]=max(re,re1);
}

int main()
{
   scanf("%d%d",&n,&t);

   memset(dp,-1,sizeof dp);

   for(int i=0;i<n;i++)
   {
       int x,y;
       scanf("%d%d",&x,&y);
       p[i]={x,y};
   }

   sort(p,p+n);

   printf("%d\n",func(0,0));

    return 0;
}


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

public class Main {
	static class FastReader{
		BufferedReader br ;
		StringTokenizer st;
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch(IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		int h = ob.nextInt();
		int n = ob.nextInt();
		int sum=0;
		for(int i=0;i<n;i++) {
			sum+=ob.nextInt();
		}
		if(sum>=h) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
				
	}

}


Measured memory_bytes: 31756
#include<stdio.h>
 
int main(void)
{
  int N;
  scanf("%d",&N);
  N=N%100;
  N=N%10;
  switch(N){
    case 1:
      printf("pon\n");
      break;
    case 2:
      printf("hon\n");
      break;
    case 3:
      printf("bon\n");
      break;
    case 4:
      printf("hon\n");
      break;
    case 5:
      printf("hon\n");
      break;
    case 6:
      printf("pon\n");
      break;  
    case 7:
      printf("hon\n");
      break;
    case 8:
      printf("pon\n");
      break;
    case 9:
      printf("hon\n");
      break;
    case 0:
      printf("pon\n");
      break;   
  }
    return 0;
  }

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


int main(){
    int64_t X,N,key_l,key_h;
    cin >> X >> N;
    vector<int64_t> p(N);
    for(int i = 0; i < N; i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());

    key_l = X;
    key_h = X;

    while(binary_search(p.begin(), p.end(), key_l) == 1 && binary_search(p.begin(), p.end(), key_h) == 1){
        key_l--;
        key_h++;
    }

    if(binary_search(p.begin(), p.end(), key_l) == 0){
        cout << key_l << endl;
    }else{
        cout << key_h << endl;
    }
}

Measured memory_bytes: 3632
import sys
from heapq import heappop, heappush
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M, S, T = rl()
graph = [[] for _ in range(N+1)] #0使わず
for _ in range(M):
    u, v, a, b = rl()
    graph[u].append((v, a, b))
    graph[v].append((u, a, b))

def dijkstra(start, mode):
    # 各地点への最小コストを返す
    INF = 10 ** 15
    dist = [INF] * (N+1) #0使わず
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, src = heappop(que)
        if dist[src] < d:
            continue
        for next_city, *cost in graph[src]:
            d1 = d + cost[mode]
            if dist[next_city] > d1:
                dist[next_city] = d1
                heappush(que, (d1, next_city))
    return dist

d_en = np.array(dijkstra(S, 0))
d_snuke = np.array(dijkstra(T, 1))
d_cost = d_en + d_snuke
answer = 10 ** 15 - np.minimum.accumulate(d_cost[::-1])[::-1][1:]
print('\n'.join(answer.astype(str)))
# 21

Measured memory_bytes: 82856
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// ここにコードを挿入
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		int t = x - (k - 1);
		if (k == 1) {
			System.out.print(x);
		} else {
			for (int i = 0; i < k + k - 1; i++) {
				System.out.println(t);
				t++;
			}
		}

	}
}

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int maxValue = max(max(A, B), C);

    int leftSum = A + B + C - maxValue;

    int sum = maxValue * pow(2, K);

    int ans = leftSum + sum;

    cout << ans << endl;

    return 0;
}


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

int main(){
  int X, Step;
  Step = 1;
  cin >> X;
  vector<int> moti(X);
  
  //配列に代入
  for(int i = 0; i < X; i++){
   cin >> moti.at(i); 
  }
  sort(moti.begin(), moti.end()); //配列を並び替え
  reverse(moti.begin(), moti.end());
  
  for(int i = 0;i < X - 1; i++){
    if(moti.at(i + 1) < moti.at(i)){
      Step++;
    }
    
  }
  cout << Step << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;

immutable long mod = 10L^^9 + 7;

void main() {
    int n; scan(n);

    auto fact = new long[](n + 1);
    auto rfact = new long[](n + 1);
    fact[0] = 1;
    foreach (i ; 1 .. n + 1) {
        fact[i] = (fact[i-1] * i) % mod;
    }
    rfact[n] = powmod(fact[n], mod - 2, mod);
    foreach_reverse (i ; 0 .. n) {
        rfact[i] = (rfact[i+1] * (i+1)) % mod;
    }
    debug {
        writeln(fact);
        writeln(rfact);
    }
    long binom(int n, int k) {
        return fact[n] * rfact[k] % mod * rfact[n-k] % mod;
    }

    long ans;
    long pre;

    foreach (k ; 0 .. n) {
        int b = n - 2 - (k - 1);
        if (b < 0 || b > k - 1) continue;
        long v = binom(k - 1, b) * fact[k] % mod * fact[n - 1 - k] % mod;
        debug {
            writeln(k, " ", v);
        }
        ans += k * (v - pre + mod) % mod;
        ans %= mod;
        pre = v;
    }

    writeln(ans);
}



long powmod(long x, long y, long mod) {
    return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 18684
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, d, a, i, j, k, ans, x, h, dd, rr, c;
	cin >> n >> d >> a;
	vector<pair<long long, long long>> v(n);
	for (i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());

	ans = 0;
	dd = 0;
	map<long long, long long> r;
	for (i = 0; i < n; i++) {
		while (!r.empty() && (r.begin()->first < v[i].first)) {
			x = r.begin()->first;
			rr = r.begin()->second;
			r.erase(r.begin()); 
			dd += rr;
		}

		if (dd >= v[i].second) continue;
		else {
			c = (v[i].second - dd + a - 1) / a;
			ans += c;
			dd += c * a;
			r[v[i].first + d + d] -= c * a;
		}
	}

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 9984
from collections import defaultdict, Counter
N = int(input())
A = list(map(int, input().split()))
count = Counter(A)
count = dict(count)
Q = int(input())
# Q回の処理を行う, i回目の操作では, 値がBiであるものを全てCiに置き換える
now = sum(A)
for _ in range(Q):
    b, c = map(int, input().split())
    if b not in count:
        print(now)
    else:
        if c not in count:
            count[c] = 0
        now += (c-b) * count[b]
        print(now)
        count[c] += count[b]
        count[b] = 0


Measured memory_bytes: 21224
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 500000

struct node
{
    int key;
    struct node* p;
    struct node *l, *r;
} typedef node;

void Insert(int);
node* Find(int);
void Delete(int);
node* Successor(int);
node* Minimum(node*);
void Print();
void Inorder(node*);
void Preorder(node*);

node *root = NULL;

int main()
{
    int i;
    int n, key;
    char order[7];

    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%s", order);
 
        if(strcmp(order, "insert") == 0)
        {
            scanf("%d", &key);
	        Insert(key);
	    }
	    if(strcmp(order, "find") == 0)
	    {
	        scanf("%d", &key);
	        if(Find(key) != NULL)
	        printf("yes\n");
	        else
	        printf("no\n");
	    }
	    if(strcmp(order, "delete") == 0)
	    {
	    	scanf("%d", &key);
	    	Delete(key);
	    }
        if(strcmp(order, "print") == 0)
        {
            Print();
        }
    }
    return 0;
}

void Insert(int key)
{
    node *x, *y, *z;

    x = root;
    y = NULL;
    z = (node*)malloc(sizeof(node));
    z->key = key;
	z->l = NULL;
	z->r = NULL;

    while(x != NULL)
    {
        y = x;
        if(z->key < x->key) x = x->l;
        else x = x->r;
    }
    z->p = y;

    if(y == NULL) 
    root = z;
    else if(z->key < y->key)
    y->l = z;
    else 
    y->r = z;
}

node* Find(key)
{
    node *x;
    
    x = root;
    
    while(x != NULL)
    {
        if(key == x->key)
        return x;

        if(key < x->key)
        x = x->l;
        else
        x = x->r;
    }
    return NULL;
}

void Delete(int key)
{
	node *x, *y, *z;
	
	z = Find(key);
	
	if(z->l == NULL || z->r == NULL)
	y = z;
	else
	y = Successor(key);
	
	if(y->l != NULL)
	x = y->l;
	else
	x = y->r;
	
	if(x != NULL)
	x->p = y->p;
	
	if(y->p == NULL)
	root = x;
	else if(y == y->p->l)
	y->p->l = x;
	else
	y->p->r = x;
	
	if(y != z)
	z->key = y->key;
}

node* Successor(int key)
{
	node *x, *y;
	
	x = Find(key);
	
	if(x->r != NULL)
	return Minimum(x->r);
	
	y = x->p;
	while(y != NULL && x == y->r)
	{
		x = y;
		y = y->p;
	}
	return y;
}

node* Minimum(node *x)
{
	while(x->l != NULL)
	{
		x = x->l;
	}
	return x;
}
    
void Print()
{
    Inorder(root);
    printf("\n");
    Preorder(root);
    printf("\n");
}
 
void Inorder(node *x)
{
    if(x == NULL) return;

    Inorder(x->l);
    
    printf(" %d", x->key);
    
    Inorder(x->r);
}

void Preorder(node *x)
{
    if(x == NULL) return;
    
    printf(" %d", x->key);

    Preorder(x->l);
    Preorder(x->r);
}

Measured memory_bytes: 19364
n, k = map(int, input().split())
l = [0]*(10**5+10)

for i in range(n):
    a, b = map(int, input().split())
    l[a] += b

sum = 0
for i in range(len(l)):
    sum += l[i]
    if sum >= k:
        print(i)
        break


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(N);
}

void solve() {
  ll n3 = N/3;
  ll n5 = N/5;
  ll n15 = N/15;
  ret = N * (N+1) / 2;
  ret -= 3 *n3 * (n3+1) / 2;
  ret -= 5 * n5 * (n5+1) / 2;
  ret += 15 * n15 * (n15+1) / 2;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  bool ok = n >= 30;
  ok();
  return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll color[200010];
vector<vector<ll> >G(200010);
bool dfs(ll v,ll c){
  color[v]=c;
  rep(i,G[v].size()){
    if(color[G[v][i]]==c)return false;
    if(color[G[v][i]]==0&&!dfs(G[v][i],-c))return false;
  }
  return true;
}
int main(){
  ll n;cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,n){
    if(color[i]==0){
      dfs(i,1);
    }
  }
  ll plus=0;
  ll minus=0;
  rep(i,n){
    if(color[i]==1)plus++;
    else minus++;
  }
  ll ans[200010];
  ll three=0,one=0,two=0;
  if(plus<=n/3){
    rep(i,n){
      if(color[i]==1){
        ans[i]=3*three+3;
        three++;
      }
      else {
        if(3*one+1<=n){
          ans[i]=3*one+1;
          one++;
        }
        else if(3*two+2<=n){
          ans[i]=3*two+2;
          two++;
        }
        else {
          ans[i]=3*three+3;
          three++;
        }
      }
    }
  }
  else if(minus<=n/3){
    rep(i,n){
      if(color[i]==-1){
        ans[i]=3*three+3;
        three++;
      }
      else {
        if(3*one+1<=n){
          ans[i]=3*one+1;
          one++;
        }
        else if(3*two+2<=n){
          ans[i]=3*two+2;
          two++;
        }
        else {
          ans[i]=3*three+3;
          three++;
        }
      }
    }
  }
  else {
    rep(i,n){
      if(color[i]==1){
        if(one*3+1<=n){
          ans[i]=one*3+1;
          one++;
        }
        else {
          ans[i]=three*3+3;
          three++;
        }
      }
      else {
        if(two*3+2<=n){
          ans[i]=two*3+2;
          two++;
        }
        else {
          ans[i]=three*3+3;
          three++;
        }
      }
    }
  }
  rep(i,n){
    cout<<ans[i];
    if(i!=n-1)cout<<" ";
    else cout<<endl;
  }
}
      
    
    
  
        


Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int c = count(s.cbegin(), s.cend(), 'o');
    
    if (c+(15-s.size())>=8){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }

}

Measured memory_bytes: 3624
#include <stdio.h>

int a[200], tmp[200];

void Refull(int n);
void Cut(int n, int k);

int main(void)
{
	int n, m;
	int i, j;
	int op;
		
	for (i = 0; i < 200; i++){
		a[i] = i + 1;
	}
	scanf("%d %d", &n, &m);
	
	for (i = 0; i < m; i++){
		for (j = 0; j < 2 * n; j++){
			tmp[j] = a[j];
		}
		scanf("%d", &op);
		if (op == 0){
			Refull(n);
		}
		else {
			Cut(n, op);
		}
	}
	
	for (i = 0; i < 2 * n; i++){
		printf("%d\n", a[i]);
	}
	
	return (0);
}

void Refull(int n)
{
	int i, j, k;
	int a_b[2][100];
	
	k = 0;
	for (i = 0; i < 2; i++){
		for (j = 0; j < n; j++){
			a_b[i][j] = a[k];
			k++;
		}
	}
	
	k = 0;
	for (i = 0; i < 2 * n; i += 2){
		a[i] = a_b[0][k];
		a[i + 1] = a_b[1][k];
		k++;
	}
}

void Cut(int n, int k)
{
	int i, j, now;
	
	now = 0;
	
	for (i = k; i < 2 * n; i++){
		a[now] = tmp[i];
		now++;
	}
	for (i = 0; i < k; i++){
		a[now] = tmp[i];
		now++;
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
int dp[3010][3010];

int main(){
	int n, time; scanf("%d %d", &n, &time);
	vector<P> a(n);
	for(int i = 0; i < n; i++) scanf("%d %d", &a[i].first, &a[i].second);
	sort(a.begin(), a.end());
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= time; j++){
			dp[i + 1][j] = dp[i][j];
			if(j - a[i].first >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - a[i].first] + a[i].second);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) ans = max(ans, dp[i][time - 1] + a[i].second);
	printf("%d\n", ans);
}

Measured memory_bytes: 38980
#include <stdio.h>

int main(void)
{
  int s;
  scanf("%d", &s);
  
  int i = 1;
  int a[1000001];
  a[0] = s;
  int ans = 0;
  int k;
  int flg = 0;
  while (i < 1000000 && flg == 0)
  {
    if (a[i - 1] % 2 == 0)
    {
      a[i] = a[i - 1] / 2;
    }
    else if (a[i - 1] % 2 == 1)
    {
      a[i] = 3 * a[i - 1] + 1;
    }
    k = 0;
    while (k < i)
    {
      if (a[k] == a[i])
      {
        ans = i + 1;
        flg = 1;
        break;
      }
      k++;
    }
    i++;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <cstring>
#include <sstream>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define sqr(x) (x)*(x)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2l(x) 64 - __builtin_clzll((x)) - 1
#define inf1 int(1e9+7)
#define inf2 0x3f3f3f3f
#define infll ll(1e18+7)
#define Pi acos(-1.0)
#define mu(x,y) trunc(exp(log((x))*(y)))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const ll MOD = inf1;
const int N = 2001;
ll n,k;
vvll Pascal(N+2,vll(N+2,0));

int main() {
    fastIO;
    //freopen(".inp","r",stdin);
    //freopen(".out","w",stdout);

    Pascal[0][1]=1;
    forw(i,1,N) {
        forw(j,1,i+2)
            Pascal[i][j]=(Pascal[i-1][j]+Pascal[i-1][j-1])%MOD;
    }
    cin >> n >> k;
    forw(i,1,k+1) {
        cout << (Pascal[n-k+1][i+1]*Pascal[k-1][i])%MOD << "\n";
    }
    return 0;
}


Measured memory_bytes: 31744
import math

n, k = map(int, input().split())

win = 0.
prob = 1 / n
for i in range(1, n + 1):
    if i >= k:
        win += prob
        continue
    board = math.log2(k) - math.log2(i)
    head = math.ceil(board)
    win += prob * (0.5 ** head)

print(win)


Measured memory_bytes: 3060
#include <stdio.h>

int main() {
  int n;
  int i;
  int data[100];
  int in;
  int temp;

  int s, g;
  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 0; i < n; i++) scanf("%d", &data[i]);
    scanf("%d", &in);

    s = 0;
    g = n-1;
    for(i = 1; ; i++) {
      temp = (s + g) / 2;
      if(data[temp] == in) break;
      if(data[temp] > in) {
	g = temp-1;
      } else if(data[temp] < in) {
	s = temp+1;
      }
      if(g-s+1 <= 0) break;
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    bool flag = true;
    vector<int> s_rule(26, -1), t_rule(26, -1);
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        if ((s_rule[s[i] - 'a'] == -1 || s_rule[s[i] - 'a'] == t[i] - 'a')
            && (t_rule[t[i] - 'a'] == -1 || t_rule[t[i] - 'a'] == s[i] - 'a')) {
            s_rule[s[i] - 'a'] = t[i] - 'a';
            t_rule[t[i] - 'a'] = s[i] - 'a';
        } else {
            flag = false;
            break;
        }
    }

    cout << (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    ll a,b; cin >> a >> b;
    cout << a/__gcd(a,b)*b << endl;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	R := float64(getInt())
	fmt.Printf("%12.12f\n", R*math.Pi*2)
}


Measured memory_bytes: 1756
#include<stdio.h>
#include<math.h>

int isprime(int a){
	
	int flag=0,i;
	if(a==1) return 0;
	for(i=2;i<=sqrt(a);i++){
		if(a%i == 0){
			flag = 1;
		}
	}
	if(flag==1){
		return 0;
	}else{
	return 1;
	}
}


int main (void){
	
	int n,time,i,sum=0;
	
	scanf("%d",&time);
	for(i=0;i<time;i++){
	scanf("%d",&n);
	sum += isprime(n);
	}
	printf("%d\n",sum);
	
return 0;
}
	
	

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
ll n,ans;
vector<ll> a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	FOR(i,0,n){
		ll k;
		cin>>k;
		a.pb(k);
	}
	SORT(a);
	FOR(i,0,n){
		ll k=NUM(a,a[i]);
		if(k-a[i]>=0)ans+=(k-a[i]);
		else ans+=k;
		i+=k;
		i--;
	}
	pri(ans);
	return 0;
}


Measured memory_bytes: 1400
// https://atcoder.jp/contests/dp/tasks/dp_n

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <limits>

using namespace std;

long long helper(const vector<vector<int>>& match, vector<unordered_map<int, long long>>& dp, int states, int idx) {
	if (idx >= match.size()) return 1;
	auto dp_itr = dp[idx].find(states);
	if (dp_itr != dp[idx].end()) return (*dp_itr).second;
	long long total = 0;
	for (int i = 0; i < match.size(); i++) {
		if (match[idx][i] == 0) continue;
		if (states & (1 << i)) continue;
		total = (total + helper(match, dp, states | (1 << i), idx + 1)) % 1000000007;
	}
	return dp[idx][states] = total;
}

int main (int argc, char* argv[]) {
	int n;
	cin >> n;

	vector<vector<int>> match(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> match[i][j];
		}
	}

	vector<unordered_map<int, long long>> dp(n);
	cout << helper(match, dp, 0, 0) << endl;
}


Measured memory_bytes: 89624
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Integer;

public class Main {

	public static void main(String[] args) throws Exception {
		String line = readLine();
		String[] strArray = line.split(" ");
		int[] array = new int[2];
		for (int i = 0; i < 2; i++) {
			array[i] = Integer.parseInt(strArray[i]);
		}

		if (array[0] <= array[1]) {
			System.out.println(array[0]);
		} else {
			System.out.println(array[0]-1);
		}

	}


	private static String readLine() throws Exception {
		BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
		return br.readLine();
	}


}

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

int main()
{
    int n;
    cin>>n;
    set<string> fruits;
    for(int i=0; i<n; i++){
    	string a;
    	cin>> a;
    	fruits.insert(a);
    }

    cout<<fruits.size();
}

Measured memory_bytes: 19184
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    cout << (1900 * m + 100 * (n - m)) * (ll)pow(2, m) << endl;
    return 0;
}


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

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int sum = 0;

    if (A >= K)
    {
        cout << K << endl;
    }
    else if (A + B >= K)
    {
        cout << A << endl;
    }
    else
    {
        cout << 2 * A + B - K << endl;
    }
}

Measured memory_bytes: 3636
n = list(input())
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9120
#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() {
	int x, t;
	cin >> x >> t;
	int ans = x - t;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m;
    long int k;
    scanf("%d %d %ld",&n,&m,&k);
    
    long int a[200000]={};
    long int as[200001]={};
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
        if(i==0){
            as[i]=0;
        }
        as[i+1]=as[i]+a[i];
        
        //printf("%d %d\n",a[i],as[i]);
    }//printf("\n");
    
    long int b[200000]={};
    long int bs[200001]={};
    for(int i=0;i<m;i++){
        scanf("%ld",&b[i]);
        if(i==0){
            bs[i]=0;
        }
        bs[i+1]=bs[i]+b[i];
        
        //printf("%d ",bs[i]);
    }//printf("\n");
    
    int num=0;
    int mo=m;
    for(int i=0;i<=n;i++){
        if(as[i]>k)break;
        
        for(int j=mo;j>=0;j--){
            if(as[i]+bs[j]<=k){
                if(i+j>num)num=i+j;
                mo=j;
                break;
            }
        }
        
    }
    
    
    printf("%d\n",num);
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int64_t x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  int64_t mvs = min(k, x / d);
  k -= mvs; x -= mvs * d;
  if(k & 1) cout << d - x << '\n';
  else cout << x << '\n';
  return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int a, b;
string s;
string ans = "";

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

  int hyphen = s.find('-');
  if (hyphen == 0 || hyphen == s.length()-1 || hyphen == -1) {
    ans = "No";
  } else {
    string s1 = s.substr(0, hyphen);
    string s2 = s.substr(hyphen+1);
    if (s1.find('-') == -1 && s1.length() == a
        && s2.find('-') == -1 && s2.length() == b) {
      ans = "Yes";
    } else {
      ans = "No";
    }
  }

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


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

int main() {
  string s, t;
  cin >> s >> t;
  int s_size = s.size(), t_size = t.size();
  vector<vector<int>> dp(s_size + 1, vector<int>(t_size + 1));
  for (int i = 1; i <= s_size; ++i) {
    for (int j = 1; j <= t_size; ++j) {
      if (s[i - 1] == t[j - 1])
        dp[i][j] = dp[i - 1][j - 1] + 1;
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }

  string ans = "";
  int i = s_size, j = t_size;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      --i;
    } else if (dp[i][j] == dp[i][j - 1]) {
      --j;
    } else {
      ans = s[i - 1] + ans;
      --i, --j;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 35584
import java.util.*;
import java.io.*;
public class Main{
    static int determine(long p[],int a){
        int low = 1;
        int high = p.length;
        while(low < high){
            int mid = (low + high)/2;
            if(p[mid] <= a)low = mid + 1;
            else high = mid;
        }
        return low - 1;
    }
    public static void main(String [] args)throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int w = Integer.parseInt(st.nextToken());
        int h = Integer.parseInt(st.nextToken());
        long ans = 0;
        long p[] = new long[w + 1];
        p[0] = 0;
        for(int i = 1;i <= w;i++){
            int a = Integer.parseInt(br.readLine());
            ans += a*1L*(h + 1);
            p[i] = a;
        }
        Arrays.sort(p);
        long var = 0;
        long temp[] = p.clone();
        for(int i = 1;i < p.length;i++)
            p[i] += p[i - 1];
        for(int i = 1;i <= h;i++){
            int a = Integer.parseInt(br.readLine());
            ans += a*1L*(w + 1);
            int pos = determine(temp,a);
            var += a*1L*pos + p[p.length - 1] - p[pos];
            //System.out.println(var + " " + pos + " " + i);
        }
        System.out.println(ans - var);
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int main(void)
{
    int N;
    cin >> N;

    string S;
    map<string, int> mp;

    REP(i,N){
        cin >> S;
        mp[S]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3520
n, y = map(int, input().split())
y = y // 1000
for a in range(n+1):
    b = (y - n - 9 * a) // 4
    c = n - a - b
    if 0 <= b and 0 <= c and a * 10 + b * 5 + c == y:
        print(a,b,c)
        exit(0)
print(-1,-1,-1)

Measured memory_bytes: 9152
#include "iostream"
using namespace std;
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int a, b;
	char cal;
	int ans;

	while(true){
		cin >> a >> cal >> b;
		if(cal == '?')
		{
			break;
		}else if(cal == '+')
		{
			ans = a + b;
		}else if (cal == '-')
		{
			ans = a - b;
		}else if (cal == '*')
		{
			ans = a * b;
		}else if (cal == '/')
		{
			ans = a / b;
		}

		printf("%d\n", ans);
	}


	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
const int N = 100000;

vector<int> G[N];

// ??°??£????????????????????????/??????
pi dp1[N];
void dfs(int v, int par)
{
    int res = 0;
    for(int nx:G[v])if(nx!=par)
    {
        dfs(nx,v);
        res += dp1[nx].fi+2;
    }

    int notback = res;
    for(int nx:G[v])if(nx!=par)
    {
        int t = res;
        t += dp1[nx].se+1 - (dp1[nx].fi+2);
        notback = min(notback,t);
    }

    dp1[v] = {res,notback};
}

int ans[N];
void dfs2(int v, int par, pi d)
{

    // v????????¨???????????????????????¨????????¨?????¨????????±?????????
    vector<pair<pi,int>> c;
    // ???????????????
    for(int nx:G[v])if(nx!=par) c.pb({dp1[nx],nx});
    // ?????????
    c.pb({d,-1});

    int C = c.size();
    // ??¨??¨?????¨?????¨???????????????????????£?????°??£?????????????????¨???????????´???????????????
    int sum = 0;
    rep(i,C) sum += c[i].fi.fi+2;

    // second????????¶?????¨????????£?????????????????????(?°?????????????????¬???????)
    // (??????,??????)
    vector<pi> gain;

    // ??????v??????????????????????¨??????????
    ans[v] = sum;
    // ????????¨?????¨???"??°?????????"??????????????¨??¢?´¢
    rep(i,C)
    {
        // "??°??£?????????"??????"??°?????????"???????????????????????¨????????£????????????????????????
        int g = c[i].fi.se+1 - (c[i].fi.fi+2);

        ans[v] = min(ans[v],sum+g);
        gain.pb({g,c[i].se});
    }

    // ??????????????¨?????¨????????± d ?????´??°????????????????????????????????????
    sort(all(gain));
    rep(i,C)
    {
        int nx = gain[i].se;
        if(nx==-1) continue;

        pi nd;
        // "??°??£?????????"???????????????????????¨?????¨?????¶??????????????°??????
        nd.fi = sum - (dp1[nx].fi+2);

        // "??°?????????"???????????????????????¨?????¨??????????????????????????????????????§???????????§??´????????????????????????
        // ??????????????????????????¨?????¨???"??°?????????"??????????????§????????????????????§?¬??????§????????¨?????????"??°?????????"??????????????????
        // ????????§???????????°??????????????¨?????¨???"??°?????????"???????????°??????
        nd.se = nd.fi;
        if(i==0)
        {
            if(C>1) nd.se += gain[1].fi;
        }
        else nd.se += gain[0].fi;

        dfs2(nx,v,nd);
    }
}

int main()
{
    int n;
    scanf(" %d", &n);
    rep(i,n-1)
    {
        int u,v;
        scanf(" %d %d", &u, &v);
        --u;
        --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    dfs(0,-1);
    dfs2(0,-1,{-2,-1});
    rep(i,n) printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 31712
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll v=0;
    ll le=0,ri=0;
    ll ans=0;
    rep(i,n){
        le=i;
        ri=max(ri,i);
        if(le==ri) v=a[le];
        while(true){
            bool ok=true;
            if(ri==n-1) break;
            rep(j,20){
                if((v>>j)%2==1 && ((a[ri+1])>>j)%2==1){
                    ok=false;
                    break;
                }
            }
            if(ok){
                ri++;
                v^=a[ri];
            }
            else break;
            if(ri==n-1) break;
        }
        //cout << v << endl;
        ans+=(ri-le)+1;
        v^=a[le];
        
    }
    cout << ans << endl;
} 


Measured memory_bytes: 1920
s=input()
n=len(s)
ans=0
currentstreak=0
numberbefore=0
legacy=0
for i in range(n):
  if s[i]=='<':
    numberbefore+=1
    ans+=numberbefore
    currentstreak=0
    legacy=numberbefore
  else:
    currentstreak+=1
    ans+=currentstreak
    if currentstreak<=legacy:
      ans-=1
    numberbefore=0
print(ans)

Measured memory_bytes: 4104
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
  int N, K;
  int ans = 0;

  cin >> N >> K;

  int p[N];

  for (int i = 0; i < N; i++)
    cin >> p[i];

  sort(p, p + N);

  for (int i = 0; i < K; i++)
    ans += p[i];

  cout << ans << endl;
}


Measured memory_bytes: 3124
N = int(input())
H = list(map(int,input().split()))
count = 1
for i in range(1,N,1):
    flag = True
    for j in range(0,i,1):
        if H[j] > H[i]:
            flag = False
            break
    if flag == True:
        count += 1
print(count)

Measured memory_bytes: 2940
from collections import *
import sys


def is_all_tarverse(start, mem, town_mem):

    if len(town_mem) == len(paths):
        return True

    for nxt in paths[start]:
        edge = frozenset((start, nxt))
        if edge in mem: continue
        if is_all_tarverse(nxt, mem | {edge}, town_mem | {nxt}):
            return True

    return False


paths = defaultdict(set)

for _ in range(3):
    a = input()
    st, dt = [int(x) for x in a.split()]
    paths[st].add(dt)
    paths[dt].add(st)


for start in paths:
    if is_all_tarverse(start, set(), {start}):
        print('YES')
        sys.exit()

print('NO')



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

int main(){
    for(int i = 0; ; i++){
        int x,y;
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        for(int j = 0; j < x; j++){
            for(int k = 0; k < y; k++){
                if(j == 0 || j == x-1 || k == 0 || k == y-1){
                    cout << '#';
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int main(){
	int H,W,N;
	cin>>H>>W>>N;
	int m=max(H,W);
	cout<<(N+m-1)/m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

const int N = 110;
const int M = 2010;

struct Edge {
	int to, cap, next;
} es[M];

int S, T;  // source, sink
int SIZE = 0; // number of edges
int h[N]; // pointer to edge list, height
int height[N]; // height (label)
int excess[N]; // excess flow
int queue[N], inque[N]; // the queue

// add forward and backtracked edge
void add(int u, int v, int cap) {
	int i = SIZE++;
	es[i].to = v;
	es[i].cap = cap;
	es[i].next = h[u];
	h[u] = i; 
	int j = SIZE++;
	es[j].to = u;
	es[j].cap = 0;
	es[j].next = h[v];
	h[v] = j; 
}

void push(int u, int idx) {
	int v = es[idx].to;
	int temp = std::min(excess[u], es[idx].cap);
	es[idx].cap -= temp;
	es[idx^1].cap += temp;
	excess[u] -= temp;
	excess[v] += temp;
}

void relabel(int u) {
	int temp = __INT_MAX__;
	for (int i = h[u]; i != -1; i = es[i].next)
		if (es[i].cap > 0)
			temp = std::min(temp, height[es[i].to]);
	height[u] = temp + 1;
}

void solve(int S, int T) {
	int front = 0, back = 0;
	for (int i = h[S]; i != -1; i = es[i].next) {
		int v = es[i].to;
		int flow = es[i].cap;
		excess[S] -= flow;
		excess[v] += flow;
		es[i].cap -= flow;
		es[i^1].cap += flow;
		if (v != T && !inque[v]) {
			queue[back++] = v;
			inque[v] = 1;
		}
	}
	while (front != back) {
		int u = queue[front];
		int m = __INT_MAX__;
		for (int i = h[u]; i != -1; i = es[i].next) {
			int v = es[i].to;
			if (es[i].cap > 0) {
				if (height[u] > height[v]) {
					push(u, i);
					if (inque[v] == 0 && v != S && v != T) {
						queue[back++] = v;
						if (back == N) back = 0;
						inque[v] = 1;
					}
				} else {
					m = std::min(m, height[v]);
				}
			} 
		}
		if (excess[u] > 0) {
			// relabel
			height[u] = m + 1;
		} else {
			front += 1;
			if (front == N) front = 0;
			inque[u] = 0;
		}
	}
}

void run() {
	int n, m, u, v, c;
	scanf("%d%d", &n, &m);
	memset(h, -1, sizeof(h));
	S = 0, T = n - 1;
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &u, &v, &c);
		add(u, v, c);
	}
	memset(height, 0, sizeof(height));
	memset(excess, 0, sizeof(excess));
	memset(inque, 0, sizeof(inque));
	height[S] = n;
	solve(S, T);
	printf("%d\n", excess[T]);
}

int main() {
	run();
}

Measured memory_bytes: 2756
import sys

for line in sys.stdin:
    n = int(line)
    debt = 100000
    for k in range(n):
        debt *= 1.05
        if debt / 1000 - int(debt) / 1000 > 0:
            debt = (int(debt) / 1000 + 1) * 1000
        else:
            debt = int(debt)
    print debt

Measured memory_bytes: 4228
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
go = [1]

while len(go) > 0:
    before = go.pop()
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            go.append(i)

for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 39572
#include <iostream>
#include <string>

int main()
{
    std::string S;
    long long K;
    std::cin >> S >> K;

    long long number = 0;
    int value;
    int ans;
    for (size_t i = 0; i < S.size(); ++i)
    {
        value = S[i] - '0';
        if (value != 1)
        {
            ans = value;
            break;
        }
        else
            ++number;
        if (number >= K)
        {
            ans = value;
            break;
        }
    }

    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// 個数の入力
		int n = int.Parse(Console.ReadLine());
		// 色入力
		string input = Console.ReadLine();
		char last = ' ';
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (last == input[i]) continue;
			last = input[i];
			count++;
		}
		//出力
		Console.WriteLine(count);
	}
}

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

using namespace std;


double dp[305][305][305];


// dp[one][two][three]
// 

int N=302;

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

    int n;
    cin>>n;
    vector<int> cnt(3+1);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        cnt[x]++;
    }

    // dp[0][0][0]=1;
    for(int three=0;three<N;three++){
        for(int two=0;two<N;two++){
            for(int one=0;one<N;one++){
    // for(int three=0;three<=cnt[3];three++){
    //     for(int two=0;two<=cnt[2];two++){
    //         for(int one=0;one<=cnt[1];one++){
                if(one+two+three == 0){
                    continue;
                }
                if(one+two+three>n){
                    continue;
                }
                dp[one][two][three]=1;
                if(one!=0){
                    dp[one][two][three]+=(dp[one-1][two][three])*((double)one/n);
                }
                if(two!=0){
                    dp[one][two][three]+=(dp[one+1][two-1][three]*((double)two/n));
                }
                if(three!=0){
                    dp[one][two][three]+=(dp[one][two+1][three-1]*((double)three/n));
                }

                int zeroes=(n-one-two-three);
                dp[one][two][three]/=(1.0 - 1.0*zeroes/(double)(n));
            }
        }
    }

    cout<<setprecision(10)<<dp[cnt[1]][cnt[2]][cnt[3]]<<endl;
}

Measured memory_bytes: 112604
#include<bits/stdc++.h>
using namespace std;
int t=0,n=0;
string s;
int main()
{
    cin>>s;
    n=s.size();
    for(int i=1;i<s.size()-1;i++)
    {
    	t++;
	}
	cout<<s[0]<<t<<s[n-1];
	return 0;
}

Measured memory_bytes: 256