akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: i32);
    puts!("{}\n", a * a);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
s = [a[0]]
for i in range(1, n):
    s.append(s[i-1] + a[i])
cnt = Counter(s)
ans = 0
if 0 in cnt.keys():
    ans += cnt[0]
val = list(cnt.values())
for val_i in val:
    if val_i >= 2: ans += (val_i) * (val_i - 1) // 2
print(ans)


Measured memory_bytes: 41696
# -*- coding: utf-8 -*-
from statistics import mean
from math import factorial as fact

n,a,b = map(int, input().split())
v = sorted([int(x) for x in input().split()], reverse=True)
sel = v[:a]
print(mean(sel))

vn = v.count(sel[-1])
na = sel.count(sel[-1])
nb = min(b-a, vn-na)
# print(na,nb,vn,len(sel),sel[-1])

if na!=len(sel):
    print(fact(vn)//(fact(na)*fact(vn-na)))
elif nb==0:
    print(1)
else:
    ret = 0
    for bi in range(na,na+nb+1):
        ret += fact(vn)//(fact(bi)*fact(vn-bi))
    print(ret)


Measured memory_bytes: 5976
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
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...);}

vector<ll> len;

ll rec(int level, ll x) {
    if (level == 0) return 1;
    if (x <= 1) return 0;
    else if (x <= 1 + len[level-1]) return rec(level-1, x-1);
    else if (x <= 1 + len[level-1] + 1) return rec(level-1, len[level-1]) + 1;
    else if (x <= 1 + len[level-1] + 1 + len[level-1]) return rec(level-1, len[level-1]) + 1 + rec(level-1, x-(1+len[level-1]+1));
    else return 2 * rec(level-1, len[level-1]) + 1;
}

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

    int n; ll x;
    cin >> n >> x;
    len.resize(51);
    len[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        len[i] = 3 + 2*len[i-1];
    }
    cout << rec(n, x) << endl;
}


Measured memory_bytes: 3580
N = int(input())
S = input()
alphabet = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 
           'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')
result = ''
for letter in S:
  result += alphabet[(alphabet.index(letter)+N)%26]
print(result)

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

int main(){
    int n;
    cin>>n;
    vector<vector<int>> edge(n);
    vector<int> color(n,-1);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    queue<int> f,s;
    f.push(0),s.push(n-1);
    for(int ii=0;ii<n;ii++){
        queue<int> nf,ns;
        while(!f.empty()){
            int v=f.front();
            f.pop();
            if(color[v]!=-1) continue;
            color[v]=0;
            for(int i=0;i<edge[v].size();i++){
                nf.push(edge[v][i]);
            }
        }    
        f=nf;
        while(!s.empty()){
            int v=s.front();
            s.pop();
            if(color[v]!=-1) continue;
            color[v]=1;
            for(int i=0;i<edge[v].size();i++){
                ns.push(edge[v][i]);
            }
        }    
        s=ns;
    }
    int val=accumulate(color.begin(),color.end(),0);
    if(val<(n+1)/2){
        cout<<"Fennec"<<endl;
    }
    else{
        cout<<"Snuke"<<endl;
    }
    return 0;
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int m1 = m / 2, m0 = m - m1;
  for (int i = 0; i < m0; ++i) {
    cout << i + 1 << ' ' << 2 * m0 - i << '\n';
  }
  for (int i = 0; i < m1; ++i) {
    cout << 2 * m0 + i + 1 << ' ' << 2 * m0 + 2 * m1 - i + 1 << '\n';
  }
}


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

