akhauriyash/Code-Regression huggingface dataset:
s = input()
x, y = map(int, input().split())

x_list = []
y_list = []

st = s.split("T")
x -= len(st[0])

for i, ls in enumerate(st[1:]):
    if i % 2:
        x_list.append(len(ls))
    else:
        y_list.append(len(ls))

def judge(xy, ls):
    dp = set([0])
    for l in ls:
        tmp = []
        for v in dp:
            tmp.append(v+l)
            tmp.append(v-l)
        dp = set(tmp)
    return xy in dp

print("Yes" if judge(x, x_list) and judge(y, y_list) else "No")


Measured memory_bytes: 3816
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <limits.h>



int main(int argc, char const *argv[]) {
    int i =1;
    scanf("%d", &i);
    int *a;
    i *=2;
    a = (int *)malloc(sizeof(int) * i);
    for (size_t j = 0; j < i; j++) {
        int k;
        scanf("%d", &k);
        a[j] = k;
    }
    for (int q = 0; q < i - 1; q++) {
       for (int j = i - 1; j > q; j--) {
           if (a[j - 1] < a[j]) {  /* 前の要素の方が大きかったら */
               int temp = a[j];        /* 交換する */
               a[j] = a[j - 1];
               a[j - 1]= temp;
           }
       }
   }

    int answer = 0;
    for (size_t m = 1; m < i;) {
        answer += a[m];
        m+=2;
    }
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

vector<pair<lint, int>> Pfact(lint num) {
	vector<pair<lint, int>> res;
	for (lint i = 2; i * i <= num; i++) {
		int cnt = 0;
		while (num % i == 0) {
			cnt++;
			num /= i;
		}
		if (cnt) res.emplace_back(i, cnt);
	}
	if (num != 1) res.emplace_back(make_pair(num, 1));
	return res;
}

class Combi {
private:
	vector<lint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

public:
	Combi(int N) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	int Cmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	lint Pmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n - k] % MOD;
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	auto pfM = Pfact(M);
	
	Combi C(100030); // 30 > log2(10^9)
	lint ans = 1;
	for (const auto &elem : pfM) {

		ans *= C.Cmod(N - 1 + elem.second, N - 1);
		ans %= MOD;

	}

	cout << ans << "\n";

	return 0;
}


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

int N;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N;
    vector<ll> a(N);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());
    ll ub = a[0];
    for (int i = 1; i < N - 1; i++) {
		if (a[i] <= a[N - 1] / 2) {
			if (a[N - 1] / 2 - a[i] < a[N - 1] / 2 - ub) {
				ub = a[i];
			}
		} else {
			if (abs(a[i] - ceil(a[N - 1] / (double)2)) < abs(ub - ceil(a[N - 1] / (double)2))) {
				ub = a[i];
			}
		}
	}
    cout << a[N - 1] << " " << ub;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    vector<pair<ll, ll>> p(N);
    for (int i = 0; i < N; i++)
    {
        ll x, y;
        cin >> x >> y;
        p[i] = make_pair(x, y);
    }

    SORT(p);
    int ans = 0;
    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
                continue;

            int tmpP = p[j].first - p[i].first;
            int tmpQ = p[j].second - p[i].second;
            int cnt = 0;
            for (int k = 0; k < N; k++)
            {
                for (int l = 0; l < N; l++)
                {
                    if (k == l)
                        continue;
                    if (p[k].first - p[l].first == tmpP && p[k].second - p[l].second == tmpQ)
                    {
                        cnt++;
                    }
                }
            }
            ans = max(ans, cnt);
        }
    }

    cout << N - ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int n;
int main(){
	read(n);
	while(n--){
		int t,x,y;
		read(t),read(x),read(y);
		if(x+y>t){
			puts("No");
			exit(0); 
		}
		if((x+y)%2!=t%2){
			puts("No");
			exit(0);
		}
	}
	puts("Yes");
	exit(0);
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SplittingPile solver = new SplittingPile();
        solver.solve(1, in, out);
        out.close();
    }

    static class SplittingPile {
        long[] a;
        long result;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            a = new long[n];
            result = Long.MAX_VALUE;

            long sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in.next());
                sum += a[i];
            }
            long beer = 0;
            for (int i = 0; i < n - 1; i++) {
                sum -= a[i];
                beer += a[i];
                result = Math.min(result, Math.abs(sum - beer));
            }
            out.println(result);
        }

    }
}



