akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    auto N = in.read<int>();
    auto s = in.read<std::string>();

    for (auto&& c : s) {
        c = ((c - 'A') + N) % 26 + 'A';
    }
    out << s;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static int MOD = 1000000007;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();

		long power = 1;
		for (int i = 2; i <= N; i++) {
			power = power % MOD * i % MOD;
		}

		System.out.println(power);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23252
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    // long double a;
    ll a, b, c;
    sf(a, b, c);
    ll t = c - a - b;
    if (t <= 0) puts("No");
    else {
        ll aa = 4 * a * b;
        if (aa < t * t) {
            puts("Yes");
        }else {
            puts("No");
        }
    }
    return 0;
}

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

int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	if((a%3)==0 || (b%3)==0 || ((a+b)%3)==0)
		cout << "Possible" << endl;
	else 
		cout << "Impossible" << endl;
	
	return 0;
}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

#define mx 500005
int tree[4*mx];
string str;

void build(int node,int s, int e)
{
    if(s == e){
        tree[node] = (1 << (str[s-1]-'a'));
        return;
    }
    int left = node*2;
    int right = node*2+1;
    int mid = (s+e)/2;
    build(left, s, mid);
    build(right, mid+1, e);
    tree[node] = tree[left] | tree[right];
    return;
}

int query(int node, int s, int e, int l, int r)
{
    if(l > e || r < s){
        return 0;
    }
    if(l<=s && e<=r){
        return tree[node];
    }
    int left = node*2;
    int right = node*2+1;
    int mid = (s+e)/2;
    return query(left, s, mid, l, r) | query(right, mid+1, e, l, r);
}

void update(int node, int ind, char val,  int s, int e){
    if(s ==ind  && e == ind){
        tree[node] = (1 << (val-'a'));
        return;
    }
    if(ind < s || ind > e){
        return;
    }
    int left = node*2;
    int right = node*2+1;
    int mid = (s+e)/2;
    update(left, ind, val, s, mid);
    update(right, ind, val, mid+1, e);
    tree[node] = tree[left] | tree[right];
    return;
}

int main()
{
    //textIO();
    fastIO();

    long long n, q;
    cin >> n;
    cin >> str;
    build(1, 1, n);
    cin >> q;
    while(q--){
        long long qr, ind, l, r;
        char val;
        cin >> qr;
        if(qr == 1){
            cin >> ind >> val;
            update(1, ind, val, 1, n);
        }
        else{
            cin >> l >> r;
            cout << __builtin_popcount(query(1, 1, n, l, r)) << '\n';
        }
    }
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int zero_count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0')
            zero_count++;
    }
    int one_count = s.size() - zero_count;
    cout << 2 * min(zero_count, one_count);
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			long sum = 0;
			for(int i=1;i*i<=n;i++) {
				if (i * i == n) {
					sum += i;
					break;
				}
				if (n % i == 0) {
					sum += i + n / i;
				}
			}
			sum -= n;
			if (n == sum) {
				System.out.println("perfect number");
			}else if(n > sum) {
				System.out.println("deficient number");
			}else{
				System.out.println("abundant number");
			}
		}
	}

}

Measured memory_bytes: 19952
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n;cin>>n;
    vint l(n); rep(i,n)cin>>l[i];
    int m = 0, s = 0;
    rep(i,n){
        s += l[i];
        m = max(m,l[i]);
    }
    cout<<((m<s-m)?"Yes":"No")<<endl; return 0;
}


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

void Main() {
    int n;
    double x, ans = 0;
    string u;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}

