akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

ll com(int n, int r) {

	ll re = 1;

	rep(i, r) {
		re *= n - r + 1 + i;
		re /= i + 1;
	}

	return re;

}

int main() {

	int n, a, b;
	cin >> n >> a >> b;
	V<ll> v(n);
	rep(i, n)cin >> v[i];
	sort(all(v), greater<ll>());
	ll sum = 0;
	rep(i, a)sum += v[i];

	cout << fixed << setprecision(8);
	cout << (double)sum / a << endl;

	ll ans = 0;

	if (v[0] == v[a - 1]) {
		reverse(all(v));
		int k = upper_bound(all(v), v[n - 1]) - lower_bound(all(v), v[n - 1]);
		for (int i = a;i <= min(k, b);i++)ans += com(k, i);
		cout << ans << endl;
	}
	else {
		reverse(all(v));
		int k = upper_bound(all(v), v[n - a]) - lower_bound(all(v), v[n - a]);
		int l = upper_bound(all(v), v[n - a]) - v.begin();
		l -= n - a;
		ans = com(k, l);
		cout << ans << endl;
	}

}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if(n < 1200)System.out.println("ABC");
        else if(n < 2800)System.out.println("ARC");
        else System.out.println("AGC");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;

  if (S == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PokerPlaying {
    class Player {
        static void Main(string[] args) {
            
            while (true) {
                string stsize = Console.ReadLine();
                int size = int.Parse(stsize);
                if (size == 0) {
                    return;
                }
                int[,] matrix = new int[size + 1, size + 1];
                for (int i = 0; i < size; i++) {
                    string data = Console.ReadLine();
                    string[] splitData = data.Split(' ');
                    for (int j = 0; j < size; j++) {
                        matrix[i, j] = int.Parse(splitData[j]);
                    }
                }
                string[,] result = calcMtx(matrix);
                for (int i = 0; i < matrix.GetLength(0); i++) {
                    for (int j = 0; j < matrix.GetLength(1); j++) {
                        Console.Write(string.Format("{0,5}",result[i,j].ToString()));
                    }
                    Console.Write("\r\n");
                }
            }            
        }

        public static string[,] calcMtx(int[,] matrix) {
            for (int i = 0; i < matrix.GetLength(0)-1; i++) {
                for (int j = 0; j < matrix.GetLength(1)-1; j++) {
                    matrix[i, matrix.GetLength(1) - 1] += matrix[i, j];
                    matrix[matrix.GetLength(0) - 1, i] += matrix[j, i];
                }
                matrix[matrix.GetLength(0) - 1 , matrix.GetLength(1) - 1] += matrix[i, matrix.GetLength(1) - 1 ];
            }


            string[,] data = new string[matrix.GetLength(0),matrix.GetLength(1)];
            for (int i = 0; i < matrix.GetLength(0); i++) {
                for (int j = 0; j < matrix.GetLength(1); j++) {
                    data[i, j] = matrix[i, j].ToString();
                }
            }
            return data;
        }

    }

   
}

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

int N,c[60];
ll A[100000],res,p;

int main(){
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	for(int i=0;i<60;++i){
		for(int j=0;j<N;++j){
			if(A[j]&(1ll<<i)){
				++c[i];
			}
		}
		if(c[i]&1){
			res+=(1ll<<i);
			for(int j=0;j<N;++j){
				if(A[j]&(1ll<<i)){
					A[j]^=(1ll<<i);
				}
			}
		}
	}
	for(int i=59;i>=0;--i){
		ll t=0;
		for(int j=0;j<N;++j){
			if(A[j]&(1ll<<i)){
				t=A[j];
				break;
			}
		}
		for(int j=0;j<N;++j){
			if(A[j]&(1ll<<i)){
				A[j]^=t;
			}
		}
		if(!(p&(1ll<<i))){
			p^=t;
		}
	}
	for(int i=59;i>=0;--i){
		if((c[i]%2==0)&&(p&(1ll<<i))){
			res+=(2ll<<i);
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	static int p,t,r;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			t=sc.nextInt();
			p=sc.nextInt();
			r=sc.nextInt();
			if(t+p+r==0)break;
		
			
			ArrayList<Data>list=new ArrayList<Data>();//listに入れる処理をしなきゃね			
			for(int i=0;i<t;i++){
				list.add(new Data(i+1));
			}
			for(int i=0;i<r;i++){
				int teams=sc.nextInt()-1;
				int number=sc.nextInt();
				int pena=sc.nextInt();
				String mes=sc.next();
				list.get(teams).solve(number, pena, mes);
			}
			Collections.sort(list);
			for(int i=0;i<list.size();i++){
				System.out.println(list.get(i));
			}
		}
	}
	static class Data implements Comparable<Data>{
		int team,ans,pena;
		int wrong[];boolean t[];
		public Data(int id){
			this.team=id;
			this.ans=0;
			this.pena=0;
			wrong=new int[p+1];
			t=new boolean[p+1];
		}
		void solve(int problem,int time,String message){//提出したときの処理
			if(message.equals("CORRECT")){
				if(t[problem])return;
				ans++;
				pena+=time+wrong[problem]*1200;
				t[problem]=true;
			}else{
				wrong[problem]++;
			}
		}
		@Override
		public int compareTo(Data o) {
			if(this.ans<o.ans){
				return 1;
			}else if(this.ans>o.ans){
				return -1;
			}else if(this.pena>o.pena){
				return 1;
			}else if(this.pena<o.pena){
				return -1;
			}else if(this.team>o.team){
				return 1;
			}else if(this.team<o.team){
				return-1;
			}return 0;
		}
		public String toString(){
			return this.team+" "+this.ans+" "+this.pena;
		}
	}
}

Measured memory_bytes: 61824
#include "stdio.h"
#include "math.h"

int a,b,c;
double pi=3.141592653;
double rad;
double S,L,h;
int main(void){
	scanf("%d %d %d",&a,&b,&c);
	rad=pi*c/180;
	S=(double)a*(double)b*sin(rad)/2;
	L=sqrt((double)a*(double)a+(double)b*(double)b-2*(double)a*(double)b*cos(rad))+(double)a+(double)b;
	h=S*2/(double)a;
	printf("%f\n",S);
	printf("%f\n",L);
	printf("%f\n",h);
	return 0;
}
	

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
    long k;
    cin >> k;
    int ans = -1;
    int retu = 7;
    for(long i=1;i<=10000000;i++){
        if(retu % k == 0){
            ans = i;
            break;
        }else{
            retu = (retu*10+7)%k;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
yes_no = lambda x: 'Yes' if x else 'No'

def solve():
    N, K, Q = map(int, input().split())
    point = [0]*N
    for _ in range(Q): 
        point[int(input())-1] += 1

    print('\n'.join([yes_no(p+K-Q > 0) for p in point]))
    
solve()

Measured memory_bytes: 5044
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.NoSuchElementException;

public class Main {

	static final int[] dx = { -1, 0, 0, 1 };
	static final int[] dy = { 0, -1, 1, 0 };

	static int h, w, n;
	static char[][] block;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		h = sc.nextInt();
		w = sc.nextInt();
		n = sc.nextInt();

		block = new char[h][w];
		int[][] point = new int[n + 1][2];

		for (int y = 0; y < h; y++) {
			block[y] = sc.next().toCharArray();
			for (int x = 0; x < w; x++) {
				char c = block[y][x];
				if (c == 'S') {
					point[0] = new int[] { x, y };
				} else if ('1' <= c && c <= '9') {
					point[c - '0'] = new int[] { x, y };
				}
			}
		}

		int total = 0;
		for (int i = 0; i < n; i++) {
			total += bfs(point[i][0], point[i][1], point[i + 1][0], point[i + 1][1]);
		}

		System.out.println(total);
	}

	static int bfs(int sx, int sy, int gx, int gy) {
		Deque<int[]> q = new ArrayDeque<>();
		boolean[][] visited = new boolean[h][w];
		q.offer(new int[] { sx, sy, 0 });
		while (!q.isEmpty()) {
			int[] now = q.poll();
			if (now[0] == gx && now[1] == gy) return now[2];
			for (int i = 0; i < 4; i++) {
				int nx = now[0] + dx[i];
				int ny = now[1] + dy[i];
				if ((0 <= ny && ny < h) && (0 <= nx && nx < w) && !visited[ny][nx] && block[ny][nx] != 'X') {
					visited[ny][nx] = true;
					q.offer(new int[] { nx, ny, now[2] + 1 });
				}
			}
		}
		return -1;
	}
}

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 byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			System.out.println("poyo");
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte 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();
		}
	}

}

