akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;

int n, u, v, a, b, dist[100010];
vector<int> g[100010];

void rec1(int v, int p, int d) {
	dist[v] = d;

	for(int nv : g[v]) {
		if (nv == p) continue;
		rec1(nv, v, d + 1);
	}
}

int rec2(int v, int p, int d) {
	if (d >= dist[v]) return 0;

	int res = dist[v] - 1;
	for (int nv : g[v]) {
		if (nv == p) continue;
		res = max(res, rec2(nv, v, d + 1));
	}
	return res;
}

int main()
{
	cin >> n >> u >> v;
	--u, --v;
	for (int i = 0; i < n - 1; ++i) {
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rec1(v, -1, 0);
	cout << rec2(u, -1, 0);
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int n;
const int coin[] = {500, 100, 50, 10, 5, 1};

int main()
{
  while(cin >> n, n){
    n = 1000 - n;

    int res = 0;
    rep(k, 6){
      res += n / coin[k];
      n -= n / coin[k] * coin[k];
    }

    cout << res << endl;
  }

  return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n,m;
    cin>>n>>m;
    vector<int> k;
    vector<vector<int>> a(m);
    f1(i,0,m)
    {
        cin>>temp;
        k.pb(temp);
        f1(j,0,temp)
        {
            int z;
            cin>>z;
            a[i].pb(z);
        }
    }
    vector<int> p;
    f1(i,0,m)
    {
        cin>>temp;
        p.pb(temp);
    }
    // f1(i,0,m)
    // {
    //     f1(j,0,k[i])
    //     cout<<a[i][j]<<gp;
    //     cout<<endl;
    // }
    int ans=0;
    f1(i,0,1<<n)
    {
        int arr[n+1];
        memset(arr,0,sizeof(arr));
        f1(j,0,n)
        {
            if(i&(1<<j))
                arr[j+1]=1;
        }
        // f1(j,1,n+1)
        // cout<<arr[j]<<gp;
        // cout<<endl;
        int temp=0;
        f1(j,0,m)
        {
            int x;
            int count=0;
            f1(x,0,a[j].size())
            {
                if(arr[a[j][x]]==1)
                    count++;
            }
            if(count%2==p[j])
                temp++;
        }
        //cout<<i<<gp<<temp<<gp<<ans<<endl;
        if(temp==m)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

type Int64Slice []int64

func (p Int64Slice) Len() int           { return len(p) }
func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
func (p Int64Slice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	vals := make(Int64Slice, 0, n)
	for index := 0; index < n; index++ {
		var n int64
		fmt.Scan(&n)

		vals = append(vals, n)
	}

	take := Min(n, k)

	var max int64

	for i := 0; i <= take; i++ {
		lim := take - i
		for j := 0; j <= lim; j++ {
			var val int64
			tmpVals := make(Int64Slice, 0, take)
			drop := k - i - j

			for idx := 0; idx < i; idx++ {
				tmpVals = append(tmpVals, vals[idx])
			}

			for idx := 0; idx < j; idx++ {
				tmpVals = append(tmpVals, vals[n-idx-1])
			}

			sort.Sort(tmpVals)

			for _, item := range tmpVals {
				if drop > 0 && item < 0 {
					drop--
					continue
				}
				val += int64(item)
			}

			if val > max {
				max = val
			}
		}
	}

	fmt.Printf("%d\n", max)
}

func Min(nums ...int) int {
	if len(nums) == 0 {
		panic("function min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> vec1(n+2),vec2(m+2);
  ll sum1 = 0;
  rep(i,n){
    cin >> t1;
    sum1 += t1;
    vec1[i+1] = sum1;
  }
  vec1[0] = 0;
  vec1[n+1] = INFLONG;
  ll sum2 = 0;
  rep(i,m){
    cin >> t2;
    sum2 += t2;
    vec2[i+1] = sum2;
  }
  vec2[0] = 0;
  vec2[m+1] = INFLONG;
  ll ans = 0;
  rep(i,n+1){
    if(k - vec1[i] >= 0){
      auto itr = upper_bound(all(vec2),k-vec1[i]);
      t1 = itr - vec2.begin();
      chmax(ans,i + t1 - 1);
      //cout << i << " " << t1-1 << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6372
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<100;i++)
		for (int n=0;n<100;n++)
			if (i+n==a&&i*2+n*4==b)
			{
				cout<<"Yes";
				return 0;
			}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3636
INF=10**30
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
last=[0]*26
ans=[]
point=0
for i in range(D):
    d=i+1
    res=-INF
    z=-1
    for j in range(26):
        p=s[i][j]
        for k in range(26):
            if k==j:
                continue
            p-=c[k]*(d-last[k])
        res=max(res,p)
        if res==p:
            z=j
    ans.append(z+1)
    last[z]=i+1
    point+=res
print(*ans,sep='\n')

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

using ll = long long;

constexpr ll inf = 1e18;

int main() {
    int n, m, k; cin >> n >> m >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<vector<ll>> dp(n + 1, vector<ll>(k + 1, -inf));
    dp[0][0] = 0;
    vector<deque<pair<ll, int>>> deq(k + 1);
    deq[0].emplace_back(0, n + 1);
    for(int i = 0; i < n; ++i) {
        for(int j = k - 1; j >= 0; --j) {
            if(deq[j].empty()) continue;
            while(m < i - deq[j].front().second) deq[j].pop_front();
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], deq[j].front().first + (j + 1) * a[i]);
            while(!deq[j + 1].empty() && deq[j + 1].back().first <= dp[i + 1][j + 1]) {
                deq[j + 1].pop_back();
            }
            if(j + 1 != k) {
                deq[j + 1].emplace_back(dp[i + 1][j + 1], i);
            }
        }
        dp[i + 1][k] = max(dp[i + 1][k], dp[i][k]);
    }

    cout << dp[n][k] << endl;
}

Measured memory_bytes: 239616
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    if(SZ(s)%2)W("No");
    else{
        bool err=0;
        REP(i,SZ(s)){
            if(i%2==0){
                if(s[i]!='h')err=1;
            }
            else{
                if(s[i]!='i')err=1;
            }
        }
        W(err?"No":"Yes");
    }
    return 0;
}


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

int main(void){
 char a, b;
  cin >> a >> b;
  if(a == 'H'){
    if(b == 'H'){
    	cout << "H" << endl;
    }
    else{
    	cout << "D" << endl;
    }
  }
  else{
    if(b == 'H'){
    	cout << "D" << endl;
    }
    else{
    	cout << "H" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		b += a * 3;
		int sum = b / 2;
		System.out.println(sum);
	}	
}

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

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String s = sc.next();
        String t = sc.next();

        char[] sc = s.toCharArray();
        char[] tc = t.toCharArray();

        Arrays.sort(sc);
        Arrays.sort(tc);
        if (new StringBuilder(new String(tc)).reverse().toString()
                .compareTo(new StringBuilder(new String(sc)).toString()) <= 0) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 20820
s = input()
l = len(s)

dp = [[0, 0] for _ in range(l+1)]
dp[1][0] = 1

for i in range(2, l+1):
    if s[i-1] != s[i-2]:
        dp[i][0] = dp[i-1][0] + 1

    dp[i][0] = max(dp[i][0], dp[i-1][1] + 1)
    dp[i][1] = dp[i-2][0] + 1
    # print(dp)

print(max(dp[-1]))


Measured memory_bytes: 36400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;


		
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	a.push_back(-1);
	ll ans=1000;
	ll pre=1e18;
	for(int i=0;i<n;++i){
		if(a[i]<a[i+1]){
			pre=min(pre,a[i]);
		}
		else{
			ll rem=ans%pre;
			ll num=ans/pre;
			ans=rem+num*a[i];
			pre=a[i+1];
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main() {

	
	char s[4],t[4];

	scanf("%s", s);

	if (strlen(s) == 3) {
		t[0] = s[2];
		t[1] = s[1];
		t[2] = s[0];
		t[3] = s[3];
		printf("%s", t);
	}
	else {
		printf("%s", s);
	}

	return 0; 
}

Measured memory_bytes: 128
n = int(input())
arr = [x for x in list(map(int, input().split()))]

flag = True
count = 0
while flag:
  flag = False
  for i in reversed(range(1, len(arr))):
    if arr[i] < arr[i - 1]:
      tmp = arr[i]
      arr[i] = arr[i - 1]
      arr[i - 1] = tmp
      flag = True
      count += 1

print(" ".join([str(x) for x in arr]))
print(count)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
void dfs(){ 
  return;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b,c,k; READ a >> b >> c >> k;
  if(k<=a){
   cout << k << endl;
  }else if(k<a+b){
    cout << a << endl;
  }else{
    cout << a-(k-a-b) << endl;
  }
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A==B && B==C){
    printf("No\n");
  }else if(A==B || B==C || C==A){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

using namespace std;

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

struct st {
    int t, s, d;
};
bool b[20005];
st p[20005];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m), n) {
        rep(i, m) {
            int t, s, d; scanf("%d%d%d", &t, &s, &d);
            p[i] = {t, s, d};
        }
        sort(p, p + m, [](st a, st b){return a.t < b.t;});
        memset(b, 0, sizeof(b));
        b[1] = 1;
        rep(i, m)b[p[i].d] |= b[p[i].s];
        printf("%d\n", count(b, b+n+1, 1));
    }
}


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

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

    ll s;
    cin >> s;

    ll a = s/1000000000 + 1;
    ll b = 1000000000 - s%1000000000;

    if(s==1000000000000000000){
        cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << 0 << " " << 1000000000 << endl;
        return 0;
    }
    cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << b << " " << a << endl;


    return 0;
}

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

int main(){
  int N, W, V;
  cin >> N >> W;
  V = 0;
  static ll w[101], v[101];
  rep(i,N) {
    cin >> w[i] >> v[i];
    V += v[i];
  }
  static ll dp[101][100001];

  rep(i,N+1){
    rep(j,V+1){
      dp[i][j] = inf;
    }
  }
  dp[0][0] = 0;
  
  rep(i,N){
    rep(j,V+1){
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      if(j-v[i] < 0) continue;
      dp[i+1][j] = min(dp[i+1][j], dp[i][j-v[i]]+w[i]);
    }
  }
  
  int ans = 0;
  rep(i,N+1){
    rep(j,V+1) {
      if(dp[i][j] > W) continue;
      ans = max(ans, j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 82192
#include <stdio.h>

int main(void)
{
    int H, W;

    while(1)
    {
        scanf("%d %d", &H, &W);

        if(H == 0 && W == 0)
        {
            return 0;
        }

        int i, j;
        for(i = 0; i < H; ++i)
        {
            for(j = 0; j < W; ++j)
            {
                if(i % 2 == j % 2)
                {
                    printf("#");
                }

                else
                {
                    printf(".");
                }
            }

            printf("\n");
        }

        printf("\n");
    }
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	map<int, bool> m;
	int n[4];
	REP(i, 4){
		cin >> n[i];
		m[n[i]] = 1;
	}

	if (m[1] and m[9] and m[7] and m[4]) cout << "YES" << endl;
	else cout << "NO" << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>

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

int main(){
    int n,r;
    cin >> n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+(100*(10-n))<<endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int D, T, S;
	cin >> D >> T >> S;
	if ((D + S - 1) / S <= T) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b || (n == 1 && a != b)) cout << 0 << endl; 
    else cout << b*(n-1)+a - a*(n-1)-b + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {	
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new AOJ0034();
	}
	
	
	
	class  AOJ0155{
		int d[];
		int n;
		int x[];
		int y[];
		int ban[];
		int[][] cost;
		public AOJ0155(){
			Scanner in = new Scanner(System.in);
			while(true){
				n = in.nextInt();
				if(n==0)break;
				cost = new int[n+1][n+1];
				ban = new int[n+1];
				x = new int[n+1];
				y = new int[n+1];
				for(int i=1;i<n+1;i++){
					ban[i] = in.nextInt();
					x[i] = in.nextInt();
					y[i] = in.nextInt();
				}
				for(int i=1;i<n+1;i++){
					for(int s=i+1;s<n+1;s++){
						int x1 = x[i],y1= y[i],x2=x[s],y2=y[s];
						int costs = (int)Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));		
						cost[i][s] = costs > 50 ? 1000000:costs;
						cost[s][i] = cost[i][s];
					}
				}
				int kai = in.nextInt();
				for(int i=0;i<kai;i++){
					int s = in.nextInt();
					int g = in.nextInt();
					//ArrayList<Integer> list = dijkstra(s, g);
				}
			}
		}
	}
	
	class AOJ0034{
		int[] kyori = new int[11];
		double speed1,speed2;
		public AOJ0034() {
			Scanner in = new Scanner(System.in);
			while(in.hasNext()){
				speed1 = 0.000000;
				speed2 = 0.000000;
				String input[] = in.next().split(",");
				int sum=0;
				for(int i=1;i<=10;i++){
					kyori[i] = Integer.parseInt(input[i-1]);
					sum+=kyori[i];
				}
				speed1 = Integer.parseInt(input[10]);
				speed2 = Integer.parseInt(input[11]);
				speed1/=3600;
				speed2/=3600;
				double speed = speed1+speed2;//km/秒速を合計
				double time = sum/speed;
				int came = 0;
//				System.out.println(time+" "+speed+" "+speed*time);
				for(int i=1;i<=10;i++){
					came+=kyori[i];
					if(came>=speed1*time){
						System.out.println(i);
						break;
					}
				}
			}
		}
		
		
	}
}

Measured memory_bytes: 15308
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;

int main(void)
{
    int bingo[1000];
    int answer=0;
    vector<int> cel; //ビンゴの数、選ぶ数

    int num;
    int i,j,l,n;

    cin >> bingo[0] >> bingo[1] >> bingo[2] >> bingo[3] >>
bingo[4] >> bingo[5] >> bingo[6] >> bingo[7] >> bingo[8] ; 

    cin >> num; //何個数を選ぶか
    cel.resize(num);

    rep (i,0,num){
        cin >> cel[i];
    }

    rep (i,0,num){
        rep (j,0,9){
            if (cel[i]==bingo[j]) bingo[j]=0;
        }
    }
    if (bingo[0]+bingo[1]+bingo[2]==0) answer=1;
    else if ((bingo[3]+bingo[4]+bingo[5])==0) answer=1;
    else if ((bingo[6]+bingo[7]+bingo[8])==0) answer=1;
    else if ((bingo[0]+bingo[3]+bingo[6])==0) {answer=1;} 
    else if ((bingo[1]+bingo[4]+bingo[7])==0) answer=1;
    else if ((bingo[2]+bingo[5]+bingo[8])==0) answer=1;
    else if ((bingo[0]+bingo[4]+bingo[8])==0) answer=1;
    else if ((bingo[2]+bingo[4]+bingo[6])==0) answer=1;
    if (answer==1) cout << "Yes" << endl;
    if (answer==0) cout << "No" << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n, f = 0, g = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2)f++;
		else g++;
	}
	if (!(f % 2) && !((f / 2 + g) % 2))cout << "YES" << endl;
	else if (!(f % 2) && !(f % 2))cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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


int main() {
    ll n, a[100000], sum;
    
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }
    sum = abs(a[0]);
    for(int i = 1; i < n; i++){
        sum += abs(a[i] - a[i - 1]);
    }
    sum += abs(a[n - 1]);
    
    REP(i, n){
        if(i == 0){
            cout << sum - abs(a[i]) - abs(a[i] - a[i + 1]) + abs(a[i + 1]) << endl;
        }
        else if(i == n - 1){
            cout << sum - abs(a[i] - a[i - 1]) - abs(a[i]) + abs(a[i - 1]) << endl;
        }
        else{
            cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << endl;
        }
    }
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	public static int mod= (int) (1e9+7);
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		int n= in.nextInt();
		int m= in.nextInt();
		
		if(Math.abs(n-m)>1){
			System.out.println(0);
			return;
		}
		if(n==m){
			BigInteger res= go(n);
			res= res.multiply(go(m));
			res= res.mod(new BigInteger(""+mod));
			res= res.multiply(new BigInteger("2"));
			res= res.mod(new BigInteger(""+mod));
			System.out.println(res.toString());
			return;
		}
		BigInteger res= go(n);
		res= res.multiply(go(m));
		res= res.mod(new BigInteger(""+mod));
		System.out.println(res.toString());
	}
	public static BigInteger go(int n){
		BigInteger res= BigInteger.ONE;
		for (int i = 1; i <=n; i++) {
			res= res.multiply(new BigInteger("" + i));
			res= res.mod(new BigInteger(""+mod));
		}
		return res;
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 92952
from math import pi, cos, sqrt
def main():
    A, B, H, M = map( int, input().split())
    ans = A**2 + B**2 - 2*A*B*cos((M/60 - (H/12+M/(12*60)))*2*pi)
    print(sqrt(ans))
if __name__ == '__main__':
    main()


Measured memory_bytes: 9496
import java.util.*;
 
class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    int a= Integer.parseInt(sc.next());
    int b= Integer.parseInt(sc.next());
	int c= Integer.parseInt(sc.next());
    if((a < c && c < b) || (b < c && c < a) )
    {
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
    
} 
 
}




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

map<string, int> a;
int n, m;

int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		string st;
		cin >> st;	
		a[st]++;
	}
	cin >> m;
	for(int j = 1; j <= m; ++j)
	{
		string sl;
		cin >> sl;
		if( a[sl] > 0 ){
			a[sl]--;
		}
	}
	map <string, int>::iterator it;
	int maxn = INT_MIN;
	for(it = a.begin(); it != a.end(); ++it)
	{
		if(it->second > maxn) maxn = it->second;
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
c = list(map(lambda x:int(x)-1, input().split()))
query = []
for i in range(q):
    l, r = map(int, input().split())
    query.append((i, l-1, r-1))

class BinaryIndexedTree():
    def __init__(self, n):
        self.n = n
        self.bit = [0]*n
    
    def add(self, i, w):
        x = i+1
        while x<=self.n:
            self.bit[x-1] += w
            x += x & -x
    
    def sum(self, i):
        ret = 0
        x = i+1
        while x>0:
            ret += self.bit[x-1]
            x -= x & -x
        return ret

bit = BinaryIndexedTree(n+1)
query.sort(key=lambda x:x[2])
last = [None]*n
ans = [None]*q
nr = -1
for idx, l, r in query:
    for cr in range(nr+1, r+1):
        if last[c[cr]] is not None:
            bit.add(last[c[cr]]+1, -1)
        last[c[cr]] = cr
        bit.add(cr+1, 1)
    nr = r
    ans[idx] = bit.sum(r+1) - bit.sum(l)
for i in ans:
    print(i)

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

void Swap( int& a, int& b ){
    int tmp = std::move( a );
    a = std::move( b );
    b = std::move( tmp );
}

class Heap{
public:
    Heap( std::vector<int>& vec ) : arr( vec ){
        BuildMaxHeap();
    }

    //Getter
    int operator[]( int i ){ // returns i-th elem's key
        return arr[i];
    }

    bool HasLeft( int i ){
        return LeftIndex( i ) < arr.size();
    }

    bool HasRight( int i ){
        return RightIndex( i ) < arr.size();
    }

    int Parent( int i ){
        return arr[ParentIndex( i )];
    }

    int Right( int i ){
        return arr[RightIndex( i )];
    }

    int Left( int i ){
        return arr[LeftIndex( i )];
    }

    //Setter

private:
    int ParentIndex( int i ){ // returns i-th elem's parent's index of arr
        return i/2;
    }

    int LeftIndex( int i ){
        return 2*i;
    }

    int RightIndex( int i ){
        return 2*i+1;
    }

    void MaxHeapify( int i ){
        int left = LeftIndex( i );
        int right = RightIndex( i );
        int largest;
        if( left < arr.size() && arr[left] > arr[i] ){
            //std::cout << " arr[left] > arr[i] ";
            largest = left;
        }else{
            largest = i;
        }

        if( right < arr.size() && arr[right] > arr[largest] ){
            //std::cout << " arr[largest] > arr[i] ";
            largest = right;
        }

        if( largest != i ){
            Swap( arr[i], arr[largest] );
            MaxHeapify( largest );
        }
    }

    void BuildMaxHeap(){
        for( int i = ( arr.size()-1 ) / 2; i > 0; --i ){
            //std::cout << "build[" << i  << "] " << arr[i] << "->";
            MaxHeapify( i );
            //std::cout << arr[i] << "\n";
        }
    }

    //variables
    std::vector<int>& arr;
};

int main(){
    int n;
    std::cin.tie( 0 );
    std::cin >> n;

    std::vector<int> v = std::vector<int>( n+1 );
    for( int i = 1; i <= n; ++i ){
        std::cin >> v[i];
    }

    Heap maxheap( v );

    for( int i = 1; i <= n; ++i ){
        std::cout << " " << maxheap[i];
    }
    std::cout << "\n";
}


Measured memory_bytes: 4492
// Date: 2020-03-13

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 300 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, a[N], cnt[4];
double dp[N][N][N], vis[N][N][N];

double dfs(int a, int b, int c) {
    if(vis[a][b][c]) return dp[a][b][c];
    dp[a][b][c] = 1;
    if(a) dp[a][b][c] += 1.0*a/n*dfs(a-1, b, c);
    if(b) dp[a][b][c] += 1.0*b/n*dfs(a+1, b-1, c);
    if(c) dp[a][b][c] += 1.0*c/n*dfs(a, b+1, c-1);
    if(a+b+c < n) dp[a][b][c] /= (1.0-1.0*(n-a-b-c)/n);
    vis[a][b][c] = 1;
    return dp[a][b][c];
}

int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> a[i], cnt[a[i]]++;
    mem(dp, -1);
    dp[0][0][0] = 0; vis[0][0][0] = 1;
    cout << fixed << setprecision(10) << dfs(cnt[1], cnt[2], cnt[3]);

    return 0;
}

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

int main(){
    long long int N,Ncopy,S=0;
    cin >> N;
    Ncopy = N;
    for(long long int i = 100000000000;i>0;i=i/10){
        long long int temp1 = N/i;
        S += temp1;
        N -= temp1*i;
    }
    if(Ncopy%S == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int dxx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 }, dyy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
    int n, m;
    cin >> n >> m;
    pair<ll, ll> p[200005];
    ll l;
    vector<ll> a (n), b (m), c (m);
    rep (i, n) {
        cin >> p[i].first;
        p[i].second = 1;
        l++;
    }
    rep (i, m) {
        cin >> p[n + i].second >> p[n + i].first;
        l += p[n + i].first;
    }
    sort (p, p + n + m, greater<pair<ll, ll>>());
    ll ans = 0, now = n;
    rep (i, n) {
        if (now > p[i].second) {
            ans += p[i].first * p[i].second;
            now -= p[i].second;
        } else {
            ans += p[i].first * now;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5760
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const H=input[0].split(' ')[0]-0;
  const A=input[0].split(' ')[1]-0;
  console.log(Math.ceil(H/A));

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29580
# Fall 7, Stand 8...
# !/ankit_SM/bin/env python
from __future__ import division, print_function
import os;
import sys;
from io import BytesIO, IOBase
import math
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def main():
    k=int(input())
    s=str(input())
    if(k<len(s)):
        print(s[:k],end="...")
    else:
        print(s)





# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd,
                        max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(
                b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd,
                        max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(
                b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(
        sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 63092
N,M=map(int,input().split())
lights=[]
for i in range(M):
    k,*s=map(int,input().split())
    lights.append(list(map(lambda x:x-1,s)))
P=list(map(int,input().split()))
cnt=0
for b in range(1<<N):#bit
    #print("bit="+str(b))
    flg=True
    for m in range(M):#各bitごとに各電球を調べる
        on_cnt=0
        for switch in lights[m]:#つながってるスイッチ番号
            if (b>>switch)&1:
                on_cnt+=1
        #if on_cnt==0 or on_cnt%2 != P[m]:
        if on_cnt%2 != P[m]:
            flg=False
    if flg:
       cnt+=1
       #print(b)
print(cnt)       

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

using namespace std;

string inmap[100][100];
const int delta[3] = {-1, 0, 1};

string cnt(int i, int j) {
    int c = 0;
    for (int dh : delta) {
        for (int dw : delta) {
            if (inmap[i+dh][j+dw] == "#") c++;
        }
    }
    return to_string(c);
}

int main() {
    int H, W;
    string tmp;
    cin >> H >> W;
    for (int i=1; i<=H; i++)  {
        cin >> tmp;
        for (int j=1; j<=W; j++) {
            inmap[i][j] = tmp[j-1];
        }
    }
    for (int i=1; i<=H; i++) {
        for (int j=1; j<=W; j++) {
            if (inmap[i][j] == ".") {
                inmap[i][j] = cnt(i, j);
            }
            cout << inmap[i][j];
        }
        cout << "\n"; 
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> p(N+1);
    int c=0;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    p[N] = -1;
    for(int i=0;i<N;i++){
        if(p[i]==i+1){
            if(p[i+1]==i+2){
                i++;
            }
            c++;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3768
#include <stdio.h>
#include <stdlib.h>

long long int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

int main(void){
  long long int n,t[10001],i,ans;
  while(scanf("%lld",&n),n){
    ans=t[0]=0;
    for(i=1;i<=n;i++)
      scanf("%lld",&t[i]);
    qsort(t,n+1,sizeof(long long int),cmp);
    for(i=1;i<n;i++){
      t[i]+=t[i-1];
      ans+=t[i];
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 800
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*(b/__gcd(a,b))
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define test ll t;cin>>t;while(t--)
#define check(a) cout<<#a<<" = "<<a<<endl;
#define loop(n) for(int i=0;i<n;i++)
#define rloop(n) for(int i=n-1;i>=0;i--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fileio freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

const ll Mod = 1000000007LL;
const ll Inf = 2242545357980376863LL;
const int maxn = 2e5;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> omset;


//////////////////////// Template Ends ///////////////////////////////////


int main(){
	int a,b,c,k; cin>>a>>b>>c>>k;
	int res=0;
	while(b<=a){b*=2;res++;}
	while(c<=b){c*=2;res++;}
	if(res<=k) cout<<"Yes";
	else cout<<"No";
	return 0;
}





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

void printarray(int n, int a[])
{
    for (int i = 0;i < n;i++)
    {
        cout << a[i];
        if (i != n-1) cout << " ";
    }
    cout << endl;
    return;
}

void insertionsort(int n, int a[])
{
    int key;
    for (int i = 1;i < n;i++)
    {
        key = a[i];;
        int j = i-1;
        while(j >= 0 && a[j] > key)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        printarray(n, a);
    }
    
    return;
}

int main ()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;i++) cin >> a[i];
    
    printarray(n, a);
    insertionsort(n, a);
    
    
}


Measured memory_bytes: 3084
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

vector<int> z_algorithm(string s){
    vector<int> a((int)s.size());
    a[0] = (int)s.size();
    int i = 1, j = 0;
    while(i < (int)s.size()){
        while(i + j < (int)s.size() && s[j] == s[i + j])j++;
        a[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i + k < (int)s.size() && k + a[k] < j)a[i + k] = a[k], k++;
        i += k;
        j -= k;
    }
    return a;
}

int n;
string s;

int main(){
    cin >> n;
    cin >> s;
    int ans = 0;
    REP(i, n){
        string t = s.substr(i);
        vector<int> v = z_algorithm(t);
        REP(j, (int)v.size())ans = max(ans, min((int)j, v[j]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String T = scan.next();
    int ans = 0;
    char s[] = S.toCharArray();
    char t[] = T.toCharArray();
    for(int i=0; i<3; i++){
      if(s[i] == t[i])
        ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
# D - Various Sushi
import sys
from collections import defaultdict
import heapq

readline = sys.stdin.readline

dd = defaultdict(list)
N, K = map(int, readline().split())
for i in range(N):
    t, d = map(int, readline().split())
    heapq.heappush(dd[t], d*-1)

dd = list(dd.values())
dd.sort()

ans = 0
fix = 0
var = []
len_var = 0
sum_var = 0
tmp_max = 0

for i in range(min(K, len(dd))):
    fix += heapq.heappop(dd[i]) * -1
    for _ in range(len(dd[i])):
        tmp = heapq.heappop(dd[i]) * -1
        heapq.heappush(var, tmp)
        len_var += 1
        sum_var += tmp
    while len_var > K-(i+1) and len_var > 0:
        del_var = heapq.heappop(var)
        len_var -= 1
        sum_var -= del_var
    if len_var == K-(i+1):
        ans = max(ans , fix+sum_var + (i+1)**2)

print(ans)


Measured memory_bytes: 27812
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n);
	vector<double> tmp(n);
	double sum = 1000000;
	int number = 0;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < n; i++) {
		tmp[i] = abs(((double)t - (double)h[i] * 0.006) - (double)a);
		if (sum > tmp[i]) {
			sum = tmp[i];
			number = i + 1;
		}
	}
	cout << number << endl;
	return 0;
}

Measured memory_bytes: 384
$n=<>;for$s(f,p){$$s[$_]=[glob<>]for@@=1..$n}
$\=-5e9;
for$i(1..1023){$c=0;$c+=$p[$j=$_][grep$f[$j][$_]&$i>>$_,0..9]for@@;$\+=$-=$c-$\}
print

Measured memory_bytes: 1024
def solve():
  N, M = map(int, input().split())
  S = input()
  ans = []
  visited = [False]*(N+1)
  visited[-1] = True
  now = N
  while True:
    i = min(M,now)
    visited[now-i] = True
    while S[now-i]=='1':
      i -= 1
      if visited[now-i]==True:
        return [-1]
      visited[now-i] = True
    ans.append(i)
    if now-i==0:
      return ans[::-1]
    now -= i
print(*solve())

Measured memory_bytes: 76036
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  LL total = 0;
  for (int n = 0; n < N; ++n) {
    LL a; std::cin >> a;
    total += a - 1;
  }
  std::cout << total << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<list>
typedef long long ll;
using namespace std;
bool used[105] = { false };
ll a[105] = { 0 };
ll dp[105];
int main() {
	ll n, num = 0;
	cin >> n;
	for (ll i = 1;i <= n;i++)used[i] = false;
	for (ll i = 1;i <= n;i++)dp[i] = 0;
	for (ll i = 1;i <= n;i++)cin >> a[i];
	dp[0] = 0;
	for (ll i = 1;i <= n;i++) {
		bool flag = false;
		for (ll j = 1;j <= n;j++) {
			if (!used[j]&&((dp[i - 1] + a[j]) % 10 != 0)) {
				if (dp[i - 1] + a[j] > dp[i]) {
					dp[i] = dp[i - 1] + a[j];
					num = j;
					flag = true;
				}
			}
		}
		if (!flag) {
			dp[i] = dp[i - 1];
		}
		else used[num] = true;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 256