Measured memory_bytes: 256
a,b,c=(int(x) for x in input().split())
l=[]
for i in range(1,int(c**0.5)+1):
  if c%i==0:
    l.append(i)
    if i!=c//i:
      l.append(c//i)
count=0
for j in range(len(l)):
  if a<=l[j]<=b:
    count+=1
print(count)


Measured memory_bytes: 5644
fn main() {
    proconio::input! {
    a:usize,
    b:usize,
    c:[usize;a],
    }
    let mut d=0;
    for i in 0..a {
        d+=std::cmp::min(c[i],b-c[i])
    }
    println!("{}",d*2)
}

Measured memory_bytes: 2092
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int v, e;
    cin >> v >> e;

    vector<vector<int>> edge(v, vector<int>(v, INF));
    rep(i, e){
        int s, t, d;
        cin >> s >> t >> d;
        edge[s][t] = d;
    }

    vector<vector<int>> cost(1 << v, vector<int>(v, INF));
    vector<vector<int>> path(1 << v, vector<int>(v));
    rep(i, v){
        cost[0][i] = 0;
    }
    for(int s = 0; s < (1 << v); s++){
        rep(i, v){
            if(s != 0 && (s >> i) % 2 == 0){
                continue;
            }
            rep(j, v){
                if((s >> j) % 2 == 1 || edge[i][j] == INF){
                    continue;
                }
                if(cost[s | (1 << j)][j] > cost[s][i] + edge[i][j]){
                    cost[s | (1 << j)][j] = cost[s][i] + edge[i][j];
                    path[s | (1 << j)][j] = i;
                }
            }
        }
    }

    /*
    rep(i, (1 << v)){
        cout << bitset<7>(i) << " ";
        rep(j, v){
            cout << cost[i][j] << " ";
        }
        cout << endl;
    }
    */

    /*
    int ans = INF;
    rep(i, v){
        int last;
        if(ans > cost[(1 << v)-1][i] && cost[(1 << v)-1][i] != INF){
            last = i;
        }

        if(cost[(1 << v)-1][i] == INF){
            continue;
        }
        int s = (1 << v) - 1;
        int first = i;
        for(int j = 0; j < v - 1; j++){
            int from = path[s][first];
            s ^= 1 << first;
            first = from;
        }
        if(ans > cost[(1 << v)-1][i] + edge[last][first]){
            ans = cost[(1 << v)-1][i] + edge[last][first];
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    */
    int ans = 0;
    rep(i, v){
        if(ans < cost[(1 << v) - 1][i]){
            ans = cost[(1 << v) - 1][i];
        }
    }
    if(ans == INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 12592
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  300005

ll cost[100000];

void initialize(ll n)
{
    for(ll i=0;i<n;i++)
    {
        cost[i]=-1;
    }
}

ll cost_min(ll a[],ll p)
{
    if(cost[p]==-1)
    {
        if(p==0){cost[p]=0;}
        else if(p==1){cost[p]=abs(a[p]-a[p-1]);}
        else{cost[p] =min( cost_min(a,p-1)+abs(a[p]-a[p-1]),cost_min(a,p-2)+abs(a[p]-a[p-2]));}
        return cost[p];
    }
    else
    {
        return cost[p];
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    initialize(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cout<< cost_min(a,n-1);


    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const int intinf = 1 << 30;
const long long mod = 1e9 + 7;

int n;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end())
            cout << " ";
    }
    cout << endl;
};

void CountingSort(vector<int> A, vector<int> &B, int M) {
    vector<int> C(M + 1, 0);

    for(int i = 0; i < n; i++) {
        C[A[i]]++;
    }

    rep(i, 1, M + 1) C[i] += C[i - 1];

    for(int j = n - 1; j >= 0; j--) {
        B[C[A[j]] - 1] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int M = -1;
    cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    rep(i, n) {
        cin >> A[i];
        M = max(A[i], M);
    }

    CountingSort(A, B, M);

    vecout(B);
}



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

using namespace std;
using ll = long long;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> s(M);
	for (int i = 0; i < M; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int S;
			cin >> S;
			s[i].push_back(S - 1);
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) { cin >> p[i]; }

	int res = 0;
	for (int i = 0; i < (1<<N); ++i) {
		vector<int> on(N, 0);
		for (int j = 0; j < N; ++j) {
			if ((i>>j) & 1) { on[j] = 1; }
		}

		int cnt = 0;
		for (int j = 0; j < M; ++j) {
			int cnt2 = 0;
			for (int k = 0; k < s[j].size(); ++k) {
				if (on[s[j][k]] == 1) { cnt2 += 1; }
			}
			if (cnt2 % 2 == p[j]) { cnt += 1; }
		}

		if (cnt == M) { ++res; }
	}

	cout << res << endl;

	return 0;
}


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

int insertionSort(int *a, int n, int g){
	int cnt = 0, i, j, key;

	for(i = g; i < n; i++){
		key = a[i];
		j = i - g;
		while( j >= 0 && a[j] > key){
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = key;
	}

	return cnt;
}

 int shellSort(int *a, int n){
 	int cnt = 0;
 	int h = 1, m = 1, i;
 	int G[1000];

 	G[0] = 1;
 	i = 1;
 	while(h < n / 3){
		h = 3 * h + 1;
		G[i] = h;
		i++;
		m++;
 	}
 	printf("%d\n", m);

 	//G[] output
 	for(i = m - 1; i >= 0; i--){
 		printf("%d", G[i]);
 		(i != 0) ? printf(" ") : printf("\n");
 	}

 	for(i = m-1; i >= 0; i--)
 		cnt += insertionSort(a, n, G[i]);
 	
 	return cnt;
}


int main(){
	int n, i, cnt = 0;
	int *a;

	scanf("%d", &n);
	a = (int*)calloc(n, sizeof(int));
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	cnt = shellSort(a, n);
	printf("%d\n", cnt);

	for(i = 0; i < n; i++)
		(i != n-1) ? printf("%d\n", a[i]): printf("%d", a[i]);

	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long

int main(void)
{
	int n;
	cin >> n;
	vec<ll> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	sort(a.begin(), a.end());

	ll ans = 0;
	rep(i, n) ans += a[3 * n - 2 * i - 2];
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){

	int r,c;

	while(cin>>r>>c,r||c){
		if((r*c)%2){
			cout<<"no"<<endl;
		}
		else{
			cout<<"yes"<<endl;
		}
	}
}

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

#define BUF_SIZE 100100

char* strmap[] = {
  "dream",
  "dreamer",
  "eraser",
  "erase",
};

int main(void) {
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  char *tmp;
  int len = 0;
  for(tmp = line; *tmp != '\n'; tmp++, len++) ;
  int i, j;

  int flag = 1;
  for(i = len-1; i >= 0;) {
    int step = 0;
    int size = sizeof(strmap)/sizeof(char*);
    for(j = 0; j < size; j++) {
      int len = strlen(strmap[j]);
      if(i-len+1>=0 && !strncmp(&line[i-len+1], strmap[j], len)) {
        step = len;
        break;
      }
    }
    if(!step) {
      flag = 0; break;
    }
    i -= step;
  }
  printf("%s\n", flag ? "YES" : "NO");

  return 0;
}

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


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

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

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
















int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    while(n > 0){
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using namespace __gnu_pbds; 
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif






 
int main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    IOS;
    
   string s, t;

   cin>>s>>t;

   int n =s.size(), ans= 0;

   for(int i=0; i<n; i++)
   {
     if(s[i]!=t[i])ans++;
   }

   cout<<ans<<endl;
   
   
}

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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0)
        cout<<min(b,c)<<endl;
    else
        cout<<min(b/a,c)<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int g[13] = { -1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 };

int main(int argc, char **argv) {
	int x, y;
	cin >> x >> y;
	cout << (g[x] == g[y] ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  long long answer = 0, sum_a = 0, sum_b = 0;
  vector<pair<int, int>> all(n << 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    answer += a[i] + b[i];
    sum_a += a[i];
    sum_b += b[i];
    all[i << 1] = make_pair(a[i], i);
    all[i << 1 | 1] = make_pair(b[i], i);
  }
  long long result = max(sum_a, sum_b);
  sort(all.begin(), all.end(), greater<pair<int, int>> ());
  vector<bool> visit(n);
  bool already = false;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    if (visit[all[i].second]) {
      already = true;
    }
    sum += all[i].first;
    visit[all[i].second] = true;
  }
  if (already) {
    result = max(result, sum);
  } else {
    for (int i = n; i < n << 1; ++i) {
      if (all[n - 1].second == all[i].second) {
        result = max(result, sum + all[i].first - all[n - 2].first);
      } else {
        result = max(result, sum + all[i].first - all[n - 1].first);
      }
    }
  }
  cout << answer - result << endl;
  return 0;
}

Measured memory_bytes: 5624
# ABC141E - Who Says a Pun?
def main():
    N = int(input())
    S = input().rstrip()
    ok, ng = 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg, checked = 0, set()
        for i in range(N - 2 * mid + 1):
            checked.add(S[i : i + mid])
            if S[i + mid : i + 2 * mid] in checked:
                flg = 1
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter
    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    main()

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll X; cin >> X;
    ll target = 100;
    ll res = 0;
    while (X > target)
    {
        target *= 1.01;
        target = floor(target);
        res++;
    }
    cout << res << endl;
    return 0;
}


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

int a[3010],b[3010],dp[2][3010],mm1[3010][2],mm2[3010][2];
int main(){
	int N,T,S,I,O,hog,hma,res;
	cin>>N>>T>>S;
	for(int i=1;i<=N;i++){
		cin>>a[i]>>b[i];
	}
	memset(dp[0],-1,sizeof(dp[0]));
	I=0;O=1;
	dp[0][0]=0;
	for(int i=1;i<=N;i++){
		memset(dp[O],-1,sizeof(dp[O]));
		hma=-1;
		for(int j=0;j<=S;j++){
			hog=dp[I][j];
			if(j>=b[i]&&dp[I][j-b[i]]!=-1)hog=max(hog,dp[I][j-b[i]]+a[i]);
			dp[O][j]=hog;
			hma=max(hma,hog);
		}
		mm1[i][0]=hma;
		hog=dp[I][S+1];
		if(S+1>=b[i]&&dp[I][S+1-b[i]]!=-1)hog=max(hog,dp[I][S+1-b[i]]+a[i]);
		dp[O][S+1]=hog;
		mm1[i][1]=max(hma,hog);
		swap(I,O);
	}
	memset(dp[I],-1,sizeof(dp[I]));
	dp[I][0]=0;
	for(int i=N;i>=1;i--){
		memset(dp[O],-1,sizeof(dp[O]));
		hma=-1;
		for(int j=0;j<=T-S;j++){
			hog=dp[I][j];
			if(j>=b[i]&&dp[I][j-b[i]]!=-1)hog=max(hog,dp[I][j-b[i]]+a[i]);
			dp[O][j]=hog;
			hma=max(hma,hog);
		}
		mm2[i][1]=hma;
		hog=dp[I][T-S+1];
		if(T-S+1>=b[i]&&dp[I][T-S+1-b[i]]!=-1)hog=max(hog,dp[I][T-S+1-b[i]]+a[i]);
		dp[O][T-S+1]=hog;
		mm2[i][0]=max(hma,hog);
		swap(I,O);
	}
	res=0;
	mm1[0][0]=mm1[0][1]=mm2[N+1][0]=mm2[N+1][1]=0;
	for(int i=0;i<=N;i++){
		//cout<<i<<" "<<j<<" "<<mm1[i][j]<<" "<<mm2[i+1][j]<<endl;
		res=max(mm1[i][0]+mm2[i+1][1],res);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1260
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    vector<string> dp(26);
    for(int i = 0; i < 26; i++){
        dp[i] = (char)('a' + i);
    }

    for(int i = 0; i < str.size(); i++){
        for(int j = 0; j < 26; j++){
            if((char)('a'+j) == str[i]){
                string tmp = dp[j];
                for(int k = 0; k < 26; k++){
                    if(k == j){
                        dp[j] += (char)('a' + j);
                        continue;
                    }
                    if(dp[k].size() > tmp.size()+1 || (dp[k].size() == tmp.size()+1 && dp[k] > tmp+(char)('a'+k))){
                        dp[k] = tmp + (char)('a' + k);
                    }
                }
            }
        }
    }

    string ans = dp[0];
    for(int i = 1; i < 26; i++){
        if(dp[i].size() < ans.size() || (dp[i].size() == ans.size() && dp[i] < ans)){
            ans = dp[i];
        }
    }

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

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

using namespace std;

void solve();

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

void solve() {
    int N,M,K;
    cin >> N >> M >> K;
    bool ok = false;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= M; j++) {
            int k = i * (M - j) + j * (N - i) ;
            if(k == K) {
                ok = true;
                i = N+1;
                break;
            }

        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
vector<ll> adj[N];
ll ans;
bool dfs(ll u,ll pr){
    ll bad=0,child=0;
    for(auto &v:adj[u]){
        if(v==pr)continue;
        if(!dfs(v,u))bad++;
        child++;
    }
    ans+=max(0ll , bad-1);
    if(child>1)return 1;
    if(child==1)return 1 - bad;
    return 0;
}
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    for(ll i=0,u,v;i<n-1;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);
    ll root=0;for(ll i=0;i<n;i++)if(adj[i].size()>2)root=i;
    if(adj[root].size()<=2)return cout<<"1" , 0;
    dfs(root,root);
    cout<<max(1ll,ans);
}

Measured memory_bytes: 9472
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
  long long int x[200000],xx,sum[200000],ans,b,n;
  scanf("%lld %lld",&n,&xx);
  for(int i=0;i<n;i++)
    scanf("%lld ",&x[i]);
 sum[0]=x[0];
  for(int i=1;i<n;i++)
    sum[i]=sum[i-1]+x[i];
  ans=n*xx+sum[n-1]*5;
  for(long long int i=1;i<=n;i++){
    b=(i)*xx;
    for(long long int j=0;j<n;j+=i){
      if(j==0&&n-1-i>=0)
        b+=5*(sum[n-1-j]-sum[n-j-1-i]);
      else if(j==0)
        b+=5*sum[n-1-j];
      else if(n-j-1-i>=0)
        b+=(2*(j/i+1)+1)*(sum[n-1-j]-sum[n-j-1-i]);
      else
        b+=(2*(j/i+1)+1)*(sum[n-1-j]);
    }
    if(b>0)
      ans=min(ans,b);
  }
  printf("%lld\n",ans+n*xx);
}


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

static const int N = 100;

int main(){
    int n;
    vector<int> p(N+1);
    vector<vector<int>> m(N+1, vector<int>(N+1, 0));
    cin >> n;

    for(int i = 1; i <= n; i++){
        cin >> p.at(i - 1) >> p.at(i);
    }
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m.at(i).at(j) = (1 << 21);
            for(int k = i; k <= j - 1; k++){
                m.at(i).at(j) = min(m.at(i).at(j), m.at(i).at(k) + m.at(k + 1).at(j) + p.at(i - 1) * p.at(k) * p.at(j));
            }
        }
    }
    cout << m.at(1).at(n) << endl;


}




Measured memory_bytes: 3208
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun isAppropriate(n: Int): Boolean
    = n.toString().toMutableList().distinct().size == 1

fun main(args: Array<String>) {
    val n = readInt()
    var next = n
    while(!isAppropriate(next)) {
        next++
    }
    println(next)

    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) = pw.print(value)
fun println(value : Any) = pw.println(value)

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
    }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    return v.map { it.toList() }.toList()
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 33784
'use strict';
class Queue {
  constructor(size) {
    this.arr = new Array(size);
    this.head = this.tail = 0;
  }