Measured memory_bytes: 60768
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin >> n;
    if(n & 1){
        cout << 0;
    }
    else{
        ll yo = 5;
        ll ans = 0;
        while(n >= (yo << 1)){
            ans += n / (yo << 1);
            yo *= 5LL;
        }
        cout << ans;
    }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pi 3.14159265358979323846
#define IL inline
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define Rep(i,a,b) for(int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    ll x=0;char f=0;char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);pc('\n');}
IL void wri(ll x){write(x),pc(' ');}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define y1 ____y1
#define hash __hash
#define union _union
#define ramdom ((double)rand() / RAND_MAX)
#define x first
#define y second
const int maxn = 300030;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn*2];
int first[maxn],nume;
void Addedge(int a,int b){
	edge[nume] = Edge(b,first[a]);
	first[a] = nume++;
}
int mxdep[maxn],wson[maxn],sz[maxn];
int dfn[maxn],dfx[maxn],n,k;
int dp_array[maxn];
int *f[maxn];
void init(int u,int fa){
	mxdep[u] = 0;wson[u] = 0;sz[u] = 1;
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v == fa) continue;
		init(v,u);
		mxdep[u] = max(mxdep[u],mxdep[v] + 1);
		sz[u] += sz[v];
		if(!wson[u] || mxdep[v] > mxdep[wson[u]])
			wson[u] = v;
	}
}
void pre(int u,int fa){
	dfx[dfn[u] = ++*dfn] = u;
	f[u] = dp_array + dfn[u];
	if(wson[u]) pre(wson[u],u);
	for(int e=first[u];~e;e=edge[e].nxt){
		int v=edge[e].to;
		if(v==fa || v==wson[u]) continue;
		pre(v,u);
	}
}
int g[maxn],h[maxn],ans;
void dfs(int u,int fa){
	if(wson[u]) dfs(wson[u],u);
	f[u][0] = wson[u] ? sz[wson[u]] : 0;
	int m = min(k,mxdep[u]);
	for(int e=first[u];~e;e=edge[e].nxt){
		int v = edge[e].to;
		if(v==wson[u] || v==fa) continue;
		dfs(v,u);
		int len = min(k,mxdep[v] + 1);
		g[0] = sz[v];Rep(i,1,len) g[i] = f[v][i-1];
		Rep(i,0,len) h[i] = f[u][i];
		Rep(i,0,len)
			f[u][i] = min(g[i]+h[min(i,k-i)],g[min(i,k-i)] + h[i]);
		Rep(i,0,len) if(k-i>len && k-i<=m) f[u][k-i] += g[i];
		Rep(i,len+1,k-len-1) if(i<=m) f[u][i] += g[len];
		Rep(i,1,m) f[u][i] = min(f[u][i],f[u][i-1]);
	}
	ans = min(ans,n - sz[u] + f[u][min(k,m)]);
}
void solve(){
    mem(first,-1);nume = 0;
	n = read();k = read();ans = n;
    Rep(i, 1, n) {
        dfx[i] = dfn[i] = dp_array[i] = 0;
    }
	rep(i,1,n) {
		int x = read(),y = read();
		Addedge(x,y);
		Addedge(y,x);
	} init(1,0);
	*dfn = 0;
	pre(1,0);
	dfs(1,0);
	writeln(ans);
}
int main(){
	int T = 1; //cin>>T;
    while(T--){
        solve();
    }
	return 0;
}
/*
2
10 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
7 2
1 2
2 3
1 4
4 5
1 6
6 7
*/