Measured memory_bytes: 65816
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        double temp = N / 1.08;
        int Ans = (int)temp;
        if (N == (int)(Ans * 1.08)) { Console.WriteLine(Ans); }
        else if(N == (int)((Ans + 1) * 1.08)) { Console.WriteLine(Ans+1); }
        else { Console.WriteLine(":("); }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(){
    int a,b,i,j;
    scanf("%d %d",&a,&b);
    while(1){
        if(a==0&&b==0){
            break;
        }
        else{
            for(i=0;i<a;i++){
                for(j=0;j<b;j++){
                    printf("#");
                }
                printf("\n");
            }
        }
        printf("\n");
        scanf("%d %d",&a,&b);
    }
    return 0;
}


Measured memory_bytes: 2108
n,a,b,c,d = map(int, input().split())
s = input()
if s[a:c-1].count("##")!=0 or s[b:d-1].count("##")!=0:
	print("No")
	exit()

if c > d:
	if s[b-2:d+1].count("...") == 0:
		print("No")
		exit()
print("Yes")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
ll solve() {
    ll n; cin >> n;
    vector<ll> c(n); cin >> c;
    vector<ll> v(n, 0);
    ll Q; cin >> Q;
    rep(q, Q) {
        ll t, x, d; cin >> t >> x >> d; --x;
        if (t == 1) {
            v[x] += d;
            if (v[x] > c[x]) return x+1;
        }
        else {
            v[x] -= d;
            if (v[x] < 0) return x+1;
        }
    }
    return 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << solve() << endl;
}



