akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int i, j;
	
	int n;
	cin >> n;
	int pret = 0;
	int prex = 0, prey = 0;
	for (i = 0; i < n; i++) {
		int t, x, y;
		cin >> t >> x >> y;
		int t2, x2, y2;
		t2 = t - pret;
		x2 = abs(x - prex);
		y2 = abs(y - prey);
		//DEBUG(t2);
		//DEBUG(x2);
		//DEBUG(y2);
		if ((x2 + y2) % 2 != t2 % 2) {
			cout << "No" << endl;
			return 0;
		}
		if (abs(x) + abs(y) > t) {
			cout << "No" << endl;
			return 0;
		}
		pret = t;
		prex = x;
		prey = y;
	}
	cout << "Yes" << endl;
	return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int n, a[102];

int solve() {
  rep (i,n) cin >> a[i];
  //rep (i,n) printf("%2d", a[i]); puts("");

  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < n - (i+1); ++j) {
      if (a[j] > a[j+1]) { swap(a[j], a[j+1]); ans++; }
    }
  }
  //rep (i,n) printf("%2d", a[i]); puts("");
  return ans;
}

int main() {
  while (cin >> n, n) cout << solve() << endl;
  return 0;
}

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

class Strongly_connected_components
{
    const size_t V;
    std::vector<std::vector<size_t>> adj, mbr;
    std::vector<size_t> comp, low;
    size_t n;
    bool is_built;

  public:
    Strongly_connected_components(size_t _V) : V(_V), adj(V), comp(V), low(V), is_built() {}

    // add an edge from the vertex s to the vertex t.
    void add_edge(size_t s, size_t t) { adj[s].emplace_back(t); is_built = false; }

    // the number of the components.
    size_t count() { return build(), n; }

    // the number of vertices in the i-th component.
    size_t size(size_t i) { return build(), mbr[i].size(); }

    // vertices in the i-th component.
    const std::vector<size_t> &component(size_t i) { return build(), mbr[i]; }

    // the component which the vertex v belongs to.
    size_t operator[](size_t v) { return build(), comp[v]; }

    // the directed acyclic graph consisting of the components.
    std::vector<std::vector<size_t>> make_dag()
    {
        build();
        std::vector<std::vector<size_t>> res(n);
        bool *apr = new bool[V]{};
        size_t *stack_ptr = new size_t[V]; 
        for(size_t i = 0; i != n; ++i)
        {
            size_t *itr = stack_ptr;
            for(size_t s : mbr[i]) for(size_t t : adj[s]) if(!apr[comp[t]]) apr[comp[t]] = true, *itr++ = comp[t];
            res[i].resize(itr - stack_ptr);
            while(itr != stack_ptr) apr[res[i][--itr - stack_ptr] = *itr] = false;
        }
        delete[] apr, stack_ptr;
        return res;
    }

  protected:
    void build()
    {
        if(is_built) return;
        is_built = true, n = 0;
        fill(low.begin(), low.end(), -1);
        fill(comp.begin(), comp.end(), -1);
        size_t *itr = new size_t[V];
        for(size_t v = 0, c = 0; v != V; ++v) affix(v, c, itr);
        delete[] itr; mbr.resize(n);
        for(size_t v = 0; v != V; ++v) mbr[comp[v] = n - 1 - comp[v]].emplace_back(v);
    }

    size_t affix(size_t v, size_t &c, size_t* &itr)
    {
        if(~low[v]) return ~comp[v] ? -1 : low[v];
        size_t idx = c++; low[v] = idx; *itr++ = v;
        for(int u : adj[v]) low[v] = std::min(low[v], affix(u, c, itr));
        if(low[v] == idx) { do { comp[*--itr] = n; } while(*itr != v); ++n; }
        return low[v];
    }
};

main()
{
    using namespace std;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    Strongly_connected_components scc(n);
    while(m--)
    {
        int s, t;
        cin >> s >> t;
        scc.add_edge(s, t);
    }

    int Q;
    cin >> Q;
    while(Q--)
    {
        int s, t;
        cin >> s >> t;
        std::cout << (scc[s] == scc[t]) << "\n";
    }
}




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

int compstr(const void *a, const void *b){
    const char *x = a, *y = b;
    return strcmp(x,y);
}

