akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
typedef long long int llint;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
	*this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

int main(void){
  int A[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      std::cin >> A[i][j];
    }
  }

  bool isOK[3][3];
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      isOK[i][j] = false;
    }
  }

  int n;
  std::cin >> n;
  for(int i=0; i<n; i++){
    int b;
    std::cin >> b;
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
	if(b==A[j][k]) isOK[j][k] = true;
      }
    }
  }

  bool bingo = false;
  for(int i=0; i<3; i++){
    bool tate = true;
    bool yoko = true;
    for(int j=0; j<3; j++){
      tate &= isOK[i][j];
      yoko &= isOK[j][i];
    }
    bingo |= tate | yoko;
  }
  bool naname1 = true;
  bool naname2 = true;
  for(int i=0; i<3; i++){
    naname1 &= isOK[i][i];
    naname2 &= isOK[i][2-i];
  }
  bingo |= naname1 | naname2;

  std::cout << (bingo?"Yes":"No") << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  _ <- getLine
  as <- map read . words <$> getLine
  print $ counter as

counter
  :: [Int] -> Int
counter = helper 0

helper
  :: Int -> [Int] -> Int
helper k ms
  | all even ms = helper (k+1) $! (map (`div` 2) ms)
  | otherwise   = k

Measured memory_bytes: 1020
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::vector<int> v(n);
  for(int i=0; i<n; i++)std::cin >> v[i];
  int a[100010];
  for(int i=0; i<100010; i++) a[i]=0;

  for(int i=0; i<n; i++){
    if(v[i]==1){
      a[1]++;a[2]++;
    }
    else{
      a[v[i]-1]++; a[v[i]]++; a[v[i]+1]++;
    }
  }

  sort(a,a+100010,greater<int>());
  std::cout << a[0] << '\n';

  return 0;
}


Measured memory_bytes: 1024
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
	ll n;
	cin >> n;
	if (n % 2) {
		ll sa = n + 1, cnt_2 = 0, cnt_5 = 0, sh_2 = 0, sh_5 = 0;
		while (sa) {
			cnt_2 += sa / 2;
			sa /= 2;
		}
		cnt_2 -= (n + 1) / 2;
		cnt_2 = max(cnt_2, ll(0));
		sa = n + 1;
		while (sa) {
			cnt_5 += sa / 5;
			sa /= 5;
		}
		sa = (n + 1) / 2;
		while (sa) {
			sh_2 += sa / 2;
			sa /= 2;
		}
		cnt_2 -= sh_2;
		cnt_2 = max(cnt_2, ll(0));
		sa = (n + 1) / 2;
		while (sa) {
			sh_5 += sa / 5;
			sa /= 5;
		}
		cnt_5 -= sh_5;
		cnt_5 = max(cnt_5, ll(0));
		cout << min(cnt_2, cnt_5) << '\n';
	}
	else {
		ll sa = n / 2, cnt = 0;
		while (sa) {
			cnt += sa / 5;
			sa /= 5;
		}
		cout << cnt << '\n';
	}
}


Measured memory_bytes: 256
using System;