  is_full() {
    return this.head == (this.tail + 1) % this.arr.length;
  }

  push(v) {
    if (this.is_full()) {
      this.arr.length *= 2;
    }
    this.arr[this.tail] = v;
    this.tail = (this.tail + 1) % this.arr.length;
  }

  is_empty() {
    return this.head == this.tail;
  }

  pop() {
    if (this.is_empty()) {
      throw -1;
    }
    let v = this.arr[this.head];
    this.head = (this.head + 1) % this.arr.length;
    return v;
  }

  maxsize() {
    return this.arr.length;
  }
}

function main(input) {
  let lines = input.split('\n')
  let v = lines[0].split(' ').map((n) => parseInt(n));
  let h = v[0];
  let w = v[1];
  let c = [];
  let d = [];
  for (let i = 1; i < h + 1; i++) {
    c.push(lines[i]);
    d.push([]);
  }
  let q = new Queue(1000000000);
  for (let i = 0; i < h; i++) {
    for (let j = 0; j < w; j++) {
      if (c[i][j] == '#') {
        q.push([i, j]);
        d[i][j] = 0;
      } else {
        d[i][j] = -1;
      }
    }
  }
  let p = q.pop();
  let max = 0;
  const dx = [1, 0, -1, 0];
  const dy = [0, 1, 0, -1];
  while (true) {
    const xx = p[0];
    const yy = p[1];
    for (let i =0; i < 4; i++) {
      let x = xx + dx[i];
      let y = yy + dy[i];
      if (x < 0 || x > h - 1 || y < 0 || w - 1 < y || d[x][y] >= 0) {
        continue;
      }
      if (c[x][y] == '.') {
        q.push([x, y]);
        let count = d[xx][yy] + 1;
        if (max < count) {
          max = count;
        }
        d[x][y] = count;
      }
    }
    if (q.is_empty()) {
      break;
    }
    p = q.pop();
  }
  console.log(max);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
  int N, K;
  int sumD = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x < (K-x)) {
      sumD += 2 * x;
    } else {
      sumD += 2 * (K-x);
    }
  }
  
  cout << sumD << endl;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  string s;
  cin >> s;

  for (auto x: s) {
    if (x == '?') cout << "D";
    else cout << x;
  }
  cout << '\n';
}

