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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m;
vector<array<int, 4>> in;
vector<pair<int, int>> e[500000];
int dist[500000];

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int  ep = e.FI;
			Cost ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		
		int ep = n + 2 * i + 0;
		int eq = n + 2 * i + 1;
		in.PB({ p, c, ep, eq });
		in.PB({ q, c, eq, ep });
	}
	sort(ALL(in));
	
	inc(i, in.size()) {
		int  p = in[i][0];
		int ep = in[i][2];
		int eq = in[i][3];
		e[ep].PB({ eq, 0 });
		e[ep].PB({  p, 1 });
		e[ p].PB({ ep, 1 });
	}
	
	int k = in.size() - 1;
	inc(i, k) {
		if(in[i][0] == in[i + 1][0] && in[i][1] == in[i + 1][1]) {
			int ep0 = in[i + 0][2];
			int ep1 = in[i + 1][2];
			e[ep0].PB({ ep1, 0 });
			e[ep1].PB({ ep0, 0 });
		}
	}
	
	int INF = n + 2 * m + 1;
	inc(i, n + m * 2) { dist[i] = INF; }
	dijkstra<int>(0, e, dist);
	
	cout << (dist[n - 1] == INF ? -1 : dist[n - 1] / 2) << endl;
	
	return 0;
}


