akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  combination comb(200100);
  int sum = 0;
  for (int i = 1; i <= n; ++i) {
    sum += i;
  }
  ll lowit = n;
  ll highit = 0;
  mint high = sum;
  mint low = sum;
  for (int i = n; i >= k - 1; --i) {
    int kesukaisu = n - i;
    ans += high - low + 1;
    high -= highit;
    low -= lowit;
    highit++;
    lowit--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6428
#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;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}

ll dp[3001][3001][4],arr[3001][3001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    memset(dp,0,sizeof(dp));
    memset(arr,0,sizeof(arr));
    ll r,c,k;
    cin>>r>>c>>k;
    for(ll i=0;i<k;i++){
        ll p,q,r;
        cin>>p>>q>>r;
        p--;q--;
        arr[p][q] = r;
    }
    dp[r-1][c-1][1] = arr[r-1][c-1];
    dp[r-1][c-1][2] = arr[r-1][c-1];
    dp[r-1][c-1][3] = arr[r-1][c-1];
    for(ll i=r-1;i>=0;i--){
        for(ll j=c-1;j>=0;j--){
            if(i==r-1 && j==c-1)
                continue;
            if(i<r-1)
                dp[i][j][3] = max(dp[i][j][3],(max(dp[i+1][j][1]+arr[i][j],max(dp[i+1][j][2]+arr[i][j],max(dp[i+1][j][0]+arr[i][j],dp[i+1][j][3]+arr[i][j])))));
            if(j<c-1)
                dp[i][j][3] = max(dp[i][j][3],max(dp[i][j+1][3], dp[i][j+1][2]+arr[i][j]));
            if(i<r-1)
                dp[i][j][2] = max(dp[i][j][2],(max(dp[i+1][j][1]+arr[i][j],max(dp[i+1][j][2]+arr[i][j],max(dp[i+1][j][0]+arr[i][j],dp[i+1][j][3]+arr[i][j])))));
            if(j<c-1)
                dp[i][j][2] = max(dp[i][j][2],max(dp[i][j+1][2], dp[i][j+1][1]+arr[i][j]));
            if(i<r-1)
                dp[i][j][1] = max(dp[i][j][1],(max(dp[i+1][j][1]+arr[i][j],max(dp[i+1][j][2]+arr[i][j],max(dp[i+1][j][0]+arr[i][j],dp[i+1][j][3]+arr[i][j])))));
            if(j<c-1)
                dp[i][j][1] = max(dp[i][j][1],max(dp[i][j+1][1],dp[i][j+1][0]+arr[i][j]));
            if(i<r-1)
                dp[i][j][0] = max(dp[i][j][0],max(dp[i+1][j][1],max(dp[i+1][j][2],max(dp[i+1][j][0],dp[i+1][j][3]))));
            if(j<c-1)
                dp[i][j][0] = max(dp[i][j][0],dp[i][j+1][0]);
            //cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<" "<<dp[i][j+1][0]<<en;
        }
    }
    cout<<max(dp[0][0][3],max(dp[0][0][0],max(dp[0][0][1],dp[0][0][2])));
}


Measured memory_bytes: 363196
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
struct edge{
    ll v,d;
};

int n,q,k,x[100010],y[100010];
vector<edge> G[100010];
ll d[100020];
void dfs(int i,ll dis){
    d[i] = dis;
    REP(j,G[i].size()){
        if(d[G[i][j].v] < 0)
            dfs(G[i][j].v,G[i][j].d + dis);
    }
}
int main(){
    scanf("%d",&n);
    REP(i,n - 1){
        ll a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--;b--;

        G[a].pb((edge){b,c}); G[b].pb((edge){a,c});
    }

    scanf("%d%d",&q,&k);
    REP(i,q){
        scanf("%d%d",x + i,y + i);
    }
    fill(d,d + n,-1);
    dfs(k - 1,0);
    REP(i,q){
        printf("%lld\n",d[x[i] - 1] + d[y[i] - 1]);
    }
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, mod = 1000000007;
    long long f = 1;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        f *= i;
        f %= mod;
    }
    cout << f;
}

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

