akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

void solve()
{
 ll i,j=1,k,n,m=0,f,s=0,x,c=1,t;
 cin>>n>>m;
if(n>1) s+=(n*(n-1))/2;
if(m>1) s+=(m*(m-1))/2;
cout<<s;
}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
         //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 256
// C++ program to count the Minimum number of 
// increasing subsequences 
#include <bits/stdc++.h>
using namespace std;

int MinimumNumIncreasingSubsequences(int arr[], int n)
{
    multiset<int> last;

    // last element in each increasing subsequence
    // found so far
    for (int i = 0; i < n; i++) {

        // here our current element is arr[i]
        multiset<int>::iterator it = last.lower_bound(arr[i]);

        // iterator to the first element larger
        // than or equal to arr[i]
        if (it == last.begin())

            // if all the elements in last larger
            // than or to arr[i] then insert it into last
            last.insert(arr[i]);

        else {
            it--;

            // the largest element smaller than arr[i] is the number
            // before *it which is it--
            last.erase(it); // erase the largest element smaller than arr[i]
            last.insert(arr[i]); // and replace it with arr[i]
        }
    }
    return last.size(); // our answer is the size of last
}

// Driver program 
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }

    int arr[n];
    for (int i = 0; i < n; i++)
        arr[i] = vec[i];



//    int arr[] = { 8, 4, 1, 2, 9 };
//    std::vector<int> vec;
//    int arr[n];
//
//    std::copy( arr.begin(), arr.end(), arr );
//
    cout << MinimumNumIncreasingSubsequences(arr, n) << endl;
} 


Measured memory_bytes: 5760
n=int(input())
a=list(map(int,input().split()))
b={}
for i in range(len(a)):
    if a[i] in b:
        b[a[i]]+=1
    else:
        b[a[i]]=1
c=[0]*n
for i in range(len(c)):
    if i+1 in b:
        c[i]=b[i+1]
for i in range(len(c)):
    print(c[i])

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

int main() {
    // input
    string S;
    cin >> S;

    // solve
    int ans = 700;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == 'o') ans += 100;
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> x1(a);
    vector<int> y1(b);
    vector<int> z(c);

    for(int i=0; i<a; i++)
        cin >> x1[i];
    for(int i=0; i<b; i++)
        cin >> y1[i];
    for(int i=0; i<c; i++)
        cin >> z[i];

    sort(x1.rbegin(), x1.rend());
    sort(y1.rbegin(), y1.rend());
    sort(z.rbegin(), z.rend());

    vector<int> ans;
    for(int i=0; i<x; i++)
    {
        ans.push_back(x1[i]);
    }

    for(int i=0; i<y; i++)
    {
        ans.push_back(y1[i]);
    }

    sort(ans.begin(), ans.end());

    int j = 0;
    int n = ans.size();
    for(int i=0; i<n; i++)
    {
        if(j <= (c-1))
        {
            if(ans[i] < z[j])
            {
                ans[i] = z[j];
                j++;
            }
        }
    }

    int sum = 0;
    for(int i=0; i<n; i++)
    {
        sum += ans[i];
        // cout << i << " " << ans[i] << endl;
    }

    cout << sum << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define pb push_back
#define ff first
#define ss second
#define SIZE 200001
#define INF 2e9 + 9
#define BIG_INF 1e18 + 9
#define acmpIN "input.txt"
#define acmpOUT "output.txt"

//#pragma GCC optimize("Ofast")
//


int n, k, a[SIZE];



int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//    freopen(acmpIN, "r", stdin);
//    freopen(acmpOUT, "w", stdout);


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


    vector<ll> d;
    for(int i = 1; i < n; i++)
    {
        d.pb(a[i] - a[i - 1]);
    }

    d.pb(k - a[n - 1] + a[0]);

    ll sum = 0;

    ll mx = 0;
    for(int i = 0; i < d.size(); i++)
    {
        sum += d[i];
        mx = max(mx, d[i]);
    }

    cout << sum - mx;


    return 0;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    if(a+b<10) cout<<a+b<<endl;
    else cout<<"error"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    int cnt=0;
    int ans=1;
    int temp=b;
    while(b>0){
        b/=10;
        cnt++;
    }
    for(int i=0;i<cnt;i++){
        ans*=10;
    }
    temp+=a*ans;
    for(int i=1;i<100101;i++){
        if(i*i==temp){
            printf("Yes");
            return 0;
        }
    }
    printf("No");
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

