akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

long long f_gcd(long long a, long long b) {
	if (a < b)return f_gcd(b, a);
	long long r;
	while (r = a % b) {
		a = b;
		b = r;
	}
	return b;
}

int is_prime(long long n) {
	if (n == 2)return 1;
	for (int i = 2; i < sqrt(n) + 1; i++) {
		if (n % i == 0) {
			return 0;
		}
	}
	return 1;
}
#define MAX 10000000
int main(void) {
	long long a, b, count = 0;
	scanf("%lld %lld", &a, &b);
	long long gcd = f_gcd(a, b);
	long long list[100000];
	for (long long i = 2; i * i <= gcd; i++) {
		if (gcd % i == 0) {
			list[count] = i;
			count++;
			while (gcd % i == 0) { gcd /= i; }
		}
	}
	if (gcd != 1) {
		list[count] = gcd;
		count++;
	}
	
	printf("%lld\n", count+1);

	return 0;
}

Measured memory_bytes: 128
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {


    int n, a, count = 0, ans = 0;
    
    cin >> n;
    a = n;
    
    while(a)
    {
        a = a / 10;
        count++;
    }
    
    if(count == 1)
    {
        ans = n;
    } else if (count == 2)
    {
        ans = 9;
    } else if (count == 3)
    {
        ans += 9;
        ans += n - 100 + 1;
    } else if (count == 4)
    {
        ans += 9;
        ans += 999 - 100 + 1;
    } else if (count == 5)
    {
        ans += 9;
        ans += 999 - 100 + 1;
        ans += n - 10000 + 1;
    } else if (count == 6)
    {
        ans += 9;
        ans += 999 - 100 + 1;
        ans += 99999 - 10000 + 1;
    }
    
    cout << ans << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define     PI 				3.14159265358979
#define     mod 			1000000007
#define     ll  			long long int
#define     rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define     mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define     hi   			"hello"
#define     nl 				"\n"
#define     ws 				" "
#define     sz              size()
#define     len             length()
#define     F 				first
#define     S 				second
#define     pb				push_back
#define     MP				make_pair
#define     B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

////////////////// Inverse Modulo //////////////////////

ll power(ll a, ll b){//a^b
    ll res=1;
    a = a% mod;
    while(b>0){
        if(b&1){
            res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b /= 2;
    }
    return res;
}

ll fermat_inv(ll y){return power(y, mod-2);}
//////////////////////////////////////////////////////////

vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 1000005

void solve() {
    ll d, t, s;
    cin >> d >> t >> s;

    if(s*t >= d) cout << "Yes\n";
    else cout << "No\n";

}

int main(){
    // boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("perimetric_chapter_1_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);


    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
using namespace std;
long long int ara[1000000],ara1[1000000];
int main()
{
    long long int n,k,i,j,sum;
    cin>>n>>k;
    ara[0]=k;
    for(i=1;i<=n;i++) cin>>ara[i];
    sort(ara,ara+n+1);
//    for(i=0;i<=n;i++) {
//        cout<<ara[i]<<" ";
//    }
//    cout<<endl;
    long long int mini=200000000000;
    for(i=1,j=0;i<=n;i++,j++){
        ara1[j]=ara[i]-ara[i-1];
    }
    sum=ara1[0];
    for(i=1;i<j;i++){
        sum=__gcd(sum,ara1[i]);
    }
    cout<<sum<<endl;
}


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

int H, W;

const int di[] = {1, -1, 0, 0};
const int dj[] = {0, 0, 1, -1};

int main(void){
	cin >> H >> W;
	vector<vector<char>> m(H, vector<char>(W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> m[i][j];
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(m[i][j] == '#'){
				bool ans = false;
				for(int k = 0; k < 4; k++){
					int ni, nj;
					ni = i+di[k];
					nj = j+dj[k];
					if(ni < 0 || nj < 0 || ni >= H || nj >= W) continue;
					if(m[ni][nj] == '#'){
						ans = false;
						break;
					}
					ans = true;
				}
				if(ans){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

const int N = 15;
const int M = 1e3 + 5;

int n, m, dp[1 << N], mask[M], val[1 << N], a[M];

int proc (int maskx, int masky) {
    for (int i = 0; i < n; i++) {
        if (masky & (1 << i)) {
            if (maskx & (1 << i)) maskx ^= (1 << i);
        }
    }
    
    return maskx;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> a[i] >> x;
        for (int j = 0; j < x; j++) {
            int y; cin >> y;
            mask[i] |= (1 << (y - 1));
        }
    }
    
    memset(dp, 0x3f, sizeof(dp)); dp[0] = 0;
    for (int maskdp = 0; maskdp < (1 << n); maskdp++) {
        for (int i = 1; i <= m; i++) {
            dp[maskdp] = min(dp[maskdp], dp[proc(maskdp, mask[i])] + a[i]);
        }
    }
    
    if (dp[(1 << n) - 1] > 1e9) return cout << -1, 0;
    cout << dp[(1 << n) - 1];
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main(){

  int n, l;
  cin >> n >> l;
  vector<int> a(n);
  REP(i,n) a[i] = l + i; //美味しさ
  debug(a);
  //総和
  int sum = 0;
  REP(i,n) sum += a[i];
  int minx = 1000000000;
  int ans;
  REP(i,n){
    int tmps = 0;
    REP(j,n){
      if(i == j) continue;
      tmps += a[j];
    }
    if(minx > abs(sum - tmps)){
      minx = abs(sum-tmps);
      ans = tmps;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, Q = in.next().toInt
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to N-1) {
    val a, b = in.next().toInt
    graph(a) = b :: graph(a)
    graph(b) = a :: graph(b)
  }
  val count = new Array[Int](N+1)
  for (_ <- 1 to Q) {
    val p, x = in.next().toInt
    count(p) += x
  }

  //
  val q = Queue[(Int, Long)]((1, 0)) // (node, total)
  val ans = Array.fill[Long](N+1)(-1)
  while (!q.isEmpty) {
    val (now, _cost) = q.dequeue()
    if (ans(now) == -1) {
      val cost = _cost + count(now)
      ans(now) = cost
      for (e <- graph(now)) {
        q.enqueue((e, cost))
      }
    }
  }

  println(ans.drop(1).mkString(" "))
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

int n;
vector<int> g[MAX_N];

int cnt[MAX_N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int p;
		cin >> p;
		cnt[p]++;
	}
	for (int i = 1; i <= n; ++i) {
		cout << cnt[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, T, ans = 0, now = 0;
    cin >> N >> T;
    vll t(N + 1);
    rep(i, N)
    {
        cin >> t[i];
    }
    t[N] = INF;
    rep(i, N)
    {
        ans += min(abs(t[i + 1] - t[i]), T);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    string S, T;
    cin >> S >> T;

    if (SIZE(S) + 1 != SIZE(T)) {
        cout << "No";
        return;
    }

    REP(i, SIZE(S)) {
        if (S[i] != T[i]) {
            cout << "No";
            return;
        }
    }

    cout << "Yes";
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a[100],b='A';
  int c=1,d,e;
  cin>>d>>e;
  for(;;){
    cin>>a;
    if(a[0]=='s' && a[1]=='n' && a[2]=='u' && a[3]=='k' && a[4]=='e'){
      cout<<b<<c<<endl;
      return(0);
    }
    else{
      b++;
      if(b-e=='A'){
	b='A';
	c++;
      }
    }
  }	
  return(0);
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
    dp[0][0] = 1.0;
    for (int i = 0;i < n;++i) {
        double p;
        cin >> p;
        for (int j = 0;j < n;++j) {
            dp[i+1][j] += dp[i][j]*(1-p);
            dp[i+1][j+1] += dp[i][j]*p;
        }
    }
    double ans = 0.0;
    for (int i = (n+1)/2;i <= n;++i) ans += dp[n][i];
    cout << setprecision(10) <<  ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<fstream>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

class UnionFind {
public:
	vector<ll> parent;
	vector<ll> gap;//強化前の、素の値
	vector<ll> up;//強化量

	UnionFind(ll n) : parent(n), gap(n, 0), up(n, 0) {
		REP(i, 0, n) parent[i] = i;
	}

	ll find(ll i) {
		if (parent[i] == i) return i;

		int tmp = parent[i];
		ll p = find(parent[i]);
		//cerr << "find  " << i+1 << " ,," << tmp+1 << "p: " << p+1 << endl;
		gap[i] += gap[tmp];
		return parent[i] = p;
	}

	void unite(ll i, ll j, ll c) {
		ll p = find(i), q = find(j);
		if (p != q) {
			gap[p] = c + get(j) - get(i);
			parent[p] = q;
		}
		up[i] += c;
		up[j] += c;
	}

	ll get(ll i) {
		return  - up[i] + gap[i];
		//return up[find(i)] - up[i] + gap[i];
	}
};

int main(void) {
	ll N, Q;
	cin >> N >> Q;
	vector<ll> T(Q), A(Q), B(Q), C(Q);
	REP(i, 0, Q) {
		string type;
		cin >> type >> A[i] >> B[i]; A[i]--; B[i]--;
		if (type == "IN") {
			T[i] = 0;
			cin >> C[i];
		}
		if (type == "COMPARE") T[i] = 1;
	}

	UnionFind uf(N);
	REP(i, 0, Q) {
		//cerr << endl<<endl<<"   debug" << endl;
		if (T[i] == 0) {
			uf.unite(A[i], B[i], C[i]);
		}
		if (T[i] == 1) {
			if (uf.find(A[i]) != uf.find(B[i])) cout << "WARNING" << endl;
			else {
				//uf.find(A[i]);
				//uf.find(B[i]);
				//cerr << "testing" << endl;
				cout << uf.get(A[i]) - uf.get(B[i]) << endl;
			}
		}
		//cerr << "====" << endl;
		//cerr << "way::" << A[i]+1 << " " << B[i]+1 << endl;
		//REP(i, 0, N) cerr <<"me:"<<i+1<< " par:" << uf.parent[i] + 1 << ",  gap:" << uf.gap[i] << ",  up:" << uf.up[i] << endl;
	}
	//cerr << "==FINISH==" << endl;
	//REP(i, 0, N) cerr << "par:" << uf.parent[i] << ",  gap:" << uf.gap[i] << ",  up:" << uf.up[i] << endl;
	int n;
	cin >> n;

}



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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll n; cin >> n;
    vector<P> A(n);
    rep(i,n){
        ll a; cin >> a;
        A[i].first = a;
        A[i].second = i+1;
    }

    VL B(n);
    rep(i,n){
        B[i] = A[i].second - A[i].first;
    }
    sort(B.begin(), B.end());

    ll ans = 0;
    rep(i,n){
        ll val = A[i].first + A[i].second;
        ans += (ll)(upper_bound(B.begin(), B.end(), val) - lower_bound(B.begin(), B.end(), val));
    }

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

Measured memory_bytes: 8008
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N, M; cin >> N >> M;
   vector<int> H(N);
   rep(i, 0, N) cin >> H.at(i);

   vector<int> maxH(N, 0);

   rep(i, 0, M) {
     int a, b; cin >> a >> b;
     maxH.at(a - 1) = max(maxH.at(a - 1), H.at(b - 1));
     maxH.at(b - 1) = max(maxH.at(b - 1), H.at(a - 1));
   }

   int ans = 0;
   rep(i, 0, N) {
     if (maxH.at(i) < H.at(i)) ans++;
   }

   cout << ans << endl;
 }


Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
   ll n,k; cin >> n >> k;
   vector<ll> p(n);
   rep(i,n){
       cin >> p[i];
       p[i]--;
   }
   vector<ll> c(n);
   rep(i,n) cin >> c[i];
   map<ll,ll> pc;
   ll ans=-INF;
   rep(i,n){
       if(pc[i]) continue;
       vector<ll> jun;
       ll now=i;
       ll jsum=0;
       while(!pc[now]){
           pc[now]++;
           jun.push_back(c[now]);
           jsum+=c[now];
           now=p[now];
       }
       ll l=jun.size();
       jun.insert(jun.end(),jun.begin(),jun.end());

       jun.insert(jun.end(),jun.begin(),jun.end());
           ll di = min(l,k);
           rep(j,l){
               ll tmpa=-INF;
               ll tmp=0;
               for(ll z=j; z<j+di; z++){
                   tmp+=jun[z];
                   tmpa=max(tmpa,tmp);
               }
               ans=max(ans,tmpa);
           }
        
       if(jsum>=0){
            rep(j,l){
                ll di=jun.size()/4;
                ll times=k%di;
                ll time=k/di;
                ll tmp=jsum*(time-1);
                ll tmpa=-INF;
                ans=max(tmp,ans);
                for(ll z=j; z<times+j+l; z++){
                    tmp+=jun[z];
                    tmpa=max(tmpa,tmp);
                }
                ans=max(ans,tmpa);
            }
       }
   }

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

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int n=(int)s.size();
  if(s == string(n,s[0])){
    cout << n * k / 2 << endl;
  }else{
    int ans1 = 0;
    for(int i = 0; i+1 < n; i++){
      if(s[i%n]==s[(i+1)%n]){
        ++ans1;
        ++i;
      }
    }
    int ans2 = 0;
    for(int i = 0; i+1 < 2 * n; i++){
      if(s[i%n] == s[(i+1)%n]){
        ++ans2;
        i++;
      }
    }
    cout << ans1 + (ans2 - ans1) * (k - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int mod = 1000000007;

int main(){
  unsigned long long N, K, cnt=0, ans=0, cnt2=0;
  cin >> N >> K;
  long long int A[N];
  for(int i=0; i<N; i++) cin >> A[i];

  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      if(A[i] > A[j]) cnt++;
      if(A[i] < A[j]) cnt2++;
    }
  }

  if(K % 2 == 0) ans = (K/2*((2*cnt +(K-1)*cnt)%mod)%mod + (K-1)*((cnt2 +(K-2)/2*cnt2)%mod))%mod;
  else ans = (K*((cnt +(K-1)/2*cnt)%mod)%mod + ((K-1)/2*((2*cnt2 +(K-2)*cnt2)%mod))%mod)%mod;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=0&&a<=5)
    {
        printf("0");
    }else if(a>=6&&a<=12)
    {
        printf("%d",b/2);
    }else
    {
        printf("%d",b);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    long double x , a , p = 1.01 ;
    cin >> x ;
    long long int val = 0 , t = 0 ;
    val = 100 ;
    a = 100 ;
    while(1)
    {
        // a = val ;
        if(val >= x)
        {
            break ;
        }
        val = val + (val/100) ;
        // a *= p ;
        // val = (int)a ; 
        // cout << val << endl ;
        t++ ;
    }
    cout << t << endl; 
}

Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<cmath>
using namespace std;

typedef long long llong;
const int INFTY = 2000000001;
int S[500010], n;
llong cmp;

int merge(int left, int mid, int right)
{
	int n1 = mid - left, n2 = right - mid;
	llong ans = 0;
	vector<int>L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++)
		L[i] = S[left + i];
	for (int i = 0; i < n2; i++)
		R[i] = S[mid + i];
	L[n1] = R[n2] = INFTY;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			S[k] = L[i];
			i += 1;
		}
		else {
			S[k] = R[j];
			j += 1;
			ans += n1 - i;
			cmp += n1 - i;
		}
	}
	return ans;
}

int mergeSort(int left, int right)
{
	llong l = 0, r = 0, m = 0;
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		l = mergeSort(left, mid);
		r = mergeSort(mid, right);
		m = merge(left, mid, right);
		return l + r + m;
	}
	else
		return 0;
}

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> S[i];
	//cmp = 
	mergeSort(0, n);
	cout << cmp << endl;
	return 0;
}


Measured memory_bytes: 4356
#include<iostream>
using namespace std;
char mas[100][100];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int w,h,cnt;
void dts(int x,int y);
int main(){
  while(1){
    cnt=0;
    cin >> h >> w;
    if(w == 0 && h == 0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mas[i][j];
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(mas[i][j]=='*' || mas[i][j]=='#' || mas[i][j]=='@'){
	  cnt++;
	  dts(j,i);
	}
      }
    }
    cout << cnt <<endl;
  }
}
void dts(int x,int y){
  char temp=mas[y][x];
  mas[y][x]='.';
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx>=0 && nx<w && ny<h && ny>=0 && mas[ny][nx]==temp){
      dts(nx,ny);
    }
  }
}

	

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

int main() {
  int A, B;
  cin >> A >> B;
  vector<int> decimal(5);
  int counter = 0;
  for(int i = A; i <= B; i++) {
    int n = i;
    for(int j = 0; j < 5; j++) {
      decimal.at(j) = n % 10;
      n /= 10;
    }
    if(decimal.at(0) == decimal.at(4) && decimal.at(1) == decimal.at(3)) counter++;
  }
  cout << counter << endl;
}


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

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,i,cou,j;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    cou=0;
    for(i=a+1;i<=a*2;i++){
      for(j=2;j*j<=i;j++){
	if(i%j==0)break;
      }
      if(j*j>i)cou++;
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1028
N, M = map(int, input().split())

all_set = set()
for i in range(N):
    A = list(map(int, input().split()))
    A.pop(0)
    if i == 0:
        all_set = set(A)
    else:
        all_set = all_set & set(A)

print(len(all_set))

Measured memory_bytes: 38256
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=3e6+5;
const int modulo=1e9+7;
const int inf=1e18;
const int N=1001;
int a[no],b[no],cc[no],dd[no],mat[N][N];
stack<int> S;
stack<int> ma;
int dx[]={-1 , 0 , 1 , 0};
int dy[]={0 , 1 , 0 , -1};
char c[N][N];

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/
int mul(int x ,int y,int mod) {
    return ((x%mod)*(y%mod))%mod;
}

int powwmod(int x, int y , int mod) { int res=1; while (y) { if (y & 1){ y--; res=mul(res,x,mod); res%=mod; } else { y/=2; x=mul(x,x,mod); x%=mod; } } return res%mod; }

int poww(int x , int y) { int res=1; while(y) { if(y%2) { y--; res=res*x; } else { y/=2; x=x*x; } } return res; }

bool comp(int x, int y) {
    return (x < y);   // MINIMUM
    return (x > y);   // MAXIMUM
}

int gcd(int x, int y) { if(y==0) return x; else return gcd(y,x%y); }

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

vi adj[no];
int used[no],vis[N][N],dist[N][N],timer,in[no],low[no];
int pp,brig;

/**/
void solve (){
    int n,m,k,x,y,p,q;
    string s1,s2;
    cin>>s1>>s2;
    int l1=s1.size();
    int l2=s2.size();
    int maxi=0;
    for(int i=0 ; i<=(l1-l2) ; i++) {
        int cou=0;
        for(int j=0 ; j<l2 ; j++) {
            if(s1[i+j]==s2[j]) cou++;
        }
        maxi=max(cou,maxi);
    }
    cout<<l2-maxi<<en;
}
void runn(){
        #ifndef ONLINE JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif
}

signed main()
{
    night_rider
    //runn();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 73972
import bisect

n = int(input())
a,b,c = [list(sorted(map(int, input().split())))  for _ in range(3)]

ans = 0
for i in range(n):
    x = bisect.bisect_left(a, b[i])
    y = len(c) - bisect.bisect_right(c, b[i])
    ans += x*y
print(ans)

Measured memory_bytes: 22720
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const int maxn = 60;
const int MOD = 1000000007;

//文件输入输出
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);

//浮点型运算
typedef long double db;
const double eps = 1e-7;
bool eq(const double &a, double const &b) { return fabs(a - b) < eps; }
bool ls(const double &a, double const &b) { return a + eps < b; }

int main ()
{
    int n;
    scanf("%d",&n);
    char s1[maxn],s2[maxn];
    scanf("%s",s1);
    scanf("%s",s2);
    ll ans;
    int start,pre;
    if (s1[0] == s2[0]) {
        ans = 3;
        start = 1;
        pre = 1;
    } else {
        ans = 6;
        start = 2;
        pre = 2;
    }
    rep(i,start,n) {
        if (s1[i] == s2[i]) {
            if (pre == 1)
                ans = ans * 2 % MOD;
            pre = 1;
        } else {
            if (pre == 1) {
                ans = ans * 2 % MOD;
                i++;
            } else if (pre == 2) {
                ans = ans * 3 % MOD;
                i++;
            }
            pre = 2;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([][]int, 2+1)
	dp := make([][]int, 2+1)
	for i := 0; i <= 2; i++ {
		a[i] = make([]int, n+1)
		dp[i] = make([]int, n+1)
		if i == 0 {
			continue
		}
		for j := 1; j <= n; j++ {
			a[i][j] = readInt()
		}
	}

	for i := 1; i <= 2; i++ {
		for j := 1; j <= n; j++ {
			dp[i][j] = maxInt(dp[i-1][j], dp[i][j-1]) + a[i][j]
		}
	}

	println(dp[2][n])
}


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

int main()
{
	char a[2], b[2];
	
	scanf("%s%s", a, b);
	if (a[0] == 'H') {
		puts(b);
	} else {
		if (b[0] == 'H') {
			puts("D");
		} else {
			puts("H");
		}
	}
}

Measured memory_bytes: 256
g=gets,k=(0..1e5).map{[]};$<.map{|l|a,b=l.split.map &:to_i;k[a]<<b;k[b]<<a};q=g[j=k[i=1][0]]=1,j;q[S,0]=g[R]=R while S=[0,i+=1].find{|c|R=k[q[c-c/i]].find{|x|!g[x]}};puts i,q*' '

Measured memory_bytes: 16380
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int h1,m1,h2,m2,k;
  scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
  if (h2<h1)
  h2+=24;
  int val=((h2-h1)*60+m2-m1-k);
  printf("%d\n",val);
  return 0;  
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define x() real()
#define y() imag()

typedef complex<double> point; // 2D point only
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldob;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef pair<ii, ll> ii_i;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
struct custom_hash {
	static uint64_t splitmix64(uint64_t x) {
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

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

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 41;
const int NN = 1001;
const int MOD = 1e9+7;
const int IMAX = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int n, Ma, Mb, ai[N], bi[N], ci[N], dp[N][N*11][N*11];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0);
	// cout.precision(3); cout << fixed;
	memset(dp, -1, sizeof dp);
	cin >> n >> Ma >> Mb;
	for (int i = 0; i < n; ++i)
		cin >> ai[i] >> bi[i] >> ci[i];

	for (int i = 0; i <= n; ++i)
		for (int a = 0; a < N*11; ++a)
			for (int b = 0; b < N*11; ++b)
				dp[i][a][b] = IMAX;
	dp[0][0][0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int a = 0; a < N*11; ++a) {
			for (int b = 0; b < N*11; ++b) {
				if (dp[i][a][b] == IMAX)
					continue;
				dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b]);
				dp[i+1][a+ai[i]][b+bi[i]] = min(dp[i+1][a+ai[i]][b+bi[i]], dp[i][a][b]+ci[i]);
			}
		}
	}

	int ans = IMAX;
	for (int a = 1; a < N*11; ++a) {
		for (int b = 1; b < N*11; ++b) {
			if (a*Mb == b*Ma)
				ans = min(ans, dp[n][a][b]);
		}
	}
	cout << (ans == IMAX ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 36180
def main():
    mod = 10**9 + 7
    s = input()
    n = len(s)

    a_num = 0
    c_num = s.count('C')
    q_num = 0
    q_cnt = s.count('?')

    pows = [0] * 4
    if q_cnt >= 3:
        pows[3] = pow(3, q_cnt-3, mod)
        pows[2] = pows[3] * 3 % mod
        pows[1] = pows[2] * 3 % mod
        pows[0] = pows[1] * 3 % mod
    elif q_cnt == 2:
        pows[2] = 1
        pows[1] = 3
        pows[0] = 9
    elif q_cnt == 1:
        pows[1] = 1
        pows[0] = 3
    else:
        pows[0] = 1

    ans = 0
    for x in s:
        if x == 'A':
            a_num += 1
        elif x == 'B':
            ans += pows[0] * a_num * c_num
            ans += pows[1] * (q_num * c_num + a_num * (q_cnt - q_num))
            ans += pows[2] * (q_num) * (q_cnt - q_num)
            ans %= mod
        elif x == 'C':
            c_num -= 1
        else:
            ans += pows[1] * a_num * c_num
            ans += pows[2] * (q_num * c_num + a_num * (q_cnt - q_num - 1))
            ans += pows[3] * (q_num) * (q_cnt - q_num - 1)
            ans %= mod
            q_num += 1

    print(ans)

main()

Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n);
    VV<> res(n, V<>(n));
    REP(i, n) REP(j, n){
        if(i == j) continue;
        ll k = i ^ j;
        k = k & (-k);
        ll z = -1;
        RREP(i, 9) if((k >> i) & 1) z = i;
        res[i][j] = z + 1;
    }
    REP(i, n) for(int j = i + 1; j < n; j++) cout << res[i][j] << (j == n - 1 ? "\n" : " ");
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
//#define int long long
using namespace std;

signed main()
{
	//ios::sync_with_stdio(false);
	int n,cnt=0;
	string a,b,c;
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		if(a[i]==b[i]&&b[i]==c[i]) continue;
		else if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i]) cnt++;
		else cnt+=2;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    string s;
    cin >> s;

    cout << (s[2]==s[3] && s[4]==s[5] ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

auto g = make_vec<int>(0, 0);
vector<int> ord, par;
vector<bool> seen;

void dfs(int v) {
    seen[v] = true;
    for (int u : g[v]) {
        if (seen[u]) continue;
        dfs(u);
    }
    ord.pb(v);
}

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

    int n, m;
    cin >> n >> m;
    g.resize(n);
    rep(i, n-1+m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
    }
    seen.resize(n);
    par.resize(n, -1);
    rep(v, n) if (!seen[v]) dfs(v);
    rep(i, n) {
        int v = ord[i];
        for (int u : g[v]) if (par[u] == -1) par[u] = v;
    }
    rep(v, n) cout << (par[v] == -1 ? 0 : par[v]+1) << endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> p(m);
  rep(i,m) cin >> p[i].first >> p[i].second;
  rep(i,1000){
    int k = 0,x = i;
    vector<int> d;
    while(x > 0){
      k++;
      d.push_back(x%10);
      x /= 10;
    }
    if(i==0){
        d.push_back(0);
        k++;
    } 
    reverse(d.begin(),d.end());
    if(k!=n) continue;
    bool flag = true;
    rep(j,k){
      rep(l,m){
      	if(d[p[l].first-1] != p[l].second) flag = false;
      }
    }
    if(flag){
        cout << i << endl;
        return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

//int a[1001][1001] //aise global me hi

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
queue<ll> q;   
ll n;cin>>n;
f(i,1,10)
q.push(i);

f(i,0,n-1)
{
	ll x=q.front();q.pop();
	ll d=x%10;
	if(d==0) {q.push(10*x);q.push(10*x+1);}
	else if(d==9) {q.push(10*x+8);q.push(10*x+9);}
	else
	{
		q.push(10*x+d-1);
		q.push(10*x+d);
		q.push(10*x+d+1);
	}

}
cout<<q.front();

}


int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
   // cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  char c[n];
  cin >> c;
  if(n%2!=0){
    cout << "No" << endl;
    exit(0);
  }
  for(int i = 0; i < n/2; i++){
    if(c[i]!=c[i+n/2]){
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt

    // 0 0が入力された
    if(!width && !height){
      break;
    }

    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
    
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];

        switch(c){
        case 'S':
          start = new Pos(x, y);
          break;
        case 'G':
          goal = new Pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1].push(new Pos(x, y));
          break;
        }
      }
    }

    
    var bestElement = -1;
    var distance = Infinity;
    
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for (var e = 0; e < 5; e++) {
        dp[e].length = 1000;
        for(var ei = 0; ei < 1000; ei++){
          dp[e][ei] = Infinity;
        }
      }
      
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;

      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
      
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = Math.min(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
      
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
        
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
        
      }
      
    }
    
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }

    i++;
  }
  

}

function dist(from, to){
  return Math.abs(from.x - to.x) + Math.abs(from.y - to.y)
}

function Pos(a, b){
  this.x = a;
  this.y = b;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 64496
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
P p[200110];
int n, x[200011], z = -1, vz = 0, ans = 1;
void mutu(int a) {
	if(a)x[a] += x[a - 1];
	x[a] %= mmod;
	for (int i = z + 1; i<n&&p[a].first + p[a].second>p[i].first; i = z + 1) {
		z++;
		mutu(i);
	}
	x[z + 1] += x[a];
}
signed main() {
	cin >> n;
	f(i, n) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	for (; z < n-1;) {
		if (z + 1)x[z + 1] = x[z] * -1 + 1;
		else x[z + 1] = 1;
		z++;
		mutu(z);
		int sum = 1;
		for (; vz <= z; vz++)sum += x[vz];
		ans *= sum % mmod;
		ans %= 998244353;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11264