Measured memory_bytes: 50152
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	ll N, K, S;
	cin >> N >> K >> S;
	ll dummy = S+1;
	if (S == 1000000000)
	{
		dummy = 1;
	}
	rep(i, N)
	{
		if (K > 0)
		{
			cout << S << " ";
			K--;
		}
		else
		{
			cout << dummy << " ";
		}
	}
	cout << endl;
	return 0;
}


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

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

    int count = 0;

    for (int i=0; i<=A; i++){
        for (int j=0; j<=B; j++){
            for (int k=0; k<=C; k++){
                if ((500 * i + 100 * j + 50 * k) == X){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char S[4];
	scanf("%s", S);
	if (S[0] == S[1]) {
		if(S[0] != S[2] && S[2] == S[3]) printf("Yes\n");
		else printf("No\n");
	} else if (S[0] == S[2]) {
		if(S[0] != S[1] && S[1] == S[3]) printf("Yes\n");
		else printf("No\n");
	} else if (S[0] == S[3]) {
		if(S[0] != S[1] && S[1] == S[2]) printf("Yes\n");
		else printf("No\n");
	} else printf("No\n");
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
#define MOD 1000000007
const int INF = 1e9;
const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}
ll spow(ll base, ll exp){
	ll ans = 1;
	for(ll i=0;i<exp;i++) ans = ans * base % MOD;
	return ans;
}
ll divide(ll a, ll b){
	return a * spow(b, MOD-2) % MOD;
}
void solve(){
	int a, b;
	cin >> a >> b;
	
}

int main(){
	load;
	string a, b;
	cin >> a >> b;
	int sum = 0;
	fori(i,a.size()){
		if (a[i] !=  b[i]) sum++;
	}
	cout << sum;
	
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

unsigned int xor128() {
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t;
    t = x ^ (x << 11);
    x = y; y = z; z = w;
    return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
}

void simulated_annealing() {

    auto begin_time = chrono::steady_clock::now();
    auto cur_time = begin_time;
    ll time_elapsed = 0;
    const ll DURATION = 1000;

    double temperature = 1;

    ll best_score = 0;
    ll cur_score = 0;

    int iter = 0;

    while (true) {
        // check the time and update the temperature
        if (iter % 100 == 0) {
            cur_time = chrono::steady_clock::now();
            time_elapsed = chrono::duration_cast<chrono::milliseconds>(cur_time - begin_time).count();
            if (time_elapsed > DURATION) break;
            temperature = (double) (DURATION - time_elapsed) / DURATION;
        }

        // get a neighbor

        // calculate the neighbor's score

        // if the score improved or force_next is true, set the neighbor as the current node
        const ll R = 10000;
        const bool force_next = temperature > (double) (xor128() % R) / R;

        // save the best state
        if (cur_score > best_score) {
            best_score = cur_score;
            // save the best node
        }

        for (int i = 0; i < 1e6; i++);

        iter++;
    }

    cerr << "Time elapsed: " << time_elapsed << endl;
    cerr << "Iterations: " << iter << endl;
}

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

    int D;
    cin >> D;
    vector<int> c(26);
    REP(i, 26) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    REP(i, D) REP(j, 26) cin >> s[i][j];

    vector<int> last(26, -1);

    for (int d = 0; d < D; d++) {
        int best_i = 0, score = 0;
        for (int i = 0; i < 26; i++) {
            int nscore = s[d][i] + (d - last[i]) * c[i] * 5;
            if (nscore > score) {
                best_i = i;
                score = nscore;
            }
        }
        last[best_i] = d;
        cout << best_i + 1 << endl;
    }
    // simulated_annealing();
}

Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        while(i+1 < n && a[i] == a[i+1]){
            i++;
        }
        if(i+1 < n && a[i] < a[i+1]){
            while(i+1 < n && a[i] <= a[i+1]){
                i++;
            }
        }else if(i+1 < n && a[i] > a[i+1]){
            while(i+1 < n && a[i] >= a[i+1]){
                i++;
            }
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    char s[25];
   scanf("%s",s);
    for(int i=0;s[i]!='\0';++i)
    {
        if(s[i]==',')
            s[i]=' ';
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 384
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    int N;
    set<long long> s;
    cin >> N;
    for (int i = 0; i < N; i++){
        int A;
        cin >> A;
        if (s.count(A)) {
            cout << "NO";
            return;
        }
        else s.insert(A);
    }
    cout << "YES";
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 9600
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        ans = 0
        for i in range(1, N):
            if S[i] != S[i - 1]:
                ans += 1

        print(ans + 1)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 39280
import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [float("inf"), 2, 5, 5, 4, 5, 6, 3, 7, 6]
mincost = min(cost)

dp = [None] * (n + 1)
def dfs(at):
    if at < 0:
        return -1
    if at == 0:
        return 0
    if dp[at] is not None:
        return dp[at]
    r = max(dfs(at - cost[v]) * 10 + v for v in a)
    dp[at] = r
    return r


print(dfs(n))


Measured memory_bytes: 21620
#include <iostream>
#include <cmath>

using namespace std;

double get2pDist(double, double, double, double);
double getplDist(double, double, double, double, double, double);
double getTriangle(double, double, double, double, double, double);

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		double S = getTriangle(x1, y1, x2, y2, x3, y3);
		double s =
			getTriangle(x1, y1, x2, y2, xp, yp)
			+ getTriangle(x2, y2, x3, y3, xp, yp)
			+ getTriangle(x3, y3, x1, y1, xp, yp);
		abs(S - s) == 0 ? cout << "YES" << endl : cout << "NO" << endl;
	}
	return 0;
}

double get2pDist(double x1, double y1, double x2, double y2){
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));	
}

double getplDist(double x, double y, double x1, double y1, double x2, double y2){
	double a, b, c;
	a = y1 - y2;
	b = x2 - x1;
	c = x1 * y2 - x2 * y1;
	return abs(a * x + b * y + c) / sqrt(a * a + b * b);
}

double getTriangle(double x1, double y1, double x2, double y2, double x3, double y3){
	return (get2pDist(x1, y1, x2, y2)
	 * getplDist(x3, y3, x1, y1, x2, y2)) / 2;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
  int n,c=0;cin>>n;
  vi a,b;
  int m=n+1;
  if(n%2)m--;
  REP(i,1,n){
    REP(j,i+1,n+1){
      if(i+j!=m){
        c++;
        a.pb(i);b.pb(j);
      }
    }
  }
  cout<<c<<endl;
  rep(i,c)
    cout<<a.at(i)<<' '<<b.at(i)<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int A, B, M, a[100005], b[100005], x, y, c;
	int ans, ma = 200000, mb = 200000;
	cin >> A >> B >> M;
	for (int i = 0; i < A; i++)
	{
		cin >> a[i];
		ma = min(ma, a[i]);
	}
	for (int i = 0; i < B; i++)
	{
		cin >> b[i];
		mb = min(mb, b[i]);
	}
	ans = ma + mb;
	for (int i = 0; i < M; i++)
	{
		cin >> x >> y >> c;
		ans = min(ans, a[x-1] + b[y-1] - c);
	}

	cout << ans << endl;



		 
	return 0;
}

Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
 
using namespace std;
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define forab(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second
 
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<pii>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"
 
int n;
vi a, b;
 
bool read() {
    if (!(cin >> n)) {
        return 0;
    }

    a = b = vi(n);
    forn (i, n)
        cin >> a[i];
    forn (i, n)
        cin >> b[i];

    return 1;
}

int bit (int mask, int i)
{
    return ((mask >> i) & 1);
}
int pref (int mask, int len)
{
    return mask & ((1 << len) - 1);
}
 
void solve() {
    vi cur_a(n), cur_b(n);
    const int bits = 28;

    int ans = 0;

    forn (i, bits)
    {
        vi cnt(2);
        forn (it, 2)
        {
            vi &to = (it == 0 ? cur_a : cur_b);
            const vi &from = (it == 0 ? a : b);
            transform(all(from), to.begin(), [&] (int mask) {return pref(mask, i + 1);});
            sort(all(to));
            for (int x : from)
                cnt[it] ^= bit(x, i);
        }

        int sum = (cnt[0] * (n - cnt[1]) + cnt[1] * (n - cnt[0]));
        if (sum % 2)
            ans ^= (1 << i);

        int ptr = n - 1;
        const int bound = (1 << (i + 1));
        int par = 0;

        forn (i, n) 
        {
            while (ptr >= 0 && cur_b[ptr] + cur_a[i] >= bound)
                ptr--;

            par ^= (n - 1 - ptr) % 2;
        }

        if (par)
            ans ^= (1 << (i + 1));
    }

    cout << ans << endl;
}
 
int main() {
#ifdef LOCAL
    freopen(FILE_NAME ".in", "r", stdin);
//    freopen(FILE_NAME ".out", "w", stdout);
#endif

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
 
    while (read()) {
        solve();
    }
 
    return 0;
}


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

int n;
vector<vector<P>> v;

bool judge(int bit){//決め打ちで判断
    //検証
    for(int i = 0;i <n; i++){
        if(!(bit & (1<<i)))continue;//bitにフラグが立っていない時
        
        for(P xy : v[i]){
            int x = xy.first;//xが
            int y = xy.second;//y = 1:正直、y=0不親切
            if(y == 1 && !(bit & (1 << x)))return false;//正直なのにフラグが立ってない
            if(y == 0 && (bit & (1 << x)))return false;
        }
    }
    return true;
}

int main() {    
    cin >> n;
    v.resize(n);
    rep(i,n){
        int a; cin >> a;
        v[i].resize(a);
        rep(j,a){
            cin >> v[i][j].first >> v[i][j].second;
            v[i][j].first--;//0-indexed
        }
    }
    int res = 0;
    for(int bit = 0; bit < (1<<n);bit++){
        if(judge(bit)){
            int cnt = 0;
            for(int i = 0; i < n; i++){
                if(bit & (1<<i))cnt++;
            }
            res = max(cnt,res);
        }
    }
    cout << res << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int R,C,N;
pair<int,int> p[100100];
int check(int x,int y){
	if(y==0) return x;
	if(x==R) return R+y;
	if(y==C) return R*2+C-x;
	if(x==0) return 2*R+2*C-y;
	return -1;
}
int main(){
	//	freopen("in.txt","r",stdin);

	scanf("%d%d%d",&R,&C,&N);
	int j = 0;
	for (int i = 0; i < N; ++i)
	{
		int tx1,ty1,tx2,ty2;
		scanf("%d%d%d%d",&tx1,&ty1,&tx2,&ty2);
		int p1 = check(tx1,ty1);
		int p2 = check(tx2,ty2);
		if(p1 >= 0 && p2 >= 0){
			p[j].fi = min(p1,p2);
			p[j].se = max(p1,p2);
			j++;
		}
	}
	N = j;
	sort(p,p+N);

	// for (int i = 0; i < N; ++i)
	// {
	// 	printf("%d : %d \n",p[i].fi,p[i].se);
	// }

	stack<int> st;
	st.push(p[0].se);
	for (int i = 1; i < N; ++i)
	{
		while(!st.empty() && st.top() < p[i].fi){
			st.pop();
		}
		if(!st.empty() && p[i].se > st.top()){
			printf("NO\n");
			return 0;
		}
		st.push(p[i].se);
	}
	//横線だけを調べる
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    ans = max(a * c, max(a * d, max(b * c, b * d)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main(){
    int n;
    cin >> n;
    int d[n];
    rep(i,n){
        cin >> d[i];
    }
    sort(d,d+n);
    int ans = 0;
    rep(i, n - 2)
    {
        rep2(j,i+1,n-1){
            rep2(k, j + 1, n)
            {
                if(d[k]>=d[i]+d[j])
                    break;
                if (d[i] < d[j] + d[k] && d[j] < d[i] + d[k] && d[k] < d[i] + d[j])
                    ans++;
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;


int main(int argc, char *argv[])
{
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string line;
    int sum = 0;
    
    while (getline(cin, line),line != "0") {
        for (int i = 0; i < line.length(); i++) {
            sum += line[i]-'0';
        }
        cout << sum << endl;
        sum = 0;
    }
    
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> s(4,0);
  rep(i,N){
    string str;
    cin >> str;
    if(str == "AC"){
      s[0]++;
    }else if(str == "WA"){
      s[1]++;
    }else if(str == "TLE"){
      s[2]++;
    }else if(str == "RE"){
      s[3]++;
    }
  }
  cout << "AC x " << s[0] << endl;
  cout << "WA x " << s[1] << endl;
  cout << "TLE x " << s[2] << endl;
  cout << "RE x " << s[3] << endl;
  	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	vector<string> pat;
	pat.push_back("dream");
	pat.push_back("dreamer");
	pat.push_back("erase");
	pat.push_back("eraser");
	vector<bool> f(s.length() + 1, false);
	f[0] = true;
	for (int i = 1; i <= s.length(); i++) {
		for (auto p : pat) {
			if (i >= p.length() && s.substr(i - p.length(), p.length()) == p && f[i - p.length()]) {
				f[i] = true;
			}
		}
	}
	cout << (f[s.length()] ? "YES\n" : "NO\n");
	return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int n, k; cin >> n >> k; cout << ((n % k == 0) ? 0 : 1) << endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		int answer=0;
		//List<Integer> hb=new ArrayList<Integer>();
		//long a=0;
		int hi=0;
		//入力
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int H=sc.nextInt();
		int W=sc.nextInt();
		//int [][] cost =new int[N-1][2];
		//処理
		int a=N-H+1;
		int b=N-W+1;
		answer=a*b;
		// 出力
		System.out.println(answer);
	}
}

Measured memory_bytes: 21844
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
        int K = sc.nextInt();
		
		System.out.println(num[K-1]);
    }
}

Measured memory_bytes: 22868
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

string s;
int cnt = 0;

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

	cin >> s;
	for (int i=1; i<sz(s); i++) {
		if (s[i] != s[i-1]) cnt++;
	}
	cnt++;
	
	cout << cnt - 1;


}


Measured memory_bytes: 640
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))

S = LI2()
N = len(S)
print(min(sum(S[i] for i in range(0,N,2)) + sum(1-S[i] for i in range(1,N,2)),sum(1-S[i] for i in range(0,N,2))+sum(S[i] for i in range(1,N,2))))


Measured memory_bytes: 77700
sx, sy, tx, ty = map(int, input().split())
ans = []
ans += ["R"] * (tx - sx) + ["U"] * (ty - sy)
ans += ["L"] * (tx - sx) + ["D"] * (ty - sy)
ans += ["D"] + ["R"] * (tx - sx + 1) + ["U"] * (ty - sy + 1) + ["L"]
ans += ["U"] + ["L"] * (tx - sx + 1) + ["D"] * (ty - sy + 1) + ["R"]
print("".join(ans))


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<vector<char>>a(n, vector<char>(n)), b(m, vector<char>(m));
	rep(i, n)rep(j, n)cin >> a[i][j];
	rep(i, m)rep(j, m)cin >> b[i][j];
	rep(i, n-m+1) {
		rep(j, n-m+1) {
			bool now = true;
			rep(k, m) {
				rep(l, m) {
					if (a[i + k][j + l] != b[k][l]) {
						now = false;
					}
				}
			}
			if (now) {
				cout << "Yes" << endl; return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
//
// ABC179 B - Go to Jail
//

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

int main()
{
    // 標準入力から値(回数)を受け取る。
    int n;
    cin >> n;

    // 標準入力から値(出目)を受け取る。
    vector<vector<int>> d(n, vector<int>(2));
    for (int i = 0; i < d.size(); i++)
    {
        for (int j = 0; j < d.at(i).size(); j++)
        {
            cin >> d.at(i).at(j);
        }
    }

    // check ゾロ目！
    int renzoro_cnt = 0;
    bool renzoro_res = false;
    for (int i = 0; i < d.size(); i++)
    {
        // is ゾロ目？
        if (d.at(i).at(0) == d.at(i).at(1))
        {
            renzoro_cnt++;
        }
        else
        {
            renzoro_cnt = 0;
        }

        // is ゾロ目３連続以上？
        if (3 <= renzoro_cnt)
        {
            renzoro_res = true;
            break;
        }
    }

    // 標準出力に結果を表示する。
    if (renzoro_res)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    // 戻り値
    return (0);
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll a, b, q, s, t, now, sum;
	ll ss[2];
	ll tt[2];
	ll ans = INF;

	cin >> a >> b >> q;

	vector<ll> x, y;

	x.push_back(-INF);
	y.push_back(-INF);

	REP(i, a) {
		cin >> s;
		x.push_back(s);
	}

	REP(i, b) {
		cin >> t;
		y.push_back(t);
	}

	x.push_back(INF);
	y.push_back(INF);

	REP(i, q) {
		cin >> now;

		auto itr1 = lower_bound(x.begin(), x.end(), now);
		auto itr2 = lower_bound(y.begin(), y.end(), now);

		ss[0] = *(itr1 - 1);
		ss[1] = *itr1;
		tt[0] = *(itr2 - 1);
		tt[1] = *itr2;
		ans = INF;

		REP(j, 2) {
			REP(k, 2) {
				sum = 0;
				sum += abs(now - ss[j]);
				sum += abs(ss[j] - tt[k]);
				ans = min(ans, sum);
			}
		}

		REP(j, 2) {
			REP(k, 2) {
				sum = 0;
				sum += abs(now - tt[j]);
				sum += abs(tt[j] - ss[k]);
				ans = min(ans, sum);
			}
		}

		cout << ans << endl;
	}
}

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

using namespace std;

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

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    --a; --b; --c; --d;
    string s; cin >> s;

    for(int i = a; i < c - 1; ++i)
    {
        if(s[i] == '#' && s[i + 1] == '#')
        {
            cout << "No";
            return 0;
        }
    }

    for(int i = b; i < d - 1; ++i)
    {
        if(s[i] == '#' && s[i + 1] == '#')
        {
            cout << "No";
            return 0;
        }
    }

    if(c < d)
    {
        cout << "Yes";
        return 0;
    }

    for(int i = b; i <= d; ++i)
    {
        if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
        {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 592
<?php
fscanf(STDIN, "%s", $b);
if ($b === 'A') {
    echo 'T';
} elseif ($b === 'T') {
    echo 'A';
}
if ($b === 'C') {
    echo 'G';
} elseif ($b === 'G') {
    echo 'C';
}


Measured memory_bytes: 15764
#include <bits/stdc++.h>
using namespace std;
 
 
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 2e6 + 1;//                                                             |
//----------------------------------------------------------------------------------
 



void solve()
{
    
    ll n,k;cin>>n>>k;
    ll val=1;
    vl v(n);
    for(auto &i:v) cin>>i;

    for(int i=k;i<n;i++){
        if(v[i]>v[i-k]) cout<<"Yes\n";
        else cout<<"No\n";
        
    }
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
}

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

void solve(){

	string s ;
	cin>>s ;

	for(int i=0;i<(int)s.length();i++){
		if(s[i]=='?'){
			s[i]='D' ;
		}

	}	
	
	cout<<s ;

}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3732
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
d_dict = {}
for d in D:
    if d not in d_dict:
        d_dict[d] = 0
    d_dict[d] += 1
 
count = 0
for t in T:
    if t in d_dict and d_dict[t] > 0:
        d_dict[t] -= 1
        count += 1
if count == M:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 41316
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 + (y1 - y2) << " " << y2 - (x1 - x2) << " " << x1 + (y1 - y2) << " " << y1 - (x1 - x2) << endl;
    return 0;
}

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

int main(){
    int D,N;
    cin >> D >> N;
    if (D == 0){
        if (N == 100){
            cout << 101 << endl;
        }
        else{
            cout << N << endl;
        }
    }
    else if (D == 1){
        if (N == 100){
            cout << 10100 << endl;
        }
        else{
            cout << 100 * N << endl;
        }
    }
    else if (D == 2){
        if (N == 100){
            cout << 1010000 << endl;
        }
        else{
            cout << 10000 * N << endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;


int main(void){
    long N;
    cin >> N;
    long table[100000 + 20] = {0};
    vector<long> list;
    long sum = 0;
    for(long i= 0; i < N; i++){
        long tmp =0;
        cin >> tmp;
        sum += tmp;
        list.push_back(tmp);
        table[tmp]+= 1;
    }
    long Q;
    cin >> Q;
    for(long i = 0 ; i < Q; i++){
        long B,C;
        cin >> B >> C;

        long num = table[B];
        table[B] = 0;
        table[C] += num;

        sum -= num * B;
        sum += num * C;

        cout << sum << endl;
    }
}

Measured memory_bytes: 5104
#include <iostream>

using namespace std;

int main()
{
  int n, c;
  int p;
  int sum = 0;
  int num_of_cakes;
  
  cin >> n >> c;
  while(c--) {
    cin >> p;
    sum += p;
  }

  sum % (n + 1) ? num_of_cakes = sum / (n + 1) + 1
    : num_of_cakes = sum / (n + 1);

  cout << num_of_cakes << endl;
}



Measured memory_bytes: 3112
fun main(args:Array<String>): Unit {
    readLine()!!.trim().toInt()
    val scores = readLine()!!.trim().split(' ').map(String::toInt)
    val counts = IntArray(100){0}
    for (s in scores) counts[s - 1]++
    for (i in 99 downTo 1) counts[i - 1] += counts[i]
    for (s in 100 downTo 1){
        if (s <= counts[s - 1]){
            println(s)
            return
        }
    }
}


Measured memory_bytes: 33888
#include<iostream>
using namespace std;
int main(){
	while (1){
		int n, a[10000] = { 0 }, b[10000] = { 0 }, A = 0, B = 0;
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
			if (a[i] < b[i]){
				B = B + a[i] + b[i];
			}
			else if (a[i] > b[i]){
				A = A + a[i] + b[i];
			}
			else{
				A = A + a[i];
				B = B + b[i];
			}
		}
		cout << A << " " << B << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] str = buf.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);

			if(W==0 && H==0)
				break;

			for(int i=1; i<=H; i++){
				for(int j=1; j<=W; j++){
					if(i%2==1 && j%2==1 || i%2==0 && j%2==0)
						System.out.print("#");
					else
						System.out.print(".");
				}
				System.out.println();
			} 
			System.out.println();
		}
	}
}

Measured memory_bytes: 30488
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

vector<int> divisor(int x) {
	vector<int> ret;
	int i;
	for (i = 1; i*i < x; i++) {
		if (x%i)continue;
		ret.emplace_back(i);
		ret.emplace_back(x / i);
	}
	if (i*i == x)ret.emplace_back(i);
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> d = divisor(N);
	cout << (int)log10(d.back()) + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string s;
cin>>s;
deque<char> q;
for(int i=0;i<s.size();i++){
   q.emplace_back(s[i]);
}
int m;
cin>>m;
int c=1;
for(int i=0;i<m;i++){
    int t;cin>>t;
    if(t==1){
        c^=1;
    }
    else{
        int f;char d;
        cin>>f>>d;
        if(c){
            if(f==1)q.emplace_front(d);
            else q.emplace_back(d);
        }else{
            if(f==2)q.emplace_front(d);
            else q.emplace_back(d);
        }
    }
}
if(c){
while(q.size()){
    cout<<q.front();
    q.pop_front();
}
}else{
    while(q.size()){
    cout<<q.back();
    q.pop_back();
}
}
cout<<endl;
}

Measured memory_bytes: 976
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, K = map(int, input().split())

    keta = 1
    while True:
        q = N // K
        if q == 0:
            break
        else:
            N = N // K
            keta += 1

    print(keta)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  int abc[3] = {0};
  rep(i, 3){
    if (S[i] == 'a') abc[0]++;
    else if (S[i] == 'b') abc[1]++;
    else if (S[i] == 'c') abc[2]++;
  }
  rep(i, 3){
    if (abc[i] == 0) {
      cout <<"No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;

}


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

using namespace std;
using ll = long long;
using ld = long double;

vector<int> pt;
vector<bool> seen;
void dfs(vector<vector<int>>& g, int v, int ap){
    seen[v]=false;
    pt[v]+=ap;
    int nap=pt[v];
    for(int nv: g[v]) {
        if(seen[nv]) dfs(g,nv,nap);
    }
}


//#define int long long
//signed main(){
int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int n,q;
    cin >> n >> q;
    vector<vector<int>> g(n);;
    for(int i = 0; i < n-1; i++) {
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    pt.assign(n,0);
    seen.assign(n,true);
    int p,x;
    for(int i = 0; i < q; i++) {
        cin >> p >> x;
        p--;
        pt[p]+=x;
    }
    dfs(g,0,0);

    for(int i = 0; i < n; i++) {
        cout << pt[i] << " ";
    }
    cout << "\n";

    return 0;
}

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

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

using namespace std;

int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};

struct Table{
	int d[25][25];
	Table(int a){
		rep(i,25) rep(j,25) d[i][j] = a;
	}
};

int solve(int x, int y, Table &t, int cnt){
	int res = 100;
	if( cnt <= 10 ) rep(k,4){
		//cout << "(" << x << " " << y << ") " << cnt << " : ";
		//cout << "RDLU"[k] << endl;
		int nx = x, ny = y;
		while( t.d[ nx+vx[k] ][ ny+vy[k] ] == 0 ){
			nx += vx[k];
			ny += vy[k];
		}
		if( t.d[ nx+vx[k] ][ ny+vy[k] ] == 3 ){
			res = min(res, cnt);
		}else if( t.d[ nx+vx[k] ][ ny+vy[k] ] == 1 ){
			if( nx == x && ny == y ) continue;
			t.d[ nx+vx[k] ][ ny+vy[k] ] = 0;
			res = min(res, solve(nx, ny, t, cnt+1) );
			t.d[ nx+vx[k] ][ ny+vy[k] ] = 1;
		}
	}
	return res;
}

int main(){
	int w, h;
	while(cin >> w >> h, w|h){
		Table t(-1);
		int sx, sy;
		rep(y,h) rep(x,w){
			cin >> t.d[x+1][y+1];
			if( t.d[x+1][y+1] == 2 ){
				t.d[x+1][y+1] = 0;
				sx = x+1;
				sy = y+1;
			}
		}
		int ans = solve(sx, sy, t, 1);
		cout << ( ans>10 ? -1 : ans) << endl;
	}
	return 0;
}

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

int main(void){
	char    S[200001];
	char    T[200001];
	int i,j;
	int R0[26];
	int R1[26];
	for(i=0;i<26;i++){
		R0[i]=-1;
		R1[i]=-1;
	}
	scanf("%s",S);
	scanf("%s",T);
	int n = strlen(S);
	for(i=0;i<n;i++){
		if(R0[S[i]-'a']<0){
			R0[S[i]-'a'] = T[i]-'a';
		}
		if(R1[T[i]-'a']<0){
			R1[T[i]-'a'] = S[i]-'a';
		}
	}
	for(i=0;i<n;i++){
		if(R0[S[i]-'a']!=T[i]-'a'){
			printf("No");
			return 0;
		}
		if(R1[T[i]-'a']!=S[i]-'a'){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 512