akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,M,X,min = 10000,rs=0,t = 0;
    cin >> N >> M >> X;
    vector<int> A(M);

    for(int i = 0;i < M;i++)
        cin >> A.at(i);

    for(int i = 0;;i++){
        if(A.at(i) < X)
            rs++;
        else
        {
            t = i;
            break;
        }       
    }

    if(min > rs)
        min = rs;
    rs = 0;

    for(int i = t;i < A.size();i++){
        if(A.at(i) < N)
            rs++;
    }

    if(min > rs){
        min = rs;
    }

    cout << min << endl;

    

}

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

void bubble_sort(int N, float* A){
	int nchange = 0;
	
	for(int i=0;i<N;i++){
		for(int j=N-1;j>i;j--){
			if(A[j-1] > A[j]){
				swap(A[j-1], A[j]);
				nchange++;
			}
		}
	}
	
	for(int i=0;i<N;i++){
		if(i==N-1){
			cout << A[i] << endl;
		}else{
			cout << A[i] << " ";
		}
	}
	cout << nchange << endl;
}

int main(){
	int N;
	cin >> N;
	
	float A[N];
	for(int i=0;i<N;i++)
		cin >> A[i];

	bubble_sort(N, A);
	return 0;
}


Measured memory_bytes: 3288
// exawizards2019_b

package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	var s string
	fmt.Scanf("%s", &s)

	var r, b int
	for _, c := range s {
		if c == 'R' {
			r++
		} else if c == 'B' {
			b++
		}
	}
	if r > b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

  vector<ll> l(8,0);
  ll ans = (ll)1e12;
  rep(i,n) cin >> l[i];
  for(ll i = 0; i <= 1<<16 ; i++){
    ll tmp = 0;
    
    ll a = 0,b = 0,c = 0;
    for(ll j = 0; j < n; j++){
        ll x = 0;
        x += (i>>(j*2))%2;
        x += ((i>>(j*2+1))%2)*2;
        if(x==0){
          if(a!=0) tmp += 10;
          a += l[j];
        }else if(x==1){
          if(b!=0) tmp += 10;
          b += l[j];
        }else if(x==2){
          if(c!=0) tmp += 10;
          c += l[j];
        }else{
          continue;
        }
    }
    if(a==0||b==0||c==0){
      continue;
    }else{
      // cout << a << " " << b <<  " " << c << endl; 
      tmp += abs(A-a)+abs(B-b)+abs(C-c);
      // if(tmp==10) cout << a << " " << b <<  " " << c << endl;
      // if(tmp==10) cout << abs(A-a)+abs(B-b)+abs(C-c) << endl;

      ans = min(ans,tmp);
    }
  }

  cout << ans << endl;

  return 0;
} 

Measured memory_bytes: 256
S = input()
N = len(S)

even = [1 for _ in range(N)]
odd = [0 for _ in range(N)]
ret = [0 for _ in range(N)]

for i in range(N - 1):
    if S[i] == 'R':
        odd[i + 1] += even[i]
        even[i + 1] += odd[i]
        odd[i] = 0
        even[i] = 0

for i in range(1, N)[::-1]:
    if S[i] == 'L':
        odd[i - 1] += even[i]
        even[i - 1] += odd[i]
        odd[i] = 0
        even[i] = 0

for i in range(N - 1):
    if S[i] == 'R' and S[i + 1] == 'L':
        ret[i] = even[i] + odd[i + 1]
        ret[i + 1] = even[i + 1] + odd[i]

print(' '.join(map(str, ret)))


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

int main(void){
    int n;
    cin >> n;
    bool flag = 0;
    for(int i=0;i<=n;i+=4){
        for(int j=i;j<=n;j+=7){
            if((j)==n){
                flag = 1;
                break;
            }
        }
    }
    if(flag==1)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    
    return 0;
}







Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, a, b, c, d, i;

    scanf("%d", &n);

    d = n%10;
    n /= 10;
    c = n%10;
    n /= 10;
    b = n%10;
    n /= 10;
    a = n%10;

    if(a+b+c+d == 7)
        printf("%d+%d+%d+%d=7\n", a, b, c, d);
    else if(a+b+c-d == 7)
        printf("%d+%d+%d-%d=7\n", a, b, c, d);
    else if(a+b-c+d == 7)
        printf("%d+%d-%d+%d=7\n", a, b, c, d);
    else if(a+b-c-d == 7)
        printf("%d+%d-%d-%d=7\n", a, b, c, d);
    else if(a-b+c+d == 7)
        printf("%d-%d+%d+%d=7\n", a, b, c, d);
    else if(a-b+c-d == 7)
        printf("%d-%d+%d-%d=7\n", a, b, c, d);
    else if(a-b-c+d == 7)
        printf("%d-%d-%d+%d=7\n", a, b, c, d);
    else if(a-b-c-d == 7)
        printf("%d-%d-%d-%d=7\n", a, b, c, d);

    return 0;
}

