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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int s;
	cin >> s;

	int h = s / 3600;
	int m = (s - 3600 * h) / 60;
	int s_ = (s - 3600 * h) % 60;
	cout << h << ":" << m << ":" << s_ << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}
int solve(int h,int* a,int*  c,int n,vector<vector<int>>& dp)
{
	if(h<=0)
	{
		return 0;
	}
	if(n==0)
	{
		return INT_MAX;
	}
	if(dp[h][n]!=-1)
	{
		return dp[h][n];
	}
	//int ans=c[0]+solve(h-a[0],a+1,c+1);
	int ans=solve(h,a+1,c+1,n-1,dp);
	ans=min(ans,c[0]+solve(h-a[0],a,c,n,dp));
	ans=min(ans,c[0]+solve(h-a[0],a+1,c+1,n-1,dp));
	dp[h][n]=ans;
	return ans;
}
int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int h,n;
	cin>>h>>n;
	int* a=new int[n];
	int* c=new int[n];
	vector<vector<int>> dp(h+2,vector<int>(n+2,-1));
	for(int i=0;i<n;i++)cin>>a[i]>>c[i];
	cout<<solve(h,a,c,n,dp)<<endl;;
	return 0;
}













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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


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

    vector<pair<int, int>> v = {{200,  380},
                                {1000, 1520},
                                {300,  550},
                                {1200, 1870},
                                {500,  850},
                                {1500, 2244}};
    vector<int> dp(5001, INT_MAX);
    dp[0] = 0;

    FOR(i, 0, dp.size()) {
        FOE(p, v) {
            if (dp[i] != INT_MAX and i + p.first < dp.size()) {
                dp[i + p.first] = min(dp[i + p.first], dp[i] + p.second);
            }
        }
    }

    while (true) {
        int n;
        cin >> n;
        if (n == 0) { break; }
        print(dp[n]);
    }

}




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

