akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
using namespace std;
template <typename T> T Max(T X,T Y){return X>Y?X:Y;}
template <typename T> T Min(T X,T Y){return X<Y?X:Y;}
template <typename T> void chmax(T &X,T Y){X=X>Y?X:Y;return;}
template <typename T> void chmin(T &X,T Y){X=X<Y?X:Y;return;}

int n,num;

int main()
{
	scanf("%d",&n);
	num=n%10;
	if(num==3) printf("bon\n");
	else if(num==0||num==1||num==6||num==8) printf("pon\n");
	else printf("hon\n");
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int a[200];
    int s,t,u;
    int r;
    cin>>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    s=1;
    r=0;
    u=0;
    t=10000;
    for(int i=0;i<n;i++){
        if(t==a[i]){
            u=1;
            s++;
        }else{
            if(u==1) r+=s/2;
            s=1;
            u=0;
        }
        t=a[i];
    }
    if(u==1) r+=s/2;
    cout << r<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
#define pll pair<ll, ll>
#define vpl vector<pll>
#define vb vector<bool>
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=s; i>=e; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<ll>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define mz(a)   memset(a,0,sizeof(a))
#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main() {
    zoom;
    ll x;
    in1(x);
    if (x==0) out1(1);
    else out1(0);
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin>>N;
  vector<int> x(N);
  for(int i=0;i<N;i++)cin>>x.at(i);
  
  sort(x.begin(),x.end());
  int sum=0;
  for(int i=0;i<N-1;i++)sum+=x.at(i);
  if(sum>x.at(N-1))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	vector<string> b = { "","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts" };
	for (int m, n; cin >> m >> n&&m;) {
		vector<int> v(b.size(), 0); v[0] = 1;
		rep(i, 0, n) {
			rep(j, 0, v.size()) {
				v[j] *= m;
			}
			rep(j, 0, v.size() - 1) {
				int add = v[j] / 10000;
				if (add) {
					v[j + 1] += add;
					v[j] %= 10000;
				}
			}
		}
		dumpc(v);
		rrep(j, 0, v.size()) {
			if (v[j] == 0)continue;
			cout << v[j] << b[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
import networkx as nx
ans = (-float("inf"), None)
f = n*k
g = nx.DiGraph()
for i in range(2*n):
    g.add_node(i)
g.add_node(2*n, demand=-f)
g.add_node(2*n+1, demand=f)
for i in range(n):
    g.add_edge(2*n, i, capacity=k, weight=0)
    g.add_edge(i+n, 2*n+1, capacity=k, weight=0)
g.add_edge(2*n, 2*n+1, capacity=f, weight=0)
for i in range(n):
    for j in range(n):
        g.add_edge(i, j+n, capacity=1, weight=-a[i][j])
val, d = nx.network_simplex(g)
vals = [["."]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j+n]==1:
            vals[i][j] = "X"
if -val>ans[0]:
    ans = (-val, vals)
print(ans[0])
print("\n".join("".join(ans[1][i]) for i in range(n)))

Measured memory_bytes: 54828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char s[n][m];
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cin>>s[i][j];
    }
    int l=m+2;
    for(i=0;i<l;i++)
        cout<<"#";
    cout<<endl;
    for(i=0;i<n;i++)
    {
        cout<<"#";
        for(j=0;j<m;j++)
            cout<<s[i][j];
        cout<<"#";
        cout<<endl;
    }
     for(i=0;i<l;i++)
        cout<<"#";
    cout<<endl;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main() {
    ll n, ans = 1;
    cin >> n;
    ll tmp;
    bool flag = true;
    bool isZero = false;

    vector<ll> A(n);
    rep(i, n) {
        cin >> A[i];
        if (A[i] == 0) isZero = true;
    }

    if (isZero) {
        cout << 0 << endl;
        return 0;
    }

    ll tmp1;
    ll li = 1e+18;
    rep(i, n) {
        if (A[i] == 0) continue;

        if ((long double) (li) / (long double) ans >= (long double) A[i]) {
            ans *= A[i];
        } else{
            flag = false;
        }
    }


    if (flag) {
        cout << ans << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}

Measured memory_bytes: 3964
N = int(input())
A = [int(a) for a in input().split()]

A.sort(reverse=True)
c1 = 0
c2 = 0
i = 1
while i < N:
    if A[i] == A[i-1]:
        if c1 == 0:
            c1 = A[i]
            i += 1
        else:
            c2 = A[i]
            break
    i += 1
    
print(c1*c2)

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;
  std::vector<ll> H(N);
  for(int i=0; i<N; i++) std::cin >> H[i];

  for(int i=1; i<N; i++) {
    if ( H[i] == H[i-1] ) continue;
    else if ( H[i] > H[i-1] ) { H[i] -= 1; continue; }
    else { std::cout << "No" << std::endl; return 0; }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (double a) {return Point(a*x,a*y);}
    Point operator / (double a) {return Point(x/a,y/a);}

    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}

    bool operator<(const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator==(const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

struct Segment {
    Point p1,p2;
};

typedef Point Vector;

double dot(Vector a,Vector b) {
    return a.x*b.x+a.y*b.y;
}

Point project(Segment s,Point p) {
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;
}

Point reflect(Segment s,Point p) {
    return p+(project(s,p)-p)*2.0;
}

int main(void) {
    Segment s;
    cin>>s.p1.x>>s.p1.y>>s.p2.x>>s.p2.y;
    int q;
    cin>>q;
    while(q) {
        Point p;
        cin>>p.x>>p.y;
        Point ans=reflect(s,p);
        printf("%.10f %.10f\n",ans.x,ans.y);
        q--;
    }
    return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
ll u, d, A, B, C, D;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> A >> B >> C >> D;
  A -= B;
  u = A;
  d = A;
  FOR(i, 0, n-1){
    if(abs(u) > abs(d)){
      u -= C;
      d -= D;
    }else{
      u += D;
      d += C;
    }
  }
  cout << (d<=0 && 0<=u ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, num, ans = 0;
ll Sum[1000];
vector <ll> P;

int main(){
  for (int i = 1; i < 1000; i++){
    Sum[i] = Sum[i - 1] + i;
  }

  cin >> N; num = N;
  for (ll i = 2; i * i <= N; i++){
    ll cnt = 0;
    while (num % i == 0){
      num /= i; cnt++;
    }
    P.push_back(cnt);
  }
  if (num > 1) P.push_back(1);

  for (int i = 0; i < P.size(); i++){
    int L = 0, R = 1000;
    while (R - L > 1){
      int now = (L + R) / 2;
      if (P[i] >= Sum[now]) L = now;
      else R = now;
    }
    ans += L;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

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

  int x;
  cin >> x;

  auto p = [&](int i) {
    return 1ll * i * i * i * i * i;
  };

  for (int i = -1000; i < 1000; ++i) {
    for (int j = -1000; j < 1000; ++j) {
      if (p(i) - p(j) == x) {
        cout << i << " " << j << '\n';
        return 0;
      }
    }
  }

}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

vector<bool> eratosthenes(ll n) {
    vector<bool> sieve(n+1, true);
    vector<ll> table;
    sieve[0] = sieve[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (sieve[i]) {
            table.push_back(i);
            for (ll j = 2; i * j <= n; j++) {
                sieve[i * j] = false;
            }
        }
    }

    return sieve;
}

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

    ll N;
    cin >> N;
    vector<bool> a = eratosthenes(55555);

    vector<ll> ans;
    ll i = 1;
    while (ans.size() < N) {
        if (a[i] && i % 5 == 1) {
            ans.push_back(i);
        }
        i++;
    }

    Rep (i, N) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << "\n";
}

Measured memory_bytes: 384
from collections import deque
H,W=map(int,input().split())
C=list(map(int,input().split()))
D=list(map(int,input().split()))
S=[]
ischecked=[[-1]*W for _ in range(H)]
for _ in range(H):
    s=input()
    S.append(s)
walkq=deque()
walkq.append([C[0]-1,C[1]-1])
warpq=deque()

def Walk(h,w):
    if 0<=h<H and 0<=w<W:
        if ischecked[h][w]==-1 and S[h][w]==".":
            walkq.append([h,w])
def Warp(h,w,warp):
    if 0<=h<H and 0<=w<W:
        if ischecked[h][w]==-1 and S[h][w]==".":
            warpq.append([h,w,warp+1])

warp=0
ans=-1
while 1:
    if len(walkq)!=0:
        now=walkq.popleft()
    elif len(warpq)!=0:
        now=warpq.popleft()
        warp=now[2]
    else:
        break
    h=now[0]
    w=now[1]
    if ischecked[h][w]==-1:
        ischecked[h][w]=warp
        Walk(h-1,w)
        Walk(h+1,w)
        Walk(h,w-1)
        Walk(h,w+1)
        for i in range(5):
            for j in range(5):
                Warp(h-2+i,w-2+j,warp)
    if h==D[0]-1 and w==D[1]-1:
        ans=ischecked[h][w]
        break
print(ans)

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

typedef long long ll;

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

    ll n,ans=1LL<<60;
    cin >> n;
    vector<ll> a(n),sum(n+1,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum[i+1] = sum[i];
        sum[i+1] += a[i];
    }
    for(int i=1;i<n;i++){
        ans = min(ans,abs((sum[n]-sum[i])-sum[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 510000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int n, q;
vector <int> p[200005];
int total[200005];
bool flag[200005];

void cnt(int x, int y) {
	flag[x] = false;
	total[x] += y;

	rep(i, p[x].size()) {
		if (flag[p[x][i]]) {
			cnt(p[x][i], total[x]);
		}
	}
	return;
}

int main() {

	cin >> n >> q;
	rrep(i, n)flag[i] = true;
	rep(i, n - 1) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		p[tmp1].pb(tmp2);
		p[tmp2].pb(tmp1);
	}

	rep(i, q) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		
		total[tmp1] += tmp2;

	}

	cnt(1, 0);

	rrep(i, n)cout << total[i] << endl;

	return 0;
}

Measured memory_bytes: 23680
N = int(input())

L = 3500 + 1

for h in range(1, L):
    for n in range(1, h + 1):
        x = N * h * n
        y = 4 * h * n - N * (n + h)
        if y <= 0:
            continue
        if x % y == 0:
            w = x // y
            print(h, n, w)
            exit(0)


Measured memory_bytes: 9048
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

import math

N = int(readline())
T,A = map(int,readline().split())

def update(T,A,t,a):
    T1 = (T+t-1)//t*t
    A1 = T1//t*a
    A2 = (A+a-1)//a*a
    T2 = A2//a*t
    return max(T1,T2),max(A1,A2)

for i in range(N-1):
    t,a = map(int,readline().split())
    T,A = update(T,A,t,a)
print(T+A)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int i,j,n=0,m;
    string s;
    cin >> s;
    for(i=0; i<s.size(); i++)
        n = n+s[i]-'0';
    if(n%9)
        cout <<"No\n";
    else
        cout <<"Yes\n";
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}




Measured memory_bytes: 3684
/*
	Code written by Talant I.D.
*/

#include <bits/stdc++.h> 

using namespace std;

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

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound 
#define ub upper_bound 
#define mp make_pair
#define mt make_tuple
#define mod int(1e9+7)
#define eps double(1e-9)
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define curMod ll(998244353)
#define fr first
#define sc second

inline bool isvowel(char ch){
	ch = tolower(ch);
	return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y');
}

inline bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i == 0) return false;
	return true;
}

const int N = 407;
ll dp[N][N], pref[N];
vector <ll> v;

ll rec(int l, int r){
	if(dp[l][r]) return dp[l][r];
	if(l == r){
		return 0;
	}
	if(l == r-1){
		return v[l]+v[r];
	}
	ll mn = 9e18;
	for(int i = l; i <= r-1; i++){
		mn = min(mn, rec(l, i)+rec(i+1, r)+pref[r]-pref[l-1]);
	}
	return dp[l][r] = mn;
}

int main(){
	do_not_disturb
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, i;
	cin >> n;
	v.resize(n+1);
	for(i = 1; i <= n; i++){
		cin >> v[i];
		pref[i] = pref[i-1]+v[i];
	}	
	
	cout << rec(1, n);
	
	return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#define ll long long
using namespace std;
ll M=1e9 +7;
int main(){
    ll h,w;
    cin>>h>>w;
    char a[h][w];
    ll dp[h][w]={0};
    for (ll i = 0; i < h; ++i)
    {
        for (ll j = 0; j < w; ++j)
        {
            cin>>a[i][j];
            if(a[i][j]=='#')    dp[i][j]=-1;
            else dp[i][j]=0;
        }
    }
    dp[0][0]={0};
    bool check=false;
    for (int i = 1; i <w; ++i)
    {
        if(dp[0][i]==-1 && !check){
            check=true;
        }
        else if(check){
            dp[0][i]=-1;
        }
        else 
            dp[0][i]=1;
    }
    check=false;
    for (int i = 1; i <h; ++i)
    {
        if(dp[i][0]==-1 && !check){
            check=true;
        }
        else if(check){
            dp[i][0]=-1;
        }
        else 
            dp[i][0]=1;
    }
    for (ll i = 1; i <h; ++i)
    {
        for (ll j = 1; j <w ; ++j)
        {
            if(dp[i][j]==-1)
                continue;
            if( dp[i-1][j]>0 )
                dp[i][j]=((dp[i-1][j])+dp[i][j]+M)%M;
            if( dp[i][j-1]>0)
                dp[i][j]=((dp[i][j])+dp[i][j-1]+M)%M;
        }
    }
   /* for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[h-1][w-1];

    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  char a,b,c,d;cin>>a>>b>>c>>d;
  ll e=0;
  if(a=='+')e++;
  else e--;
  if(b=='+')e++;
  else e--;
  if(c=='+')e++;
  else e--;
  if(d=='+')e++;
  else e--;    
  cout<<e;  
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
using namespace std;

/*
 tips :
 Sqrt opt
 Binary search
 Try to find the easiest solution
 Recursiya
 FUCK YOU pishi kod akuratnee daun yobani
 sdohni v adu nahui blyat' y ub'uy tebya
 esli ti blyad' budesh pisat' kod gryaznim
 to ya tebya v rot viebu
*/

const ll N = 2e5 + 10;
const ll big = 1e18;
const ll shift = 1000;
const ll block = 500;
const long long mod = 1e9 + 7;

int main() {	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max( b * c, max(a * d, max(a * c, b * d)));
}             

/*

*/          

Measured memory_bytes: 3632
s = list(input())
n = len(s)

ans = 0

for i in range(2**(n-1)):
    s_temp = s[0]
    for j in range(n-1):
        if i>>j & 1:
            s_temp += "+" + s[j+1]
        else:
            s_temp += s[j+1]
    ans += eval(s_temp)

print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}
int n;
ll k,a[200005];

int ok(ll x)
{
    ll c=0;
    for(int i=0;i<n;i++)
    {
        c+=a[i]/x-1;
        if(a[i]%x!=0)
            c++;
    }
    if(k>=c)
        return 1;
    else
        return 0;
}
int main()
{
    read(n);
    read(k);
    for(int i=0;i<n;i++)
    {
        read(a[i]);
        //r=max(r,a[i]);
    }
	ll l=1,r=1e9+7,mid;
    while(l<=r)
    {
        mid=(l+r)/2;
        if(ok(mid))
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l<<endl;
    return 0;

}

Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
long long s[1000005];
int main(){
	memset(s,0,sizeof(0));
	int n;
	cin>>n;
	int a[n+1];
	long long sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
		s[a[i]]++;
	}
	int m;
	cin>>m;
	for(int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		sum+=s[x]*(y-x);
		s[y]+=s[x];
		s[x]=0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 4748
//In the name of Allah//
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x = a*b;
    int y = c*d;
    if(x==y)
    {
        cout<<x<<endl;
    }
    else
    {
       cout<< max( x,y )<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 n, i;
  cin >> n;
  string S;
  getchar();
  getline(cin, S);

  i64 ans = 0;
  REP(0, n-2, i) {
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
using namespace std;

int main(){
 int N; cin >> N;
 int L[N]; int ans=0; int max=0;
  for(int i=0;i<N;i++){ cin >> L[i]; }
  for(int j=0;j<N;j++){
    if(L[j]>=max) max=L[j];
    ans=ans+L[j];
  }
    if(max < ans-max) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

	int n,m,taro[100],hanako[100],sum_taro,sum_hanako,minimum,taro_min,hanako_min;
	bool FLG;
	while(true){
		scanf("%d %d",&n,&m);
		if(n == 0 && m == 0)break;

		sum_taro = sum_hanako = 0;
		for(int i=0; i < n; i++){
			scanf("%d",&taro[i]);
			sum_taro += taro[i];
		}
		for(int i=0; i < m; i++){
			scanf("%d",&hanako[i]);
			sum_hanako += hanako[i];
		}

		FLG = false;
		minimum = 2147483647;
		for(int i=0; i < n; i++){
			for(int k = 0; k < m; k++){
				if(sum_taro-taro[i]+hanako[k] == sum_hanako-hanako[k]+taro[i] && taro[i]+hanako[k] < minimum){
					minimum = taro[i] + hanako[k];
					taro_min = taro[i];
					hanako_min = hanako[k];
					FLG = true;
				}
			}
			if(FLG)break;
		}

		if(!FLG)printf("-1\n");
		else{
			printf("%d %d\n",taro_min,hanako_min);
		}
	}

    return 0;
}

Measured memory_bytes: 2556
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  n = int(input())
  s = n

  for i in range(1, n):
    if i ** 2 > n:
      break

    if n % i != 0:
      continue

    s = min((i - 1) + (n // i - 1), s)

  print(s)


if __name__ == '__main__':
  main()


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

int main() {
  int N;
  cin >> N;
  
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  
  int count=0;
  
  for(int j=0;j<N;j++){
    if(p.at(j)!=j+1){
      count++;
    }
  }
  
  if(count==0||count==2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct r{int d,p;}r;
r R[10005];
int N,M,i,res;
int c(const void * a,const void *b)
{
	return (*(r*)b).p-(*(r*)a).p;
}

int main()
{
	for(;scanf("%d%d",&N,&M),N;)
	{
		for(i=0;i<N;i++)
			scanf("%d%d",&R[i].d,&R[i].p);
		qsort(R,N,sizeof(r),c);
		for(i=res=0;i<N;i++)
		{
			if(M>R[i].d)
				M-=R[i].d;
			else
			{
				res+=(R[i].d-M)*R[i].p;
				M=0;
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll x,a;
  cin>>x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int n,m;
char a[1005][1005];
ll dp[1005][1005];
const ll MOD=1e9+7;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1;i<=n;++i){
    	cin>>a[i];
    	for (int j=m;j>0;--j) a[i][j]=a[i][j-1]; 
	}
	dp[1][1]=1;
	for (int i=1;i<=n;++i){
		for (int j=1;j<=m;++j){
			if (i==1&&j==1) continue;
			if (a[i][j]=='#') dp[i][j]=0;
			else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[n][m];
    return 0; 
}

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

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

  double c;
  c = stoi( to_string(a) +to_string(b) );
  
  a = (int)sqrt(c);
 
  if ( a*a == c ) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
  

Measured memory_bytes: 256
/*input
25
*/

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>




#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pdd pair<double, double>
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define forstl(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.f<<" , "<<it.s<<endl;} cerr<<endl
#define PI           3.14159265358979323846

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define pdd pair<double, double>
#define in(v,n) vll v(n);rep(i,n) cin>>v[i]


using namespace std;


int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int T;
	// cout<<std::fixed<<std::setprecision(35);
	// cin>>T;while(T--)
	{
		ll t,n,i,j,x,y,m,l,d,k;
		cin>>n;
		if(n>=30) cout<<"Yes\n";
		else cout<<"No\n";
	}
}

Measured memory_bytes: 3612
def main():
    INF = 10 ** 9 + 10

    D = int(input())
    *C, = map(int, input().split())
    # C[type]
    # sum(ci*(d-last(d,i) for ci in C)だけ下がる
    S = [[int(x) for x in input().split()] for _ in range(D)]
    # S[day][type]:=happiness

    last = [-1] * 26

    def diff(d, t):
        ret = S[d][t]
        ret -= sum(ci * (d - last[i]) for i, ci in enumerate(C) if i != t)
        return ret

    T = []
    score = 0
    for d in range(D):
        delta = -INF
        take_t = -1
        for t_ in range(26):
            buf = diff(d, t_)
            if delta < buf:
                delta = buf
                take_t = t_

        last[take_t] = d
        score += buf
        T.append(take_t + 1)
    print(*T, sep='\n')
    # print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    rep(i, 0, k) cout << "ACL";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3612
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]+a[n//2][0])+1)

Measured memory_bytes: 49844
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        long a=Long.parseLong(sc.next());
        long b=Long.parseLong(sc.next());
        long c=Long.parseLong(sc.next());
        long d=Long.parseLong(sc.next());
        long cd=lcm(c,d);
        long ans=0,x,y;
        x=(a+c-1)/c;
        y=b/c;
        ans+=y-x+1;
        
        x=(a+d-1)/d;
        y=b/d;
        ans+=y-x+1;
        
        x=(a+cd-1)/cd;
        y=b/cd;
        ans-=y-x+1;
        System.out.println(b-a+1-ans);
    }
    public static long gcd(long a,long b){
        if(a<b){
        a^=b^=a;
        b^=a;}
        if(b!=0)
        return gcd(a%b,b);
        else return a;
    }public static long lcm(long a,long b){
        return a*b/gcd(a,b);
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int main(){
	io;
	int n;
	cin >> n;
	int c[n], s[n], f[n];
	int ans[n];
	for(int i = 0;i < n; i++){
		cin >> c[i] >> s[i] >> f[i];
	}
	for(int i = 0; i < n - 1; i++){
		int curr = s[i] + c[i];
		for(int j = i + 1;j < n - 1; j++){
			int minn = s[j];
			while(minn < curr)
				minn += f[j];
			curr = minn + c[j];
		}
		ans[i] = curr;
	}
	for(int i = 0;i < n-1; i++)
		cout << ans[i] << endl;
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e3+5;
const double EPS = 1e-6;
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
char a[105][105];
int ans[105][105];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,n)	scanf("%s",a[i]);
	rep(i,0,n){
		rep(j,0,m){
			if(a[i][j]=='.'){
				ans[i][j]=0;
				if(j+1<m){
					if(a[i][j+1]=='#') ans[i][j]++;
				}
				if(j-1>=0){
					if(a[i][j-1]=='#') ans[i][j]++;
				}
				if(i+1<n&&j+1<m)if(a[i+1][j+1]=='#') ans[i][j]++;
				if(i+1<n) if(a[i+1][j]=='#') ans[i][j]++;
				if(i-1>=0) if(a[i-1][j]=='#') ans[i][j]++;
				if(i-1>=0&&j+1<m) if(a[i-1][j+1]=='#') ans[i][j]++;
				if(i-1>=0&&j-1>=0) if(a[i-1][j-1]=='#') ans[i][j]++;
				if(i+1<n&&j-1>=0) if(a[i+1][j-1]=='#') ans[i][j]++;
			}
		}
	}
	rep(i,0,n){
		rep(j,0,m){
			if(a[i][j]=='.') printf("%d",ans[i][j]);
			else printf("%c",a[i][j]);
		}
		cout<<endl;
	}
	return 0;
}


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

ll solve() {
    ll N, X, M;
    cin >> N >> X >> M;
    vector<ll> as;
    set<ll> used;
    ll a = X;
    while ( true ) {
        as.push_back(a);
        used.insert(a);
        a = a * a % M;
        if ( used.count(a) > 0 ) break;
    }
    ll f = 0;
    for ( f = 0; f < as.size(); f++ ) {
        if ( as[f] == a ) break;
    }
    ll t = as.size() - f;
    ll s0 = 0, s1 = 0;
    int i;
    for ( i = 0; i < f; i++ ) {
        s0 += as[i];
    }
    for ( ; i < as.size(); i++ ) {
        s1 += as[i];
    }
    ll ans = 0;
    if ( N - f <= 0 ) {
        for ( int i = 0; i < N; i++ ) {
            ans += as[i];
        }
    } else {
        ll k = (N-f) % t;
        ans = s0 + s1 * ((N-f)/t);
        for ( int i = f; i < f+k; i++ ) {
            ans += as[i];
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    /*#ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan*/


    int n,m,k; cin >> n >> m >> k;
    vector< long long int > first(n);
    vector < long long int > second(m);

    for(int i=0;i<n;i++) cin >> first[i];

    for(int i=0;i<m;i++) cin >> second[i];


    for(int i=1;i<n;i++) first[i]=first[i]+first[i-1];
    for(int i=1;i<m;i++) second[i]=second[i]+second[i-1];

    /*for(long long int x : first)
        cout << x << " ";
    cout << endl;

    for(long long int x : second)
        cout << x << " ";
    cout << endl;*/

    int answer = 0;

    for(int i=0;i<n;i++)
    {
        if(first[i]>k)
            break;

        int t_a = i+1;

        int t_k = k-first[i];

        int index = lower_bound(second.begin(),second.end(),t_k) - second.begin();

        if(index==m || second[index]>t_k)
            index-=1;
        t_a+=(index+1);
        answer=max(answer,t_a);
    }

    for(int i=0;i<m;i++)
    {
        if(second[i]>k)
            break;

        int t_a = i+1;

        int t_k = k-second[i];

        int index = lower_bound(first.begin(),first.end(),t_k) - first.begin();

        if(index==n || first[index]>t_k)
            index-=1;
        t_a+=(index+1);
        answer=max(answer,t_a);
    }

    cout << answer << endl;


    #ifdef TarekHasan
        main();
    #endif // TarekHasan

    return 0;
}


Measured memory_bytes: 6372
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, k] = spi[0].split(' ').map(e => Number(e));

    const snukes = new Array(n);
    for (let i = 0; i < n; i++) snukes[i] = 0;

    let row = 1;
    for (let i = 0; i < k; i++) {
        const d = Number(spi[row]);
        row++;
        const a = spi[row].split(' ').map(e => Number(e));
        row++;
        for (let j = 0; j < d; j++) {
            snukes[a[j] - 1]++;
        }
    }

    let ans = 0;
    for (let i = 0; i < n; i++) {
        if (snukes[i] === 0) ans++;
    }

    console.log(ans);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30340
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>
#define mx 1000000


int main() {
    fastio;
    lli h,w;
    cin>>h>>w;
    lli ans=h*w;
    if(h==1 or w==1)
    {
        cout<<"1\n";
        return 0;
    }
     ans=((ans/2)+(ans%2));
    cout<<ans<<"\n";
    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 rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        vector<int> v = {p[i-1], p[i], p[i+1]};
        sort(all(v));
        if (v[1] == p[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		//		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println(Math.min(numA * numN, numB));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int addAllDigit(int num) {
		if (num < 10) {
			return num;
		}
		return addAllDigit(num / 10) + num % 10;
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int res = addAllDigit(numN);

			if (numN % res == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");

			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e4 + 7;
const int md = 1e9 + 7;
int vis[N];
std::vector<int> g[N];
int dist[N];
set<pair<int, int>> P[N];
int n, x, y;
void bfs(int s) {
  dist[s] = 0;
  for(int i=1; i<=n; i++) {
    dist[i] = 0;
    vis[i] = 0;
  }
  queue<int> q;
  q.push(s);
  vis[s] = 1;
  while(!q.empty()) {
    int from = q.front();
    q.pop();
    for(auto to : g[from]) {
      if(!vis[to]) {
        dist[to] = dist[from] + 1;
        vis[to] = 1;
        q.push(to);
      }
    }  
  }
  for(int i=1; i<=n; i++) {
    //cout << dist[i] << " ";
    if(i == s) continue;
    if(P[dist[i]].count({i, s})) continue;
    P[dist[i]].insert({s, i});
  }
}
void sol() {
  //int n, x, y;
  cin >> n >> x >> y;
  for(int i=1; i<n; i++) {
    g[i].pb(i+1);
    g[i+1].pb(i);
  }
  g[x].pb(y);
  g[y].pb(x);
  for(int i=1; i<=n; i++) {
    bfs(i);
    //cout << endl;
  }
  for(int i=1; i<=n-1; i++) {
    cout << (int)P[i].size() << "\n";
  }
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


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

int main() {
	
	int N;
	int ans = 0;
	int ans0 = 0;
	cin >> N;
	int H[N];
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	
	for (int i = 0; i < N; i++) {
		ans0 = 0;
		if (ans >= N-i) {
			break;
		}
		for (int j = i; j < N-1; j++) {
			if (H[j] >= H[j+1]) {
				ans0++;
			} else {
				break;
			}
		}	
		if (ans0 > ans) {
			ans = ans0;
		}	
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    long long days = 0;
    for (int i = 0; i < M; ++i) {
        int a;
        cin >> a;
        days += a;
    }
    if (days > N) {
        cout << -1 << endl;
    } else {
        cout << (N - days) << endl;
    }

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main(){
    char name[4];
    cin >> name;
    for (int i=0;i<3;++i){
        if (name[i] == name[i+1]){
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good" << "\n";
    return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;

    vector<string> S(N);
    for (auto& s : S) cin >> s;

    vector<vector<bool>> order(26, vector<bool>(26, false));
    // order[a][b] => a < b

    for (int i = 0; i < N - 1; ++i) {
        bool diff = false;
        for (int j = 0; j < min(S[i].length(), S[i + 1].length()); ++j) {
            if (S[i][j] != S[i + 1][j]) {
                order[S[i][j] - 'a'][S[i + 1][j] - 'a'] = true;
                diff = true;
                break;
            }
        }

        if (!diff && S[i].length() > S[i + 1].length()) {
            cout << "no" << endl;
            return true;
        }
    }

    for (int j = 0; j < 26; ++j) {
        for (int i = 0; i < 26; ++i) {
            for (int k = 0; k < 26; ++k) {
                if (order[i][j] && order[j][k]) order[i][k] = true;
            }
        }
    }

    for (int i = 0; i < 26; ++i) {
        if (order[i][i]) {
            cout << "no" << endl;
            return true;
        }
    }
    cout << "yes" << endl;
    return true;
}

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



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              300005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int par[sz];
bool vis[sz];
vector < int > V[sz];

void bfs(int src){

    memset(vis,0,sizeof(vis));
    memset(par,0,sizeof(par));
    queue< int > q;
    q.push(1);
    vis[1]=0;

    while(!q.empty()){
        int u=q.front();
        q.pop();

        for(int i=0; i<V[u].size(); i++){
            int v=V[u][i];
            if(vis[v]==0){
                par[v]=u;
                vis[v]=1;
                q.push(v);
            }
        }
    }
}

int main(){
    Fast;
    int a,b,c, i,j, n,m,t, cs=1;

    cin>>n>>m;
    for(i=0; i<m; i++){
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    bfs(1);

    bool flag=true;
    vector < int > pp;
    for(i=2; i<=n; i++){
        if(par[i]==0){
            flag=false;break;
        }
        pp.push_back(par[i]);
    }
    if(!flag){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        for(i=0; i<n-1; i++){
            cout<<pp[i]<<endl;
        }
    }


    return 0;
}



Measured memory_bytes: 16444