int main(){
    int n,t;
    cin >> n >> t;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int p=0;
    int m=0;
    for(int i=0; i<n; i++){
        p = max(p,a[i]-a[m]);
        if(a[i] < a[m]) m = i;
    }
    m=0;
    long long ans = 0;
    for(int i=0; i<n; i++){
        if(a[i]-a[m] == p){
            ans++;
        }
        if(a[i] < a[m]) m = i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<int,int>
#define MAX 100006
#define CASE(i) printf("Case %d:\n", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)

using namespace std;

vector<string>vec;

int main()
{
    int N, L;
    scanf("%d %d", &N, &L);
    string str;
    for(int i=0; i<N; i++){
        cin>>str;
        vec.push_back(str);
    }

    stable_sort(vec.begin(), vec.end());
    for(int i=0; i<N; i++)
        cout<<vec[i];
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const INF: usize = 1 << 50;

fn main() {
    input! {
    A: usize,
    B: usize,
    }

    if A <= 8 && B <= 8 {
        println!("Yay!");
    } else {
        println!(":(");
    }
}


Measured memory_bytes: 4352
n=int(input())
a=[int(x) for x in input().rstrip().split()]

ruiseki=[0]
for i in range(n):
  ruiseki.append(ruiseki[i]+a[i])

ans=float('inf')
last=ruiseki[len(ruiseki)-1]
# print(last)
# print(ruiseki)
for i in range(1,len(ruiseki)-1):
  now=(last-ruiseki[i])
  ans=min(ans,abs(ruiseki[i]-now))
print(ans)
  




Measured memory_bytes: 31204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll sum = 0;
	unordered_map<ll,ll>m;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		m[x]++;
		sum += x;
	}
	ll q;
	cin >> q;
	while (q--) {
		ll b, c;
		cin >> b >> c;
		ll no = m[b];
		sum = sum + (no * c) - no * b;
		m[c] += no;
		m[b] = 0;
		cout << sum << endl;
	}
}


Measured memory_bytes: 7068
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 10 + 5;
const ll inf = LLONG_MAX;
using namespace std;

template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T>
void print_container(T &container) {
	for (auto &t : container) {
		cout << t << " ";
	}
	cout << endl;
}

int n, m, k;
char a[N][N];
void solve() {
	cin >> n >> m >> k;

	int total = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < m; j++) {
			a[i][j] = s[j];
			if (a[i][j] == '#') {
				total++;
			}
		}
	}

	int rows[n];
	int cols[m];
	clr(rows);
	clr(cols);
	for (int i = 0; i < n; i++) {
		int curr = 0;
		for (int j = 0; j < m; j++) {
			if (a[i][j] == '#') {
				curr++;
			}
		}
		rows[i] = curr;
	}

	// for (int i = 0; i < n; i++) {
	// 	cout << rows[i] << " ";
	// }
	// cout << endl;

	for (int i = 0; i < m; i++) {
		int curr = 0;
		for (int j = 0; j < n; j++) {
			if (a[j][i] == '#') {
				curr++;
			}
		}
		cols[i] = curr;
	}

	// for (int i = 0; i < m; i++) {
	// 	cout << cols[i] << " ";
	// }
	// cout << endl;


	int cnt = 0;
	for (int i = 0; i < pow(2, n); i++) {
		for (int j = 0; j < pow(2, m); j++)
		{
			int curr = total;
			int x = i;
			vector<int> mx, my ;
			for (int p = 0; p < n; p++) {
				if (x & 1) {
					curr -= rows[p];
					mx.pb(p);
				}
				x >>= 1;
			}

			int y = j;
			for (int p = 0; p < m; p++) {
				if (y & 1) {
					curr -= cols[p];
					my.pb(p);
				}
				y >>= 1;
			}

			// deb(curr);
			for (int x : mx) {
				for (int y : my) {
					if (a[x][y] == '#') {
						curr++;
					}
				}
			}
			// deb(curr);
			// cout << endl;
			cnt += (curr == k);

		}
	}

	cout << cnt << endl;
}

int32_t main() {
	IOS;



	solve();
}



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

template<typename T> using V = vector<T>;
using VI = V<int>;

int N, M;
VI S, T;

int dfs(int s, int t, int c) {
  static V<V<VI>> memo(N+1, V<VI>(M+1, VI(2, -1)));
  if(~memo[s][t][c]) return memo[s][t][c];
  int res = 0;
  if(s < N) if(S[s] == c) res = max(res, 1 + dfs(s+1, t, !c));
  if(t < M) if(T[t] == c) res = max(res, 1 + dfs(s, t+1, !c));
  return memo[s][t][c] = res;
}

