akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib> 

using namespace std;

int main() {
	int a,b;
	cin >>a>>b;
	if(a==b) cout <<"Draw";
	else if (a==1) cout << "Alice";
	else if (b==1) cout << "Bob";
	else if (a>b) cout << "Alice";
	else if (a<b) cout << "Bob";
	
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {
	
	int r, b, w, g;
	cin >> r >> b >> w >> g;
	cout << r + b + w + g << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main (void){

int a,b,c,d;

scanf("%d %d %d",&a,&b,&c);

if(a>c)

{

d=a;

a=c;

c=d;

}

if(a>b)

{

d=a;

a=b;

b=d;




}

if(b>c)

{

d=b;

b=c;

c=d;

}

printf("%d %d %d\n",a,b,c);

return 0;

}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static final int MOD = 1000000007;


	static int ans = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n-1];
		for(int i= 0;i < n;i++){
			a[i] = sc.nextInt()-1;
		}
		for(int i= 0;i < n;i++){
			b[i] = sc.nextInt();
		}
		for(int i= 0;i < n-1;i++){
			c[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0;i < n;i++){
			ans += b[a[i]];
			if(i < n - 1 && a[i + 1] == a[i] + 1){
				ans += c[a[i]];
			}
		}
		
		System.out.println(ans);









	}
	
	
	static void sieve(ArrayList<Long> list){
		int n = 50000000;
		boolean[] is_prime = new boolean[n+1];
		int[] prime = new int[n];
		for(int i= 0;i <=n;i++){
			is_prime[i] = true;
		}
		list.add((long) 1);
		for(int i = 2;i <= n;i++){
			if(is_prime[i]){
				list.add((long)i);
				for(int j = 2*i;j <= n;j+=i){
					is_prime[j] = false;
				}
			}
		}



	}




	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class Town{
	int index;
	int x ;
	int y;
	public Town(int index,int x,int y) {
		this.index = index;
		this.x = x;
		this.y = y;
		// TODO 自動生成されたコンストラクター・スタブ
	}


}


class Edge extends ArrayList<P>{

}

class P{
	int to;
	long cost;
	P(int to,long cost){
		this.to = to;
		this.cost = cost;
	}
}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   from- otherpair.from;
	}








}






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

int min(int T[3][3]){
    int m = 100000;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if(T[i][j] < m){
                m = T[i][j];
            }
        }
    }
    return m;
}

int main(){
    int A[3];
    scanf("%d%d%d",&A[0],&A[1],&A[2]);
    int T[3][3];
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){            
            if(i != j){
                for(int l = 0;l < 3;l++){
                    if(l != i && l != j){
                        T[i][j] = abs(A[i] - A[j]) + abs(A[j] - A[l]);
                    }
                }
             }else{
                T[i][j] = 100000;
            }
        }
    }
    printf("%d\n",min(T));
    return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

