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

using namespace std;
typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;
#define debug_ printf("OK\n")

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    unsigned x,ans=0;
    std::cin>>x;
    ans+=x/500*1000;
    ans+=(x-(x/500*500))/5*5;
    std::cout<<ans;
    return 0;
}


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

int main(void) {
  int x;

  if(scanf("%d", &x) == 1);

  if(x == 7 || x == 5 || x == 3) {
    printf("YES");
  } else {
    printf("NO");
  }

  return 0;
}


Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))

max_ctn = 0
start = 0
for i in range(0,n):
    tmp_ctn = 0
    i +=start
    for j in range(i,len(h)-1):
        if h[j] >= h[j+1]:
            tmp_ctn += 1
            start +=1
            continue
        break
    if max_ctn < tmp_ctn:
        max_ctn = tmp_ctn
print(max_ctn)


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

int dp[3][301];

int main()
{
	int N,M;
	while(cin>>N>>M)
	{
		int cost,a[3];
		char str[32];
		memset(dp, 0, sizeof(dp));

		for(int i=0; i<N; i++)
		{
			cin.getline(str,32);
			cin.getline(str,32);

			cin >> cost;
			for(int j=0; j<3; j++)
			{
				cin >> a[j];
			}

			for(int j=0; j<3; j++)
			for(int k=cost; k<=M; k++)
			{
				dp[j][k] = max(dp[j][k], dp[j][k-cost]+a[j]);
			}
		}

		cout << max(max(dp[0][M],dp[1][M]),dp[2][M]) << endl;
	}
}

Measured memory_bytes: 876
#include <cstdio>
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

//関数プロトタイプ宣言
bool input();
void bfs(int H, int W);

