akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
using namespace std;
double solve(vector<vector<vector<double>>>& dp,int x,int y,int z,int n){
    if(x<0||y<0||z<0){
        return 0;
    }
    if(x==0&&y==0&&z==0){
        return 0;
    }
    if(dp[x][y][z]>-0.9){
        return dp[x][y][z];
    }
    double exp = double(n + x*solve(dp,x-1,y,z,n) + y*solve(dp,x+1,y-1,z,n)+z*solve(dp,x,y+1,z-1,n));
    return dp[x][y][z] = exp/(x+y+z);
}
int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> map(4,0);
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    map[a[i]]++;
	}
	vector<vector<vector<double>>> dp(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
	prDouble(solve(dp,map[1],map[2],map[3],n));
	
	
	return 0;
}

Measured memory_bytes: 216960
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
  ll n;
  cin>>n;
  set<ll>s;
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    s.insert(x);
  }
  if(s.size()==n)
  {
    cout<<"YES"<<'\n';
  }
  else
  {
    cout<<"NO"<<'\n';
  }
  return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

// 素因数の計算(素因数だけ)
template <typename T>
set<T> factorize(T x) {
  set<T> res;
  for (long long i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      res.insert(i);
      while (x % i == 0) x /= i;
    }
  }
  return res;
}