int main(){
    int n, l;
    scanf("%d %d\n", &n, &l);
    char s[n][l+1];
    
    for (int i = 0; i < n; ++i)
        scanf("%s\n", s[i]);

    qsort(s, n, sizeof(s[0]), compstr);
    for(int i=0; i<n; i++)
        printf("%s",s[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#define DEBUG 1
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;
using p_ii = pair<int, int>;
map<p_ii, char> mp;
map<pair<p_ii, p_ii>, int> memo;

vector<pair<int, int>> positions;
const vector<pair<int, int>> dir_list = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int h, w;

inline bool isLoad(p_ii pos)
{
    return mp[pos] == '.';
}

inline bool inRange(p_ii pos)
{
    return (0 <= pos.first && pos.first < h) && (0 <= pos.second && pos.second < w);
}

void input()
{
    cin >> h >> w;

    // init maze map
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cin >> mp[{i, j}];
        }
    }
    positions.resize(h * w);
    // point list
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            positions[i * w + j] = {i, j};
        }
    }
    return;
}

// bfs
int bfs(p_ii pos)
{
    // init
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<p_ii> que;
    que.push(pos);
    dist[pos.first][pos.second] = 0;

    // search next node
    while (que.empty() == false)
    {
        p_ii cur = que.front();
        que.pop();

        for (auto dir : dir_list)
        {
            p_ii next = {cur.first + dir.first, cur.second + dir.second};

            if (inRange(next) == true && isLoad(next) == true && dist[next.first][next.second] == -1)
            {
                dist[next.first][next.second] = dist[cur.first][cur.second] + 1;
                que.push(next);
            }
        }
    }

    // max dist
    int res = 0;
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            res = max(res, dist[i][j]);
        }
    }
    
    return res;
}

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

    // count move number
    int ans = 0;
    for (size_t i = 0; i < (h * w); i++)
    {
        const pair<int, int> pos = positions[i];
        if (isLoad(pos) == true)
        {
            // pos からの最長経路を計算する
            int dis = bfs(pos);
            ans = max(ans, dis);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn gcd(a: i64, b: i64) -> i64 {
    if a % b == 0 { b } else { gcd(b, a % b )}
}
fn lcm(a: i64, b: i64) -> i64 {
    a * b / gcd(a, b)
}
fn main() {
    let a: Vec<i64> = read_vec();
    println!("{}", lcm(a[0], a[1]));
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int ans;

		if(N%(D+1+D)>0) {
			ans = N / (D + 1 + D)+1;
		} else {
			ans = N / (D + 1 + D);
		}
		System.out.println(ans);
     }

	}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>

using namespace std;


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

int64_t lcm(int64_t a, int64_t b) {
    return a * b / gcd(a, b);
}

int64_t count_div(int64_t a, int64_t b, int64_t div) {
    int64_t last_before, last_counted;
    if (a%div == 0) {
        last_before = (a-1) / div;
    } else {
        last_before = a / div;
    }
    last_counted = b / div;
    return last_counted - last_before;
}

int main(int argc, char **argv) {
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;

    int64_t ans = b - a + 1;
    int64_t l = lcm(c, d);

    ans -= count_div(a, b, c);
    ans -= count_div(a, b, d);
    ans += count_div(a, b,l);

    cout << ans << endl;

    return 0;
}

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

bool hasEightDivisor(const int N)
{
    int num_divisor = 0;
    reb(i, 1, N+1) {
        if (N%i == 0) num_divisor++;
    }
    return (num_divisor == 8);
}

int main(int argc, char *argv[])
{
    int N;
    cin >> N;

    int ans = 0;
    for (int i=1; i<=N; i+=2) {
        if (hasEightDivisor(i)) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
           {
               cnt++;
           }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 22;

int n, a[N][N], dp[N][(1 << N)];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    }
    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int mask = 0; mask < (1 << n); mask++) {
            if(!dp[i][mask]) continue;
            for(int k = 0; k < n; k++) {
                if(a[i][k] && (mask & (1 << k)) == 0)
                    dp[i + 1][(mask ^ (1 << k))] = (dp[i + 1][(mask ^ (1 << k))] + dp[i][mask]) % mod;
            }
        }
    }
    cout << dp[n][(1 << n) - 1];
}


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

int main(){
    int n,ans(0);

    cin >> n;
    int a[n];

    rep(i,n)    cin >> a[i];

    while(true){
        rep(i,n){
            if(a[i]%2==0){
                a[i] = a[i]/2;
            }else{
                cout << ans << endl;
                return 0;
            }   
        }
        ans++;
    }
}

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

using namespace std;