Measured memory_bytes: 128
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();
        System.out.println((A <= 8) ? (B <= 8) ? "Yay!":":(" :":(");
        sc.close();
    }
}

Measured memory_bytes: 23252
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, x, y, i, count = 0;
  cin >> n;
  vector<pair<int, int>> v;
  for (i = 0; i < n; i++)
  {
    cin >> x >> y;
    v.emplace_back(x, y);
  }
  for (i = 0; i <= n - 3; i++)
  {
    if (v[i].first == v[i].second)
    {
      if ((v[i + 1].first == v[i + 1].second) && (v[i + 2].first == v[i + 2].second))
      {
        count = 1;
        break;
      }
    }
  }
  if (count == 1)
  {
    cout << "Yes " << endl;
  }
  else
  {
    cout << "No " << endl;
  }
  return 0;
}



Measured memory_bytes: 3632
#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 int long long
#define pb push_back
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main()
{   fastio;
    int n , m;
    cin>>n>>m;
    std::vector<int> v(m);
    int s=0;
    for(int i=0; i<m; i++)
    {
        cin>>v[i];
        s += v[i];
    }
    if(s>n)cout<<"-1\n";
    else cout<<n-s<<"\n";

}

Measured memory_bytes: 3664
x, n = tuple(map(int, input().split()))
p = list(map(int, input().split()))

if x not in p:
    print(x)
    exit()

for i in range(1, 200):
    if (x - i) not in p:
        print(x - i)
        exit()
    if (x + i) not in p:
        print(x + i)
        exit()


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = b;
    if(a<=5)ans = 0;
    else if(a<=12)ans /= 2;
    cout << ans << endl;
    return 0;
}

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

int partition(int*, int, int);

int main()
{
  int *A;
  int i, n, base;

  scanf("%d", &n);
  A = (int *)malloc(n * sizeof(int));

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

  base = partition(A, 0, n-1);

  for(i=0;i<n;i++)
    {
      if(i)printf(" ");
      if(i == base)printf("[");
      printf("%d", A[i]);
      if(i == base)printf("]");
    }

  printf("\n");

  free(A);
  return 0;
}

int partition(int *A, int p, int r)
{
  int base, swap, i, j;
  base = A[r];
  i = p-1;
  for(j=p;j<r;j++)
    {
      if(A[j] <= base)
        {
          i++;
          swap = A[i]; A[i] = A[j]; A[j] = swap;
        }
    }
    swap = A[i+1]; A[i+1] = A[r]; A[r] = swap;
    return i+1;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#include <iomanip> 
using namespace std;
int main()
{
  int n;
  cin>>n;
  double p[n];
  for(int i=0;i<n;i++)
    cin>>p[i];
  double dp[n+1][n+1];
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
    dp[0][i]=0;
  for(int j=1;j<=n;j++)
  {
    dp[j][0]=(1-p[j-1])*dp[j-1][0];
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      dp[i][j]=(1-p[i-1])*dp[i-1][j]+p[i-1]*dp[i-1][j-1];
    }
  }
 
  double ans=0.0;
  for(int j=n/2+1;j<=n;j++)
  {
    ans+=dp[n][j];
  }
  cout<<setprecision(9)<<ans<<"\n";
}


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

