akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

void print(int i, int p, int d, int type, vi &ch) {
    cout << "node " << i << ": parent = " << p << ", depth = " << d << ", ";
    if(type == 0) {
        cout << "root, ";
    } else if(type == 1) {
        cout << "internal node, ";
    } else {
        cout << "leaf, ";
    }
    cout << '[';
    rep(i, ch.size()) {
        if(i) cout << ", ";
        cout << ch[i];
    }
    cout << "]\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi dep(n);
    vvi ch(n);
    int root = -1;
    vi che(n);
    rep(i, n) {
        int j;
        cin >> j;
        if(!i) root = j;
        int k;
        cin >> k;
        ch[j].resize(k);
        rep(i, k) {
            cin >> ch[j][i];
            che[ch[j][i]]++;
        }
    }
    rep(i, n) {
        if(!che[i]) root = i;
    }
    vi type(n);
    vi par(n);
    function<void(int, int)> dfs = [&](int i, int j) {
        par[i] = j;
        for(int ne:ch[i]) {
            if(ne == j) continue;
            dep[ne] = dep[i]+1;
            if(ch[ne].size() == 0) {
                type[ne] = 100;
            } else {
                type[ne] = 1;
            }
            dfs(ne, i);
        }
    };
    dfs(root, -1);
    rep(i, n) {
        print(i, par[i], dep[i], type[i], ch[i]);
    }
}


Measured memory_bytes: 7152
H,W,K = list(map(int, input().split()))
c,h,w = [],[],[]
for i in range(H):
  oneline = input()
  c.append(oneline)
for i in range(H):
  temp = 0
  for j in range(W):
    if(c[i][j]=="#"):
      temp += 1
  h.append(temp)
for j in range(W):
  temp = 0
  for i in range(H):
    if(c[i][j]=="#"):
      temp += 1
  w.append(temp)
num = H+W
ans = 0
totalblack = sum(h)
for k in range(2**(H+W)):
  b = format(k, '0%db'%num)
  hb = b[:H]
  wb = b[-W:]
  #print(b, hb, wb, h, w, end=" ")
  delsum, cov = 0 ,0
  for i in range(H):
    if(hb[i]=="1"):
      delsum += h[i]
  for j in range(W):
    if(wb[j]=="1"):
      delsum += w[j]
  for i in range(H):
    for j in range(W):
      if(hb[i]=="1" and wb[j]=="1" and c[i][j]=="#"):
        cov += 1
  remainblack = totalblack - delsum + cov
  #print(remainblack, delsum, cov, end=" ")
  if(remainblack == K):
    ans += 1
print(ans)

Measured memory_bytes: 9284
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