for i in range(1, n):
    a[i] += a[i-1]

ans = 10**20
l = 0
r = 2
for c in range(1, n-2):
    r = max(r, c+1)

    while l+1 < c and abs(a[c]-2*a[l]) >= abs(a[c]-2*a[l+1]):
        l += 1
    while r+1 < n and abs(a[-1]-2*a[r]+a[c]) >= abs(a[-1]-2*a[r+1]+a[c]):
        r += 1

    x = [a[l], a[c]-a[l], a[r]-a[c], a[-1]-a[r]]
    x.sort()
    ans = min(ans, x[3]-x[0])

print(ans)


Measured memory_bytes: 24684
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

class Comb{
  public:
  const int n;
  vector<ll> fac,refac;
  Comb(int N) : n(N),fac(N+1,1),refac(N+1,1) {
    rep(i,n)fac[i+1] = fac[i]*(i+1)%MOD;
    refac[n] = modpow(fac[n],MOD-2);
    for(int i = n;i > 0;i--)refac[i-1] = refac[i]*i%MOD;
  }
  ll comb(ll n,ll r){
    if(n < r)return 0;
    ll res = fac[n]*refac[r]%MOD;
    res = res*refac[n-r]%MOD;
    return res;
  }
  ll modpow(ll n,ll r){
    ll res = 1;
    while(r){
      if(r & 1)res = res*n%MOD;
      n = n*n%MOD;
      r >>= 1;
    }
    return res;
  }
};


int main(){
  
  int n,m;
  cin >> n >> m;
  Comb cb(m);
  ll res = cb.fac[m]*cb.refac[m-n]%MOD;
  res = res*res%MOD;
  for(int i = 1;i <= n;i++){
    ll k = cb.comb(n,i)*cb.fac[m]%MOD;
    k = k*cb.refac[m-n]%MOD;
    k = k*cb.fac[m-i]%MOD;
    k = k*cb.refac[m-n]%MOD;
    if(i & 1){
      res = (res-k+MOD)%MOD;
    }else{
      res = (res+k)%MOD;
    }
  }
  cout << res << "\n";


  

  return 0;
}

Measured memory_bytes: 11116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,N,M,ans;

int main() {
	cin >> N >> M;
	
	cout << (pow(2,M)*((N-M)*100+1900*M));
	
	return 0;
}


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

typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;

const int INF = 1000000;

int H, W, S;
int sum;

P dp[33][33][33][33];

P div(mat &v, int x, int y, int h, int w) {
    if (dp[x][y][h][w].first > 0) return dp[x][y][h][w]; 

    auto Area = [&]() -> int {
        int punder = (x > 0 && y > 0) ? v[x - 1][y - 1] : 0;
        int funder = (x > 0) ? v[x - 1][y + w - 1] : 0;
        int ptop = (y > 0) ? v[x + h - 1][y - 1] : 0;
        int ftop = v[x + h - 1][y + w - 1]; 

        return ftop - funder - ptop + punder;
    };

    if (Area() < sum - S) return P(-INF, -INF);

    P res = P(1, S - (sum - Area()));

    auto Max = [&](P p) {
        if (p.first > res.first) {
            res.first = p.first;
            res.second = p.second;
        } else if (p.first == res.first) {
           res.second = max(res.second, p.second);
        }
    };

    for (int i = 1; i < h; i++) {
        P p1 = div(v, x, y, i, w);
        P p2 = div(v, x + i, y, h - i, w);

        if (p1.first <= 0 && p2.first <= 0) continue;

        P tmp = P(p1.first + p2.first, min(p1.second, p2.second));
        Max(tmp);
    }

    for (int j = 1; j < w; j++) {
        P p1 = div(v, x, y, h, j);
        P p2 = div(v, x, y + j, h, w - j);

        if (p1.first <= 0 && p2.first <= 0) continue;

        P tmp = P(p1.first + p2.first, min(p1.second, p2.second));
        Max(tmp);
    }

    dp[x][y][h][w].first = res.first;
    dp[x][y][h][w].second = res.second;


    return res;
}