//変数宣言
int w, h;
bool chart[50][50];		//trueは陸、falseは海
bool check[50][50];		//探索を終えた場所はtrue
typedef pair<int, int> P;	//P(h, w)に統一する
int dw[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dh[8] = {-1, 0, 1, -1, 1, -1, 0, 1};	
//順に　左上　←　左下　↑　↓　右上　→　右下

int main()
{
	while (input())
	{
		int output = 0;
		//check配列の初期化
		for (int i=0; i<h; i++)
			for (int i2=0; i2<w; i2++)
				check[i][i2] = false;
	
		//陸の探索
		for (int i=0; i<h; i++)
		{
			for (int i2=0; i2<w; i2++)
			{
				//次のbfsで１つの島の全ての陸のcheckをtrueにする
				if (chart[i][i2]==true)
				{
					bfs(i, i2);		//引数は(h, w)で渡している
					output++;
				}
			}
		}
		printf("%d\n", output);
	}
	return 0;
}


//こいつにある陸の座標を渡すと、陸続きの全ての陸のcheck値がtrueになる
void bfs(int H, int W)
{
	queue<P> que;
	//スタート地点の陸の座標をキューに入れる
	que.push(P(H, W));
	check[H][W] = true;
	chart[H][W] = false;
	
	//キューが空になるまでループ
	while (que.size())
	{
		// printf("in while\n");
		
		//キューの先頭を取りだす
		P p = que.front();
		que.pop();
		
		//移動８方向をループ
		for (int i=0; i<8; i++)
		{
			//移動後の座標をnw, nhとする
			int nw = p.second + dw[i];
			int nh = p.first + dh[i];
			
			if (0<=nw && nw<w && 0<=nh && nh<h && chart[nh][nw]==true && check[nh][nw]==false)
			{
				que.push(P(nh, nw));
				check[nh][nw] = true;
				chart[nh][nw] = false;
			}
		}
	}
}

bool input()
{
	scanf("%d %d", &w, &h);
	if (w==0) return false;

	for (int i=0; i<h; i++)
	{
		for (int i2=0; i2<w; i2++)
		{
			//陸はtrue、海はfalseで入る
			cin >> chart[i][i2];
			// printf("%d ", chart[i][i2]);
		}
		// printf("\n");
	}
	return true;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    y = 0;
    for(int i=1;i<=n;i++){
        cin>>x;
        if((x%2)&&(i%2))y++;
    }
    cout<<y;


    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int n;
	while (cin >> n && n) {
		int r; cin >> r;
		V cards(n);
		rep(i, n) cards[i] = n - i;
		rep(_, r) {
			int p, c; cin >> p >> c;
			p--;
			rep(i, c) {
				for (int idx = p + i; idx - 1 >= i; idx--) {
					swap(cards[idx - 1], cards[idx]);
				}
			}
		}
		cout << cards[0] << endl;
	}
}

Measured memory_bytes: 2968
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>













const int N=2e5+10;
ll n,m,a,b,c[N];

void solve()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)c[i]=0;
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		if(a==1)c[b]++;
		if(b==n)c[a]++;
	}
	for(int i=2;i<n;i++)
	{
		if(c[i]==2)
		{
			cout<<"POSSIBLE\n";
			return;
		}
	}
	cout<<"IMPOSSIBLE\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<class T> struct Dinic {
  struct Edge { int to, rev; T cap; };
  const T inf = numeric_limits<T>::max();
  const int n;
  VV<Edge> g;
  V<> dist, i;
  Dinic(int n) : n(n), g(n), dist(n), i(n) {}
  void add_edge(int from, int to, T cap) {
    assert(from != to);
    assert(cap >= 0);
    if (!cap) return;
    g[from].emplace_back(Edge{to, (int)g[to].size(), cap});
    g[to].emplace_back(Edge{from, (int)g[from].size() - 1, 0});
  }
  void bfs(int s) {
    fill(begin(dist), end(dist), -1);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while (!que.empty()) {
      int v = que.front(); que.pop();
      for (const auto& e : g[v]) {
        if (dist[e.to] != -1 or !e.cap) continue;
        dist[e.to] = dist[v] + 1;
        que.push(e.to);
      }
    }
  }
  T dfs(int v, int s, T f) {
    if (v == s) return f;
    for (; i[v] < (int)g[v].size(); ++i[v]) {
      Edge& e = g[v][i[v]];
      if (dist[e.to] >= dist[v] or !g[e.to][e.rev].cap) continue;
      T d = dfs(e.to, s, min(f, g[e.to][e.rev].cap));
      if (d > 0) {
        g[e.to][e.rev].cap -= d;
        e.cap += d;
        return d;
      }
    }
    return 0;
  }
  T max_flow(int s, int t) {
    assert(s != t);
    T res = 0;
    while (true) {
      bfs(s);
      if (dist[t] == -1) return res;
      fill(begin(i), end(i), 0);
      while (true) {
        T f = dfs(t, s, inf);
        if (!f) break;
        res += f;
      }
    }
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<lint> a(n); for (auto&& e : a) cin >> e;
  bitset<60> bs;
  lint res = 0;
  for (int k = 59; k >= 0; --k) {
    int c = 0;
    for (lint e : a) {
      c += e >> k & 1;
    }
    bs[k] = c and ~c & 1;
    if (c & 1) {
      res += 1LL << k;
      for (auto&& e : a) {
        e &= ~(1LL << k);
      }
    }
  }
  V<lint> v;
  for (lint e : a) {
    for (lint x : v) {
      e = min(e, e ^ x);
    }
    if (e) v.push_back(e);
    sort(rbegin(v), rend(v));
  }
  lint sum = 0;
  for (lint e : v) {
    sum = max(sum, sum ^ e);
  }
  res += 2 * sum;
  cout << res << '\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int kaijou(int k) {
    int x = 1;
    for (int i = 1; i < k; ++i) x *= i;
    return x;
}

int main() {
    int n, a[9] = {}, b[9] = {},m=0;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) {
        m += kaijou(n - i) * (a[i] - b[i]);
        for (int j = i + 1; j < n;++j) {
            if (a[j] > a[i]) a[j] -= 1;
            if (b[j] > b[i]) b[j] -= 1;
        }
        
    }
    if (m >= 0) cout << m << endl;
    else cout << -m << endl;

}



Measured memory_bytes: 256
w, h, n = map(int, input().split())
WH = [[1]*w for i in range(h)]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(h):
            for j in range(x):
                WH[i][j] = 0
    elif a == 2:
        for i in range(h):
            for j in range(x, w):
                WH[i][j] = 0
    elif a == 3:
        for i in range(y):
            for j in range(w):
                WH[i][j] = 0
    elif a == 4:
        for i in range(y, h):
            for j in range(w):
                WH[i][j] = 0
ans = 0
for i in WH:
    ans += sum(i)
print(ans) 

Measured memory_bytes: 74916
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"

/*##################################################################################*/