using namespace std;
typedef long long ll;
int main(){
    int n;cin>>n;
    ll rj=0;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            rj+=j;
        }
    }
    cout <<rj<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n + 1), b(n);
  for (auto& x : a) std::cin >> x;
  for (auto& x : b) std::cin >> x;
  long long ans = 0;
  auto cancel = [&] (int& x, int& y) {
    int min = std::min(x, y);
    ans += min;
    x -= min;
    y -= min;
    assert(x >= 0);
    assert(y >= 0);
    assert(x == 0 || y == 0);
  };
  auto simulate = [&] (int i) {
    assert(0 <= i && i < n);
    cancel(a.at(i), b.at(i));
    cancel(a.at(i + 1), b.at(i));
  };
  for (int i = 0; i < n; i++) simulate(i);
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, m;
	int c[20];
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	int dp[50001] = {};
	fill_n(dp, n + 1, INT_MAX / 2);
	dp[0] = 0;
	for (int i = 0; i <= m; i++) {
		for (int j = c[i]; j <= n; j++) {
			dp[j] = min(dp[j], dp[j - c[i]] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1364
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long long sx,sy,tx,ty,stx,sty;
	while(cin>>sx)
	{
		cin>>sy>>tx>>ty;
		stx=tx-sx;
		sty=ty-sy;
		for(int i=0;i<sty;i++)
		{
			cout<<'U';
		}
		for(int i=0;i<stx;i++)
		{
			cout<<'R';
		}
		for(int i=0;i<sty;i++)
		{
			cout<<'D';
		}
		for(int i=0;i<stx;i++)
		{
			cout<<'L';
		}
		cout<<'L';
		for(int i=0;i<=sty;i++)
		{
			cout<<'U';
		}
		for(int i=0;i<=stx;i++)
		{
			cout<<'R';
		}
		cout<<'D';
		cout<<'R';
		for(int i=0;i<=sty;i++)
		{
			cout<<'D';
		}
		for(int i=0;i<=stx;i++)
		{
			cout<<'L';
		}
		cout<<'U';
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.IntStream;

public class Main {
	
	class UnionFind {
		int[] Parent;
		int N;
		
		UnionFind(int N){
			this.N = N;
			Parent = new int[N];
			IntStream.range(0, N).forEach( i -> Parent[i] = -1);
		}
		
		int root(int A) {
			if (Parent[A] < 0) return A;
			return Parent[A] = root( Parent[A] );
		}
		
		int size(int A) {
			return -Parent[root(A)];
		}
		
		boolean connect(int A, int B) {
			A = root(A);
			B = root(B);
			if ( A == B ) return false;
			if (size(A) < size(B)) {
				A = A ^ B;
				B = A ^ B;
				A = A ^ B;
			}
			Parent[A] += Parent[B];
			Parent[B] = A;
			return true;
		}
		
	}
	
	public Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		UnionFind UN = new UnionFind(N);
		
		for (int i = 0; i < M; i++) {
			int A = scanner.nextInt()-1;
			int B = scanner.nextInt()-1;
			UN.connect(A, B);
		}
		
		int Ans = 0;
		for (int i = 1; i < N; i++) {
			if (UN.connect(0, i)) {
				Ans++;
			}
		}
		System.out.println(Ans);
	}
	
	public static void main(String[] args) {
		new Main();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main()
{string S, T;
 cin >> S >> T;
 bool can2=false;
 for(int i=S.size()-T.size(); i >=0; i--){
   bool can1=true;
   rep(j, T.size()){
     if((S[i+j]!=T[j])&&(S[i+j]!='?'))
       can1=false;}
   if(can1) {
     rep(j, T.size())
       S[i+j]=T[j];
     can2=true;
      break;}}
 rep(i, S.size()){
   if(S[i]=='?')
     S[i]='a';}
 if(can2) cout << S << endl;
 else cout << "UNRESTORABLE" << endl;
 }
    

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int g=6002;

int f[6002][12005],n,mod;

int qpow(int a,int x) {
    int res=1;
    for(;x;x>>=1,a=1ll*a*a%mod) if(x&1) res=1ll*res*a%mod;
    return res;
}

void update(int &x,int y) {x+=y;if(x>=mod) x-=mod;}

int main() {
    read(n),read(mod);n*=3;
    f[0][g]=1;int fac=1;
    for(int i=1;i<=n;i++) {
        int iv=qpow(i,mod-2);fac=1ll*fac*i%mod;
        for(int j=-n;j<=n;j++) {
            if(i>=1) update(f[i][j+g],f[i-1][j-1+g]);
            if(i>=2) update(f[i][j+g],f[i-2][j+1+g]);
            if(i>=3) update(f[i][j+g],f[i-3][j+g]);
            f[i][j+g]=1ll*f[i][j+g]*iv%mod;
            // printf("%d %d %I64d\n",i,j,1ll*fac*f[i][j+g]%mod);
        }
    }
    int ans=0;
    for(int i=0;i<=n;i++) update(ans,f[n][i+g]);
    write(1ll*ans*fac%mod);
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, k;
    cin >> n >> k;
    vector<llong> A(n), Cum(n + 1);
    Cum[0] = 0;
    rep(i, n) {
        cin >> A[i];
        Cum[i + 1] = Cum[i] + A[i];
    }

    vector<llong> P;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n + 1; ++j) {
            P.push_back(Cum[j] - Cum[i]);
        }
    }
    sort(allr(P));

    vector<llong> cur = P;
    for (llong bit = 63; bit >= 0; --bit) {
        vector<llong> tmp;
        for (int e = 0; e < cur.size(); ++e) {
            if (cur[e] & (1LL << bit)) tmp.push_back(cur[e]);
        }
        if (tmp.size() >= k) cur = tmp;
    }

    llong res = -1;
    rep(i, k) {
        res &= cur[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9964
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
int main() {
  string s;
  cin >> s;
  ll k=s.size();
  ll ans=0;
  rep(i,1<<(k-1)){
    ll A=0;
    string S="";
    rep(j,k){
      S+=s[j];
      if((i>>j)%2==0){
        A+=atoll(S.c_str());
        S="";
      }
    }
    ans+=A;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
n, m = gets_i_list
alist, blist = [],[]

ans = [0] * (n+1)

m.times do
  a, b = gets_i_list
  ans[a] = ans[a].to_i + 1
  ans[b] = ans[b].to_i + 1
end

1.upto(n+1) do |i|
  puts ans[i]
end

Measured memory_bytes: 14500
'''
https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N = int(input())
    for i in range(10**3):
        if i*(i-1) == N*2:
            res = i
            break
    else:
        print('No')
        exit()

    s = [[] for _ in range(res)]
    num = 1

    for a,b in combinations(range(res), 2):
        s[a].append(num)
        s[b].append(num)
        num += 1

    print('Yes')
    print(res)
    for i in s:
        print('{} {}'.format(res-1, ' '.join(map(str, i))))

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<bool> isLeft(N);

    for (int i = 0; i < N; i++) {
        isLeft[i] = (S[i] == 'L');
    }

    int cnt = 0;

    for (int i = 0; i < N - 1; i++) {
        if (isLeft[i] == isLeft[i + 1]) cnt++;
    }

    int ans = min(cnt + 2 * K, N - 1);

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,o,f[500010],c[500010],a[500010];
int main(){
    cin>>n; 
    for(int i=1;i<=n;i++){
		scanf("%1d",&c[i]);
        if(!c[i]) o=i;
        a[i]=o;
	}
    for(int i=1;i<=n;i++){
        f[i]=f[i-1];
        if(!c[i]) continue;
        if(!c[i-1]&&c[i-2])//这有一个101 
            f[i]=max(f[i],f[a[i-2]]+i-2-a[i-2]),
            f[i]=max(f[i],f[a[i-2]+1]+i-2-a[i-2]-1);
        else if(a[i]>1&&c[a[i]-1])
            f[i]=max(f[i],f[a[i]-2]+i-a[i]);
    }
    printf("%d\n",f[n]);
    return 0;
} 

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,-1,1};
int main() {
  int H,W;
  cin >> H >> W;
  string s[H];
  for(int i = 0; i < H; i++) cin >> s[i];
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int cnt = 0;
      if(s[i][j]== '.') continue;
//      cout << "A"<< i << j << endl;
      for(int k = 0; k < 4; k++){
        int xx = j + dx[k];
        int yy = i + dy[k];
//       cout << xx << yy << endl;
        if(!(0 <= xx && xx < W && 0 <= yy && yy < H)) continue;
//        cout << "B" << endl;
        if(s[yy][xx]=='#') cnt++;
      }
      if(cnt == 0){
//        cout << i << j << endl;
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


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

public class Main {
	int n, d;
	int[] t, a, b, c;
	int[][] dp;

	int dp(int k, int l) {
		if (0 <= dp[k][l]) {
			return dp[k][l];
		}
		if (k == 0) {
			return 0;
		}

		int res = 0;
		for (int i = 0; i < n; i++) {
			if (t[k - 1] < a[i] || b[i] < t[k - 1]) continue;
			res = Math.max(res, dp(k - 1, i) + Math.abs(c[l] - c[i]));
		}
		return dp[k][l] = res;
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		d = sc.nextInt();
		n = sc.nextInt();
		t = new int[d];
		for (int i = 0; i < d; i++) {
			t[i] = sc.nextInt();
		}
		a = new int[n];
		b = new int[n];
		c = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		
		dp = new int[d][n];
		for (int i = 0; i < d; i++) {
			Arrays.fill(dp[i], -1);
		}
		
		int max = 0;
		for (int i = 0; i < n; i++) {
			if (t[d - 1] < a[i] || b[i] < t[d - 1]) continue;
			max = Math.max(max, dp(d - 1, i));
		}
		
		System.out.println(max);
	}

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

Measured memory_bytes: 21464
# -*- coding: utf-8 -*-
from bisect import bisect_left, bisect_right

N=input()
L=[]
for i in range(1,N+1):
    if i==1:
        L.append(i)
    else:
        L.append(L[-1]+i)

max_n=bisect_left(L,N)+1

for i in range(max_n,0,-1):
    if N-i>=0:
        print i
        N-=i


Measured memory_bytes: 184372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Arrays;
// Solution Starts here
public class Main{
    public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int a=in.nextInt();
        int b=in.nextInt();
        out.println(a*b);
        out.close();
    }
    // solution ends here
    static class FastScanner{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer sr = new StringTokenizer("");
        String next(){
            while(!sr.hasMoreTokens()){
                try{
                    sr=new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return sr.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        int[] readArray(int n){
            int a[]=new int[n];
            for(int i=0;i<n;i++)
                a[i]=nextInt();
            return a;
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
    }

}

Measured memory_bytes: 32956
X,N = map(int, input().split())
if N != 0:
    s=set(list(map(int, input().split())))
else:
    s=set([])
    
if X not in s:
    print(X)
else:
    for i in range(1, 101):
        if X-i not in s:
            print(X-i)
            break
        if X+i not in s:
            print(X+i)
            break
    


Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

int parent[mxN];

int find_set(int u){
	if(parent[u] == u)return u;
	return parent[u] = find_set(parent[u]);
}

void solve(){
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; ++i)parent[i] = i;
	int a, b;
	for(int i = 0; i < m; ++i){
		cin >> a >> b;
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			if(a < b)parent[b] = a;
			else parent[a] = b;
		}
	}
	map<int, int> mp;
	for(int i = 1; i <= n; ++i){
		mp[find_set(i)]++;
	}
	int mx = 0;
	for(auto it : mp){
		mx = max(mx, it.second);
	}
	cout << mx << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 17648
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e3 + 10 ;
const ll INF = 1e18 + 10 ;
int main(){
    fastio
    ll n ;
    cin >> n ; 
    vector<vector<bool>> v(n, vector<bool>(61)) ; 
    for(ll i = 0; i < n; i++){
        ll x ;
        cin >> x ; 
        for(ll j = 0; j < 61; j++){
            if ( x & (1LL << j) ){
                v[i][j] = 1; 
            }
        }
    }
    vector<ll> cnt(61) ;
    for(ll i = 0; i < 61; i++){
        ll ones = 0 ; 
        for(ll j = 0; j < n; j++){
            if ( v[j][i] ) ones++ ; 
        }
        cnt[i] = ones ; 
    }
    ll sum = 0 ;
    for(ll i = 0; i < 61; i++){
        ll ones = cnt[i] ; 
        ll zeroz = n - cnt[i] ; 
        sum += (((ones % MOD) * (zeroz % MOD)) % MOD * ((1LL << i) % MOD)) % MOD ; 
        sum = sum % MOD ; 
    }
    cout << sum << endl;
    return 0; 
}

Measured memory_bytes: 21376
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b >= 10)cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{int sum=17;
int mul=175;
int sum1=0;int mul1=1;
int a=0;
for(int i=0;i<3;i++)
{cin>>a;
sum1=sum1+a;
mul1=mul1*a;
}
if(sum==sum1&&mul==mul1){
cout<<"YES";
}
else
{cout<<"NO";
}
return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

even = v[0:n:2]
odd = v[1:n:2]

c_even = [0]*(10**5+100)
c_odd = [0]*(10**5 + 100)

for i in even:
    c_even[i]+=1
for i in odd:
    c_odd[i]+=1

m_even = -1
m_odd = -1


for i,j in enumerate(c_even):
    if j > m_even:
        m_even = j 
        m_even_num = i

for i,j in enumerate(c_odd):
    if j > m_odd:
        m_odd = j 
        m_odd_num = i

if m_even_num == m_odd_num:
    print(min(n - m_odd - sorted(c_even,reverse=True)[1], n - m_even - sorted(c_odd,reverse=True)[1]))
else:
    print(n - m_even - m_odd)        


Measured memory_bytes: 14264
#include <stdio.h>
int main(void){
    // Your code here!
  int i,n,j,k;
  int b,f,r,v;
  int count[4][3][10]={0};
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
      scanf("%d %d %d %d",&b, &f, &r, &v);
      count[b-1][f-1][r-1]+=v;
  }
  
  for(k=0;k<4;k++){
      for(j=0;j<3;j++){
          for(i=0;i<10;i++){
              printf(" %d",count[k][j][i]);
          }
          printf("\n");
      }
      if(k==3) break;
      printf("####################\n");
  }
  return 0;
}



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

int main(){
  string a, b;
  cin >> a >> b;
  if(a.size() + 1 != b.size()){
    cout<< "No\n";
    return 0;
  }
  if(b.substr(0, b.size()-1) == a){
      cout<<"Yes\n";
    return 0;
  }
  cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  string N;
  cin>>N;
  if(N=="A"){
    cout<<"T";
  }else if(N== "T"){
    cout<<"A";
  }else if(N=="G"){
    cout<<"C";
  }else{
    cout<<"G";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,k,x,y,i,r,a[100004];
bool ok;
int main()
{
    scanf ("%d %d", &n, &k);
    for (i=1;i<=n;i++)
        scanf ("%d", &a[i]);
    x=a[1];
    for (i=2;i<=n;i++)
    {
        y=a[i];
        r=x%y;
        while (r!=0)
        {
            x=y;
            y=r;
            r=x%y;
        }
        x=y;
    }
    ok=false;
    for (i=1;i<=n;i++)
    {
        if ((a[i]>=k) && (((a[i]-k)%x)==0))
        {
            ok=true;
            break;
        }
    }
    if (ok==true)
        printf ("POSSIBLE\n");
    else
        printf ("IMPOSSIBLE\n");
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 200010

ll N;
vector<ll> C;

ll start_pos[MAX_N];
// i から始まる区間の終わりの場所
ll range[MAX_N];
ll dp[MAX_N];

ll dfs(ll i) {
    if(i >= N) { return 1; }

    ll& ret = dp[i];
    if(~ret) { return ret; }
    ret = 0;

    if(range[i] > 0 && range[i] > i + 1) {
        ret += dfs(range[i]);
        ret %= MOD;
    }
    ret += dfs(i+1);
    ret %= MOD;
    return ret;
}

signed main()
{
    cin >> N;
    C.resize(N);
    REP(i, N) { cin >> C[i]; }

    // range の作成
    MINUS(start_pos);
    MINUS(range);
    REP(i, N) {
        if(start_pos[C[i]] == -1) {
            start_pos[C[i]] = i;
        }
        else {
            range[start_pos[C[i]]] = i;
            start_pos[C[i]] = i;
        }
    }
    MINUS(dp);
    ll ans = dfs(0);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12800
package main

import "fmt"

func swap(a int, b int) (int, int) {
	return b, a
}

func main() {
	var x, y, z int
	fmt.Scan(&x, &y, &z)

	x, y = swap(x, y)
	x, z = swap(x, z)

	fmt.Println(x, y, z)

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 100003;
template<typename T>
inline void read(T &x){
	int ch = getchar(); x = 0;
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int n, rt1, rt2, head[N], to[N << 1], nxt[N << 1], qu[N], f, r, dep[N], d[N], tot, deg[N], fa[N], p[N], q[N];
bool vis[N];
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
inline void bfs(int S){
	memset(dep, -1, sizeof dep);
	memset(fa, 0, sizeof fa);
	f = r = 0; qu[r ++] = S; dep[S] = 0;
	while(f < r){
		int u = qu[f ++];
		for(Rint i = head[u];i;i = nxt[i])
			if(dep[to[i]] == -1){
				dep[to[i]] = dep[u] + 1; fa[to[i]] = u; qu[r ++] = to[i];
			}
	}
}
int main(){
	read(n);
	for(Rint i = 1, u, v;i < n;++ i){
		read(u); read(v);
		add(u, v); add(v, u);
	}
	bfs(1); bfs(rt1 = qu[r - 1]); rt2 = qu[r - 1];
	for(;rt2;rt2 = fa[rt2]){
		vis[rt2] = true; d[++ tot] = rt2;
	}
	for(Rint i = 1;i <= n;++ i) if(!vis[i]){
		bool f = false;
		for(Rint j = head[i];j;j = nxt[j])
			if(vis[to[j]]){++ deg[to[j]]; f = true; break;}
		if(!f) return puts("-1"), 0;
	}
	for(Rint i = 1, now = 1;i <= tot;++ i){
		for(Rint j = 0;j < deg[d[i]];++ j)
			p[now + j] = now + j + 1;
		p[now + deg[d[i]]] = now; now += deg[d[i]] + 1;
	}
	for(Rint i = tot, now = 1;i;-- i){
		for(Rint j = 0;j < deg[d[i]];++ j)
			q[now + j] = now + j + 1;
		q[now + deg[d[i]]] = now; now += deg[d[i]] + 1;
	}
	for(Rint i = 1;i <= n;++ i)
		if(p[i] < q[i]){
			for(Rint j = 1;j <= n;++ j) printf("%d ", p[j]);
			return 0;
		} else if(p[i] > q[i]){
			for(Rint j = 1;j <= n;++ j) printf("%d ", q[j]);
			return 0;
		}
	for(Rint i = 1;i <= n;++ i) printf("%d ", p[i]);
}

Measured memory_bytes: 5504
import sys
import math
from functools import reduce
from operator import mul
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

X = In()
M = X // 500
X -= 500 * M
D = X // 5
print((M*1000)+(D*5))


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  int H, W;
  cin >> H >> W;

  vector<int> cnt(26);

  rep(i, 26) cnt[i] = 0;

  rep(i, H){
    string s;
    cin >> s;
    rep(j, W){
      cnt[s[j]-'a']++;
    }
  }

  int cnt_4 = 0;
  int cnt_2 = 0;

  rep(i, 26){

    cnt_4 += cnt[i] / 4;
    cnt_2 += cnt[i] / 2;

  }

  int req_4 = (H/2) * (W/2);
  int req_2 = 2 * req_4 + (H/2) * (W%2) + (H%2) * (W/2);

  if(cnt_4 >= req_4 && cnt_2 >= req_2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H,W;
char maze[2000][2000];
int whatsup[2000][2000];
int whatsdown[2000][2000];
int whatsright[2000][2000];
int whatsleft[2000][2000];
int up(int y,int x){
    if(whatsup[y][x]) return whatsup[y][x];
    if(0<=y-1&&maze[y-1][x]=='.'){
        whatsup[y][x]=1+up(y-1,x);
        return 1+up(y-1,x);      
    }
    return 1;
}
int down(int y,int x){
    if(whatsdown[y][x])return whatsdown[y][x];
    if(y+1<H&&maze[y+1][x]=='.'){
        whatsdown[y][x]=1+down(y+1,x);
        return 1+down(y+1,x);      
    }
    return 1;
}
int right(int y,int x){
    if(whatsright[y][x]) return whatsright[y][x];
    if(x+1<W&&maze[y][x+1]=='.'){
        whatsright[y][x]=1+right(y,x+1);
        return 1+right(y,x+1);      
    }
    return 1;
}
int left(int y,int x){
    if(whatsleft[y][x])return whatsleft[y][x];
    if(0<=x-1&&maze[y][x-1]=='.'){
        whatsleft[y][x]= 1+left(y,x-1);
        return 1+left(y,x-1);      
    }
    return 1;
}
void solve(){
    cin>>H>>W;
    int sum=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            whatsup[i][j]=0;
            whatsdown[i][j]=0;
            whatsright[i][j]=0;
            whatsleft[i][j]=0;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)cin>>maze[i][j];
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(maze[i][j]=='.')sum=max(sum,up(i,j)+down(i,j)+right(i,j)+left(i,j)-3);
        }
    }
    cout<<sum<<endl;
}
int main(){
    solve();
}

Measured memory_bytes: 66816
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    while(true) {
      val h, w = scanner.nextInt
      if((h == 0) && (w == 0)) System.exit(0)
      println(("#" * w + "\n") * h)
    }
  }
}


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

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


int main() {

int x,n;
cin >> n >> x;

int L[n];
rep(i,n)cin >> L[i];

int d=0;
int a = 1;


rep(i,n){
    d +=L[i];
    if(d<=x) a++;
}

cout << a << endl;
  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    double s[1000];
    double sum=0;
    double sum2=0;
    int i;
    double m;
    double m2;
    double m3;
    
    for(;;){
        sum=0;
        m=0;
        sum2 = 0;
        m3 = 0;
        cin >> n;
        if (n==0)break;
        for ( i = 0;i < n; i++ ){
            cin >> s[i];
            sum = sum + s[i];
        }
            m=sum / n;
            
        for  ( i = 0;i < n; i++ ){
           sum2 = sum2 + ((s[i] - m) * (s[i] - m));        
        }
        m3 = sqrt(sum2 / n);

        printf("%-20.8f\n",m3);
    }
    
    return 0;
}

Measured memory_bytes: 3192
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    // backward greedy
    vector<int> backward(k);
    {
        int pos = n-1;
        int cnt = k;
        while (pos>0 and cnt > 0)
        {
            if (s[pos] == 'o')
            {
                backward[--cnt] = pos;
                pos -= c+1;
            }
            else
                --pos;
            debug(pos, cnt);
        }
    }

    // forward greedy
    vector<int> forward(k);
    {
        int pos = 0;
        int cnt = 0;
        while (pos<n and cnt<k)
        {
            if (s[pos] == 'o')
            {
                forward[cnt++] = pos;
                pos += c+1;
            }
            else
                ++pos;
        }
    }

    debug(backward);
    debug(forward);

    // print out
    rep(cnt, 0, k)
    if (forward[cnt] == backward[cnt])
        printf("%d\n", forward[cnt]+1);
    return 0;
}


Measured memory_bytes: 3332
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
def popcnt(n):
  c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
  c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
  c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
  c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
  c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
  c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
  return c

answer = 10 ** 18
#for i in range(1):
for i in range(2 ** (H - 1)):
    flag = 0
    answer_tmp = popcnt(i)
    #print(answer_tmp)
    dic = [-1] * H
    index = 0
    for j in range(H):
        dic[j] = index
        if i >> j & 1:
            index += 1
    tmp = [0] * (index + 1)
    #print(dic)
    #print(tmp)
    
    for k in range(W):
        for j in range(H):
            #print(S[j][k])
            if S[j][k] == "1":
                tmp[dic[j]] += 1
        if k == 0 and max(tmp) > K:
            #print(dic)
            flag = 1
            break
        if max(tmp) > K:
            answer_tmp += 1
            for j, t in enumerate(tmp):
                tmp[j] = 0
            for j in range(H):
                #print(S[j][k])
                if S[j][k] == "1":
                    tmp[dic[j]] += 1
            if max(tmp) > K:
                flag = 1
                break
        #print(tmp)
        if flag:
            break
    if flag:
        continue
    #print(answer_tmp)
    answer = min(answer, answer_tmp)

print(answer)

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

int main(){
    int a,b,c;
	cin>>a>>b;
	if(b<10) a*=10;
	else if(b>=10&&b<100) a*=100;
	 else a*= 1000;
	c=a+b;
	for(int i=1;i<=c;i++)
	if(c==i*i) {
		cout<<"Yes"; return 0;
	}
	cout<<"No";
	return 0; 
	 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;


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

   if (N >= 10) printf("%d\n", R);
   else printf("%d\n", R+100*(10-N));
 
	return 0;
}













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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K % 2 == 0){
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    // vector<int> va(a), vb(b), vc(c);
    // for(int i = 0; i < a; ++i)
    //     cin >> va[i];
    // for(int i = 0; i < b; ++i)
    //     cin >> vb[i];
    // for(int i = 0; i < c; ++i)
    //     cin >> vc[i];
    // sort(va.begin(), va.end(), greater<int>());
    // sort(vb.begin(), vb.end(), greater<int>());
    // sort(vc.begin(), vc.end(), greater<int>());
    vector<pair<int, int>> V;
    vector<int> Vc;
    int num;
    for(int i = 0; i < a; ++i){
        cin >> num;
        V.push_back(make_pair(0, num));
    }
    for(int i = 0; i < b; ++i){
        cin >> num;
        V.push_back(make_pair(1, num));
    }
    for(int i = 0; i < c; ++i){
        cin >> num;
        V.push_back(make_pair(2, num));
    }
    sort(V.begin(), V.end(), [](pair<int, int> p1, pair<int, int> p2){return p1.second > p2.second;});

    // cout << V.begin()->first << " " << V.begin()->second << "\n";
    ll total = 0;
    ll cnx = x;
    ll cny = y;
    for(int i = 0; i < a+b+c; ++i) {
        if((cnx == 0 && cny == 0) || cnx+cny == Vc.size())
            break;

        if(V[i].first == 0 && cnx > 0) {
            total += V[i].second;
            cnx--;
        }
        else if(V[i].first == 1 && cny > 0) {
            total += V[i].second;
            cny--;
        }
        else if(V[i].first == 2){
            Vc.push_back(V[i].second);
        }      
    }
    for(int i = 0; i < Vc.size(); i++){
        total += Vc[i];
    }
    cout << total << "\n";
    

    

    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;

    int diff  = (h2-h1)*60 + (m2-m1);
    cout<<diff-k<<"\n";
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
using namespace std;

int main(void){
  int n, a[100][2];
  int t1, t2;
  
  scanf("%d", &n);
  for (int i=0; i<2; i++){
    for (int j=0; j<n; j++){
      scanf("%d", &a[j][i]);
    }
  }
  
  t1 = a[0][0]; t2 = a[0][0]+a[0][1];
  for (int i=1; i<n; i++){
    t2 = MAX(t1+a[i][0]+a[i][1], t2+a[i][1]);
    t1 += a[i][0];
  }
  printf("%d\n", t2);
  
  return 0;
}
    

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

using namespace std;

int main()
{
    int num[3];
    cin >> num[0] >> num[1] >> num[2];
    sort(num, num+3, greater<int>());
    cout << num[0] * 10 + num[1] + num[2] << endl;
    return 0;
}


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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 1e6 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int cnt[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, g = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        g = __gcd(x, g);
        cnt[x]++;
    }
    for (int i = 2; i < N; i++) {
        if (cnt[i] > 1) {
            cout << (g == 1 ? "setwise coprime" : "not coprime") << '\n';
            return 0;
        }
        int tmp = 0;
        for (int j = i; j < N; j += i) {
            tmp += cnt[j];
        }
        if (tmp > 1) {
            cout << (g == 1 ? "setwise coprime" : "not coprime") << '\n';
            return 0;
        }
    }
    cout << "pairwise coprime" << '\n';
    return 0;
}


Measured memory_bytes: 7564