ll n , k , a[N];

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;
    for(int i=1; i<=n; i++)
        cin >> a[i];

    ll ans = 1e18 , mn , mx , tmp;
    for(int i=1; i+k-1<=n; i++)
    {
        if (a[i] <= 0 && a[i+k-1] <= 0)
        {
            ans = min(ans , abs(a[i]));
        }
        else if (a[i] >= 0 && a[i+k-1] >= 0)
        {
            ans = min(ans , a[i+k-1]);
        }
        else
        {
            mn = min(abs(a[i]) , a[i+k-1]);
            mx = max(abs(a[i]) , a[i+k-1]);
            tmp = 2*mn + mx;
            ans = min(ans , tmp);
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    lld ans = 0;
    rep(i, 1, n + 1)
    {
        int exp = 0;
        ll tmp = i;

        while (tmp < k)
        {
            exp++;
            tmp *= 2;
        }
        ans += powl(0.5, exp) / (lld)n;
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int n,x[100],y[100],h[100];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];
	for(int cx=0;cx<=100;cx++)
	{
		for(int cy=0;cy<=100;cy++)
		{
			int H;
			for(int i=0;i<n;i++)
			{
				if(h[i])
				{
					H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
					break;
				}
			}
			bool flag=1;
			for(int i=0;i<n;i++)
			{
				flag&=h[i]==max(H-abs(x[i]-cx)-abs(y[i]-cy),0);
			}
			if(flag)
			{
				cout<<cx<<" "<<cy<<" "<<H<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define rrp(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}

const int N = 20;
struct edge {
  int a,b,v;
};
vector<edge> vec;
int n, l, val[N + 10];
int main() {
  read(l);
  n = N;
  val[n] = 1;
  for (int i = n - 1, j = 1 ; i >= 2 ; -- i, j <<= 1) {
    vec.push_back((edge) {i, i+1, 0});
    vec.push_back((edge) {i, i+1, j});
    val[i] = j << 1;
  }
  int cur = 0;
  rep (i, 2, n) while (cur + val[i] <= l) {
    vec.push_back((edge) {1, i, cur});
    cur += val[i];
  }
  printf("%d %d\n", n, (int)vec.size());
  for (int i = 0 ; i < (int)vec.size() ; ++ i)
    printf("%d %d %d\n", vec[i].a, vec[i].b, vec[i].v);
  return 0;
}


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

int main(void){
   long long N,H,W;
   cin>>N>>H>>W;
   vector<long long> A(N),B(N);
   for(int i=0;i<N;i++){
      cin>>A[i]>>B[i];
   }
   long long ans=0;
   for(int i=0;i<N;i++){
      if(A[i]>=H&&B[i]>=W) ans++;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define SZ(a) ((int)a.size())
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

int n;
set<string> ss;
vector<string> vs;

bool solve() {
	ss.insert(vs[0]);
	forab (i, 1, n) {
		string sa = vs[i - 1];
		string sb = vs[i];
		if (sa[SZ(sa) - 1] != sb[0]) {
			return false;
		}
		if (ss.find(sb) != ss.end()) {
			return false;
		}
		ss.insert(sb);
	}
	return true;
}

int main(int argc, char *argv[]) {
	char tmp[20];
	while (scanf("%d", &n) != EOF) {
		ss.clear();
		vs.clear();
		forn (i, n) {
			scanf("%s", tmp);
			vs.push_back(tmp);
		}
		bool ret = solve();
		if (ret) {
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

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

using namespace std;

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

void divisor(int n, vector<int>& vec){
  for(int i=1;i*i<=n;i++){
    if(n % i == 0){
      vec.push_back(i);
      if(i != n / i) vec.push_back(n / i);
    }
  }
}

main(){
  int n, in[3];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> in[i];
  }
  vector<int> ans;
  if(n == 2) divisor(gcd(in[0], in[1]), ans);
  else divisor(gcd(in[0], gcd(in[1], in[2])), ans);
  sort(ans.begin(), ans.end());
  for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
using namespace std;
int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int min = INT_MAX;
  int max_mix = max(X, Y)*2;
  for(int i = 0; i <= max_mix; i+=2){
    int a_p = 0, b_p = 0;
    if(X-i/2 >= 0) a_p = X-i/2;
    if(Y-i/2 >= 0) b_p = Y-i/2;
    int price = A * a_p + B * b_p + C * i;
    if( price < min ) min = price;
  }

  cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

std::vector<bool> IsPrime0;
std::vector<bool> IsPrime1;

void sieve(size_t max){
    if(max+1 > IsPrime0.size()){     // resizeで要素数が減らないように
        IsPrime0.resize(max+1,true); // IsPrimeに必要な要素数を確保
        IsPrime1.resize(max+1,false);
    }
    IsPrime0[0] = false; // 0は素数ではない
    IsPrime0[1] = false; // 1は素数ではない
    for(size_t i=2; i*i<=max; ++i){ // 0からsqrt(max)まで調べる
        if(IsPrime0[i]){ // iが素数ならば
            for(size_t j=2; i*j<=max; ++j){ // (max以下の)iの倍数は
                IsPrime0[i*j] = false;      // 素数ではない
            }
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    sieve(100000);
    REPS(i,100000){
        if(IsPrime0[(i+1)/2]&&IsPrime0[i])IsPrime1[i] = 1;
    }
    vector<int> A(100001);
    REPS(i,100000){
        A[i] = A[i-1] + IsPrime1[i];
    }
    int Q = in();
    REP(i,Q){
        int l = in(),r = in();
        cout << A[r] - A[l-1] << "\n";
    }
}

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

using namespace std;

int main(){

	int n;
	int field[6][6];
	cin>>n;
	for(int l = 0; l < n; l++){
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 5; j++){
				cin>>field[i][j];
			}
		}
		int maxCnt=0;
		for(int minx = 0; minx < 5; minx++){
			for(int miny=0;miny < 5;miny++){
				for(int maxx = 0; maxx < 5; maxx++){
					for(int maxy=0;maxy<5;maxy++){
						int cnt=0;
						bool f=false;
						for(int i = minx; i <= maxx; i++){
							for(int j = miny; j <= maxy; j++){
								if(field[i][j])
									cnt++;
								else{
									f=true;
									break;
								}
							}
							if(f)
								break;
						}
						if(!f)
							maxCnt=max(maxCnt,cnt);
					}
				}
			}
		}
		cout<<maxCnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#define rep(i,n) for(lint (i) = 0;(i) < (n);(i)++)
#define INF (1000005)
#define SZ 1030
#define BS 515
#define MAX(a,b) (a)<(b)?(b):(a)
using namespace std;
typedef long long int lint;
int go[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int dw[3][2]={{1,-1},{1,0},{1,1}};

int site[1000000+5][2];
int prime[1000000+5];
lint mp[SZ][SZ]={0};

int main(){
    int m,n;
    rep(i,1000000+5){
        prime[i]=-1;
    }
    prime[0]=0;
    prime[1]=0;
    int now = 2;
    while(now<1000000+5){
        if(prime[now]==0){
            now++;
            continue;
        }
        prime[now]=1;
        lint temp = now*2;
        while(temp<1000000+5){
            prime[temp]=0;
            temp+=now;
        }
        now++;
    }
    prime[1]=0;
    rep(i,SZ){
        rep(j,SZ){
            mp[i][j]=INF;
        }
    }
    int at[2]={BS,BS};

    int dir=0;
    for(int i = 1;i <= 1000000;i++){
        mp[at[0]][at[1]]=i;
        site[i][0]=at[0];
        site[i][1]=at[1];
        int ndir = (dir+ 1)%4;
        if(mp[at[0]+go[ndir][0]][at[1]+go[ndir][1]]==INF){at[0]+=go[ndir][0];at[1]+=go[ndir][1];dir = ndir;}
        else{
            at[0]+=go[dir][0];
            at[1]+=go[dir][1];
        }
    }
    while(cin>>m>>n&&m){
        int dp[SZ][SZ];
        rep(i,SZ){
            rep(j,SZ){
                dp[i][j]=-1;
            }
        }
        
        dp[site[n][0]][site[n][1]]=prime[n];
        for(int i=0;i<SZ-1;i++){
            for(int j=1;j<SZ-1;j++){
                rep(k,3){
                    int hoge[2] = {i+dw[k][0],j+dw[k][1]};
                    
                    if(mp[i][j]<=m&&mp[hoge[0]][hoge[1]]<=m&&dp[i][j]!=-1){
                        dp[hoge[0]][hoge[1]]=MAX(dp[hoge[0]][hoge[1]],dp[i][j]+prime[mp[hoge[0]][hoge[1]]]);
                    }
                }
            }
        }/*
          for(int x = -10;x < 10;x++){
          for(int y = -10;y < 10;y++){
          printf("%5d", dp[BS+x][BS+y]);
          }
          cout << endl;
          }
          for(int x = -10;x < 10;x++){
          for(int y = -10;y < 10;y++){
          printf("%5d", prime[mp[BS+x][BS+y]]);
          }
          cout << endl;
          }
          for(int x = -10;x < 10;x++){
          for(int y = -10;y < 10;y++){
          printf("%ll", mp[BS+x][BS+y]);
          }
          cout << endl;
          }*/
        lint retp = 0;
        lint ret = 0;
        for(int i = m;i >= 1;i--){
            int sx = site[i][0],sy=site[i][1];
            if(prime[i]&&dp[sx][sy]>0&&ret<dp[sx][sy]){
                ret = dp[sx][sy];
                retp = i;
            }
        }
        cout << ret <<  " " << retp << endl;
        
    }
}

Measured memory_bytes: 25312
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()

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

const int SZ = 100000;
 int dp[SZ];

int solve(vector<int> a, int v)
{
    fill(dp, dp + SZ, 0);
    int b = 30000;
    dp[0 + b] = 1;
    for (int m : a)
    {
        vector<int> cr;
        for (int i = -b; i <= b; i++)
        {
            if (dp[i + b] == 0) continue;
            cr.pb(i + m + b); cr.pb(i - m + b);
        }
        for (int i = -b; i <= b; i++)
            dp[i + b] = 0;
        for (int p : cr)
            dp[p] = 1;
    }
    return dp[v + b];
}

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    int fx, fy;
    cin >> s >> fx >> fy;
    int n = s.size();
    vector<vector<int>> mv(2);
    int i = 0;

    while (i < s.size() && s[i] == 'F')
    {
        i++;
        fx--;
    }

    int c = 0, cn = 0;
    for (; i < n; i++)
    {
        if (s[i] == 'T')
        {
            mv[c].push_back(cn);
            c = (c + 1) % 2;
            cn = 0;
            continue;
        }
        cn++;
        if (i == n - 1)
            mv[c].push_back(cn);
    }
    if (solve(mv[0], fx) && solve(mv[1], fy))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 768
s=int(input())
t=1 if s>=3 else 0
M=10**9+7
S=[1]+[0]*2000

def cmb(n,r):
  c,m=1,1
  for i in range(1,r+1):
    c=c*(n-i+1)%M
    m=m*i%M
  return c*pow(m,M-2,M)%M

for i in range(2,s//3+1):
  t=(t+cmb(s-2*i-1,i-1))%M

print(t)


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

int main(int argc, char const *argv[]) {
  ll N,K; cin>>N>>K;
  ll sum = 0;

  if (K == 0) {
    cout << N * N << "\n";
    return 0;
  }

  for (ll b = K + 1; b <= N; b++) {
    sum += (b - K) * (N / b);
    int rem = N % b;
    if(rem >= K) {
      sum += (rem - K + 1);
    }
  }
  cout << sum << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
using namespace std;

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

	int N, temp;
	cin >> N;
	vector<pair<int, int>> stu(N);

	REP(i, N)
	{
		cin >> temp;
		stu[i] = make_pair(temp, i + 1);
	}

	sort(stu.begin(), stu.end());

	REP(i, N)
	{
		cout << stu[i].second;
		if (i != N - 1)
			cout << ' ';
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;

int min(int a,int b){return (a<b)?a:b;}

int main(){
	string s;
	int k,n;
	cin>>s>>k;
	vector<string> vec;
	set<string> st;
	rep(i,s.size()){
		for(int j=i;j<min(s.size(),i+k);j++){
			string next=s.substr(i,j-i+1);
			if(st.find(next)!=st.end())continue;
			vec.pb(s.substr(i,j-i+1));
			st.insert(next);
		}
	}
	sort(all(vec));
	cout<<vec[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 2432
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        
        cin = new Scanner();
        int[] input = cin.arrayInt(2);
        int n = input[0];
        int m = input[1];
        int[][] ka = new int[n][];
        for(int a = 0; a < n; a++)
        {
            ka[a] = ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        }
        int count = 0;
        for (int a = 0; a < m; a++)
        {
            for(int b = 0; b < n; b++)
            {
                
                if (!contain(ka[b],a + 1)) break;
                if (b == n - 1) count++;
            }
            

        }
        WriteLine(count);

    }
    static bool contain(int[] array,int key)
    {
        for(int a = 1;a< array.Length; a++)
        {
            if (array[a] == key) return true;
        }
        return false;
    }
    static int CountChar(string s,string key)
    {
        return s.Length - s.Replace(key, "").Length;
    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string input()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return input();
        i = 0;
        return s[i++];
    }

    public int inputInt()
    {
        return int.Parse(input());
    }
    public int[] arrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputInt() + add;
        }
        return Array;
    }

    public long inputLong()
    {
        return long.Parse(input());
    }

    public long[] arrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputLong() + add;
        }
        return Array;
    }

    public double inputDouble()
    {
        return double.Parse(input());
    }


    public double[] arrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputDouble() + add;
        }
        return Array;
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let mut x: u64 = read();

	let ure_1000 = x / 500;
	x %= 500;
	let ure_5 = x / 5;

	let ans = ure_1000 * 1000 + ure_5 * 5;
	println!("{}", ans);
}


Measured memory_bytes: 4352
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	REP(i,n)cin>>a[i];
	REP(i,n)cin>>b[i];
	priority_queue<ll> q;
	ll s1=0,s2=0;
	REP(i,n){
		if(a[i]>b[i]){
			s1+=a[i]-b[i];
		}else if(a[i]<b[i]){
			s2+=(b[i]-a[i])/2;
		}
	}
	if(s1<=s2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}




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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    ll sum = 0;
    vll a(n);
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    ll ssum = 0;
    ll mn = INF;
    rep(i, n-1){
        ssum += a[i];
        mn = min(mn, abs((sum-ssum)-ssum));
    }

    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

char S[10];

int main(){
  int a, b;
  cin >> a >> b;
  int c = min(a, b) + '0';
  int d = max(a, b);
  // rep(i, 10) S[i] = 0;
  rep(i, d) S[i] = c;
  cout << S << endl;
}


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

int main() {
    int n,k;
    int ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int buf;
        cin >> buf;
        if(buf >= k)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> ii;
int main(){
  int n, m;
  cin >> n >> m;
  vector<ii>a(n), b(m);
  for(int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second;
  for(int j = 0; j < m; j++)
    cin >> b[j].first >> b[j].second;
  for(int i = 0; i < n; i++){
    ii ans = {LLONG_MAX, -1};
    for(int j = 0; j < m; j++){
      ans = min(ans,{abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second),j + 1});
    }
    cout << ans.second << '\n';
  }


}


Measured memory_bytes: 256
k, n = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))

total = k

minimum = 10000000000000
for i in range(n):
    if i == 0:
        dist = total - ((k - as_[-1]) + as_[0])
    else:
        dist = total - (as_[i] - as_[i - 1])

    minimum = min(minimum, dist)

print(minimum)


Measured memory_bytes: 26060
import math

def main():
    N, K = map(int, input().split())
    prob = 0
    for i in range(1, N+1):
        if K / i <= 1:
            prob += 1
        else:
            coin = math.ceil(math.log2(K / i))
            prob += 0.5 ** coin
    print(prob / N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64504
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=2*1e5;
const LL INF=1LL<<60;
const LL p=7+1e9;
LL N,M,s,t,a,b,d[SIZE];
LL DP[SIZE];
Vpr edges[SIZE];
LL solve(){
	cin >> N >> M >> s >> t;

	FOR(i,1,N+1){
		cin >> d[i];
		edges[i].PB(pr(0,i-1));
		if(i==s) DP[i]=0;
		else DP[i]=INF;
	}
	PQ qu;
	REP(i,M){
		cin >> a >> b;
		edges[a].PB(pr(d[b],b));
	}
	qu.push(pr(0,s));
	while(!qu.empty()){
		int now=qu.top().second,dists=qu.top().first;
		qu.pop();
		if(dists>DP[now]) continue;
		REP(i,edges[now].size()){
			int next=edges[now][i].second;
			int ndist=dists+edges[now][i].first;
			if(DP[next]>ndist){
				DP[next]=ndist;
				qu.push(pr(ndist,next));
			}
		}
	}
	return DP[t];
}
int main(){
	cout << solve() << endl;
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    int k=a[n-1];
    double mid=1.0*a[n-1]/2;
    int l=lower_bound(a.begin(),a.end(),mid)-a.begin();
    if ((l>0 && mid-a[l-1]<a[l]-mid) || l==n-1) l--;
    cout << k << ' ' << a[l] << endl;
}

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

int main(){
  while(1){
    int N,M;
    int t[101]={};
    cin>>N>>M;

    if(N==0)
      break;

    for(int i=0;i<N;i++){
      int d,v;
      cin>>d>>v;
      t[d]=max(t[d],v);
    }

    int ans=0;
    for(int i=1;i<=M;i++){
      ans+=t[i];
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3012
#include<stdio.h>

int main()
{
  	long long int a,b,k ;

	 scanf ("%lld%lld%lld",&a,&b,&k);
	 if (a>=k){
      printf("%lld %lld",a-k,b);
	 }
	 else if (a<=k && a+b>=k){
        printf("0 ");
         printf("%lld",(b-(k-a)));
	 }

	 else if (a+b<=k)
	 printf("0 0");


	 }


Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][] e=new int[m][3];
        long[][][] warshall=new long[n+1][n][n];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                warshall[0][i][j]=Integer.MAX_VALUE;
            }
        }
        for(int i=0;i<m;i++){
            for(int j=0;j<3;j++){
                e[i][j]=sc.nextInt();
            }
            warshall[0][e[i][0]-1][e[i][1]-1]=warshall[0][e[i][1]-1][e[i][0]-1]=e[i][2];
        }
        for(int i=1;i<n+1;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    warshall[i][j][k]=Math.min(warshall[i-1][j][k],warshall[i-1][j][i-1]+warshall[i-1][i-1][k]);
                }
            }
        }
        int ans=0;
        for(int i=0;i<m;i++){
            if(warshall[n][e[i][0]-1][e[i][1]-1]<e[i][2]){
                ans++;
            }
        }
        System.out.println(ans);
    }

    
}

Measured memory_bytes: 32440
program test
implicit none

character(len=100000) :: s
integer(8) :: l,temp,ans=0,big=1000000007,ruijyo(0:100000)
integer(8) :: i,j,k,a(100000)=0,b(100000)=0,c(100000)=0,q(100000)=0
integer(8) :: ax(0:100001)=0, qx(0:100001)=0
integer(8) :: cy(0:100001)=0, qy(0:100001)=0

read(*,*) s

ruijyo(0)=1
do i=1,100000
	ruijyo(i) = mod(ruijyo(i-1)*3,big)
enddo


l = len_trim(s)

do i=1,l
	if(s(i:i)=="A") then
		a(i) = 1
	else if(s(i:i)=="B") then
		b(i) = 1
	else if(s(i:i)=="C") then
		c(i) = 1
	else
		q(i) = 1
	endif
enddo

!累積
do i=1,l
	ax(i) = ax(i-1) + a(i)
	qx(i) = qx(i-1) + q(i)
enddo

do i=l,1,-1
	cy(i) = cy(i+1) + c(i)
	qy(i) = qy(i+1) + q(i)
enddo

do i=2,l-1
	if(b(i)==1 .or. q(i)==1) then
		temp = 0
		temp = temp + (ax(i-1))*(cy(i+1))*ruijyo(qx(i-1)+qy(i+1))
		temp = temp + (qx(i-1))*(cy(i+1))*ruijyo(max(0,qx(i-1)+qy(i+1)-1))
		temp = temp + (ax(i-1))*(qy(i+1))*ruijyo(max(0,qx(i-1)+qy(i+1)-1))
		temp = temp + (qx(i-1))*(qy(i+1))*ruijyo(max(0,qx(i-1)+qy(i+1)-2))
		ans = ans + mod(temp,big)
	endif
enddo

write(*,*) mod(ans,big)


end program

Measured memory_bytes: 7588
#pragma target("avx2")
#pragma target("Ofast")
main(n,fn,c){
        n = fn = 0;
        while((c=getchar())!='\n') n=n*10+c-'0', fn+=c-'0';
        if(n%fn) puts("No");
        else puts("Yes");
        return 0;
}


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


int main(int argc, char const *argv[])
{
	int a,b,c;
	cin>>a>>b>>c;
	set<int>s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size()==2) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*
              *******
When winter comes,You'll hear no lions roar,
no stags grazing the fields,
no roses growing in the meadows,
no snakes in the sand.
The krakens will freeze where they swim.
The flayed men will rot and wither.
No trouts swimming in the river and no falcons flying in the air.
Not even the dragons breath will warm you in your halls.
Only the wolfs howl in the night.
            WINTER IS COMING
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double 
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%lld",&x)
#define p(x) printf("%lld\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define inf 4e18
#define prec(x) fixed<<setprecision(15)<<x
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mem(x,y) memset(x,y,sizeof(x))
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

const int N=1e5+7;
int a[N],l_sum[N],r_sum[N],l_diff[N],r_diff[N];

int main() {
    fast_io;
    int n; cin>>n;
    a[0]=0,a[n+1]=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    mem(l_sum,0); mem(r_sum,0); mem(l_diff,0); mem(r_diff,0);
    for(int i=1;i<=n;i++) {
        l_diff[i]=abs(a[i]-a[i-1]);
        l_sum[i]=l_sum[i-1]+l_diff[i];
    }
    for(int i=n;i>=1;i--) {
        r_diff[i]=abs(a[i]-a[i+1]);
        r_sum[i]=r_sum[i+1]+r_diff[i];
    }
    for(int i=1;i<=n;i++) {
        int ans=l_sum[i-1]+r_sum[i+1]+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

LL dp[1010][1010][2][2][2];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<LL> x(N), y(N), z(N);
    REP(i, N) cin >> x[i] >> y[i] >> z[i];
    REP(i, 1010)REP(j, 1010)REP(k,2)REP(l,2)REP(m,2) dp[i][j][k][l][m] = (LL)-1e17;
    REP(i, 1010)REP(k,2)REP(l,2)REP(m,2) dp[i][0][k][l][m] = 0;
    REP(i, N){
        FOR(j, 1, M+1){
        dp[i+1][j][0][0][0] = max(dp[i][j][0][0][0], dp[i][j-1][0][0][0]+x[i]+y[i]+z[i]);               
        dp[i+1][j][0][0][1] = max(dp[i][j][0][0][1], dp[i][j-1][0][0][1]+x[i]+y[i]-z[i]);               
        dp[i+1][j][0][1][0] = max(dp[i][j][0][1][0], dp[i][j-1][0][1][0]+x[i]-y[i]+z[i]);               
        dp[i+1][j][0][1][1] = max(dp[i][j][0][1][1], dp[i][j-1][0][1][1]+x[i]-y[i]-z[i]);               
        dp[i+1][j][1][0][0] = max(dp[i][j][1][0][0], dp[i][j-1][1][0][0]-x[i]+y[i]+z[i]);               
        dp[i+1][j][1][0][1] = max(dp[i][j][1][0][1], dp[i][j-1][1][0][1]-x[i]+y[i]-z[i]);               
        dp[i+1][j][1][1][0] = max(dp[i][j][1][1][0], dp[i][j-1][1][1][0]-x[i]-y[i]+z[i]);               
        dp[i+1][j][1][1][1] = max(dp[i][j][1][1][1], dp[i][j-1][1][1][1]-x[i]-y[i]-z[i]);               
        }
    }
    LL ans = 0;
    REP(i,2)REP(j,2)REP(k,2) ans = max(ans, dp[N][M][i][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 64000
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_N = 100;
int N;
char S[MAX_N + 1];

void _main() {
  cin >> N >> S;

  int ans = 0;
  int tmp = 0;
  rep(i, 0, N) {
    if (S[i] == 'D') {
      tmp--;
      continue;
    }
    tmp++;
    chmax(ans, tmp);
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C_A = [list(map(int, input().split())) for i in range(N)]

ans = float('inf')
def dfs(i, now, cost):
    global ans
    if i == N:
        if all(elem >= X for elem in now):
            ans = min(cost, ans)
    else:
        dfs(i+1, now, cost)
        A = C_A[i][1:]
        now_next = [x + y for (x, y) in zip(now, A)]
        dfs(i+1, now_next, cost+C_A[i][0])

dfs(0, [0]*M, 0)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#define M 100000
using namespace std;

struct node {
	int d = -1, low, p, t = 0;
};

int cnt = 1, v, e;
vector<int> G[M], A;
node V[M];

void Serch(int u, int v) {
	V[u].d = cnt; V[u].low = cnt; cnt++;

	for (int i = 0; i < G[u].size(); i++) {
		if (V[G[u][i]].d < 0) {
			V[G[u][i]].p = u;
			Serch(G[u][i], u);
			V[u].low = min(V[u].low, V[G[u][i]].low);
		}
		else if (G[u][i] != v) {
			V[u].low = min(V[u].low, V[G[u][i]].d);
		}
	}
}

int main() {
	int v, e, s, t, k = 0;
	scanf("%d %d", &v, &e);
	for (int i = 0; i < e; i++) {
		scanf("%d %d", &s, &t);
		G[s].push_back(t);
		G[t].push_back(s);
	}

	Serch(0, -1);

	for (int i = 1; i < v; i++) {
		if (V[i].p == 0) k++;
		else if (V[V[i].p].t == 0 && V[i].low >= V[V[i].p].d) {
			A.push_back(V[i].p); V[V[i].p].t++;
		}
	}
	if (k > 1) A.push_back(0);
	sort(A.begin(), A.end());

	for (int i = 0; i  < A.size(); i++) cout << A[i] << endl;
	return 0;
}


Measured memory_bytes: 8184
S = input()

count = 0
letter = "R"

end = [0] * len(S)

for i, s in enumerate(S):
    if s == letter:
        count += 1
    else:
        letter = s
        evens = count // 2
        odds = (count + 1) // 2
        if s == "L":
            if count % 2 == 0:
                end[i - 1] += evens
                end[i] += odds
            else:
                end[i - 1] += odds
                end[i] += evens
        if s == "R":
            end[i - count] += odds
            end[i - count - 1] += evens
        count = 1

evens = count // 2
odds = (count + 1) // 2
end[i - count + 1] += odds
end[i - count] += evens

end = [str(item) for item in end]
end = " ".join(end)
print(end)


Measured memory_bytes: 10364
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define Maxn 100010
#define LL long long
const int INF=1000010;

int mymin(int x,int y) {return x<y?x:y;}

struct node
{
    int x,y,next;
}t[Maxn*2];
int len,first[Maxn];

void ins(int x,int y)
{
    t[++len].x=x;t[len].y=y;
    t[len].next=first[x];first[x]=len;
}

int r1,r2,ad;
int sm[Maxn],ss[Maxn],ans,d[Maxn],h[Maxn];
int dfs(int x,int fa,int dep)
{
    sm[x]=1;ss[x]=dep;d[x]=dep;
    if(x==r1||x==r2) sm[x]+=ad,ss[x]+=ad;
    int tt=0;
    for(int i=first[x];i;i=t[i].next) if(t[i].y!=fa)
    {
        int y=t[i].y;
        tt+=dfs(y,x,1-dep);
        sm[x]+=sm[y];ss[x]+=ss[y];
    }
    if(x==r1) tt++;
    if(x==r2) tt--;
    if(tt==1) h[++h[0]]=ss[x]-(sm[x]-ss[x]);
    else if(tt==-1) h[++h[0]]=(sm[x]-ss[x])-ss[x];
    else ans+=abs(ss[x]-(sm[x]-ss[x]));
    // ans+=abs(ss[x]-(sm[x]-ss[x]));
    return tt;
}

int ff[Maxn];
int ffa(int x)
{
    if(ff[x]!=x) ff[x]=ffa(ff[x]);
    return ff[x];
}

int main()
{
    // int T;
    // scanf("%d",&T);
    // while(T--)
    {
        int n,m;r1=r2=0;
        scanf("%d%d",&n,&m);
        len=0;
        memset(first,0,sizeof(first));
        for(int i=1;i<=n;i++) ff[i]=i;
        for(int i=1;i<=m;i++)
        {
            int x,y;
            scanf("%d%d",&x,&y);
            if(ffa(x)!=ffa(y))
            {
                ff[ffa(x)]=ffa(y);
                ins(x,y);ins(y,x);
            }
            else r1=x,r2=y;
        }
        if(m==n-1)
        {
            dfs(1,0,0);
            ans=0;
            for(int i=1;i<=n;i++) ans+=abs(ss[i]-(sm[i]-ss[i]));
            if(sm[1]-ss[1]!=ss[1]) printf("-1\n");
            else printf("%d\n",ans);
        }
        else
        {
            // printf("-2\n");
            ad=0;
            dfs(1,0,0);
            if(d[r1]==d[r2])
            {
                ad=abs(ss[1]-(sm[1]-ss[1]));
                if(ad&1) printf("-1\n");
                else
                {
                    ad/=2;
                    if(ss[1]>sm[1]-ss[1]) dfs(1,0,1);
                    else dfs(1,0,0);
                    ans=ad;
                    for(int i=1;i<=n;i++) ans+=abs(ss[i]-(sm[i]-ss[i]));
                    printf("%d\n",ans);
                }
            }
            else
            {
                h[0]=0;h[++h[0]]=0;
                ans=0;
                dfs(1,0,0);
                if(sm[1]-ss[1]!=ss[1]) printf("-1\n");
                else
                {
                    sort(h+1,h+1+h[0]);
                    int x=h[h[0]/2+1];
                    for(int i=1;i<=h[0];i++) ans+=abs(h[i]-x);
                    printf("%d\n",ans);
                }
            }
        }
    }
    return 0;
}

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

struct P {
	string s;
	int t;
};

int main(void) {
	int n; cin >> n;
	vector<P> v(n);
	rep(i, n) cin >> v[i].s >> v[i].t;
	string x; cin >> x;

	int ans = 0;
	bool flag = false;
	rep(i, n) {
		if (flag) ans += v[i].t;
		if (v[i].s == x) flag = true;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())+2
A=[0]
A.extend(list(map(int,input().split())))
A.append(0)
B=sum(abs(A[i]-A[i-1]) for i in range(1,N))
for i in range(1,N-1):
  print(B-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))

Measured memory_bytes: 20428
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000009
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
using namespace std;
void solve()
{
	ll n;
	cin>>n;
	if(n==1)
	{
		cout<<0<<endl;
		return;
	}
	ll ans=0;
	ll curr=0;
	ll prev=0;
	while(n%2==0)
	{
		n=n/2;
		curr++;
		if(curr==prev+1)
		{
			ans++;
			prev++;
			curr=0;
		}
	}
	for(int i=3;i<=sqrt(n);i++)
	{
		prev=0;
		curr=0;
		while(n%i==0)
		{
			n/=i;
			curr++;
			if(curr==prev+1)
			{
				ans++;
				prev++;
				curr=0;
			}
		}
	}
	if(n>2)
	{
		ans++;
	}
	cout<<ans<<endl;

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3724
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string s1,s2;
int main()
{
    cin>>s1>>s2;
int n1=s1.length();
int n2=s2.length();
if (n1>n2){cout<<"GREATER";return 0;}
if (n1<n2){cout<<"LESS";return 0;}
for (int i=0;i<n1;i++)
{
    if (s1[i]-'0'>s2[i]-'0') {cout<<"GREATER";return 0;}
    if (s1[i]-'0'<s2[i]-'0'){cout<<"LESS";return 0;}
}
printf("EQUAL\n");


return 0;
}


Measured memory_bytes: 256
import math
import heapq
from bisect import bisect_right, bisect_left
from collections import defaultdict, Counter
import itertools
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if h[i] >= k:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12300
import random
import time
import numpy as np

def search(day, schedule, c, s, satisfy):
    score = 0
    date = [0] * 26
    for d in range(day):
        tmp = 0
        contest = 0
        nmax = -float('inf')
        for i in range(26):
            tmp += c[i] * (d + 1 - date[i])
        for i in range(26):
            tmp2 = s[d][i] - tmp + c[i] * (d + 1 - date[i])
            if nmax < tmp2:
                nmax = tmp2
                contest = i
        
        date[contest] = d + 1
        satisfy.append(tmp - c[contest] * (d + 1 - date[contest]))
        schedule.append(contest)
        score += s[d][contest] - satisfy[d]

    return score
    
# def decrease(day, schedule, c, s, satisfy):
#     ret = 0
#     date = [0] * 26

#     for d in range(day):
#         now = schedule[d] + 1
#         date[now - 1] = d + 1
#         tmp = 0
#         for i in range(26):
#             tmp += c[i] * (d+1 - date[i])
#         ret += tmp
#         satisfy.append(tmp)

#     return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (d+1 - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    # for i in range(D):
    #     schedule.append(np.argmax(s[i]))
    #     score += np.max(s[i])
    ans = search(D, schedule, c, s, dissatisfy)
    for i in range(D):
        score+=s[i][schedule[i]]
    
    while time.time() - start < 1.85:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        if schedule[day] == contest:
            continue

        save = dissatisfy.copy()
        dec2 = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec2:
            ans = score2 - dec2
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save

    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()

Measured memory_bytes: 27176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
ll dp[3010][3010];
ll a[3010];
ll rec(int fl,int l, int r){//fl:first 1 second -1 [l,r)
    if(dp[l][r]!=0){
        return dp[l][r];
    }
    if(l==r){
        return 0;
    }
    ll x = rec(fl*-1,l+1,r);
    ll y = rec(fl*-1,l,r-1);
    if(fl==1){
        return dp[l][r] = max(x+a[l],y+a[r-1]);
    }
    else{
        return dp[l][r] = min(x-a[l],y-a[r-1]);
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    cout << rec(1,0,n)<<endl;
return 0;
}

Measured memory_bytes: 70272