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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int dx[4] = {0, 0, 1, -1};
    int dy[4] = {1, -1, 0, 0};
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int> > g(h, vector<int>(w, Inf));
    rep (i, h) cin >> s[i];
    int black = 0;
    rep (i, h) rep (j, w) if (s[i][j] == '#') black++;
    queue<pair<int, int> > q;

    q.push(make_pair(0, 0));
    g[0][0] = 0;
    while (!q.empty()) {
        int x, y;
        x = q.front().first, y = q.front().second;
        q.pop();
        rep (i, 4) {
            int nx, ny;
            nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
            if (s[nx][ny] == '#') continue;
            if (g[nx][ny] != Inf) continue;
            g[nx][ny] = g[x][y] + 1;
            q.push(make_pair(nx, ny));
        }
    }
    if (g[h - 1][w - 1] == Inf) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    q.push(make_pair(h - 1, w - 1));
    while (!q.empty()) {
        int x, y;
        x = q.front().first, y = q.front().second;
        q.pop();
        rep (i, 4) {
            int nx, ny;
            nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
            if (s[nx][ny] == '#') continue;
            if (g[nx][ny] >= g[x][y]) continue;
            q.push(make_pair(nx, ny));
            cnt++;
            break;
        }
    }
    cout << h * w - 1 - black - cnt << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,k,x,y,i,ans;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	ans=0;
	for(i=1;i<=n;i++){
	    if(k<i){
		    ans+=y;
		}
		else{
		    ans+=x;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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


int main(){
    cout<<fixed<<setprecision(10);

    
    ll H,W;cin>>H>>W;
    
    while(H>0 || W>0){
        rep(i,H){
            if(i == 0 || i == H-1){
                rep(j,W)cout<<'#';
            }else{
                cout<<'#';
                rep(j,W-2) cout<<".";
                cout<<'#';
            }
            cout<<endl;
        }    
        cout<<endl;
        cin>>H>>W;
    }
    

    

    return 0;
}





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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
	ull n = 0;
	cin >> n;
	if( n == 3 )
	{
		cout << 2 << " " << 5 << " " << 63 << endl;
	}
	else if( n <= 10000 )
	{
		cout << 3 << " " << 9;
		n -= 2;
		// 15000
		ull nn = n - 1;
		ull i = 2;
		ull sum = 0;
		for( ull j = 0; j < nn; i += 2, ++j, --n )
		{
			cout << " " << i;
			sum += i;
			sum = sum % 30;
		}
		for( ; true; i += 2 )
		{
			if( ( sum + i ) % 30 == 0 )
			{
				cout << " " << i << endl;
				break;
			}
		}
	}
	else
	{
		// 2000
		cout << 5 << " " << 25;
		n -= 2;
		for( ull i = 55; i <= 30000; i += 30, n -= 2 )
		{
			cout << " " << i - 20 << " " << i;
		}
		// 5000
		for( ull i = 27; i <= 30000; i += 30, n -= 5 )
		{
			cout << " " << i - 24 << " " << i - 18
			<< " " << i - 12 << " " << i - 6
			<< " " << i;
		}
		// 15000
		ull nn = n - 1;
		ull i = 2;
		ull sum = 0;
		for( ull j = 0; j < nn; i += 2, ++j, --n )
		{
			cout << " " << i;
			sum += i;
			sum = sum % 30;
		}
		for( ; true; i += 2 )
		{
			if( ( sum + i ) % 30 == 0 )
			{
				cout << " " << i << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <iostream>
#include<string>

int main()
{
	std::string str[3];
	int cnt;

	for (int i = 0; i < 3; i++) {
		std::cin >> str[i];
	}
	int num[] = { 0,0,0 };

	for (int i = 0; i < 3; i++) {
		num[i] = stoi(str[i]);
	}
	cnt = num[2];
	num[2] = num[1];
	num[1] = num[0];
	num[0] = cnt;

	printf("%d %d %d", num[0], num[1], num[2]);
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, k; cin >> n >> k;
	int nk = n / k;
	int rk = n % k;

	vector<int> ps(n); for (auto& p : ps) { cin >> p; }
	vector<int64_t> cs(n); for (auto& c : cs) { cin >> c; };

	vector<vector<int64_t>> ans(n, vector<int64_t>(n + 1));
	vector<int> ncycle(n);

	FOR_LT(i, 0, n) {
		int p = i;
		int64_t ca = 0;
		int c = 0;
		do{
			p = ps[p] - 1;
			ca += cs[p];
			c++;
			ans[i][c] = ca;
		} while (p != i);
		ncycle[i] = c;
	}

	int64_t fans = INT64_MIN;
	FOR_LT(i, 0, n) {
		int64_t ca = INT64_MIN;
		FOR_LE(t, 1, min(k, ncycle[i])) {
			ca = max(ca, ans[i][t]);
			int64_t r = ans[i][ncycle[i]] * ((k - t) / ncycle[i]);
			ca = max(ca, ans[i][t] + r);
		}
		fans = max(ca, fans);
	}
	cout << fans << endl;

	return 0;
}

Measured memory_bytes: 198808
solver :: Int -> Int -> Int
solver n l =
  let tot = div (n * (2 * l + n - 1)) 2
   in if l > 0
        then tot - l
        else if (l + n - 1) < 0
               then tot - (l + n - 1)
               else tot

main :: IO ()
main = do
  n:l:[] <- map read . words <$> getLine
  print $ solver n l


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;


int main() {


    int N;
    cin >> N;

    N = N % 10;

    if(N == 2 or N == 4 or N ==5 or N==7 or N==9) {
        cout << "hon" << endl;
    } else if (N == 0 or N == 1 or N ==6 or N==8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }


    return 0;

}

Measured memory_bytes: 3616
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            switch (Console.ReadLine())
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    ll ans = 1;

    ll r = 1e18;

    vector<ll> a(n);

    for (auto &x : a)
    {
        cin >> x;
        if (x == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (1000000000000000000ll / ans < a[i])
        {
            cout << -1 << endl;
            return 0;
        }

        ans *= a[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, cnt=0;
  cin >> a >> b;
  
  for(int i=a; i<=b; i++){
	if(i%10 == i/10000%10){
      if(i/10%10 == i/1000%10) cnt++;
    }
  }

  cout << cnt << endl;
}

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

int cnt=0;

void bubbleSort(int N, int A[]){
    int flag=1,tmp=0;
    while(flag){
        flag=0;
        for(int i=N-1; i>=1; i--){
            if(A[i]<A[i-1]){
                tmp=A[i];
                A[i]=A[i-1];
                A[i-1]=tmp;
                flag=1;
                cnt++;
            }
        }
    }
}

int main(){
    int n,a[105]={};
    cin>>n;
    for(int i=0; i<n; i++)cin>>a[i];
    bubbleSort(n,a);
    for(int i=0; i<n; i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll ls;
string s, t;

int main(){
    cin >> ls >> s >> t;
    ll sm = 0, tm = 0;
    ll ss = s.size(), ts = t.size();
    for (ll i = 0; i <= ls; i++) {
        if (ss * i > ls) break;
        if ((ls - ss*i)%ts == 0) {
            sm = max(sm, i);
            tm = max(tm, (ls-ss*i)/ts);
        }
    }
    string out1;
    rep(i,sm) out1 += s;
    rep(i,(ls-ss*sm)/ts) out1 += t;
    string out2;
    rep(i,tm) out2 += t;
    rep(i,(ls-ts*tm)/ss) out2 += s;
    cout << min(out1, out2) << endl;
}
































Measured memory_bytes: 1408
def mi():
    return map(int, input().split())
'''
3 4
*G*S
G**S
*G*S
'''
n,m = mi()
l = -1
r = 1e10
for i in range(m):
    a,b=mi()
    if l>b or b<a:
        print(0)
        exit()
    l = max(l,a)
    r = min(r,b)
if r<l:
    print(0)
else:
    print(r-l+1)

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

ll tb[200005];

int main(){
    int n; 
    cin>>n;
    ll sum=0;
    vector<int> v;
    rep(i,n){
        int a;cin>>a;
        tb[a]++;
        v.push_back(a);
    }
    REP(i,n){
        sum+=tb[i]*(tb[i]-1)/2;
    }

    for(auto k:v){
        cout<<sum-(tb[k]-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 4084
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

using namespace std;
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define if_range(x, w, h) if (w <= x && x <= h)
#define BitCheck(a,b)   (a >> b) & 1
#define BitSet(a,b)       a |= (1 << b)
#define BitunSet(a,b)    a &= ~(1 << b)
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define numof(array)  (sizeof (array) / sizeof *(array))
template <typename T>
class Node {
	T value;
	Node* prev;
	Node* next;

public:
	Node(T value_a, Node* prev_a, Node* next_a) : value(value_a), prev(prev_a), next(next_a) {};
	T Getvalue() { return value; }
	Node* Getprev() { return prev; }
	Node* Getnext() { return next; }
	void Setvalue(T value_a) { value = value_a; }
	void Setprev(Node* prev_a) { prev = prev_a; }
	void Setnext(Node* next_a) { next = next_a; }
};

template <typename T>
class Double_List {
	Node<T>* dummy;

public:
	Double_List() {
T buf;
		dummy = new Node<T>(buf, nullptr, nullptr);
		dummy->Setprev(dummy);
		dummy->Setnext(dummy);
	}
	void node_insert(T value) {
		Node<T> *First = new Node<T>(value, dummy->Getprev(), dummy);
		dummy->Getprev()->Setnext(First);
		dummy->Setprev(First);
	}
	bool node_delete(T tar) {
		Node<T>* now = dummy;
		do {
			now = now->Getprev();
			if (now == dummy)
				return false;

		} while (now->Getvalue() != tar);
		now->Getprev()->Setnext(now->Getnext());
		now->Getnext()->Setprev(now->Getprev());
		delete now;
		return true;
	}

	bool node_deleteFirst() {
		if (dummy->Getprev() == dummy) return false;
		Node<T>* buf = dummy->Getprev();
		dummy->Getprev()->Getprev()->Setnext(dummy);
		dummy->Setprev(dummy->Getprev()->Getprev());
		delete buf;
		return true;
	}
	bool node_deleteLast() {
		if (dummy->Getnext() == dummy) return false;
		Node<T>* buf = dummy->Getnext();
		dummy->Getnext()->Getnext()->Setprev(dummy);
		dummy->Setnext(dummy->Getnext()->Getnext());
		delete buf;
		return true;
	}

	void Printall() {
		Node<T>* now = dummy;
		while (1) {
			now = now->Getprev();
			if (now == dummy)return;
			cout << now->Getvalue();
			if (now->Getprev() != dummy) printf(" ");
		}
	}
	~Double_List() {
		while (node_deleteFirst());
		delete dummy;
	}
};

int main() {
	int n;
	Double_List<int> list;

	scanf("%d", &n);
	for (int i = 0; n > i; i++) {
		char order[15];
		scanf("%s", order);
		if (!strcmp(order, "insert")) {
			int arg;
			scanf("%d", &arg);
			list.node_insert(arg);
		}
		else if (!strcmp(order, "delete")) {
			int arg;
			scanf("%d", &arg);
			list.node_delete(arg);
		}
		else if (!strcmp(order, "deleteFirst"))
			list.node_deleteFirst();
		else if (!strcmp(order, "deleteLast"))
			list.node_deleteLast();
	}
	list.Printall();
	printf("\n");
	return 0;
}

Measured memory_bytes: 34372
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

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

ll a[n+1];
ll sum=0;
rep(i, n){
	cin>>a[i];
	sum+=a[i];
}
ll ans=inf;

for(int i=2;i<=n;i++){
	a[i]=a[i]+a[i-1];
}
rep(i, n-1){
	ans=min(ans,abs(a[i]-(sum-a[i])));
}
cout<<ans<<endl;
return 0;


}




Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    int tmp=pow(2, N);
    int a;
    for(int i=0; i < N; i++){
        a = pow(2, i) + (N - i) * K;
        tmp = min(a, tmp);
    }
    cout << tmp << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int S(int n)
{
	int sum = 0;

	for ( int i = 0; i < 10; i++ )
	{
		sum += (int)(n / pow(10, i)) % 10;
	}

	return sum;
}

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

	int sn = S(n);

	if ( sn == 0 )
	{
		cout << "No" << endl;
	}
	else
	{
		if ( n % sn == 0 )
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

std::vector<int> Zalgorithm(const std::string& s){
  int ret = 0;
  int n = s.length();
  std::vector<int> z(n, 0);

  int L = 0, R = 0;
  for(int i=1; i<n; i++){
    if(i>R){
      L = R = i;
      while(R<n && s[R-L] == s[R]) R++;
      z[i] = R-L;
      R--;
    }else{
      int k = i-L;
      if(z[k] < R-i+1){
        z[i] = z[k];
      }else{
        L = i;
        while(R<n && s[R-L] == s[R]) R++;
        z[i] = R-L;
        R--;
      }
    }
    ret = std::max(ret, z[i]);
  }
  return z;
}

int main(){
  string s, t;
  cin >> s >> t;

  string ss = s;
  while(ss.size() < 2*t.size()) ss += s;
  if(ss.size() == s.size()) ss += s;
  
  string m = t + "$" + ss;

  vector<int> res = Zalgorithm(m);
  vector<int> ok(s.size(), 0);
  rep(i,s.size()){
    if(res[t.size()+1+i] == t.size()) ok[i] = 1;
  }

  vector<int> dp(s.size(),-1);
  rep(tt,3){
    bool update = false;
    rep(i,s.size()){
      int p = i - (int)(t.size() % s.size());
      if(p<0) p += s.size();
      if(ok[i] == 0){
        dp[i] = 0;
      }else{
        if(dp[p] >= 0){
          int prev = dp[i];
          dp[i] = dp[p] + 1;
          if(dp[i] != prev) update = true;
        }else{
          dp[i] = 1;
        }
      }
    }
    if(tt==2 && update){
      cout << -1 << endl;
      return 0;
    }
  }

  int ret = 0;
  rep(i,s.size()){
    ret = max(ret, dp[i]);
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 16820
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int main(){
  long long n,m,k,M=998244353,d[200010],i,s=1,a=0;
  scanf("%lld %lld %lld",&n,&m,&k);
  d[0]=m;  
  for(i=1;i<n;i++)d[i]=(d[i-1]*(m-1))%M;
  //for(i=0;i<n;i++)printf("%lld %lld\n",i,d[i]);
  for(i=0;i<=k;i++){
    a=(a+(d[n-i-1]*s%M))%M;//printf("%lld\n",s);
    s=s*(n-i-1)%M;
    s=s*inv(i+1,M)%M;
  }
  printf("%lld\n",a);
  return 0;
}


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

int main(void){
	string s;
	int m,n;
	cin >> s;
	while(s != "-"){
		cin >> m;
		for(int i = 0; i < m;i++){
			cin >> n;
			s = s.substr(n)+s.substr(0,n);
		}
		cout << s << endl;
		cin >> s;
	}
}



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

const int MOD = 1e9 + 7;

void add(int& a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

int main() {
	string s;
	cin >> s;
	reverse(s.begin(), s.end());

	vector<int> ans(13);
	ans[0] = 1;

	int ten = 1;
	for (char c : s) {
		vector<int> tmp(13);
		if (c == '?') {
			for (c = '0'; c <= '9'; c++) {
				for (int mod = 0; mod < 13; mod++) {
					add(tmp[(mod + ten*(c-'0'))%13], ans[mod]);
				}
			}
		} else {
			for (int mod = 0; mod < 13; mod++) {
				add(tmp[(mod + ten*(c-'0'))%13], ans[mod]);
			}
		}
		ten = (ten * 10) % 13;
		swap(tmp, ans);
	}
	cout << ans[5] << endl;

	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <iomanip>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1200000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define SHOWVEC(v, n) for(int i = 0; i < (n); i++)cerr<<(v[i])<<' ';cerr<<endl;

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(ALL(A));
  vector<long long> Asum(A);
  for (int i = 0; i < N - 1; i++) {
    Asum[i + 1] += Asum[i];
  }

  int idx = -1;
  for (int i = 0; i < N - 1; i++) {
    if (2*Asum[i] < A[i + 1]) idx = i;
  }
  cout << (N - idx - 1) << endl;

  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>

using namespace std;

int pow(int x, int n) {
  int ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= x;
  }
  return ans;
}
int charToInt(char c) {
  return (int)c - (int)'0';
}

int strToInt(string str) {
  int ans = 0;
  for(int i = 0; i < str.length(); i++) {
    ans += charToInt(str[i]) * pow(10, (int)str.length()-i-1);
  }
  return ans;
}

int main() {
  string str;
  int l = 1;
  string temp;
  int data[100][50];
  while(getline(cin, str)) {
    if(l == 1) {
      for(int i = 0; i < 100; i++) {
	for(int j = 0; j < 50; j++) {
	  data[i][j] = -1;
	}
      }
    }
    int t = 0;
    int count = 0;
    int s = 0;
    for(int i = 0; i <= str.length(); i++) {
      if(str[i] == ',' || i == str.length()) {
	count++;
	data[l-1][t++] = strToInt(str.substr(s, i-s));
	s = i+1;
      }
    }
    l++;
  }
  l -= 1;
  int w = l/2+1;
  int value[l][w];
  for(int i = 0; i < l; i++) {
    for(int j = 0; j < w; j++) {
      value[i][j] = -1;
    }
  }
  value[0][0] = data[0][0];
  for(int i = 1; i < l; i++) {
    for(int j = 0; j < w; j++) {
      if(data[i][j] == -1) break;
      for(int k = 0; k < 2; k++) {
	int nx, ny;
	ny = i-1;
	if(i <= l/2) {
	  switch(k) {
	  case 0:
	    nx = j-1;
	    break;
	  case 1:
	    nx = j;
	    break;
	  }
	} else {
	  switch(k) {
	  case 0:
	    nx = j;
	    break;
	  case 1:
	    nx = j+1;
	    break;
	  }
	}
	if(nx < 0) continue;
	if(nx >= 50) continue;
	if(ny < 0) continue;
	if(ny >= 100) continue;
	if(data[ny][nx] == -1) continue;
	
	int newValue = data[i][j] + value[ny][nx];
	if(newValue > value[i][j]) value[i][j] = newValue;
      }
    }
  }
  
  cout << value[l-1][0] << endl;

  return 0;
}

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

signed main(void)
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15)
		cout << '+' << endl;
	else if (a * b == 15)
		cout << '*' << endl;
	else
		cout << 'x' << endl;
	return 0;
}


Measured memory_bytes: 256
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=a; i<(int)b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 3e5+2;


void solve()
{
    ll x, k, d;
    cin >> x >> k >> d;

    ll mn = LLONG_MAX;

    x = abs(x);

    ll dist = x;
    ll moves = (dist + d - 1) / d; // dbg(moves);

    if(moves > k) {
        ll le = x - (k * d);

        lprin(abs(le));

        exit(0);
    }   
    
    {
        ll le = x - (moves * d);

        // dbg(le);

        ll remain = k - moves;

        if(remain & 1) {
            mn = le + d;
        } else {
            mn = le;
        }
    }

    {
        ll ri = x - ((moves - 1) * d);

        k -= (moves - 1);

        if(k & 1) {
            mn = ri - d;
        } else {
            mn = ri;
        }
    }

    lprin(abs(mn));
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3760
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
# define ll unsigned long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 998244353
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)
const ll mod = 1000000007;
const int K = 2;
//typedef vector<vector<int> > matrix;
/*
int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	a += mod;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}
*/

signed main(){
   gok

   int x,y;
   cin>>x>>y;
   bool ch=false;
   for(int i=0;i<=x;i++)
   {
       int tt = 2*i + (x-i)*4;
       if(tt==y)
       {
           ch=true;
           break;
       }
   }

if(ch)
    cout<<"Yes";
else
    cout<<"No";

















 return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
  int N;
  scanf("%d", &N);
  for(int i = 0; i <= N/4; i++){
    for(int j = 0; j <= N/7; j++){
      if(4*i + 7*j == N){
        printf("%s\n", "Yes");
        return 0;
      }
    }
  }
  printf("%s\n", "No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long N, long long D){
 if(N%(D*2+1))op(N/(D*2+1)+1)
  else op(N/(D*2+1))
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
    return 0;
}


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

int main(){
    int N,a,b,c=0,i,k=0;
    cin >> N >> a >> b;
    char S[N+1];
    scanf("%s",S);
    for(i=0;i<N;i++){
        if(S[i] == 'a' && c<a+b){cout << "Yes" << endl;c++;}
        else if(S[i] == 'b' && c<a+b && k <b){cout << "Yes" << endl;c++;k++;}
        else{cout << "No" << endl;}
    }
    return 0;
}

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




    int main(){
        int n;
        std::cin >> n;
        std::vector<int> a(n), b(n), c(n-1);
        rep(i, n) std::cin >> a[i];
        rep(i, n) std::cin >> b[i];
        rep(i, n) std::cin >> c[i];
        int cnt = b[a[0]-1];
        for (int i = 1; i < n; ++i)
        {
            cnt += b[a[i]-1];
            if (a[i-1] == a[i]-1)
            {
                /* code */cnt += c[a[i-1]-1];
            }
        }
        std::cout << cnt << "\n";
        return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int width, height, n;

	scanf("%d", &width);
	scanf("%d", &height);
	scanf("%d", &n);

	int rect[101][101] = {0};

	int result = (width) * (height);
	for (int i = 0; i < n; i++) {
		int x, y, a;
		scanf("%d", &x); scanf("%d", &y); scanf("%d", &a);

		switch(a) {
			case 1:
				for (int j = 0; j < height; j++) {
					for (int k = 0; k < x; k++) {
						if (rect[k][j]) continue;
						rect[k][j] = 1;
						result--;
					}
				}
				break;
			case 2:
				for (int j = 0; j < height; j++) {
					for (int k = x; k < width; k++) {
						if (rect[k][j]) continue;
						rect[k][j] = 1;
						result--;

					}
				}
				break;
			case 3:
				for (int j = 0; j < y; j++) {
					for (int k = 0; k < width; k++) {
						if (rect[k][j]) continue;
						rect[k][j] = 1;
						result--;
					}
				}
				break;
			case 4:
				for (int j = y; j < height; j++) {
					for (int k = 0; k < width; k++) {
						if (rect[k][j]) continue;
						rect[k][j] = 1;
						result--;
					}
				}
				break;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
N =int(input())
word_list = [input() for i in range(N)]
ans = "Yes"
def f(s1,s2):
  if s1[len(s1)-1] == s2[0] :
    return True

for i in range(0,N-1):
  if f(word_list[i],word_list[i+1]):
    pass
  else:
    ans = "No"

if len(set(word_list)) != len(word_list):
  ans = "No"

print(ans)

Measured memory_bytes: 38256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 1003
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a);



    return 0;
}


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


int main(){
	string s;
	cin>>s;
	string a="AIDUNYAN";
	string b="AIZUNYAN";
	
	sort(a.begin(),a.end());
	
	for(int i=7;i<s.size();i++){
		string t="";
		for(int j=i-7;j<=i;j++)t+=s[j];
		sort(t.begin(),t.end());
		if(a==t){
			for(int j=i-7,k=0;j<=i;j++,k++){
				s[j]=b[k];
			}
			i+=7;
		}
	}
	
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1216
SWITCHES, LIGHTS = gets.split(' ').map(&:to_i)
switches_to_check = []
LIGHTS.times do
  sum, *switches = gets.split(' ').map{|n| n.to_i }
  switches_to_check << switches
end
ps = gets.split(' ').map(&:to_i)
total = 0
0.upto(2 ** SWITCHES - 1) do |i|
  switches = i.to_s(2).split('').map{|s| s == '1' ? true : false}
  if switches.length != SWITCHES
    (SWITCHES - switches.length).times{switches.unshift(false)}
  end
  lights_on = 0
  1.upto(LIGHTS) do |m|
    total_switches_on = 0
    switches_to_check[m - 1].each do |stc|
      total_switches_on += 1 if switches[stc - 1] == true
    end
    lights_on += 1 if total_switches_on % 2 == ps[m - 1]
  end
  total += 1 if lights_on == LIGHTS
end
p total

Measured memory_bytes: 3964
#include <iostream>
using namespace std;
typedef long long LL;
LL F2(int N)
{
	if (N<=1){
		return 0;
	}
	return N*(N-1)/2;
}
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	cout<<F2(N)+F2(M)<<endl;
	return 0;
}

Measured memory_bytes: 256
def smallestPossible(creatures):
	creatureSum = 0
	possible = 0
	for i in range(len(creatures)):
		if i == len(creatures) - 1:
			return possible + 1
		creatureSum += creatures[i]
		if (2 * creatureSum >= creatures[i + 1]):
			possible += 1
		else:
			possible = 0

input()
print(smallestPossible(sorted(list(map(lambda x: int(x), input().split())))))

Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
using ll = unsigned long long;
using P = pair<int, int>;

const ll MAX = 1e18;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    int zero = 0;
    rep(i,n) {
        cin >> a[i];
        if(a[i] == 0) zero++;
    }
    if(zero){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i,n){
        if(MAX/ans < a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4056
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	int sum = 0;
	int days = 0;
	while(true){
		if(sum + A*7 + B >= C){
			for(int i = 0; i < 7; i++){
				sum += A;
				days++;
				if(i == 6){
					sum += B;
				}
				if(sum >= C){
					break;
				}
			}
		}
		else{
			sum += A*7 + B;
			days += 7;
		}
		if(sum >= C){
			break;
		}
	}
	cout << days << "\n";
}



Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<cstdlib>
#include<queue>
#include<algorithm>
using namespace std;

struct State {
	int d, x, y, foot;
	State(int _d, int _x, int _y, int _foot) {
		d = _d;
		x = _x;
		y = _y;
		foot = _foot;
	}
};

int d[30][60][2];
vector<int>sv;

int dijkstra(vector<vector<int>>&cost, State start) {
	int res = 1000000;
	auto compare = [](const State& s1, const State& s2) {return s1.d > s2.d; };
	priority_queue < State, vector<State>, decltype(compare) > q(compare);
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 60; j++) {
			d[i][j][0] = d[i][j][1] = 1000000;
		}
	}
	d[start.x][start.y][start.foot == 1] = 0;
	q.push(start);
	int flag = 0;
	while (!q.empty()) {
		State s = q.top(); q.pop();
		if (d[s.x][s.y][s.foot == 1] < s.d)continue;
		if (cost[s.x][s.y] == 0) return s.d;
		for (int mx = 1; mx <= 3; mx++) {
			for (int my = 3 - mx; my >= mx - 3; my--) {
				int next_x = s.x + mx*s.foot;
				int next_y = s.y + my;
				if (!(next_x >= 0 && next_x < cost.size() && next_y >= 0 && next_y < cost[0].size()))continue;
				if (cost[next_x][next_y] == -1)continue;
				if (d[next_x][next_y][(-s.foot) == 1] > d[s.x][s.y][s.foot == 1] + cost[next_x][next_y]) {
					d[next_x][next_y][(-s.foot) == 1] = d[s.x][s.y][s.foot == 1] + cost[next_x][next_y];
					q.push(State(d[next_x][next_y][(-s.foot) == 1], next_x, next_y, -s.foot));
				}
			}
		}
	}
	return res;
}

int main() {
	int w, h;
	while (cin >> w >> h, w) {
		vector<vector<int>>cliff(w, vector<int>(h));
		bool s_flag = 0, t_flag = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				char c; cin >> c;
				if (c <= '9' && c >= '0') {
					cliff[j][i] = atoi(&c);
				}
				else if (c == 'S') {
					cliff[j][i] = -1;
					sv.push_back(j);
				}
				else if (c == 'X')cliff[j][i] = -1;
				else if (c == 'T') cliff[j][i] = 0;
			}
		}
		int ans = 1000000;
		for (auto start : sv) {
			int ans1 = min(dijkstra(cliff, State(0, start, h - 1, 1)), dijkstra(cliff, State(0, start, h - 1, -1)));
			ans = min(ans, ans1);
		}
		if (ans == 1000000)ans = -1;
		cout << ans << endl;
		sv.clear();
	}
}

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

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    ll result = 0;
    REP(i, N) {
        result += A[i] / 2;
        A[i] %= 2;
        if (A[i] == 1 && i + 1 < N && A[i + 1] > 0) {
            --A[i];
            --A[i + 1];
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 640
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod    1000000007
#define PI 2*acos(0.0)

bool ck(int n, int p)
{
    return (bool)(n &(1<<p));
}


int32_t main()
{
    io;
    int h, w, k;
    cin>>h>>w>>k;
    string inp[h];
    for(int i= 0; i< h; i++)
        cin>>inp[i];
    int ans = 0;
    for(int i = 0; i < (1<<h); i++)
    {
        for(int j = 0; j < (1<<w); j++)
        {
            int cnt = 0;
            for(int x = 0; x < h; x++)
            {
                if(!ck(i, x))
                    continue;
                for(int y = 0; y < w; y++)
                {
                    if(!ck(j, y) || inp[x][y] == '.')
                        continue;
                    cnt++;

                }
            }
            if(cnt == k)
                ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

int go(int * a,int n,int * output)
{
	if(n<=1)
	return 0;
	if(output[n-1]!=-1)
	return output[n-1];
	int value=abs(a[0]-a[1]);
	int value2=abs(a[0]-a[2]);
	int ans=go(a+1,n-1,output);
	int ans1=go(a+2,n-2,output);
	output[n-1]= min(ans1+value2,ans+value);
	return output[n-1];
}
int32_t main(){
	ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   int a[n];
   for(int i=0;i<n;i++)
   cin >> a[i];
   int output[n];
   for(int i=0;i<n;i++)
   output[i]=-1;
   int ans=go(a,n,output);
   cout << ans <<endl;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <numeric>
#include <iostream>
using namespace std;

int x[101];
int len[101];

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

    for (int n = 1; n <= N; n++) {
        cin >> x[n];
        int A = x[n] * 2;
        int B = abs(x[n] - K) * 2;
        len[n] = min(A, B);
    }

    cout << accumulate(len + 1, len + N + 1, 0) << endl;

    return 0;
}

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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n;cin>>n;
  vi t(n);cin>>t;
  int ans = 1;
  rep(i,n) ans = lcm(ans,t[i]);
  cout << ans << endl;
}



Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = str(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    N = [int(n[i]) for i in range(len(n))]
    Dic = {1:"+", -1:"-"}

    flag = False
    for i in [-1, 1]:
        for j in [-1, 1]:
            for k in [-1, 1]:
                if N[0] + (i * N[1]) + (j * N[2]) + (k * N[3]) == 7:
                    print(str(N[0]) + Dic[i] + str(N[1]) + Dic[j] + str(N[2]) + Dic[k] + str(N[3]) + "=7")
                    flag = True
                    break
            if flag == True:
                break
        if flag == True:
            break

resolve()

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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define FOUND(u, val) u.find(val) != u.end()
#define max_self(a, b) a = max(a, b);

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

/* 
3
0.30 0.60 0.80

 */

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

    int n;
    cin >> n;

    // if we had i tosses then tails = i - heads
    vector<double> dp(n + 1);
    dp[0] = 1;
    for (int coin = 0; coin < n; coin++) {
        double p_heads;
        cin >> p_heads;
        for (int i = coin + 1; i >= 0; i--) {
            dp[i] = (i == 0 ? 0 : dp[i - 1] * p_heads) + dp[i] * (1 - p_heads);
            // dp[i + 1] += p_heads * dp[i];
            // dp[i] = (1 - p_heads) * dp[i];
        }
    }
    double answer = 0;
    for (int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if (heads > tails) {
            answer += dp[heads];
        }
    }
    printf("%.10lf\n", answer);
}

Measured memory_bytes: 3868
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
#define sbs(i,j) substr(i,j)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int get_digits(int x){
    int cnt=0;
    while(x){
        cnt++;
        x/=10;
    }
    return cnt;
}
int main(){
    ll N;
    cin>>N;
    int ans=get_digits(N);
    for(ll i = 1;i*i<=N;i++){
        if(N%i!=0) continue;
        ll k=N/i;
        ans=min(ans,max(get_digits(k),get_digits(i)));
    }
    cout<<ans<<endl;
    getchar();
    return 0;
}

Measured memory_bytes: 256
// I am Nothing, You Are Nothing!
// Krishna is Everything ...
// Jai Shree Krishna

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e2 + 5, M = 1e5 + 5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, bag_capacity;
	cin >> n >> bag_capacity;

	vector<int> weights(n + 1), values(n + 1);

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

	vector<vector<int>> dp(n + 1, vector<int>(bag_capacity + 1, 0));

	for (int w = weights[1]; w <= bag_capacity; w++) {
		dp[1][w] = values[1];
	}

	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= bag_capacity; j++) {
			int best = dp[i - 1][j];
			if (weights[i] <= j) {
				best = max(best, values[i] + dp[i - 1][j - weights[i]]);
			}
			dp[i][j] = best;
		}
	}
	cout << dp[n][bag_capacity] << endl;

	return 0;
}


Measured memory_bytes: 83092
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL x = 0;
	inc(i, n) { x += (i % 2 == 0 ? +1 : -1) * a[i]; }
	x /= 2;
	
	inc(i, n) {
		cout << 2 * x << "\n";
		x = a[i] - x;
	}
	
	return 0;
}


Measured memory_bytes: 2048