Measured memory_bytes: 3240
#include<iostream>
int main(){
	int n,ret=0,b1,b2,list[101];
	bool isrev=true;
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>list[i];
	}
	while(isrev){
		isrev=false;
		for(int i=n-1;i>=1;i--){
		    if(list[i]<list[i-1]){
		    	b1=list[i],b2=list[i-1];
		    	list[i]=b2,list[i-1]=b1;
			    isrev=true;
			    ret++;
		    }
	    }

	}
	for(int i=0;i<n;i++){
		std::cout<<list[i];
		if(i!=n-1)std::cout<<" ";
		else std::cout<<"\n";
	}
	std::cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3092
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String s=in.next();
		int n=s.length();
		int[][] dp=new int[n+n+1][n+n+1];
		int[] c1=new int[n+1];
		int[] c2=new int[n+1];
		for (int i=1;i<=n;++i) {
			c1[i]=c1[i-1];
			c2[i]=c2[i-1];
			if (s.charAt(i-1)=='0') c1[i]+=2;
			else if (s.charAt(i-1)=='2') c2[i]+=2;
			else {
				++c1[i];
				++c2[i];
			}
		}
		dp[0][0]=1;
		for (int i=0;i<=c1[n];++i)
			for (int j=0;j<=c2[n];++j) if (c1[Math.min(n,i+j)]>=i&&c2[Math.min(n,i+j)]>=j) {
				if (i>0) dp[i][j]+=dp[i-1][j];
				if (dp[i][j]>=998244353) dp[i][j]-=998244353;
				if (j>0) dp[i][j]+=dp[i][j-1];
				if (dp[i][j]>=998244353) dp[i][j]-=998244353;
			}
		System.out.println(dp[c1[n]][c2[n]]);
	}
}

