akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
using namespace std;
const int N=1000005;
int n,pos,ans,head,tail,q[N];
char s[N],t[N];
int main(){
    scanf("%d%s%s",&n,s+1,t+1);
    if(!strcmp(s+1,t+1)){
        puts("0");
        return 0;
    }
    pos=n;
    head=1,tail=0;
    for(int i=n;i>=1;i--){
        if(t[i]==t[i-1]){
            continue;
        }
        pos=min(pos,i);
        while(pos&&t[i]!=s[pos]){
            pos--;
        }
        if(!pos){
            puts("-1");
            return 0;
        }
        while(head<=tail){
            if(q[head]-(tail-head+1)+1>i){
                head++;
            }else{
                break;
            }
        }
        q[++tail]=pos;
        if(i!=pos){
            ans=max(ans,tail-head+1);
        }
    }
    printf("%d\n",ans+1);
    return 0;
}

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

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

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;

	ll ans = 0;
	for(int i = 0; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0) continue;
		ans += i;
	}

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

Measured memory_bytes: 3652
package main

import (
    "fmt"
    "os"
    "strings"
)

var words = []string{
    "dream",
    "dreamer",
    "erase",
    "eraser",
}

func canSolve(s string) bool {
    if s == "" {
        return true
    }
    for _, word := range words {
        if strings.HasPrefix(s, word) {
            if canSolve(s[len(word):]) {
                return true
            }
        }
    }
    return false
}