// 最大公約数を求める(ユークリッドの互除法).
long long gcd (long long x, long long y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

// 最小公倍数を求める(lcm(a,b) = a*b / gcd(a,b)). overflowに気をつけよう
ll lcm (long long  x, long long y) {
  ll t = gcd(x,y);
  return (x / t) * y;
}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll t = lcm(c,d);
  // cout << t << endl;
  ll p1 = (b / c) - ((a - 1)/ c);
  ll p2 = (b / d) - ((a - 1) / d);
  ll p3 = (b / t) - ((a - 1) / t);
  // cout << p1 << " " << p2 << " " << p3<< endl;
  ll total = b - a + 1;
  cout << total - (p1 + p2) + p3 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    string S,T;
    cin >> S >> T;
    ll out = 0;
    rep(i,S.length()){
        if(S[i]!=T[i]) out++;
    }
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3816
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b, c;
    cin >> a >> b >> c;

    if(a+b+1 >= c) cout << b+c << endl;
    else cout << b + (a + b + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	while(cin>>a>>b>>c>>d){
		if(a+b>c+d)
			cout<<"Left"<<endl;
		if(a+b==c+d)
			cout<<"Balanced"<<endl;
		if(a+b<c+d)
			cout<<"Right"<<endl;
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
int main(){
int n,l;cin>>n>>l;
vector<string> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
sort(v.begin(),v.end());
string ans="";
for(int i=0;i<n;i++)ans+=v[i];
cout<<ans;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    string s;
    std::cin >> s;
    ll c=0;
    char now = s[0];
    for (int i = 1; i < s.length(); i++) {
        if( s[i] == now ){
            continue;
        }else{
            c++;
            now = s[i];
        }
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19228
n, a, b, c, d = map(int, input().split())

ans = False
l = 0
r = n - 1
cnt = 0
while cnt <= 20:
    m = (l + r) // 2
    if b < a + m * c - (n - 1 - m) * d:
        r = m
    elif a + m * d - (n - 1 - m) * c < b:
        l = m
    else:
        ans = True
        break
    cnt += 1
print('YES' if ans else 'NO')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int w,h,n;
int dx[]={0,0,0,1,-1};
int dy[]={0,1,-1,0,0};
string mp[20];

struct dat{
  int y1,x1;
  int y2,x2;
  int y3,x3;
};


int D[14][14][15][14][14][15];
queue<dat> Q;
void DD(dat &a,int b){D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1] = b;}
int DD(const dat &a){return D[a.y1-1][a.x1-1][a.y2-1][a.x2-1][a.y3-1][a.x3-1];}

bool check(const dat &a){
  if(mp[a.y1][a.x1]=='#') return 0;
  if(n>=2&&mp[a.y2][a.x2]=='#') return 0;
  if(n>=3&&mp[a.y3][a.x3]=='#') return 0;
  return DD(a)==-1;
}

void update(const dat &a){
  int cost = DD(a);

  for(int i=0;i<5;i++){
    int ny1 = a.y1+dy[i], nx1 = a.x1+dx[i];
    for(int j=0;j<5;j++){
      int ny2 = a.y2+dy[j], nx2 = a.x2+dx[j];
      if(n<=1) ny2 = 15,nx2 = 14;
      for(int k=0;k<5;k++){
	int ny3 = a.y3+dy[k], nx3 = a.x3+dx[k];
	if(n<=2) ny3 = 14,nx3 = 15;

	dat nt = (dat){ny1,nx1,ny2,nx2,ny3,nx3};
	if(!check(nt))continue;
	
	if((ny1==ny2&&nx1==nx2) ||(ny2==ny3&&nx2==nx3) ||(ny3==ny1&&nx3==nx1))continue;//same pos
	if(((a.y1==ny2&&a.x1==nx2) && (a.y2==ny1&&a.x2==nx1)) || // swap positoin
	   ((a.y2==ny3&&a.x2==nx3) && (a.y3==ny2&&a.x3==nx2)) ||
	   ((a.y3==ny1&&a.x3==nx1) && (a.y1==ny3&&a.x1==nx3)) )continue;
	
	Q.push(nt);
	DD(nt,cost+1);
      }
    }
  }
}

bool goal(const dat &s,const dat &t){
  char a = mp[s.y1][s.x1];
  char b = mp[s.y2][s.x2];
  char c = mp[s.y3][s.x3];
  char A = mp[t.y1][t.x1];
  char B = mp[t.y2][t.x2];
  char C = mp[t.y3][t.x3];
  return toupper(a)==A&&(n<=1||toupper(b)==B)&&(n<=2||toupper(c)==C);
}

int bfs(dat &start){
  memset(D,-1,sizeof(D));
  while(!Q.empty())Q.pop();
  Q.push(start);
  DD(start,0);
  
  while(!Q.empty()){
    dat t = Q.front();Q.pop();
    if(goal(start,t)) return DD(t);
    update(t);
  }
  return 0;
}

int main(){
  while(1){
  cin>>w>>h>>n;
  if(!w&&!h&&!n)break;
  cin.ignore();
  for(int i=0;i<h;i++)getline(cin,mp[i]),mp[i]+='#';
  
  dat start = (dat){15,15,15,14,14,15};
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(!islower(mp[i][j]))continue;
      if(start.y1==15) start.y1=i,start.x1=j;
      else if(start.y2==15) start.y2=i,start.x2=j;
      else start.y3=i,start.x3=j;
    }
  cout<<bfs(start)<<endl;
  }
  return 0;
}

Measured memory_bytes: 42524
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,a;
    cin>>n;
    int c = 1;
    rep(i,0,n){
        cin>>a;
        if(a%2==0){c*=2;}
    }
    cout<<(int)pow(3,n)-c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll cnt[19][19];

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

	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 10 != 0) {
			string tmp = to_string(i);
			cnt[tmp[0]-'0'][tmp.back()-'0']++;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += cnt[i][j] * cnt[j][i];
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [0] + [int(i) for i in input().split()] + [0]
    d = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
    num = sum(d)
    print("\n".join(
        [str(num - d[i] - d[i + 1] + abs(A[i] - A[i + 2]))
         for i in range(N)]))

    return


main()


Measured memory_bytes: 20032
let rec make_xy ?(l=[0]) = function
  | 0 -> l
  | n ->
    let t = Scanf.scanf "%d\n" (fun x -> x) in
    make_xy ~l:((List.hd l + t) :: l) (pred n)

let t = Array.make (1500*1000) 0

let rec t2 y = function
  | [] -> ()
  | h :: l' ->
    let n = Array.get t (y-h) in
    Array.set t (y-h) (succ n);
    t2 y l'

let rec t1 = function
  | [] -> ()
  | h :: l' ->
    t2 h l';
    t1 l';
    ()

let rec u2 y cnt = function
  | [] -> cnt
  | h :: l' ->
    let n = Array.get t (y-h) in
    u2 y (cnt+n) l'

let rec u1 ?(cnt=0) = function
  | [] -> cnt
  | h :: l' -> u1 ~cnt:(u2 h cnt l') l'

let rec solve () =
  let nm = Scanf.scanf "%d %d\n" (fun i j -> (i, j)) in
  match nm with
  | (0, 0) -> exit 0
  | (n, m) ->
    let y = make_xy n in
    let x = make_xy m in
    Array.fill t 0 ((max m n)*1000) 0;
    t1 y;
    let cnt = u1 x in
    Printf.printf "%d\n" cnt;
    solve ()

let () = solve ()

Measured memory_bytes: 16460
n = int(input())
d = list(map(int,input().split()))
d.sort()
m = int(input())
t = list(map(int,input().split()))
t.sort()

label = 0
count = 0
ans = 1
for i in t:
    check = 0
    for j in range(label,n):
        if i == d[j]:
            label = j + 1
            check = 1
            break
    if check == 0:
        ans = 0
        break
if ans == 0:
    print('NO')
else:
    print('YES')



Measured memory_bytes: 35420
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int a, b;
  ci(a, b);
  a + b < 10 ? co(a + b) : co("error");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;
void solve(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - w * H + w * h;
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}




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

#define ll long long
#define ull unsigned long long
#define lld long double
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl '\n'
template <typename T> using mxpq = priority_queue<T>;
template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>;
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e4 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions
//int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves
//int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

ll fact[maxN], invfact[maxN];
ll modinv(ll a) {
	return powerM(a, mod - 2, mod);
}
ll nCr(ll n, ll r) {
	if (r > n) return 0;
	return ((fact[n] * invfact[r]) % mod * invfact[n - r]) % mod;
}
void precomputenCr() {
	fact[0] = fact[1] = 1;
	for (ll i = 2; i < maxN; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
	}
	/*
	n! = n * (n-1) !
	==> 1/(n-1!) = n/(n!)
	==> (1/(n-1!)) % M = (n/(n!)) % M
	==> (1/(n-1!)) % M = ((n % M) * ((1/(n!)) % M)) % M
	*/
	invfact[maxN - 1] = modinv(fact[maxN - 1]);
	for (ll i = maxN - 2; i >= 0; i--) {
		invfact[i] = invfact[i + 1] * (i + 1);
		invfact[i] %= mod;
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	precomputenCr();
	ll s;
	cin >> s;
	// all integers greater than or equal to 3, and whose sum is equal to S
	ll len = 1;
	ll ans = 0;
	while (3 * len <= s) {
		ll ex = s - 3 * len;
		ans += nCr(ex + len - 1, len - 1);
		ans %= mod;
		++len;
	}
	cout << ans;
	return 0;
}


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

vector<bool> vis;
vector<vector<pair<int,int>>> ab;
vector<int> ans;
void dfs(int node,int d){
    if(vis[node]){
        return;
    }
    vis[node]=true;
    rep(i,ab[node].size()){
        int tt = (ab[node][i].second+d)%2;
        if(tt){
            ans[ab[node][i].first]=1;
        }else{
            ans[ab[node][i].first]=0;
        }
        dfs(ab[node][i].first,tt);
    }
}

int main(){

    int n;
    cin >> n;

    vis = vector<bool>(n,false);
    ab = vector<vector<pair<int,int>>>(n);
    ans = vector<int>(n);
    ans[0]=0;
    rep(i,n-1){
        int s,t,d;
        cin >> s >>t >> d;
        s--;
        t--;
        ab[s].push_back({t,d});
        ab[t].push_back({s,d});
    }

    dfs(0,0);

    rep(i,n){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 7424
using System;
using System.Linq;

namespace codefestival_2016_qualA_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = 0;
            for (int i = 0; i < n; i++)
            {
                if (x[x[i] - 1] == i + 1)
                {
                    a++;
                }
            }
            Console.WriteLine(a / 2);
        }
    }
}

Measured memory_bytes: 10968
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

#define WIN 1000
#define LOSE -1

struct Bigger {
    bool operator()(pair<int, char>a, pair<int, char>b) {
        return a.first > b.first;
    }
};

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector< pair<int, char> > team(n);
        for (int i = 0; i < n; i++) {
            char t; cin >> t;
            int r;
            int point = 0;
            for (int j = 0; j < n-1; j++) {
                cin >> r;
                if (r == 0) point += WIN;
                if (r == 1) point += LOSE;
            }
            team[i].first = point;
            team[i].second = t;
        }
        stable_sort(team.begin(), team.end(), Bigger());
        for (int i = 0; i < n; i++) {
            cout << team[i].second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <queue>
typedef long long ll;

int main(void) {
  ll i, j, k, n, now, ans = 0;
  scanf("%lld", &n);
  bool flg[n], flg2[n];
  ll d[n];
  for(i = 0; i < n; ++i) flg[i] = true;
  char s[n][n + 10];
  for(i = 0; i < n; ++i) scanf("%s", s[i]);
  flg[0] = true;
  std::queue<ll> q;
  q.push(0);
  while(q.size()) {
    now = q.front(), q.pop();
    for(i = 0; i < n; ++i) if(s[now][i] == '1') {
      if(flg[i]) flg[i] = false, flg2[i] = !flg2[now], q.push(i);
      else if(flg2[i] == flg2[now]) {
        printf("-1");
        return 0;
      }
    }
  }
  for(i = 0; i < n; ++i) {
    for(j = 0; j < n; ++j) flg[j] = true;
    flg[i] = false, d[i] = 1;
    q.push(i);
    while(q.size()) {
      now = q.front(), q.pop();
      if(d[now] > ans) ans = d[now];
      for(j = 0; j < n; ++j) if(s[now][j] == '1' && flg[j]) {
        d[j] = d[now] + 1;
        q.push(j), flg[j] = false;
      }
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n;

llint calc(int a,int b){
  llint c=a-b;
  return c*c;
}
void solve(){
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  llint ans=inf;
  for(int k=-100;k<=100;k++){
    llint tmp=0;
    for(int x:a){
      tmp+=calc(x,k);
    }
    ans=min(ans,tmp);
  }
  cout << ans << endl;

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int> > s(M);
  rep(i,M){
    cin >> k[i];
    rep(j,k[i]){
      int t;
      cin >> t;
      s[i].push_back(t);
    }
  }
  vector<int> p(M);
  rep(i,M) cin >> p[i];

  int ans=0;
  for(int bit=0; bit<(1<<N); bit++){
    vector<bool> on(N);
    rep(i,N){
      if(bit & (1<<i)) on[i] = true;
    }
    bool allok;
    rep(i,M){
      int onum=0;
      rep(j,s[i].size()){
	if(on[s[i][j]-1]) onum++;
      }
      if((onum%2) == p[i]) allok = true;
      else{
	allok=false;
	break;
      }
    }
    if(allok) ans++;
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  string S,T; cin >> S >> T;

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


Measured memory_bytes: 3608
#include "bits/stdc++.h"
 
using namespace std;
 
#define ll long long int
#define FOR(i,a,b) for(ll i = a;i<b;i++)
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
int main(){
    boost;
    ll n;
    cin>>n;
    ll len = 1;
    ll temp = 26;
    while(n>temp){
        n-=temp;
        temp*=26;
        len+=1;
    }
    string s(len,'0');
    n-=1;
    for(ll i = len-1;i>=0;i--){
        s[i] = n%26+'a';
        n/=26;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int64_t l = 2;
  int64_t r = 1;
  int64_t k = 1;
 
  for (int i = 1; i < N; i++) {
  k = l + r;

  l = r;
  r = k; 
  }
      cout << k << endl;


 
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=998244353;
int n,m;
ll jc[101010],jc_ny[101010];
ll f[220][8080];
ll Power(ll x,ll k)
{
	ll sss=1;
	while (k)
	{
		if (k%2) sss=sss*x%mod;
		x=x*x%mod;
		k/=2;
	}
	return sss;
}
ll ny(ll x){return Power(x,mod-2);}

struct Poly
{
	ll A[202020],B[202020],C[202020];
	ll g[202020];
	int rev[202020];
	int len,kkk;
	void NTT(ll P[],ll type)
	{
		for (int i=0;i<len;++i) if (i<rev[i]) swap(P[i],P[rev[i]]);
		for (int i=2;i<=len;i<<=1)
		{
			int num=i/2;
			g[0]=1; g[1]=Power(3,(mod-1)/i); 
			if (type==-1) g[1]=ny(g[1]);
			for (int j=2;j<num;++j) g[j]=g[j-1]*g[1]%mod;
			
			for (int j=0;j<len;j+=i)
				for (int k=0;k<num;++k)
				{
					ll x=P[j+k],y=P[j+k+num]*g[k]%mod;
					P[j+k]=(x+y)%mod;
					P[j+k+num]=(x-y+mod)%mod;
				}
		}
		if (type==-1)
		{
			ll doe=ny(len);
			for (int i=0;i<len;++i) P[i]=P[i]*doe%mod;
		}
	}
	void mul(const vector<ll>a , const vector<ll>b , vector<ll> &c)
	{
		int lena=a.size(),lenb=b.size(),lenc=lena+lenb-1; 
		len=1,kkk=0;
		while (len<=lenc) len*=2,++kkk;
		for (int i=0;i<len;++i) rev[i]=(rev[i>>1]>>1) | ((i&1)<<(kkk-1));

		for (int i=0;i<len;++i) A[i]=B[i]=0;
		for (int i=0;i<lena;++i) A[i]=a[i];
		for (int i=0;i<lenb;++i) B[i]=b[i];

		NTT(A,0); NTT(B,0);
		for (int i=0;i<len;++i) C[i]=A[i]*B[i]%mod;
		NTT(C,-1);
		c.clear();
		for (int i=0;i<lenc;++i) c.push_back(C[i]);
	}
}S;
ll C(int x,int y)
{
	if (y>x || y<0) return 0;
	if (y==x || y==0) return 1;
	return jc[x] *jc_ny[x-y]%mod *jc_ny[y]%mod;
}
void init()
{
	jc[0]=jc_ny[0]=1;
	for (int i=1;i<=100010;++i) jc[i]=jc[i-1]*i%mod,jc_ny[i]=ny(jc[i]);
}
vector<ll> F1,F2,G;
int main()
{
	init();

	scanf("%d%d",&n,&m);
	F1.resize(n+1); F2.resize(n+1);
	f[0][0]=1;
	for (int i=0;i<m;++i) 
	{	
		for (int j=0;j<=n;++j) F1[j]=f[i][j]*jc_ny[j]%mod;
		for (int j=0;j<=n;++j) F2[j]=jc_ny[j+2];
		F2[0]=0;

		S.mul(F1,F2,G);
		for (int j=0;j<=n;++j) f[i+1][j]=G[j]*jc[j+2]%mod;

		for (int j=0;j<=n;++j)
			(f[i+1][j]+=(C(j+1,2)+1) * f[i][j]%mod )%=mod;
	}
	ll ans=0;
	for (int i=0;i<=n;++i) ( ans+= f[m][i]*C(n,i)%mod )%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 21504
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	sc.Split(bufio.ScanWords)
	var m, n int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	var totalVote int
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		totalVote += a[i]
	}

	judge := func() string {
		total := 0
		for i := 0; i < n; i++ {
			if a[i]*4*m >= totalVote {
				total++
			}
			if total >= m {
				return "Yes"
			}
		}
		return "No"
	}()

	fmt.Println(judge)
}


Measured memory_bytes: 640
#include  <iostream>
int main(){ 
int X;
int A;
int B;
std::cin >> X >> A >> B ;
if (B-A > X )
std::cout << "dangerous" << std::endl;
else if (A-B >= 0)
std::cout << "delicious" << std::endl;
else
std::cout << "safe" << std::endl;
return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i+1;

    map<vector<int>, int> mp;
    do {
        mp[a] = mp.size();
    }while(next_permutation(a.begin(),a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5248
# -*- coding: utf-8 -*-
from collections import defaultdict
def solve():
    N, M = map(int, input().split())
    PY = sorted([tuple(map(int, input().split()))+(i,) for i in range(1,M+1)])
    x = defaultdict(int)
    ID = sorted([(i, '{0:0>6d}{1:0>6d}'.format(p,x[p])) for p,y,i in PY if x.update({p:x[p]+1}) is None])
    res = '\n'.join([id_[1] for id_ in ID])
    return res
    
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 42556
N = int(input())
X = list(map(int, input().split()))

cnt = 0
mini = float('inf')

P = max(X) + 1

for i in range(P):
    for j in range(len(X)):
        cnt += (X[j] - i)**2
    if cnt < mini:
        mini = cnt
    cnt = 0

print(mini)

Measured memory_bytes: 8952
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
	int N;
	cin >> N;
	LL T, A;
	cin >> T >> A;
	REP( i, N - 1 )
	{
		LL t, a;
		cin >> t >> a;
		LL nt = t * max( ( T + ( t - 1 ) ) / t, ( A + ( a - 1 ) ) / a );
		LL na = a * max( ( T + ( t - 1 ) ) / t, ( A + ( a - 1 ) ) / a );
		T = nt;
		A = na;
		// printf( "%lld : %lld = %lld : %lld\n", t, a, T, A );
	}
	cout << T + A << endl;
	return 0;
}


Measured memory_bytes: 256
//in the name of allah the most gracious the most merciful
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast","unroll-loops")
#define int long long
#define pb push_back
#define fi  first
#define rep(i,n)  for(int i=0;i<n;i++)//looping 
#define rep1(i,n) for(int i=1;i<=n;i++)  
#define se  second
#define endl '\n'
#define PB pop_back
#define PF pop_front
#define pf push_front
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define ld long double 
const double PI = acos(-1);
const double e = exp(1);
const int MAXN = 2e5+100;
using namespace std;
bool check(string s ){
    int n = s.size(); 
    for(int i=0;i<n/2;i++){
        if(s[i] != s[n-1-i]) return 0 ; 
    }
    return 1 ;
}
void solve(){
    double n ; 
    cin>>n ;
    double d = n/3; 
    double ans = d; 
    ans*=d;
    ans*=d; 
    cout << setprecision(7);
    cout << ans ; 
        return ;
}
signed main ()
{
    int t=1; 
    
    while(t--){
        solve(); 
        cout << endl;
    }
    return 0 ; 
}   

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <ll, ll> P;

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

    while (T--) {
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;

        priority_queue<P, vector<P>, greater<P>> q;
        q.push({0, n});

        map<ll, bool> mp;
        ll ans = 1e18;
        while (true) {
            P p = q.top();
            q.pop();

            ll cost = p.first;
            ll cur = p.second;

            if (mp[cur]) continue;
            mp[cur] = true;

            if (cost >= ans) break;

            if (cur == 1) {
                ans = min(ans, cost + d);
            }

            if (cur < (1e18 - cost) / d) {
                ans = min(ans, cost + cur * d);
            }

            if (cur % 2 == 1) {
                q.push({cost + a + d, (cur + 1) / 2});
                q.push({cost + a + d, (cur - 1) / 2});
            } else {
                q.push({cost + a, cur / 2});
            }

            if (cur % 3 == 1) {
                q.push({cost + b + 2 * d, (cur + 2) / 3});
                q.push({cost + b + d, (cur - 1) / 3});
            } else if (cur % 3 == 2) {
                q.push({cost + b + 2 * d, (cur - 2) / 3});
                q.push({cost + b + d, (cur + 1) / 3});
            } else {
                q.push({cost + b, cur / 3});
            }

            for (int i = 1; i < 5; i++) {
                if (cur % 5 == i) {
                    q.push({cost + c + (5 - i) * d, (cur + 5 - i) / 5});
                    q.push({cost + c + i * d, (cur - i) / 5});
                }
            }
            if (cur % 5 == 0) {
                q.push({cost + c, cur / 5});
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4272
#include <iostream>
#include <string>

using namespace std;

int main()
{
    unsigned int n, points;
    cin >> n;
    int div = n / 500;
    points = div * 1000;
    n = n - (div * 500);
    div = n / 5;
    points += div * 5;
    cout << points;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr long long int mod = 1e9 + 7;
using container = vector<Int>;

int main() {

	char C; cin >> C;
	cout << (char)(C + 1) << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
	if(a<b){return a;}
	else{return b;}
}

int main(){

	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);

	int s1=a+b;
	int s2=b+c;
	int s3=c+a;

	printf("%d\n",min(s1,min(s2,s3)));

	return 0;
}

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

int main(){
  string S;
  cin >> S;

  string T="";
  for(int i=0;i<S.size();i++){
    if(S.at(i)!='x')  T+=S.at(i);
  }
  for(int i=0;i<T.size()/2;i++){
    if(T.at(i)!=T.at(T.size()-1-i)){
      cout << -1 << endl;
      return 0;
    }
  }

  int l=0;
  int r=S.size()-1;
  int ans=0;
  while(l<r){
    if(S.at(l)==S.at(r)){
      l++;
      r--;
      continue;
    }
    if(S.at(l)=='x'){
      ans++;
      l++;
      continue;
    }
    if(S.at(r)=='x'){
      ans++;
      r--;
      continue;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    vector<int> d(n + 1);
    rep(i, 0, n){
        if(s[i] == 'W'){
            d[i + 1] = 1;
        }
    }
    rep(i, 0, n){
        d[i + 1] += d[i];
    }
    int ans = INF;
    rep(i, 1, n + 1){
        int tmp = 0;
        int left = d[i - 1];
        int right = n - i - (d[n] - d[i]);
        tmp = left + right;
        chmin(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int result(int n, int k) {
    int d = n / k;
    if ((n - d * k) % (d + 1) == 0) {
        return d;
    }
    int x = (n - d * k) / (d + 1) + 1;
    return result(n - x * (d + 1), k);

}

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n;
    cin >> n;
    vector <int> a(n), k(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> k[i];
    }
    int res = 0;
    for (int id = 0; id < n; id++) {
        res ^= result(a[id], k[id]);
    }
    cout << (res ? "Takahashi" : "Aoki");
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

d = 0
a.insert(0, 0)
a.append(0)
for i in range(n+1):
  d += abs(a[i+1] - a[i])
  
for i in range(n):
  ans = d - abs(a[i+1]-a[i]) - abs(a[i+2]-a[i+1]) + abs(a[i+2]-a[i])
  print(ans)
  

Measured memory_bytes: 14176
#include<iostream>

using namespace std;

int main(){
	int a,b,c;
	int t,i;
	cin >> a >> b >> c;
	t=c;
	i=0;
	while(i<60){
		if((c+60*i)%(a+b)<=a){
			cout << (i*60+c) << '\n';
			break;
		}
		i++;
	}
	if(i==60){
		cout <<-1<< '\n';
	}
}

Measured memory_bytes: 3088
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL dp[SIZE][2];
int N,Z,w,a[SIZE];
int main(){
    R(N,Z,w);
    REPP(i,1,N+1)R(a[i]);
    a[0]=w;
    dp[N][0]=dp[N][1]=abs(a[N]-a[N-1]);
    auto maa = [](auto& x,auto y){if(x<y)x=y;};
    auto mii = [](auto& x,auto y){if(x>y)x=y;};
    for(int i=N-1;i>0;i--){
        dp[i][0]=abs(a[i-1]-a[N]);
        for(int j=i+1;j<=N;j++){
            maa(dp[i][0],dp[j][1]);
        }
        dp[i][1]=abs(a[i-1]-a[N]);
        for(int j=i+1;j<=N;j++){
            mii(dp[i][1],dp[j][0]);
        }
    }
    W(dp[1][0]);
    return 0;
}


Measured memory_bytes: 2304
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

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

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  string str; cin >> str;
  for(auto & c : str) c = (c-'A'+n)%26 + 'A';
  cout << str << endl;
  return 0;
}


Measured memory_bytes: 256
n, c = map(int, input().split())
L = [[0, 0, 0] for _ in range(n)]

rec = []

for i in range(n):
    s, t, c = map(int, input().split())
    c = c-1
    L[i][0] = s
    L[i][1] = t
    L[i][2] = c

L.sort(key=lambda x: x[0])

for i in range(n):
    s = L[i][0]
    t = L[i][1]
    c = L[i][2]
    if i == 0:
        rec.append([c, t])
    else:
        for j in range(len(rec)):
            if rec[j][0] == c and rec[j][1] <= s:
                rec[j][1] = t
                break
        else:
            rec.sort(key=lambda x: x[1])
            for k in range(len(rec)):
                if rec[k][1]+1 <= s:
                    rec[k][0] = c
                    rec[k][1] = t
                    break
            else:
                rec.append([c, t])
#print(rec)
print(len(rec))

Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin>>s;
  for(int i=0;i<s.size();i++) if((i%2&&s[i]=='R')||(!(i%2)&&s[i]=='L')){cout<<"No"; return 0;}
  cout<<"Yes";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
int a[55];
int sum[55];
ll dp[55][2550];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum[i]=a[i]+sum[i-1];
//		printf("%d\n",sum[i]);
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j>=1;j--)
		{
			for(int k=sum[i];k>=a[i];k--)
			{
				dp[j][k]+=dp[j-1][k-a[i]];
			}
		}
	}
	ll res=0;
	for(int i=1;i<=n;i++)
	{
		res+=dp[i][i*m];
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    vector<P> ab(n);
    for(int i=0; i<n; i++){
        int a,b;cin >> a >> b;
        ab[i]=P(b,a);
    }
    sort(ab.rbegin(),ab.rend());
    int start=ab[0].first;
    for(int i=0;i<n;i++){
        if(start>ab[i].first) start=ab[i].first;
        start=start-ab[i].second;
    }
    if(start<0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=2e5+5;
const double eps=1e-6;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n,k;
int a[N];

bool check(int delta){
    int res=0;
    Rep(i,1,n)res+=(a[i]-1)/delta;
    return res<=k;
}

int main()
{
    read(n),read(k);
    Rep(i,1,n)read(a[i]);
    int l=1,r=1e9,ans=0;
    while(l<=r){
        double mid=(l+r)/2;
        if(check(mid))ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4360
#include <stdio.h>

#define MAX 101
#define INF 1000000

void matrixChainOrder(int);
int min(int, int);

int m[MAX][MAX];
int p[MAX];

int main() {
  int n,i;

  scanf("%d", &n);

  for(i=1;i<=n;i++) scanf("%d%d", &p[i-1], &p[i]);

  matrixChainOrder(n);

  printf("%d\n", m[1][n]);

  return 0;
}

void matrixChainOrder(int length){
  int n,i,j,l,k,q;

  n = length;
  for(i=1;i<=n;i++) m[i][i] = 0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k=i;k<j;k++){
        q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        m[i][j] = min(m[i][j],q);
      }
    }
  }
}

int min(int a, int b){
  if(a>b) return b;
  return a;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int left = a + b;
    int right = c + d;
    string lr = "";
    if (left > right){
        lr = "Left";
    } else if (left == right){
        lr = "Balanced";
    } else {
        lr = "Right";
    }
    cout << lr << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
long long MOD = 1e9 + 7;
constexpr ll INF = 1e17;


class Edge {
public:
    explicit Edge(int cost, int to)
    :cost(cost), to(to)
    {}

    int getCost() const {
        return cost;
    }

    int getNext() const {
        return to;
    }

private:
    int cost;
    int to;
};

void applyWarshallFroid(vector<vector<ll>>& d) {
    for (int i = 0; i < d.size(); i++)
    {
        for (int j = 0; j < d.size(); j++)
        {
            for (int k = 0; k < d.size(); k++)
            {
                d[j][k] = std::min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}

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

    
    ll n, m, l;
    cin >> n >> m >> l;
    //vector<ll> a(m, 0), b(m, 0), c(m, 0);
    //vector<vector<Edge>> graph(n);
    //for (int i = 0; i < n; i++)
    //{
    //    int from, to, cost;
    //    cin >> from;
    //    cin >> to;
    //    cin >> cost;
    //    graph[from].emplace_back(Edge(cost, to));
    //}
    vector<vector<ll>> d(n, vector<ll>(n, INF));
    for (int i = 0; i < m; i++)
    {
        int from, to, cost;
        cin >> from;
        cin >> to;
        cin >> cost;
        --from;
        --to;

        d[from][to] = cost;
        d[to][from] = cost;
    }
    for (int i = 0; i < n; i++)
    {
        d[i][i] = 0;
    }
    applyWarshallFroid(d);

    ll q;
    cin >> q;


    vector<vector<ll>> fuel(n, vector<ll>(n, INF));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j) {
                continue;
            }
            if (d[i][j] <= l) {
                fuel[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        fuel[i][i] = 0;
    }
    applyWarshallFroid(fuel);


    for (int i = 0; i < q; i++)
    {
        ll s, t;
        cin >> s >> t;
        --s;
        --t;
        if (fuel[s][t] != INF) {
            cout << fuel[s][t] - 1 << endl;
        }
        else {
            cout << -1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2048