akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#pragma GCC optimize("O3")

using namespace std;

#define MAXN 100005

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORR(j, i, n) for (int i = j; i < n; i++)
#define FORD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOBIR(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
#define DUEHOANG                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(NULL);                \
	cout.tie(NULL)

#define fileio(in, out) \
	freopen(in, "r", stdin); \
	freopen(out, "w", stdout);

#define long long long

typedef set<int> si;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef priority_queue<int> pqi;
typedef stack<int> sti;
typedef queue<int> qi;
typedef deque<int> di;
typedef map<int, int> mii;
#define f first
#define s second

int n;
string s;
int main()
{
    cin >> n;
    cin >> s;
    FOR(i, s.length())
    {
        int w = s[i] - 'A';
        w = (w+n)%26;
        s[i] = 'A' + w;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
s = [n for n in input()];r = len(set(s)) == 2 and ((s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]));print("Yes" if r else "No")


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

ll n;
ll a [1000000][3];
ll dp [1000000][3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie (0);
    cout.tie (0);

    cin >> n;
    for (ll i=0; i<n; ++i)
        for (int j=0; j<3; ++j)
            cin >> a [i][j];
    dp [0][0] = a[0][0];
    dp [0][1] = a[0][1];
    dp [0][2] = a[0][2];
    for (ll i=1; i<n; ++i)
    {
        dp[i][0] = a[i][0] + max (dp[i-1][1] , dp[i-1][2]);
        dp[i][2] = a[i][2] + max (dp[i-1][0] , dp[i-1][1]);
        dp[i][1] = a[i][1] + max (dp[i-1][0] , dp[i-1][2]);
    }

    ll ans = max (max (dp[n-1][0] , dp[n-1][1]) , dp[n-1][2]);
    cout << ans;

    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll a, b, c;
	cin >> a >> b >> c;
	ll num = a*100+b*10+c;
	if(!(num%4)) puts("YES");
	else puts("NO");

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

using ll = long long;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        cout << "Yes";
    } else {
        cout << "No";
    }

  return 0;
}

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