void solve(mat d) {
    auto v = d;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int up = i > 0 ? v[i - 1][j] : 0;
            int left = j > 0 ? v[i][j - 1] : 0;
            int sub = (i > 0 && j > 0) ? v[i - 1][j - 1] : 0;
            v[i][j] += up + left - sub;
        }
    }

    P res = div(v, 0, 0, H, W);

    cout << res.first << " " << res.second << endl;
}

int main() {
    while (cin >> H >> W >> S, H || W || S) {
        for (int i = 0; i < 33; i++) {
            for (int j = 0; j < 33; j++) {
                for (int k = 0; k < 33; k++) {
                    for (int l = 0; l < 33; l++) {
                        dp[i][j][k][l].first = -1;
                        dp[i][j][k][l].second = -1;
                    }
                }
            }
        }

        mat d(H, vec(W));
        sum = 0;
        for (auto &v : d) {
            for (auto &c : v) {
                cin >> c;
                sum += c;
            }
        }

        solve(d);
    }

    return 0;
}

Measured memory_bytes: 12460
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
https://beta.atcoder.jp/contests/abc091/tasks/abc091_b
"""

from collections import defaultdict

rewards = defaultdict(lambda: 0)

N = int(input())
for i in range(N):
    rewards[input()] += 1

M = int(input())
for j in range(M):
    rewards[input()] -= 1

print(max(0, max(rewards.values())))





Measured memory_bytes: 3316
#include <bits/stdc++.h>
    using namespace std; 
    int main() {
        int x,k ; 
        cin>> k>>x  ; 

        for(int i=max(x -k+1, (int)-1e6); i<= min(x+k-1, (int)1e6 );i++ ) {
            cout << i << ' ' ;
        }

        return 0 ; 
    }

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

int main() {
    long long a, b, c, d, e, f, g;
    while (cin >> a >> b >> c >> d >> e >> f >> g) {
        long long res = 0;
        long long m = min(a, min(d, e));
        for (long long i = max(m-2, 0LL); i <= m; ++i) {
            long long tmp = i * 3;
            long long na = a - i, nd = d - i, ne = e - i;
            tmp += na/2 * 2;
            tmp += nd/2 * 2;
            tmp += ne/2 * 2;
            res = max(res, tmp);
        }
        cout << res + b << endl;
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
// 素因数分解
vector<pair<long long, long long>> prime_factorize(long long N)
{
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a)
  {
    if (N % a != 0)
      continue;
    long long ex = 0; // 指数

    // 割れる限り割り続ける
    while (N % a == 0)
    {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main()
{
  cout << fixed << setprecision(10);
  ll A,B;
  cin >> A >> B;
  ll N = gcd(A,B);
  vector<pair<long long, long long>> vec = prime_factorize(N);
  cout << vec.size() + 1 << endl;
  return 0;
}


Measured memory_bytes: 3600
uses
  SysUtils,
  Classes;

 procedure mainProc;
	var
		r: Integer;
	begin
	readln(r);
	if  (r >= 2800) then
		writeln('AGC')
	else if  (r >= 1200) then
		writeln('ARC')
	else
		writeln('ABC');
	end;
 
begin
mainProc;
end.


Measured memory_bytes: 256
object Main extends App {
	val Array(n, k) = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	def calc(x: Long): Long = {
		x*x*x
	}

	if(k%2 == 1){
		val cnt = n/k
		println(calc(cnt))
	}else{
		val cnt0 = n/k
		val cnt1 = n/(k/2) - n/k
		println(calc(cnt1) + calc(cnt0))
	}

}

Measured memory_bytes: 25544
h,w = map(int,input().split())
mod = 10**9+7
a = [list(input()) for i in range(h)]
a[0][0] = 1
for i in range(1,w):
    if a[0][i] == '.':
        a[0][i] = a[0][i-1]
    else:
        a[0][i] = 0
for i in range(1,h):
    if a[i][0] == '.':
        a[i][0] = a[i-1][0]
    else:
        a[i][0] = 0
for i in range(1,h):
    for j in range(1,w):
        if a[i][j] == '.':
            a[i][j] = (a[i-1][j]+a[i][j-1])%mod
        else:
            a[i][j] = 0
print(a[-1][-1])

Measured memory_bytes: 153004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll gcd(ll a, ll b)
{
    if (b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b))*b;
}

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

    ll ans = 1;
    rep(i, n) {
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

N = I()
A = LI()

l = []
r = []
for i, a in enumerate(A):
    l.append(i+1+a)
    r.append(i+1-a)

rr = collections.Counter(r)
ans = 0
for ll in l:
    ans += (rr[ll])

print(ans)


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

//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll a[200001];
int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	ll r = -10000000000;
	ll l = 10000000000; 
	rep(i, n) {
		cin >> a[i];
		a[i] -= (i + 1);
		r = max(r, a[i]);
		l = min(l, a[i]);
	}
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll ans = 0;
		rep(i, n) {
			ans += abs(a[i] - mid); 
		}
		ll cmp = mid - 1;
		ll cnt = 0;
		rep(i, n) {
			cnt += abs(a[i] -cmp);
		}
		if (ans >= cnt) {
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	ll ans = 0;
	rep(i, n) {
		ans += abs(a[i] - r);
	}
	cout << ans << '\n';




}

Measured memory_bytes: 1792
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))

    if N==K:
        print(1)
    else:
        N=N-K
        print(1+-(-N//(K-1)))


resolve()

Measured memory_bytes: 14004
<?php
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
 
  for($i=0; $i<3; $i++){
      if($i==0){
          $p = $c[$i][$i];
          for($j=1; $j<3; $j++){
              $w[$j] = $c[$i][$j]-$p;
              $h[$j] = $c[$j][$i]-$p;
          }
          continue;
      }
      foreach($w as $j => $s){
          if($s != $c[$i][$j]-$c[$i][0]){
              echo "No";
              exit;
          }
      }
    //   foreach($h as $j => $s){
    //       if($s != $c[$j][$i]-$c[0][$i]){
    //           echo "No";
    //           exit;
    //       }
    //   }
  }
  echo "Yes";

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


int main(){
  long long int a,b,c,d,n,m;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  if(b>=0 && d>=0){
    if(a<0 && c<0){
      n=a*c;
      m=b*d;
      if(n>m)	
	printf("%lld\n",n);
      else
	printf("%lld\n",m);
    }
    else
      printf("%lld\n",b*d);
  }
  else if(a>=0 && d<=0)
    printf("%lld\n",a*d);
  else if(c>=0 && b<=0)
    printf("%lld\n",b*c);
  else
    printf("%lld\n",a*c);
  return 0;
}

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

#define PI (acos(-1.0))
#define DBG printf("Hi\n")
#define loop(i,n) for(i =1 ; i<=n; i++)
#define mp make_pair
#define pb push_back
#define mod 1000000007LL
#define INF 1000000000
#define xx first
#define yy second
#define sq(x) ((x)*(x))
#define eps 0.0000000001
#define i64 long long int
#define ui64 unsigned long long int

using namespace std ;

#define maxn 100005

int main()
{
    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&k) ;

    i64 ans = ( n/k )*( n/k )*(n/k) ;

    if( k%2==0 )
    {
        j = k/2 ;

        if( n>= j )
        {
            i = (n-j)/k + 1 ;
            ans += i*i*i ;
        }
    }

    cout<<ans<<endl ;

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=100;i++) {
        for(int j=0;j<=100;j++) {
            if((i*2+j*4==y)&&(i+j==x)) {
                cout<<"Yes\n";
                return;
            }
        }
    }
    cout<<"No\n";
    return;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
using namespace std;
long long power2(long long a, long long b, long long c)
 {
     long long res = 1;
     a %= c;
     while (b)
     {
         if (b & 1)
             res = (res * a) % c;
         a = (a * a) % c;
         b >>= 1;
     }
     return res;
}
int main()
{
	int n,a,i,j,k[100005]={0},t=1;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		k[a]++;
	}
	if(n%2==0)
	{
		for(i=1;i<n;i+=2)
		if(k[i]!=2)
		t=0;
	}
	else
	{
		if(k[0]!=1)
		t=0;
		for(i=2;i<n;i+=2)
		if(k[i]!=2)
		t=0;
	}
	if(t)
	{
		printf("%lld",power2(2,n/2,1000000007));
	}
	else
	printf("0");
}

Measured memory_bytes: 640
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    int n;
    cin>>n;
    int cnt=-1;
    string s;
    rep(i,n+1){
        s=to_string(i);
        if(s.length()%2==1) cnt++;
    }
    cout<<cnt<<endl;
    
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

class D {
	int n;
	string s;
	const int MOD{ 1000000007 };
public:
	D()
	{
		cin >> n >> s;
	}
	void solve()
	{
		vi v;

		int i{ 0 };
		while (i < n)
		{
			if (i == n - 1)
			{
				v.PB(1);
				++i;
			}

			else if (s[i] == s[i + 1])
			{
				v.PB(0);
				i += 2;
			}

			else
			{
				v.PB(1);
				i++;
			}
		}


		ll ans;
		int last{ v.back() };
		if (last)
			ans = 3;
		else
			ans = 6;
		v.pop_back();

		while (!v.empty())
		{
			if (last)
			{
				ans = ans * 2 % MOD;
				last = v.back();
				v.pop_back();
			}

			else
			{
				if (!v.back())
					ans = ans * 3 % MOD;

				last = v.back();
				v.pop_back();
			}

		}

		cout << ans << endl;
	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

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

int main(void)
{
    int M;
    std::cin >> M;
    int D;
    std::cin >> D;

    int cnt = 0;
    for (int i = 1; i <= M; i++) {
        for (int j = 1; j <= D; j++) {
            int d1 = j % 10;
            int d10 = j / 10 % 10;
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) {
                cnt++;
            }
        }
    }
    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

newUF :: PrimMonad m => Int -> m (VM.MVector (PrimState m) Int)
newUF n = do
  d <- VM.new n
  VM.set d (-1)
  return d

findUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> m Int
findUF d x = do
  dx <- VM.read d x
  if dx < 0
    then return x
    else do dx' <- findUF d dx
            VM.write d x dx'
            return dx'

uniteUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> Int -> m ()
uniteUF d x y = do
  x' <- findUF d x
  y' <- findUF d y
  when (x' /= y') $ do
    let (x'', y'') = if (x' <= y') then (x', y') else (y', x')
    dx <- VM.read d x''
    dy <- VM.read d y''
    VM.write d x'' (dx + dy)
    VM.write d y'' x''
  return ()

sameUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> Int -> m Bool
sameUF d x y = do
  fx <- findUF d x
  fy <- findUF d y
  return $ fx == fy

sizeUF :: PrimMonad m => VM.MVector (PrimState m) Int -> Int -> m Int
sizeUF d x = do
  fx <- findUF d x
  dfx <- VM.read d fx
  return (-dfx)


main = do
  [n, m] <- getIntList

  uf <- newUF n

  replicateM_ m $ do
    [a, b] <- getIntList
    uniteUF uf (a-1) (b-1)

  let solve :: Int -> Int -> IO Int
      solve i res | i >= n = return res
                  | otherwise = do
                      sz <- sizeUF uf i
                      solve (i+1) (max res sz)
  ans <- solve 0 0
  print ans


Measured memory_bytes: 20436
#include<stdio.h>
int main(){
  int n;
  int z,w,a;
  int i;
  scanf(" %d",&n);
  for(i=0;i<n;i++){
    scanf(" %d %d %d",&z,&w,&a);
    if((z*z)+(w*w)==a*a){
      printf("YES\n");
    }else{
      if((w*w)+(a*a)==z*z){
	printf("YES\n");
      }else{
	if((a*a)+(z*z)==w*w){
	  printf("YES\n");
	}else{
	  printf("NO\n");
	    }
      }
    }
  }
  return(0);
}
    

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

int main(int argc, char const *argv[]) {
  string s;
  int k;
  cin>>k>>s;
  for(int i=0; i<s.length(); i++){
    if(i+1<=k){
      cout<<s[i];
    }
    else{
      cout<<"...";
      break;
    }
  }
  return 0;
}


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

int main(){
    int c[3][3], a[3], b[3];
    rep(i, 3)rep(j, 3) cin >> c[i][j];
    a[0] = 0;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    bool ok = true;
    rep(i, 3)rep(j, 3) {
        if (a[i] + b[j] != c[i][j]) {
            ok = false;
            break;
        }
    }
    if (ok) puts("Yes");
    else puts("No");
    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    ll k = 0;
    for (ll i = 0; i < n; i++)
    {

        if (i + 1 != p[i])
        {
            k++;
        }
    }
    if (k == 2 || k == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;

int main(){
    int x,a;
    cin>>x>>a;
    int ans = x<a ? 0 : 10;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int m, d, ret = 0;
  cin >> m >> d;
  for (int i = 1; i <= m; ++i) {
    for (int j = 11; j <= d; ++j) {
      int x = j / 10, y = j % 10;
      if (x > 1 && y > 1 && i == x * y) ++ret;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static Scanner scanner = new Scanner(System.in);
 
    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] d = new int[n];
        Arrays.fill(d, 1, n, Integer.MAX_VALUE);
        Map<Integer, Map<Integer, Integer>> dist = new HashMap<>();
        for (int i = 0; i < n; i++) {
            dist.put(i, new HashMap<>());
        }
 
        for (int i = 0; i < n - 1; i++) {
            int u = scanner.nextInt() - 1;
            int v = scanner.nextInt() - 1;
            int w = scanner.nextInt() & 1;
            dist.get(u).put(v, w);
            dist.get(v).put(u, w);
        }
 
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(0);
        while (!deque.isEmpty()) {
            int i = deque.poll();
            for (Map.Entry<Integer, Integer> entry : dist.get(i).entrySet()) {
                if (d[entry.getKey()] > d[i] + entry.getValue()) {
                    d[entry.getKey()] = d[i] + entry.getValue();
                    deque.add(entry.getKey());
                }
            }
        }
 
        for (int i : d) {
            System.out.println(i & 1);
        }
    }
}

Measured memory_bytes: 120120
#include <stdio.h>
int main(void){
int a;
scanf("%d",&a);
if(a == 25)
{
  printf("Christmas");
}
if(a == 24)
{
  printf("Christmas Eve");
}
if(a == 23)
{
  printf("Christmas Eve Eve");
}
if(a == 22)
{
  printf("Christmas Eve Eve Eve");
}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define p_q priority_queue
#define MN 1000000007

ll n, m, t;
ll f(ll X){
    ll C=1;
    for (ll l=2; l<=X; ++l) C=(C*l)%MN;
    return C;
}
int main(){
    cin >> n >> m;
    if (n>m){
        t=n; n=m; m=t;
    }
    if (n<m-1){
        cout << 0; return 0;
    }
    if (n==m){
        cout << f(n)*f(m)*2%MN;
    } else {
        cout << f(n)*f(m)%MN;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int s[3] = {};
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;

        s[(p > a) + (p > b)]++;
    }

    cout << min(min(s[0], s[1]), s[2]) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


map<int, int> factorize(int n) {
    map<int, int> res;

    for (int i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res[i] = 0;
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }

    if (n != 1) res[n] = 1;
    return res;
}


int all_gcd(vector<int> &v) {
    int now = v.front();
    for (int l : v) now = __gcd(now, l);
    return now;
}

vector<vector<int>> all_prime_vec(vector<int> &v) {
    vector<vector<int>> ans(v.size());

    rep(i, v.size()) {
        auto f = factorize(v[i]);

        for (auto e : f) {
            if (e.first != 1) {
                ans[i].push_back(e.first);
            }
        }

    }

    return ans;
}

map<int, int> all_prime_set(vector<vector<int>> &v) {
    map<int, int> ans;
    int n = v.size();
    rep(i, n) {
        for (int l : v[i]) {
            ans[l]++;
        }
    }
    return ans;
}

bool has_pair(vector<vector<int>> &v, map<int, int> &s) {
    int n = v.size();
    rep(i, n) {
        for (int l : v[i]) {
            s[l]--;
            if (s[l] == 0) s.erase(s.find(l));
        }

        for (int l : v[i]) {
            auto it = s.find(l);
            if (it != s.end()) return true;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int a = all_gcd(v);

    vector<vector<int>> a_vec = all_prime_vec(v);
    map<int, int> a_set = all_prime_set(a_vec);

    bool b = has_pair(a_vec, a_set);

    if (!b) {
        cout << "pairwise coprime" << endl;
    } else if (a == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }

}


Measured memory_bytes: 75796
def ascan; gets.split.map(&:to_i); end

N, M = ascan
aa = ascan

if M == 1
    if N == 1
        puts aa[0]
        p 1
        puts aa[0]
    else
        puts aa[0]
        p 2
        puts [1, N-1]*" "
    end
    exit
end

oo = aa.select(&:odd?)

if oo.size > 2
    puts "Impossible"; exit
end

if oo.size >= 1
    aa -= oo
    aa.unshift(oo.pop)
    aa.push(oo.pop) unless oo.empty?
end

bb = []
off = 0
aa.each do |a|
    bb << a + 1 - off
    off = 1
end

bb[-1] -= 1
bb.pop if bb[-1] == 0

puts aa*" "
p bb.size
puts bb*" "

Measured memory_bytes: 1788
//11-4 1年生
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)

int N;
int num[100];
LL dp[100][21];//0～20

int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        num[i] = tmp;
		for(int j=0; j<21; j++){
			dp[i][j] = 0;
		}
    }
	
	dp[0][num[0]] = 1;
	for(int t=1; t<N-1; t++){
		for(int i=0; i<21; i++){
			if(dp[t-1][i]>0 && i+num[t]<21) dp[t][i+num[t]] += dp[t-1][i];
			if(dp[t-1][i]>0 && i-num[t]>=0) dp[t][i-num[t]] += dp[t-1][i];
		}
	}
    
    cout << dp[N-2][num[N-1]] << endl;
    return 0;
}



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

using namespace std;

const int N = 2001;

int f[N * 2][N], bl[N], wt[N], bit[N * 2], n, p;
char x;

void upd (int x, int v)
{
    if (!x)
        return;
    for (; x < (N * 2); x += x & -x)
        bit[x] += v;
}

int get (int x)
{
    int rep = 0;
    for (; x; x -= x & -x)
        rep += bit[x];
    return rep;
}

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < (N * 2); ++i)
        for (int j = 0; j < N; ++j)
            f[i][j] = 1e9;
    f[0][0] = 0;
    for (int i = 1; i <= (n * 2); ++i)
    {
        cin >> x >> p;
        if (x == 'B')
            bl[p] = i;
        else
            wt[p] = i;
    }
    for (int i = 1; i <= (n * 2); ++i)
    {
        memset(bit, 0, sizeof bit);
        for (int j = 1; j <= (n * 2); ++j)
            upd(j, 1);
        int k = min(i, n);
        for (int j = 1; j <= k; ++j)
            upd(wt[j], -1);
        for (int j = 1; j <= (i - k); ++j)
            upd(bl[j], -1);
        for (int j = max(0, i - n); j <= min(i, n); )
        {
            if (i > j)
                f[i][j] = min(f[i][j], f[i - 1][j] + get(wt[k]));
            if (j)
                f[i][j] = min(f[i][j], f[i - 1][j - 1] + get(bl[j]));
            upd(wt[k--], 1);
            upd(bl[++j], -1);
        }
    }
    cout << f[n * 2][n];
    return 0;
}

Measured memory_bytes: 31616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;


class f {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }
    vector<vector<int>> G;
    void dfs(vector<int>& dist, int v, int p, int d) {
        dist[v] = d;
        for (int to : G[v]) {
            if (to == p) continue;
            dfs(dist, to, v, d + 1);
        }
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n, u, v;
        cin >> n >> u >> v;
        u--, v--;

        G.resize(n);
        REP(i, n-1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        vector<int> distu(n), distv(n);
        dfs(distu, u, -1, 0);
        dfs(distv, v, -1, 0);
        int res = -1;
        REP(i, n) {
            if (distu[i] < distv[i]) {
                res = max(res, distv[i] - 1);
            }
        }

        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    f solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 10624
# ABC124C - Coloring Colorfully
def main():
    S = input()
    a = sum(i != "1" for i in S[::2]) + sum(i != "0" for i in S[1::2])
    b = len(S) - a
    print(min(a, b))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}

signed main() {
	int n;
	cin >> n;
	if (n % 2)cout << (n / 2 + 1)*(n / 2) << endl;
	else cout << (n / 2)*(n / 2) << endl;
	endre;
}

Measured memory_bytes: 256
s =  list(input())
combo = False
cnt = 0
ans = [0,] 
for mozi in s:
    if(mozi == "A" or mozi == "G" or mozi == "C" or mozi == "T"):
        cnt = cnt + 1 
        if combo != True:
            combo = True
    else:
        if combo:
            ans.append(cnt)
            cnt = 0
            combo = False
ans.append(cnt)
print(max(ans))


Measured memory_bytes: 9040
#include<iostream>
using namespace std;
int c[10000001];
int main()
{
	int n,m,a,b;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
	cin>>a>>b;
	for(int j=1;j<=n;j++){
	if(a==j||b==j)
	c[j]++;}
	}
	for(int j=1;j<=n;j++)
	cout<<c[j]<<endl;
	return 0;
}

Measured memory_bytes: 256
import math
a,b,h,m = map(int,input().split())

deg1 = 30 * h + 0.5*m
deg2 = 6*m
deg3 = deg2 - deg1
ans = a**2 + b**2 - (2*a*b*math.cos(math.radians(deg3)))
print(ans**0.5)


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

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

  if (x <= 599) {
    cout << 8 << endl;
  } else if (x <= 799) {
    cout << 7 << endl;
  } else if (x <= 999) {
    cout << 6 << endl;
  } else if (x <= 1199) {
    cout << 5 << endl;
  } else if (x <= 1399) {
    cout << 4 << endl;
  } else if (x <= 1599) {
    cout << 3 << endl;
  } else if (x <= 1799) {
    cout << 2 << endl;
  } else if (x <= 1999) {
    cout << 1 << endl;
  }
  return 0;
}

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

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int p = 1e9 + 7;
const int mod = p;
const int inf = 1e18;
const int maxn = 2e5+5;

void solve(){
	string s; cin>>s;
	int ans = 0;
	rep(i, 0, sz(s)){
		ans += s[i] - '0';
	}
	if(ans%9 == 0) cout<<"Yes";
	else cout<<"No";

}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); //io();
    //cout<<setprecision(12);
    int tc=1; //0cin>>tc; //int t = 1; 
    while(tc--){
    	//cout<<"Case #"<<t<<": "; ++t;
        solve();cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3780