int main()
{
	int hh;
	int hhh;
	int kk;
	int kkk;
	int a;
	int b;
	int c;
	int d;
	cin >> hh >> hhh;
	cin >> kk >> kkk;
	cin >> a >> b >> c >> d;

	int hiro = (hh * a) + (hhh * b) +((hh / 10) * c) + ((hhh / 20) * d);
	int kenji = (kk * a) + (kkk * b) +((kk / 10) * c) + ((kkk / 20) * d);
	if(hiro > kenji) cout << "hiroshi" <<endl;
	if(hiro < kenji) cout << "kenjiro" << endl;
	if(hiro == kenji) cout << "even" <<endl;

return 0;
}

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

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

    int N, M, X;
    cin >> N >> M >> X;

    vector<int> C(N);
    vector<vector<int> > A(N, vector<int>(M));

    for(int i = 0; i < N; i++) {
        cin >> C[i];
        for(int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = 100000000;

    for (int bit = 0; bit < (1 << N); bit++) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {
                S.push_back(i);
            }
        }
        int count = 0;
        vector<int> x(M);

        for(int i = 0; i < S.size(); i++) {
            count += C[S[i]];
            for(int j = 0; j < M; j++) {
                x[j] += A[S[i]][j];
            }
        }

        bool checker = false;

        for(int i = 0; i < M; i++) {
            if(x[i] < X) {
                checker = true;
                break;
            }
        }

        if(checker) continue;
        ans = min(ans, count);
    }

    if(ans == 100000000) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s,t;
    cin>>s;
    ll ans=0;
    t="CODEFESTIVAL2016";
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in a:
    ans^=i
k=~ans
for i in range(n):
    a[i]&=k
rank=0
# 掃き出し法
for i in range(59,-1,-1):
    for j in range(rank,n):
        if a[j]>>i&1:
            break
    if j==n:
        continue
    if j>rank:
        # a[rank]のi番目のbitを1にするswapでもいい
        a[rank]^=a[j]
    for j in range(rank+1,n):
        a[j]=min(a[j],a[j]^a[rank])
    res=0
    rank+=1
for i in a:
    res=max(res,res^i)
print(ans+2*res)

Measured memory_bytes: 76960
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n,m;
int a[1002];
int main() {
	scanf("%d%d",&n,&m);
	int s=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		s+=a[i];
	}
	sort(a+1,a+1+n);
	int val=a[n-m+1];
	// val >= tot / 4m
	printf("%s\n", 1LL * 4 * m * val >= s ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a<b)
    cout << "a < b" << endl;
    else if(a>b)
    cout << "a > b" << endl;
    else if(a==b)
        cout << "a == b" << endl;
}


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