Measured memory_bytes: 5036
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX 1000001
int main(){
  int a,b;
  
  while(scanf("%d%d",&a,&b),a+b){
    vector<pair<int,int> > v;
    v.push_back(mp(a+b,0));
    REP(i,4){
      scanf("%d%d",&a,&b);
      v.push_back(mp(a+b,i+1));
    }
    sort(v.rbegin(), v.rend());
    printf("%c %d\n",'A'+v[0].s, v[0].f);
  }

  return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int num[105];
bool used[1005]={0};
int main(){
	int i,x,n;
	scanf("%d%d",&x,&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
		used[num[i]]=1;
	}
	if(!used[x]){
		printf("%d\n",x);
		return 0;
	}	
	for(i=1;i<=n;i++){
		if(!used[x-i]){
			printf("%d\n",x-i);
			return 0;
		}
		if(!used[x+i]){
			printf("%d\n",x+i);
			return 0;
		}
	}
}


Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

int main(void){
    for(string in; cin >> in; cout << endl)
        rep(i, in.size()){
            if(in.at(i) == '@'){
                rep(j, in[i + 1] - '0') cout << in[i + 2];
                i += 2;
            }
            else cout << in[i];
        }

    return 0;
}

Measured memory_bytes: 1172
w_list = list(input())

w_dict = {}
for c in w_list:
    if( c not in w_dict ):
        w_dict[c] = 1
    else:
        w_dict[c] += 1

result = 'Yes'
for v in w_dict.values():
    if( v % 2 ):
        result = 'No'

print(result)

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

int main()
{
    
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    rep(i, d) {
        int s_max = 0;
        rep(j, 26) {
            if (s_max < s[i][j]) {
                s_max = s[i][j];
                t[i] = j+1;
            }
        }
        
    }
    rep(i, d) {
        cout << (i+1)%26+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 _main()
{
    char a, b;
    cin >> a >> b;
    cout << (a == 'H' ? b : b == 'H' ? 'D' : 'H') << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;


std::vector<ll> enum_div(ll n);

int main() {

    ll N, M;

    cin >> N >> M;

    vector<ll> v = enum_div(M);

    sort(v.begin(), v.end(), greater<ll>());

    ll ans = 1;

    for (ll i = 0; i < v.size(); i++) {
        if (v[i] * N <= M) {
            ans = v[i];
            break;
        }
        
    }


    cout << ans << '\n';

}

std::vector<ll> enum_div(ll n)//nの約数を列挙
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++) {

        if (n % i == 0) {

            ret.push_back(i);

            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    
    return ret;
}


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

using namespace std;

vector<bool> used(200000, false);
vector<vector<int>> relation(200000);

int dfs(int target){
  used.at(target) = true;
  int sum = 0;
  for(int next_target : relation.at(target)){
    if(used.at(next_target)) continue;
    sum += dfs(next_target);
  }
  return sum + 1;
}

int main(){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    relation.at(a-1).push_back(b-1);
    relation.at(b-1).push_back(a-1);
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    if(used.at(i)) continue;
    ans = max(ans, dfs(i));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 23452
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	vector<ll> v[500], p, q;
	ll N, M, Q;
	cin >> N >> M >> Q;

	rep(i, M) {
		ll x, y;
		cin >> x >> y;
		v[--x].push_back(--y);
	}
	rep(i, Q) {
		ll x, y;
		cin >> x >> y;
		p.push_back(--x), q.push_back(--y);
	}
	rep(i, 500) sort(all(v[i]));
	
	rep(loop, Q) {
		ll ans = 0;
		fori(i, p[loop], q[loop] + 1) {
			ll t = upper_bound(all(v[i]), q[loop]) - v[i].begin();
			ans += t;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char a,b;
   cin>>a>>b;
    if(a-b>0){
      cout<<">"<<endl;
    }
  else if(a==b){
    cout<<"="<<endl;
  }
  else{
    cout<<"<"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int A,B;

int main(){
    cin>>A>>B;
    if(A>=13)out(B);
    else if(A>=6)out(B/2);
    else out(0);
    
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int a[101010];
int main(){
    scanf("%d",&n);
    int mx = 0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        mx = max(mx, a[i]);
    }
    int diff = 1000000001;
    int x;
    for(int i=0;i<n;i++){
        int d = abs(a[i]*2-mx);
        if (diff > d && a[i] != mx){
            x = a[i];
            diff = d;
        }
    }
    printf("%d %d\n", mx, x);
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
set<ll> psq;
int main() {
	for (ll i = 1; i <= 100000; i++) {
		psq.insert(i*i);
	}
	vector<ll> p;
	int isp[2501] = {};
	Rep(i,2, 2501) {
		if (!isp[i]) {
			p.push_back(i);
			for (int j = 2 * i; j < 2501; j += i) {
				isp[j] = 1;
			}
		}
	}
	int len = p.size();
	int n; cin >> n;
	ll a;
	ll nor[100000]; ll con[100000];
	map<ll, int> count;
	rep(i, n) {
		cin >> a;
		ll c = 1; ll r = a;
		rep(j, len) {
			if (a % p[j] == 0) {
				int cnt = 0;
				while (a%p[j] == 0) {
					a /= p[j]; cnt++;
				}
				int d = 3 * (cnt / 3);
				rep(aa, d) {
					r /= p[j];
				}
				cnt %= 3; cnt = 3 - cnt; cnt %= 3;
				rep(aa, cnt) {
					c *= p[j];
				}
			}
		}
		if (psq.count(a)) {
			c *= (ll)sqrt(a + 0.1);
		}
		else {
			c *= a * a;
		}
		nor[i] = r;
		con[i] = c;
		count[r]++;
	}
	bool f = false;
	int out = 0;
	rep(i, n) {
		if (nor[i] == 1) {
			f = true; continue;
		}
		else {
			int cx = count[nor[i]];
			int cy = count[con[i]];
			out += max(cx, cy);
			count[nor[i]] = 0; count[con[i]] = 0;
		}
	}
	if (f)out++;
	cout << out << endl;
	return 0;
}

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

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

int main(void){
    int n, a, now;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        if(i == 0) now = a;
        else now = gcd(a, now);
    }
    cout << now;
    
}


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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return sz; }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n * 2);
    for (int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z; x--, y--;
        if (z % 2) {
            uf.unionSet(x, y + n);
            uf.unionSet(x + n, y);
        } else {
            uf.unionSet(x, y);
            uf.unionSet(x + n, y + n);
        }
    }
    cout << uf.size() / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
n1 = int(input())
li = list(map(int,input().split()))
n2 = int(input())
for i in range(n2):
    p,x = map(int,input().split())
    a = li[p-1]
    li[p-1] = x
    print(sum(li))
    li[p-1] = a

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

int main() {
    int n, m;
    cin >> n >> m;
    ll s[n], t[m];

    rep(i, n) { cin >> s[i]; }
    rep(j, m) { cin >> t[j]; }

    ll dp[n + 1][m + 1];

    rep(i, n + 1) { dp[i][0] = 1; }
    rep(i, m + 1) { dp[0][i] = 1; }

    rep(i, n) {
        rep(j, m) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
            } else {
                dp[i + 1][j + 1] =
                    (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + mod) % mod;
            }
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string now;
    int Cz = 0;
    int Co = 0;
    int Ct = 0;
    int Cth = 0;
    cin >> N;
    if(1 <=N <= (10*10*10*10*10)){
  for (int i = 0; i < N; i++) {
    cin >> now;
      if(now=="AC"){
        Cz++;
      }
    else if(now=="WA"){
        Co++;
      }
    else if(now=="TLE"){
        Ct++;
      }
    else if(now=="RE"){
        Cth++;
      }
  }
      cout << "AC x ";
 cout <<  Cz << endl;
      cout << "WA x ";
  cout << Co << endl;
      cout << "TLE x ";
  cout << Ct << endl;
      cout << "RE x ";
  cout << Cth << endl;
}
}

Measured memory_bytes: 3628
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, M; cin >> N >> M;
	char A[51][51];
	char B[51][51];
	rep(y, N) rep(x, N) cin >> A[y][x];
	rep(y, M) rep(x, M) cin >> B[y][x];

	bool ok = false;
	rep(y, N) rep(x, N) {
		bool flag = true;
		rep(j, M) rep(i, M) {
			if (j >= N || i >= N) {
				flag = false;
				j = i = M;
			}
			if (A[y + j][x + i] != B[j][i]) {
				flag = false;
				j = i = M;
			}
		}
		ok = flag ? true : false;
		if (ok) y = x = N;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int n,m;
    cin>>n>>m;
    if(m==n)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;

struct T {
  ull a;
  ull b;
  ull c;
  ull d;
};

ull calc(vector<T> const& V, vector<ull> const&A) {
  ull r = 0;
  for(auto const& t: V) {
    if(A[t.b-1] - A[t.a-1] == t.c) r += t.d;
  }
  return r;
};

ull track(vector<T> const& V, vector<ull>& A, ull const N, ull const M, ull const upper, ull const& ix) {
  ull ret = 0;
  if(ix == N) {
    ret = calc(V, A);
  } else {
    for(ull Ai = (ix == 0? 1 : A[ix-1]); Ai <= M; ++Ai) {
      A[ix] = Ai;
      ret = max(ret, track(V, A, N, M, upper, ix + 1));
      if(ret == upper) break;
    }
  }
  return ret;
};

int main() {
  ull N, M, Q;
  cin >> N >> M >> Q;
  vector<T> V;
  V.reserve(Q);
  
  vector<ull> A(N);

  ull upper = 0;
  for(ull i = 0; i < Q; ++i) {
    ull ai, bi, ci, di;
    cin >> ai >> bi >> ci >> di;
    V.push_back({ai, bi, ci, di});
    upper += di;
  }

  auto ans = track(V, A, N, M, upper, 0);

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

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)


#define INF (1e9)
typedef long long unsigned int ll;


int main()
{

    int n;
    cin >> n;
    int l[100];
    int max = 0;
    int idx = 0;
    bool flag = false;
    REP(i, n)
    {
        cin >> l[i];
        if(l[i]>max){
            max = l[i];
            idx = i;
        }
    }
    int sum = 0;
    REP(i, n)
    {
        if(idx!=i){
            sum += l[i];
        }
    }
    if(max<sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)



// // aのp乗を求める関数
// ll modpow(ll a, int p)  {
//   if (p == 0) return 1;
//   if (p%2 == 0) {
//     int halfP = p / 2;
//     ll half = modpow(a, halfP);
//     return half * half % MOD;
//   }
//   else  {
//     return a * modpow(a, p-1) % MOD;
//   }
// }
//
//
// /// aCbを求める関数
// ll mod_combination(int a, int b)  {
//   if (b > a-b)  return mod_combination(a, a-b);
//   ll ansMul = 1;
//   ll ansDiv = 1;
//   rep(i, b) {
//     ansMul *= (a - i);
//     ansDiv *= (i + 1);
//     ansMul %= MOD;
//     ansDiv %= MOD;
//   }
//   ll ans = ansMul * modpow(ansDiv, MOD-2) % MOD;
//   return ans;
// }

// /// 最大公約数を求める関数
// ll gcd(ll m, ll n) {
//   // int x = max(m, n);
//   // int y = min(m, n);
//   if (y == 0) return x;
//   return gcd(y, x%y);
// }


int main(void){
	int X, Y, Z, K;	cin >> X >> Y >> Z >> K;
	vector<ll>	A(X), B(Y), C(Z);
	rep(i,X)	cin >> A[i];
	rep(i,Y)	cin >> B[i];
	rep(i,Z)	cin >> C[i];

	vector<ll> AB;
	rep(i,X)	{
		rep(j,Y)	{
			AB.push_back(A[i] + B[j]);
		}
	}
	sort(AB.begin(), AB.end());
	reverse(AB.begin(), AB.end());

	vector<ll>	ABC;
	rep(i,min(K,(int)AB.size()))	{
		rep(j,Z)	{
			ABC.push_back(AB[i] + C[j]);
		}
	}
	sort(ABC.begin(), ABC.end());
	reverse(ABC.begin(), ABC.end());

	rep(i,K)	cout << ABC[i] << endl;

	return 0;
}


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

ll N;

void func(ll cur, int use, ll &counter) {
    if (cur > N) return; // ベースケース
    if (use == 0b111) counter ++; //答えを増やす。

    //7を付け加える
    func(cur * 10 + 7, use | 0b001, counter);

    //5を付け加える
    func(cur * 10 + 5, use | 0b010, counter);

    //3を付け加える
    func(cur * 10 + 3, use | 0b100, counter);
}

int main() {
    cin >> N;
    ll res = 0;
    func(0, 0, res);
    cout << res << endl;
    return 0;
}

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

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int num = (n-1)/x+1;
    cout << num * t << endl;
}

Measured memory_bytes: 3684
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    int mn = 1001;
    int mx = -1;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        if (scanf("%d", &tmp) < 1) return 0;
        mn = min(mn, tmp);
        mx = max(mx, tmp);
    }

    printf("%d\n", mx - mn);
    return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(i, 1, (n))
#define pb push_back
#define f first
#define s second
#define INF 100000000000000000
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<piii> viii;



int main()
{
    FAST_IO;

    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;

    bool ok = true;
    FOR(i, a, c-1) {
        if (s[i] == '#' && s[i-1] == '#') ok = false;
    }
    FOR(i, b, d-1) {
        if (s[i] == '#' && s[i-1] == '#') ok = false;
    }

    if (d < c) {
        bool ok2 = false;
        FOR(i, b-1, d-1) {
            if (s[i-1] != '#' && s[i] != '#' && s[i+1] != '#') ok2 = true;
        }
        ok &= ok2;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 592
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {

	vll num(4);
	string s;
	cin >> s;
	rep(i, 4) num[i] = s[i] - '0';

	rep(bit, 1ull << 3) {
		ll tmp = num[0];
		rep(i, 3) {
			if ((bit >> i) & 1ull) tmp += num[i + 1];
			else tmp -= num[i + 1];
		}
		if (tmp == 7) {
			cout << num[0];
			rep(i, 3) {
				if ((bit >> i) & 1ull) cout << "+";
				else cout << "-";
				cout << num[i + 1];
			}
			cout << "=7" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int n; cin >> n;
    vector<int> a(n-1);
    rep(i,n) cin >> a[i],a[i]--;
    vector<int> ans(n);
    rep(i,n-1) ans[a[i]]++;
    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 4792
#include <iostream>
#include <stdio.h>

int i = 1;

int main(){
	while(i <= 9 ){
		int r = 1;
		while(r <= 9){
			int num = i * r;
			printf("%dx%d=%d\n", i, r, num);
			r++;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1096
import sys
n = int(input())

A=[[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
#0??§?????????
#[[[0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],  
#  [0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0],
#  [0 0 0 0 0 0 0 0 0 0]]]

#?£?    Building = b
#???    Floor    = f
#???    Room     = r
#??°    Number   = num
for i in range(n):
	b,f,r,num = input().strip().split()
	A[int(b)-1][int(f)-1][int(r)-1]+=int(num)

for i in range(4):
	for j in range(3):
		print('',' '.join(map(str,A[i][j])))
	if i!=3:
		print('#'*20)

Measured memory_bytes: 7672
import java.util.*;
public class Main {
	public static long mod;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String S[] = new String[H];
		for(int i=0;i<H;i++)S[i]=sc.next();
		sc.close();
		
		int a[][]= new int[2000][2000];
		for(int i=0;i<H;i++) {
			int cnt = 0;
			for(int j=0;j<W;j++) {
				if(S[i].charAt(j)=='.' && j!=W-1)cnt++;
				else {
					if(j==W-1&&S[i].charAt(j)=='.') {
						cnt++;
						j++;
					}
					for(int k=1;k<=cnt;k++) {
						a[i][j-k]+=cnt;
					}
					cnt=0;
				}
			}
		}

		for(int i=0;i<W;i++) {
			int cnt = 0;
			for(int j=0;j<H;j++) {
				if(S[j].charAt(i)=='.' && j!=H-1)cnt++;
				else {
					if(j==H-1&&S[j].charAt(i)=='.') {
						cnt++;
						j++;
					}
					for(int k=1;k<=cnt;k++) {
						a[j-k][i]+=cnt;
					}
					cnt=0;
				}		
			}
		}
		
		int ans=0;
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				ans = Math.max(a[i][j],ans);
			}
		}
		System.out.println(ans-1);
	}
}

Measured memory_bytes: 66688
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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



















int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    vector<long long> cnt(n);
    long long ans = 0;
    for(int i = 0; i < n; i++){
        if(i + a[i] < n) cnt[i + a[i]]++;
        if(i - a[i] >= 0) ans += cnt[i - a[i]];
    }
    cout << ans << endl;
}

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

int main()
{
  int n;
  cin >> n;
  
  int a[n],b[n];
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  int line[n];
  rep(i,n) line[i] = i+1;
  
  int count = 1;
  int ansa = 0, ansb = 0;
  bool flag = true;
  do{
    rep(i,n)
    {
      if(line[i] != a[i]) flag = false;
    }
    if(flag == true) ansa = count;
    
    flag = true;
    rep(i,n)
    {
      if(line[i] != b[i]) flag = false;  
    }
    if(flag == true) ansb = count;
    
    if(ansa > 0 && ansb > 0) break;
    count++;
    flag = true;
  }while(next_permutation(line,line+n));
  
  cout << abs(ansa - ansb) << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int maxn = 1e5 +3;
long long n, a[maxn], b[maxn], c[maxn];
long long dp[maxn][4];

int solve(int indx, int day)
{
    if(indx >= n)
        return INT_MIN;
    if(indx == n - 1)
    {
        if(n != 1)
        {
            if(day == 0)
                return max(b[indx],c[indx]);
            if(day == 1)
                return max(a[indx],c[indx]);
            return max(a[indx],b[indx]);
        }
        return max(a[indx],max(b[indx],c[indx]));
    }
    if(dp[indx][day] != -1)
        return dp[indx][day];
    long long ans = 0;
    if(indx == 0)
    {
        ans = max(ans, solve(indx + 1,0) + a[indx]);
        ans = max(ans, solve(indx + 1,1) + b[indx]);
        ans = max(ans, solve(indx + 1,2) + c[indx]);
    }
    else
    {
        if(day == 0)
        {
            ans = max(ans, solve(indx + 1,1) + b[indx]);
            ans = max(ans, solve(indx + 1,2) + c[indx]);
        }
        if(day == 1)
        {
            ans = max(ans, solve(indx + 1,0) + a[indx]);
            ans = max(ans, solve(indx + 1,2) + c[indx]);
        }
        if(day == 2)
        {
            ans = max(ans, solve(indx + 1,0) + a[indx]);
            ans = max(ans, solve(indx + 1,1) + b[indx]);
        }
    }
    return dp[indx][day] = ans;
}
int main()
{
    IO;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0,0);
    return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<int> B(N+2);
    vector<int> A(N+2);
    for(int i=1;i<=N;i++){
        cin >> A.at(i);
    }
    int count = 0;
    for(int i = N;i>0;i--){
        if((B.at(i)+A.at(i))%2!=0){
            count++;
            B.at(i) = 1;
            for(int j=1;j*j<=i;j++){
                if(i%j==0){
                    B.at(j)++;
                    B.at(i/j)++;
                }
                if(j*j==i){
                    B.at(j)--;
                }
            }
        }else{
            B.at(i) = 0;
        }
    }
    cout << count << endl;
    for(int i=1;i<=N;i++){
        if(B.at(i)>=1){
            cout << i << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N;
    cin >> N;
    vector<long long> a(N);
    REP(i, N) { cin >> a[i]; }
    long long s = accumulate(a.begin(), a.end(), 0LL);
    long long sum = 0;
    long long res = INF;
    for(int i = 0; i < N - 1; i++) {
        sum += a[i];
        res = min(res, abs(s - 2 * sum));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextInt(); //w
		sc.nextInt(); //h
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i=0;i<n;i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		long ans = 0;
		for(int i=0;i<n-1;i++) {
			ans += dist(x[i],y[i],x[i+1],y[i+1]);
		}
		System.out.println(ans);
	}

	public static int dist(int x1,int y1,int x2,int y2) {
		if ((x1 < x2 && y1 < y2) || (x1 > x2 && y1 > y2)) {
			return Math.max(Math.abs(x1-x2), Math.abs(y1-y2));
		}else{
			return Math.abs(x1-x2) + Math.abs(y1-y2);
		}
	}

}

Measured memory_bytes: 25464
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, d[200000], a[200000], b[200000];
string str[3], ss;
bool f[200000];
char c[800][800];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v[23];
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
vector<int> tsort(vector<vector<Edge>> vec) {
	enum { YET, VISITED, DONE };
	vector<int> res, flg(n, YET);
	static const function<bool(int)> dfs = [&](int v) {
		flg[v] = VISITED;
		for (auto &e : vec[v]) {
			int w = e.to;
			if (flg[w] != DONE && (flg[w] == VISITED || !dfs(w))) return false;
		}
		flg[v] = DONE;
		res.push_back(v);
		return true;
	};
	for (int i = 0; i < n; ++i)
		if (flg[i] == YET && !dfs(i)) return{};
	reverse(res.begin(), res.end());
	return res;
}
void dfs(int cur,int par) {
	a[cur] = par;
}
int main() {
	cin >> n >> m;
	vec.resize(n);
	rvec.resize(n);
	rep(i, n + m - 1) {
		LL x, y;
		cin >> x >> y;
		x--, y--;
		vec[x].push_back(Edge{ y,1 });
		rvec[y].push_back(Edge{ x,1 });
	}
	vector<int>vv = tsort(rvec);
	rep(i, n) {
		d[vv[i]] = i;
	}
	rep(i, n) {
		LL cur = INF;
		rep(j, rvec[i].size()) {
			if (d[rvec[i][j].to] < cur&&d[rvec[i][j].to]>d[i]) {
				cur=d[rvec[i][j].to];
				a[i] = rvec[i][j].to + 1;
			}
		}
	}
	rep(i, n)
		cout << a[i] << endl;
	return 0;
}


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

int main() {
    int N; cin >> N;
    vector<tuple<string,int,int>> vec(N);
    rep(i,N) {
        string s;
        int p;
        cin >> s >> p;
        vec.at(i) = make_tuple(s,-1*p,i+1);
    }
    sort(vec.begin(),vec.end());
    rep(i,N) {
        cout << get<2>(vec.at(i)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

int N,K;
vector<int> A;

bool judge(int M) {
	vector<int> B;
	for (int n = 0; n < N; n++) {
		B.push_back(A[n] % M);
		if (B.back() == 0)B.back() += M;
	}
	if (B.size() == 0)return true;
	else if (B.size() == 1)return false;
	sort(B.begin(), B.end());
	vector<int> BB1,BB2;
	BB1.resize(B.size());
	BB1[0] = B[0];
	for (int n = 1; n < B.size(); n++)BB1[n] = BB1[n - 1] + B[n];
	BB2.resize(B.size());
	BB2.back() = M-B.back();
	int c = BB1.back() / M;
	int a = 0;
	for (int n = N - 1; n >= N - c; n--)a += (M - B[n]);
	if (a <= K)return true;
	else return false;
}

void solve() {
	cin >> N >> K;
	A.clear();
	A.resize(N);
	int s = 0;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		s += A[n];
	}
	int ans = 0;
	for (int n = 1; n * n <= s; n++) {
		if (s % n != 0)continue;
		if (judge(n))ans = max(ans, n);
		if (judge(s / n))ans = max(ans, s / n);
	}
	cout << ans << endl;
	return;
}

//////////////////////////////
//////////////////////////////

int main() {
#ifdef DEBUGTIME
	for (int time = 0; time < DEBUGTIME; time++) {
		solve();
		cout << "####################" << endl;
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int n;
char S[4];
char T;


int main(void){
    scanf("%s\n", S);

    for(int i =0; i<4; i++){
        T = S[i];
        if(T == '+'){
            n++;
        }else{
            n--;
        }
    }

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

}

Measured memory_bytes: 128