akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define int long long

typedef struct {
	int t;
	int d;
}pair;

signed compair(const void *a, const void *b){
	pair pa = *(pair *)a, pb = *(pair *)b;
	int sub = pa.d - pb.d;
	if(sub < 0){
		return 1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return -1;
	}
}

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int N, K, i, j, k;
	scanf("%lld%lld", &N, &K);
	pair *ps = (pair *)malloc(sizeof(pair) * 2 * N);
	for(i = 0; i < N; i++){
		ps[i] = (pair){i, 0};
	}
	for(i = N; i < 2 * N; i++){
		scanf("%lld%lld", &ps[i].t, &ps[i].d);
		ps[i].t--;
	}
	qsort(ps, 2 * N, sizeof(pair), compair);
	int *t_num = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		t_num[i] = 0;
	}
	int *A = (int *)malloc(sizeof(int) * 2 * N);
	int *B = (int *)malloc(sizeof(int) * 2 * N);
	int sum = 0, t_count = 0;
	for(i = 0, j = 0, k = 0; i < N; i++){
		if(i < K){
			sum += ps[i].d;
			if(t_num[ps[i].t] == 0){
				t_count++;
			}
			else{
				A[j] = ps[i].d;
				j++;
			}
		}
		else{
			if(t_num[ps[i].t] == 0){
				B[k] = ps[i].d;
				k++;
			}
		}
		t_num[ps[i].t]++;
	}
	int NA = j, NB = k, ans = sum + t_count * t_count;
	for(i = 0; i < NA && i < NB; i++){
		sum -= A[NA - 1 - i];
		sum += B[i];
		t_count++;
		ans = max(ans, sum + t_count * t_count);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6396
from itertools import combinations
n=int(input())
dp=[0]*5
for i in range(n):
  s=input()
  if s[0]=="M":
      dp[0]+=1
  if s[0]=="A":
      dp[1]+=1
  if s[0]=="R":
      dp[2]+=1
  if s[0]=="C":
      dp[3]+=1
  if s[0]=="H":
      dp[4]+=1
ans=0
for a,b,c in combinations(dp,3):
  ans+=a*b*c
print(ans)


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

bool check(int x) {
	while (x) {
		if (x % 10 == 3)return true;
		x /= 10;
	}
	return false;
}

int main()
{
	int i, n;
	cin >> n;
	for (i = 1;i <= n;i++) {
		if (i%3==0||check(i))
			cout << ' ' << i;
	}
	cout << endl;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

int main(void){
  LL n;
  int a, b;

  cin >> n >> a >> b;

  LL sum = 0;
  int remain, quotient;

  for (int i = 1; i < n + 1; i++) {
    int digit_sum = 0;
    quotient = i;
    while(1) {
      digit_sum += quotient % 10;
      quotient /= 10;
      if (quotient == 0) break;
    }
    if (a <= digit_sum && digit_sum <= b) sum += i;
  }

  cout << sum << endl;

  return 0;
}

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

bool check(int x,long long N,vector<long long> &s, std::vector<long long> &c)
{
    vector<long long> t;
    if(x)
    {
        while(x)
        {
            t.push_back(x%10);
            x/=10;
        }
    }else
    {
        t.push_back(0);
    }
    if(t.size()!=N)return false;
    t.push_back(0);
    reverse(t.begin(),t.end());

    for(int i=0;i<s.size();++i)
    {
        if(t[s[i]]!=c[i])return false;
    }
    return true;
}
void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    for(int x=0;x<=3000;++x)
    {
        if(check(x,N,s,c)){
            cout<<x<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const ll sz = 1e6+5;
const ll MD = 998244353;

inline ll MUL(ll a, ll b) {
	return (a * b) % MD;
}

inline ll powMod(ll a, ll p) {
	ll res = 1;
	for (; p; p >>= 1, a = MUL(a,a)) {
		if (p & 1) res = MUL(res,a);
	}
	return res;
}

inline ll DIV(ll a, ll b) {
	return MUL(a, powMod(b, MD-2));
}

inline ll ADD(ll a, ll b) {
	return (a + b) % MD;
}

ll fac[sz];
ll inv[sz];
void preCompute() {
	fac[0] = 1;
	for (int i = 1; i < sz; ++i) {
		fac[i] = MUL(fac[i-1], i);
	}
	inv[sz-1] = DIV(1, fac[sz-1]);
	for (int i = sz-2; i >= 0; --i) {
		inv[i] = MUL(inv[i+1], i+1);
		assert(MUL(inv[i], fac[i]) == 1);
	}
}

inline ll C(ll n, ll k) {
	if (k > n) return 0;
	return MUL(fac[n], MUL(inv[k], inv[n-k]));
}

// a1 + a2 + a3 + a4 = n

// C(n + 4 - 1, 4 - 1);


/*
  1 block painted -> 2 remains (cannot extend)
  2 blocks painted -> 1 remain (2 ways) (extend the two or extend the one) * length([1, 2])
  3 blocks painted -> 0 remain (1 way) * length([1,2])
*/

int main() {
	preCompute();
	ll N, M, K;
	scll(N), scll(M), scll(K);
	ll ans = 0;
	ll coef = 1;
	ll blocksPainted = 0;
	for (int i = 0; i < N; ++i) {
		++blocksPainted;
		coef = MUL(coef, M-(i > 0));
		if (N-blocksPainted <= K) {
			ans = ADD(ans, MUL(C(N-1, blocksPainted - 1), coef));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void print_i(Node x){
        if(x == NIL)return;
        print_i(x->left);
        printf(" %d", x->key);
        print_i(x->right);
}

void print_p(Node x){
        if(x == NIL)return;
        printf(" %d", x->key);
        print_p(x->left);
        print_p(x->right);      
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
          y = x;
          if(z->key < x->key){
                x = x->left;
          }else{
                x = x->right;
          }
  }

  z->parent = y;

  if(y == NIL)
          root = z;
  else if(z->key < y->key)
          y->left = z;
  else
          y->right = z;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

        for(i = 0 ; i < n ;i++){
                scanf("%s", com);
                if(strcmp(com, "insert") == 0){
                        scanf("%d", &x);
                        insert(x);      
                }else{
                        print_i(root);
                        printf("\n");
                        print_p(root);
                        printf("\n");
                }
        }

  return 0;
}


Measured memory_bytes: 25176
// finish date: 2018/03/25

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int A, B;
    cin >> A >> B;
    vvc ans;
    if (A > B) {
        ans = vvc(100, vc(100, '#'));
        B--;
    } else {
        ans = vvc(100, vc(100, '.'));
        A--;
    }
    int c = 0;
    int posy = 1, posx = 1;
    while (c != min(A, B)) {
        for (int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                if (i == 0 && j == 0) continue;
                ans[posy + i][posx + j] = (A > B) ? '.' : '#';
            }
        }
        posx += 4;
        if (posx + 1 >= 100) {
            posx = 1;
            posy += 4;
        }
        c++;
    }
    posy = 99;
    posx = 99;
    while (c < max(A, B)) {
        ans[posy][posx] = (A > B) ? '.' : '#';
        posx -= 2;
        if (posx < 0) {
            posy -= 2;
            posx = 99;
        }
        c++;
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100) {
        rep(j, 100) {
            cout << ans[i][j];
        }
        cout << endl;
    }


    return 0;
}

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

#define x first
#define y second

int n, m;
vector < vector < char > > s;
vector < vector < vector < pair < int, int > > > > g;

void ckmax (int &a, int x) {
	a = max(a, x);
}

int bfs (pair < int, int > root) {
	vector < vector < int > > d(n, vector < int > (m, 0));
	vector < vector < bool > > used(n, vector < bool > (m, 0));
	queue < pair < int, int > > q;
	used[root.x][root.y] = 1;
	q.push(root);
	while (!q.empty()) {
		pair < int, int > u = q.front();
		q.pop();
		for (auto v: g[u.x][u.y]) {
			if (!used[v.x][v.y]) {
				used[v.x][v.y] = 1;
				d[v.x][v.y] = d[u.x][u.y] + 1;
				q.push(v);
			}
		}
	}
	int res = 0;
	for (vector < int > arr: d) 
		ckmax(res, *max_element(arr.begin(), arr.end()));
	return res;
}

signed main () {
	cin >> n >> m;
	s.assign(n, vector < char > (m));
	g.assign(n, vector < vector < pair < int, int > > > (m));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> s[i][j];
			if (s[i][j] == '.') {
				if (i && s[i - 1][j] == '.') {
					g[i][j].push_back(make_pair(i - 1, j));
					g[i - 1][j].push_back(make_pair(i, j));
				}
				if (j && s[i][j - 1] == '.') {
					g[i][j].push_back(make_pair(i, j - 1));
					g[i][j - 1].push_back(make_pair(i, j));
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (s[i][j] == '.')
				ckmax(ans, bfs(make_pair(i, j)));
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};
 
template <typename Cost>
struct Edge {
  int from, to;
  Cost cost;
  Edge(int s, int t, Cost c) : from(s), to(t), cost(c) {}
};
 
template<typename Cost> using Graph = vector<vector<Edge<Cost>>>;
 
template <typename Cost>
void add_edge(Graph<Cost> &g, int from, int to, Cost cost) {
  g[from].emplace_back(from, to, cost);
}
 
template <typename Cost>
vector<Cost> bfs01(const Graph<Cost> &g, int s, Cost zero = 0) {
  vector<Cost> d(g.size(), int(1e9));
  d[s] = zero;
  using P = pair<Cost,int>;
  deque<P> que;
  que.push_back(P(zero, s));
  while (!que.empty()) {
    P top = que.front(); que.pop_front();
    Cost dist = top.first; int v = top.second;
    if (d[v] < dist) continue;
    for (const auto &e: g[v]) {
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        if (e.cost) que.push_back(P(d[e.to], e.to));
        else que.push_front(P(d[e.to], e.to));
      }
    }
  }
  return d;
}
 
void solve(ll K) {
  Graph<int> g(K);
  REP(i,K) {
    add_edge(g, i, (i + 1) % K, 1);
    add_edge(g, i, (i * 10) % K, 0);
  }
  cout << bfs01(g, 1)[0] + 1 << endl;
}
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll K;
	scanf("%lld", &K);
	solve(K);
	return 0;
}

Measured memory_bytes: 6528
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        ans = (ans < k ? ans * 2 : ans + k);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int x[100001],f[100001],su[100001];
int main(void)
{
	int n,m,i,j,y,a,b,c;
	long long sum,nn,mm;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d",&x[i]);
	for(i=1;i<=n;i++){
		f[i]=0;	su[i]=0;
	}	
	for(i=1;i<m;i++){
		if(x[i-1]<x[i]){
			f[x[i-1]]++;	f[x[i]]--;
		}
		else{
			f[x[i]]++;	f[x[i-1]]--;
		}
	}
	y=0;
	su[0]=0;
	for(i=1;i<=n;i++){
		y+=f[i];	su[i]=y;
	}
	sum=0;
	for(i=1;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		nn=(long long)a*su[i];
		mm=(long long)b*su[i]+c;
		if(nn<mm) sum+=nn;
		else sum+=mm;
	}	
	printf("%lld\n",sum);	
	return 0;
}

Measured memory_bytes: 3864
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr ll INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld PI = acos(-1);
constexpr ld EPS = 1e-11;

Vec a;

ll f(ll l, ll d, ll m, bool flg){
	if(m == 2){
		ll res = abs(a[l] - a[l + d]);
		if(!flg) if(res == 2) res = 0;
		return res;
    }
	if(m == 3){
		ll res = abs(a[l] - a[l + d * 2]);
		if(!flg) if(res == 2) res = 0;
		return res;
	}
	
	//bool flg = true;
	//rep(i, n) flg &= (a[l + d * i] != 1);

	ll res = 0;
	if(m % 2){
		res = abs(f(l, d * 2, m / 2, flg) - f(l + d * 2, d * 2, m / 2, flg));
		if(!flg) if(res == 2) res = 0;
	}else{
		res = abs(f(l, d * 2, m / 2, flg) - f(l + d, d * 2, m / 2, flg));
		if(!flg) if(res == 2) res = 0;
	}
	return res;
}

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	a.resize(n);
	bool flg = true;
	rep(i, n){
		a[i] = s[i] - '1';
		flg &= (a[i] != 1);
	}

	co(f(0, 1, n, flg));

	return 0;
}


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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=55;
//i_am_noob
int n,x,y,a[205][205],v2,v5,maxv2=-100,minv2=100,maxv5=-100,minv5=100,ans=0,ans1=0,k;
string str;

int vp(int n, int p){return n%p?0:vp(n/p,p)+1;}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(205) rep1(j,205) a[i][j]=0;
    rep(n){
        cin >> str;
        x=0,y=-1;
        rep1(j,sz(str)){
            if(str[j]=='.') y=j;
            else x=x*10+(str[j]-'0');
        }
        if(y==-1) y=sz(str)-1;
        v2=vp(x,2)-(sz(str)-y-1);
        v5=vp(x,5)-(sz(str)-y-1);
        maxv2=max(maxv2,v2),minv2=min(minv2,v2),maxv5=max(maxv5,v5),minv5=min(minv5,v5);
        a[100+v2][100+v5]++;
        //print2(v2,v5);
    }
    //print4(minv2,maxv2,minv5,maxv5);
    rep2(i1,minv2,maxv2+1) rep2(j1,minv5,maxv5+1) rep2(i2,minv2,maxv2+1) rep2(j2,minv5,maxv5+1){
        if(i1+i2>=0&&j1+j2>=0){
            k=ans;
            if(i1==i2&&j1==j2) ans+=a[100+i1][100+j1]*(a[100+i1][100+j1]-1)/2;
            else ans1+=a[100+i1][100+j1]*a[100+i2][100+j2];
            if(ans!=k){
                //print4(i1,j1,i2,j2);
                //print1(ans);
            }
        }
    }
    print1(ans+ans1/2);
    return 0;
}


Measured memory_bytes: 3912
# coding: utf-8
import re
import math
import fractions
#import numpy as np

mod=int(10**9+7)


def lcm(a,b):
    ab=a*b
    return ab//fractions.gcd(a,b)

#main
N=int(input())
A=list(map(int,input().split()))
l=A[0]
for a in range(1,N):
    l=lcm(l,A[a])
l%=mod

ans=0
for a in A:
    ans+=l*pow(a,mod-2,mod)
    ans%=mod
print(ans)

Measured memory_bytes: 67452
#include <iostream>
#include <vector>
using namespace std;

long long fibonacci(vector<long long>& array, int n) {
    if(n == 0 || n == 1) {
        return array[n];
    }
    int size = array.size();
    if(n < size) {
        return array[n];
    }
    long long ans = fibonacci(array, n-2) + fibonacci(array, n-1);
    array.push_back(ans);
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<long long> array;
    array.push_back(1);
    array.push_back(1);
    long long ans = fibonacci(array, n);
    cout << ans << endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int r;	cin>>r;
	cout<<r*r<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define setbits __builtin_popcount 
#define big 1e9+7
using namespace std;
ll n,k,m,flag,mod = 1000000000+7,cnt;
ll mat[1005][1005],dp[1005][1005];
string s = " \n";
char ch;
int main()
{
	IOS
	ll x,y;
	cin>>n>>m;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
			cin>>ch,mat[i][j] = 1*(ch == '.');
	}
	dp[0][1] = 1;
	for(int i = 1; i < n+1; ++i)
	{
		for(int j = 1; j < m+1; ++j)
		{
			if(mat[i][j])
				dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
			else dp[i][j] = 0;
		}
	}
	cout<<dp[n][m]<<endl;
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
 
int main()
{
    ll a;
    string s;
    cin >> a >> s;
    if(a>=3200){
        cout << s << endl;
    }
    else{
        cout << "red" <<endl;
    }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100000];
long long int solve(int h[],int i,int n)
{
	if(i>=(n-1))
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	else
	return dp[i]=min(abs(h[i]-h[i+1])+solve(h,i+1,n),abs(h[i]-h[i+2])+solve(h,i+2,n));
}
int main()
{
	for(int i=0;i<100000;i++)
	{
		dp[i]=-1;
	}
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	cout<<solve(h,0,n);
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
int main()
{
    ll n, x=1, y=1, z=1;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        x*=10,y*=9,z*=8;
        x%=MOD,y%=MOD,z%=MOD;
    }
    x -= y;
    x = (x+MOD)%MOD;
    x -= y;
    x = (x+MOD)%MOD;
    x +=z;
    x %= MOD;
    x = (x+MOD)%MOD;
    cout << x << endl;
}

Measured memory_bytes: 3588
/*
 *
 *
 */

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

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

int main() {
  string way = "<^>v";

  int h, w;
  cin >> h >> w;
  vvc field(h, vc(w));
  int ox, oy;
  int ix, iy, id;
  REP(y, h){
    REP(x, w){
      char c;
      cin >> c;
      switch (c) {
      case 'G':
        ox = x;
        oy = y;
        break;
      case '<':
      case '^':
      case '>':
      case 'v':
        ix = x;
        iy = y;
        id = way.find(c);
        break;
      }
      field[y][x] = c;
    }
  }

  bool d[h][w][4];
  fill_n((bool *)d, h * w * 4, false);
  set<int> number;
  while(true) {
    if (d[iy][ix][id]) {
      cout << -1 << endl;
      break;
    }
    if (ix == ox && iy == oy) {
      cout << number.size() + 1 << endl;
      break;
    }
    d[iy][ix][id] = true;
    number.insert(iy * w + ix);

    // r turn
    int rd = (id + 1) % 4;
    int rx = ix + dx[rd], ry = iy + dy[rd];
    if (0 <= rx && rx < w && 0 <= ry && ry < h && field[ry][rx] != '#') {
      id = rd;
      ix = rx;
      iy = ry;
      continue;
    }
    // go ahead
    int sx = ix + dx[id], sy = iy + dy[id];
    if (0 <= sx && sx < w && 0 <= sy && sy < h && field[sy][sx] != '#') {
      ix = sx;
      iy = sy;
      continue;
    }
    // l turn
    id = (id + 3) % 4;
  }
}

Measured memory_bytes: 3216
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "agc047_a.cpp"

int main() {

  int n;
  cin >> n;

  ll cnt[128][128] = {};
  vector<pair<ll, ll>> a(n);
  REP(i, n) {
    string s;
    cin >> s;
    int len = s.length();
    int dot = -1;
    REP(i, len) {
      if (s[i] == '.') {
        dot = i;
      }
    }
    ll b, c;
    if (dot == -1) {
      b = atoll(s.c_str());
      c = 0LL;
    } else {
      b = atoll(s.substr(0, dot).c_str());
      c = len - dot - 1;
      b *= pow(10LL, len - dot - 1);
      b += atoll(s.substr(dot + 1, len - dot - 1).c_str());
    }

    int f = 0, t = 0;
    while (b > 1 && b % 2 == 0) {
      t++;
      b /= 2;
    }
    while (b > 1 && b % 5 == 0) {
      f++;
      b /= 5;
    }
    t -= c;
    f -= c;
    a[i] = {t, f};
    cnt[t + 64][f + 64]++;
  }

  for (int i = 126; i >= 0; i--) {
    cnt[i][0] += cnt[i + 1][0];
  }
  for (int j = 126; j >= 0; j--) {
    cnt[0][j] += cnt[0][j + 1];
  }
  for (int i = 126; i >= 0; i--) {
    for (int j = 126; j >= 0; j--) {
      cnt[i][j] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i + 1][j + 1];
    }
  }

  ll ans = 0;
  REP(i, n) {
    ans += cnt[-a[i].first + 64][-a[i].second + 64];
    if (a[i].first * 2 >= 0 && a[i].second * 2 >= 0) {
      ans--;
    }
  }
  cout << ans / 2 << endl;
}


Measured memory_bytes: 6376
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
int S[100000];
int Q;
int T;
int ans;
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&S[i]);
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%d",&T);
		//T???[l,r)????????¨??????
		int l=0,r=N;
		while(r-l>1){
			int c=(l+r)/2;
			if(T<S[c])r=c;
			else l=c;
		}
		if(S[l]==T)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int cnt[2][111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int x; cin>>x; cnt[i&1][x]++;
	}
	int mx1 = 0; int mx2 = 0;
	int mxval=-1;
	for(int i=0;i<=100000;i++)
	{
		if(cnt[1][i]>=mx1)
		{
			mx2=mx1;
			mx1=cnt[1][i]; mxval=i;
		}
		else if(cnt[1][i]>=mx2)
		{
			mx2=cnt[1][i];
		}
	}
	int ans = int(1e9);
	for(int i=0;i<=100000;i++)
	{
		//first type becomes i
		if(i==mxval)
		{
			ans=min(ans,n-(mx2+cnt[0][i]));
		}
		else
		{
			ans=min(ans,n-(mx1+cnt[0][i]));
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    ll A[N];
    REP(i, N){
        cin >> A[i];
    }

    ll temp = 0, ans = 0;
    REP(i, N-1){
        temp = max(temp, A[i]);
        if (A[i+1] < temp){
            ans += temp - A[i+1];
            A[i+1] = temp;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5192
#include "bits/stdc++.h"
using namespace std;

int dx8[9] = { -1,-1,-1, 0, 1, 1, 1, 0 ,0};
int dy8[9] = { -1, 0, 1, 1, 1, 0,-1,-1,0 };
int main() {
	string st; cin >> st;
	int now = st[0] == 'o';
	int num = 1;
	for (int i = 1; i < st.size(); ++i) {
		int next = st[i] == 'o';
		if (now != next) {
			num++;
			now = next;
		}
	}
	if (num % 2) {
		if (st[0] == 'o') {
			cout << 'o' << endl;
		}
		else {
			cout << "x" << endl;
		}
	}
	else {
		cout << "o" << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include <cstdio>
#include <algorithm>
#define MAX 100000
#define INF 2e9

struct Card{
	char suit;
	int val;
};

Card L[MAX/2+2],R[MAX/2+2];

void merge(Card A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	int i,j;
	for(int i=0;i<n1;i++){
		L[i]=A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i]=A[mid+i];
	}
	L[n1].val=R[n2].val=INF;
	i=j=0;
	for(int k=left;k<right;k++){
		if(L[i].val<=R[j].val){
			A[k]=L[i++];
		}else{
			A[k]=R[j++];
		}
	}
}

void mergeSort(Card A[],int n,int left,int right){
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int partition(Card A[],int n,int p,int r){
	Card x=A[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(A[j].val<=x.val){
			i++;
			std::swap(A[i],A[j]);
		}
	}
	std::swap(A[r],A[i+1]);
	return i+1;
}

void quickSort(Card A[],int n,int p,int r){
	if(p<r){
		int q=partition(A,n,p,r);
		quickSort(A,n,p,q-1);
		quickSort(A,n,q+1,r);
	}
}

int main(void){
	int n,v;
	Card A[MAX],B[MAX];
	char S[10];
	bool flag=true;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %d",S,&v);
		A[i].suit=B[i].suit=S[0];
		A[i].val=B[i].val=v;
	}
	mergeSort(A,n,0,n);
	quickSort(B,n,0,n-1);
	for(int i=0;i<n;i++){
		if(A[i].suit!=B[i].suit)flag=false;
	}
	printf("%s\n",flag?"Stable":"Not stable");
	for(int i=0;i<n;i++){
		printf("%c %d\n",B[i].suit,B[i].val);
	}
	return 0;
}

Measured memory_bytes: 3380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * Property Distribution
 */
public class Main {

	static int DISTRIBUTED = 0;
	static Queue<Integer> xs, ys;
	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {

			int h = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int w = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			// read in.
			int[][] prop = new int[h + 2][w + 2];
			for (int i = 1; i < h + 1; ++i) {
				line = br.readLine();
				for (int j = 1; j < w + 1; ++j) {
					prop[i][j] = line.charAt(j - 1);
				}
			}

			// solve
			xs = new ArrayDeque<Integer>();
			ys = new ArrayDeque<Integer>();
			count = 0;
			for (int i = 1; i < h + 1; ++i) {
				for (int j = 1; j < w + 1; ++j) {
					if (prop[i][j] != DISTRIBUTED) {
						int fruit = prop[i][j];
						xs.add(i);
						ys.add(j);
						while (!xs.isEmpty() && !ys.isEmpty()) {
							distribute(prop, fruit);
						}
						++count;
					}
				}
			}
			// print
			System.out.println(count);
		}
	}

	static void distribute(int[][] prop, int fruit) {

		final int V[] = { 1, -1, 0, 0 };
		final int H[] = { 0, 0, 1, -1 };

		int x, y;
		x = xs.poll();
		y = ys.poll();

		if (prop[x][y] == fruit) {

			// prop[x][y] = DISTRIBUTED;
			prop[x][y] ^= prop[x][y];

			for (int i = 0; i < 4; ++i) {
				int xv, yh;
				xv = x + V[i];
				yh = y + H[i];
				if (prop[xv][yh] == fruit) {
					xs.offer(xv);
					ys.offer(yh);
				}
			}
		}
	}
}

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

int main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a <= k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
def main():
    n = int(input())
    vs = list(map(lambda x: int(x), input().split(' ')))
    vs.sort()
    ans = vs[0] / (2 ** (n - 1))
    for i in range(1, n):
        ans += (vs[i] / (2 ** (n - i)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
// ※※※ 解答不能 ※※※
// 以下のソースを勉強する.
// E869120氏.
// https://atcoder.jp/contests/jsc2019-qual/submissions/7109342
#include <bits/stdc++.h>
using namespace std;
#pragma warning (disable: 4996)
using LL = long long;
LL mod = 1000000007;
int A[300009];

int main(){
    
    int N;
    char C[210012];
    scanf("%d %s", &N, C);
    string S(C);
    
    if(S[0] == 'W' || S[S.size() - 1] == 'W'){
        printf("%d\n", 0);
        return 0;
    }
    for(int i = 0; i < S.size(); i++){
        if(i == 0) A[i] = 1;
        else if(S[i - 1] != S[i]){
            if(A[i - 1] == 1) A[i] = 1;
            else              A[i] = 0;
        }else{
            if(A[i - 1] == 1) A[i] = 0;
            else              A[i] = 1;
        }
    }
    
    LL dep = 0, ans = 1;
    for(int i = 0; i < S.size(); i++){
        if(A[i] == 1){
            dep++;
        }else{
            ans *= dep;
            ans %= mod;
            dep--;
        }
        if(dep < 0){
            printf("%d\n", 0);
            return 0;
        }
    }
    if(dep != 0){
        printf("%d\n", 0);
        return 0;
    }
    for(LL i = 1; i <= N; i++){
        ans *= i;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

// ローリングハッシュ
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};

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

    // ロリハ
    RollingHash rh(S);

    // 二分探索判定
    auto check = [&](int d) -> bool {
        for (int i = 0; i < N; ++i) {
            for (int j = i+d; j+d <= N; ++j) {
                if (S[i] != S[j]) continue;
                if (rh.get(i, i+d) == rh.get(j, j+d)) return true;
            }
        }
        return false;
    };

    // 二分探索
    int left = 0, right = N/2 + 1;
    while (right - left > 1) {
        int mid = (left + right) >> 1;
        if (check(mid)) left = mid;
        else right = mid;
    }
        
    cout << left << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_155
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            for(int i = 0; i < n; i++)
            {
                if (array[i] % 2 == 1)
                {
                    continue;
                }

                if (array[i] % 3 == 0 || array[i] % 5 == 0)
                {
                    continue;
                }

                WriteLine("DENIED");
                return;
            }
            WriteLine("APPROVED");
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

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

void solve() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	if (b > a) {
		printf("No\n"); return;
	}
	if (b > d) {
		printf("No\n"); return;
	}
	if (b <= c) {
		printf("Yes\n"); return;
	}
	ll flag = b - gcd(b, d) + (a % gcd(b, d));
	if (flag > c) printf("No\n");
	else printf("Yes\n");
}

int main() {
	int t; cin >> t;
	rep(i, 0, t) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
  int n;
  int *a, *b, *c;
  int sum = 0;
  int last_dish = -99;
  
  cin >> n;
  
  a = new int[n];
  b = new int[n];
  c = new int[n];
  
  // A
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  // B
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  
  // C
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  
  // calc
  for (int i = 0; i < n; i++) {
    int dish_num = a[i];
    sum += b[dish_num - 1];
    
    if (last_dish + 1 == dish_num) {
      sum += c[dish_num - 1 - 1];
    }
    
    last_dish = dish_num;
  }
  
  cout << sum << endl;
  
  return 0;
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ')
                .Select(x => int.Parse(x)).ToList();
            var n = input[0];

            var inputs = new List<int>(n);

            for (int i = 0; i < n; i++)
            {
                var y = Console.ReadLine().Split(' ')
                    .Select(x => int.Parse(x)).ToList();
                var z = y[0];
                inputs.Add(z);
            }
            var inputs2 = new List<int>(inputs);
            inputs2.Sort();
            inputs2.Reverse();
            int once = inputs2[0];
            int second = inputs2[1];

            for (int i = 0; i < n; i++)
            {
                if (inputs[i] == once)
                {
                    Console.WriteLine(second);
                }
                else
                {
                    Console.WriteLine(once);
                }
            }
        }
    }
}

Measured memory_bytes: 20124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int m;
   cin >> m;
   cout << 24 + (24-m) << endl;

   return 0;
}

Measured memory_bytes: 256
from numpy import array as n
N, C = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(N)]
r1, r2, l1, l2 = [0],[0],[0],[0]
sum = 0
for x, cal in xy:
    sum += cal
    r1.append(max(r1[-1], sum-x))
    r2.append(max(r2[-1], sum-2*x))
sum = 0
for x, cal in xy[::-1]:
    sum += cal
    l1.append(max(l1[-1], sum-C+x))
    l2.append(max(l2[-1], sum-2*(C-x)))
a = max(n(r1)+n(l2[::-1]))
b = max(n(r2)+n(l1[::-1]))
print(max(a,b))

Measured memory_bytes: 51688
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;

int main() {
 
   string S;
   string T;
   cin >> S >> T;
   cout << T+S << endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int v, next, c, w;
    edge() {}
    edge(int _v, int _next, int _c, int _w) {
        v = _v, next = _next, c = _c, w = _w;
    }
} e[100010];
int head[2010], tot = -1;
void addedge(int u, int v, int c, int w) {
    e[++tot] = edge(v, head[u], c, w);
    head[u] = tot;
    e[++tot] = edge(u, head[v], 0, -w);
    head[v] = tot;
}
int n, m, s, t, ansc;
long long answ;
long long dis[2010];
int last[2010], laste[2010], liu[2010];
bool inque[2010];
queue < int > q;
int spfa(int s, int t) {
    memset(dis, 63, sizeof dis);
    memset(liu, 0, sizeof liu);
    dis[s] = 0;
    inque[s] = 1;
    liu[s] = 10000000;
    q.push(s);
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        inque[now] = 0;
        for (int i = head[now]; ~i; i = e[i].next) {
            if (e[i].c && e[i].w + dis[now] < dis[e[i].v]) {
                last[e[i].v] = now;
                laste[e[i].v] = i;
                liu[e[i].v] = min(liu[now], e[i].c);
                dis[e[i].v] = e[i].w + dis[now];
                if (!inque[e[i].v])
                    inque[e[i].v] = 1, q.push(e[i].v);
            }
        }
    }
    if (liu[t] == 0)
        return 0;
    for (int u = t; u != s; u = last[u]) {
        e[laste[u]].c -= liu[t];
        e[laste[u] ^ 1].c += liu[t];
    }
    ansc += liu[t];
    answ += liu[t] * dis[t];
}
int main() {
    memset(head, -1, sizeof head);
    int n;
    scanf("%d", &n);
    s = 0, t = n * 2 + 5;
    for (int i = 1; i <= n; i++) {
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        addedge(s, i, c, 0);
        addedge(i, n * 2 + 1, c, + x + y);
        addedge(i, n * 2 + 2, c, + x - y);
        addedge(i, n * 2 + 3, c, - x + y);
        addedge(i, n * 2 + 4, c, - x - y);
    }
    for (int i = 1; i <= n; i++) {
        int x, y, c;
        scanf("%d%d%d", &x, &y, &c);
        addedge(i + n, t, c, 0);
        addedge(n * 2 + 1, i + n, c, - x - y);
        addedge(n * 2 + 2, i + n, c, - x + y);
        addedge(n * 2 + 3, i + n, c, + x - y);
        addedge(n * 2 + 4, i + n, c, + x + y);
    }
    while (spfa(s, t));
    return cout << -answ << endl, 0;
}

Measured memory_bytes: 768