void solve(long long X){
  long long acc = X;
  for(long long i = 1; i < 100000; i++){
    if((acc*i)%360 == 0) {
      cout << i << endl;
      return;
    }
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
  scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3648
#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

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

int main(){
    int N,Q;
    scanf("%d%d",&N,&Q);
    fenwick_tree<long long> fw(N);
    rep(i,N){
        int tmp;
        scanf("%d",&tmp);
        fw.add(i,tmp);
    }
    rep(i,Q){
        int t;
        scanf("%d",&t);
        if(t==0){
            int p,x;
            scanf("%d%d",&p,&x);
            fw.add(p,x);
        }
        else{
            int l,r;
            scanf("%d%d",&l,&r);
            printf("%lld\n",fw.sum(l,r));
        }
    }

    return 0;
}

Measured memory_bytes: 8208
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  a = (a + 11) % 13, b = (b + 11) % 13;
  printf("%s", a == b ? "Draw" : (a > b ? "Alice" : "Bob"));
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long ans=10000000000000;
	for(int i=1;i<=sqrt(n);i++){
		if(n%i==0){
			ans=min(ans,n/i+i);
		}
	}
	printf("%lld",ans-2);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#define LL long long
#define PI pair<LL,LL>
using namespace std;
LL D,St1[25],St2[25],P[25];
vector<LL>V;
void DFS(LL L,LL R,vector<PI>& Rec,LL Val,LL Cnt){
	if(L==R){
		Rec.push_back(PI(Val,Cnt));
		return; 
	}
	for(LL I=-9;I<=9;I++) DFS(L+1,R,Rec,Val+I*V[L],Cnt*((L==0)?St2[I+10]:St1[I+10]));
}
LL Solve(LL Len){
	V.clear();
	for(LL I=0;Len-I-1>I;++I) V.push_back(P[Len-I-1]-P[I]);
	vector<PI>An1,An2;
	LL Res=0;
	DFS(0,(V.size()+1)/2,An1,0,1);
	DFS((V.size()+1)/2,V.size(),An2,0,1);
	map<LL,LL>Mp;  Mp.clear();
	for(LL I=0;I<An2.size();I++) Mp[An2[I].first]+=An2[I].second;
	for(LL I=0;I<An1.size();I++) Res+=Mp[D-An1[I].first]*An1[I].second;
	if(Len&1) Res*=10;
	return Res;
}
int main(){
    scanf("%lld",&D);
    P[0]=1;
    for(LL I=1;I<=18;I++) P[I]=P[I-1]*10;
    for(LL I=0;I<=9;I++)
    	for(LL J=0;J<=9;J++){
    		St1[I-J+10]++;
			if(I&&J) St2[I-J+10]++;	
		}
	LL Ans=0;
	for(LL I=1;I<=18;I++) Ans+=Solve(I);
	printf("%lld",Ans);
	return 0;
}


Measured memory_bytes: 206936
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    string a, b;
    cin >> a >> b;
    //reverse(a.begin(), a.end());
    //reverse(b.begin(), b.end());
    if(a.length() > b.length()) cout << "GREATER" << endl;
    else if(b.length() > a.length()) cout << "LESS" << endl;
    else{
        bool z = true;
        for(int i = 0; i < a.length(); i++){
            if(a[i] > b[i]){
                z = false;
                cout << "GREATER" << endl;
                break;
            }else if(a[i] < b[i]){
                z = false;
                cout << "LESS" << endl;
                break;
            }
        }
        if(z) cout << "EQUAL" << endl;
    }
    return 0;
}

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

//5桁の整数abcde(a～eは1桁の正の整数)が回文数かどうか判定する関数f(x)
bool f(int x) {
    int a = x / 10000;          //xの10000の位
    int b = (x / 1000) % 10;    //xの1000の位
    int d = (x / 10) % 10;      //xの10の位
    int e = x % 10;             //xの1の位

    if( a == e && b == d ) {
        return true;
    }
    else {
        return false;
    }
}

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    
    for(int i = A; i <= B; i++) {
        if( f(i) ) {
            ans++;
        }
    }

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

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int A[110], B[110];
int ans;

void solve() {
	A[0] = B[0];
	for (int i = 1; i < n - 1; i++) A[i] = min(B[i - 1], B[i]);
	A[n - 1] = B[n - 2];

	for (int i = 0; i < n; i++) ans += A[i];
	printf("%d\n", ans);

	return;
}

int main(void){
	cin>>n;
	for (int i = 0; i < n - 1; i++) cin>>B[i];

	solve();
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n);
  b[0]++;
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    a[p-1]--;
    a[q-1]++;
    if (b[p-1] != 0) {
      if (a[p-1] == -1) {
        b[p-1] = 0;
        b[q-1]++;
      }
      else {
        b[q-1]++;
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != 0) {
      ans ++;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#define mp make_pair
#define ii pair < ll, ll >
#define F first
#define S second
#define i_ii pair < ll, ii >
#define mpp(AA, BB, CC) mp( AA, mp(BB, CC) )
#define ll long long int

using namespace std;

int v[20][200010];

int main()
{
    //para q (^ = +) no pueden tener bits iguales prendidos
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, a;
    cin >> n;
    for(ll j = 0 ; j < 20 ; j++){
        v[j][0] = 0;
    }
    for(ll i = 1 ; i <= n ; i++){
        cin >> a;
        for(ll j = 0 ; j < 20 ; j++){
            v[j][i] = (a%2) + v[j][i - 1];
            a /= 2;
        }
    }
    map < ll, ll > m[20];//m[bit][suma] = posicion maxima en la q la suma es esa
    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 0 ; j < 20 ; j++){
            m[j][ v[j][i] ] = i;
        }
    }
    /*
    for(int j = 0 ; j < 5 ; j++){
        for(int i = 1 ; i <= n ; i++){
            //cout << v[j][i]  << ' ';
        }//cout << endl;
    }//cout << endl;
    for(int j = 0 ; j < 5 ; j++){
        for(int i = 1 ; i <= n ; i++){
            //cout << m[j][ v[j][i] ] << ' ';
        }//cout << endl;
    }*/
    ll res = 0;
    for(ll i = 1 ; i <= n ; i++){
        ll mi = n + 5;
        for(int j = 0 ; j < 20 ; j++){
            ll s = v[j][i], aux;
            if(v[j][i - 1] == v[j][i]){
                aux = max( m[j][s], m[j][s + 1] );
            }else aux = m[j][s];
            mi = min( mi, aux);
        }
        //cout << i << ' ' << mi << endl;
        res += (mi - i + 1);
    }
    cout << res;
    return 0;
}












Measured memory_bytes: 140928
def main():
    N = int(input())
    S = input()

    rcs = [0] * N
    gcs = [0] * N
    bcs = [0] * N

    for i in range(N):
        if S[i] == 'R':
            rcs[i] = 1
        elif S[i] == 'G':
            gcs[i] = 1
        elif S[i] == 'B':
            bcs[i] = 1

    for i in range(1, N):
        rcs[i] += rcs[i - 1]
        gcs[i] += gcs[i - 1]
        bcs[i] += bcs[i - 1]

    result = 0
    for i in range(N):
        if S[i] == 'R':
            for j in range(i + 1, N):
                if S[j] == 'R':
                    continue
                elif S[j] == 'G':
                    result += bcs[N - 1] - bcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'B':
                        result -= 1
                elif S[j] == 'B':
                    result += gcs[N - 1] - gcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'G':
                        result -= 1
        elif S[i] == 'G':
            for j in range(i + 1, N):
                if S[j] == 'G':
                    continue
                elif S[j] == 'R':
                    result += bcs[N - 1] - bcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'B':
                        result -= 1
                elif S[j] == 'B':
                    result += rcs[N - 1] - rcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'R':
                        result -= 1
        elif S[i] == 'B':
            for j in range(i + 1, N):
                if S[j] == 'B':
                    continue
                elif S[j] == 'R':
                    result += gcs[N - 1] - gcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'G':
                        result -= 1
                elif S[j] == 'G':
                    result += rcs[N - 1] - rcs[j]
                    t = 2 * j - i
                    if t < N and S[t] == 'R':
                        result -= 1
    print(result)


main()


Measured memory_bytes: 9396
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s, t;
	cin>>s>>t;

	vector <set <int>> v(26);
	rep(i,s.length())
	{
		int x = s[i]-'a';
		v[x].insert(i+1);
	}
	int pre = 0, ans = 0, curr=0;
	rep(i,t.length())
	{
		int x = t[i]-'a';
		if (sz(v[x])==0)
		{
			cout<<-1;
			return 0;
		}
		auto itr = v[x].lower_bound(pre+1);
		if (itr==v[x].end())
		{
			ans+=sz(s)-pre;
			pre = 0;
		}
		itr = v[x].lower_bound(pre+1);
		curr = *itr;
		if (curr>pre)
		{
			ans+=curr-pre;
		}
		// else
		// {
		// 	ans+= sz(s)-pre+curr;
		// 	debug2(t[i],curr);
		// }
		pre = curr;
		// debug1(ans);
	}
	cout<<ans;

	return 0;
}



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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	vector<ll> x(n+1,0);
	for(int i = 1; i <= n; i++){
		ll res = i;
		for(int j = 2; j*j <= n; j++){
			while(res%j==0){
				x[j]++;
				res /= j;
			}
		}
		if(res!=0)
			x[res]++;
	}

	x[1] = 0;
	ll ans = 1;
	for(int i = 1; i <= n; i++){
		ans *= x[i]+1;
		ans %= mod;
	}
	cout<<ans<<endl;

	return 0;
}

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