struct P { double x, y; };
P operator+(const P& a, const P& b) { return { a.x+b.x, a.y+b.y }; }
P operator-(const P& a, const P& b) { return { a.x-b.x, a.y-b.y }; }
P operator*(const P& a, const double& v) { return { a.x*v, a.y*v }; }
double cross(P a, P b) { return a.x * b.y - a.y * b.x; }
P intersection(P a1, P a2, P b1, P b2) {
    P a = a2-a1, b = b2-b1;
    return a1 + a * (cross(b, b1-a1) / cross(b, a));
}

const double EPS = 1e-10;

int main()
{
    while (1) {
        int n; cin >> n;
        if (!n) break;
        int ans = 1;
        vector<vector<P>> ls;
        while (n--) {
            P a, b;
            cin >> a.x >> a.y >> b.x >> b.y;
            vector<P> ps;
            for (auto l : ls) {
                P c = l[0], d = l[1];
                P t = intersection(a, b, c, d);
                if (t.x >= -100 + EPS && t.x <= 100 - EPS &&
                    t.y >= -100 + EPS && t.y <= 100 - EPS) {
                    int ok = 1;
                    for (P p : ps) {
                        if (sqrt(pow(p.x-t.x, 2) + pow(p.y-t.y, 2)) < EPS) ok = 0;
                    }
                    if (ok) {
                        ps.push_back(t);
                        ans++;
                    }
                }
            }
            ans += 1;
            ls.push_back({ a, b });
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
#include <iostream>

using namespace std;


int main() {

	int a, b;
	cin >> a >> b;
	int mat[101][101] = { 0 };


	for (int i = 0; i < a; i++) {
		int sum = 0;
		int j = 0;
		for (j = 0; j < b; j++) 	{
			int temp = 0;
			cin >> temp;
			mat[i][j] = temp;
			sum += temp;
		}
		mat[i][j] = sum;
	}

	for (int i = 0; i <= b; i++)
	{
		int sum = 0;
		int j = 0;
		for (j = 0; j < a; j++)
		{
			sum += mat[j][i];
		}
		mat[j][i] = sum;
	}

	for (int i = 0; i < a + 1; i++)
	{
		for (int j = 0; j < b + 1; j++)
		{
			if (j == 0) cout << mat[i][j];
			else cout << " " << mat[i][j];
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin>>a>>b>>c;
  if(a[(a.size())-1]==b[0] && b[(b.size())-1]==c[0]){
    cout<<"YES"<<"\n";
  }
  else{
    cout<<"NO"<<"\n";
  }
  
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
	
	public void solve(){
        Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i=0;i<n;i++){
			int nkin = sc.nextInt();
			int pkin = sc.nextInt();
			int nsu = sc.nextInt();
			int psu = sc.nextInt();
			int gokei = nkin*nsu + pkin*psu;
			
			if(nsu>=5 && psu>=2){
				gokei = (nkin*nsu + pkin*psu)*4/5;
			}else{
				if(nsu<5){
					nsu = 5;
				}
				if(psu<2){
					psu = 2;
				}
				int hiki = (nkin*nsu + pkin*psu)*4/5;
				if(gokei>hiki){
					gokei = hiki;
				}
			}
		    System.out.println(gokei);
		}
	} 
				
    public static void main(String args[]){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 23480
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
const int inf = 2e9;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
   // 	freopen("output.txt", "w", stdout);
//	#endif
	int n;
	cin>>n;
	vi h(n);
	int k;
	cin>>k;
	rep(i,n){
		cin>>h[i];
	}		
	vi cost(n,inf);
	cost[0] = 0;
	cost[1] = abs(h[0]-h[1]);
	repa(i,2,n){
		repa(j,1,k+1){
			if(i-j < 0)break;
			cost[i] = min(cost[i],abs(h[i]-h[i-j])+cost[i-j]);
		}
		// cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<cost[n-1]<<" ";
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

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

   int ans = inf;
   for (int t = 1; t < n; ++t)
   {
      int s0 = 0, s1 = 0;
      for (int i = 1; i <= n; ++i)
      {
         if(i <= t)s0 += a[i];
         else s1 += a[i];
      }
      smin(ans, abs(s0-s1));
   }

   cout<<ans;

   

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
 
int main()
{
  
  ll a,b;
  char op;
  scanf("%lld",&a);
  op = getchar();
  op = getchar();
  scanf("%lld",&b);
  if(op == '+') a+=b;
  else a-=b;
  printf("%lld\n",a);
  
  return 0;
}


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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
using namespace std;

signed main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (b * c >= a) {
    cout << "Yes";
  } else {
    cout << "No";
  }

}

Measured memory_bytes: 3640
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1, 3501):
            if (4*h*n - N*h - N*n)>0 and N*h*n % (4*h*n - N*h - N*n)==0:
                w = N*h*n // (4*h*n - N*h - N*n)
                print(h, n, w)
                exit()

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
from itertools import combinations
from math import hypot

def solve():
    INF = float('inf')
    eps = 10**-6

    N = int(input())
    pts = [tuple(map(int, input().split())) for _ in range(N)]

    if N == 2:
        x1, y1 = pts[0]
        x2, y2 = pts[1]
        ans = hypot(x1-x2, y1-y2) / 2
        print(ans)
        return

    lines = {}
    for i in range(N):
        x1, y1 = pts[i]
        for j in range(i+1, N):
            x2, y2 = pts[j]
            if y1 == y2:
                a = INF
                b = (x1+x2)/2
            else:
                x0, y0 = (x1+x2)/2, (y1+y2)/2
                a = -(x2-x1)/(y2-y1)
                b = y0 - a*x0
            lines[(i, j)] = (a, b)
#    print('lines:', lines)

    ans = INF
    for i, j, k in combinations(range(N), r=3):
        a1, b1 = lines[(i, j)]
        a2, b2 = lines[(i, k)]
        if a1 == a2: continue
        if a1 == INF:
            x = b1
            y = a2*x + b2
        elif a2 == INF:
            x = b2
            y = a1*x + b1
        else:
            x = (b2-b1) / (a1-a2)
            y = (a1*b2-b1*a2) / (a1-a2)
        x1, y1 = pts[i]
        r = hypot(x1-x, y1-y)
#        print('(i, j, k):', (i, j, k), '/ (x,y):', (x, y), '/ r:', r)
        for xi, yi in pts:
            dist = hypot(xi-x, yi-y)
            if dist > r + eps:
                break
        else:
            ans = min(ans, r)

    for i in range(N):
        x1, y1 = pts[i]
        for j in range(i+1, N):
            x2, y2 = pts[j]
            x, y = (x1+x2)/2, (y1+y2)/2
            r = hypot(x1-x, y1-y)
            for xi, yi in pts:
                dist = hypot(xi-x, yi-y)
                if dist > r + eps:
                    break
            else:
                ans = min(ans, r)

    print(ans)


solve()


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    REP(i, M) cin >> A[i];
    ll sum = 0;
    REP(i, M) sum += A[i];
    ll ans;
    if (sum <= N) ans = N - sum;
    else ans = -1;

    cout << ans << endl;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#define MAX 1000000000000000000LL

using namespace std;
int main(){
    int n;
    int a;
    cin>>n;
    long long num;
    vector<int> v;
    for(int i=0; i<n; i++){
        cin>>a;
        num+=a;
        v.push_back(a);
    }
    long long   left=0;
    long long  mini=1000000000000000000LL;
    for(int i=0;i<n-1; i++){
        left+=v[i];
        long long key=num-left*2;
        mini=min(mini,abs(key));
    }
    cout<<mini<<endl;
    return 0;
}


Measured memory_bytes: 1400
// 2011/02/02 Tazoe

#include <iostream>
#include <string>
using namespace std;

struct score{
	string nam;
	int win;
	int los;
	int drw;
	int ord;
	int pnt;
};

int main()
{
	bool flg = false;

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		if(flg)
			cout << endl;
		else
			flg = true;

		struct score tem[10];
		for(int i=0; i<n; i++){
			cin >> tem[i].nam >> tem[i].win >> tem[i].los >> tem[i].drw;
			tem[i].ord = i;
		}

		for(int i=0; i<n; i++)
			tem[i].pnt = tem[i].win*3+tem[i].drw;

		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(tem[i].pnt<tem[j].pnt||(tem[i].pnt==tem[j].pnt&&tem[i].ord>tem[j].ord)){
					struct score tmp = tem[i];
					tem[i] = tem[j];
					tem[j] = tmp;
				}

		for(int i=0; i<n; i++)
			cout << tem[i].nam << ',' << tem[i].pnt << endl;
	}

	return 0;
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string str;
    int val = 0;
    cin >> str;
    for (auto ch: str) {
        val += ch - '0';
    }
    if (val % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

int dp[3001][3002];

int A[3001];
int B[3001];

int main(){

int N,T,S;

scanf("%d %d %d",&N,&T,&S);

for(int i=0;i<N;i++)
scanf("%d %d",&A[i],&B[i]);

int M=0;

for(int i=0;i<N;i++){
for(int j=0;j<=S;j++){
if(j<B[i]) dp[i+1][j]=dp[i][j];
else dp[i+1][j]=max(dp[i][j],dp[i][j-B[i]]+A[i]);
}
}

for(int i=N-1;i>=0;i--){
for(int j=S+1;j<=T+1;j++){
if(j-1-S<B[i]) dp[i][j]=dp[i+1][j];
else dp[i][j]=max(dp[i+1][j],dp[i+1][j-B[i]]+A[i]);
}
}


for(int i=0;i<=N;i++){
if(M<dp[i][S]+dp[i][T+1]) M=dp[i][S]+dp[i][T+1];


}

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


	 return 0;
}

Measured memory_bytes: 36396
N,A,B,C,D,E = [int(input()) for _ in range(6)]
if N%min(A,B,C,D,E) == 0:
  bottle = N // min(A,B,C,D,E) - 1
else:
  bottle = N // min(A,B,C,D,E)
print(5+bottle)

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

template <typename T>
struct Edge { int src, dst; T cost;
    Edge(int dst, T cost) : src(-1), dst(dst), cost(cost) { }
    Edge(int src, int dst, T cost) : src(src), dst(dst), cost(cost) { }
};
template <typename T> using Edges = vector<Edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
template <typename T> using Matrix = vector<vector<T>>;

template <typename T>
void warshall_floyd(Matrix<T> &g) {
    const T INF = numeric_limits<T>::max();
    for (int k = 0; k < g.size(); k++) {
        for (int i = 0; i < g.size(); i++) if (g[i][k] != INF) {
            for (int j = 0; j < g.size(); j++) if (g[k][j] != INF) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

int main() {
    int V, E; cin >> V >> E;
    int L; cin >> L;
    using ll = long long;
    const auto INF = numeric_limits<ll>::max();
    Matrix<ll> mat(V, vector<ll>(V, INF));
    for (int i = 0; i < V; i++) mat[i][i] = 0;
    while (E--) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        mat[a][b] = c;
        mat[b][a] = c;
    }
    warshall_floyd(mat);
    for (int s = 0; s < V; s++) for (int t = 0; t < V; t++) if (s != t) {
        mat[s][t] = (mat[s][t] > L ? INF : 1);
    }
    warshall_floyd(mat);
    int Q; cin >> Q;
    while (Q--) {
        int s, t; cin >> s >> t; s--, t--;
        int ans = (mat[s][t] == INF ? -1 : mat[s][t] - 1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
next_step = [0] * N
memo = [-1] * (2*10**5)
cnt = 0
for i, a in enumerate(A+A):
    if memo[a-1] >= 0:
        if next_step[memo[a-1]%N]:
            continue
        next_step[memo[a-1]%N] = i - memo[a-1] + 1
        if next_step[memo[a-1]%N] == 0:
            pass
        cnt += 1
    if cnt == N:
        break
    memo[a-1] = i

j = 0
while True:
    if j + next_step[j%N] < N*K:
        j += next_step[j%N]
        if j%N == 0:
            j = max(j, N*K//j*j)
    else:
        break

q = deque()
memo = [-1] * (2*10**5)
cnt = 0
for k in range(j, N*K):
    a = A[k%N]
    if memo[a-1] < 0:
        q.append(a)
        memo[a-1] = cnt
        cnt += 1
    else:
        while True:
            b = q.pop()
            memo[b-1] = -1
            if b == a:
                break

print(*q)


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

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

  double water_high = x / (a*a);

  double volume = a * a * b;
  double halfv = volume / 2;
  
  double theta;

  if(x >= halfv) {
    double high_min,high_max = b;
     high_min = 2 * water_high - b;
     double k = b - high_min;
     double tan = k / a;
    // theta = atan2(b - (2*water_high-b), a) * (180 / 3.14159265359);
    theta = atan(tan) * (180 / 3.1415926535897932384);
  }
  else {
    double high = x * 2 / (b * a);
    // theta = atan(b, x / (b * a * 2)) * (180 / 3.14159265359);
    double tan = b / high;
    theta = atan(tan) * (180 / 3.1415926535897932384);
  }

  cout << std::fixed << setprecision(10) << theta << endl;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back
char arr[1001][1001]  ;
#define dfg 1000000007 
ll grr[1001][1001] ,visi[1001][1001]   , m , n ;
ll path(ll i , ll j )
{
    if(visi[i][j] ==1)
    return grr[i][j] ;
    
    if(i ==m-1 && j == n-1)
    {
        grr[i][j] =1 ;
        visi[i][j]=1 ;
        
        return 1 ;
    }
    
    ll mm =0 ; 
    if(arr[i+1][j]=='.' && i+1 < m)
    {
        mm = (mm%dfg + path(i+1 , j)%dfg )%dfg;
    }
    if(arr[i][j+1]=='.'&& j+1 < n)
    {
        mm= (mm%dfg +  path(i, j+1 )%dfg)%dfg ;
        
    }
    
        grr[i][j] =mm ;
        visi[i][j]=1 ;
    return  mm ;
}
int main() 
{
    cin >> m >> n ;
    for( ll i =0 ; i < m ;i++)
    {
        for( ll j =0 ; j< n ;j++)
        {
            cin >> arr[i][j] ; 
            }
    }
      
    cout<< path(0 , 0) ;
    
    
}

Measured memory_bytes: 16896
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>
#include <complex>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

constexpr int64 MOD = 1e9 + 7;

template <int64 M>
struct ModInt {
    int64 n;
    constexpr ModInt(const int64 n = 0) noexcept : n(n % M) {}
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt& operator+=(const ModInt rhs) noexcept {
        n += rhs.n;
        while (n >= M) {
            n -= M;
        }
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt rhs) noexcept {
        n -= rhs.n;
        while (n < 0) {
            n += M;
        }
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt rhs) noexcept {
        (n *= rhs.n) %= M;
        return *this;
    }
    constexpr ModInt& operator/=(ModInt rhs) noexcept {
        *this *= pow(rhs, M - 2);
        return *this;
    }
    constexpr ModInt inv() const noexcept {
        return pow(*this, M - 2);
    }

    static ModInt pow(ModInt a, int64 n) {
        ModInt res = 1;
        while (n) {
            if (n % 2) {
                res *= a;
            }
            a *= a;
            n /= 2;
        }
        return res;
    }
};

namespace CombUtil {

constexpr int64 M = MOD;

vector<ModInt<M>> fact;
vector<ModInt<M>> inv_fact;

static void setup(int max_n) {
    fact.resize(max_n + 1);
    inv_fact.resize(max_n + 1);

    fact[0] = 1;
    for (int n = 1; n <= max_n; n++) {
        fact[n] = fact[n - 1] * n;
    }

    inv_fact[max_n] = fact[max_n].inv();
    for (int n = max_n - 1; n >= 0; n--) {
        inv_fact[n] = inv_fact[n + 1] * (n + 1);
    }
}

ModInt<M> choose(int m, int n) {
    if (m < n) return 0;
    return fact[m] * inv_fact[m - n] * inv_fact[n];
}

};  // namespace CombUtil

namespace CU = CombUtil;

ModInt<CU::M> cumsum(int r, int c) {
    return CU::choose(r + c + 2, r + 1) - CU::choose(r, 0);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    CU::setup(r2 + c2 + 2);

    auto ans = cumsum(r2, c2) - cumsum(r1 - 1, c2) - cumsum(r2, c1 - 1) + cumsum(r1 - 1, c1 - 1);
    cout << ans.n << endl;

    return 0;
}



Measured memory_bytes: 31488
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }

    rep(K, i, N)
    {
        if (A.at(i - K) < A.at(i))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4836
package main

import (
	"fmt"
	"math"
)

var N int
var ans, res int = 1, 1
var mod int = pow(10, 9) + 7

func main() {
	fmt.Scan(&N)
	m := make(map[int]int)

	for i := 2; i <= N; i++ {
		res = i
		for j := 2; j*j <= i; j++ {
			for res%j == 0 {
				m[j]++
				res /= j
			}
		}
		if res != 1 {
			m[res]++
		}
	}

	for _, value := range m {
		ans *= (value + 1)
		ans %= mod
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */
func lcm(x, y uint64) uint64 {
	return (x / gcd(x, y)) * y
}

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 1000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

bool is_prime[110000];
ll prime[110000];

//n以下の素数の数を返す
//計算量は大体O(n)
ll sieve(ll n){
  ll count=0;
  for(int i=0;i<=n;i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[count++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
    }
  }
  return count;
}


int main(){
   int N;
   cin>>N;
   sieve(55555);
   int count=0,i=0;
   while(count!=N){
       if(prime[i]%5==1){
           cout<<prime[i]<<endl;
           count++;
       }
       i++;
   }
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

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

	int n, k;
	cin >> n >> k;
	if (k > 1) cout << n-k << '\n';
	else cout << 0 << '\n';
}


Measured memory_bytes: 256
import sys
n=int(input())
p=list(map(int,input().split()))
sort_p=sorted(p)
q=p
if p==sort_p:
  print("YES")
  sys.exit()
for i in range(1,n):
  for j in range(i):
    p[i],p[j]=p[j],p[i]
    if p==sort_p:
      print("YES")
      sys.exit()
    else:
      p[i],p[j]=p[j],p[i]
print("NO")

Measured memory_bytes: 63836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;


#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{
    string s;
    cin >> s;
    ll** dp;
    int row;
    row = s.length();
    dp = new ll* [row+1];//indexは1
    for (int i = 0; i < row+1; i++)
    {
        dp[i] = new ll [13];
    }

    rep(i,row+1)
    {
       rep(j,13)
       {
           dp[i][j] = 0;
       } 
    }
     
    ll temp;
    int rest;
    int int_s;

    if (s[row-1] != '?')
    {
        int_s = s[row-1] - '0';
        dp[1][int_s] = 1;
    }else
    {
        for (int i = 0; i < 13; i++)
        {
            if (i<10)
            {
                dp[1][i] = 1;
            }else
            {
                dp[1][i] = 0;
            }
            
        }
        
    }
    
    int num;
    

    for (int i = 2; i < row+1; i++)
    {
        if (s[row-i]!= '?')
        {
            int_s = s[row-i] - '0';
            for (int j = 0; j < 13; j++)
            {
                num = (i-1)%6;
                temp = int_s*(((int) pow(10,num))%13)+j;
                rest = temp%13;
                dp[i][rest] += dp[i-1][j];
            }
        }else
        {
            for (int j = 0; j < 10; j++)
            {
                for (int k = 0; k < 13; k++)
                {
                    num = (i-1)%6;
                    temp = j*(((int) pow(10,num))%13)+k;
                    rest = temp%13;
                    dp[i][rest]+= dp[i-1][k];
                }
                
            }
            
        }

        for (int j = 0; j < 13; j++)
        {
            dp[i][j] = dp[i][j]%MOD;
        }
        
    }

    cout << dp[row][5] << endl;

}

Measured memory_bytes: 12032
#include<stdio.h>
int main(){
  int d1,d2,x,tmp;
  scanf("%d%d",&d1,&d2);
  if(d1<d2){
    tmp=d1;
    d1=d2;
    d2=tmp;
  }
  x=d1%d2;
  while(x!=0){
    d1=d2;
    d2=x;
    x=d1%d2;
  }
  printf("%d\n",d2);
  return 0;
}



Measured memory_bytes: 2140
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    ans = []
    while n > 0:
        ans.insert(0, n % k)
        n = n // k
    print(len(ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  if (s[a] != '-') {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '-' && i != a) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) {
    cin>>a[i];
    a[i]--;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[a[i]]==i) ans++;
  }
  cout<<ans/2<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define SIZE 2000000+1

void insert(int);
int extractMax();
void maxHeapify(int);
void swap(int *,int *);

int heep_size=1;
int A[SIZE];

int main(){
  char order[8];
  int n;

  while(1){
    scanf("%s",order);
    
    if(strcmp(order,"insert") == 0){
      scanf("%d",&n);
      insert(n);
    }
    
    else if(strcmp(order,"extract") == 0){
      int ma;
      ma = extractMax();
      printf("%d\n",ma);
    }
    
    else if(strcmp(order,"end") == 0){
      break;
    }  
  }

  return 0;
  
}

int extractMax(){
  int origin,ma;
  origin = 1;
  ma = A[origin];
  A[origin] = A[heep_size];
  heep_size--;
  maxHeapify(origin);

  return ma;
}

void insert(int key){
  int par,pos;
  heep_size++;
  A[heep_size] = key;
  pos = heep_size;
  par = pos/2;

  while(pos > 1 && A[pos] > A[par]){
    swap(&A[par],&A[pos]);
    pos = par;
    par /= 2;
  }
}
 
void swap(int *a,int *b){
  
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
  
}

void maxHeapify(int i){
  int left,right,maximum;
  left = i*2;
  right = i*2+1;
  if(left <= heep_size && A[left] > A[i])
    maximum = left;
  else maximum = i;
  
  if(right <= heep_size && A[right] > A[maximum])
    maximum = right;
  
  if(maximum != i){
    swap(&A[i],&A[maximum]);
    maxHeapify(maximum);
  }

}



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vector<vector<int> > b(h, vector<int>(w));
    int y = 0, x = 0;
    rep(i, 0, n){
        while(a[i]){
            b[y][x] = i + 1;
            if(y % 2 == 0){
                if(x != w - 1) x++;
                else y++;
            }else{
                if(x != 0) x--;
                else y++;
            }
            a[i]--;
        }
    }
    rep(i, 0, h){
        for(int ii = 0; ii < b[i].size(); ii++){
            if(ii) cout << ' ';
            cout << b[i][ii];
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll n = SZ(s);
  ll K;
  cin >> K;
  vector<ll> run;

  bool only = true;
  REP(i, n) {
    if (s[i] != s[0]) only = false;
  }
  if (only) {
    cout << (ll)n * K / 2 << endl;
    return 0;
  }

  ll cur = 1;
  REP(i, n - 1) {
    if (s[i] == s[i + 1]) {
      cur++;
      continue;
    }
    run.push_back(cur);
    cur = 1;
  }
  run.push_back(cur);
  ll ans = 0;
  if (s[0] != s[n - 1]) {
    REP(i, SZ(run)) ans += run[i] / 2;
    ans *= K;
    cout << ans << endl;
    return 0;
  }
  FOR(i,1,SZ(run)){
    ans += run[i]/2;
  }
  run[SZ(run)-1] += run[0];
  ll sum = 0;
  REP(i,SZ(run)){
    ans += run[i]/2;
  }
  FOR(i,1,SZ(run)){
    sum += run[i]/2;
  }
  ans += (K-2)*sum;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string.h>

const int MAXN = 1000000000;

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

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

int main() {
	int arr[10];
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
	}
	int lcmv = arr[0];
	for (int i = 1; i < n; i++) {
		lcmv = lcm(lcmv, arr[i]);
	}
	printf("%d\n", lcmv);
	return 0;
}


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

int main()
    {char cof[30];
     int i, j = 0, k, l;

     gets(cof);

     if (cof[2] == cof[3] && cof[4] == cof[5]) {
         j++;
     }

     if (j > 0) printf("Yes");
     else printf("No");

     }

Measured memory_bytes: 1600
import sys
for line in sys.stdin.readlines():
    exp = line.strip()
    ans = "NA"
    # 1<=X<10
    for i in xrange(1,10):
        filled_exp = exp.replace("X",str(i))
        left,right = filled_exp.split("=")
        a,b = left.split("+")
        if int(a)+int(b) == int(right):
            ans = i
    # X==0
    filled_exp = exp.replace("X","0")
    left,right = filled_exp.split("=")
    a,b = left.split("+")
    if not any([(s[0]=="0" and len(s)>1)  for s in (a,b,right)]):
        if int(a)+int(b) == int(right):
            ans = 0
    print ans

Measured memory_bytes: 4288
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<stdlib.h>
#include<limits.h>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#define maxn 1000005
#define lson (now<<1)
#define rson ((now<<1)|1)
#define mid ((nl+nr)>>1)
using namespace std;
typedef long long ll;
struct nod
{
	int f;
	int id;
	ll dis;
	nod(int o,int a,ll b)
	{
		f=o;
		id=a;
		dis=b;
	}
	nod(){}
};

bool operator<(nod a,nod b)
{
	return a.dis>b.dis;
}

int n,m,k;
int xx1,yy1,xx2,yy2;
string ss[maxn];
int vis[4][maxn];
ll dis[4][maxn];
priority_queue<nod> q;
int getid(int x,int y)
{
	return x*m+y;
}

int fx[maxn]={0,0,1,-1};
int fy[maxn]={1,-1,0,0};

void dijkstra(int s)
{
	for(int o=0;o<=3;o++)
	{
		for(int i=0;i<=n*m;i++)
			dis[o][i]=-1,vis[o][i]=0;
		dis[o][s]=0;
		q.push(nod(o,s,0));
	}
		
	
	while(!q.empty())
	{
		int now=q.top().id; 
		int no=q.top().f;
		q.pop();
		if(vis[no][now]) continue;
		vis[no][now]=1;
		int xx=now/m,yy=now%m;
		
		int nx=xx+fx[no];
		int ny=yy+fy[no];
		
		if(0<=nx && nx<n && 0<=ny && ny<m && ss[nx][ny]!='@')
		{
			int nex=getid(nx,ny);
			if(dis[no][nex]==-1 || dis[no][nex]>dis[no][now]+1)
			{
				dis[no][nex]=dis[no][now]+1;
				q.push(nod(no,nex,dis[no][nex]));
			}
		}
		
		for(int i=0;i<=3;i++)
		if(i!=no)
		{
			ll nexdis=dis[no][now];
			if(dis[no][now]%k)
				nexdis+=(k-(dis[no][now]%k));
			if(dis[i][now]==-1 || dis[i][now]>nexdis)
			{
				dis[i][now]=nexdis;
				q.push(nod(i,now,dis[i][now]));
			}
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	scanf("%d%d%d%d",&xx1,&yy1,&xx2,&yy2);
	xx1--; yy1--; xx2--; yy2--;
	for(int i=0;i<n;i++)
		cin>>ss[i];
	dijkstra(getid(xx1,yy1));
	
	
	if(dis[0][getid(xx2,yy2)]==-1)
		printf("-1\n");
	else
	{
		ll maxx=LONG_LONG_MAX;
		for(int i=0;i<3;i++)
		{
			ll d=dis[i][getid(xx2,yy2)];
			if(d%k)
				d+=(k-d%k);
			maxx=min(maxx,d);
		}
		printf("%lld\n",maxx/k);
	}
}

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

int N;
long long L;
vector<string>  s;
map<int, int> nims;

int main()
{
    cin >> N >> L;
    string prev, now;
    s.resize(N);
    for (int i=0; i<N; i++) cin >> s[i];
    sort(s.begin(), s.end());
    for (int i=0; i<s[0].size(); i++)
    {
        if (s[0][i] == '1')
        {
            nims[i]++;
        }
    }
    for (int j=1; j<N; j++)
    {
        prev = s[j-1];
        now = s[j];
        bool flag = false;
        for (int i=0; i<max(now.size(), prev.size()); i++)
        {
            if (flag)
            {
                if (prev.size() > i && prev[i] == '0') nims[i]++;
                if (now.size() > i && now[i] == '1') nims[i]++;
            }
            else
            {
                if (now[i] != prev[i]) flag = true;
            }
        }
    }
    for (int i=0; i<s[N-1].size(); i++)
    {
        if (s[N-1][i] == '0')
        {
            nims[i]++;
        }
    }
    int bool_ans = 0;
    for (auto nim : nims)
    {
        long long val = L - nim.first;
        if (val == 0 || (nim.second & 1) == 0) continue;
        int tmp=0;
        while ((val & 1) == 0)
        {
            val /= 2;
            tmp++;
        }
        bool_ans =  bool_ans ^ (1<<tmp);
    }
    if (bool_ans)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Bob" << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    String t = sc.nextLine();
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      if (s.charAt(i) == t.charAt(i)) ans++;
    }
    
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 22996
#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--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  double ans = 0;
  vector<double> a(n); rep(i, n) cin >> a[i], ans += 1 / a[i];
  cout  << 1/ans << endl;
}


Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    H,W,K=MI()
    S=[]
    for _ in range(H):
        s=input()
        S.append(s)
        
    # Hに関してbit全探索
    import itertools
    
    inf=10**10
    ans=inf
    
    import bisect
    for ite in itertools.product([0,1], repeat=H-1):
        temp=sum(ite)
        g=[-1]#グループに分ける，区切り(末尾)の数字をいれる
        for i in range(len(ite)):
            if ite[i]==1:
                g.append(i)
        
        M=len(g)
        cnt=[0]*M#グループ毎
        
        flag=1#無理かどうか
        for j in range(W):
            if flag==0:
                break
            cnt2=[0]*M#各列用
            
            #数える
            for i in range(H):
                if S[i][j]=="1":
                    num=bisect.bisect_left(g,i)-1
                    cnt[num]+=1
                    cnt2[num]+=1
            
            #無理
            for i in range(M):
                if cnt2[i]>K:
                    temp=inf
                    flag=0
                    break
                
            #わるか確認
            flag2=0
            for i in range(M):
                if cnt[i]>K:
                    flag2=1
                    break
            #わる
            if flag2:
                for i in range(M):
                    cnt[i]=cnt2[i]
                temp+=1
                
        # print(ite,temp,g)
                    
        ans=min(ans,temp)
        
    print(ans)
                  
                
                

main()


Measured memory_bytes: 74376
//#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

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

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

  cout << 800 * N - (N / 15) * 200 << endl;
  return 0;
}


Measured memory_bytes: 3576