/*
int prime[1000000] = {0} ;
vector < vector < int >  > fact(1000001);
void calculateprime()
{
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; i <= 1000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*2 ; j <= 1000000 ; j += i )
            {
                fact[j].pb(i);
            }
        }
    }
}
*/

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    for(ll i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

ll fib(int n)
{
  ll a = 0, b = 1, c, i;
  if( n == 0)
    return a;
  for (i = 2; i <= n; i++)
  {
    c = (a + b);
    a = b;
    b = c;
  }
  return b;
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair<int,int> &a , const pair<int,int> &b){
    return a.first < b.first;
    if(a.first == b.first)  return a.second < b.second;
}


void solve(){
  char ch;
  in(ch);
  if(ch >= 'A' and ch <= 'Z')   out("A");
  else out("a");
  
}
int main() {
    fast();
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}


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

string solve (int a, int b, int c, int d, int e, int k) {

    if (b - a <= k && c - a <= k && d - a <= k && e - a <= k && c - b <= k && d - b <= k && e - b <= k && d - c <= k && e - c <= k && e - d <= k) {
        return "Yay!";
    }
    else {
        return ":(";
    }
}

int main () {

    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    cout << solve(a, b, c, d, e, k) << endl;

    return 0;
}


Measured memory_bytes: 256
O = "RUD"
E = "LUD"

S = input()
f = 0
for i in range(len(S)):
  if i % 2:
    if S[i] in E:
      f += 1
  else:
    if S[i] in O:
      f += 1

if len(S) == f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
n = gets.to_i 
h = {} 
n.times do 
    s = gets 
    # hの配列にキーを"S 10"みたいなものをいれて、全てに1をいれる 
    h[s.chomp] = 1 
end 

for m in ["S", "H", "C", "D"] do 
    for i in 1..13 do 
        # キーにm+" "+i.to_sが存在しなかったら出力する
        if !h.has_key?(m + " " + i.to_s) 
           puts m + " " + i.to_s 
        end
    end 
end


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
const ll MOD = 1000000007;

void solve(long N, vector<long> A) {
  vector<long> cum(N, 0);
  REP(i, N) {
    if (i == 0)
      cum[i] = A[i];
    else
      cum[i] = (cum[i - 1] + A[i]) % MOD;
  }
  long ans(0);
  FOR(i, 1, N) {
    ll mul = cum[i - 1] * A[i];
    ans += mul % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

  long N;
  cin >> N;
  
  vector<long> A(N);
  REP(i, N)
    cin >> A[i];

  solve(N, move(A));

  return 0;
}


Measured memory_bytes: 6348
DBG = !true
n,k = gets.split.map{|x| x.to_i}
a = gets.split.map{|x| x.to_i}

msb = 1
msblog = 0
while msb <= k
  msb *= 2
  msblog += 1
end
#msb /= 2
puts "msb #{msb} log #{msblog}" if DBG

restsum = 0
for i in 0...n
  restsum += a[i] & ~(2**msblog - 1)
end
puts "restsum #{restsum}" if DBG

bits = Array.new(msblog, 0)
for i in 0...n
  x = a[i]
  for e in 0...msblog
    bits[e] += 1 if x%2 == 1
    x /= 2
  end
end
print bits if DBG

bestx = 0
for i in 0...msblog
  bestx += 2**i if bits[i] < (n+1)/2
end
puts "#{bestx}" if DBG

if bestx <= k
  sum = 0
  for i in 0...msblog
    sum += ((bestx & (2**i) != 0) ? n-bits[i] : bits[i]) * (2**i)
  end
else
  bestx1 = bestx - 2**(msblog-1)
  sum1 = 0
  for i in 0...msblog
    sum1 += ((bestx1 & (2**i) != 0) ? n-bits[i] : bits[i]) * (2**i)
  end

  bestx2 = bestx
  (msblog-2).downto(0) { |e|
    if (bestx2 & (2**e)) != 0 && (k & (2**e)) == 0
      bestx2 -= 2**e
      break if bestx2 <= k
    end
  }
  sum2 = 0
  for i in 0...msblog
    sum2 += ((bestx2 & (2**i) != 0) ? n-bits[i] : bits[i]) * (2**i)
  end
  puts "casex s1 #{sum1} b1 #{bestx1} s2 #{sum2} b2 #{bestx2}" if DBG
  sum = [sum1, sum2].max
end
puts "#{restsum + sum}"


Measured memory_bytes: 15516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    string s, t;
    cin >> s >> t;
    ll ans = INF;
    rep(i, s.size()-t.size()+1){
        ll cnt = 0;
        rep(j, t.size()){
            if(t[j] != s[i+j]) cnt++;
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

int main(){
  long N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int res=0;
  if(d[N/2-1] != d[N/2]){
    res = d[N/2] - d[N/2-1];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

typedef struct tnode tnode;

typedef struct{
	tnode *root;
}Tree;

struct tnode {
	int key;
	tnode *left, *right;
	tnode *p;
};
void insert(Tree *T, int n) {
	tnode *z;
	z = malloc(sizeof(tnode));
	z->key = n;
	z->left = z->right = NULL;
	tnode *y = NULL;
	tnode *x = T->root;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
		z->p = y;
	}

	if (y == NULL) {
		T->root = z;
	}
	else if (z->key < y->key) {
		y->left = z;
	}
	else {
		y->right = z;
	}
}

int find_rec(tnode *node, int key) {
	if(node->key == key) return 1;
	if(node->key == key) return 1;
	if(node->key > key) {
		if(node->left != NULL && find_rec(node->left, key)) return 1;
	}
	else {
		if(node->right != NULL && find_rec(node->right, key)) return 1;
	}
	return 0;
}

int find(Tree *tree, int key) {
	return find_rec(tree->root, key);
}

void print_preorder_rec(tnode *node){
	printf(" %d", node->key);
	if(node->left != NULL) print_preorder_rec(node->left);
	if(node->right != NULL) print_preorder_rec(node->right);
}

void print_preorder(Tree *tree) {
	print_preorder_rec(tree->root);
	printf("\n");
}

void print_inorder_rec(tnode *node){
	if(node->left != NULL) print_inorder_rec(node->left);
	printf(" %d", node->key);
	if(node->right != NULL) print_inorder_rec(node->right);
}

void print_inorder(Tree *tree) {
	print_inorder_rec(tree->root);
	printf("\n");
}

void print_postorder_rec(tnode *node){
	if(node->left != NULL) print_postorder_rec(node->left);
	if(node->right != NULL) print_postorder_rec(node->right);
	printf(" %d", node->key);
}

void print_postorder(Tree *tree) {
	print_postorder_rec(tree->root);
	printf("\n");
}

int main(void) {
	Tree T;
	T.root = NULL;
	int i, n, z;
	char command[7];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", command);
		if (strcmp(command, "insert") == 0) {
			scanf("%d", &z);
			insert(&T, z);
		}
		if (strcmp(command, "print") == 0) {
			print_inorder(&T);
			print_preorder(&T);
		}
		if (strcmp(command, "find") == 0) {
			scanf("%d", &z);
			if (find(&T, z)) printf("yes\n");
			else printf("no\n");
		}
	}
	return 0;
}



Measured memory_bytes: 20440
#include <stdio.h>
#include <math.h>

int main(void){
	
	int a, b;
	int menseki, ensyu;
	
	scanf("%d%d", &a, &b);
	
	ensyu = 2 * a + 2 * b;
	menseki = a * b;
	
	printf("%d %d\n", menseki, ensyu);
	
	return 0;
}



Measured memory_bytes: 2028
#include <stdio.h>
int main(void){

int r,c;
int a,b,e=0,g=0;
int d[101]={},f[101]={};

scanf("%d %d",&r,&c);

for(a=1;a<=r;a++){
	for(b=1;b<=c;b++){
	scanf("%d",&d[b]);
	e=e+d[b];
	f[b]=f[b]+d[b];
	printf("%d ",d[b]);
	}
	printf("%d\n",e);
	e=0;
}
for(b=1;b<=c;b++){
printf("%d ",f[b]);
g=g+f[b];
}
printf("%d\n",g);
return 0;
}

Measured memory_bytes: 600
N = int(input())
S = [input() for _ in range(N)]

# sort
for i in range(N):
    S[i] = "".join(sorted(S[i]))

# main
t = dict()
for i in range(N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1

print(sum(t[key]*(t[key] - 1) // 2 for key in t))

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

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

  bool flag;
  int ans = 0;
  for (int i=X; i<110000; i++) {
    flag = true;
    for (int j=2; j<X; j++) {
      if (i%j == 0) {
        flag = false;
      }
    }
    if (flag == true) {
      ans = i;
      break;
    }
  }

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


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

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int h, w; cin >> h >> w;
  vector<vector<char>> A(h, vector<char>(w));
  queue<int> q;
  
  rep(i, h){
    rep(j, w){
      cin >> A[i][j];
      if(A[i][j] == '#'){
        q.push(i);
        q.push(j);
      }
    }
  }

  int cnt = 0;
  int qs = q.size() / 2;
  int temp = 0;
  while(!q.empty()){
    
    if(qs == temp){
      temp = 0;
      qs = q.size() / 2;
      cnt ++;
    }

    int y = q.front(); q.pop();
    int x = q.front(); q.pop();

    rep(i, 4){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(ny >= 0 and ny < h and nx >= 0 and nx < w){
        if(A[ny][nx] == '.'){
          A[ny][nx] = '#';
          q.push(ny);
          q.push(nx);
        }
      }
    }
    temp ++;
  }
 
  pr(cnt);
  
  return 0;
}


Measured memory_bytes: 9488
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a>b) {
			System.out.println("a > b");		
		}else if(a<b) {
			System.out.println("a < b");
		}else if(a==b) {
			System.out.println("a == b");
		}

	}

}


Measured memory_bytes: 26132
n, m = map(int,input().split())
l = []
r = []
for i in range(m):
    a, b = map(int,input().split())
    l.append(a)
    r.append(b)

a = 1
b = n
for i in range(m):
    a = max(l[i], a)
    b = min(r[i], b)

if b - a + 1 >= 0:
    print(b - a + 1)
else:
    print(0)

Measured memory_bytes: 11000
#include <stdio.h>

int min (int m, int x) {
	if (m > x) {
		m = x;
	}

	return m;
}

int main () {
	int i, j, k, l, n;
	int x[200];
	int m[200][200];

	scanf("%d", &n);

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

	for (l = 2; l <= n; l++) {
		for (i = 1; i <= n - l + 1; i++) {
			j = i + l - 1;
			m[i][j] = 1000000;
			
			for (k = i; k <= j - 1; k++)  {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + x[i - 1] * x[j] * x[k]);
			}
		}
	}

	printf("%d\n", m[1][n]);	 

	return 0;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int k;
	cin>>k;
	forn(i,0,k)
		cout<<"ACL";
	cout<<endl;
	return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)

#define BR "\n"

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

  vector<ll> v;

  rep0(i, q) {
    int query; cin >> query;
    if (query == 0) {
      int x; cin >> x;
      v.push_back(x);
    } else if (query == 1) {
      int p; cin >> p;
      cout << v[p] << BR;
    } else {
      v.pop_back();
    }
  }

  return 0;
}


Measured memory_bytes: 4948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string str; cin >> str;

    int ans = 0;
    int s = 0, t = 0;
    rep(i,str.size()) {
        if(str[i]=='S') {
            ++s;
        }else {
            if(s!=0) {
                --s;
            }else {
                ++ans;
            }
        }
    }
    cout << ans + s << endl;

    return 0;
}