unordered_map<string,ll> cnts;

bool comp(string a,string b)
{
	if(cnts[a]!=cnts[b])return cnts[a]<cnts[b];
	return a<b;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	vector<string> v(n);
	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
		cnts[v[i]]++;
	}
	sort(all(v),comp);
	v.erase(unique(all(v)),v.end());
	ll cur=cnts[v[sz(v)-1]];
	vector<string> x;
	for(ll i=sz(v)-1;i>=0;i--)
	{
		if(cnts[v[i]]==cur)x.pb(v[i]);
		else break;
	}
	reverse(all(x));
	for(auto it:x)cout<<it<<"\n";
	return 0;
}

Measured memory_bytes: 26948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

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


  cout << N*M << endl;

}

Measured memory_bytes: 3636
def s(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]
    return [(2*a+c)/3,(2*b+d)/3]
def t(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]    
    return [(a+2*c)/3,(b+2*d)/3]
def u(p,q):
    a=p[0]
    b=p[1]
    c=q[0]
    d=q[1]
    return [(a+c)/2+(3**(1/2))*(b-d)/6,(b+d)/2+(3**(1/2))*(c-a)/6]

def koch(p1,p2,n):
    if n==0:
        return [p1]
    else:
        return koch(p1,s(p1,p2),n-1)+koch(s(p1,p2),u(p1,p2),n-1)+koch(u(p1,p2),t(p1,p2),n-1)+koch(t(p1,p2),p2,n-1)