int main() {
  string s, t;
  cin >> N >> M >> s >> t;
  for(auto c: s) S.push_back(c == 'I');
  for(auto c: t) T.push_back(c == 'I');

  int ans = 0;
  for(int i = 0; i < N; ++i) for(int j = 0; j < M; ++j) ans = max(ans, dfs(i, j, 1));
  cout << max(0, ans - !(ans&1)) << endl;
}

Measured memory_bytes: 222528
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n = int(input())
es=[[] for i in range(n)]
for i in range(n - 1):
   a, b = map(int, input().split())
   es[a - 1].append(b - 1)
   es[b - 1].append(a - 1)
def dfs0(v, d, p):
    if v == n - 1:
        return d
    for e in es[v]:
        if e != p:
            k = dfs0(e, d + 1, v)
            if k:
                if isinstance(k, int) and k // 2 == d:
                    return v, e
                return k
    return 0

def dfs1(v, p):
    if v == E:
        return 0
    cnt = 1
    for e in es[v]:
        if e != p:
            cnt += dfs1(e, v)
    return cnt

def dfs2(v, p):
    if v == 0:
        return 0
    cnt = 1
    for e in es[v]:
        if e != p:
            cnt += dfs2(e, v)
    return cnt
V, E = dfs0(0, 0, -1)
if  2*dfs1(0, -1) > n:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 177056
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int n, k;
int sum[4005][4005], b[2005][2005];
 