Measured memory_bytes: 720
from collections import deque

mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

N = I()
c = input()
r_num = c.count("R")

count = 0
for i in range(r_num):
  if(c[i] == "W"):
    count += 1
print(count)

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

int main() {
	const ll INF = 1e18;
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	vector<vector<ll>> dp_p(N, vector<ll>(16, INF));
	vector<ll> p_min(N, INF);
	p_min[N - 1] = 0;
	for (int i = N - 1; i >= 0; --i) {
		if (i == N - 1) {
			for (int j = 0; j < 16; ++j) {
				dp_p[i][j] = j;
			}
			continue;
		}
		for (int j = 0; j < 16; ++j) {
			ll x = a[i] * pow(4LL, j);
			ll y = a[i + 1];
			ll cnt = 0;
			while (x > y) {
				y *= 4;
				++cnt;
			}
			if (cnt <= 15) {
				dp_p[i][j] = dp_p[i + 1][cnt] + j;
			} else {
				dp_p[i][j] = dp_p[i + 1][15] + j + (N - i - 1) * (cnt - 15);
			}
			p_min[i] = min(p_min[i], dp_p[i][j]);
		}
	}
	vector<vector<ll>> dp_n(N, vector<ll>(16, INF));
	vector<ll> n_min(N, INF);
	n_min[0] = 0;
	for (int i = 0; i < N; ++i) {
		if (i == 0) {
			for (int j = 0; j < 16; ++j) {
				dp_n[i][j] = j;
			}
			continue;
		}
		for (int j = 0; j < 16; ++j) {
			ll x = a[i] * pow(4LL, j);
			ll y = a[i - 1];
			ll cnt = 0;
			while (x > y) {
				y *= 4;
				++cnt;
			}
			if (cnt <= 15) {
				dp_n[i][j] = dp_n[i - 1][cnt] + j;
			} else {
				dp_n[i][j] = dp_n[i - 1][15] + j + i * (cnt - 15);
			}
			n_min[i] = min(n_min[i], dp_n[i][j]);
		}
	}

	ll res = INF;
	for (int i = -1; i < N; ++i) {
		ll p = INF, n = INF;
		if (i >= 0) { n = n_min[i] * 2; }
		else { n = 0; }

		if (i < N - 1) { p = p_min[i + 1] * 2; }
		else { p = 0; }

		res = min(res, p + n + i + 1);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 70528
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    ll n;
    cin>>n;
    ll ans=1;
    for(int i=1;i<=n;i++){
        ans*=i;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	pair<int, int> a[n];
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	vector<int> ans;
	rep(i, n) {
		for (int j = n - 1; j >= 0; j--) {
			if (a[j].first == 0) continue;
			if (a[j].first == a[j].second) {
				a[j].first = 0;
				ans.push_back(a[j].second);
				break;
			} else
				a[j].second--;
		}
	}
	reverse(all(ans));
	if (ans.size() == n) {
		for (auto p : ans) cout << p << endl;
	} else
		cout << -1 << endl;
	return 0;
}

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

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

    int maxValue = max(A, B);
    maxValue = max(maxValue, C);

    int leftSum = A + B + C - maxValue;

    int sum = maxValue;
    rep(i, K) {
        sum = sum * 2;
    }

    int ans = leftSum + sum;

    cout << ans << endl;

    return 0;
}


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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[10];

  REP(i, 10) {
    cin >> a[i];
  }
  sort(a, a + 10);

  REP(i, 3) {
    cout << a[9 - i] << endl;
  }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rank tipa_rank
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 1000000000
#define EPS 1e-6
#define free tipa_free
#define EPS2 1e-8
using namespace std;
const ll MOD = INF + 7;
using namespace std;
ll ans = 0;
int n , m;
int visited[100000];
ll trees , cycles , free;
vector<vector<int> > g(100000);
int edgesCnt = 0 , verticesCnt;
bool bipatride;
void dfs(int u)
{
	for(int i = 0; i < g[u].size(); i++)
	{
		edgesCnt++;
		int v = g[u][i];
		bool Dfs = false;
		if(!visited[v])
			Dfs = true;
		if(visited[u] == 1)
		{
			if(visited[v] == 1)
				bipatride = false;
			visited[v] = 2;
		}
		if(visited[u] == 2)
		{
			if(visited[v] == 2)
				bipatride = false;
			visited[v] = 1;
		}
		if(Dfs)
			dfs(v);
	}
}
int main()
{
	scanf("%d %d" , &n , &m);
	for(int i = 0; i < m; i++)
	{
		int u , v;
		scanf("%d %d" , &u , &v);
		u--;v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	for(int i = 0; i < n; i++)
	{
		if(!visited[i])
		{
			edgesCnt = 0;
			bipatride = true;
			visited[i] = 1;
			//edgesCnt++;
			dfs(i);
			if(!edgesCnt)
				free++;
			else if(bipatride)
			{
				trees++;
			}
			else
				cycles++;
		}
	}
	//cout << trees << " " << cycles << " " << free << endl;
	int x = n * 2 - 1;
	for(int i = 0; i < free; i++)
	{
		ans += x;
		x -= 2;
	}
	ans += cycles * (trees + cycles) + trees * (cycles + 2 * trees);
	cout << ans;
}


Measured memory_bytes: 8960
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		String str=input.readLine();
		String[] str2=str.split(" ");
		int a=Integer.parseInt(str2[0]);
		int b=Integer.parseInt(str2[1]);
		int c=Integer.parseInt(str2[2]);
		int ans=0;

		for(int i=a;i<b+1;i++){
			if(c%i==0){
			ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24328
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int A[100000];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&A[i]);

    LLI ans = 0,sum = 0;
    for (i = 0; i < N; i++) {
        if (A[i] == 0) ans += sum/2,sum = 0;
        else sum += A[i];
    }
    ans += sum/2;
    printf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int mo(int r, int d, int x) { return x * r - d; }
int main() {
  int r, d, xi;
  cin >> r >> d >> xi;
  for (int i = 0; i < 10; i++) {
    int tmp = mo(r, d, xi);
    cout << tmp << endl;
    xi = tmp;
    ;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;

int main()
{
    int n, k;
    vector<int> h(MAXN);

    cin >> n >> k;
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
    }

    if (n <= k)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(h.begin(), h.begin() + n);

    for (int i = 0; i < k; ++i)
    {
        h.pop_back();
    }

    long long int res = accumulate(h.begin(), h.begin() + n - k, 0LL);
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
int n,a;
cin >> n >>a;
if((n%500)<=a)cout << "Yes";
else cout<< "No";
return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int A,B;
int main(){
    cin >> A >> B;
    int ans;
    if(A >= 13) ans = B;
    else if(A <= 5) ans = 0;
    else ans = B/2;
    cout << ans << '\n';
}

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

int main() {
	int N , M;
  	cin >> N;
  	vector<string> blue(N);
  	for(int i = 0; i < N; i++){
    	cin >> blue.at(i);
    }
  	cin >> M;
  	vector<string> red(M);
  	for(int i = 0; i < M; i++){
    	cin >> red.at(i);
    }
  	int max = 0;
    int counter;
  	string temp;
  	for(int i = 0; i < N; i++){
    	counter = 0;
      	temp = blue.at(i);
      	for(int j = 0; j < N; j++){
        	if(blue.at(j) == temp){
            	counter++;
            }
        }
      	for(int k = 0; k < M; k++){
        	if(red.at(k) == temp){
            	counter--;
            }
        }
      	if(max < counter){
        	max = counter;
        }
    }
  	cout << max << endl;
}

Measured memory_bytes: 3608
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
leng = len(S)
ans = 0
for i in range(1<<(leng-1)):
    lis = [S[0]]
    for j in range(leng-1):
        if (i>>j)&1:
            ans += int(''.join(lis))
            lis = []
        lis.append(S[j+1])
    else:
        if lis:
            ans += int(''.join(lis))
print(ans)

Measured memory_bytes: 69988
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, c = i_map()

    print('YES' if b-a == c-b else 'NO')

if __name__ == '__main__':
    main()


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

int main(){
    int n,N;
    cin >> n;
    N=n;
    int s_n;
    while (n>0){
        s_n+=(n%10);
        n/=10;
    }
    if (N%s_n==0){
        cout << "Yes" <<endl;
    }
    else {
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
import math
import sys
from collections import deque
a,b=map(int,input().split())
b=b//1000
for i in range(a+1):
  for j in range(a+1):
    if 10*i+5*j+a-i-j==b and i+j<=a:
      print(i,j,a-i-j,sep=" ")
      sys.exit()
print(-1,-1,-1,sep=" ")

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

using namespace std;
const int mod = 1e9 + 7;

void add(int& a, int b) {
  a += b;
  if(a >= mod) {
    a -= mod;
  }
}
void sub(int& a, int b) {
  a -= b;
  if(a < 0) {
    a += mod;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> dp(n + 1, vector<int> (k + 1, 0));
  for(int i = 0; i <= n; i++) dp[i][0] = 1;
  for(int j = 1; j <= k; j++) {
    if(j <= a[n - 1]) dp[n - 1][j] = 1;
  }
  for(int i = n - 2; i >= 0; i--) { 
    int ways = 0;
    for(int j = 0; j <= a[i]; j++) {
      add(ways, dp[i + 1][j]);
      dp[i][j] = ways;
    }
    for(int j = a[i] + 1; j <= k; j++) { 
      add(ways, dp[i + 1][j]);
      sub(ways, dp[i + 1][j - a[i] - 1]);
      dp[i][j] = ways;
    }
  }    
  cout << dp[0][k] << '\n';
  return 0;
}
  
 
  
  



Measured memory_bytes: 43312
M, K = map(int, input().split())

sum = 0

for j in range(K,M+2):
    temp = j*(M-j+1) + 1
    if temp > (10**9 + 7):
        temp = temp%(10**9 + 7)
    sum += temp
if sum > 10**9+7:
    sum = sum%(10**9+7)

print(sum)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
char ch[110][110];
bool visit[1010],visit2[1010];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	memset(visit2,false,sizeof(visit2));
	memset(visit,false,sizeof(visit));
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) cin>>ch[i][j];
	for (int i=1;i<=n;i++)
	{
		bool flag=false;
		for (int j=1;j<=m;j++) if (ch[i][j]=='#')
		{
			flag=true;
			break;
		}
		if (!flag) visit[i]=true;
	}
	for (int i=1;i<=m;i++)
	{
		bool flag=false;
		for (int j=1;j<=n;j++) if (ch[j][i]=='#')
		{
			flag=true;
			break;
		}
		if (!flag) visit2[i]=true;
	}
	for (int i=1;i<=n;i++)
	{
		bool flag=false;
		for (int j=1;j<=m;j++) if (!visit[i] && !visit2[j])
		{
			cout<<ch[i][j];
			flag=true;
		}
		if (flag) cout<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
    public static void main(String[] args) {
       int a,b,c;
       Scanner scan = new Scanner(System.in);
        
       a = scan.nextInt();
       b = scan.nextInt();
       c = scan.nextInt();
       if(a<b && b<c){
        System.out.println("Yes");
       }else{
        System.out.println("No");
       }
   }
 
}

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


int main(void){

	int n;
	std::vector<long long> x, cp;

	std::cin >> n;
	x.resize(n);
	for(int i = 0; i < n; i++){
		std::cin >> x[i];
	}
	cp = x;

	std::sort(cp.begin(), cp.end());

	long long l = cp[n / 2 - 1];
	long long r = cp[n / 2];
	for(int i = 0; i < n; i++){
		std::cout << ((x[i] > l) ? l : r) << std::endl;
	}

	return 0;
}

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

int main() {
	int n_in, oki;
	float val;
	cin >> n_in;
	int v_in[n_in];
	for (int i = 0; i < n_in; ++i) {
		cin >> v_in[i];
	}

	for(int i=0; i<n_in-1; ++i){
		for (int j = 0; j < n_in-1; ++j) {
			if(v_in[j]>v_in[j+1]){
				oki=v_in[j+1];
				v_in[j+1]=v_in[j];
				v_in[j]=oki;
			}
		}
	}
	val=( (float)(v_in[0]+v_in[1]) )/2;
	for (int i = 1; i < n_in-1; ++i) {
		val = ( val + (float)(v_in[i+1]) )/2;
	}
	std::cout << std::setprecision(10) << val;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range(1,n-1):
    if(p[i-1]<p[i] and p[i]<p[i+1]):
        cnt += 1
    elif(p[i-1]>p[i] and p[i]>p[i+1]):
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()


int main(){
  ll N,ans=-INF;
  cin >> N;
  vec A(3*N),a(N+1),b(N+1);
  priority_queue<ll> B,C;
  rep(i,N){
    cin >> A.at(i);
    B.push(-A.at(i));
    a.at(0)+=A.at(i);
  }
  rep(i,N){
    cin >> A.at(N+i);
  }
  rep(i,N){
    cin >> A.at(2*N+i);
    C.push(A.at(2*N+i));
    b.at(N)+=A.at(2*N+i);
  }
  rep(i,N){
    a.at(i+1)=a.at(i);
    if(A.at(N+i)+B.top()>0){
      a.at(i+1)+=B.top();
      a.at(i+1)+=A.at(N+i);
      B.pop();
      B.push(-A.at(N+i));
    }
  }
  rep(i,N){
    b.at(N-1-i)=b.at(N-i);
    if(A.at(2*N-1-i)<C.top()){
      b.at(N-1-i)-=C.top();
      b.at(N-1-i)+=A.at(2*N-1-i);
      C.pop();
      C.push(A.at(2*N-1-i));
    }
  }
  rep(i,N+1){
    ans=max(ans,a.at(i)-b.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 9528
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    int A[N], S[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        S[i] = A[i];
    }
    sort(S, S + N);
    for (int i = 0; i < N; ++i) cout << (A[i] == S[N - 1] ? S[N - 2] : S[N - 1]) << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int k;
  cin >>k;
  rep(i, k){
    cout << "ACL";
  }
cout<<endl;

  return 0;
}


Measured memory_bytes: 3624