namespace ABC097_B_Exponential
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int x = int.Parse(Console.ReadLine());
			int xUnderPowNumber = (int)Math.Pow(2, 2);

			if (x == 1)
			{
				Console.WriteLine(1);
				return;
			}

			for (int i = 2; i < x; i++)
			{
				for (int j = 2; ; j++)
				{
					int pow = (int)Math.Pow(i, j);
					
					if (pow <= x && pow > xUnderPowNumber)
					{
						xUnderPowNumber = pow;
					}

					if (pow > x)
					{
						break;
					}
				}
			}
			
			Console.WriteLine(xUnderPowNumber);
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define IL inline
IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f;
}
char s[100005];
int main() {
	scanf("%s", s + 1); 	
	int n = strlen(s + 1);
	int ct = 0;
	for (int i = 2; i <= n; ++i) {
		if (s[i] != s[i - 1]) ct++;
	}
	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 384
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include<iostream>

using namespace std;

typedef long long ll;

#define F first
#define S second

#define mp make_pair
#define pb push_back

#define pii pair<int,int>
#define pll pair<ll,ll>

const int N = 30000;
const int INF = int(2e9);
const int MOD = int(1e9) + 7;

string s;

int main()  
{
    freopen("debug.txt","w",stderr);

    int n,a[200100];
    cin >> n;
    int cnt = 0;
    for(int i = 1;i <= n;i ++) {
    	cin >> a[i];
    	if(a[i] % 2 == 1) {
    		++ cnt;
    	}
    }
    if(cnt % 2 == 0) {
    	cout << "YES";
    }
    else {
    	cout << "NO";
    }
	return 0;  
}  

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    long long int N, T;
    cin >> N >> T;
    long long int t[N];
    for (int i = 0; i < N; ++i) {
        cin >> t[i];
    }
    long long int time = N * T;
    for (int i = 1; i < N; ++i) {
        if (T - (t[i] - t[i - 1]) > 0) {
            time -= T - (t[i] - t[i - 1]);
        }
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int th, ts, ah, as;
	cin >> th >> ts >> ah >> as;
	while (true)
	{
		ah = (ah - ts);
		th = (th - as);
		if (ah <= 0)
		{
			cout << "Yes";
			break;
		}
		else if (th <= 0) {
			cout << "No";
			break;
		}
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std; 

string list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main()
{
 int n, l, p;
 string s, ans;

 while(cin >> n){
	if(n==0){return 0;} ans = "";
	int* key = new int[n];
	for(int i=0; i<n; i++){cin >> key[i];}
	cin >> s; l=s.length();
	for(int i=0; i<l; i++){
		p = (list.find(s.substr(i,1))-key[i%n]+104)%52;
		ans += list.substr(p,1);
	}
	cout << ans << endl; delete[] key;
 }
}

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

int main(){
	int k,a,b,i;
	cin>>k>>a>>b;
	
	for(i=a;i<=b;i++)
		if(i%k==0){
			cout<<"OK"<<endl;
			return 0;	
		}
		
	cout<<"NG"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#define P 100003
#define N 100000
using namespace std;

int main(){
    string c = "ABC";
    string d = "ABD";
    int n;
    cin  >> n;
    if(n<1000)
        cout <<c;
    else 
        cout << d;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define ll long long
using std::min;

const int MAXN =2002;

inline int read(){
	int x =0; char c =getchar();
	while(c < '0' || c > '9') c =getchar();
	while(c >= '0' && c <= '9') x = (x<<3) + (x<<1) + (48^c), c =getchar();
	return x;
}

int n, x, c[MAXN];
int dp[MAXN][MAXN]/*得到第 i个，进化最多 j次，的消耗。不含进化消耗*/;

int main(){
	n =read(), x =read();
	for(int i =0; i < n; ++i) c[i] =read();
	for(int i =0; i < n; ++i) for(int j =0; j < n /*进化 n次一定不优*/; ++j){
		if(j == 0){
			dp[i][j] =c[i];
			continue;
		}
		int d =i-j;
		if(d < 0) d +=n;
		dp[i][j] =min(dp[i][j-1], c[d]);
	}
	
	ll ans =0x4fffffffffffffff;
	for(int j =0; j < n; ++j){
		ll ans2 =1ll*j*x;
		for(int i =0; i < n; ++i) ans2 +=dp[i][j];
		ans =min(ans, ans2);
	}
	printf("%lld", ans);
}

Measured memory_bytes: 15872
($a, $b, $k) = split/ /,<>;
if(($b-$a+1)/2<=$k){
	@ary= ($a..$b);
}else{
	@ary=($a..$a+$k-1,$b-$k+1..$b);
    
}
foreach (@ary){
	print $_."\n";
}


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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

ll p(ll n, ll x) {
    ll ans = 1, cur = n;
    while(x) {
        if(x & 1) ans = (cur * ans) % MOD;
        cur = (cur * cur) % MOD;
        x >>= 1;
    }
    return ans;
}

struct Res {
    ll g, x, y;
};

Res modinv(ll a, ll b) {
    if(b == 0) return {a, 1, 0};
    Res prev = modinv(b, a % b);
    return {prev.g, prev.y, prev.x - a / b * prev.y};
}

ll ncr(ll n, ll r) {
    ll ans = 1, den = 1;
    for(int i = n; i > n - r; i--) ans = (ans * i) % MOD;
    for(int i = 2; i <= r; i++) den = (den * i) % MOD;
    ll inv = modinv(den, MOD).x;
    return (ans * inv) % MOD;
}

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll x = p(2, n);
    ll y = ncr(n, a);
    ll z = ncr(n, b);
    cout << (x - y - z - 1 + MOD) % MOD << endl;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	
	
	bool ch=0;int c=0;int a,b;
	int test1;cin>>test1;while(test1--){ 
		
		cin>>a>>b;
		if(a==b) c++;
		else c=0;
		if(c>2) ch=1;
	 }
	 ch?db("Yes"):db("No");
	 //*/
return 0;
}



Measured memory_bytes: 3648
def main():
	M, D = [int(f) for f in input().split()]

	dic = {}
	for row in range(11, D+1):
		if int((row%10)) < 2 or int((row/10)) < 2:
			continue
		num = int((row%10))*int((row/10))
		if num in dic:
			dic[num] += 1
		else:
			dic[num] = 1
	
	counter = 0
	for key in range(M+1):
		if key in dic:
			counter += dic[key]
	
	print(counter)


if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
import math

n, d = list(map(int, input().split()))

x = [[0]*d for _ in range(n)]
ans = 0
for i in range(n):
    x[i] = list(map(int, input().split()))

for i in range(n):
    for j in range(i+1, n):
        r2 = 0
        for k in range(d):
            r2 =  r2 + (x[i][k] - x[j][k])**2

        r = math.sqrt(r2)
        ans += r.is_integer()

print(ans)  

Measured memory_bytes: 3064
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

c = Counter(a)
key = c.keys()
comb = 0
for i in key:
    comb += (c[i]) * (c[i]-1) // 2

for i in a:
    ans = comb - (c[i]-1)
    print(ans)

Measured memory_bytes: 25900
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <assert.h>
#include <sstream>
typedef long long ll;
#define vi vector<int>
using namespace std;

int dX[4] = { 0, 0, -1, 1 };
int dY[4] = { -1, 1, 0, 0 };
int R, C, M;
int main() {
	cin >> R >> C >> M;
	vi X(R, 0), Y(C, 0);
	set<pair<int, int>> has;
	for (int i = 0; i < M; i++) {
		int r, c;
		cin >> r >> c;
		r--; c--;
		X[r]++; Y[c]++;
		has.insert({ r, c });
	}
	int mxx = 0, mxy = 0;
	vi xs, ys;
	for (int i = 0; i < R; i++) {
		mxx = max(mxx, X[i]);
	}
	for (int j = 0; j < C; j++) {
		mxy = max(mxy, Y[j]);
	}
	for (int i = 0; i < R; i++) {
		if (X[i] == mxx) {
			xs.push_back(i);
		}
	}
	for (int j = 0; j < C; j++) {
		if (Y[j] == mxy) {
			ys.push_back(j);
		}
	}
	ll L1 = xs.size();
	ll L2 = ys.size();
	if (L1 * L2 > M) {
		cout << mxx + mxy << '\n';
		return 0;
	}
	for (int i = 0; i < L1; i++) {
		for (int j = 0; j < L2; j++) {
			pair<int, int> chk = { xs[i], ys[j] };
			if (has.find(chk) == has.end()) {
				cout << mxx + mxy << '\n';
				return 0;
			}
		}
	}
	cout << mxx + mxy - 1 << '\n';
}

Measured memory_bytes: 23856
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14

#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

void solve(){
	map<int,int> a;
	map<int,int> b;
	int N;
	int D[201010];
	int M;
	int T[201010];
	cin >> N;
	rep(i,N){
		int t;
		cin >> t;
		a[t]++;
	}
	cin >> M;
	rep(i,M){
		int t;
		cin >> t;
		a[t]--;
		if(a[t]<0){ 
			cout << "NO" << endl;
			return;
		}
	}
	cout << "YES" << endl;
	return;

}

int main(){
	// while(1){
		solve();
	// }
	return 0;
}

Measured memory_bytes: 9728
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  if(n*a >= b){
    cout << b << endl;
  }
  else{
    cout << n*a << endl;
  }

}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var x = Console.ReadLine().ToLong();
		
		for(long i = -200; i <= 500; i++)
		{
			long i5 = i * i * i * i * i;
			for(long j = -200; j <= 500; j++)
			{
				
				long j5 = j * j * j * j * j;
				long q = i5 - j5;
				
				if(q == x)
				{
					Console.WriteLine("{0} {1}", i, j);
					return;
				}
			}
		}
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 17516
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	int ans = 0;
	cin >> n;
	Vi a(n);
	cin >> a;
	int sum = 0;
	rep(i, n) { sum ^= a[i]; }
	rep(i, n) {
		cout << (sum ^ a[i]);
		if (i != n - 1) {
			cout << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 4000
#include<cstdio>
#include <string.h>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main(){
  int count=0;
  string s;
  cin>>s;
  for(int i=0;i<strlen(&s[0]);i++){
    if(s[i]=='1') count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll dp[3010][3010];
int n,a[3010];
int main() {
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",a+i);
	}
	int j,k;
	for(k=1;k<=n;k++) {
		for(i=0;i+k-1<n;i++) {
			j=i+k-1;
			bool fir=n%2==k%2;
			if(k==1) {
				if(fir) dp[i][j]=a[i];
				else dp[i][j]=-a[i];
			} else {
				if(fir) dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
				else dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
			}
		}
	}
	printf("%lld",dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 70016
#include<iostream>
using namespace std;
int main(){
  int n,f=0,c=0,i;
  cin>>n;
  for(i=0;i<n;i++){
    string s;
    cin>>s;
    f|=(s=="A"?++c*0: !c--);
  }
  cout<<(f||c?"NO\n":"YES\n");
  return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdio>

using namespace std;

const long long M = 1e9 + 7;

long long dp[100005];

int main()
{
    long long N, A, B;
    vector<long long> S;

    cin >> N >> A >> B;

    if(A > B)
    {
        swap(A, B);
    }

    S.resize(N + 1);
    for (int i = 1; i <= N; i++)
    {
        cin >> S[i];
    }
    S[0] = -10e9;

    for (int i = 1; i <= N - 2;i++)
    {
        if(S[i + 2] - S[i] < A)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    dp[0] = 1;
    dp[1] = 1;

    long long dpsum = 1;
    long long l = 0;
    long long r = 1;
    // Sum up values from l to r - 1 to dpsum.

    for (int i = 2; i <= N;i++)
    {
    //    printf("l = %lld, r = %lld, dpsum = %lld\n", l, r, dpsum);
        r = max(r, l);
        while (S[i] - S[r] >= B)
        {
            dpsum += dp[r];
            dpsum %= M;
            r++;
        }
        
        dp[i] = dpsum;

        if(S[i] - S[i - 1] < A)
        {
            for (int j = l; j < r;j++)
            {
                dpsum = (dpsum + M) - dp[j];
                dpsum %= M;
            }
            l = i - 1;
        }
    }
    long long ans = 0;
    for (int i = l; i <= N;i++)
    {
        ans = (ans + dp[i]) % M;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
s = input()

out = []
bc = 0
for j in range(len(s) - 1, -1, -1):
    if s[j] == 'B':
        bc += 1
    elif bc > 0:
        bc -= 1
    else:
        out.append(s[j])
ans = "".join(reversed(out))
print(ans)


Measured memory_bytes: 38256
def main():
    n = int(input())
    dic = {}
    x = 2
    while n % x == 0:
        if x in dic:
            dic[x] += 1
        else:
            dic[x] = 1
        n //= x
    x = 3
    while x**2 <= n:
        while n % x == 0:
            if x in dic:
                dic[x] += 1
            else:
                dic[x] = 1
            n //= x
        x += 1
    if n > 1:
        if n in dic:
            dic[x] += 1
        else:
            dic[x] = 1
    ans = 0
    for v in dic.values():
        p = 1
        while p <= v:
            ans += 1
            v -= p
            p += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int h,w;
    cin >> h >> w;
    int H[h+ 1];
    int W[w+ 1];
    REP(i,h) cin >> H[i];
    REP(i,w) cin >> W[i];
    H[h] = INF;
    W[w] = INF;
    sort(H,H+h);
    sort(W,W+w);
    int h_kake = w + 1;
    int w_kake = h + 1;

    int ans = 0;
    int h_id = 0;
    int w_id = 0;
    REP(i,h + w){
        if(H[h_id] <= W[w_id]){
            ans += H[h_id] * h_kake;
            h_id ++;
            w_kake --;
        }
        else{
            ans += W[w_id] * w_kake;
            w_id ++;
            h_kake --;

        }
    }

    cout << ans << endl;

}

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

int main(){
  int n;
  cin>>n;
  
  vector<int> v;
  int x;
  
  for(int i =0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  int cnt  =0;
  for(int i =1;i<n-1;i++){
      int min_1 = min(min(v[i-1],v[i]),v[i+1]);
      int min_2;
      if(min_1 == v[i-1])
        min_2 = min(v[i],v[i+1]);
      else if(min_1 == v[i+1])
        min_2 = min(v[i-1],v[i]);
      else
        min_2 = min(v[i-1],v[i+1]);
      if(min_2 == v[i])
      cnt++;
    }
  
  cout<<cnt;
  return 0;
}
      
      

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

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

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














int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max(c - (a - b), 0LL) << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j

const int INF = 1e9+7;

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

  vector<int> X(M);
  rep(i, 0, M) {
    cin >> X[i];
  }

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }

  sort(All(X));

  // 間隔
  vector<int> dist(M - 1);
  rep(i, 0, M - 1) {
    dist[i] = X[i + 1] - X[i];
  }
  sort(All(dist));
  int ans = 0;
  rep(i, 0, dist.size() - (N - 1)) {
    ans += dist[i];
  }
  cout << ans << endl;
};


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  vector<int> MY(N);
  for (int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  cout << MY.at(N-1)-MY.at(0) << endl;
}
 

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

int triple_max(int x, int y, int z);

int main(){
    string a;
    cin >> a;
    if (a.at(0) == a.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}


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

int main() {
	int N;
	cin >>N;
	int a,p;
	p=1;
	a=1;
	vector<string> S(N);
	for(int i=0;i<N;i++){
		cin >>S[i];
	}
	sort(S.begin(),S.end());
	for(int i=1;i<N;i++){
		if(S[i-1]==S[i]){
			p++;
			a=max(a,p);
		}
		else{
			p=1;
		}
	}
	p=1;
	if(a!=1){
		for(int i=1;i<N;i++){
		if(S[i-1]==S[i]){
			p++;
		}
		else{
			p=1;
		}
		if(p==a){
			cout <<S.at(i)<<endl;
		}
	}
}
	else{
		for(int i=0;i<N;i++){
			cout <<S.at(i)<<endl;
		}

	}
	




}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, M, N, D, K, Q, W, H, T, X, Y;

int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    if (s1.size() > s2.size())
        cout << "GREATER" << endl;
    else if (s1.size() < s2.size())
        cout << "LESS" << endl;
    else {
    for (int i = 0; i < s1.size(); ++i) {
        if (s1[i] > s2[i]) {
            cout << "GREATER" << endl; return 0;
        }else if (s1[i] < s2[i]) {
            cout << "LESS" << endl; return 0;
        }
    }
    cout << "EQUAL" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define nl              "\n"
#define ll              long long
#define ull             unsigned long long
#define pb              push_back
#define SIZE(a)         (int)a.size()
#define SORT(v)         sort(v.begin(),v.end())
#define RSORT(v)        sort(v.rbegin(),v.rend())
#define REV(v)          reverse(v.begin(),v.end())
#define ff              first
#define ss              second
#define sq(a)           ((a)*(a))
#define For(i,a,b)      for(i=a;i<=b;i++)
#define Rof(i,a,b)      for(i=a;i>=b;i--)
#define Rep(i,b)        for(i=0;i<b;i++)
#define MOD             1000000007
#define PI              acos(-1.0)
#define eps             1e-9
#define Linf            2e18
#define inf             1<<30
#define MX5             100005
#define MX6             1000006
#define GCD(a,b)	    __gcd(a,b)
#define Abs(a)		    abs(a)
#define input(a,b)	    scanf("%lld%lld",&a,&b)
#define in1(a)		    scanf("%lld",&a)
#define output(a)	    printf("%lld\n",a);
#define mem(a)          memset(a,-1,sizeof(a))
#define clr(a)          memset(a,0,sizeof a)
#define mk              make_pair
#define pLL             pair<ll,ll>
#define ff              first
#define ss              second
#define invcos(a)	    (acos(a)*(180/3.14159265))
#define pip		        printf("pip")
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
///8direction ->        int del_x[]={-1,0,1,0,1,-1,-1,1},del_y[]={0,1,0,-1,-1,-1,1,1};


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

//ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
//ll modinverse(ll n){return bigmod(n,mod-2)%mod;}

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/
int main()
{
    ll arr[100][100];
    ll n,d,i,j,counter=0,k,l;
    input(n,d);
    For(i,1,n)
    {
        For(j,1,d)
        {
            in1(arr[i][j]);
        }
    }
    ll first,second;
    for(i=1;i<=n;i++)
    {

        for(k=i+1;k<=n;k++)
        {
            ll sum=0;
            for(j=1;j<=d;j++)
            {
                first=arr[i][j];
                second=arr[k][j];
                ll fo=first-second;
                fo*=fo;
                sum+=fo;
            }
            ll prev=sum;
        sum=sqrt(sum);
        sum*=sum;
        if(prev==sum)
        {
            counter++;
        }
        }

    }
    output(counter);
}






Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	int N,K,Q;
	ll A[2010],small=1e10;
	scanf("%d%d%d",&N,&K,&Q);
	rep(i,N)scanf("%lld",&A[i]);
	rep(i,N){
		ll X = A[i],j=0;
		vector<ll> a;
		vector<ll> v;
		while(j<N){
			if(A[j]>=X){
				v.push_back(A[j]);
			}else{
				sort(v.begin(),v.end());
				rep(k,v.size()-K+1)a.push_back(v[k]);
				v.erase(v.begin(),v.end());
			}
			j++;
		}
		sort(v.begin(),v.end());
		rep(k,v.size()-K+1)a.push_back(v[k]);
		v.erase(v.begin(),v.end());
		sort(a.begin(),a.end());
		if(a.size()>=Q && small>a[Q-1]-X)small=a[Q-1]-X;
	}
	printf("%lld\n",small);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;


int under(vector<int> A, int K) {
    int count = 0;
    for (int i = 0; i < A.size() - 1; i++) {
        int base = A[i];
        int left = -1;
        int right = A.size();
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (base < 0) {
                if (base * A[mid] <= K) right = mid;
                else left = mid;
            } else {
                if (base * A[mid] <= K) left = mid;
                else right = mid;
            }
        }
        if (base < 0) count += ((int)A.size() - max(i + 1, right));
        else if (left > i) count += (left - i);
        // cout << i << " " << count << endl;
    }
    return count;
}

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    cin >> A;
    sort(A.begin(), A.end());
    int left = -1e18 - 10;
    int right = 1e18 + 10;
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (under(A, mid) <= (K - 1)) left = mid;
        else right = mid;
        // cout << mid << endl;
    }
    cout << right << endl;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> a(n+1);
    REP(i,n){
        cin>>a[i];
    }
    a[n]=0;
    ll ans=0;
    REP(i,n-1){
        ans+=a[i]/2;
        a[i]%=2;
        if(a[i]>0&&a[i+1]>0){
            ++ans;
            --a[i];
            --a[i+1];
        }
    }
    ans+=a[n-1]/2;
    cout<<ans<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int x = 1;
  
  rep(cnt, N) {
    if (x < K) {
      x *= 2;
    } else {
      x += K;
    }
  }

  cout << x << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int n, k; cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i < n; ++i) {
		cin >> l[i];
	}
	sort(all(l));
	int ans = 0;
	for (int i = l.size() - k; i < n; ++i) {
		ans += l[i];
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = []
for i in range(N):
    a, b = map(int, input().split())
    L.append([a, b])
L.sort()
# print(L)
total = 0
number = 0
index = 0
while (number + L[index][1]) < M:
    number += L[index][1]
    total += L[index][0] * L[index][1]
    index += 1
    # print(number)
    # print(total)
total += L[index][0] * (M - number)
print(total)

Measured memory_bytes: 20064
//linwenqi
#include <iostream>
#include <cstdio>
using namespace std;
long long a[200005],sum[200005],x[200005];
int main(){
	int n, i, j;
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(i = 1; i <= n; i++){
		x[i] = x[i-1] ^ a[i];
		sum[i] = sum[i-1] + a[i];
	}
	long long ans = 0;
	int l = 1,r;
	for(r = 1; r <= n; r++){
		while((x[l-1] ^ x[r]) != (sum[r]-sum[l-1])) l++;
		ans += r - l + 1;
	}
	cout << ans;
	return 0; 
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N, D, X, A;
    cin >> N >> D >> X;
    rep(i, N) {
        cin >> A;
        X += (D - 1) / A + 1;
    }
    cout << X << "\n";
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a, b;
    int ans[21][21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,7,8,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,9,9,10,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,11,11,11,12,13,15,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,13,13,13,13,14,15,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,15,15,15,15,15,16,17,19,21,23,25,27,29,31,33,35,37,39,0,0,0,17,17,17,17,17,17,18,19,21,23,25,27,29,31,33,35,37,39,0,0,0,19,19,19,19,19,19,19,20,21,23,25,27,29,31,33,35,37,39,0,0,0,21,21,21,21,21,21,21,21,22,23,25,27,29,31,33,35,37,39,0,0,0,23,23,23,23,23,23,23,23,23,24,25,27,29,31,33,35,37,39,0,0,0,25,25,25,25,25,25,25,25,25,25,26,27,29,31,33,35,37,39,0,0,0,27,27,27,27,27,27,27,27,27,27,27,28,29,31,33,35,37,39,0,0,0,29,29,29,29,29,29,29,29,29,29,29,29,30,31,33,35,37,39,0,0,0,31,31,31,31,31,31,31,31,31,31,31,31,31,32,33,35,37,39,0,0,0,33,33,33,33,33,33,33,33,33,33,33,33,33,33,34,35,37,39,0,0,0,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,36,37,39,0,0,0,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,38,39,0,0,0,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,40};
    /*int aa, ab, bb;
    for (int i = 3; i < 21; ++i)
    {
        for (int j = 3; j < 21; ++j)
        {
            res = 0;
            aa = i + i - 1;
            ab = i + j;
            bb = j + j - 1;
            res = max(res, aa);
            res = max(res, ab);
            res = max(res, bb);
            ans[i][j] = res;
        }
    }
    for (int i = 0; i < 21; ++i)
    {
        for (int j = 0; j < 21; ++j)
        {
            cout << ans[i][j] << ",";
        }
    }*/
    scanf("%d%d", &a, &b);
        printf("%d\n", ans[a][b]);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int main(){
    int N,square[2][101];
    scanf("%d",&N);
    for(int i=0;i<2;i++)
        for(int j=0;j<N;j++)
            scanf("%d",&square[i][j]);
    int ans=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<=i;j++)
            sum+=square[0][j];
        for(int j=i;j<N;j++)
            sum+=square[1][j];
        ans=ans>sum?ans:sum;
    }
    printf("%d\n",ans);
    return 0;
}

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

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    
    System.out.println(sl[0].charAt(1) == 'R' ? "ABC" : "ARC");
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 32312
#include <iostream>
#include <cstdlib>

using namespace std;

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

int main()
{
    int n;
    cin >> n;
    int *l = new int[n + 1];
    long long int ans = 0;
    int tmp1, tmp2;
    bool flag = true;

    for (int i = 1; i <= n; i++) {
        cin >> l[i];
    }
    
    qsort(&l[1], n, sizeof(int), compare);

    for (int i = 1; i <= n; i++) {
        tmp1 = l[i];
        for (int j = i + 1; j <= n; j++) {
            tmp2 = l[j];
            for (int k = j + 1; k <= n; k++) {
                if (l[k] + tmp2 > tmp1) {
                    ans++;
                } else {
                    if (k == j + 1) {
                        flag = false;
                        break;
                    } else {
                        break;
                    }
                }
            }
            if (!flag) {
                flag = true;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define MOD 1000000007
vector <ll> N;
ll dp[63][3];
ll marked[63][3];
ll find_ans(ll idx, ll op)
{

    if(marked[idx][op])
    {

        return dp[idx][op];
    }
    else
    {

        marked[idx][op] = 1;
    }

    ll ans = 0;

    if(idx==0) // base case
    {
        if(op==0)
        {

            ans = 3;
        }
        else if(op == 1)
        {

            ans = 3;
        }
        else if(op == 2)
        {

            if(N[idx] == 1)
            {

                ans = 2;
            }
            else
            {

                ans  = 1;
            }
        }
        return dp[idx][op] = ans ;

    }
    if(op==0)//all options available
    {
        ans = find_ans(idx-1,op);
        ans *= 3;
        ans %= MOD;

    }
    else if(op == 1) // lead by N on last bit
    {
        if(N[idx]==1)
        {
            ans += find_ans(idx-1,0); // a=0,b=0
            ans %= MOD;
            ans += find_ans(idx-1,1); // a=1 ,b = 1
            ans %= MOD;
            ans += find_ans(idx-1,0); // a= 1 , b = 0
            ans %= MOD;
        }
        else if(N[idx] == 0)
        {

            ans += find_ans(idx-1,0) ; // a= 0, b= 0
            ans %= MOD;
            ans += find_ans(idx-1,2) ; // a=1 , b = 1 ( neutralise the previous lead)
            ans %= MOD;
            ans += find_ans(idx-1,1) ; // a= 1 , b = 0
            ans %= MOD;
        }
    }
    else if(op == 2) // draw so far i.e no lead
    {
        if(N[idx] == 1)
        {
            ans += find_ans(idx-1,1); // a= 0. b = 0
            ans %= MOD;
            ans += find_ans(idx-1,2) ; // a=1 , b = 0
            ans %= MOD;

        }
        else
        {

            ans += find_ans(idx-1,2); // a= 0 , b = 0;
            ans %= MOD;
        }

    }
    return dp[idx][op] = ans;

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

    ll n;
    cin >> n;
    ll temp= n;
    while(temp!=0)
    {
        ll r = temp%2;
        N.p_b(r);
        temp /= 2 ;

    }
    //reverse(N.begin(),N.end());
    ll sz = N.size();
    //cout << sz << endl;
    //cout << N[0] << N[1] << N[2] << endl;
    ll ans = find_ans(sz-1,2);
    cout << ans << endl;

    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl;

ll gcd(ll x,ll y){
  if(x<=y){
    swap(x,y);
  }
  if(x%y==0) return y;
  else{
    return(gcd(y,x%y));//最大公約数
  }
}

ll lcm(ll x,ll y){
  return (x/gcd(x,y))*y;//最小公倍数
}

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    ll t[n];
    REP(i,n){
        cin >> t[i];
    }
    sort(t,t+n);
    REP(i,n){
      ans = lcm(ans,t[i]);
    }
    COUT(ans)
}



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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int n,m;
  cin>>n;
  vector<string> v(n);
  cinv(v,0,n);
  cin>>m;
  vector<string> s(m);
  cinv(s,0,m);

  sort(v.begin(),v.end());
  sort(s.begin(),s.end());
  vector<pair<int,string>> key;
  key.push_back(make_pair(1,v[0]));
  FOR(i,1,n){
    if(key[key.size()-1].second==v[i]){
      key[key.size()-1].first++;
    }
    else{
      key.push_back(make_pair(1,v[i]));

    }
  }
  vector<pair<int,string>> key2;
  key2.push_back(make_pair(1,s[0]));
  FOR(i,1,m){
    if(key2[key2.size()-1].second==s[i]){
      key2[key2.size()-1].first++;
    }
    else{
      key2.push_back(make_pair(1,s[i]));

    }
  }
  FOR(i,0,key.size()){
    FOR(j,0,key2.size()){
      if(key[i].second==key2[j].second){
        key[i].first-=key2[j].first;
        break;
      }
    }
  }
  sort(key.begin(),key.end());

  if(key[key.size()-1].first>0) cout<<key[key.size()-1].first<<endl;
  else cout<<0<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;
using ull = unsigned long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ull a,b,c,d;
    cin >> a >> b >> c >> d;
    ull lcm = (c*d)/__gcd(c,d);
    ull i=1;
    ull cntc, cntd, cntl;
    ull c2,d2,lcm2;
    cntc = b/c-(a%c==0 ? (a/c-1) : a/c);
    cntd = b/d-(a%d==0 ? (a/d-1) : a/d);
    cntl = b/lcm-(a%lcm==0 ? (a/lcm-1) : a/lcm);
    
    ull ans = (b-a+1)-(cntc+cntd-cntl);
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256