Measured memory_bytes: 131668
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char temp='a';
		char[] s = sc.next().toCharArray();
		String ans = "Good";
		for (char c : s) {
			if(temp == c) ans = "Bad";
			temp = c;
		}
		System.out.println(ans);
	}
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  str s;
  cin>>s;
  int g=0,p=0,ans=0;
  each(c,s){
    if(c=='g'){
      if(p+1<=g)ans++,p++;
      else g++;
    }
    else{
      if(p+1<=g)p++;
      else ans--,g++;
    }
  }
  out(ans);
  
  
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 1010;
int N;
map<int, int> cnt[MAX_N];
map<int, int> deg;
int main() {
  cin >> N;
  for (int i = 2; i <= N; i++){
    int tmp = i;
    for (int j = 2; j <= N / 2; j++){
      while (tmp % j == 0){
        cnt[i][j]++;
        tmp /= j;
        if (j == 1)break;
      }

    }
    cnt[i][tmp]++;
  }
  for (int i = 2; i <= N; i++){
    for (auto &val : cnt[i]){
      deg[val.first] += val.second;
    }
  }
  ll result = 1;
  for (auto &val : deg){
    if (val.first == 1)continue;
    // cout << val.first << " "<< val.second << endl;
    result *= (val.second + 1);
    result %= MOD;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S = "ACL";
    int K; cin >> K;
    rep(i, K) cout << S;
    cout << endl;

    return 0;
}


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

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

  int size = s.size();

  for (int i = 0; i < size; i++) {
    if (s[i] == 'R') {
      if (i % 2 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (s[i] == 'L') {
      if (i % 2 == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;

int main(){
	int N; cin >> N;
	int W[N];
	for(int i=0; i<N; i++) cin >> W[i];
	int ans = 1e9;
	for(int i=1; i<N; i++){
		int ans1 = 0, ans2 = 0;
		for(int j=0; j<N; j++){
			if(j <= i) ans1 += W[j];
			else ans2 += W[j];
		}
		if(ans > abs(ans1 - ans2)) ans = abs(ans1 - ans2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


a, b, c, d = LI()
print('Yes' if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d) else 'No')


Measured memory_bytes: 9136
s = input()
k = int(input())

smin = list(set(list(s)))
smin = sorted(smin)[0:5]


def search(st):
    ans = []
    cnt = 0
    for a in st:
        if len(set(ans)) >= 5:
            return ans
        for i in range(len(s)):
            if s[i] is a:
                for j in range(1,6):
                    ans.append(s[i:min(i+j,len(s))])

    
    return ans
    
b = list(set(search(smin)))
b = sorted(b)
if b[0] == '':
    del b[0]

print(b[k-1])

Measured memory_bytes: 4324
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

a,b,c,d = readInts()

ans = b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
ans+=b//(c*d//(math.gcd(c,d)))-(a-1)//(c*d//(math.gcd(c,d)))

print(ans)

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

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

  vector<pair<long,long>> vec;
  for (int i = 0; i < n; i++)
  {
    long long x,l;
    cin >> x >> l;
    vec.emplace_back(x+l,x-l);
  }  
  sort(vec.begin(),vec.end());

  long long minr = -1e10;
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    long long l,r;
    r = vec[i].first;
    l = vec[i].second;
    if(l < minr) continue;
    minr=r;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2420
import sys
n=int(input())
L=[0 for i in range(n+1)]
a=list(map(int,input().split()))
if n==1 and a[0]==1:
  print(1)
  print(1)
  sys.exit()
for i in range((n//2)+1,n+1):
  L[i]=a[i-1]
  if L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
for i in range(n//2,0,-1):
  L[i]=(a[i-1]+L[i])%2
  if i!=1 and L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
ct=0
for i in range(1,len(L)):
  if L[i]==1:ct+=1
print(ct)
ans=[]
for i in range(1,len(L)):
  if L[i]==1:ans.append(str(i))
print(' '.join(ans))

Measured memory_bytes: 72700
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
const int INF = 1e9;

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

    int n;
    cin >> n;

    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    vector<vector<int>> edge(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }

    vector<int> ans(n), dp(n, INF);

    auto dfs = [&](auto dfs, int cur, int par) -> void {
        int idx = lower_bound(dp.begin(), dp.end(), a[cur]) - dp.begin();
        int prev = dp[idx];
        dp[idx] = a[cur];

        ans[cur] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

        for (int ch : edge[cur]) {
            if (ch == par) continue;
            dfs(dfs, ch, cur);
        }

        dp[idx] = prev;
    };

    dfs(dfs, 0, -1);

    for (int x : ans) cout << x << '\n';
    return 0;
}

Measured memory_bytes: 36696
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 ll dp[1005][4096];
int main(){
 
/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,m,i,j,x,b;
sfl(n);sfl(m);
ll c[m],mask[m];
f(i,0,m){
  sfl(c[i]);
  sfl(b);
  mask[i]=0;

  f(j,0,b){
    sfl(x);
  mask[i]|=(1<<(x-1));
  }


}

f(i,0,1005)
f(j,0,4096)dp[i][j]=LLONG_MAX;

dp[0][0]=0;


 
 for(i=0;i<m;i++){
for(j=0;j<(1<<n);j++){
  dp[i+1][j]=dp[i][j];
  if(dp[i][j-(j&mask[i])]!=LLONG_MAX)
  dp[i+1][j]=min(dp[i+1][j],dp[i][j-(j&mask[i])]+c[i]);

  //cout<<j<<" "<<dp[i+1][j]<<"\n";

  

}

 }

 

 if(dp[m][(1<<n)-1]==LLONG_MAX)cout<<"-1";
 else cout<<dp[m][(1<<n)-1];



 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

Measured memory_bytes: 32384
#include <iostream>
using namespace std;
const int N = 1e5 + 1000;
int h[N], n;
int d[N];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) cin >> h[i], d[i] = 0;
  d[n-1] = 0;
  for (int i = n-2; i >= 0; i--)
    if (h[i] >= h[i+1]) d[i] = d[i+1] + 1;
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, d[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll table[100];

int main(){

	table[0] = 2;
	table[1] = 1;

	for(int i = 2; i <= 86; i++){
		table[i] = table[i-1]+table[i-2];
	}

	int N;

	scanf("%d",&N);

	printf("%lld\n",table[N]);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int B = sc.nextInt();
   int C = sc.nextInt();
   
   int[] si = {Math.abs(A-B),Math.abs(C-B),Math.abs(A-C)};
   Arrays.sort(si);
   
   System.out.println(si[0]+si[1]);
 }
}

Measured memory_bytes: 23892
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int t[26];
#define DIV 4
ll dp[10001];
int main(void)
{
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i, 0, n)cin >> a[i] >> b[i];
	rep(i, 1, h + 1) {
		dp[i] = 1ll << 60;
		rep(i2, 0, n) {
			if(i >= a[i2])dp[i] = min(dp[i], dp[i - a[i2]] + b[i2]);
		}
	}
	rep(i, 0, n) {
		rep(i2, 0, a[i]) {
			if(h >= i2)dp[h] = min(dp[h], dp[h - i2] + b[i]);
		}
	}
	printf("%lld\n", dp[h]);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int h,w;
ll ans;
vector<int>r[1005],c[1005];
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char s;
            cin>>s;
            if(s=='#'){
                r[i-j+300].PB(i+j);
                c[i+j].PB(i-j+300);
            }
        }
    }
    for(int i=0;i<600;i++){
        if(r[i].size()>0)sort(r[i].begin(),r[i].end());
        if(c[i].size()>0)sort(c[i].begin(),c[i].end());
    }
    for(int i=0;i<600;i++){
        for(int j=0;j<c[i].size();j++){
            for(int k=j+1;k<c[i].size();k++){
                int a=c[i][j],b=c[i][k],d=b-a;
                if(i-d>=0&&c[i-d].size()>0){
                    ll x=lower_bound(c[i-d].begin(),c[i-d].end(),a)-c[i-d].begin(),y=upper_bound(c[i-d].begin(),c[i-d].end(),b)-c[i-d].begin();
                    ans+=(y-x);
                    if(x<c[i-d].size()&&c[i-d][x]==a)ans--;
                    if(y-1<c[i-d].size()&&c[i-d][y-1]==b)ans--;
                }
                if(i+d<600&&c[i+d].size()>0){
                    ll x=lower_bound(c[i+d].begin(),c[i+d].end(),a)-c[i+d].begin(),y=upper_bound(c[i+d].begin(),c[i+d].end(),b)-c[i+d].begin();
                    ans+=(y-x);
                    if(x<c[i+d].size()&&c[i+d][x]==a)ans--;
                    if(y-1<c[i+d].size()&&c[i+d][y-1]==b)ans--;
                }
            }
        }
    }
    for(int i=0;i<600;i++){
        for(int j=0;j<r[i].size();j++){
            for(int k=j+1;k<r[i].size();k++){
                int a=r[i][j],b=r[i][k],d=b-a;
                if(i-d>=0&&r[i-d].size()>0){
                    ll x=lower_bound(r[i-d].begin(),r[i-d].end(),a)-r[i-d].begin(),y=upper_bound(r[i-d].begin(),r[i-d].end(),b)-r[i-d].begin();
                    ans+=(y-x);
                }
                if(i+d<600&&r[i+d].size()>0){
                    ll x=lower_bound(r[i+d].begin(),r[i+d].end(),a)-r[i+d].begin(),y=upper_bound(r[i+d].begin(),r[i+d].end(),b)-r[i+d].begin();
                    ans+=(y-x);
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long I, O, T, J, L, S, Z;
	cin >> I >> O >> T >> J >> L >> S >> Z;
	long long tmp = 0;
	if ((I & 1) + (J & 1) + (L & 1) == 2) {
		tmp = 1;
		if (min(min(I, J), L) == 0) tmp = 2;
	}
	if ((I & 1) + (J & 1) + (L & 1) == 1) tmp = 1;
	cout << O + I + J + L - tmp << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <functional>
#include <complex>
#include <cmath>
using namespace std;
#define P complex<double>
#define X real()
#define Y imag()
#define EPS 1e-10

class Triangle {
	private:
		P a, b, c;
		double edgeA, edgeB, edgeC;
		double angleA, angleB, angleC;
		double getAngle(double e1, double e2, double e3) {
			return acos((e2 * e2 + e3 * e3 - e1 * e1) / (2 * e2 * e3));
		}
	public:
		Triangle(P p1, P p2, P p3) : a(p1), b(p2), c(p3) {
			edgeA = abs(b - c);
			edgeB = abs(c - a);
			edgeC = abs(a - b);
			angleA = getAngle(edgeA, edgeB, edgeC);
			angleB = getAngle(edgeB, edgeC, edgeA);
			angleC = getAngle(edgeC, edgeA, edgeB);
		}
		
		double getCircumscribedCircleRadius() {
			return edgeA / sin(angleA) / 2;
		}
		
		P getCircumscribedCirclePoint() {
			double A = sin(2 * angleA);
			double B = sin(2 * angleB);
			double C = sin(2 * angleC);
			P p;
			p.X = (a.X * A + b.X * B + c.X * C) / (A + B + C);
			p.Y = (a.Y * A + b.Y * B + c.Y * C) / (A + B + C);
			
			return p;
		}
};

int main()
{	
	int n;
	cin >> n;
	while (n--) {
		P p1, p2, p3;
		scanf("%lf %lf %lf %lf %lf %lf", &p1.X, &p1.Y, &p2.X, &p2.Y, &p3.X, &p3.Y);
		Triangle tr(p1, p2, p3);
		P p = tr.getCircumscribedCirclePoint();
		double r = tr.getCircumscribedCircleRadius();
		
		printf("%.3f %.3f %.3f\n", p.X, p.Y, r);
	}
		
	return 0;
}

Measured memory_bytes: 1372
import java.util.*;

public class Main {
    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int result = 0;
		for (int i = 0; i < N; i++) {
		    result += sc.nextInt();
		}
		System.out.println(result - N);
	}
}

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

int main(){
  int n;
  long long a;
  long long minValue = 1000000;
  long long maxValue = -1000000;
  long long sum = 0;

  cin >> n;

  for (int i = 0; i < n; i++ ){
    cin >> a;
    if( a < minValue ) minValue = a;
    if( a > maxValue ) maxValue = a;
    sum += a; 
  }
  
  cout << minValue << " " << maxValue << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	bool flag = false;
	for (int i = s.length() - t.length(); i >= 0; i--)
	{
		int same = 0;
		for(int j = 0; j < t.length(); j++)
		{
			if (s.at(i + j) == t.at(j) || s.at(i + j) == '?')
				same++;
			else
				break;
		}
		if (same == t.length())
		{
			for (int j = 0; j < t.length(); j++)
				s.at(i + j) = t.at(j);
			flag = true;
			break;
		}
	}
	if (flag)
	{
		for (int i = 0; i < s.length(); i++)
			if (s.at(i) == '?')
				s.at(i) = 'a';
		cout << s;
	}
	else
	{
		cout << "UNRESTORABLE";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int H, W, K;
vector<vector<int>> a;
map<P, ll> m;

ll solve(ll p = 0, ll q = 0) {
    if (m.find(P(p, q)) != m.end())return m[P(p, q)];
    if (p == H) {
        if (q == K)return m[P(p, q)] = 1;
        return m[P(p, q)] = 0;
    }
    ll res = 0;
    for (int i = 0; i < a.size(); i++) {
        res = (res + solve(p + 1, a[i][q])) % mod;
    }
    return m[P(p, q)] = res;
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }
    K--;
    for (int i = 0; i < (1 << W - 1); i++) {
        vector<int> p(W);
        vector<bool> f;
        for (int j = i; j; j >>= 1) {
            f.push_back(j & 1);
        }
        while (f.size() != W - 1) { f.push_back(0); }
        bool flag = 1;
        for (int j = 1; j < W - 1; j++) {
            if (f[j] && f[j - 1]) {
                flag = 0;
            }
        }
        if (!flag)continue;
        p[W - 1] = (f[W - 2]) ? W - 2 : W - 1;
        p[0] = (f[0]) ? 1 : 0;
        for (int j = 1; j < W - 1; j++) {
            if (f[j - 1]) {
                p[j] = j - 1;
            } else if (f[j]) {
                p[j] = j + 1;
            } else {
                p[j] = j;
            }
        }
        a.push_back(p);
    }
    cout << solve() << endl;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
bool p_judge(int x) {
    for(int i=2; i<=x/2; i++) {
        if(x%i==0)
            return false;
    }
    return true;
}

int main(void) {
    int n, i, j=1;
    cin >> n;
    for(i=11; j<=n; i+=10) {
        if(p_judge(i)) {
            printf("%d ", i);
            j++;
        }
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0
# i = 0
ma = a[0]
for i in range(1, n):
  if a[i] < ma:
    cnt += ma - a[i]
  elif a[i] == ma:
    pass
  else:
    ma = a[i]
print(cnt)

Measured memory_bytes: 32200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a, b; cin >> a >> b;
  cout << (a+b+1)/2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int h,n;
    int num = 0;
    scanf("%d%d",&h,&n);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        num = num + a[i];
    }
    if (h <= num)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    
}

Measured memory_bytes: 1988
#include <stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(){
  int n,i;
  for(i = 0; i<50; i++) dp[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}

Measured memory_bytes: 596
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]
n = int(input())
for m in range(n):
    card = input().split()
    ch = card[0]
    rank = int(card[1])
    cards[pattern.index(ch)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], str(j+1))


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> sumB(N + 1), sumW(N + 1);
  rep(i, 0, N) {
    sumW[i+1] = sumW[i] + (S[i] == '.');
    sumB[i+1] = sumB[i] + (S[i] == '#');
  }
  int ans = 1e9;
  rep(i, 0, N + 1) {
    int cntB = sumB[i];
    int cntW = sumW[N] - sumW[i];
    ans = min(ans, cntB + cntW);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using i64 = long long;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

std::vector<std::vector<int>> g;
constexpr i64 mod = 1000000007;
std::vector<i64> cs, dp, p2;
int n;

int szdfs(int v, int p) {
    for (int to : g[v]) {
        if (to == p) continue;
        cs[v] += szdfs(to, v);
    }
    return cs[v];
}

void dfs(int v, int p) {
    i64 s = p2[n - cs[v]] - 1;
    for (int to : g[v]) {
        if (to == p) continue;
        dfs(to, v);
        s = (s + p2[cs[to]] + mod - 1) % mod;
    }
    dp[v] = s + 1;
}

int main() {
    std::cin >> n;
    g.resize(n); cs.resize(n, 1); dp.resize(n);
    p2.push_back(1);
    for (int i = 0; i < n; i++) p2.push_back(p2.back() * 2 % mod);
    for (int i = 1; i < n; i++) {
        int u, v;
        std::cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    szdfs(0, -1);
    dfs(0, -1);

    i64 ret = 0;
    for (int i = 0; i < n; i++) {
        ret = (ret + p2[n - 1] + mod - dp[i]) % mod;
    }

    std::cout << ret * inverse(p2[n], mod) % mod << std::endl;

    return 0;
}


Measured memory_bytes: 26992
#include<bits/stdc++.h>
using namespace std;
int dp[100001][4];
int ans(int ar[100000][3], int j, int i)
{
    if(i<0)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    if(j==0)
    {
        return dp[i][j]=ar[i][0]+max(ans(ar, 1, i-1), ans(ar, 2, i-1));
    }
    else if(j==1)
    {
        return dp[i][j]=ar[i][1]+max(ans(ar, 0, i-1), ans(ar, 2, i-1));
    }
    else if(j==2)
    {
        return dp[i][j]=ar[i][2]+max(ans(ar, 1, i-1), ans(ar, 0, i-1));
    }
}
int main()
{
    int n;
    cin>>n;
    int ar[n][3];
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
            cin>>ar[i][j];
    }
    for(int i=0; i<100001; i++)
    {
        for(int j=0; j<4; j++)
            dp[i][j]=-1;
    }
    int a=ans(ar, 0, n-1);
    int b=ans(ar, 1, n-1);
    int c=ans(ar, 2, n-1);
    int s=max(a, max(b, c));
    cout<<s<<endl;
    return 0;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	int sum=accumulate(A.begin(),A.end(),0);
	int c=0;
	for(auto i:A){
		if(i*4*M>=sum)c++;
	}
	if(c>=M)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a[7] = {1,3,5,7,8,10,12};
    int b[4] = {4,6,9,11};
    int c[1] = {2};
    int x,y;
    scanf("%d %d",&x,&y);
    for(int i = 0; i < 7; i++){
        if(a[i] == x){
            for(int j = i + 1; j < 7; j++){
                if(a[j] == y){
                    printf("Yes\n");

                    return 0;
                }
            }
            printf("No\n");

            return 0;
        }
    }
    
    for(int i = 0; i < 4; i++){
        if(b[i] == x){
            for(int j = i + 1; j < 4; j++){
                if(b[j] == y){
                    printf("Yes\n");

                    return 0;
                }
            }
            printf("No\n");

            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 760
using System;

class HelloWorld
{
        static public void Main ()
        {
                string[] a=Console.ReadLine().Split();
                int b =int.Parse(a[0]);
                int c =int.Parse(a[1]);
                
                Console.Write( b*c + " " );
                Console.WriteLine( 2*(b+c));
        }

}




Measured memory_bytes: 15868
#include<bits/stdc++.h>
#define pi 3.141592653589793238
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const int N = 2e5 + 1;
ll t[4 * N], powr[N];
ll s[4 * N];
ll ans[4 * N];
ll mod = 998244353;
void build(ll v, ll tl ,ll tr){
    if(tl == tr){
        s[v] = powr[tl];
        return;
    }
    ll tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2* v + 1, tm + 1, tr);
    s[v] = (s[2 * v] + s[2 * v + 1]) ;
    if(s[v] > mod){
        s[v] %= mod;
    }
}

void update(ll v, ll tl, ll tr, ll l, ll r, ll val){
    if(l > r){
        return;
    }
    if(tl == l && tr == r){
        t[v] = val;
        ans[v] = val * s[v];
        if(ans[v] > mod)
            ans[v] %= mod;
        return;
    }
    if(t[v] != -1){
        t[2 * v + 1] = t[v];
        t[2 * v] = t[v];
        ans[2 * v + 1] = s[2 * v + 1] * t[v];
        ans[2 * v] = s[2 * v] * t[v];
        if(ans[2 * v] > mod)
            ans[2 * v] %= mod;
        if(ans[2 * v + 1] > mod)
            ans[2 * v + 1] %= mod;
        t[v] = -1;
    }
    ll tm = (tl + tr) / 2;
    update(2 * v, tl, tm, l, min(r, tm), val);
    update(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, val);
    ans[v] = ans[2 * v] + ans[2 * v + 1];
    if(ans[v] > mod) 
        ans[v] %= mod;
} 

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, k;
        cin >> n >> k;
        for(i = 0; i < 4 * N; i++){
            t[i] = -1;
        }
        
        ll p = 1;
        for(i = n; i >= 1; i--){
            powr[i] = p;
            p *= 10;
            if(p > mod){
                p %= mod;
            }
        }
        build(1, 1, n);
        update(1, 1, n, 1, n, 1);
        
        //..cout << ans[1] << endl;
        while(k--){
            ll l, r, d;
            cin >> l >> r >> d;
            update(1 , 1, n, l, r, d);
            cout << ans[1] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 19556
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;

int main(){
  int N;
  cin >> N;
  int A[N];
  int ans = 0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    while(true){
      if(A[i] % 2 == 1){
        break;
      }
      else{
        A[i] /= 2;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<int> X(N);
    int tmp = 0;
    int coef = -1;
    for (int i = 0; i < N - 2; i++) {
        tmp += coef * A[i];
        coef *= -1;
    }
    tmp += A[N-2] + A[N-1];
    tmp /= 2;
    X[N-1] = tmp;

    X[0] = A[N-1] - X[N-1];
    for (int i = 1; i < N - 1; i++) {
        X[i] = A[i-1] - X[i-1];
    }

    for (int i = 0; i < N; i++) {
        cout << 2 * X[i];
        if (i != N - 1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944