Measured memory_bytes: 3772
A = input()
B = input()
C = input()

win = ''
turn = 'A'
while win=='':
	if turn=='A':
		if A=='':
			win = 'A'
		turn = A[:1].upper()
		A = A[1:]
	if turn=='B':
		if B=='':
			win = 'B'
		turn = B[:1].upper()
		B = B[1:]
	if turn=='C':
		if C=='':
			win = 'C'
		turn = C[:1].upper()
		C = C[1:]

print(win)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, X, Y;
	cin >> N >> X >> Y;

	vector<int> ans(N);

	X--; Y--;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int d = j-i;
			d = min(d, 1+abs(X-i)+abs(Y-j));
			d = min(d, 1+abs(X-j)+abs(Y-i));
			ans[d]++;
			debug(i, j, d);
		}
	}

	for(int k=1; k<N; k++) cout << ans[k] << endl;

	return 0;
}


Measured memory_bytes: 256
def digit_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


N = int(input())

t = float('inf')
for a in range(1, N // 2 + 1):
    b = N - a
    t = min(t, digit_sum(a) + digit_sum(b))
print(t)


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll n=s.size();
    if(s[0]=='0'||s[n-1]=='1'){
        cout << -1 << endl;
        return 0;
    }
    vl v;
    rep(i,n-1){
        if(s[i]!=s[n-2-i]){
            cout << -1 << endl;
            return 0;
        }
        if(s[i]=='1'){
            v.pb(i+1);
        }
    }
    string t;
    ll nowj=0;
    rep(i,(ll)v.size()-1){
        cout << v[i] << ' ' << v[i+1] << '\n';
    }
    FOR(i,1,n+1){
        if(v[nowj]==i){
            nowj++;
            continue;
        }
        if(i>v[v.size()-1]){
            cout << v[v.size()-1] << ' ' << i << '\n';
            continue;
        }
        cout << i << ' ' << v[nowj] << '\n';
    }
}