int calc(int x, int y){
	return sum[y+k][x+k] - sum[y+k][x] - sum[y][x+k] + sum[y][x];
}
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	rep(i,n){
		int x, y;
		char c;
		cin >> x >> y >> c;
		if(c == 'W') x += k;
		x %= 2*k;
		y %= 2*k;
		b[y][x]++;
	}
	rep(i,4*k)rep(j,4*k) sum[i][j] = b[i%(2*k)][j%(2*k)];
	rep(i,4*k){
		for(int j = 1; j < 4*k; ++j){
			sum[i][j] += sum[i][j-1];
		}
	}
	for(int i = 1; i < 4*k; ++i){
		rep(j,4*k){
			sum[i][j] += sum[i-1][j];
		}
	}
	int ans = 0;
	rep(i,2*k)rep(j,2*k){
		int score = calc(j, i) + calc(j + k, i + k);
		chmax(ans, score);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 81828
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

vector<Int> A;
Int dfs(Int i){
  static _int used[200010], mem[200010];
  if(i + 1 == (Int)A.size()) return 0;
  if(used[i]++) return mem[i];
  if(A[i] < A[i+1]) return mem[i] = 1 + dfs(i + 1);
  return mem[i] = 0;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;
  A.resize(N);
  cin>>A;


  set<Int> S;
  for(Int i=0;i<K;i++) S.insert(A[i]);

  Int ans = 1;
  Int f = 0;
  for(Int i=K;i<N;i++){
    S.erase(A[i - K]);
    S.insert(A[i]);
    if(S.lower_bound(A[i]) != (--S.end())) ans++;
    else if(S.lower_bound(A[i - K]) != S.begin()){
      ans++;
      if(f && dfs(i-K + 1) + 1 >= K) ans --;
    }
    if(dfs(i - K + 1) + 1 >= K) f = 1;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 15744
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n+1, 0);
  for(int i=0;i<m;i++) {
    int ai, bi;
    cin >> ai >> bi;
    v[ai]++;
    v[bi]++;
  }
  bool ok = true;
  for(int i=0;i<n+1;i++) {
    if(v[i] == 0) continue;
    if(v[i] % 2) {
      ok = false;
      break;
    }
  }
  if(ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;


}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=3005;
ll dp[N][N],vis[N][N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s,t;cin>>s>>t;
    ll n=s.size(),m=t.size();
    s="$"+s;
    t="$"+t;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1,vis[i][j]=1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string ans="";
    for(ll x=n,y=m;x>0 && y>0;){
        if(vis[x][y])ans+=s[x],x--,y--;
        else if(dp[x-1][y]==dp[x][y])x--;
        else y--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

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

int main() {

	string s, t; cin >> s >> t;
	vector<string> ans;
	int ns = s.size();
	int nt = t.size();
	for (int start = 0; start < ns - nt + 1; start++) {
		bool ok = true;
		for (int i = 0; i < nt; i++) {
			if (s[start + i] == '?') {
				continue;
			}
			if (s[start + i] != t[i]) {
				ok = false;
			}
		}
		if (ok) {
			string z = s;
			for (int j = 0; j < nt; j++) {
				z[start + j] = t[j];
			}
			for (int j = 0; j < ns; j++) {
				if (z[j] == '?') z[j] = 'a';
			}
			ans.push_back(z);
		}
	}
	sort(ans.begin(), ans.end());
	if (ans.size() != 0) cout << ans[0] << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
from collections import *

def bfs(s):
    visited[s] = True
    q = deque([s])
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if not visited[nv]:
                visited[nv] = True
                dist[nv] = dist[v]+w
                q.append(nv)
            else:
                if dist[nv]!=dist[v]+w:
                    return False
    
    return True

N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append((R-1, D))
    G[R-1].append((L-1, -D))

visited = [False]*N
dist = [0]*N
flag = True

for i in range(N):
    if not visited[i]:
        flag &= bfs(i)

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 74416
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <complex>

#define MAX_N 1000001
#define INF 987654321
using namespace std;
typedef long long lld;
typedef unsigned long long llu;

int main(){

	int n;
	cin>>n;

	string str;
	cin>>str;

	char last=str[0];
	int ans=1;
	for (int i = 1; i < str.length(); ++i)
	{
		/* code */
		if(last!=str[i]){
			ans++;
		}

		last=str[i];
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void go();
int main() {
#ifdef tokitsukaze
    freopen("TEST.txt", "r", stdin);
#endif
    go();
    return 0;
}

/*********************************  head  *********************************/

map<int,int> ac,wa;
int n,m;
int ans=0,acc=0;
string str;
int num;
void go() {
    cin>>n>>m;
    while(m--){
        cin>>num>>str;
        if(str[0]=='A'){if(!ac[num])acc++;ac[num]=1;}
        else{
            if(!ac[num]){
                wa[num]++;
            }
        }
    }
    map<int,int>::iterator it=wa.begin();
    while(it!=wa.end()){
        if(ac[it->first])ans+=it->second;
        it++;
    }
    cout<<acc<<" "<<ans<<endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if (K > 0) {
    ll x = min(A, K);
    ans += x;
    K -= x;
  }
  if (K > 0) {
    ll x = min(B, K);
    K -= x;
  }
  if (K > 0) {
    ll x = min(C, K);
    ans -= x;
    K -= x;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
struct P
{
  int to,cap,rev;
  P(int to=-1,int cap=-1,int rev=-1):to(to),cap(cap),rev(rev){}
};
typedef vector<int> VI;
typedef vector<P> VP;
typedef vector<VP> VVP;
typedef pair<int,int> Pes;
int N,M,s,t;
VVP G;
vector<int> level,iter;
vector<Pes> vec;
vector<int> pvec;
bool sign;
 
void add_edge(int from,int to,int i)
{
  if(sign)vec.push_back(Pes(from,G[from].size())),
        pvec.push_back(i);
  G[from].push_back(P(to,1,G[to].size()));
  G[to].push_back(P(from,0,G[from].size()-1));
}
 
void bfs()
{
  deque<int> deq;
  deq.push_back(s);
  level[s] = 0;
  while(!deq.empty())
    {
      int p = deq.front(); deq.pop_front();
      rep(i,G[p].size())
    {
      P pes = G[p][i];
      int v = pes.to;
      if(level[v] == -1 && pes.cap > 0)
        {
          level[v] = level[p]+1;
          deq.push_back(v);
        }
    }
    }
}
 
int dfs(int v,int flow)
{
  if(v == t)return flow;
 
  for(int &i = iter[v];i < G[v].size();i++)
    {
      P p = G[v][i];
 
      if(p.cap <= 0)continue;
      if(level[v] < level[p.to])
    {
      int d = dfs(p.to,min(flow,p.cap));
      if(d <= 0)continue;
      G[v][i].cap -= d;
      G[p.to][p.rev].cap += d;
      return d;
         
    }
    }
  return 0;
}
 
int maximum_flow()
{
  int res = 0;
  iter.resize(N);
  level.resize(N);
  while(1)
    {
      rep(i,N)
    iter[i] = 0,level[i] = -1;
       bfs();
       
       if(level[t] < 0)return res;
       int f;
   
       while((f = dfs(s,(1<<29))) > 0)
     res += f;
      
    }
  return res;
}
 
int main()
{
  cin >> N >> M;
  G.resize(N);
  rep(i,M)
    {
      int from,to;
      cin >> from >> to;
      from--,to--;
      sign = false;
      add_edge(from,to,i);
      sign = true;
      add_edge(to,from,i);
    }
  cin >> s >> t;
  s--,t--;
   
  int mexico = maximum_flow();
  int cnt = 0;
  rep(i,vec.size())
    {
      int p1 = vec[i].first,p2= vec[i].second;
      if(G[p1][p2].cap != 1)cnt++;
    }
 
  cout << mexico << endl;
  cout << cnt << endl;
  rep(i,vec.size())
    {
      int p1 = vec[i].first,p2= vec[i].second;
      if(G[p1][p2].cap != 1)
    cout << pvec[i]+1  << endl;
    }
 
  return 0;
}

Measured memory_bytes: 1332
#include <cstdio>
#include <iostream>
#include <cstring>
#define oo 1e17
#define N 100005
#define ll long long
#define F(i,j,k) for(int i=(j);i<=(k);++i)
#define D(i,j,k) for(int i=(j);i>=(k);--i)
using namespace std;
char op[N];
int n,mx;
ll a[N],ans,dp[N][3];
int main(){
	//freopen("txt.in","r",stdin);freopen("txt.out","w",stdout);
	scanf("%d\n",&n);
	scanf("%lld ",&a[0]);F(i,1,n-1)scanf("%c %lld ",&op[i],&a[i]);
	ans=-oo;
	memset(dp,-0x7f,sizeof(dp));
	dp[0][0]=0;
	//F(i,0,n-1)printf("%d %lld %lld %lld\n",i,dp[i][0],dp[i][1],dp[i][2]);
	F(i,1,n-1){
		if(op[i]=='+'){
			dp[i][2]=dp[i-1][2]+a[i];
			dp[i][1]=max(dp[i-1][1]-a[i],dp[i][2]);
			dp[i][0]=max(dp[i-1][0]+a[i],dp[i][1]);
		}
		else{
			dp[i][2]=max(dp[i-1][2]-a[i],dp[i-1][1]+a[i]);
			//printf("%d %lld %lld %lld\n",i,dp[i-1][2]-a[i],dp[i-1][1]+a[i],dp[i][2]);
			dp[i][1]=max(max(dp[i-1][1]+a[i],dp[i-1][0]-a[i]),dp[i][2]);
			dp[i][0]=max(dp[i-1][0]-a[i],dp[i][1]);
		}
		//printf("%d %lld %lld %lld\n",i,dp[i][0],dp[i][1],dp[i][2]);
	}
	ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
	printf("%lld\n",ans+a[0]);
	return 0;
} 

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MAX=50000;
ll a,b,d;

int main(){
  while(1){
    cin>>a>>b>>d;
    if(a==0&&b==0&&d==0)break;
    ll A=MAX,B=MAX;
    for(ll I=-MAX;I<=MAX;I++){
      ll dist=abs(d-a*I);
      if(dist%b!=0)continue;
      ll i=abs(I);
      ll j=dist/b;
      if(i+j<A+B){
	A=i;
	B=j;
      }else if(i+j==A+B){
	if(a*i+b*j<A*a+B*b){
	  A=i;
	  B=j;
	}
      }
    }
    if(A==MAX&&B==MAX)cout<<"no solution"<<endl;
    else cout<<A<<' '<<B<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a, b, c = 0;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        int count = 0;

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

        System.out.println(count);

    }

}



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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++) cin >> x[i];
  int ans = 1e9;
  for (int i = 0; i < N - K + 1; i++) {
    ans = min(ans, abs(x[i]) + abs(x[i + K - 1] - x[i]));
    ans = min(ans, abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		long T = Long.parseLong(str[1]);

		long t[] = new long[n];
		str = br.readLine().split(" ");

		for (int i = 0; i < n; i++) {
			t[i] = Long.parseLong(str[i]);
		}

		long sum = 0;
		long ans = 0;
		for (int i = 0; i < n - 1; i++) {
			long diff = t[i + 1] - t[i];

			if (diff < T) {
				sum += diff;
			} else {
				ans += sum + T;
				sum = 0;
			}
		}
		ans += sum + T;

		System.out.println(ans);
	}
}


Measured memory_bytes: 60896
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        a: [u32;n]
    }
    let res = a.iter().all(|a| {
        if a % 2 == 0 {
            a % 3 == 0 || a % 5 == 0
        } else {
            true
        }
    });
    println!("{}", if res {"APPROVED"} else {"DENIED"});
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
use std::io::stdin;

fn read_int() -> i32 {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().parse().unwrap()
}

fn main () {
    let n = read_int();
    let mut ans = "No";

    for four in 0..30 {
        for seven in 0..30 {
            if four * 4 + seven * 7 == n {
                ans = "Yes";
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define P ((int)1e9+7)
#define N 1048576

int dp[N];

int main()
{
    int n,m;
    scanf("%d%d", &n, &m);
    dp[0] = 1, dp[1] = m-n;
    for(int i=2;i<=n;++i)
        dp[i] = ((lli)dp[i-1] * (i+m-n-1) + (lli)dp[i-2] * (i-1)) % P;
    int ans = dp[n];
    for(int i=0;i<n;++i)
        ans = (lli)ans * (m-i) % P;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
int n,m,x,cnt;
/**/
int main()
{
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    read(n);read(m);
    for(int i=1;i<=n;i++)
    {
        read(x);
        if(x>=m) cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vl a(n),f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];

  sort(rng(f));
  sort(rng(a),greater<ll>());
  ll l = -1, r = f.back()*a[0]+1;
  ll ans = 1e18;
  while(r-l>1){
    ll tmp = 0;
    ll mid = l+(r-l)/2;
    rep(i,n){
      ll x = mid/f[i];
      tmp+=max(0LL,a[i]-x);
    }
    if(tmp>k){
      l = mid;
    }
    else{
      r = mid;
      mins(ans,r);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

typedef struct {
  double x, y;
} Point;

void print(Point p){ printf("%.8f %.8f\n", p.x, p.y); }

void plot(int n, Point p1, Point p2)
{
  Point s, t, u;
  double th = 60.0*(acos(-1)/180.0);
  if ( n == 0 ) return;
  s.x = (2.0 * p1.x + 1.0 * p2.x)/3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y)/3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x)/3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y)/3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y ) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y ) * cos(th) + s.y;
  
  plot(n-1, p1, s);
  print(s);
  plot(n-1, s, u);
  print(u);
  plot(n-1, u, t);
  print(t);
  plot(n-1, t, p2);
}

main(){
  Point p1, p2;
  int n;
  scanf("%d", &n);

  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  print(p1);
  plot(n, p1, p2);
  print(p2);

  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

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


// void solve()
// {
//     ll r;
//     cin>>r;
//     // cout<<r<<"\n";
//     ld ans=2.0*3.14159*r;
//     cout<<ans<<"\n"; 
// }

// void solve()
// {
//     ll n,m;
//     cin>>m>>n;
//     ll i;
//     ll a[n];
//     ll sum=0;
//     for(i=0;i<n;i++)
//     {
//         cin>>a[i];
//         sum+=a[i];
//     }
//     if(sum>m)
//     {
//         cout<<"-1\n";
//     }
//     else{
//         cout<<m-sum<<"\n";
//     }
// }


// void solve()
// {
//    ll n;
//    cin>>n;
//    vll v[n];
//    ll i;
//    ll x,y;
//    for(i=0;i<n-1;i++)
//    {
//        cin>>x;
//        x--;
//        v[x].pb(i);
//    }

//    for(auto it:v)
//    {
//        cout<<sz(it)<<"\n";
//    }
// }

void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i;
    ll suf[n+2];
    suf[n+1]=0;
    for(i=n;i>=0;i--)
    {
        if(i==n)suf[i]=i;
        else{
           suf[i]=suf[i+1]+i;
        }
    }
    ll maxi=0;
    ll res=0;
    for(i=k;i<=n+1;i++)
    {
        ll no=suf[n+1-i];
        ll minsum=(i*(i-1))/2;
        // cout<<i<<" "<<no<<" "<<minsum<<"\n";
        res+=no-minsum+1;
        res%=mod;
        // maxi=max(maxi,)
    }
    cout<<res%mod<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 0)
    {
        if (string(s.begin(), s.begin() + n / 2) == string(s.begin() + n / 2, s.end()))
        {
            Yes;
            return;
        }
    }
    No;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if (a[0] == a[1]) cout << a[2] << endl;
  else cout << a[0] << endl;
}

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



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

	int x;
	cin >> x;
	cout << (x < 1200 ? "ABC" : "ARC") << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int main()
{
	int n, s; cin>>n>>s;
	ll dp[3030][3030]={};
	dp[0][0]=1;
	ll p2=(MOD+1)/2;
	int a[3030];
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++){
		for(int j=0; j<=s; j++){
			(dp[i+1][j]+=dp[i][j])%=MOD;
			if(j+a[i]<=s){
				(dp[i+1][j+a[i]]+=dp[i][j]*p2)%=MOD;
			}
		}
	}
	ll ans=dp[n][s];
	for(int i=0; i<n; i++) (ans*=2)%=MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 75368
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
struct node
{
    string name;
    int sco;
    int pos;
}a[105];
int cmp(node a,node b)
{
    if(a.name==b.name)
    {
        return a.sco>b.sco;
    }
    else return a.name<b.name;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].name;
        scanf("%d",&a[i].sco);
        a[i].pos=i;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        printf("%d\n",a[i].pos);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void bubbleSort(int A[],int N);

int count=0;

int main()
{

  int i;
  int A[100],N;

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

  bubbleSort(A,N);

  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",count);

  return 0;
 }

void bubbleSort(int A[],int N)
{
  int i,j,temp;

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	count++;
      }
    }
  }
 

}

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    
    for(int i=1; i <= s.length(); i++){
	if(s[i-1] == s[i]){
	    ans++;
	    if(s[i] == '0'){
	    	s[i] = '1';
	    }
	    else{
	    	s[i] = '0';
	    }
	}
    }
    cout << ans << endl;
 }


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			n /= 4;
			int count = 0;
			for(int i = 0;i < n;i++){
				count += scan.nextInt();
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18244
from math import fabs
x,y = map(int, input().split())
if y >= x >= 0: 
    print(int(fabs(y-x)))
elif 0 >= y >= x:
    print(int(fabs(y-x))) 
elif x > y > 0: 
    print(int(x - y + 2))
elif 0 > x > y:
    print(int(x - y + 2)) 
else:
    print(int(fabs(fabs(x)-fabs(y)) + 1))

Measured memory_bytes: 9140
#include<stdio.h>

#define MAX 500000

void maxHeapify(int *,int);
void buildMaxHeap(int *A);

int H;

int main()
{
  int A[MAX],i;

  scanf("%d",&H);

  for(i = 1 ; i <= H ; i++)
    {
      scanf("%d",&A[i]);
    }

  buildMaxHeap(A);

  for(i = 1 ; i <= H ; i++)
    {
      printf(" %d",A[i]);
    }

  printf("\n");
  
  return 0;
}

void maxHeapify(int *A,int i)
{
  int l,r,largest,change;

  l = 2*i; //left
  r = 2*i+1; //right

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i)
    {
      change = A[i];
      A[i] = A[largest];
      A[largest] = change;
      
      maxHeapify(A,largest);
    }
  
  return;
}

void buildMaxHeap(int *A)
{
  int i;
  for(i = H/2 ; i > 0 ; i--)
    {
      maxHeapify(A,i);
    }

  return;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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;}

template<typename T>
vector<T> dijkstra(int s,vector<vector<pair<int,T>>> &G){
    const T TINF=numeric_limits<T>::max();
    using P=pair<T,int>;
    int n=G.size();
    vector<T> d(n,TINF);
    vector<int> b(n,-1);//previous point
    priority_queue<P,vector<P>,greater<P>> q;
    d[s]=0;
    q.emplace(d[s],s);
    while(!q.empty()){
        P p=q.top();q.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(auto& e:G[v]){
            int u=e.first;
            T c=e.second;
            if(d[u]>d[v]+c){
                d[u]=d[v]+c;
                b[u]=v;
                q.emplace(d[u],u);
            }
        }
    }
    return d;
}

struct edge{
    ll u,v,a,b;
    edge(int u,int v,ll a,ll b):u(u),v(v),a(a),b(b){}
    edge(){}
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,m,s;cin>>n>>m>>s;
    vector<edge> vec;
    rep(i,m){
        ll u,v,a,b;cin>>u>>v>>a>>b;u--,v--;
        vec.push_back(edge(u,v,a,b));
    }
    vector<pair<ll,ll>> c(n);
    rep(i,n){
        cin>>c[i].first>>c[i].second;
    }

    vector<vector<pair<int,ll>>> g(n*3000);
    rep(i,n){
        for(int j=0;j+c[i].first<3000;j++){
            g[i*3000+j].push_back(make_pair(i*3000+j+c[i].first,c[i].second));
        }
    }

    for(auto &e:vec){
        for(ll j=3000-1;j-e.a>=0;j--){
            g[e.u*3000+j].push_back(make_pair(e.v*3000+j-e.a,e.b));
            g[e.v*3000+j].push_back(make_pair(e.u*3000+j-e.a,e.b));
        }
    }

    auto dis=dijkstra(min(s,2999ll),g);
    for(int i=1;i<n;i++){
        ll cost=LINF;
        for(int j=3000*i;j<3000*(i+1);j++){
            chmin(cost,dis[j]);
        }
        cout<<cost<<endl;
    }
    return 0;
}


Measured memory_bytes: 28572
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max({
        a*c,a*d,b*c,b*d
    });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
N = int(input())
c = [0]
a = list(map(int, input().split()))
b = [0 for _ in range(N + 1)]

d = c + a

for i in range(N, 0, -1):
    s = 0
    for j in range(2 * i, N + 1, i):
        s ^= b[j]

    b[i] = (s ^ d[i])

# print(b)
print(b.count(1) if b.count(1) else 0)
for i in range(1, len(b)):
    if b[i] != 0:
        print(i, end=' ')

Measured memory_bytes: 72412
S=int(input())
if S//100>=13 or S//100==0:
  if 1<=S%100<=12:
    print("YYMM")
  else:print("NA")
if 1<=S//100<=12:
  if S%100>=13 or S%100==0:
    print("MMYY")
  else:print("AMBIGUOUS")

Measured memory_bytes: 3060