akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define MAX 250

struct node{
  int key;
};

int l;

int Parent(int i){
  if(i == 1) return 0;
  return i / 2;
}

int Left(int i){
  if(l < (2 * i)) return 0;
  else return 2 * i;
}

int Right(int i){
  if(l < (2 * i + 1)) return 0;
  return (2 * i) + 1;
}

int main(){
  int i;
  struct node h[MAX];

  scanf("%d",&l);
  for(i = 1; i <= l; i++){
    scanf("%d",&h[i].key);   
  }

  for(i = 1; i <= l; i++){
    printf("node %d: key = %d, ",i,h[i].key);
    if(Parent(i) != 0)
      printf("parent key = %d, ",h[Parent(i)].key);
    if(Left(i) != 0)
      printf("left key = %d, ",h[Left(i)].key);
    if(Right(i) != 0)
      printf("right key = %d, ",h[Right(i)].key);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
#define ttttyyyy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fo(i,n,m) for(int i=n;i<m;i++)
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define ft first
#define se second
#define ci(x) int x; cin>>x
ll a[200002]={0};
int main(){
    ttttyyyy
    ci(n);
    int b;
    fo(i,0,n-1){
        cin>>b;
        a[b]++;
    }
    fo(i,1,n+1){
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);

}

signed main() {
	char s[100001], t[100001];

	scanf("%s %s", s, t);

	string str(s), stt(t);

	vector<int> rs(str.length()+2), rt(str.length()+2);
	REP(i, str.length()) {
		if (str[i] == 'B')
			rs[i + 1] += 1;
		rs[i+1] += rs[i];
	}
	REP(i, stt.length()) {
		if (stt[i] == 'B')
			rt[i + 1] += 1;
		rt[i + 1] += rt[i];
	}
	
	int n;
	scanf("%d", &n);
	REP(i, n) {

		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		a--; c--;
		int bc = rs[b] - rs[a];
		bc += (b - a - bc) * 2;

		int bt = rt[d] - rt[c];
		bt += (d-c- bt) * 2;

		if (!(abs(bc -bt)%3)) {
			printf("YES\n");
		}
		else
			printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
    int X;
    int Y;
    cin >> X >> Y;
    if(X == 1 && Y == 1){
        cout << 1000000 << endl;
    }
    else if(X == 2 && Y == 2){
        cout << 400000<< endl;
    }
    else if(X == 3 && Y == 3){
        cout << 200000 << endl;
    }
    else if(X == 1 && Y == 2){
        cout << 500000 << endl;
    }
    else if(X == 1 && Y == 3){
        cout << 400000 << endl;
    }
    else if(X == 2 && Y == 1){
        cout << 500000 << endl;
    }
    else if(X == 2 && Y == 2){
        cout << 300000 << endl;
    }
    else if(X == 2 && Y == 3){
        cout << 300000 << endl;
    }
    else if(X == 3 && Y == 1){
        cout << 400000 << endl;
    }
    else if(X == 3 && Y == 2){
        cout << 300000 << endl;
    }
    else if(X == 3 && Y == 3){
        cout << 200000 << endl;
    }
    else if(X == 1 && Y >= 4){
        cout << 300000 << endl;
    }
    else if(X == 2 && Y >= 4){
        cout << 200000 << endl;
    }
    else if(X == 3 && Y >= 4){
        cout << 100000 << endl;
    }
    else if(X >= 4 && Y == 1){
        cout << 300000 << endl;
    }
    else if(X >= 4 && Y == 2){
        cout << 200000 << endl;
    }
    else if(X >= 4 && Y == 3){
        cout << 100000 << endl;
    }
    else if(X >= 4 && Y <= 4){
        cout << 0 << endl;
    }
    else{
    cout << 0 << endl;
    }
}


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

int main() {
  int a, b, r = 0;
  cin >> a >> b;
  rep(i, b-a+1){
    string s = to_string(a+i);
    if(s[0] == s[4] && s[1] == s[3]) ++r;
  }
  cout << r << endl;
  return 0;
}

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

int main() {
  string  s;
  cin >> s;
  int n=s.size();
  int m = 0;
  rep(i,n-1) {
      if(s[i+1]=='9') m+=(s[i]-'0');
      else {
        m+=((s[i]-'0')-1);
        for (int j = i+1; j < n; j++) s[j] = '9';
      }
  }
  m += s.at(n-1)-'0';
  cout << m << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  
  int n;
  cin >> n;
  string ans;
  while (n) {
    if (n % 2) {
      n--;
      ans = "1" + ans;
    } else {
      ans = "0" + ans; 
    }
    n /= -2;
  }
  
  if (ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
N = int(input())

pre = ""
suf = ""
f = 1
for i in range(N):
  Q = input()
  if Q[0] == "1":
    f *= -1
  elif Q[2] == "1":
    if f > 0:
      pre = Q[4] + pre
    else:
      suf = suf + Q[4]
  else:
    if f < 0:
      pre = Q[4] + pre
    else:
      suf = suf + Q[4]

ans = pre + S + suf
if f > 0:
  print(ans)
else:
  print(ans[::-1])



Measured memory_bytes: 4616
#include<cstdio>
#include<algorithm>
typedef long long ll;
using namespace std;
int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int a[200000];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n-k;i++){
        int f=1;
        if(a[i]>=a[i+k]) f=0;
        if(f) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

bool is_prime(int a) {
  int s = sqrt(a);
  FOR(i, 2, s) {
    if (a % i == 0) return false;
  }
  return true;
}

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  while(!is_prime(x)) x++;
  cout << x << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	string s;
	cin >> s;
		
	if (s == "ABC") {
		cout << "ARC" << endl;
	} else {
		cout << "ABC" << endl;
	}

}


Measured memory_bytes: 3624
M, D = map(int, input().split())
ans = 0
for i in range(int(M)):
    m = i+1
    for j in range(int(D)):
        d10= (j+1)//10
        d1 = (j+1)-d10*10
        if d1>=2 and d10>=2 and d1*d10 ==m:
            ans +=1
print(ans)

Measured memory_bytes: 3060
// AOJ 2005: Water Pipe Construction
// 2017.9.24 bal4u@uu
// 2017.11.21

#include <stdio.h>
#include <string.h>
#define MAX 100000

int dist[102][102];
char buf[50], *p;

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, s, g1, g2, b1, b2, i, j, k, x, ans;

	while (fgets(p=buf, 50, stdin) && *p != '0') {
		n = getint(), p++, m = getint(), p++;
		s = getint(), p++, g1 = getint(), p++, g2 = getint();
		memset(dist, 0x11, sizeof(dist));
		for (i = 0; i <= n; i++) dist[i][i] = 0;

		while (m--) {
			fgets(p=buf, 50, stdin);
			b1 = getint(), p++, b2 = getint(), p++;
			dist[b1][b2] = getint();
		}
        for (k = 1; k <= n; k++) for (i = 1; i <= n; i++) {
			if (dist[i][k] > MAX) continue;
			for (j = 1; j <= n; j++) {
				x = dist[i][k] + dist[k][j];
		        if (dist[i][j] > x) dist[i][j] = x;
			}
        }
		for (ans = 0x7ffffff, i = 1; i <= n; i++) {
			if ((x = dist[s][i] + dist[i][g1] + dist[i][g2]) < ans) ans = x;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1892
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 1e5+2;

ll dp[102][N];
ll wt[N], val[N];

int main()
{
   int n; ll  W;
   scn(n); lscn(W);

   rep(i, 1, n+1) {
      scanf("%lld%lld", &wt[i], &val[i]);
   }

   rep(i, 0, 102) {
      dp[i][0] = 0;
   }

   rep(i, 1, n+1) {
      rep(j, 1, W+1) {
         if(wt[i] <= j) {
            dp[i][j] = max({dp[i][j], val[i] + dp[i-1][j-wt[i]], dp[i-1][j]});
         } else {
            dp[i][j] = dp[i-1][j];
         }
      }
   }

   lprin(dp[n][W]);
   return 0;
}

Measured memory_bytes: 78720
#include<stdio.h>
#define MAX 10001
#define NIL -1
void Preorder(int);
void Inorder(int);
void Postorder(int);
typedef struct Node{int p,l,r;}Node;
Node T[MAX];
int n;

int main(){
  int i,u,l,r,id;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&l,&r);     
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }
  for(i = 0; i < n; i++) if(T[i].p == NIL) u = i;
  printf("Preorder\n");
  Preorder(u);
  printf("\nInorder\n");
  Inorder(u);
  printf("\nPostorder\n");
  Postorder(u);
  printf("\n");
  return 0;
}


void Preorder(int u){
  if(u == NIL) return;
  printf(" %d",u);
  Preorder(T[u].l);
  Preorder(T[u].r);
}

void Inorder(int u){
  if(u == NIL) return;
  Inorder(T[u].l);
  printf(" %d",u);
  Inorder(T[u].r);
}

void Postorder(int u){
  if(u == NIL) return;
  Postorder(T[u].l);
  Postorder(T[u].r);
  printf(" %d",u);
}

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

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define YES_ cout<<"Yes"<<endl; return 0;
#define NO_ cout<<"No"<<endl; return 0;


int main() {

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) {
		YES_;
	}
	NO_;




}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int res = INF;
    rep(i, n - k + 1) {
        chmin(res, abs(x[i]) + abs(x[i + k - 1] - x[i]));
        chmin(res, abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]));
    }
    cout << res << endl;
}