Measured memory_bytes: 4380
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int MaxN = 200;
bool g[MaxN][MaxN]; int n;

int dis[MaxN], ans; queue<int> q;
bool noSolution = false;
void bfs(int from){
	for(int i=0; i<n; ++i)
		dis[i] = 0;
	dis[from] = 1; q.push(from);
	while(not q.empty()){
		int t = q.front(); q.pop();
		ans = max(ans,dis[t]);
		for(int i=0; i<n; ++i){
			if(not g[t][i])
				continue;
			if(not dis[i]){
				dis[i] = dis[t]+1;
				q.push(i);
				continue;
			}
			if(dis[i] < dis[t])
				continue;
			if((dis[i]+dis[t]+1)&1){
				noSolution = true;
				return ;
			}
		}
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; ++i){
		getchar();
		for(int j=0; j<n; ++j)
			g[i][j] = (getchar() == '1');
	}
	for(int i=0; i<n; ++i){
		bfs(i);
		if(noSolution){
			puts("-1"); return 0;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import math

x,k,d = map(int,input().split())

abs_x = abs(x)

max_len = math.ceil(abs_x/d)*d
min_len = max_len-d

if abs_x-k*d >= 0:
    print(abs_x-k*d)
    exit()

if (math.ceil(abs_x/d)-1)%2 == k%2:
    print(abs(abs_x-min_len))
else:
    print(abs(abs_x-max_len))

Measured memory_bytes: 9216
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

signed main() {
	IOS();
	ll n, q;
	string s;
	cin >> n >> q >> s;
	vector<ll> a(n + 1);
	a[0] = a[1] = 0;
	for (int i = 1; i < n; i++) {
		if (s[i] == 'C' && s[i - 1] == 'A') {
			a[i + 1] = a[i] + 1;
		} else {
			a[i + 1] = a[i];
		}
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;

		dump(a[r] - a[l]);
	}
	return 0;
}

Measured memory_bytes: 1872
#include<stdio.h>
#define MAX 500001 /*500000*/
#define INF 10000000

void merge(int A[],int left,int mid,int right,int *cnt){
int i,j,n1,n2;
int L[MAX];
int R[MAX];
int k;
n1=mid-left;
n2=right-mid;

for(i=0;i<n1;i++)L[i]=A[left+i];
for(i=0;i<n2;i++)R[i]=A[mid+i];

L[n1]=2147483647;
R[n2]=2147483647;

i=0;
j=0;

for(k=left;k<right;k++){
  if(L[i]<=R[j]){(*cnt)++;
    A[k]=L[i];
    i++;
  }
  else{(*cnt)++;
    A[k]=R[j];
    j++;
  }
}


return;
}



void mergesort(int A[],int left,int right,int *cnt){
int mid;
 if(left+1 < right){
   mid=(left+right)/2;
   mergesort(A,left,mid,cnt);
   mergesort(A,mid,right,cnt);
   merge(A,left,mid,right,cnt);
 }

return;
}



int main(){
int n,i;
int A[MAX];
int cnt=0;

scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&A[i]);

mergesort(A,0,n,&cnt);

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

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

return 0;
}


Measured memory_bytes: 5624
from sys import stdin

n = int(stdin.readline().rstrip())
def counter(n):
    point = 0
    s = str(n)
    keta = len(s)
    if keta == 1:
        return 0
    if n%2 == 1:
        return 0
    else:
        i = 1
        while True:
            point += n//(2*5**i)
            i += 1
            if n//(2*5**i) == 0:
                break
        return point
print(counter(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    cout<<a[0]<<a[1]<<a[2]<<a[3]<<' '<<a[4]<<a[5]<<a[6]<<a[7]<<a[8]<<a[9]<<a[10]<<a[11]<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int numN = int.Parse(Console.ReadLine());

            String s = Console.ReadLine();

            String[] strInputList = s.Split();
            var List = new List<int>();

            for (int i = 0; i < numN; i++)
            {
                String n = strInputList[i];
                int a = int.Parse(n);
                List.Add(a);
            }

            int min = List[0];

            for (int i = 1; i < List.Count; i++)
            {           
                int next = List[i];

                if (next < min)
                {
                    min = next;
                }
            }

            int max = List[0];
            for(int i = 1; i < List.Count; i++)
            {
                int next = List[i];
                if (max < next)
                {
                    max = next;
                }
            }

            long sum = 0;

            for (int i = 0; i < List.Count; i++)
            {
                sum = sum + List[i];
            }

            Console.WriteLine(min + " " + max + " " + sum);
        }
    }
}


Measured memory_bytes: 18272
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n; ++i) {
		for (int j = i; j < n; ++j) {
			string tmp = s.substr(0, i) + s.substr(j);
			if (tmp == "keyence") {
				printf("%s\n", "YES");
				return 0;
			}
		}
	}
	printf("%s\n", "NO");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long int a,b,A1,B1,A2,B2;
	int i;
	while(scanf("%lld %lld",&a,&b)!=EOF){
	A1=a;A2=a;B1=b;B2=b;
	
	for(;;){
	if(A1<B1){B1=B1-A1;}else if(A1>B1){A1=A1-B1;}//?????§??¬?´???°
	if(A2<B2){A2=A2+a;}else if(A2>B2){B2=B2+b;}//????°???¬?????°
		if(A1==B1&&A2==B2){break;}
	}
	
	printf("%lld %lld\n",A1,A2);
	}
	
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll yen500 = n/500;
  yen500*=1000;
  n%=500;
  ll yen5 = n/5;
  yen5*=5;
  cout << yen5 + yen500;
}

Measured memory_bytes: 256