int main(){
    int a,b,k;
    cin>>a>>b>>k;

    for(int i=a;i<=min(a+k-1,b);i++) cout<<i<<endl;
    for(int i=max(a+k,b-k+1);i<=b;i++) cout<<i<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;



int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	
	string s;
	cin >> s;
	sort(all(s));
	cout << ((s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()

west_count = 0
east_count = 0
ans = 10**18
adj = 0

for i in s:
    if i == 'W':
        west_count += 1
    else:
        east_count += 1

for i in range(n):
    tmp = s[i]
    if tmp == 'W':
        west_count -= 1
    else:
        east_count -= 1

    if ans > east_count + adj:
        ans = east_count + adj

    if tmp == 'W':
        adj += 1

print(ans)

Measured memory_bytes: 3676
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    auto S = sread();
    auto dp = new long[][](S.length + 1, 13);
    dp[0][0] = 1;

    foreach (i; 0 .. S.length)
    {
        if (S[i] == '?')
        {
            foreach (j; 0 .. 13)
            {
                foreach (k; 0 .. 10)
                {
                    auto m = (j * 10 + k) % 13;
                    dp[i + 1][m] = (dp[i + 1][m] + dp[i][j]) % MOD;
                }
            }
        }
        else
        {
            foreach (j; 0 .. 13)
            {
                auto k = S[i] - '0';
                auto m = (j * 10 + k) % 13;
                dp[i + 1][m] = (dp[i + 1][m] + dp[i][j]) % MOD;
            }
        }
    }
    writeln(dp[S.length][5]);
}


Measured memory_bytes: 18328
#include <iostream>
using namespace std;
static const int mod = 2019;

int main() {
  long long l, r;
  cin >> l >> r;
  long long cnt = 0;
  long long ans = 2018;
  r = min(r, l + mod);
  for (long long i = l; i <= r-1; i++) {
    for (long long j = l+1; j <= r; j++) {
      long long x = ((i%mod)*(j%mod))%mod;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
S = [input() for _ in range(n)]

count = 0
countA = 0
countB = 0
countAB = 0

for each_s in S:
    if each_s[0] == "B" and each_s[-1] == "A":
        countAB += 1
    else:
        if each_s[0] == "B":
            countB += 1
        elif each_s[-1] == "A":
            countA += 1
    count += each_s.count("AB")

if countAB >= 1:
    count += countAB - 1
    if countA > 0:
        count += 1
        countA -= 1
    if countB > 0:
        count += 1
        countB -= 1
    count += min(countA, countB)
elif countAB == 0:
    count += min(countA, countB)

print(count)


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int t;
	cin >> t;
	vi v(n);
	REP(i, n)cin >> v[i];
	int tm = 0;
	int ans = 0;
	REP(i, n) {
		if (tm < v[i]) {
		
			ans += t;
		}
		else if (v[i] + t > tm) {
		
			ans += v[i] + t - tm;
		}
		tm = v[i] + t;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
PROGRAM ABC176A
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      real(p) :: n,x,t
      
      read*,n,x,t
      
      print'(i0)',nint(ceiling(n/x)*t)
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2912
function Main(input) {
	var input = input.split("\n");
    var  N = Int(input[0]);
    for(var i=1;i<=N;i++){
        var side = input[i].split(" ");
        for(var j =0;j<3;j++){
            side[j]=Int(side[j]);
        }
        side.sort(descendingOrder);
        if(side[0]*side[0]==side[1]*side[1]+side[2]*side[2]){
            output("YES");
        }else{
            output("NO");
        }
    }
}
//??°??????????????¢??°??¨(??????)
function ascendingOrder(val1,val2){
    return val1 - val2;
}
//??°??????????????¢??°??¨(??????)
function descendingOrder(val1,val2){
    return val2 - val1;
}
//??°??????
function Int(str){
    return parseInt(str, 10);
}
//????????????
function Str(num){
    return num.toString(10);
}
function output(str){
	if(_Isdebug){
		document.getElementById("input").value+=(str+"\n");
	}
	console.log(str);
}

//???????????°??¨
var _Isdebug = false;

function debug(){
	_Isdebug =true;
	var input = document.getElementById("input").value;
	Main(input);

}

//?????????????????\??????????????????
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17700
#include <iostream>

using namespace std;

int main()
{
    int n, res;
    cin >> n;
    if (n%1000==0)
    {
        cout << 0 << "\n";
    }
    else
    {
        res = 1000 - (n%1000);
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 3580
N, A, B = map(int, input().split())

items = sorted(list(map(int, input().split())), reverse=True)

ans_lis = items[:A]
ans1 = sum(ans_lis)/A 
print(ans1)

i = A
ans2 = 0
while i <= B:
  if sum(items[:i])/i != ans1:
    break
  min_ = min(items[:i])
  min_in_ans = items[:i].count(min_)
  min_in_all = items.count(min_)

  nCr = {}
  def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

  ans2 += cmb(min_in_all, min_in_ans)
  i += 1
print(ans2)

Measured memory_bytes: 3064
N=int(input())
s=[[0]*9 for i in range(9)]
for i in range(1,N+1):
    if i%10:
        t=str(i)
        s[int(t[0])-1][int(t[-1])-1]+=1
a=0
for i in range(9):
    for j in range(i):
        a+=s[i][j]*s[j][i]*2
    a+=s[i][i]**2
print(a)

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

int main() {
    int n;
    cin >> n;
    ll a[n], b[n], c[n];
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    ll ans = 0;
    rep(i, n) {
        ll lower = lower_bound(a, a + n, b[i]) - a;
        ll upper = n + c - upper_bound(c, c + n, b[i]);
        ans += lower * upper;
    }

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


Measured memory_bytes: 2560
S = input()
N = len(S)

ans = 0
tmp = 0
ACGT = {"A", "C", "G", "T"}
i = 0
while i < N:
  if S[i] in ACGT:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
  i += 1
    
ans = max(ans, tmp)  

print(ans)
  
  

Measured memory_bytes: 61836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n , m;
string s , t;
ll fpb(ll a , ll b){
	if(a == 0)return b;
	return fpb(b % a , a);
}
ll kpk(ll a , ll b){
	return a/fpb(a,b) * b;
}
bool valid(string s , string t){
	ll f = fpb(n , m);
	for(int i = 0 ; i < f ; i++){
		if(s[i*n/f] != t[i*m/f])return false;	
	}
	return true;
}
int main(){
	cin >> n >> m;
	cin >> s >> t;
	if(valid(s, t))cout << kpk(n , m) << endl;
	else cout << -1 << endl; 
}

Measured memory_bytes: 3724
#include <iostream>

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll K) {
  cout << (N%K != 0) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
int g[10][10];
int d[10][10];
 
void wf() {
    for(int k=0; k<10; ++k) {
        for(int i=0; i<10; ++i) {
            for(int j=0; j<10; ++j) {
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
}
 
/**
vector<int> shortest_path(int s, int t) {
    int cur = s;
    vector<int> res;
    while(cur != t) {
        res.push_back(cur);
        for(int i=0; i<10; ++i) {
            if(i!=cur && g[cur][i]+d[i][t]==d[cur][t]) {
                cur = i;
                break;
            }
        }
    }
}
*/
 
signed main() {
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) d[i][j] = 1e+9;
    }
 
    int h, w;
    cin >> h >> w;
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) {
            int a;
            cin >> a;
            d[i][j] = a;
        }
    }
    wf();
    int ans = 0;
    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            int a;
            cin >> a;
            if(a<0) continue;
            ans += d[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define PI 
#define ll long long

int main() {
	int n;
	string str;
	cin >> n;
	cin >> str;
	if(n % 2 != 0) {
		cout << "No\n";
		return (0);
	}
	for(int i = 0, j = n/2; i <= n/2 && j < n ; i++, j++) {
		if(str[i] != str[j]) {
			cout << "No\n";
			return (0);
		}
	}
	cout << "Yes\n";
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> d(n);
    int ans = n;

    rep(i,n) cin >> d[i];

    sort(all(d));

    rep(i,n-1) if(d[i] == d[i+1]) ans--;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int p[N];
int pd[N];
int find(int x) {
	if(p[x] != x) p[x] = find(p[x]);
	return p[x];
}
int main() {
	int n,m;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++) {
		p[i]=i;
		pd[i] = 1;
	}
	for(int i = 0; i<m;i++) {
		int a, b;
		cin >> a >> b;
		int x = find(a);
		int y = find(b);
		if(x != y) {
			pd[x] += pd[y];
			p[x] = y;
		}
	}
	int ans=0;
	for(int i = 1;i < n; i ++) {
		int x = find(i);
		int y = find(i+1);
		if(x != y) {
			p[x] = y;
			ans++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 500010
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	string s;
	while(cin >> n)
	{
		cin >> s;
		int ans = 1;
		FOR(i, 1, (int) s.size())
		{
			if(s[i] != s[i-1]) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll M, K; cin >> M >> K;
    if(K >= (1ll << M)){
        cout << - 1 << endl; return 0;
    }
    
    if(M == 1 && K == 1){
        cout << -1 << endl; return 0;
    }
    
    deque<ll> dq;
    dq.push_back(K);
    if(K==0) dq.push_back(0);
    REP(i, (1ll << M)){
        if(i == K) continue;
        dq.push_back(i); dq.push_front(i);
    }
    if(K!=0) dq.push_back(K);
    REP(i, dq.size()) cout << dq[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3968
n = int(input())
X = map(int, input().split())
X = list(X)
# n = 3
# X = [3, 5, -1]

X.insert(0,0)
X.append(0)
Y = []
for i, x in enumerate(X[1:]):
    Y.append(abs(x-X[i]))
sumY = sum(Y)

for i, x in enumerate(X):
    if i not in [0,len(X)-1]:
        ans = sumY - (Y[i-1] + Y[i]) + abs(X[i+1]-X[i-1])
        print(ans)

Measured memory_bytes: 14048
"use strict";
function Main(input) {
  const args = input.split(' ').map(m => parseInt(m));
  const A = args.shift();
  const B = args.shift();
  let price = B;
  if (A <= 5) {
   price = 0;
  } else if (A <= 12) {
   price /= 2;
  }

  console.log(price);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        Dictionary<string, int> dic = new Dictionary<string, int>();
        long count = 0;
        for (int i = 0; i < N; i++)
        {
            string str = Console.ReadLine();
            if (dic.ContainsKey(MyisAnagram(str)))
            {
                int x = dic[MyisAnagram(str)];
                count += x;
                dic[MyisAnagram(str)] = x + 1;
            }
            else
            {
                dic.Add(MyisAnagram(str), 1);
            }
        }
        Console.WriteLine(count);
    }
    static string MyisAnagram(String word1)
    {
        char[] t = new char[word1.Length];
        for (int i = 0; i < word1.Length; i++)
        {
            t[i] = (char)word1[i];
        }
        Array.Sort(t);
        return new string(t);
    }
}


Measured memory_bytes: 29260
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

int binarySearch(alias pred, T)(in T[] arr, bool isLower = true)
{ 
	int ok, ng;
	if (isLower) { ok = cast(int)arr.length; ng = -1; }
	else		 { ok = -1; ng = cast(int)arr.length; }
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng) / 2;
		if (unaryFun!pred(arr[mid]))
			ok = mid;
		else ng = mid;
	}
	return ok;
}

void main()
{
	auto N = RD;
	auto S = RD!string;

	auto pos = new long[][](26);
	foreach (i; 0..N)
	{
		auto num = S[i] - 'a';
		pos[num] ~= i;
	}

	long ans;
	foreach (i; 0..N-1)
	{
		auto num = S[i] - 'a';
		auto pi = pos[num].binarySearch!((long a) => a > i)();
		foreach (j; pos[num][pi..$])
		{
			auto len1 = j - i;
			auto len2 = N - j;
			auto len = min(len1, len2);
			if (len <= ans) continue;
          	bool ok = true;
			foreach (k; 0..ans)
			{
				if (S[i+k] != S[j+k])
                {
                  ok = false;
                  break;
                }
			}
         	if (!ok) continue;
          	foreach (k; ans..len)
			{
				if (S[i+k] != S[j+k]) break;
				ans = max(ans, k+1);
			}
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

int main() {
	string S; cin >> S;
	int N = S.size();
	int K; cin >> K;
	vector<string>A;
	for (int i = 0; i < S.size(); i++) {
		string T = "";
		int pus = min(K, N - i);
		for (int j = i; j < i + pus; j++) {
			T.push_back(S.at(j));
			A.push_back(T);
		}
	}
	sort(A.begin(), A.end());
	long long num = 1;
	if (A.size() == 1 || K == 1) {
		cout << A.at(0) << endl;
		return 0;
	}
	for (int i = 1; i < A.size(); i++) {
		if (A.at(i) != A.at(i - 1)) {
			num++;
			if (num == K) {
				cout << A.at(i) << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b) swap(a, b);
	if (a % 2 == b % 2) {
		cout << (b - a) / 2 << endl;
		return 0;
	}
	ll ans = n;
	ans = min(ans, a - 1 + (b - a + 1) / 2);
	ans = min(ans, n - b + (b - a + 1) / 2);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N;
    int a[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a, a+N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    
    for(int i=0; i<N; i++){
        if(i%2 == 0){
            Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }
    
    cout << Alice-Bob << endl;
    
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val abmInput  = scala.io.StdIn.readLine()
  val abmArray = abmInput.split(" ").map(_.toInt).toSeq
  val aLength = abmArray(0)
  val bLength = abmArray(1)
  val mLength = abmArray(2)

  val aInput = scala.io.StdIn.readLine()
  val aArray = aInput.split(" ").map(_.toInt).toVector
  val bInput = scala.io.StdIn.readLine()
  val bArray = bInput.split(" ").map(_.toInt).toVector

  var mMap = scala.collection.mutable.Map.empty[(Int, Int), Int]
  (1 to mLength).foreach { _ =>
    val mInput  = scala.io.StdIn.readLine()
    val mInputArray = mInput.split(" ").map(_.toInt).toSeq
    val key = (mInputArray(0), mInputArray(1))
    if (mMap.contains(key)) {
      val existingValue = mMap.get(key).get
      if(existingValue < mInputArray(2)) {
        mMap.put(key, mInputArray(2))
      }
    } else {
      mMap.put(key, mInputArray(2))
    }
  }

  var min = aArray.min + bArray.min
  mMap.keys.foreach { key =>
    val mCalculate = aArray(key._1 - 1) + bArray(key._2 - 1) - mMap.get(key).get
    if(mCalculate < min) {
      min = mCalculate
    }
  }
  println(min)
}

Measured memory_bytes: 95780
void main() {
	rs.count!"a == '1'".writeln;
 }

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

int main(void){
  int r, c, a[100][100];
  scanf("%d %d", &r, &c);
  for(int i = 0;i < r;++i){
    for(int j = 0;j < c;++j){
      scanf("%d", &a[i][j]);
    }
  }

  int u = 0;
  for(int i = 0;i < r;++i){
    int s = 0;
    for(int j = 0;j < c;++j){
      printf("%d ", a[i][j]);
      s += a[i][j];
    }
    u += s;
    printf("%d\n", s);
  }

  for(int j = 0;j < c;++j){
    int s = 0;
    for(int i = 0;i < r;++i){
      s += a[i][j];
    }
    printf("%d ", s);
  }

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

  return 0;
}



Measured memory_bytes: 3188
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str-evaled (gensym "STR")))
    (labels ((expand (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   `(progn ,@body)
		   `(let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			   (,pos2 (position #\space ,str-evaled :start ,pos1 :test #'char=))
			   (,(car arg-lst) (parse-integer ,str-evaled :start ,pos1 :end ,pos2)))
		      ,(expand (cdr arg-lst) nil)))))
      `(let ((,str-evaled ,string))
	 ,(expand arg-lst)))))

(deftype unum () '(integer 0 1000000000))
(defun main ()
  (declare #.O3)
  (let* ((n (read))
	 (init-hp (read))
	 (arr-a (make-array n :element-type 'fixnum))
	 (arr-b (make-array n :element-type 'fixnum)))
    (dotimes (idx n)
      (split-and-bind (a b) (the string (read-line))
	(setf (aref arr-a idx) a
	      (aref arr-b idx) b)))
    (let* ((max-a (loop for idx from 0 below n maximize (aref arr-a idx)))
	   (arr-b (sort arr-b #'>=))
	   (end-idx (loop for idx from 0
		       do (cond ((= idx n) (return n))
				((> max-a (aref arr-b idx))
				 (return idx))))))
      (print-line
       (loop for idx of-type unum from 0 below end-idx
	  and hp of-type fixnum = init-hp then (- hp (aref arr-b idx))
	  until (<= hp 0)
	  finally (return (+ idx
			     (ceiling (max hp 0) max-a))))))))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(with-open-file (out *dat-path*
		     :direction :output :if-exists :supersede)
  )

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 49636
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
int dp[100010];
vector<int> v;

int can_win(int k, int n){
    if( dp[k] != -1 )
        return dp[k];

    int ans = 0;
    for(int i=0; i<n; i++){
        if( v[i] > k )
            continue;
        if( can_win(k-v[i], n) == 0 ){
            ans = 1;
            break;
        }
    }
    dp[k] = ans;
    // cout<<k<<" "<<dp[k]<<endl;
    return dp[k];
}
int main(){
   
   for(int i=0; i<100010; i++)
     dp[i] = -1; 
   int n,k, x;
   cin>>n>>k;

   for(int i=0; i<n; i++){
        cin>>x;
        v.push_back(x);
   }
   if( can_win(k, n) == 1)
        cout<<"First\n";
   else
        cout<<"Second\n";
}

Measured memory_bytes: 8628
#include <iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<unordered_set>
#include<stack>
#include<queue>
#include<unordered_map>
using namespace std;
typedef long long int ll;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
void DSUinit(vector<ll>&a,vector<ll>&size,ll n)
{
    FOR(i,0,n)
    {
        a[i]=i;
        size[i]=1;
    }
    return;
}
ll root(vector<ll>&a,ll i)
{
    return (i==a[i])?i:a[i]=root(a,a[i]);
}
bool DSUfind(vector<ll>a,ll x,ll y)
{
    if(root(a,x)==root(a,y))
    {
        return true;
    }
    return false;
}
void DSUunion(vector<ll>&a,vector<ll>&size, ll x,ll y)
{
    x=root(a,x);
    y=root(a,y);
    if(x==y)
    {
        return;
    }
    if(size[x]<size[y]) swap(x,y);
    a[y]=x;
    size[x]+=size[y];
}
void dfs(vector<vector<ll> >&graph,vector<bool>&visited,ll start)
{
    visited[start]=true;
    FOR(i,0,graph[start].size())
    {
        if(!(visited[graph[start][i]]))
        {
            dfs(graph,visited,graph[start][i]);
        }
    }
    return;
}
bool isPrime(int n) 
{
    if (n <= 1)  return false; 
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
          return false;
    return true; 
}
ll power(ll x,ll y,ll p)
{
    ll ans=1;
    x = x%p;
    if(x==0) return 0;
    while(y)
    {
        if(y&1) ans=(ans*x)%p;
        y>>=1;
        x=(x*x)%p;
    }
    return ans;
}
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<vector<ll> >v(n,vector<ll>(3,0));
    FOR(i,0,n)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    vector<vector<ll> >dp(n,vector<ll>(3,0));
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    FOR(i,1,n)
    {
        dp[i][0]=v[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 13580
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "random"
#include        "chrono"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;



void go()
{
    ld d , t, s;

    cin >> d >> t >> s;

    ld tt = ( 1.0*d / s );

    if( 1.0*tt <= 1.0*t ) cout << "Yes\n";
    else cout << "No\n";
}

int32_t main()
{
    FAST;     
    int t=1; 
    // cin>>t;
    test(t) go();
}

 

Measured memory_bytes: 3732
import numpy as np

h, w, k = map(int,input().split())
l=[]
for i in range(h):
    ll = input()
    l.append(ll)

ans = np.array([[0] * w] * h)

n = 1
for y in range(h):
    count = 0
    for x in range(w):
        if l[y][x] == ".":
            count += 1
    
    if count != w:
        flag = -1
        for x in range(w):
            ans[y][x] = n
            if l[y][x] == "#":
                n += 1
                flag = x
            
            if x == (w - 1):
                for xx in range(flag + 1, w):
                    ans[y][xx] = ans[y][flag]

# 0の行の処理
for y in range(h):
    if sum(ans[y]) == 0:
        for i in range(y + 1, h):
            if sum(ans[i]) != 0:
                ans[y] = ans[i]
                break

for y in range(h - 1, -1, -1):
    if sum(ans[y]) == 0:
        for i in range(y - 1, -1, -1):
            if sum(ans[i]) != 0:
                ans[y] = ans[i]
                break

for y in range(h):
    print(*ans[y])

Measured memory_bytes: 15604
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by mixnector on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        int N = ni();
        long[] sizes = new long[N];
        int i;
        for (i = 0; i < N; i++) {
            sizes[i] = nl();
        }
        Arrays.sort(sizes);
        int result = N;
        int now = 0;
        long totalSize = 0;
        for (i = 0; i < N - 1; i++)
        {
            if (totalSize < 500000000)
                totalSize += sizes[i];
            //サイズ不足
            if (totalSize * 2 < sizes[i + 1])
            {
                result -= i - now + 1;
                now = i + 1;
            }
            //サイズ神化
            if (totalSize >= 500000000)
            {
                break;
            }
        }
        out.println(result);
        out.flush();
    }

    static int ni() {
        return Integer.parseInt(in.next());
    }

    static long nl() {
        return Long.parseLong(in.next());
    }
}

Measured memory_bytes: 48632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	ll sum = 0;
	vector<ll> a(n);
	rep(i, n) cin >> a[i], a[i] -= (i + 1), a[i] += 1e6, sum += a[i];
	sort(all(a));
	ll ans = 1e18;
	ll sum1 = 0;
	rep(i, n){
		sum1 += a[i];
		ll cur = abs(((i + 1) * a[i]) - sum1) + ((sum - sum1) - ((n - i - 1) * a[i]));
		ans = min(ans, cur);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1792
N = int(raw_input())
S = list(raw_input())

all = 0
tmp = 0
for i in S:
    if  i == '.':
        all += 1
ans = all
for i in range(N):
    if S[i] == '.':
        tmp += 1
    ans = min(ans, all - tmp + i + 1 - tmp)

print ans

Measured memory_bytes: 10556
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int N = Integer.parseInt(br.readLine().trim());
        int[][] CSF = new int[N - 1][3];
        for (int i = 0; i < N - 1; i++) {
            CSF[i] = inputval();
        }
        int time;

        for (int i = 0; i < N - 1; i++) {
            time = 0;
            for (int j = i; j < N - 1; j++) {
                if (time % CSF[j][2] == 0) {
                    time = Math.max(CSF[j][1], time) + CSF[j][0];
                } else {
                    time = Math.max(CSF[j][1], time + CSF[j][2] - time % CSF[j][2]) + CSF[j][0];
                }
            }
            System.out.println(time);
        }
        System.out.println(0);
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e5+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()

#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

int dp[mx],n,a[mx];

int solve (int i)
{
    if ( i >= n )
        return 0;
    if ( dp[i]!= -1 )
        return dp[i];

    int ret1 = INT_MAX, ret2 = INT_MAX;

    if (i+1<=n )
        ret1 = abs(a[i]-a[i+1])+ solve (i+1);

    if(i+2<=n)
        ret2 = abs(a[i]-a[i+2])+solve (i+2);
    ///dbg(i);
    dp[i]= min ( ret1, ret2 );

    return dp[i];
}

int main()
{
    su;

    mem ( dp, -1 );

    cin>>n;

    for ( int i = 1; i <= n; i++ )
    {
        cin >>a[i];
    }

    cout << solve( 1 )<< nl;


    return 0;
}


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

#define N (1<<17)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 1000000007
#define LINF 1000000000000000007LL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define L length() - 1

using namespace std;

int main () {
    int n;
    cin>>n;
    bool b = true;
    for (int i = 0; i < n; i++) {
        int x;
        cin>>x;
        if (x & 1) b = !b;
    }    
    if (b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 384
#include <cstring>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

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

	int** gresult = new int*[N + 1];
	for (int i = 1; i <= N; i++) {
		gresult[i] = new int[N + 1];
	}

	int numGame = N * (N - 1) / 2;
	int* tScore = new int[N + 1];
	for (int i = 0; i < numGame; i++) {
		int a, b, scoreA, scoreB;
		cin >> a >> b >> scoreA >> scoreB;

		if (scoreA == scoreB) {
			tScore[a] += 1;
			tScore[b] += 1;
		} else if (scoreA > scoreB) {
			tScore[a] += 3;
		} else if (scoreA < scoreB) {
			tScore[b] += 3;
		}
	}

	int* tRank = new int[N + 1];
	for (int i = 1; i <= N; i++) {
		tRank[i] = 1;
	}
	for (int i = 2; i <= N; i++) {
		for (int j = 1; j <= i - 1; j++) {
			if (tScore[i] > tScore[j]) tRank[j]++;
			if (tScore[i] < tScore[j]) tRank[i]++;
		}
	}

	for (int i = 1; i <= N; i++) {
		cout << tRank[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
sx, sy, tx, ty = map(int, input().split())
ans = ""
temp_x = tx - sx
temp_y = ty - sy
ans += "U"*temp_y + "R"*temp_x + "D"*temp_y + "L"* temp_x
temp_x += 1
temp_y += 1
ans += "L" + "U"*temp_y + "R"*temp_x + "D" + "R" + "D"*temp_y + "L"* temp_x + "U"
print(ans)


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

//#define mod 1000000007;

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

    char ch;
    cin>>ch;
    if(isupper(ch))
        cout<<'A';
    else
        cout<<'a';

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int N_MAX = 200001;
int main()
{
  int n,i,j,q,t,m=0;
  int a[N_MAX],b[N_MAX];
  cin >> n;
  for(i=1;i<=n;i++)
    cin >> a[i];
  for(i=n;i>0;i--){
    q=n/i;
    t=0;
    for(j=2;j<=q;j++)
      t=(t+b[i*j])%2;
    b[i]=(t+a[i])%2;
    if(b[i]==1) m++;
  }
  cout << m << endl;
  for(i=1;i<=n;i++)
    if(b[i]==1)
      cout << i << " ";
  cout << endl;
  return 0;
}

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

#define BUF_SIZE 20

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

struct point2d {
  int x;
  int y;
};

int main(void) {
  char line[BUF_SIZE];
  FILE* fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  struct point2d base; int num;
  int i;
  sscanf(line, "%d %d %d", &base.x, &base.y, &num);

  struct point2d bottomleft = {0, 0};
  struct point2d topright = base;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int mode; struct point2d p;
    sscanf(line, "%d %d %d", &p.x, &p.y, &mode);
    switch(mode) {
      case 1:
        bottomleft.x = max(p.x, bottomleft.x);
        break;
      case 2:
        topright.x = min(p.x, topright.x);
        break;
      case 3:
        bottomleft.y = max(p.y, bottomleft.y);
        break;
      case 4:
        topright.y = min(p.y, topright.y);
        break;
      default:
        printf("error\n"); return 0;
    }
  }

  int res = 0;
  if(bottomleft.x < topright.x && bottomleft.y < topright.y) {
    res = (topright.x - bottomleft.x) * (topright.y - bottomleft.y);

  }

  printf("%d\n", res);
  
  return 0;
}

Measured memory_bytes: 128
import itertools
N=int(input())
S=input()
ans=0
L=dict()
R=dict()
for seq in itertools.product([0,1],repeat=N):
    T0=""
    T1=""
    T2=""
    T3=""
    for i in range(N):
        if seq[i]==0:
            T0+=S[i]
            T2+=S[-i-1]
        else:
            T1+=S[i]
            T3+=S[-i-1]
    a0=len(T0)
    a1=len(T1)
    a2=len(T2)
    a3=len(T3)
    L[(T0,T1)]=L.get((T0,T1),0)+1
    R[(T2,T3)]=R.get((T2,T3),0)+1
for tup in L:
    if tup in R:
        ans+=L[tup]*R[tup]
print(ans)


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

using namespace std;
typedef unsigned long long ull;
const int N = 100'010;
const ull MA = 1000000000000000000ull;
ull a[N];

int main() {
    int n;
    scanf("%d", &n);
    ull mi = 1e18;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        mi = min(mi, a[i]);
    }
    if (mi == 0) {
        printf("0\n");
        return 0;
    }
    bool yes = 1;
    ull ans = 1;
    for (int i = 0; i < n; i++) {
        ull next = ans * a[i];
        if (next / ans != a[i] || next > MA) {
            yes = 0;
            break;
        }
        ans = next;
    }
    if (yes) printf("%lld\n", ans);
    else printf("-1\n");
}


Measured memory_bytes: 4540
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  string s[n];
  for(int i = 0; n > i; i++){
    cin>>s[i];
  }
  for(int i = 1; n > i; i++){
    if(s[i][0] != s[i-1][s[i-1].size()-1]){
      cout << "No" << endl;
      return 0;
    }
    for(int j = 0; i > j; j++){
      if(s[j] == s[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256