int main() {
    int N;
    string S, T;
    cin >> N >> S >> T;

    for (int i = 0; i < N; i++) {
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

struct point {
    int x,y;
};
int main() {
    int w,h,n; cin >> w >> h >> n;
    vector<point> p(n);
    vector<int> a(n);
    rep(i,n) {
        cin >> p[i].x >> p[i].y >> a[i];
    }
    vector<string> b(h);
    rep(i,h) {
        b[i].resize(w);
        rep(j,w) b[i][j]='.';
    }
    /*
    rep(i,h) {
        cout << b[i] << endl;
    }
    */
    rep(i,n) {
        switch (a[i]) {
        case 1:
            rep(y,h) {
                for (int x = 0; x < p[i].x; x++)
                {
                    b[y][x] = '#';
                }
            }
            break;
        
        case 2:
            rep(y,h) {
                for (int x = p[i].x; x < w; x++)
                {
                    b[y][x] = '#';
                }
            }
            break;

        case 3:
            rep(x,w) {
                for (int y = 0; y < p[i].y; y++)
                {
                    b[y][x] = '#';
                }
            }
            break;

        case 4:
            rep(x,w) {
                for (int y = p[i].y; y < h; y++)
                {
                    b[y][x] = '#';
                }
            }
            break;

        default:
            break;
        }
    }
    /*
    rep(i,h) {
        cout << b[i] << endl;
    }
    */
    int ans = 0;
    rep(i,h) {
        rep(j,w) {
            if (b[i][j] == '.')
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
 
using namespace std;
typedef long long llint;
 
const int maxn = 2e5+10;
const int base = 31337;
const llint mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
llint niz[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", niz+i);

	llint sum = 0;
	llint sol = 0;
	for (int i = 0; i < n; i++) {
		sol += (niz[i] * sum) % mod;
		sol %= mod;
		sum += niz[i], sum %= mod;
	}
	printf("%lld\n", sol);
	return 0;
}

Measured memory_bytes: 5284
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
    };

    let mut a = a;
    let mut b = b;
    let mut ret = 0;
    if a > b {
        ret += a;
        a -= 1;
    } else {
        ret += b;
        b -= 1;
    }
    if a > b {
        ret += a;
        a -= 1;
    } else {
        ret += b;
        b -= 1;
    }

    println!("{:?}", ret);

}



Measured memory_bytes: 4476
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n, c;
  cin >> n >> c;
  vl x(n), v(n);
  rep(i, n) { cin >> x[i] >> v[i]; }
  vl cw(n), ccw(n);
  cw[0] = v[0] - x[0];
  ccw[n - 1] = v[n - 1] - (c - x[n - 1]);
  REP(i, 1, n) {
    cw[i] = cw[i - 1] + v[i] - (x[i] - x[i - 1]);
    ccw[n - 1 - i] = ccw[n - i] + v[n - 1 - i] - (x[n - i] - x[n - 1 - i]);
  }

  // cw -> ccw
  ll ans = 0;
  multiset<ll, greater<ll>> st_cw, st_ccw;
  rep(i, n) {
    st_cw.insert(cw[i]);
    st_ccw.insert(ccw[i]);
  }
  ll cur = 0;
  rep(i, n) {
    st_ccw.erase(st_ccw.find(ccw[i]));
    ans = max(ans, cw[i]);
    // cout << cw[i] << endl;
    if (st_ccw.size() > 0) {
      ans = max(ans, cw[i] - x[i] + *(st_ccw.begin()));
    }
  }
  cur = 0;
  for (int i = n - 1; i >= 0; i--) {
    st_cw.erase(st_cw.find(cw[i]));
    ans = max(ans, ccw[i]);
    if (st_cw.size() > 0) {
      ans = max(ans, ccw[i] - (c - x[i]) + *(st_cw.begin()));
    }
  }

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


Measured memory_bytes: 12800
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int inf = 2e9 + 20 ;
int a , b , ans ;

inline int get (int a , int b) {
	if (a > b) return inf ;
	return b - a ;
}

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

	cin >> a >> b ;

	cout << min(min(get(a , b) , get(-a , b) + 1) , min(get(a , -b) + 1 , get(-a , -b) + 2)) << '\n' ;
}

Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define pb push_back

#define fi first
#define se second


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)

#define repeach(i, a) for(auto i: a)


#define endl '\n'


typedef pair<int, int> pii;

typedef vector< pii > vpii;


class Solution {
public:
    const int static MAX = 1e5 + 5;
    vpii adj[MAX];
    int color[MAX];

    void dfs(int from, int par) {
        repeach(to, adj[from]) {
            if (to.fi != par) {
                if (to.se % 2) color[to.fi] = 1 - color[from];
                else color[to.fi] = color[from];
                dfs(to.fi, from);
            }
        }
    }

    void solve(std::istream& in, std::ostream& out) {
		int n, x, y, w;
        in >> n;
        rep(i, 1, n, 1) {
            in >> x >> y >> w;
            adj[x].pb({y, w});
            adj[y].pb({x, w});
        }
        dfs(1, 1);
        rep(i, 1, n+1, 1) out << color[i] << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 7680
S = input()
 
mods = [0 for _ in range(2019)]
mods[0] = 1
t = 0
mod10 = 1
for s in reversed(S):
    t += int(s) * mod10
    t = t % 2019
    mod10 *= 10
    mod10 %= 2019
    mods[t] += 1

cnt = sum([m*(m-1)/2 for m in mods])
print(int(cnt))


Measured memory_bytes: 9308
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int a[59],b[59],c[59],d[59];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;
    cin>>N>>M;
    
    rep(i,N) cin>>a[i]>>b[i];
    rep(i,M) cin>>c[i]>>d[i];
    
    rep(i,N){
        int best, mn=INF;
        rep(j,M){
            int x=abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(x<mn){
                mn=x;
                best=j;
            }
        }
        cout1(best+1);
    }
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    int A,B;
    cin >> A >> B;

    int ans = 0;

    rep(i,2){

        if(A>B){
            ans+=A;
            A--;
        }else{
            ans+=B;
            B--;
        }
    }

    show(ans);
    return 0;
}


Measured memory_bytes: 256
# B - Time Limit Exceeded
N, T = map(int, input().split())
CMINMAX = 10000 #>1000
cmin = CMINMAX
for n in range(N):
    c, t = map(int, input().split())
    if(t <= T):
        if(c < cmin):
            cmin = c

if(cmin == CMINMAX):
    print("TLE")
else:
    print(cmin)


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

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

template <typename T>
class FenwickTree
{
    int n;
    std::vector<T> bit;

  public:
    FenwickTree(int _n) : n(_n), bit(_n, 0) {}

    void add(int pos, const T &w)
    {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1)
            bit[i] += w;
    }
    // v[0] + ... + v[pos-1]
    T sum(int pos)
    {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    T sum(int l, int r)
    {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
};

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>

typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN 16
#define INF (1 << 30)


int n, m, x;
int a[MAXN][MAXN];
int c[MAXN];

bool ok(int mask) {
	vector<int> v;
	for (int i = 0; i < m; i++) {
		v.push_back(0);
	}
	for (int i = 0; i < n; i++) {
		if (mask & (1 << i)) {
			for (int j = 0; j < m; j++) {
				v[j] += a[i][j];
			}
		}
	}
	bool ret = true;
	for (int i = 0; i < m; i++) {
		if (v[i] < x) {
			ret = false;
			break;
		}
	}
	return ret;
}

int score(int mask) {
	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (mask & (1 << i)) {
			ret += c[i];
		}
	}
	return ret;
}

int main() {
	
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int best = INF;
	for (int mask = 0; mask < (1 << n); mask++) {		
		if (ok(mask) && (score(mask) < best)) {
			best = score(mask);
		}
	}

	if (best != INF) {
		cout << best;
	} else {
		cout << "-1";
	}

	return 0;
}


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

int main(){
  int n;
  cin>>n;
  map<string,int>mp;
  rep(i,n){
    string s; cin>>s;
    mp[s]++;
  }
  int mx=0;
  for(auto&p:mp){
    mx=max(mx,p.second);
  }
  for(auto&p:mp){
    if(p.second==mx)cout<<p.first<<endl;
  }
}

Measured memory_bytes: 19092
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    if s <= "2019/04/30".to_string() {
        println!("Heisei")
    } else {
        println!("TBD")
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t; cin >> s >> t;
    int n = (int) s.size();
    int tz = (int) t.size();
    int i = n - 1;
    bool ok = 0;
    while (i >= tz - 1) {
        ok = 1;
        for (int it = i, j = tz - 1; j >= 0; it--, j--) {
            if (s[it] != '?' && s[it] != t[j]) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            for (int it = i, j = tz - 1; j >= 0; it--, j--) {
                s[it] = t[j];
            }
            break;
        }
        i--;
    }
    if (ok) {
        for (auto c : s) {
            if(c == '?') {
                cout << 'a';
            } else {
                cout << c;
            }
        }
    } else {
        cout << "UNRESTORABLE";
    }

    return 0;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
const int MOD = 1000000007;

int H, W, K;
vector<string> cell;
int tot;

void solve(int y, int x,int b_counter,int f) {
    if(b_counter == K && f) {
        // cout << "bingo" << endl;
        tot++;
        f = 0;
    }
    //getchar();
    if(x == W || b_counter < K) {
        return ;
    }
    if(y == H) {
        solve(y, x + 1, b_counter, f);
        string tmp = "";
        for(int i = 0;i < H;i++) {
            tmp += cell[i][x];
        }
        int rem = 0;
        for(int i = 0;i < H;i++) {
            if(cell[i][x] == '#') {
                rem++;
            }
            cell[i][x] = '.';
        }
        solve(y, x + 1, b_counter - rem, 1);
        for(int i = 0;i < H;i++) {
            cell[i][x] = tmp[i];
        }
    } else {
        solve(y + 1, x, b_counter, f);
        string tmp = cell[y];
        int rem = 0;
        for(int j = 0;j < W;j++) {
            if(cell[y][j] == '#') {
                rem++;
            }
            cell[y][j] = '.';
        }
        solve(y + 1, x, b_counter - rem, 1);
        cell[y] = tmp;
    }
}

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

    cin >> H >> W >> K;
    cell = getVector<string>(H);
    int b_counter = 0;
    for(int i = 0;i < H;i++) {
        cin >> cell[i];
        for(int j = 0;j < W;j++) {
            if(cell[i][j] == '#') b_counter++;
        }
    }

    solve(0, 0, b_counter, 1);

    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 3652
def main():
    S = input()
    N = len(S)
    MOD = 10 ** 9 + 7
    dp = [[0] * 13 for _ in range(N + 5)]
    dp[0][0] = 1

    for i in range(N):
        if S[i] != '?':
            for j in range(13):
                dp[i+1][(j * 10 + int(S[i]))%13] += dp[i][j]
                dp[i+1][(j * 10 + int(S[i]))%13] %= MOD
        else:
            for k in range(10):
                for j in range(13):
                    dp[i+1][(j * 10 + k)%13] += dp[i][j]
                    dp[i+1][(j * 10 + k)%13] %= MOD

    print(dp[N][5])

    

if __name__ == "__main__":
    main()

Measured memory_bytes: 61916
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    if (x >= a && (a + b) >= x) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e6+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
string s,t;
bool check(lld id)
{
  lld i=id,j=0;
  if(id+t.size()>s.size())return false;
  while(i<s.size()&&j<t.size())
  {
    if(s[i]!='?'&&s[i]!=t[j])return false;
    dg3(s[i],t[j],id);
    i++;
    j++;
  }
  return true;
}
int main()
{
      lld i,j;
        cin>>s>>t;
        n=s.size();
        down(n-1,-1,i)
        {
          if(check(i))
          {
            dg(i);
            j=0;
            while(j<i)
            {
              if(s[j]=='?')s[j]='a';
              j++;
            }
            j=0;
            while(j<t.size())
            {
              s[i]=t[j];
              i++;
              j++;
            }
            j=i;
            dg(i);
            while(j<s.size())
            {
              if(s[j]=='?')s[j]='a';
              j++;
            }
            cout<<s<<endl;
            return 0;
          }
        }
        cout<<"UNRESTORABLE\n";
        return 0;
}

Measured memory_bytes: 23680
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,m) = {
        let t =read_vec::<i64>();
        (t[0],t[1])
    };
    let mut v = vec![];
    for _ in 0..m{
        let t =read_vec::<i64>();
        let t:Vec<i64> = t[1..].into_iter().map(|&x| x).collect();
        v.push(t);
    }
    let pm = read_vec::<i64>();
    let mut ans =0;
    for bit in 0..(1<<n) {
        let mut  line =vec![0;n as usize];
        for j in 0..n {
            if (bit&(1<<j) !=0 ){
                line[j as usize] = 1;
            }
        }
        let mut flag = true;
        let mut index= 0;

        for sn in &v{
            let mut sum =0;
            for s in sn{
                if line[(*s-1) as usize] == 1 {
                    sum += 1;
                }
            }
            if sum % 2 != pm[index] {
                flag = false;
            }
            index+=1;
        }
        if flag {
            ans +=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define  p push_back
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define MOD 1000000009
#define babo ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
	babo
      float d,t,s;
  cin>>d>>t>>s;
  float j=d/s;
  if(j<=t)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}
  

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

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k,q;
  cin>>n>>k>>q;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  vector<Int> b(a);
  sort(b.begin(),b.end());
  b.erase(unique(b.begin(),b.end()),b.end());

  Int ans=1e9;
  for(Int x:b){
    vector<Int> c;
    c.reserve(2001);
    for(Int i=0;i<n;i++){
      if(a[i]<x) continue;
      Int j=i;
      while(j<n&&a[j]>=x) j++;
      if(j-i<k){
	i=j-1;
	continue;
      }
      vector<Int> d(j-i);
      for(Int y=i;y<j;y++) d[y-i]=a[y];
      sort(d.begin(),d.end());
      for(Int y=0;y<=(j-i)-k;y++) c.emplace_back(d[y]);
      i=j-1;
    }
    if(q>(Int)c.size()) break;
    sort(c.begin(),c.end());
    chmin(ans,c[q-1]-c[0]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  string s; int t;
  vector<string>S;
  vector<int>T(N,0);
  for(int i=0; i<N; i++){
    cin>>s>>t;
    S.push_back(s);
    T[i]=t; 
  }
  cin>>s;
  int z;
  for(int i=0; i<N; i++){
    if(s==S[i]){
      z=i;
      break;
    }
  }
  int ans=0;
  for(int i=z+1; i<N; i++){
    ans+=T[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    m = 0
    for i in range(N-1):
        m = max(A[i+1] - A[i], m)
    m = max(K-A[N-1] + A[0], m)
    print(K-m)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26228
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double Mangle = (m*360.0)/60.0;

		double Hangle = (h*60.0+m)*360.0/(12.0*60.0);

		double MHangle = 0;
		if(Hangle-Mangle>180) {
			MHangle = 360-(Hangle-Mangle);
		}else {
			MHangle = Hangle-Mangle;
		}
		double cosA = Math.cos(MHangle*(Math.PI/180));
 		

		double answer = (a*a)+(b*b)-(2*a*b*cosA);
		double ans = Math.sqrt(answer);
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 36448
m,n = map(int,input().split())
seat = [list(input()) for i in range(m)]
dummy = ["0" for i in range(n+2)]
for i in range(m):
    seat[i].insert(0,"0")
    seat[i].append("0")
seat.insert(0,dummy)
seat.append(dummy)

for i in range(1,m + 1):
    for j in range(1,n + 1):
        if seat[i][j] == "o":
            if seat[i][j - 1] == "-":
                seat[i][j - 1] = "0"
            if seat[i][j + 1] == "-":
                seat[i][j + 1] = "0"
        elif seat[i][j] == "x":
            for k in range(3):
                for l in range(3):
                    if seat[i - 1 + k][j - 1 + l] == "-":
                        seat[i - 1 + k][j - 1 + l] = "0"

for i in range(n + 1):
    if seat[1][i] == "-":
        seat[1][i] = "0"

count = 0
for i in seat:
    for j in i:
        if j == "-":
            count += 1

print (count)

Measured memory_bytes: 7896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

void Warshall_Floyd(Matrix<ll> &g)
{
    ll INF = infll;
    int N = g.size();
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (g[i][k] == INF || g[k][j] == INF)
                    continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int kaij(int a)
{
    if (a == 1)
        return 1;
    else
        return a * kaij(a - 1);
}

int N, M, R;
ll ans = infll;

int main()
{
    cin >> N >> M >> R;
    vector<int> r(R), perm(R);
    Matrix<ll> mt(N, vector<ll>(N, infll));
    for (int i = 0; i < R; i++)
    {
        cin >> r[i];
        r[i]--, perm[i] = i;
    }
    for (int i = 0; i < M; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        mt[a][b] = c, mt[b][a] = c;
    }

    Warshall_Floyd(mt);

    int cnt = kaij(R);

    do
    {
        ll sum = 0;
        for (int j = 0; j + 1 < R; j++)
        {
            int s = r[perm[j]], g = r[perm[j + 1]];
            sum += mt[s][g];
        }
        ans = min(sum, ans);
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;
template <typename T>
using V = std::vector<T>;

using namespace std;

int main() {
  V<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));
  out(a[2] - a[0]);
}


Measured memory_bytes: 3620
#include<ios>
int main(){
    int iN;
    char sS;
    scanf("%d",&iN);
    for (int i = 0;i < iN;i++){
        scanf("%c",&sS);
        if( sS == 'Y' ){
            printf("Four\n");
            return 0;
        }
    }
    printf("Three\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <map>

using namespace std;

int main(){
	string s;
	int k;

	cin>>k;
	cin>>s;

	if(s.size()>k){
		s=s.substr(0,k)+"...";
	}

	cout<<s;
	

}


Measured memory_bytes: 3604
n = int(input())
c = input()

l = n - 1
r = 0

ans = 0

while r <= l:
    if c[r] == "W" and c[l] == "R":
        ans += 1
        r += 1
        l -= 1

    else:
        if c[r] == "R":
            r += 1
        if c[l] == "W":
            l -= 1
print(ans)


Measured memory_bytes: 9380
n = int(input())
an = list(map(int, input().split()))

count = 0

for i in range(0,n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if an[i] == an[j] or an[j] == an[k] or an[i] == an[k]:
        continue
        
      sn = [an[i],an[j],an[k]]
      sn.sort()
      if sn[0] + sn[1] > sn[2]:
        count += 1
print(count)

Measured memory_bytes: 9204
import java.util.Scanner;

/**
 * TITLE : String Palindrome
 * URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
 */
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        String a = S.substring(0, S.length() / 2);
        String b = S.substring(S.length() / 2 + 1, S.length());
        StringBuffer str = new StringBuffer(b);
        System.out.println(str.toString().equals(a) ? "Yes" : "No");
    }
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	ll total = 0;
	F0R(i, M) {
		int x; cin >> x;
		total += x;
	}
	if (total > N) {
		print(-1);
	} else {
		print(N - total);
	}
}

Measured memory_bytes: 3648
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,k=map(int,input().split())
mod=998244353
n_max=2*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod

P=[1]
for i in range(n):
  P.append((P[-1]*(m-1))%mod)

ans=0
for i in range(k+1):
  ans+=m*P[n-1-i]*comb(n-1,i)
  if ans>mod:
    ans%=mod
print(ans)

Measured memory_bytes: 32504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 1;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < N - 1; i++) {
    if (a.at(i) > a.at(i + 1)) {
      ans++;
    }
    else {
      swap(a.at(i), a.at(i + 1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;



int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x/gcd(x, y)*y; }
int mod_pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) { res = res * x % MOD; } x = x * x % MOD; y >>= 1; } return res; }
int comb(int n, int k) { k = min(k, n - k); int nnn = 1; for (int i = n - k + 1; i <= n; i++) { nnn *= i; nnn %= MOD; } int kkk = 1; for (int i = 1; i <= k; i++) { kkk *= i; kkk %= MOD; } return (nnn * mod_pow(kkk, MOD - 2)) % MOD; }
int to_int(string s) { int n = s.size(); int ans = 0; for (int i = 0; i < n; i++) { ans = ((ans * 10) + (s[i] - '0')) % MOD; } return ans; }
bool is_prime(int n) { for(int i = 2; i*i <= n; i++) { if (n % i == 0) return false; } return n != 1; }
int extgcd(int a, int b, int& x, int& y) { // ax+by = gcd(a,b) >> gcd(a, b)
    int d = a;
    if(d != 0) { d = extgcd(b, a%b, y, x); y -= (a/b)*x; }
    else { x = 1, y = 0; }
    return 0;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    int memo[15][15];
    rep(i,15) rep(j,15) memo[i][j]=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int f=s[0]-'0';
        int l=s[s.size()-1]-'0';
        reverse(all(s));
        int h=to_int(s);
        //if(i>=h){
            memo[f][l]++;
        //}
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int f=s[0]-'0';
        int l=s[s.size()-1]-'0';
        // memo[f][l]++;
        ans+=memo[l][f];
    }
    cout<<ans<<endl;
    
}

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

const int maxn = 300002;

int n, A, B, p[maxn];

int main() {
    //freopen("lisdl.inp", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> A >> B;
    if (n<A+B-1 || 1LL*A*B<n) {
        cout << -1;
        return 0;
    }
    p[1] = B;
    int tmp = n - B - A + 1;
    for (int i=2; i<=A; ++i) {
        p[i] = 1;
    }
    for (int i=2; i<=A; ++i) {
        p[i] += min(tmp, B-1);
        tmp -= min(tmp, B-1);
    }
    int cur = 1;
    for (int i=1; i<=A; ++i) {
        for (int j=p[i]-1; j>=0; --j)
            cout << cur + j << ' ';
        cur += p[i];
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio;
    ll a,b;cin>>a>>b;
    ll ans=0;
    rep(i,0,60){
        if(i==0){
            ll xa=a/2,xb =(b+1)/2;
            if((xb-xa)%2==1)ans++;
            continue;
        }
        ll s=1LL<<i;
        ll xa=a/s;
        ll xb=b/s;
        if(xa==xb){
            if(xa%2==1){
                if((b-a)%2==0)ans+=s;
            }
        }else{
            ll k=0;
            if(xa%2==1){
                if(((xa+1)*s-a)%2==1)k++;
            }
            if(xb%2==1){
                if((b-s*xb)%2==0)k++;
            }
            if(k==1)ans+=s;
        }
    }
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<62)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 2000

using namespace std;

const ll mod = 1000000007;
ll d[maxn+5]; ///d[i] = cate secv au suma i

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  d[0] = 1;
  int i, j, z;
  for (i = 1; i <= n; i++)
    for (j = i-3; j >= 0; j--) d[i] = (d[i] + d[j]) % mod;
  cout << d[n];
  return 0;
}

Measured memory_bytes: 3636
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let n = s.len();
    let mut count = 0;
    for i in 0..n {
        if s[i] != t[i] {
            count += 1;
        }
    }
    println!("{}", count);
}


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

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

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        a[i+1]=lcm(a[i],a[i+1]);
    }
    
    cout << a[n-1] << endl;
    return 0;
}



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

int main(){
	int n;
	cin>>n;
	vector<ll>a(n);
	ll res=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i%2)res-=a[i];
		else res+=a[i];
	}
	for(int i=0;i<n;i++){
		cout<<res<<" ";
		res=2*a[i]-res;	
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2048