func main() {

    var S string
    fmt.Fscanf(os.Stdin, "%v", &S)

    if canSolve(S) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

Measured memory_bytes: 10368
from collections import Counter
N = int(input())
S = [input().strip() for _ in range(N)]
M = int(input())
T = [input().strip() for _ in range(M)]

s = Counter(S)
t = Counter(T)
for k1,v1 in s.items():
  for k2,v2 in t.items():
    if k1==k2:
      s[k1] -= v2
print(max(max(s.values()),0))

Measured memory_bytes: 3444
#include <iostream>
#include <ctype.h>
#define N 26
using namespace std;

char BCH[N]={'a','b','c','d','e','f','g',
	      'h','i','j','k','l','m','n',
	      'o','p','q','r','s','t','u',
	     'v','w','x','y','z'};

int main()
{
  char ch;
  int count[26]={0};

  while(cin >> ch){
    if(islower(ch)==0) ch=tolower(ch);
    for(int i=0;i<N;i++){
    if(ch==BCH[i]) count[i]++;
    }
  }

  for(int i=0;i<N;i++){
    cout << BCH[i] << " : " << count[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3072
# AOJ 1147: ICPC Score Totalizer Software
# Python3 2018.7.14 bal4u

while True:
	n = int(input())
	if n == 0: break
	s, vmin, vmax = 0, 1001, -1
	for i in range(n):
		a = int(input())
		vmin = min(vmin, a)
		vmax = max(vmax, a)
		s += a
	print((s-vmin-vmax)//(n-2))



Measured memory_bytes: 5596
#include "bits/stdc++.h"
 
using namespace ::std;
 
#define all(x)  x.begin(),x.end()
#define Unique(x) x.erase(unique(x.begin(), x.end()), x.end())

template< class T > T SQR(T N) {return (T) N * N;}
template< class T > double DIST(T a, T b) {return 1.0 * sqrt(SQR(double(a)) + SQR(double(b)));}
template< class T > bool CROSS(pair< T,T > a, pair< T,T > b, pair< T,T > c) {return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);}
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int,int > pi;
 
int px[] = {0, 1, -1, 0, -1, -1, 1};
int py[] = {1, 0, 0, -1, -1, 0, -1, -1};

const double eps = 1e-9;
 
inline ll power(ll a, ll p, ll mod)
{
    ll x = a, res = 1;
 
    while(p)
    {
        if(p&1) res = (res * x)%mod;
        p /= 2, x = (x * x)%mod;
    }
    return res;
}

int main()
{
    int n, m, c, d, a, b, k;
 
    int test;
 
    // scanf("%d", &test);
    // while(test--)
    // {
        scanf("%d%d", &n, &k);
        
        vector< int >p, mi;

        for(int i = 0; i<n; ++i)
        {
            scanf("%d", &a);
            if(a >= 0) p.push_back(a);
            if(a < 0) mi.push_back(-a);
        }

        sort(all(p)), sort(all(mi));
        a = p.size(), b = mi.size();

        ll res = 1, mod = 1e9 + 7;
        
        if(n == k) 
        {
            for(auto it : p) res = res * it%mod;
            for(auto it : mi)  res = res * (mod - it)%mod;
        }
        else if(a == 0 and k%2)
        {
            for(int i = 0; i<k; ++i) res = res * (mod - mi[i])%mod;
        }
        else
        {
            c = a - 1, d = b - 1;
            while (k)
            {
                if(c >= 1 and d >= 1 and k >= 2 and ll(1LL * mi[d] * mi[d - 1]) >= ll(1LL * p[c] * p[c - 1]))
                    res = res * ((1LL * mi[d] * mi[d - 1])%mod)%mod,
                    d -= 2, k -= 2;
                else if(c >= 1 and k >= 2)
                    res = res * p[c]%mod,
                    c--, k--;
                else if(d >= 1 and k >= 2)
                    res = res * ((1LL * mi[d] * mi[d - 1])%mod)%mod,
                    d -= 2, k -= 2;
                else if(c >= 0)
                    res = res * p[c]%mod,
                    c--, k--;
            }
        }

        printf("%lld\n", res);
    //}
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, Y; cin >> N >> Y;
  int N1000, N5000, N10000;
  bool ok = false;
  for (int i = 0; i <= N; i++){
    for (int j = 0; j <= N-i; j++){
      N1000 = i;
      N5000 = j;
      N10000 = N - i - j;
      int sum = 1000*N1000 + 5000*N5000 + 10000*N10000;
      if (sum == Y){
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
  }
  if(!ok) N1000 = N5000 = N10000 = -1;
  cout << N10000 << " " << N5000 << " " << N1000 << endl;
  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#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>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int arr[3][501];
string str;
bool check(int s, int t){
  if(s == t) return true;
  if(str[s] != 'm' || str[t-1] != 'w') return false;
  for(int i=s+1;i<t-1;++i){
	if(str[i] != 'e') continue;
	int j;
	for(j=0;j<2;++j)
	  if(arr[j][i-1] - arr[j][s] != arr[j+1][i-1] - arr[j+1][s]) break;
	if(j < 2) continue;
	for(j=0;j<2;++j)
	  if(arr[j][t-2] - arr[j][i] != arr[j+1][t-2] - arr[j+1][i]) break;
	if(j < 2) continue;

	if(check(s+1,i) && check(i+1,t-1))
	  return true;
  }
  return false;
}

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

  cin >> str;
  REP(i,SZ(str)){
	if(i > 0) REP(j,3) arr[j][i] = arr[j][i-1];
	if(str[i] == 'm') arr[0][i]++;
	else if(str[i] == 'e') arr[1][i]++;
	else if(str[i] == 'w') arr[2][i]++;
  }
  cout << (check(0, SZ(str))? "Cat": "Rabbit") << endl;
  
  return 0;
}

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

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

    ll N;
    ll A[100007] = {};
    ll B[100007] = {};
    cin >> N;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll ans = N;
    for (ll i = 0; i < N; i++) {
        if (i == 0) {
            B[i] = A[i];
        } else {
            B[i] = B[i - 1] + A[i];
            if (A[i] > (B[i - 1] * 2)) {
                ans = (N - i);
            }
        }
    }
    cout << ans << endl;
    // for (ll i = 0; i < N - 1; i++) {
    //     ll size = B[i];
    //     for (ll j = i + 1; j < N; j++) {
    //         if ((size * 2) >= A[j]) {
    //             if (j == N - 1) {
    //                 cout << (N - i) << endl;
    //                 return 0;
    //             } else {
    //                 size += A[j];
    //             }
    //         } else {
    //             break;
    //         }
    //     }
    // }

    return 0;
}


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

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

	vector<int> a(N * 3);
	int64_t ans = 0;
	rep(i, N * 3) cin >> a.at(i);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	rep2(i, N * 2, 1, 2) ans += a.at(i);
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

int N;
string ans;
string S;
signed main(){
	IO_STREAM;
	cin>>N>>S;

	int cnt=0;
	rep(i,0,N){
		if(S[i]==')'){
			cnt++;
		}
		else{
if(cnt <=0)  cnt--;
else
			break;
		}
	}
	rep(i,0,cnt){
		S='('+S;
		N++;
	}
	
	cnt=0;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='('){
			cnt++;
		}
		else{
if(cnt <=0) cnt--;
else			break;
		}
	}
	rep(i,0,cnt){
		S=S+')';
		N++;
	}

	DBG("S",S,N,"");
	int L=0,R=0;
	rep(i,0,N){
		if(S[i]=='(')	L++;
		else			R++;
	}
	if(R>L){
		rep(i,0,(R-L)){
			ans.pb('(');
		}
		ans=ans+S;
	}
	else if(L>R){
		ans=S;
		rep(i,0,(L-R)){
			ans.pb(')');
		}
	}
	else{
		ans=S;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	while (true) {
		int n = -1, ans = 0;
		cin >> n;
		if (n <= 0) break;
		string s;
		cin >> s;
		char prev = -1;
		for (char c : s) {
			ans += c != prev;
			prev = c;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A  = in.nextInt();
		int B  = in.nextInt();
		int C  = in.nextInt();
		int D  = in.nextInt();

        A = Math.max(A,C);
        B = Math.min(B,D);

        System.out.print(Math.max(0,B-A));
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	long K;
	int cnt;
	TreeMap<Integer, Long> Arr;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		N = Integer.parseInt(strArr[0]);
		K = Long.parseLong(strArr[1]);
		Arr = new TreeMap<Integer, Long>();
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		String[] strArr = str.split(" ");
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		if (Arr.containsKey(a))
			Arr.put(a, Arr.get(a) + b);
		else
			Arr.put(a, (long) b);
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
		long n = 0;
		for (int key : Arr.keySet()) {
			n += Arr.get(key);
			if (n >= K) {
				System.out.println(key);
				break;
			}
		}
	}
}


Measured memory_bytes: 45932
#include<iostream>
#include<cstdio>
int main() {
    int a[3];
    for(int i=0;i<3;i++) scanf("%d",a+i);
    std::swap(a[0],a[1]);
    std::swap(a[0],a[2]);
    printf("%d %d %d",a[0],a[1],a[2]);
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool f[100100] = {0};
    int ans[100100] = {0};

    int cnt_r = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            cnt_r++;
        }
        else {
            if (cnt_r % 2 == 0) {
                ans[i - 1] += cnt_r / 2;
                ans[i] += cnt_r / 2;
            }
            else {
                ans[i - 1] += cnt_r / 2 + 1;
                ans[i] += cnt_r / 2;
            }
            cnt_r = 0;
        }
    }
    ans[n - 1] += cnt_r;

    int cnt_l = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'L') {
            cnt_l++;
        }
        else {
            if (cnt_l % 2 == 0) {
                ans[i] += cnt_l / 2;
                ans[i + 1] += cnt_l / 2;
            }
            else {
                ans[i] += cnt_l / 2;
                ans[i + 1] += cnt_l / 2 + 1;
            }
            cnt_l = 0;
        }
    }
    ans[0] += cnt_l;

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

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int H,W;

	while(1){
		cin>>H>>W;
		if(H==0&&W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#113_C
N,M=map(int,input().split())
PY=[]
for i in range(M):
    p,y=map(int,input().split())
    PY.append((p,y,i))
PY=sorted(PY,key=lambda x:x[1])
PY=sorted(PY,key=lambda x:x[0])

Ans=[]
tmp=1
for j in range(M-1):
    p,y,i=PY[j]
    Ans.append(('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(tmp)))+str(tmp),i))
    if PY[j][0]==PY[j+1][0]:
        tmp+=1
    else:
        tmp=1
p,y,i=PY[M-1]
Ans.append(('0'*(6-len(str(p)))+str(p)+'0'*(6-len(str(tmp)))+str(tmp),i))
        
Ans=sorted(Ans,key=lambda x:x[1])
for i in range(M):
    print(Ans[i][0])

Measured memory_bytes: 37548
from sys import stdin


def main() -> int:
    global W
    W = next_int()
    a, b = map(int, input().split())

    if b + W < a:
        ans = diff(b + W, a)
    elif a + W < b:
        ans = diff(a + W, b)
    else:
        ans = 0

    print(ans)
    return 0


def diff(a: int, b: int) -> int:
    return abs(a - b)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

int main(){
	int n;
	double x[4];
	double y[4];
	double slope[2];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		slope[0] = (y[1] - y[0])/(x[1] - x[0]);
		slope[1] = (y[3] - y[2])/(x[3] - x[2]);
		if(slope[0] == slope[1]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
}

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

int main() {
  int n;
  cin>>n;
  vector<vector<vector<int>>> ta(n,vector<vector<int>> (n,vector<int> (1,66)));
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      int x,y;
      cin>>x>>y;
      x--;
      ta[i][x][0]=y;
      
    }
  }
 
  vector<int> seen(n);
  int ans=0;
  for(int i=0;i<(1<<n);i++){
    bitset<15> s(i);
    int d=0;
    int cu=0;
    for(int j=0;j<n;j++){
      if(s.test(j)) seen[j]=1;
      else seen[j]=0;
    }
    for(int h=0;h<n;h++){
      if(seen[h]){
        for(int g=0;g<n;g++){
       
          if(ta[h][g][0]==1){
            if(seen[g]!=1) {
              cu=1;
              break;
            }
          }
          else if(ta[h][g][0]==0){
            if(seen[g]!=0){
              cu=1;
              break;
            }
          }
        }
      }
      if(cu) break;
    }
 
    if(cu) continue;
    for(int u=0;u<n;u++){
      if(seen[u]) d++;
    }
    ans=max(ans,d);
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define IO ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
using namespace std;

string a,b;

int main()
{
	IO
	cin>>a>>b;
	
	int lena = a.size();
	int lenb = b.size();

	int ia = 0, ib = 0;
	
	while(ia < lena || ib < lenb){
		if(ia < lena)
			cout<<a[ia++];
		if(ib < lenb)
			cout<<b[ib++];
	}
	cout<<endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(a * b + " " + (a + b) * 2);

		sc.close();

	}

}



Measured memory_bytes: 26220
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL A,B,C,K;

string ans = "Yes";

void solve(){
	while(1){
		if(A>=B){
			B *= 2;
			K--;
		}else{
			break;
		}
	}
	while(1){
		if(B>=C){
			C *= 2;
			K--;
		}else{
			break;
		}
	}
	if(K<0) ans = "No";
}

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

    solve();

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

Measured memory_bytes: 3104
import java.util.*;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
		}
		boolean[] hoge = new boolean[N];
		for(int i = 0; i < N; i++) {
			hoge[i] = true;
		}
		for(int i = 0; i < M; i++) {
			hoge[a[i]] = false;
		}
		int sum = 0;
		for(int i = 0; i < N; i++) {
			boolean[] nex = new boolean[N >> (i+1)];
			
			if(nex.length == 0) break;
			for(int k = 0; k < hoge.length; k += 2) {
				if(hoge[k] && hoge[k+1]) {
					nex[k / 2] = true;
					sum++;
				}
				else if(!hoge[k] && hoge[k+1] || hoge[k] && !hoge[k+1]) {
					nex[k / 2] = true;
				}
			}
			hoge = nex;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26512
#include<bits/stdc++.h>
using namespace std;
int Q;
int C,A,N;
int main()
{
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%d%d%d",&C,&A,&N);
		int team=0;
		int te3=min(C,min(A,N));
		team+=te3;C-=te3;A-=te3;N-=te3;
		int te2=min(C/2,A);
		team+=te2;C-=2*te2;A-=te2;
		int te1=C/3;
		team+=te1;
		printf("%d\n",team);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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 ; cin>> n ;
  if(n==3){
    cout<<2<<" "<<5<<" "<<63<<endl ;
  }
  else{
    if(n<=15003){
      ll res= n%3 ;
      if(res==0){
        rep(i,n-4) cout<<2*(i+1)<<" " ;
        cout<<3<<" "<<9<<" "<<15<<" "<<21<<endl ;
      }
      else{
        rep(i,n-2) cout<<2*(i+1)<<" " ;
        cout<<3<<" "<<9<<endl ;
      }
      
    }

    else{
      ll w ;
      if(n%2==0) w=15000 ;
      else w=14999 ;
        rep(i,w) cout<<2*(i+1)<<" " ;
        rep(i,n-w){
          if(i==n-w-1) cout<<6*i+3<<endl ;
          else cout<<6*i+3<<" " ;
        }
      

    }
  }
   return 0 ;
 }



Measured memory_bytes: 3540
N=int(input())
a=[int(input()) for i in range(N)]
a.sort()
if N%2==0:
  m=N//2
  ans=-2*sum(a[:m-1])-a[m-1]+a[m]+2*sum(a[m+1:])
if N%2==1:
  m=N//2
  ans=-2*sum(a[:m-1])-a[m-1]-a[m]+2*sum(a[m+1:])
  ans=max(ans,-2*sum(a[:m])+a[m]+a[m+1]+2*sum(a[m+2:]))

print(ans)

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

int main() {
  int tmp;
  vector< vector<int> > C(3);
  for (int i = 0; i < 3; i++) {
    cin >> tmp; C[i].push_back(tmp);
    cin >> tmp; C[i].push_back(tmp);
    cin >> tmp; C[i].push_back(tmp);
  }
  vector<int> A(3), B = C[0];
  A[0] = 0;
  A[1] = C[1][0] - B[0];
  A[2] = C[2][0] - B[0];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (C[i][j] != A[i] + B[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

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

  int ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  vector<int> x;
  rep(i, a){
    if (b + i <= 1e7) x.push_back(b + i);
    if (i != 0){
      if (b - i >= -1e7) x.push_back(b - i);
    }
  }
  sort(all(x));
  rep(i, x.size()){
    cout << x.at(i);
    if (i != x.size() - 1) cout << " ";
    else cout << endl;
  }

  //cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define int long long
using namespace std;

class segtree{
	int n,seg,init;
	vector<int> dat;
public:
	segtree(int siz,int def) : n(siz),init(def),seg(1){
		while(seg < n) seg *= 2;
		dat.resize(seg * 2 - 1);
		for(int i = 0;i < seg * 2 - 1;i++) dat[i] = init;
	}
	void update(int i,int x){
		i += seg - 1;
		dat[i] = x;
		while(i){
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1],dat[i * 2 + 2]); //do
		}
	}
	int get(int a = 0,int b = -1,int k = 0,int l = 0,int r = -1){
		if(b == -1) b = seg;
		if(r == -1) r = seg;
		if(b <= l || r <= a) return init;
		if(a <= l && r <= b) return dat[k];
		return min(get(a,b,k * 2 + 1,l,(l + r) / 2),get(a,b,k * 2 + 2,(l + r) / 2,r)); //do
	}
};

signed main(){
	int n,q;
	cin >> n >> q;
	segtree rmq(n,(1<<31)-1);
	for(int i = 0;i < q;i++){
		int t,a,b;
		cin >> t >> a >> b;
		if(t == 0){
			rmq.update(a,b);
		}else{
			cout << rmq.get(a,b + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4968
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    char N,M;cin>>N>>M;

    if(N<M) cout<<"<"<<endl;
    else if(N>M) cout<<">"<<endl;
    else cout<<"="<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef long double ld;
signed  main() {
	string s;
	cin >> s;
	int n = s.size(), ans = 1000000000000;
	for (int z = 0; z < 26; z++) {
		char a = (char)z + 'a';
		int sum = 0;
		int d[26];
		fill(d, d + 26, 0);
		string h = s;
		for (int i = 0; i < n; i++)
			d[(int)s[i] - 'a']++;
		for (int i = 0; i < 26; i++) {
			if (d[i] != 0)
				sum++;
		}
		if (sum == 1)
			ans = 0;
		if (a == 'v')
			int o = 0;
		for (int i = n - 1; i >= 0; i--) {
			for (int j = 0; j < i; j++) {
				if (h[j] == a)
					continue;
				if (h[j + 1] == a) {
					d[(int)h[j] - 'a']--;
					if (d[(int)h[j] - 'a'] == 0)
						sum--;
					h[j] = a;
					d[(int)a - 'a']++;
				}
			}
			d[(int)h[i] - 'a']--;
			if (d[(int)h[i] - 'a'] == 0)
				sum--;
			if (sum == 1) {
				ans = min(n - i, ans);
				break;
			}
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  double L; scanf("%lf", &L);
  printf("%lf\n", pow(L/3, 3));
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int n,H,W;
char c;

int memo[65536];
int visi[65536];
int Q[65537];
int head = 0 , size = 0;
int A[10000],B[10000],sz=0;
char goal[5][5];
int w[20],h[20];
inline void gen(int s,int x,int y){
	int i,j,k;
	rep(k,3){
		int a=0,b=0;
		rep(i,h[s]){
			rep(j,w[s]){
				int tx = x + j;
				int ty = y + i;
				if(tx >= 0 && tx < 4 && ty < 4 && ty >= 0){
						a |= 1<<(ty*4+tx);
						b |= (goal[ty][tx] == k)<<(ty*4+tx);
				}
			}
		}
		if(b){
			A[sz] = a;
			B[sz] = b;
			++sz;
		}
	}
}
int f(){
	int i,j,k;
	Q[size++] = 0;
	memo[0] = 0;
	int good = (1<<16)-1;
	while(head < size){
		int q = Q[head++];
		int cost = memo[q];
		if(good == q) return cost;
		
		rep(i,sz){
			int bit = (q & ~A[i]) | B[i];
			if(!visi[bit]){
				visi[bit] = 1;
				memo[bit] = cost + 1;
				Q[size++] = bit;
			}
		}
	}
	

}

int main(){
	int i,j,k;
	scanf("%d",&n);
	rep(i,n) scanf("%d%d",h+i,w+i);
	rep(i,4){
		scanf("%s",goal[i]);
		rep(j,4){
			if(goal[i][j]=='R')goal[i][j] = 0;
			else if(goal[i][j]=='G')goal[i][j] = 1;
			else if(goal[i][j]=='B')goal[i][j] = 2;
		}
	}
	rep(k,n){
		rep(i,7)rep(j,7){
			gen(k,i-3,j-3);
		}
	}
	printf("%d\n",f());
	return 0;
	
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score=0;
    rep(i,n-1){
        if(s[i]==s[i+1]) score++;
    }
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
}

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

#define ll long long
#define pb push_back

int N, M;
vector<pair<int, int>> V;
bool flag[10];
ll ans = 0;

void flagInit(){
	for(int i = 1; i <= N; i ++)flag[i] = true;
}
bool checkAllFlagTrue(){
	for(int i = 1; i <= N; i ++)if(!flag[i])return false;
	return true;
}
void search(int node){
	flag[node] = true;
	if(checkAllFlagTrue()){
		ans ++;
		return;
	}
	for(int i = 1; i <= M; i ++){
		if(V[i].first == node && !flag[V[i].second]){
			search(V[i].second);
			flag[V[i].second] = false;
		}
		if(V[i].second == node && !flag[V[i].first]){
			search(V[i].first);
			flag[V[i].first] = false;
		}
	}
}

int main(){

	cin >> N >> M;
	V.pb(make_pair(0, 0));
	for(int i = 1; i <= M; i ++){
		int a, b;
		cin >> a >> b;
		V.pb(make_pair(a, b));
	}
	search(1);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] S = new int[100000];
        int[] T = new int[50000];
        String[] in_S = br.readLine().split(" ");
        for(int i = 0; i < n; i++){
            S[i] = Integer.parseInt(in_S[i]);
        }
        int q = Integer.parseInt(br.readLine());
        String[] in_T = br.readLine().split(" ");
        int sum = 0;
        for(int i = 0; i < q; i++){
            T[i] = Integer.parseInt(in_T[i]);
            if( binarySearch(S, n, T[i])) sum++;
        }
        System.out.println(sum);
    }

    public static boolean binarySearch(int[] A, int n, int key){
        int left = 0;
        int right = n;
        int mid;
        while(left < right){
            mid = (left + right) / 2;
            if(A[mid] == key) return true;
            else if(A[mid] < key) left = mid + 1;
            else right = mid;
        }
        return false;
    }

}

Measured memory_bytes: 47456
# input
H, W = map(int, input().split())
a = [list(input()) for h in range(H)]

for w in range(W):
    g = [a[h][w] for h in range(H)]
    if set(g) == {"."}:
        for h in range(H):
            a[h][w] = ""

for h in range(H):
    g = a[h]
    if set(g) != {"."} and set(g) != {"", "."}:
        print("".join(g))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
    while (b) {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}

ll po(ll a, ll b) {
    ll c = 1;
    while (b) {
        if (b % 2) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

ll f[2000006], g[2000006];

void comb() {
    f[0] = 1;
    for (int i = 1; i <= 2000000; i++) f[i] = f[i - 1] * i % mod;
    g[2000000] = 407182070;
    for (int i = 1999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
}

int p[200005];

int root(int x) {return p[x] < 0 ? x : p[x] = root(p[x]);}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    ios::sync_with_stdio(false);
    int n, k, z = 1;
    string s;
    cin >> n >> k >> s;
    for (int i = 1; i < n; i++) if (s[i] != s[i - 1]) z++;
    z -= k * 2;
    z = max(1, z);
    cout << n - z;
}


Measured memory_bytes: 3772
def resolve():
    N,K=map(int,input().split())
    S=input()
    c=0
    for i in range(N):
        if S[i]=='L':
            if i>0:
                if S[i-1]=='L':
                    c+=1
        else:
            if i<N-1:
                if S[i+1]=='R':
                        c+=1
    a=2*K
    print(min(c+a,N-1))
resolve()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 1e18
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+2];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++)
    {
    	ans=ans+a[i];
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3636
(let* ((n (read))
       (a (make-array (list (1+ n))))
       (b (make-array (list (1+ n )))))
  (loop :for i :from 1 :to n
        :do (setf (aref a i) (read)))
  (loop :for i :from 1 :to n
        :do (if (= (mod i 2) 1)
                (incf (aref b 1) (aref a i))
                (decf (aref b 1) (aref a i))))
  (loop :for i :from 2 :to n
        :do (setf (aref b i) (* (- (aref a (1- i)) (/ (aref b (1- i)) 2)) 2)))
  (loop :for i :from 1 :to (1- n)
        :do (format t "~A " (aref b i)))
  (format t "~A~%" (aref b n)))


Measured memory_bytes: 77116
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)
 
int main()
{
  int M, N, C[10000], E[10000];
  int P[10001] = {0};
 
  cin >> M >> N;
  for(int i = 1; i <= M; i++) {
    cin >> P[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i] >> E[i];
  }
 
  sort(P + 1, P + M + 1, greater< int >());
  for(int i = 1; i <= M; i++) {
    P[i] += P[i - 1];
  }
 
  int dp[20001];
  fill_n(dp, 20001, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 20000; j >= C[i]; j--) {
      dp[j] = min(dp[j], dp[j - C[i]] + E[i]);
    }
  }
  for(int i = 19999; i >= 0; i--) {
    dp[i] = min(dp[i], dp[i + 1]);
  }
  int ret = 0;
  for(int i = 0; i <= M; i++) {
    ret = max(ret, P[i] - dp[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1312
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T>
class BIT {
public:
    vector<T> v;
    BIT(int n) {
        v.resize(n + 1, 0);
    }
    void add(int pos, T x) {
        pos++;
        for (; pos < static_cast<int>(v.size()); pos += (pos & (-pos))) {
            v[pos] += x;
        }
    }
    T get(int pos) {
        pos++;
        T ans = 0;
        for (; pos > 0; pos -= (pos & (-pos))) {
            ans += v[pos];
        }
        return ans;
    }
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<lli> A(N + 1, 0);
    REP(i, 0, N) {
        cin >> A[i + 1];
        A[i + 1] -= K;
    }
    REP(i, 0, N) {
        A[i + 1] += A[i];
    }
    vector<lli> B(begin(A), end(A));
    sort(begin(B), end(B));
    B.erase(unique(begin(B), end(B)), end(B));
    REP(i, 0, N + 1) {
        A[i] = lower_bound(begin(B), end(B), A[i]) - begin(B);
    }
    lli ans = 0;
    BIT<lli> bt(N + 1);
    REP(i, 0, N + 1) {
        ans += bt.get(A[i]);
        bt.add(A[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define mod 1000000007
#define pb push_back  

int main()
{
   IOS
   
   ll n,m,i,j;
   cin>>n>>m;
   
   char c[n+1][m+1];
   for(i=1;i<=n;i++)
   {
   	for(j=1;j<=m;j++)
   	{
   		cin>>c[i][j];
   	}
   }
   ll dp[n+1][m+1];
   memset(dp,0,sizeof(dp));
   dp[1][1]=1;
   ll cnt=0;
   for(i=1;i<=n;i++)
   {
   	for(j=1;j<=m;j++)
   	{
   	  cnt++;
   	  if(c[i][j] == '.' && cnt!=1)
   	  {
   	  	dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
   	  }
   	}
   }
   cout<<dp[n][m]<<endl;
}

Measured memory_bytes: 12332
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 222222
int N,A[MX],B[MX],H[MX],T=2e9;
bool cp(int a,int b){return B[a]<B[b];}
int main(void){
    scanf("%d",&N),iota(H,H+N,0);
    F(N)scanf("%d%d",A+i,B+i);
    sort(H,H+N,cp),reverse(H,H+N);
    F(N)T=min(T,B[H[i]])-A[H[i]];
    if(T<0)return puts("No"),0;
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k ,s;
  cin >> k >> s;
  int ans =0;
  for(int i = 0;i<=k;i++){
    for(int j = 0;j<=k;j++){
      if( s - i - j >=0 && s-i-j<=k){
        ans++;
      }
    }
  }
  cout << ans;
}

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

using namespace std;

int main(){
    long long a,b,c,K;
    long long ans=0;

    cin>>K;

    for(a=1;a<=K;a++){
        for(b=1;b<=K;b++){
            for(c=1;c<=K;c++){
                ans=ans+gcd(a, gcd(b,c));
            }
        }

    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
//#define sort(x) sort(x.begin(), x.end())
#define MAX 1000005

int main()
{
//O_O ;
    int ar[100];
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(ll i=0; i<n; i++)
    {
        cin>>ar[i];
        ans+=ar[i];
    }
    double temp=1.0/(4*m);
    double z=(temp*ans);
    int c=0;
    for(ll i=0; i<n; i++)
    {
        if(ar[i]>=z)
            c++;
    }
    if(c<m)
        cout<<"No"<<nn;
    else
        cout<<"Yes"<<nn;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[101],w[101],n,W;
long long dp[101][100001];
long long f(int pos,int W){
	if(pos==n)return 0;
	long long &res=dp[pos][W];
	if(~res)return res;
	res=f(pos+1,W);
	if(w[pos]<=W)res=max(res,f(pos+1,W-w[pos])+arr[pos]);
	return res;
}

int main(int argc, char const *argv[])
{
	memset(dp,-1,sizeof dp);
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>w[i]>>arr[i];
	cout<<f(0,W)<<endl;
	return 0;
}

Measured memory_bytes: 79104
import java.util.*;


class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();


        int l= Integer.toString(n,k).length();

        System.out.println(l);


    }
    public static void main2(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int k = s.nextInt();


        if(n>=10){
            System.out.println(k);
            return;
        }

        int hoge=k+100*(10-n);
        System.out.println(hoge);


    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#define N (200000+1000)
using namespace std;

int n,a[N],l,r,ans,mid;
int g(int x){return x>mid;}

int check(int x)
{
	for (int i=1; i<=n-1; ++i)
	{
		if (g(a[n-i+1])==g(a[n-i])) return g(a[n-i]);
		if (g(a[n+i-1])==g(a[n+i])) return g(a[n+i]);
	}
	return g(a[1]);
}

int main()
{
	scanf("%d",&n);
	for (int i=1; i<=2*n-1; ++i)
		scanf("%d",&a[i]);
	l=1; r=2*n-1; ans=-1;
	while (l<=r)
	{
		mid=(l+r)>>1;
		if (!check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
}

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

int main(void){
    int a = 0, b = 0, c = 0;
    int k = 0;
    int max = 0;

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

    for(int i = 0; i < k; i++){
        if(a >= b && a >= c){
            a *= 2;
        }else if(b >= a && b >= c){
            b *= 2;
        }else{
            c *= 2;
        }
    }

    max = a + b + c;

    printf("%d\n", max);

    return 0;

} 


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

using namespace std;
using ll = long long;

const ll INF = 1e15;

int main() {
  int n;
  cin >> n;
  vector<ll> pf(n);
  cin >> pf[0];
  for (int i=1; i<n; ++i) {
    cin >> pf[i];
    pf[i] += pf[i-1];
  }
  vector<vector<ll>> dp(n, vector<ll> (n, INF));
  for (int i=0; i<n; ++i)
    dp[i][i] = 0;
  for (int a=n-1; a>=0; --a) {
    for (int b=a+1; b<n; ++b) {
      for (int k=a; k<b; ++k) {
        dp[a][b] = min(dp[a][b], dp[a][k] + dp[k+1][b]);
      }
      if (a != b)
        dp[a][b] += pf[b] - (a ? pf[a-1] : 0);
    }
  }
  cout << dp[0][n-1] << '\n';
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  int x, y;
  while (cin >> x >> y) {
    set<int> a({1, 3, 5, 7, 8, 10, 12});
    set<int> b({4, 6, 9, 11});

    if (a.count(x) && a.count(y)) {
      cout << "Yes" << endl;
      continue;
    }
    if (b.count(x) && b.count(y)) {
      cout << "Yes" << endl;
      continue;
    }
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
t = 0
while t == 0:	
	try:
		a,b,e,c,d,f = [int(i) for i in input().split()]
	except:
		break
	else:
		x = (d*e - b*f) / (a*d - b*c) + 0
		y = (a*f - c*e) / (a*d - b*c) + 0
		print("{0:.3f}".format(x) + " " + "{0:.3f}".format(y))

Measured memory_bytes: 7712
#include <iostream>
#include "bits/stdc++.h"

#include <vector>
#include <string>
using namespace std;

int main(){
	string a, b;
	vector<int> ans;
	int n, num, ai, bi, c=0;
	bool flag;

	cin >> n;

	for(int i=0 ; i<n ; i++){
		cin >> a >> b;
		flag = false;

		for(int j=0 ; j<100 ; j++){
			num = 0;
			ai = a.size()-j-1;
			bi = b.size()-j-1;
			if( ai<0 && bi<0 && c==0) break;

			if(ai>=0)num += a[ ai ] - 48;
			if(bi>=0)num += b[ bi ] - 48;
			ans.push_back( (num+c)%10 );
			if(num+c >= 10) c = 1;
			else c = 0;
		}
		if(ans.size()>80){
			printf("overflow");
		}else{
			for(int j=ans.size()-1 ; j>=0 ; --j){
				printf("%d", ans[j]);
			}
		}
		printf("\n");
		ans.clear();
	}
	return 0;
}

Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int N, W; std::cin >> N >> W;
    std::vector<int> w(N), v(N);
    for(int i(0); i < N; ++i){
        std::cin >> w[i] >> v[i];
    }
    //i番目(0o)まで, 重さj で価値最大値
    std::vector<std::vector<long long>> dp(N+1, std::vector<long long>(W+1, 0));
    for(int i(0); i < N; ++i){
        for(int j(0); j <= W; ++j){
            if(j >= w[i]) chmax(dp[i+1][j], dp[i][j-w[i]] + v[i]);

            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    std::cout << dp[N][W] << std::endl;
    return 0;
}


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

typedef long long int ll;

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    n = min(n, b-1);
    ll ans = a * n;
    ans /= b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int x,a;
  cin >> x >> a;
  if(x<a){
  cout << 0 << endl;
  }
  else{
  cout << 10 << endl;
  }
}



Measured memory_bytes: 256
n,a,b=map(int,input().split())

ans=0
for i in range(1,n+1):
    c=i
    total=0
    for j in range(5):
        total +=(i%10)
        i =i//10
        
    if total >= a and total <= b:
        ans +=c
        
print(ans)        

Measured memory_bytes: 3060
#include<iostream>
#include<map>

using namespace std;

int main(){

	int N;

	cin >> N;

	string val = to_string(N);

	if((val[0] == val[1] && val[1] == val[2]) || (val[1] == val[2] && val[2] == val[3]) ){
		cout << "Yes";
	}else{
		cout << "No";
	}


	return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int min = n+1;
        int max = 0;
        int l,r;
        for(int i=0;i<m;i++){
            l = Integer.parseInt(sc.next());
            r = Integer.parseInt(sc.next());
            min = Math.min(r,min);
            max = Math.max(l,max);
        }
        if(min-max>=0){
            System.out.println(min-max+1);
        }else{
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 49004