n=int(input())
a=[0,0]
b=[100,0]
for i in koch(a,b,n):
    print(str(i[0])+" "+str(i[1]))

print(str(b[0])+" "+str(b[1]))

Measured memory_bytes: 8292
n = int(input())
s = list(input())

p = s.count('.')
q = 0
r = p

for i in range(n):
    if s[i] == '#':
        q += 1
    else:
        p -= 1
    # r = min(r, p + q)
    r = r if r < p + q else p + q

print(r)

Measured memory_bytes: 61424
X=int(input())
primelist=[]
sqX=int(X**0.5)
i=2

while True:
  is_pr=True
  sqi=int(i**0.5)
  for p in primelist:
    if i%p==0:
      is_pr=False
      break
    if p>sqi:
      break
  if is_pr:
    primelist+=[i]
    if i>=X:
      break
  i+=1

print(primelist[-1])


Measured memory_bytes: 3504
#include<stdio.h>
char str[2];
int main(){
	int a;
	scanf("%d",&a);
	bool ok=true;
	int now=0;
	for(int i=0;i<a;i++){
		int b;
		scanf("%s%d",str,&b);
		if(str[0]=='(')now+=b;
		else now-=b;
		if(now<0)ok=false;
	}
	if(ok&&now==0)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 1012
//divisor.cpp
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a, b, c;
  cin >> a >> b >> c;

  int count = 0;
  for (int i = 1 ; i <= c; i++) {
    if ((c%i == 0) && (a <= i) && (i <= b))
      count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
vector<int> v[100010]; 
int ok[100010];
char str[5];
int res=0,cnt=0;
int main()
{
	scanf("%d%d",&n,&m);
	fill(ok,ok+n,-1);
	for (int i=0;i<m;i++)
	{
		int x;
		scanf("%d%s",&x,&str);
		x--;
		if (str[0]=='A')
		{
			if (ok[x]==-1)
			{
				cnt++;
				ok[x]=v[x].size();
			}
			v[x].push_back(1);
		}
		else v[x].push_back(0);
	}
	for (int i=0;i<n;i++) if (ok[i]!=-1) res+=ok[i];
	printf("%d %d",cnt,res);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    cout << (a+b+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

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

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int h,w;
    cin>>h>>w;
    char x[h][w];
    forn(i,h)   forn(j,w)   cin>>x[i][j];
    
    int dx[4] = {-1,0,1,0};
    int dy[4] = {0,1,0,-1};
    
    
    forn(i,h){
        forn(j,w){
            if(x[i][j]=='#'){
                bool flag = false;
                forn(k,4){
                    int t = i + dx[k];
                    int s = j + dy[k];
                    if((t>=0 && t<h) && (s>=0 && s<w)){
                        if(x[t][s]=='#'){
                            flag = true;
                            break;
                        }
                    }
                }
                if(!flag){
                    cout<<"No\n";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}



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

using namespace std;

int main() {
	string a, b,c;
	int an, bn;
	cin >> a >> b>>an>>bn>>c;
	if (a == c)
		an--;
	if (b == c)
		bn--;
	cout << an << " " << bn << endl;
}

Measured memory_bytes: 384
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(string[] ss) {
    long[string] d;
    foreach (s; ss) {
        auto t = s.array;
        t.sort();
        d[t.to!string]++;
    }

    long ans = 0;
    foreach (_, v; d) {
        if (v > 1) ans += v * (v - 1) / 2;
    }
    return ans;
}

void main() {
    int n; scan(n);
    string[] ss;
    foreach (_; 0..n) ss ~= read!string;

    writeln(calc(ss));
}


Measured memory_bytes: 19196
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 500005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k,now,sum;
char c[N];
struct Huge{
		int A[N];
}A;
void Ins()
{
	 A.A[1]+=9; sum+=9; int i;
	 for (i=1;;++i)
	 {
	 		if (A.A[i]>=10)
			   A.A[i+1]++,A.A[i]-=10,sum-=9; 
			else break;
	 }
}
void cheng()
{
		for (i=1;i<=n;++i) A.A[i]*=9;
		for (i=1;i<=n;++i) A.A[i+1]+=A.A[i]/10,A.A[i]%=10;
}
int main()
{
		scanf("%s",c+1); n=strlen(c+1); 
		for (i=1;i<=n;++i) A.A[i]=c[n-i+1]-'0';
		cheng();
		for (i=1;i<N;++i) sum+=A.A[i];
		for (i=0;;++i)
		{
				if (sum<=9*i&&(9*i-sum)%9==0)
				{
						printf("%d\n",i);
						return 0; 
				}
				Ins();
		} 
}


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

int main () {
    string a;
    int c = 0;
    cin >> a;
    for (int i = 0;i < 3;++i) {
        if (a.at(i) == 'o') {
            c++;
        }
    }
    cout << 700 + 100 * c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,D;
	cin >> A >> B >> C >> D;
 
	if (A+B > C+D)
		cout << "Left" << endl;
	else if (A+B == C+D)
		cout << "Balanced" << endl;
	else
		cout << "Right" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b;
	int ans[100]={};
	int tmp;
	int i=0;
	while(scanf("%d", &a)!=EOF){
		scanf("%d", &b);
		if(b>a){
			tmp=b;
			b=a;
			a=tmp;
		}
		while(1){
			if(a-b==0){
				ans[i]=b;
				i++;
				break;
			}
			a-=b;
			if(b>a){
				tmp=b;
				b=a;
				a=tmp;
			}
		}
	}
	int n=i;
	for(i=0;i<n;i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m,k=map(int,input().split())
uf=UnionFind(n)
friends=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    friends[a-1]+=1
    friends[b-1]+=1
block=[[] for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d)
    block[d-1].append(c)
ans=[0]*n
cnt=[0]*n
for i in range(n):
    cnt[i]=uf.find(i)
for i in range(n):
    num1=uf.size[uf.find(i)]-friends[i]-1
    num2=cnt[i]
    for j in range(len(block[i])):
        if num2==cnt[block[i][j]-1]:
            num1-=1
    ans[i]=num1
print(*ans)


Measured memory_bytes: 36400
// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
using namespace std;
int n,m,a[101],sum,p,x;
int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n;
    for(register int i=1;i<=n;++i)cin>>a[i],sum+=a[i];
    cin>>m;
    for(register int i=1;i<=m;++i)cin>>p>>x,cout<<sum-a[p]+x<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

vector<int> a[200001];

int main() {
    ios_base::sync_with_stdio(false);
    int n, m, k, x, y;
    cin >> n >> m >> k;
    for(int i = 0; i < k; ++i) {
        cin >> x >> y;
        --x, --y;
        a[x].push_back(y);
    }
    for(int i = 0; i < n; ++i)
        sort(a[i].begin(), a[i].end());
    x = 0, y = 0;
    for(int i = 0; i < n; ++i) {
        ++x;
        if(!a[x].empty() && a[x][0] <= y) {
            cout << i + 1;
            return 0;
        }
        auto d = upper_bound(a[x].begin(), a[x].end(), y);
        if(d == a[x].end() || *d > y + 1)
            ++y;
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 11264
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        ArrayList<Character> lk_min = new ArrayList<Character>();
        ArrayList<Character> lk_over = new ArrayList<Character>();
        
        boolean reversed = false;
        
        int ope_n = Integer.parseInt(sc.next());
        
        int kind=0;
        String tmp="\0";
        char newl = '\0';
        for(int i=0; i<ope_n; i++){
            kind = Integer.parseInt(sc.next());
            if(kind==1){
                reversed=!reversed;
            }else{
                kind = Integer.parseInt(sc.next());
                tmp = sc.next();
                newl = tmp.charAt(0);
                if(kind==1){
                    if(reversed){
                        lk_over.add(newl);
                    }else{
                        lk_min.add(newl);
                    }
                }else{
                    if(reversed){
                        lk_min.add(newl);
                    }else{
                        lk_over.add(newl);
                    }
                }
            }
        }
        StringBuilder bld = new StringBuilder(s);
        for(int i=0; i < lk_over.size(); i++){
            bld.append(lk_over.get(i));
        }
        StringBuilder bld2 = bld.reverse();
        for(int i=0; i < lk_min.size(); i++){
            bld2.append(lk_min.get(i));
        }
        if(reversed) System.out.println(bld2.toString());
        else  System.out.println(bld2.reverse().toString());
    }
    
}

Measured memory_bytes: 94060
import sys
input = sys.stdin.readline

def main():
    s = list(sys.stdin.readline().rstrip())
    l = len(s)
    result = 0
    for i in range(l // 2):
         result += 1 if s[i] != s[l-1-i] else 0
    print(result)
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
S = input()
T = input()

cnt_min = len(T)
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[i+j]:
            cnt += 1
    cnt_min = min(cnt_min, cnt)

print(cnt_min)

Measured memory_bytes: 9112
#include <iostream>
#include <string>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(void)
{
  string step;
  bool easy = true;

  cin >> step;
  
  rep(i,step.size()){
    if((i+1)%2==0){
      //Even
      if((step[i]!='L')&&(step[i]!='U')&&(step[i]!='D')){
        easy=false;
        break;
      }
    }else{
      //Odd
      if((step[i]!='R')&&(step[i]!='U')&&(step[i]!='D')){
        easy=false;
        break;
      }
    }
  }

  if(easy) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
const ll INF = (1ll << 60);

map<ll, ll> mp;

bool isok(ll h, ll k, ll n, vector<tuple<double, ll, ll>> &tp)
{
    ll ans = 0;
    rep(i, n)
    {
        auto cura = (get<1>(tp[i]));
        auto curb = (get<2>(tp[i]));
        cerr << (cura) << " " << (k / curb) << endl;
        ans += (cura) * (k / curb);
        k -= curb * (k / curb);
        if (ans >= h)
        {
            break;
        }
    }
    cerr << ans << " " << k << endl;
    return ans >= h;
}

ll f(ll h, vector<ll> &a, vector<ll> &b)
{
    //cerr << h << endl;
    if (h <= 0)
    {
        return 0;
    }

    //cerr << "count " << h << endl;
    if (mp.count(h) == 1)
    {
        return mp[h];
    }
    //cerr << "done " << h << endl;

    ll ans = INF;
    rep(i, a.size())
    {
        rep(j, 1, 1 + (h + a[i] - 1) / a[i])
        {
            ll tmp = f(h - j * a[i], a, b) + j * b[i];
            ans = min(ans, tmp);
        }
    }
    //cerr << ans << endl;
    mp[h] = ans;
    return ans;
}

int main(int argc, char const *argv[])
{
    int H = 10010;
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);

    rep(i, n)
    {
        cin >> a[i] >> b[i];
    }
    vector<ll> dp(H + 1, INF);
    dp[0] = 0;
    rep(i, n)
    {
        auto next = dp;
        rep(j, H)
        {
            //  cerr << j << " " << a[i] << endl;

            if (j - a[i] < 0)
            {
                continue;
            }
            else
            {
                dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
            }
        }
        for (ll j = -1; j >= 0; j--)
        {
            if (dp[j] > dp[j + 1])
                dp[j] = dp[j + 1];
        }
        //rep(j, h + 1) cerr << dp[j] << " ";
        //cerr << endl;
        //dp = next;
    }
    ll ans = INF;
    for (int i = H; i >= h; i--)
    {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int A[3][10005];
int B[3][10005];

int main ()
{
	int n;
	cin >> n;
	
	for(int i = 0; i < 2; i++)
		for(int j = 0; j < n; j++)
			scanf("%d", &A[i][j]);
	
	B[0][0] = A[0][0];
	B[1][0] = A[0][0] + A[1][0];
	
	for(int i = 1; i < n; i++)
		B[0][i] = B[0][i - 1] + A[0][i];
	
	for(int i = 1; i < n; i++)
		B[1][i] = max(B[1][i - 1], B[0][i]) + A[1][i];
	
	cout << B[1][n - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;

int main() {
	ll cnt = 0;
	scanf("%lld %lld", &N, &K);
	ll prev = 0;
	ll dig = (ll)((log(N) / log(K)) + 1);
	printf("%lld", dig);
	return 0;
}
/*
	Powered by Buggy Plugin
*/



Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
bounded = True
for i in range(40, -1, -1):
    d = 1 << i
    cnt1 = sum(d & ai > 0 for ai in a)
    cnt0 = n - cnt1
    if bounded and k & d == 0 or cnt1 >= cnt0:
        ans += cnt1 * d
        if k & d > 0:
            bounded = False
    else:
        ans += cnt0 * d
print(ans)


Measured memory_bytes: 14700
#include<iostream>
using namespace std;
int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0){
			break;
		}
		for(int j=0;j<H;j++){
			for(int i=0;i<W;i++){
				cout<<"#";
			};
		cout<<endl;
	};
	cout<<endl;
}
	return 0;	
}



Measured memory_bytes: 3084