Measured memory_bytes: 3704
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A1, A2, A3 = nl()

print(min(abs(A3 - A2) + abs(A2 - A1),
          abs(A3 - A1) + abs(A1 - A2),
          abs(A1 - A2) + abs(A2 - A3),
          abs(A1 - A3) + abs(A3 - A2),
          abs(A2 - A1) + abs(A1 - A3),
          abs(A2 - A3) + abs(A3 - A1)))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x);
        x=(x*x);
        y=y/2;
    }
    return res;
}
int main()
{
    ll n,p,a,b,c;
    cin>>n;
    ll v[n+1][3],dp[n+1][3];
    for(ll i=0;i<n;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];

    dp[0][0]=v[0][0],dp[0][1]=v[0][1],dp[0][2]=v[0][2];
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+v[i][0],dp[i-1][2]+v[i][0]);//present ai plus the answer of the other two of the prev day
        dp[i][1]=max(dp[i-1][0]+v[i][1],dp[i-1][2]+v[i][1]);
        dp[i][2]=max(dp[i-1][0]+v[i][2],dp[i-1][1]+v[i][2]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

vector<i64> factor(i64 x){
    vector<i64> res={x};
    for(i64 i=2; i*i<=x; ++i){
        if(x%i==0){
            res.push_back(i);
            if(i*i!=x) res.push_back(x/i);
        }
    }
    sort(begin(res),end(res));
    return res;
}

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

i64 mod_comb(i64 n, i64 k, i64 p) {
    if (n < 0 or k < 0 or n < k) return 0;
    //i64 num=fact[n]*mod_inverse(fact[n-k],p)%p,den=fact[k];
    i64 num = 1, den = 1;
    for (i64 i = 0; i < k; ++i) {
        num = num * ((n - i) % p) % p;
        den = den * (i + 1) % p;
    }
    return num * mod_inverse(den, p) % p;
}

void solve(){
    i64 N,M,mod=1'000'000'007;
    cin >> N >> M;

    if(M==1){
        cout << 1 << endl;
        return;
    }

    auto fs=factor(M);

    vector<map<i64,i64>> dp(32);
    ++dp[0][1];
    rep(i,0,31){
        for(auto& p:dp[i]){
            i64 x=p.first,cnt=p.second;
            for(i64 f:fs){
                i64 y=x*f;
                if(M%y!=0) continue;
                dp[i+1][y]+=cnt;
                dp[i+1][y]%=mod;
            }
        }
    }

    i64 ans=0;
    rep(i,0,32){
        ans+=dp[i][M]*mod_comb(N,i,mod);
        ans%=mod;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char x = sc.next().charAt(0);
		char y = sc.next().charAt(0);
		if(x > y) {
			System.out.println(">");
		} else if(x < y){
			System.out.println("<");
		} else {
			System.out.println("=");
		}
	}
}

Measured memory_bytes: 20692
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int r,d,a;
	cin>>r>>d>>a;
	for (int i=0;i<10;i++){
		a=r*a-d;
		cout<<a<<"\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b!=c)
    cout<<"Yes";
  else if(a==c && a!=b)
    cout<<"Yes";
  else if(b==c && a!=b)
    cout<<"Yes";
  else cout<<"No";
  return 0;
}

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

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

    ll n;
    cin >> n;
    
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    
    ll ans1,ans2,maxv;
    ans1 = a[n-1];
    ans2 = a[0];
    maxv = 1e9;
    
    ll c = ans1 / 2;

    for(int i = 0; i < n - 1; i++){
        if(maxv >= abs(a[i] - c)){
            maxv = abs(a[i] - c);
            ans2 = a[i];
        }
    }
    
    cout << ans1 << " " << ans2 << endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[25],n,ans;
int ex[25][25];
int main(){
	cin>>n;repn(i,n)cin>>a[i];
	repn(i,n-1)ex[a[i]][a[i+1]]+=1;
	repn(i,n) {int b; cin>>b; ans+=b; }
	repn(i,n-1) {int b; cin>>b; ans+=ex[i][i+1]*b; }
	cout << ans << endl;
}

Measured memory_bytes: 256
std=[]
n=int(input())
cmb=[[] for i in range(n)]
cmb[0].append("a")
tmp=[[] for i in range(n)]
for i in range(1,n):
	for j in range(len(cmb)):
		for s in cmb[j]:
			for k in range(0,j+1):
				tmp[j].append(s+chr(ord("a")+k))
			tmp[j+1].append(s+chr(ord("a")+k+1))
	#print(cmb)
	cmb=tmp
	tmp=[[] for i in range(n)]
lst=[]
for i in range(len(cmb)):
	for std in cmb[i]:
		lst.append(std)
lst.sort()
for i in range(len(lst)):
	print(lst[i])

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B;
  int i=0;
  cin>>A>>B;
  
      if(A>=13){
      i=B;
      }else if(A>=6){
        i=B/2;
      }else{
        i=0;
      }
  cout<<i<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = LLONG_MAX;

ll n, k;
vector<P> p, q;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        p.push_back({x, y});
        q.push_back({y, x});
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    ll smin = INF;
    for (int i1 = 0; i1 < n; i1++) {
        for (int i2 = 0; i2 < n; i2++) {
            for (int j1 = 0; j1 < n; j1++) {
                for (int j2 = 0; j2 < n; j2++) {
                    ll cnt = 0, xmax, xmin, ymax, ymin;
                    xmax = max(max(p[i1].first,p[i2].first),max(p[j1].first,p[j2].first));
                    xmin = min(min(p[i1].first,p[i2].first),min(p[j1].first,p[j2].first));
                    ymax = max(max(p[i1].second,p[i2].second),max(p[j1].second,p[j2].second));
                    ymin = min(min(p[i1].second,p[i2].second),min(p[j1].second,p[j2].second));
                    for (int m = 0; m < n; m++) {
                        ll nx = p[m].first, ny = p[m].second;
                        if (nx >= xmin && nx <= xmax && ny >= ymin &&
                            ny <= ymax)
                            cnt++;
                    }
                    if (cnt >= k)
                        smin = min(smin, (xmax - xmin) * (ymax - ymin));
                }
            }
        }
    }
    cout << smin << endl;
    return 0;
}