/*void solver(vector<ll> &A,vector<ll> &B,ll i,ll steps,ll score)
{
    if(steps>MinSteps)
    {
        return;
    }
    if(score>=h)
    {
        if(steps<MinSteps)
        {
            MinSteps=steps;
        }
        return;
    }
    if(i>=n)
    {
        return;
    }
    solver(A,B,i+1,steps+1,score+B[i]);
    solver(A,B,i,steps+1,score+A[i]);
    solver(A,B,i+1,steps,score);
    return;
}*/
int main()
{
    //ll n;
    cin>>n>>h;
    vector<ll> A(n,0);
    vector<ll> B(n,0);
    for(ll i=0;i<n;i++)
    {
        cin>>A[i]>>B[i];
    }
    //solver(A,B,0,0,0);
    //cout<<MinSteps<<endl;
    ll amax=A[0];
    for(ll i=0;i<n;i++)
    {
        if(A[i]>amax)
        {
            amax=A[i];
        }
    }
    ll steps=0;
    sort(B.begin(),B.end());
    for(ll i=n-1;i>=0;i--)
    {
        //cout<<B[i]<<endl;
        if(h<=0)
        {
            cout<<steps<<endl;
            return 0;
        }
        if(amax>=B[i])
        {
            break;
        }
        h-=B[i];
        steps++;
    }
    if(h>0)
    {
        steps+=h/amax;
        if(h%amax!=0)
        {
            steps++;
        }
    }
    cout<<steps<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
int main(void)
{
	int a,b,c,wa;
	scanf("%d %d %d",&a,&b,&c);
	if(a>=c){
		wa=0;
	}
	else{
		wa=c-a;
	}
	if(wa>0 && a+b<c){
		printf("NA\n");
	}
	else{
		printf("%d\n",wa);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, c, cnt;
int d[500020];
vector<pair<int, int> > a[500020];
map<int, int> g[100020];
deque<int> q;
int get(int x, int y) {
	if (g[x].count(y)) {
		return g[x][y];
	}
	return g[x][y] = ++cnt;
}
void add(int x, int y, int z) {
	a[x].push_back(make_pair(y, z));
	a[y].push_back(make_pair(x, z));
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		get(i, 0);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &x, &y, &c);
		int x0 = get(x, 0), xc = get(x, c);
		int y0 = get(y, 0), yc = get(y, c);
		add(xc, yc, 0);
		add(x0, yc, 1);
		add(xc, y0, 1);
	}
	memset(d, -1, sizeof d);
	d[1] = 0;
	q.push_back(1);
	while (q.size()) {
		int u = q.back();
		q.pop_back();
		for (pair<int, int> i: a[u]) {
			if (d[i.first] == -1 || d[i.first] > d[u] + i.second) {
				d[i.first] = d[u] + i.second;
				if (i.second == 1) {
					q.push_front(i.first);
				} else {
					q.push_back(i.first);
				}
			}
		}
	}
	printf("%d\n", d[n] >> 1);
	return 0;
}

Measured memory_bytes: 60672
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)1e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n, k;
    cin>>n;
    int a[n], ans = 0;
    f(i, 0, n) cin>>a[i];
    sort(a, a+n, greater<int>());
    ans += a[0];
    k = n-2;
    f(i, 1, n)
    {
    	if(k == 0) break;
    	ans += a[i];
    	k--;
    	if(k == 0) break;
    	ans += a[i];
    	k--;
    	if(k == 0) break;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

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

int main () {

    string S;
    cin >> S;

    map<char, int> alph;
    for (int i = 0; i < S.size(); i++) {
        alph[S[i]]++;
    }

    bool ans = true;
    for (int i = 0; i < S.size(); i++) {
        if (alph[S[i]] != 2) {
            ans = false;
        }
    }

    cout << ((ans)? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int n,m; cin >>n >>m;
  string ans = "No";
  if (m==n) ans = "Yes";
  cout <<ans <<endl;
}

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

int main()
{

    char board[4][4];

    while(true)
    {
        bool flag=true;

        for(int i=1; i<4; i++)
            for(int j=1; j<4; j++)
            {
                cin>>board[i][j];
                if(cin.eof()) return 0;
            }

        for(int i=1; i<10; i++)
            for(int j=i+1; j<10; j++)
                for(int k=j+1; k<10; k++)
                    if((i+j+k)%3 == 0 && board[(i-1)/3+1][i-(((i-1)/3+1)-1)*3] == board[(j-1)/3+1][j-(((j-1)/3+1)-1)*3]
                        && board[(j-1)/3+1][j-(((j-1)/3+1)-1)*3] == board[(k-1)/3+1][k-(((k-1)/3+1)-1)*3]
                        && board[(i-1)/3+1][i-(((i-1)/3+1)-1)*3] != 's' && j-i == k-j && ((((i-1)/3+1) == ((j-1)/3+1)
                        && ((j-1)/3+1) == ((k-1)/3+1))|| ((((i-1)/3+1)) != ((j-1)/3+1) && ((j-1)/3+1) != ((k-1)/3+1)))){
                        cout<<board[(i-1)/3+1][i-(((i-1)/3+1)-1)*3]<<endl;
                        flag=false;
                    }
        if(flag) cout<<'d'<<endl;
    }
    return 0;
}

Measured memory_bytes: 1132
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define lar(a, b) ((a>b) ? (a):(b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    vector<p> cnt;
    p pir;
    pir = make_pair(-1, 0);
    cnt.push_back(pir);
    
    ll n, i, tmp, atmp, ans=1, tmpc=0;
    cin >> n;
    ll a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    sort(a, a+n);
    
    for(i=0; i<n; i++) {
        tmp=1;
        atmp=a[i];
        while(a[i]==a[i+1]) {
            tmp++;
            i++;
        }
        pir = make_pair(atmp, tmp);
        cnt.push_back(pir);
    }
    
    pir = make_pair(-1, 0);
    cnt.push_back(pir);
    
    for(i=cnt.size()-2; i>=1; i--) {
        if(tmpc==0 && cnt[i].second>=4) {
            cout << cnt[i].first*cnt[i].first << endl;
            return 0;
        }else if(tmpc==0 && cnt[i].second>=2) {
            ans *= cnt[i].first;
            tmpc++;
            continue;
        }
        if(tmpc==1 && cnt[i].second>=2) {
            ans *= cnt[i].first;
            cout << ans << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

x=int(input())
t=list(intinput())
ans=0
for i in range(x-2):
    if t[i]<t[i+1]<t[i+2] or t[i]>t[i+1]>t[i+2]:
        ans+=1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int main() {
	int n, l; std::cin >> n >> l;
	std::vector<int>length(n); for (auto& l : length) std::cin >> l;
	std::vector<int> indices(n); for (auto i = 0; i < n; ++i) indices[i] = i;
	std::sort(indices.begin(), indices.end(), [&length](const int a, const int b) {return length[a] > length[b]; });
	std::vector<long long int> time(n);
	for (auto i : indices) {
		if (i == 0) {
			if (length[i] < length[i + 1]) {
				time[i] = l - length[i] + time[i + 1];
			}
			else {
				time[i] = l - length[i];
			}
		}
		else if (i == n - 1) {
			if (length[i] < length[i - 1]) {
				time[i] = l - length[i] + time[i - 1];
			}
			else {
				time[i] = l - length[i];
			}
		}
		else {
			if (length[i] < length[i + 1] && length[i] < length[i - 1]) {
				time[i] = l - length[i] + std::max(time[i + 1], time[i - 1]);
			}
			else if (length[i] < length[i + 1]) {
				time[i] = l - length[i] + time[i + 1];
			}
			else if (length[i] < length[i - 1]) {
				time[i] = l - length[i] + time[i - 1];
			}
			else {
				time[i] = l - length[i];
			}
		}
	}
	std::cout << *std::max_element(time.begin(), time.end()) << std::endl;
}


Measured memory_bytes: 4420
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a){cout<<0;}
    else cout<<10;
}

Measured memory_bytes: 256
#include <iostream>
#define md 1000000007
using namespace std;
bool a[23][23];
long long f[23][2200000];
long long n;
long long trau(long long i,long long used)
{
    if (i==n) return 1;
    long long &res=f[i][used];
    if (res!=-1) return res;
    res=0;
    for (long long j=0;j<n;++j)
    {
        if (a[i][j]==0||(used>>j)&1) continue;
        res=(res+trau(i+1,used|(1<<j)))%md;
    }
    return res;
}   
int main()
{
    for (int i=0;i<=22;++i)
        for (int j=0;j<=2199999;++j)
        {
            f[i][j]=-1;
        }
    cin>>n;
    for (long long i=0;i<n;++i)
    {
        for (long long j=0;j<n;++j)
        {
            cin>>a[i][j];
        }
    }
    cout<<trau(0,0);   
    return 0;
}

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

using namespace std;
using ll = long long;

ll INF = 1000000000;

int main()
{
    ll a,b,k;
    cin >> a >> b >> k;
    if(a > k){
        cout << a - k << " " << b << endl;
    }else{
        cout << 0 << " " << max(b - (k - a),0LL) << endl;
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define MOD 1000000007
using namespace std;
long long x[100010],y[100010],n,m;
long long h,w,z,p;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int j=0;j<m;j++)cin>>y[j];
	sort(x,x+n),sort(y,y+m);
	h=0,w=0;
	for(int i=1;i<n;i++){
		z=i*(n-i)%MOD;
		p=(x[i]-x[i-1])%MOD;
		z=z*p%MOD;
		h=(h+z)%MOD;
	}
	for(int i=1;i<m;i++){
		z=i*(m-i)%MOD;
		p=(y[i]-y[i-1])%MOD;
		z=p*z%MOD;
		w=(w+z)%MOD;
	}
	cout<<h*w%MOD<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    LL N;
    cin >> N;
    LL t=9;
    LL ans=0;
    bool c=false;
    for(LL i=1;;i*=10){
        ans+=t*i;
        if(ans>N){
            while(1){
                ans-=i;
                if(ans<=N){
                    break;
                }
            }
            c=true;
        }
        if(c) break;
    }
    LL count=0;
    while(ans){
        count+=ans%10;
        ans/=10;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = list(map(int, input().split()))
s = []
for i in range(h):
    s.append(list(input()))
for y in range(h):
    for x in range(w):
        if s[y][x] == "#":
            ay = [0, -1, 0, 1]
            ax = [1, 0, -1, 0]
            for i in range(4):
                if 0 <= x+ax[i] < w and 0 <= y+ay[i] < h:
                    if s[y+ay[i]][x+ax[i]] == "#":
                        break
            else:
                break
    else:
        continue
    print("No")
    break
else:
    print("Yes")

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

int Board[102][102];    //Board[j, x, w][i, y, h]
bool isOK;              //迷路がOKかNGか
int xs, ys, xg, yg;     //StartとGoalの座標

void DFS(int c, int x, int y){
    if(Board[x][y] != c){
        return;
    }
    else if(x==xg && y==yg){
        isOK = true;    //Goalなら迷路はOK
        return;
    }

    Board[x][y] = 0;

    DFS(c, x+1, y  );
    DFS(c, x  , y+1);
    DFS(c, x-1, y  );
    DFS(c, x  , y-1);
}

int main(){
    int w,h;
    while(true){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        
        isOK = false;               //初期値をNGに
        for(int i=0;i<102;i++){     //Boardの初期化
            for(int j=0;j<102;j++)
                Board[j][i] = -1;
        }
        cin >> xs >> ys >> xg >> yg;

        int n, c, d, x, y;
        cin >> n;
        for(int t=0;t<n;t++){
            cin >> c >> d >> x >> y;
            int wb = 2+(!d*2);      //d=0なら横長
            int hb = 2+(d*2);       //d=1なら縦長
            for(int i=0;i<hb;i++){
                for(int j=0;j<wb;j++)
                    Board[x+j][y+i] = c;
            }
        }

        DFS(Board[xs][ys], xs, ys);

        if(isOK)
            cout << "OK" << endl;
        else
            cout << "NG" << endl;

    }

    return 0;
}



Measured memory_bytes: 3752
def resolve():
    '''
    code here
    '''
    N, M, Q = [int(item) for item in input().split()]
    As = [int(input()) for _ in range(Q)]

    memo = [0 for _ in range(N)]

    for item in As:
        memo[item-1] += 1

    for item in range(N):
        if M - Q + memo[item] > 0:
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    resolve()



Measured memory_bytes: 13536
n = int(input())
a = input().split()
count = 0
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if i + 1 < n - 1:
			if a[i] != 1 and a[i + 2] != 1:
				a[i + 1] = 1
				count += 1
			elif a[i] != 2 and a[i + 2] != 2:
				a[i + 1] = 2
				count += 1
			elif a[i] != 3 and a[i + 2] != 3:
				a[i + 1] = 3
				count += 1

		if i == n - 2:
			if a[i] == 1:
				a[i + 1] = 2
				count += 1
			else:
				a[i + 1] = 1
				count += 1

print(count)

Measured memory_bytes: 3064
fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val vote = (0..m).map { 0 }.toMutableList()
    for(i in (1..n)) {
        readLine()!!.split(" ").map { it.toInt() }.drop(1).forEach { vote[it]++ }
    }
    println(vote.count { it == n })
}

Measured memory_bytes: 38600
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb emplace_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int x[105],n;
int getAns(int mid){
        int ans=0;
        F(i,0,n) ans+=(x[i]-mid)*(x[i]-mid);
        return ans;
}
int main(){
        while(~getI(n)){
                F(i,0,n) getI(x[i]);
                int ans=INF;
                FE(i,0,100) ans=min(ans,getAns(i));
                printf("%d\n",ans);
        }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=0,f[3005][3005][4];
int n,m,K,a[3005][3005];
int main(){
	cin>>n>>m>>K;
	for(int i=1;i<=K;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		a[x][y]=z;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			for(int k=0;k<=3;k++)f[i][j][k]=max(f[i-1][j][k],f[i][j-1][k]);
			for(int k=1;k<=3;k++)f[i][j][k]=max(f[i][j][k],f[i][j-1][k-1]+a[i][j]);
			for(int k=1;k<=3;k++){
				for(int l=0;l<=3;l++)f[i][j][k]=max(f[i][j][k],f[i-1][j][l]+a[i][j]);
			}
		}
	}
	for(int k=0;k<=3;k++)ans=max(ans,f[n][m][k]);
	cout<<ans;
} 

Measured memory_bytes: 320460
#include <stdio.h>

double ex_product (double Ax, double Ay, double Bx, double By, double Px, double Py){
	return (((Bx-Ax) * (Py-Ay)) - ((Px-Ax) * (By-Ay)));
}

int main(void) {
	double x1, y1, x2, y2, x3, y3, xp, yp, det12, det23, det31;
	while (scanf ("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF){
		det12 = ex_product (x1, y1, x2, y2, xp, yp);
		det23 = ex_product (x2, y2, x3, y3, xp, yp);
		det31 = ex_product (x3, y3, x1, y1, xp, yp);
		if 	(det12 <= 0 && det23 <= 0 && det31 <= 0) {printf ("YES\n");}
		else if	(det12 >= 0 && det23 >= 0 && det31 >= 0) {printf ("YES\n");}
		else {printf ("NO\n");}
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int x, a, b;
  cin >> x >> a >> b;
  string ans = "";
  if (a >= b) ans = "delicious";
  else if (x >= b - a) ans = "safe";
  else ans = "dangerous";
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

	int a= sc.nextInt();
	int b= sc.nextInt();
	int max=a+b;
	if(max<a-b){
	    max=a-b;
	}
	if(max<a*b){
	    max=a*b;
	}
	
	
	
	System.out.println(max);

	    
	}

}


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

int main(){
	ll n,h,a[100500],b[100500],cnt=0,dam=0;
	cin>>n>>h;
	for(int i=0; i<n; i++)cin>>a[i]>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	for(int i=n-1; i>=0; i--){
		if(b[i]<a[n-1])break;
		dam+=b[i],cnt++;
		if(dam>=h){
			cout<<cnt<<endl;
			return 0;
		}
	}
	h-=dam;
	if(h%a[n-1])cout<<cnt+h/a[n-1]+1<<endl;
	else cout<<cnt+h/a[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

int main() {
	string s; cin >> s;
	ll cnt_s = 0;
	ll ans = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'S') {
			cnt_s++;
			ans++;
		}
		else {
			if (cnt_s > 0) {
				cnt_s--;
				ans--;
			}
			else {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}
//char c[200010] = {};
//int main() {
//	string  s; cin >> s;
//	c[0] = s[0];
//	ll p = 1;
//	rep(i, 1, s.size()) {
//		if (p == 0) {
//			c[p] = s[i];
//			p++;
//			continue;
//		}
//		if (s[p - 1] == 'S' && s[i] == 'T') {
//			p--;
//		}
//		else {
//			c[p] = s[i];
//			p++;
//		}
//		c[p] = '\0';
//	}
//	cout << p << endl;
//	return 0;
//}

Measured memory_bytes: 640
#include <iostream>


#define rep(i,n) for(int i=0;i!=(n);++i)

using namespace std;

typedef long long ll; 

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

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

}

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



int main(){

    ll A,B,C,D;

    scanf("%lld %lld %lld %lld",&A,&B,&C,&D);

    ll X=lcm(C,D);

    ll p=B/C-(A-1)/C;
    ll q=B/D-(A-1)/D;
    ll r=B/X-(A-1)/X;

    cout<<B-(A-1)-p-q+r<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  int sum =0;
  for(int i=0;i<N;i++){
    if(V[i]-C[i]>0){
      sum += V[i] - C[i];
    }
  }
  cout << sum << endl;
}


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

public class Main {
	final static int MOD = (int)1e9 + 7;
	int M,N;

	public int modPow(int x,int y){

		if(y == 0){
			return 1;
		}else if(y == 1){
			return x;
		}else if(y % 2 == 0){
			int z = modPow(x,y / 2) % MOD;
			return (int)((long)z * z % MOD);
		}else{
			return (int)((long)modPow(x,y - 1) * x % MOD);
		}
	}

	public void solve() {

		M = nextInt();
		N = nextInt();
		out.println(modPow(M,N));
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define limit 1000005
#define lol (ll) sqrt((double)limit)
#define pb push_back
#define sci(x) scanf("%d",&x)
#define scl(y) scanf("%lld",&y)
int main()
{
    string t,p;
    cin>>t>>p;
    int c=0;
    for(int i=0;i<t.size();i++)
    {
        if(t[i]==p[0])
        {
            c=1;
            for(int j=i+1,k=1;j<p.size(),k<p.size();j++,k++)
            {
                if(t[j]==p[k])
                    c++;
                else
                    break;
            }
        }
        if(c==p.size())
        {
            cout<<i<<endl;
            c=0;
        }
    }
}



Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, m[4], p[4] = { 10,50,100,500 }, x[4], y[4], k, i = 0, q;
	while (true) {
		cin >> n; if (!n) { break; }
		if (i) {
			cout << endl;
		}
		i++;
		k = 0; q = 0;
		cin >> m[0] >> m[1] >> m[2] >> m[3];
		for (int j = 3; j >= 0; j--) {
			k += m[j] * p[j];
		}
		q = k - n;
		for (int j = 3; j >= 0; j--) {
			x[j] = q / p[j];
			q -= x[j] * p[j];
			y[j] = max(0, m[j] - x[j]);
		}
		for (int j = 0; j < 4; j++) {
			if (y[j]) { cout << p[j] << ' ' << y[j] << endl; }
		}
	}
}

Measured memory_bytes: 1160
N=int(input())
a=list(map(int,input().split()))
b=[]
dp=[0]*(N+1)
ans=0
for i in range(N,0,-1):
  p=0
  for j in range(1,N//i+1):
    p+=dp[j*i]
  if p%2!=a[i-1]:
    dp[i]=1
    ans+=1
    b.append(i)
b.sort()
print(ans)
print(*b)

Measured memory_bytes: 17668
#include <iostream>
using namespace std;
int main(){
    
    int N, ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        if(x & 1)ans = 1;
    }
    if(ans)cout << "first" << endl;
    else cout << "second" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>

using namespace std;
const int MAXN = 101;
int v[MAXN];
int w[MAXN];
long long dp[MAXN][100001];
int main()
{
    int N, W;
    cin >> N >> W;
    for(int i = 1; i <= N; i++) cin >> w[i] >> v[i];
    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(i*j==0)
            {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = dp[i-1][j];
            if(j-w[i]>=0) dp[i][j] = max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
        }
    }
    cout << dp[N][W];
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

int x,y,z;

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	vector<int>p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
		if(p[i]<=a){
			x++;
		}else if(p[i]>a&&p[i]<=b){
			y++;
		}else{
			z++;
		}
	}
	cout<<min(x,min(y,z))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

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

	long long res = 1;
	int r = 0, b = 0, g = 0;
	for (int i = 0; i < n; i++)
	{
		int c = (r == a[i]) + (b == a[i]) + (g == a[i]);
		res = res * c % MOD;
		if(r == a[i]) r++;
		else if(b == a[i]) b++;
		else g++;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 4004
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void){
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);
	if (a > b){
		printf("a > b\n");
	}
	if (a == b){
		printf("a == b\n");
	}
	if (a < b){
		printf("a < b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)


#a[始まりの位置: 終わりの位置: スライスの増分] # (a は配列)


import numpy as np
import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。
#np.gcd.reduce(A) #(Aは配列) で、Aの全ての要素の gcd が計算できる。

x = int(input())
if(x == 0):
    print(1)
else:
    print(0)








Measured memory_bytes: 27196
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
    unsigned long long h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    }
    else {
        cout << (h * w + 1) / 2 << endl;
    }
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int x,y;
	cin >> x >> y;
	bool flg = false;
	for(int i = 0; i <= x; i++){
		if(4 * i + 2 * (x-i) == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

struct edge{
    ll v,id;
};

int main(){
    ll n,a,b;
    cin>>n;
    vector<vector<edge>> adj(n);
    rep(i,n-1){
        cin>>a>>b;
        a--; b--;
        adj[a].push_back((edge){b,i});
        adj[b].push_back((edge){a,i});
    }
    vector<ll> col(n-1,-1);
    queue<pair<ll,ll>> q;
    q.push(make_pair(0,-1));
    ll cmx=0;
    while(!q.empty()){
        ll now=q.front().first,pcol=q.front().second;
        q.pop();
        ll ccnt=0;
        rep(i,adj[now].size()){
            if(col[adj[now][i].id]==-1){
                if(ccnt==pcol) ccnt++;
                col[adj[now][i].id]=ccnt;
                q.push(make_pair(adj[now][i].v,ccnt));
                cmx=max(cmx,ccnt);
                ccnt++;
            }
        }
    }
    cout<<cmx+1<<endl;
    rep(i,n-1) cout<<col[i]+1<<endl;
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;cin>>a>>b;
    if (a>=13) {
        cout<<b<<endl;
        return 0;
    }
    else if(a<=5){
        cout<<0<<endl;
        return 0;
    }
    else{
        cout<<b/2<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = ril()
acc = [0]
for x in ls:
    acc.append(acc[-1] + x)
res = float('inf')
for x in acc:
    res = min(res, abs(acc[-1] - 2 * x))
print(res)

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

int main() {
	for( ;; ) {
		int a, b;
		char op;
		cin >> a >> op >> b;

		int r = 0;

		if( op == '+' ) { r = a + b; }
		else if( op == '-' ) { r = a - b; }
		else if( op == '*' ) { r = a * b; }
		else if( op == '/' ) { r = a / b; }
		else { break; }

		cout << r << endl;
	}
}



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

typedef struct _data
{
	int val;
	struct _data *prev;
	struct _data *next;
} data;


data *head, *tail;

void insert(int x)
{
	data *p = (data*)malloc(sizeof(data));
	p->val = x;
	p->prev = NULL;
	p->next = head;
	if (head == NULL) tail = p;
	else head->prev = p;
	head = p;
}

void deleteFirst()
{
	data *p;

	if (head == NULL) return;
	p = head;
	head = head->next;
	free(p);
	if (head == NULL) tail = NULL;
	else head->prev = NULL;
	return;
}

void deleteLast()
{
	data *p;
	if (tail == NULL) return;
	p = tail;
	tail = tail->prev;
	free(p);
	if (tail == NULL) head = NULL;
	else tail->next = NULL;
	return;
}

void delete(int x)
{
	data *p;
	p = head;
	while (p != NULL && p->val != x) p = p->next;

	if (p == NULL) return;
	if (p == head) deleteFirst();
	else if (p == tail) deleteLast();
	else
	{
		p->prev->next = p->next;
		p->next->prev = p->prev;
		free(p);
	}
	return;
}

void terminate()
{
	data *p;
	while ((p = head) != NULL)
	{
		head = head->next;
		free(p);
	}
	tail = NULL;
}

void dump()
{
	data *p = head;
	while (p != NULL)
	{
		printf("%d", p->val);
		if (p->next != NULL) printf(" ");
		p = p->next;
	}
	printf("\n");
}

int main()
{
	int i, n, x;
	char cmd[12];

	head = tail = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%11s", cmd);
		if (!strcmp(cmd, "insert"))
		{
			scanf("%d", &x);
			insert(x);
		}
		else if (!strcmp(cmd, "delete"))
		{
			scanf("%d", &x);
			delete(x);
		}
		else if (!strcmp(cmd, "deleteFirst")) deleteFirst();
		else if (!strcmp(cmd, "deleteLast"))  deleteLast();
	}

	dump();
	terminate();

	return 0;
}



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

using namespace std;

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

    vector<int> h(n);

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

    const int inf = 2e9;

    vector<int> dp(n, inf);

    dp[0] = 0;

    for (int i = 0; i < n - 1; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

        if (i + 2 < n) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
        }
    }

    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  in a,b,c,d;
  in ans=-1*INF;
  cin>>a>>b>>c>>d;
  in i;
  i=a*c;
  ans=max(i,ans);
  i=a*d;
  ans=max(i,ans);
  i=b*c;
  ans=max(i,ans);
  i=b*d;
  ans=max(i,ans);
  
  cout<<ans<<endl;
  
}

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

int main(){
        int n,m;
        while(cin>>n>>m,n){
                vector<tuple<int,int,int>> tsd(m);
                vector<unsigned int> infected(n,0);
                infected[0]=1;
                for(int i=0;i<m;i++){
                        int t,s,d;
                        cin>>t>>s>>d;
                        s--;d--;
                        tsd[i]=make_tuple(t,s,d);
                }
                sort(tsd.begin(),tsd.end());
                for(int i=0;i<m;i++){

                        infected[get<2>(tsd[i])]|=infected[get<1>(tsd[i])];


                }
                int res=accumulate(infected.begin(),infected.end(),0);
                
                cout<<res<<endl;
        }

}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using T = tuple<ll,ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll x=(ll)pow(2,29);
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  rep(i,29){
    ll k=0;
    rep(j,N){
      k+=(A.at(j)-1)/x;
    }
    if(k<=K){
      x-=(ll)pow(2,28-i);
    }else{
      x+=(ll)pow(2,28-i);
    }
  }
  ll k=0;
    rep(j,N){
      k+=(A.at(j)-1)/x;
    }
    if(k>K){
      x++;
    }
  cout << x << endl;
      
}

Measured memory_bytes: 4784
N, Y = map(int, input().split())

man = 10000
gosen = 5000
sen = 1000
flag = False

x, y, z = 0, 0, 0

for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if (z >= 0) and (Y == man*x + gosen*y + sen*z):
            flag = True
            break
    if flag == True:
        break

if flag == True:
    print(str(x) + " " + str(y) + " " + str(z))
else:
    print("-1 -1 -1")


Measured memory_bytes: 66540
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

acum = [0] * (n + 1)
bcum = [0] * (m + 1)

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

for j in range(m):
    bcum[j + 1] = bcum[j] + b[j]

max_ans = 0
j = m
for i in range(n + 1):
    if acum[i] > k:
        break
    while acum[i] + bcum[j] > k:
        j -= 1
    max_ans = max(max_ans, i + j)

print(max_ans)

Measured memory_bytes: 47552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=1e6+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int mul(int a,int b){
	return 1ll*a*b%mod;
}

int poww(int a,int b){
	int r=1;
	while(b){
		if(b&1) r=mul(r,a);
		a=mul(a,a);
		b>>=1;
	}
	return r;
}

void add_self(int& a,int b){
	a+=b;
	if(b>0){
		if(a>=mod) a-=mod;
	}
	else{	
		if(a<0) a+=mod;
	}
}
 

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	int ans=poww(10,n);
	//~ remove list dont have 0
	add_self(ans,-1*poww(9,n));
	//~ remove list dont have 9
	add_self(ans,-1*poww(9,n));
	//~ add list dont have both 0 9
	add_self(ans,poww(8,n));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func findIndex(sets *[][]int, num int) int {
	for i := range *sets {
		for j := range (*sets)[i] {
			if (*sets)[i][j] == num {
				return i
			}
		}
	}
	return -1
}

func unite(sets *[][]int, x int, y int) {
	xIdx := findIndex(sets, x)
	yIdx := findIndex(sets, y)
	if xIdx == -1 || yIdx == -1 || xIdx == yIdx {
		return
	}

	// append slice
	(*sets)[xIdx] = append((*sets)[xIdx], (*sets)[yIdx]...)

	// remode slice
	lastIdx := len(*sets) - 1
	(*sets)[yIdx] = (*sets)[lastIdx]
	(*sets)[lastIdx] = nil
	*sets = (*sets)[:lastIdx]
}

func same(sets *[][]int, x int, y int) int {
	xIdx := findIndex(sets, x)
	yIdx := findIndex(sets, y)

	if xIdx == yIdx {
		return 1
	}
	return 0
}

func main() {
	var inputCount, uniteSize int
	fmt.Scanf("%d %d", &uniteSize, &inputCount)

	units := make([][]int, uniteSize)
	for i := range units {
		units[i] = make([]int, 1)
		units[i][0] = i
	}

	for i := 0; i < inputCount; i++ {
		var methodKind, x, y int
		fmt.Scanf("%d %d %d", &methodKind, &x, &y)
		switch methodKind {
		case 0:
			unite(&units, x, y)
		case 1:
			fmt.Println(same(&units, x, y))
		default:
		}
	}
}



Measured memory_bytes: 8224
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }

    let cnt = count(&s);
    let mut is_ok = true;
    for v in cnt.values() {
        if *v != 2 {
            is_ok = false;
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
///	sort(a,a+2);
	sort(a,a+3);
	if(a[0]==a[2])
	{
		printf("No");
		return 0;
	}
	if(a[0]==a[1])
	{
		printf("Yes");
		return 0;
	}
	if(a[1]==a[2])
	{
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
int main()
{
    rkc;
    ll n;
    cin>>n;
    lld a[n];
    fl(i,0,n)cin>>a[i];
    sort(a,a+n);
    fl(i,0,n-1)a[i+1]=(lld)((a[i]+a[i+1])/2);
    cout<<a[n-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
	cin >> n>> m;
    int ans =1;
    fro(i,n,m/2+1){
      if(m%i==0){
        ans=m/i;
        break;
      }
    }
      cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}


int main(){
    int N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2+ M * (M - 1) / 2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll>A(N);
    vector<ll>A2(N);
    vector<ll>sum(N+1);
    rep(i,N){
        ll a;
        cin>>a;
        a--;
        A2[a]++;
    }
    ll  now=0,ans=0;
    sort(all(A2));
    rep(i,N){
        if(A2[i]!=0){
            now++;
        }
    }
    rep(i,N){
        if(now>K){
            if(A2[i]!=0){
                ans+=A2[i];
                now--;
            }
        }else{
            break;
        }
    }
    cout << ans << endl;


    return 0;
    

}

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

int main(){
  int d1,d10,m;
  int M, D;
  cin >> M >> D;
  if(D<10){
    cout << 0 << endl;
  }
  else{
    int count = 0;
    for(int i = 1; i <= M; i++){
      m = i;
      for(int j = 10; j <= D; j++){
        d10 = j/10;
        d1 = j - d10*10;
        if(m == d10*d1&&d10>=2&&d1>=2){
         // cout << d1 <<' '<< d10 << ' '<<m<<endl;
          count++;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 384