Measured memory_bytes: 384
L=(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)
k=int(input())
print(L[k-1])


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,r,n) for(int i=r; i<=n; i++)
#define sz(v) (int)(v).size()
#define vec(x) vector < x >
using vi = vector < int >;
using mii = map <int , int >;
using vvi = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
const int inf = 2e9 + 7;
const char nwl = '\n';
const int mxx = 1e6 + 3;
int64 sumV(vi &v) {
	int64 s = 0;
	for (int x : v) {
		s += (int64)x;
	}
	return s;
}
int gcd(int a, int b) {
	if (!b) return a;
	return gcd(b, a % b);
}
//const int64 biGinf = 9e+18;
const string yo = "Yes\n", no = "No\n";


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

	int x;
	cin >> x;
	if (x < 30) cout << no;
	else cout << yo;

	return 0;
}

Measured memory_bytes: 3640
c = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
N = n=int(input()) 
print(c[N-1])

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf(" %lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 600000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
int n, m, k;
signed main() {
	cin >> n >> m >> k;
	int ans = 0;
	rng(i, 1, n) {
		ans += comb(n * m - 2, k - 2) * i * (n - i) % mod * m * m % mod;
		ans %= mod;
	}
	rng(i, 1, m) {
		ans += comb(n * m - 2, k - 2) * (m - i) % mod * n * n % mod * i;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9600
n,w=map(int,input().split())
dp=[[0]*(w+1) for _ in range(n)]
l=[0]*n
for i in range(n):
    l[i]=list(map(int,input().split()))
#print(l)
for i in range(w+1):
    if i>=l[0][0]:
        dp[0][i]=l[0][1]
for i in range(w+1):
    for j in range(n-1):
        if i<l[j+1][0]:
            dp[j+1][i]=dp[j][i]
        else:
            dp[j+1][i]=max(dp[j][i-l[j+1][0]]+l[j+1][1],dp[j][i])


print(dp[-1][-1])

Measured memory_bytes: 119916
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
        while (v[i] % 2 == 0)
        {
            v[i] /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();

		int m = (n % k == 0) ? 0 : 1;
		System.out.println(m);
	}
}



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

int main(){
    
    string s,t;
    cin >> s >> t;

    int count=0;

    for(int i=0;i<3;i++){
        if(s[i] == t[i]){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int n,k;
  cin >> n >> k;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  sort(all(v));
  reverse(all(v));
  ll ans = 0;
  rep(i,min(n,k))v[i] = 0;
  rep(i,n)ans += v[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int h,a;
  cin >> h >> a;
  
  if(h%a==0)
  {
      cout << h/a;
      
  }
  else
  {
    cout << h/a+1;
  }   
  
  
} 

Measured memory_bytes: 256
//
//  main.cpp
//  bubble_sort
//
//  Created by ???????????? on 2017/09/30.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include<stdio.h>

static const int N = 1000;

void swap(int* a, int* b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

void trace(int A[], int n){
    int i;
    for ( i = 0; i < n; i++ ){
        if ( i > 0 ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void bubble_sort(int n, int A[]){
    int i, j, k;
    bool flag = true;
    i = 0;
    k = 0;
    while(flag){
        flag = false;
        for(j = n-1; j >= (i+1); j-- ){
            if(A[j] < A[j-1]){
                swap(&A[j], &A[j-1]);
                flag = true;
                k++;
            }
        }
        i++;
    }
    trace(A, n);
    printf("%d", k);
    printf("\n");
}

int main(int argc, const char * argv[]) {
    int n;
    int A[N];
    

    
    //get n and A
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);

    bubble_sort(n, A);
    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m; cin >> n >> m;
    if(n == 0) break;
    vvi d1(n, vi(n, INF)), d2(n, vi(n, INF));
    for(int i=0;i<n;++i) {
      d1[i][i] = 0;
      d2[i][i] = 0;
    }
    for(int i=0;i<m;++i) {
      int x, y, t; char c; cin >> x >> y >> t >> c;
      x--; y--;
      if(c == 'L') {
        d1[x][y] = t;
        d1[y][x] = t;
      } else {
        d2[x][y] = t;
        d2[y][x] = t;
      }
    }
    for(int k=0;k<n;++k) {
      for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
          if(d1[i][k] == INF || d1[k][j] == INF) continue;
          d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);
        }
      }
    }
    for(int k=0;k<n;++k) {
      for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
          if(d2[i][k] == INF || d2[k][j] == INF) continue;
          d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
        }
      }
    }
    int r; cin >> r;
    vector<int> z(r);
    for(int i=0;i<r;++i) {
      cin >> z[i];
      z[i]--;
    }
    vvi dp(r, vi(n, INF));
    dp[0][z[0]] = 0;
    for(int i=0;i<r-1;++i) {
      for(int j=0;j<n;++j) {
        if(dp[i][j] != INF && d1[z[i]][z[i+1]]) {
          dp[i+1][j] = min(dp[i+1][j], dp[i][j] + d1[z[i]][z[i+1]]);
        }
        for(int k=0;k<n;++k) {
          if(dp[i][j] == INF || d1[z[i]][j] == INF ||
            d2[j][k] == INF || d1[k][z[i+1]] == INF) continue;
          dp[i+1][k] = min(dp[i+1][k], dp[i][j] + d1[z[i]][j] + d2[j][k] + d1[k][z[i+1]]);
        }
      }
    }
    int mi = INF;
    for(int i=0;i<n;++i) {
      mi = min(mi, dp[r-1][i]);
    }
    cout << mi << endl;
  }
}



Measured memory_bytes: 4108
n = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(n)]

for i in range(n):
    if A[i] < 0:
        A[i] = abs(A[i])
        L[i] = L[i] + 1 

if sum(L)%2 != 0:
    B = sum(A)-min(A)*2
else:
    B = sum(A)

print(B)

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    ll n, m; cin>>n>>m;
    ll k; cin>>k;
    vll a(n), b(m);
    for(i = 0; i < n; i++) cin>>a[i];
    for(i = 0; i < m; i++) cin>>b[i];
    vll sumb(m);
    sumb[0] = b[0];
    for(i = 1; i < m; i++) sumb[i] = sumb[i-1] + b[i];
    ll cur = 0;
    int ans = 0;
    for(i = 0; i <= n; i++){
        ll t = k;
        if(i){
            cur += a[i-1];
            t -= cur;
            if(t < 0) break;
        }
        auto it = up(all(sumb), t);
        int ca = 0;
        if(it == sumb.end()) ca = m + i;
        else if(it == sumb.begin()) ca = 0 + i;
        else ca = it - sumb.begin() + i;
        ans = max(ans,ca);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7944
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 100100;
int a[maxn];
int n;

int gcd(int a, int b) {
    while (a && b) {
        if (a >= b)
            a %= b;
        else
            b %= a;
    }
    return a + b;
}

bool win() {
    ll turns = 0;
    vector<int> odd;
    forn (i, n) {
        turns += a[i] - 1;
        if (a[i] % 2 && a[i] > 1)
            odd.push_back(i);
    }
    if (n == 1 || turns % 2)
        return turns % 2;

    if (sz(odd) == 1) {
        a[odd[0]]--;
        int g = 0;
        forn (i, n)
            g = gcd(g, a[i]);
        forn (i, n)
            a[i] /= g;
        return !win();
    }

    return false;
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    cin >> n;
    forn (i, n)
        cin >> a[i];
    cout << (win() ? "First\n" : "Second\n");
}


Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3,typename T4> inline void print4(T1 a, T2 b, T3 c, T4 d){
	cout << a << " " << b << " " << c << " " << d << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll l; cin >> l;
	vl a(l); rep(i,l) cin >> a[i];
	vvl dp(l+1,vl(3,linf));
	rep(i,3) dp[0][i] = 0;
	vl sum(l+1,0);
	for(ll i=l-1; i>=0; i--){
		sum[i] += sum[i+1] + a[i];
	}
	vl sum2(l+1,0);
	rep(i,l){
		sum2[i+1] += sum2[i] + a[i];
	}
	rep(i,l){
		ll c = a[i]%2;
		if(a[i]==0) c = 2;
		dp[i+1][0] = dp[i][0] + c;
		dp[i+1][1] = min(dp[i][0],dp[i][1]) + 1 - (a[i]%2);
		dp[i+1][2] = min(dp[i][1],dp[i][2]) + c;
		chmin(dp[i+1][0],sum2[i+1]);
	}
	vvl dp2(l+1,vl(3,linf));
	rep(i,3) dp2[l][i] = 0;
	for(ll i=l-1; i>=0; i--){
		ll c = a[i]%2;
		if(a[i]==0) c = 2;
		dp2[i][0] = dp2[i+1][0] + c;
		dp2[i][1] = min(dp2[i+1][0],dp2[i+1][1]) + 1 - (a[i]%2);
		dp2[i][2] = min(dp2[i+1][1],dp2[i+1][2]) + c;
		chmin(dp2[i][0],sum[i]);
	}
	ll ans = linf;
	rep(i,l+1){
		rep(j,3){
			chmin(ans,dp[i][j]+sum[i]);
		}
	}
	rep(i,l+1){
		rep(j,3){
			chmin(ans,dp2[i][j]+sum2[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 26752
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
int main()
{
	int k;
	cin>>k;
	ll ans=0;
	rep3(i,1,k+1)
	{
		rep3(j,1,k+1)
		{
			rep3(m,1,k+1)
			{
				ans+=__gcd(i,__gcd(j,m));
			}
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();

    let mut v = vec![];
    for i in 1..n + 1 {
        if i * i > n {
            break;
        }

        if n % i == 0 {
            v.push((i, n / i));
        }
    }

    let mut ans = i64::max_value();
    for (a, b) in v {
        let mut a = a;
        let mut b = b;
        let mut x = 0;
        let mut y = 0;
        while a > 0 || b > 0 {
            if a > 0 {
                a /= 10;
                x += 1;
            }
            if b > 0 {
                b /= 10;
                y += 1;
            }
        }
        ans = std::cmp::min(ans, std::cmp::max(x, y));
    }

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin>> a >> b;
  if(a>=13)cout << b <<endl;
  if(a<=5)cout << 0 <<endl;
  if(6<=a&& a<=12)cout << b/2 <<endl;
  return 0;
}

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

days=[]
dp = [0]*3
for _ in range(n):
  a = list(map(int,input().split()))
  days.append(a)

for i in range(3):
  dp[i]=days[0][i]
  
#rint(dp)
for cday in range(1,n):
  pday = cday-1
  t = [0]*3
  for i in range(3):
    max_val = dp[i]
    for j in range(3):
      if i!=j:
        cur_val = dp[j] + days[cday][i]
        if cur_val>max_val:
          max_val=cur_val
    
    t[i] = max_val
  dp=t
  #rint(dp)
  	
print(max(dp))
  
  

Measured memory_bytes: 61528
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	IN(n);
	vl v;
	FOR(i, 0, n)
	{
		IN(in);
		v.push_back(in);
	}
	ll a=0;
	vl sum;
	FORD(i, n - 1, -1)
	{
		a =(a+ v[i])%MOD;
		sum.pb(a);
		//what(a);
	}
	reverse(all(sum));
	ll ans = 0;
	FOR(i, 0, n-1)
	{
		ans = (ans + sum[i+1] * v[i]) % MOD;
	}
	cout << ans << endl;

}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 7952
#include <iostream>
#include <cmath>

int main(){
  int n;
  std::cin >> n;

  int d[n];
  for(auto i = 0;i < n;i++){
  	std::cin >> d[i];
  }
  
  auto total = 0;
  for(auto i = 0;i < n - 1;i++){
  	for(auto j = i + 1;j < n;j++){
    	total += d[i] * d[j];
    }
  }
  
  std::cout << total << 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;

int main()
{
    int n, x;
    cin >> n >> x;
  
  	int m_min = 1000000;
  	rep(i, n)
    {
      int tmp;
      cin >> tmp;
      
      if (m_min > tmp)
      {
        m_min = tmp;
      }
      
      x -= tmp;
    }
  
    cout << n + x / m_min << endl;

    return 0;
}

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

vector<long> dp;
vector<long> pre;

void rec(int i, vector<int>& nottaken, long scoresofar, int mask, int group)
{
  if(i==nottaken.size())
  {
    dp[mask]=max(dp[mask],scoresofar+pre[group]);
    return;
  }
  rec(i+1,nottaken,scoresofar,mask,group);
  rec(i+1,nottaken,scoresofar,mask^(1<<nottaken[i]),group^(1<<nottaken[i]));
  
}


int main(){
  int n;
  cin>>n;
  vector<vector<long>> a(n,vector<long>(n));
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  }
  
  pre.resize(1<<n);
  for(int mask=0;mask<(1<<n);mask++)
  {
    for(int i=0;i<n;i++)
    {
      if(mask&(1<<i))
      {
        for(int j=i+1;j<n;j++)
        {
          if(mask&(1<<j))
            pre[mask]+=a[i][j];
        }
      }
    }
  }
  
  
  dp.resize(1<<n,-99999999);
  dp[0]=0;
  for(int mask=0;mask<(1<<n);mask++)
  {
    vector<int> nottaken;
    for(int i=0;i<n;i++)
    {
      if(!(mask&(1<<i)))
         nottaken.push_back(i);
    }
    rec(0,nottaken,dp[mask],mask,0);
  }
  cout<<dp[(1<<n)-1];
  
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    ll n, x, a[100005], i, ans = 0;

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

    for(i = 0; i < n - 1; i++){
        if(a[i] + a[i + 1] > x){
            if(a[i] > x){
                ans += a[i] + a[i + 1] - x;
                a[i] = x;
                a[i + 1] = 0;
            }
            else{
                ans += a[i] + a[i + 1] - x;
                a[i + 1] -= a[i] + a[i + 1] - x;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024