akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll dp[3002][3002];
ll a[3002], n;
ll func(ll st, ll end) {
    if(dp[st][end] != -1) {
        return dp[st][end];
    }
    if(st == end) {
        dp[st][st] = a[st];
        return a[st];
    }
    if(end == st + 1) {
        dp[st][end] = max(a[st], a[end]);
        return dp[st][end];
    }
    dp[st][end] = max(a[st] + min(func(st + 2, end), func(st + 1, end - 1)), a[end] + min(func(st + 1, end - 1), func(st, end - 2)));
    return dp[st][end];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll i, j, k, sum = 0;
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    ll ans = func(0, n - 1);
    cout << ans + ans - sum << endl;

    return 0;
}

Measured memory_bytes: 70784
s = input()
n = len(s) + 1

aw = [0] * n
for i in range(1, n):
    if s[i - 1] == '<':
        aw[i] = aw[i - 1] + 1
    else:
        aw[i] = 0

ae = [0] * n
for j in range(n - 2, -1, -1):
    if s[j] == '>':
        ae[j] = ae[j + 1] + 1
    else:
        ae[j] = 0

print(sum([max(aw[i], ae[i]) for i in range(n)]))


Measured memory_bytes: 31900
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

ans=0
n = int(input())
divisors = make_divisors(n)
for i in divisors[1:]:
    i -= 1
    if n % i == n//i:
        ans += i

print(ans)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

bool dp[2][1<<24];
void Main() {
  int n;
  R n;
  n++;
  if(n>=25) {
    pr(0);
    return;
  }
  int d[n],r=0;
  d[0]=0;
  REP(i,1,n) R d[i];
  sort(d,d+n);
  dp[0][1]=1;
  REP(i,1,n) {
    rep(t,1<<24) {
      if(!dp[r][t]) continue;
      int x=d[i];
      if(!(t&(1<<x))) dp[r^1][t|(1<<x)]|=1;
      x=(24-d[i])%24;
      if(!(t&(1<<x))) dp[r^1][t|(1<<x)]|=1;
    }
    r^=1;
  }
  int ans=0;
  rep(t,1<<24) {
    if(!dp[r][t]||__builtin_popcount(t)!=n) continue;
    vector<int> v;
    rep(i,24) {
      if(t&(1<<i)) v.pb(i);
    }
    int x=MAX;
    rep(i,v.size()) {
      int y=abs(v[(i+1)%v.size()]-v[i]);
      y=min(y,24-y);
      x=min(x,y);
    }
    ans=max(ans,x);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
    vector<char> ans;
    long long int num;
    scanf("%lld", &num);
    num--;

    while (num >= 26) {
        ans.push_back((char)(((int)(num%26))+97));
        num /= 26;
        num--;
    }
    ans.push_back((char)(((int)(num % 26)) + 97));

    for (int i = ans.size()-1; i>=0; i--)
        printf("%c", ans[i]);
    printf("\n");

    return 0;
}

Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, C;
	cin >> A >> B >> C;

	if( A == B && B == C ) {
		cout << (A%2 == 0 ? -1 : 0) << endl;
	}
	else {
		int ans = 0;
		while( A%2 == 0 && B%2 == 0 && C%2 == 0 ) {
			int a = A;
			int b = B;
			int c = C;
			A = (a+b)/2;
			B = (b+c)/2;
			C = (c+a)/2;
			ans += 1;
		}
		cout << ans << endl;
	}

	return 0;
}


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

#pragma region  // {{{

#define all(x) std::begin(x), std::end(x)
#define rall(x) std::rbegin(x), std::rend(x)
#define rep(i, begin, end) for (int64_t i{begin}, i##_end{end}; i < i##_end; ++i)
#define repc(i, begin, last) for (int64_t i{begin}, i##_last{last}; i <= i##_last; ++i)
#define repr(i, begin, last) for (int64_t i{begin}, i##_last{last}; i >= i##_last; --i)
#define let const auto
using i64 = std::int64_t;
using u64 = std::uint64_t;

constexpr int32_t INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

void ioSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(11);
    std::cerr << std::fixed << std::setprecision(11);
    std::clog << std::fixed << std::setprecision(11);
}

template <class T>
std::istream& operator,(std::istream& is, T& rhs) {
    return is >> rhs;
}

#define var(type, ...) \
    type __VA_ARGS__;  \
    std::cin >> __VA_ARGS__

inline void println() {
    std::cout << '\n';
}
template <class Head, class... Tail>
inline void println(Head&& head, Tail&&... tail) {
    std::cout << head << " " + (!sizeof...(tail));
    println(std::forward<Tail>(tail)...);
}

template <class T, class U>
inline bool chmin(T& a, const U& b) {
    return b < a && (a = b, true);
}

template <class T, class U>
inline bool chmax(T& a, const U& b) {
    return b > a && (a = b, true);
}

#pragma endregion  // }}}

// constexpr int MOD = int(1e9) + 7;
// constexpr int MOD = 998244353;

signed main() {
    ioSetup();

    var(int, n);
    println(360 / gcd(360, n));

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define Int long long
#define all(x) begin(x),end(x)
#define endl "\n"
#define cy cout << "YES"<<endl 
#define cn cout<<"NO"<<endl
#define elif else if

using namespace std;

int main () {
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++)cin >> a[i];
    int count {};
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            for(int k=0; k<n; k++) {
                if(a[i]!=a[j] && a[i]!=a[k] && a[k]!=a[j]){
                    if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j]) {
                        count++;}}}}}
  	cout << count/6 << endl;
    return 0;
    
}


Measured memory_bytes: 3592
class MyStack:
    def __init__(self):
        self._lst = []

    def push(self, val):
        self._lst.append(val)

    def pop(self):
        return self._lst.pop()

line_list = input().split()

stk = MyStack()

for t in line_list:
    if t == "+":
        stk.push(stk.pop() + stk.pop())
    elif t == "-":
        temp = stk.pop()
        stk.push(stk.pop() - temp)
    elif t == "*":
        stk.push(stk.pop() * stk.pop())
    else:
        stk.push(int(t))

print(stk.pop())


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
int bns (int a[], int l, int r, int key) {
    int mid;
    while(l<=r) {
        mid=(l+r) / 2;
        if(a[mid]<key) {
            l = mid + 1;
        } else
            r = mid - 1;
    }
    return l - 1;
}
int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int cnt=0;
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            cnt += bns(a,j+1,n-1,a[i] + a[j]) - j;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[3],k,i,max,sum;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&k);
	max=0;
	sum=0;
	for(i=0;i<3;i++){
		sum+=a[i];
		if(max<=a[i]){
			max=a[i];
		}
	}
	sum=sum-max;
	for(i=0;i<k;i++){
		max=max*2;
	}
	sum=sum+max;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

static const int MAX = 100;

class MatrixChainMultiplication {
private:
    int MCM[MAX + 1][MAX + 1];
    int p[MAX + 1];
    int n;

    void set()
    {
        cin >> n;
        cin >> p[0];
        int _;
        for(int i = 1; i <= n; i++)
        {
            cin >> p[i];
            if(i == n)
                break;
            cin >> _;
        }
    }

public:
    MatrixChainMultiplication()
    {
        set();
    }

    int matrix_chain_multiplication()
    {
        for(int i = 1; i <= n; i++)
            MCM[i][i] = 0;

        for(int l = 2; l <= n; l++)
        {
            for(int i = 1; i <= n - l + 1; i++)
            {
                int j = i + l - 1;
                MCM[i][j] = (1 << 21);
                for(int k = i; k <= j - 1; k++)
                    MCM[i][j] =
                            min(MCM[i][j], MCM[i][k] + MCM[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }

        return MCM[1][n];
    }
};

int main()
{
    MatrixChainMultiplication mcm;
    cout << mcm.matrix_chain_multiplication() << endl;
}


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

int f(int x){
        return x * x;
}

int area(int d) {
    int upper = 600/d; //x軸の上限
    int s = 0;  // 面積初期化

    // 計算
    for (int i = 0; i < upper; i++) {
        s += f((600-d) - i * d) * d;
    }
    return s;
}

int main(void){
    int d;
    while(scanf("%d", &d) != EOF) {
       printf("%d\n", area(d));
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main() {

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

	int n;
	cin >> n;

	if( n & 1 ) {
		n = n << 1;
	}

	cout << n << "\n";

}

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

int main(){
  long long n, h;
  cin >> n >> h;
  pair<long long, char> p[2*n];
  long long a,b;
  for ( int i = 0; i < n; i++){
    cin >> a >> b;
    p[2*i] = make_pair(a, 'a');
    p[2*i+1] = make_pair(b, 'b');
  }
  sort(p, p+2*n);
  long long cnt = 0;
  for ( int i = 0; i < 2 * n ; i++){
    int idx = 2 * n - 1 - i;
    if ( p[idx].second == 'b'){
      h -= p[idx].first;
      cnt++;
    } else {
      if ( h % p[idx].first == 0){
        cnt += h/p[idx].first;
      } else {
        cnt += h/p[idx].first + 1;
      }
      h = 0;
    }
    if ( h <= 0){
      break;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3328
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;


long long inv[N];
long long fac[N];
long long finv[N];

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

long long nCr(long long n , long long r){
    if(n < r)
        return 0;
    if(n < 0 || r < 0)
        return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) %mod;
}

long long nPr(long long n , long long r){
    if(n < r)
        return 0;
    if(n < 0 || r < 0)
        return 0;
    return (fac[n] * finv[n - r]) %mod;
}

int fastP(int b, int e){
    if(!e)
        return 1;
    if(e & 1)
        return b * 1ll * fastP(b * 1ll * b % mod, e >> 1) % mod;
    return fastP(b * 1ll * b % mod, e >> 1) % mod;
}

int n;
int m;

vector < int > primeFactors(long long num){
    vector < int > prm;
    while (num % 2 == 0){
        prm.push_back(2);
        num = num/2;
    }
    for (long long i = 3; i*i <= num; i = i + 2){
        while (num % i == 0){
            prm.push_back(i);
            num = num/i;
        }
    }
    if (num > 2)
        prm.push_back(num);
    return prm;
}

void mul_itself(long long & a , long long b){
     a *= b;
     a %= mod;
}

int main(){
    cominit();
    scanf("%d%d" , &n , &m);
    long long ans = 1;
    set < int > distinct;
    map < int , int > cnt;
    vector < int > mine = primeFactors(m);
    for(auto v : mine){
        cnt[v]++;
        distinct.insert(v);
    }
    auto it = cnt.begin();
    for(; it != cnt.end(); it++){
        mul_itself(ans , nCr(n - 1 + it->second , n - 1));
    }
    printf("%lld\n" , ans);
}



Measured memory_bytes: 4992
// AOJ Volume1 0218

#include <stdio.h>
#include <string.h>

int main(void)
{
    int n, k;
    int sell[10];
    int i, j;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        memset(sell, 0, sizeof(sell));
        
        for (i = 0; i < n; i++){
            scanf("%d", &k);
            sell[k]++;
        }
        for (i = 0; i < 10; i++){
            if (sell[i] == 0){
                printf("-\n");
            }
            else {
                for (j = 0; j < sell[i]; j++){
                    printf("*");
                }
                printf("\n");
            }
        }
    }
    return (0);
}

Measured memory_bytes: 568
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b){
			System.out.println("a < b");
		} else if(a > b){
			System.out.println("a > b");
		} else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26336
def print_nums(nums):
    print ''.join(['%5d' % num for num in nums])

while 1:
    n = int(raw_input())
    if n == 0: break
    sums = [0] * (n + 1)
    for i in range(n):
        nums = map(int, raw_input().split())
        nums.append(sum(nums))
        print_nums(nums)
        for j in range(n + 1):
            sums[j] += nums[j]
    print_nums(sums)

Measured memory_bytes: 4232
s=input()
dic=dict()
accum=0
exp=1
dic[0]=1
ans=0
length=len(s)
for i in range(length):
  temp=exp*int(s[length-i-1])
  exp*=10
  exp%=2019
  accum+=temp
  accum%=2019
  if accum in dic:
    ans+=dic[accum]
    dic[accum]+=1
  else:
    dic[accum]=1
print(ans)



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

int main(){
    vector <int> point(5);
    for(int i = 0; i < 5; i++){
        cin >> point.at(i);
    }
    int k;
    cin >> k;
    if(point.at(4) - point.at(0) <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }


}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string S; int junjo[4];
long long STOI(string V) {
    int LEN = V.size();
    if (LEN == 0) { return 0; }
    return (V[LEN - 1] - '0') + 10 * (STOI(V.substr(0, LEN - 1)));
}
long long calc(int L,int R){
    int K=0;
    vector<int>junjo2[4];
    for(int i=0;i<4;i++){
        junjo2[junjo[i]].push_back(i);
    }
    for(int i=0;i<4;i++){
        if(junjo2[i].size()>=1){
            for(int j=R-1;j>=L;j--){
                if(S[j]=='('){K++;}
                if(S[j]==')'){K--;}
                for(int k=0;k<junjo2[i].size();k++){
                    if(junjo2[i][k]==0){
                        if(S[j]=='+' && K==0){
                            return calc(L,j)+calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==1){
                        if(S[j]=='-' && K==0){
                            return calc(L,j)-calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==2){
                        if(S[j]=='*' && K==0){
                            return calc(L,j)*calc(j+1,R);
                        }
                    }
                    if(junjo2[i][k]==3){
                        if(S[j]=='/' && K==0){
                            return calc(L,j)/calc(j+1,R);
                        }
                    }
                }
            }
        }
    }
    if(S[L]=='(' && S[R-1]==')'){return calc(L+1,R-1);}
    return STOI(S.substr(L,R-L));
}
int main() {
	cin >> S; long long ret = (1LL << 63); S+="=";
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 4; j++) {
			for(int k = 0; k < 4; k++) {
				junjo[0] = i, junjo[1] = j, junjo[2] = k;
				ret = max(ret, calc(0, S.size() - 1));
			}
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 3336
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

double pi = 3.141592658597,r;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>r;
  printf("%.10f\n",2*pi*r);
  return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <cmath>

using namespace std;

int main(void)
{
    long long width;
    long long height;
    int x, y;

    cin >> width >> height >> x >> y;

    cout << (double)width * height / 2 << " ";
    if(fabs(x - (double)width / 2) < 1e-10 && fabs(y - (double)height / 2) < 1e-10){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}

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

#define pb push_back

//var 
int n,k,d,g,ans = 0;
vector<int> a[101];

int main(){
	cin >> n >> k;
	for(int i = 1; i<=k; i++){
		cin >> d;
		for(int j = 1; j<=d; j++){
			cin >> g;
			a[g].pb(i);
		}
	}

	for(int i = 1; i<=n; i++){
		if(a[i].size()==0)ans++;
	}cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <algorithm>
using namespace std;

int n, p[200200];

int main()
{
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &p[i]);
	sort(p, p + n);
	reverse(p, p + n);

	long long ans = 0;
	for (int i = 1; i < n; i++) ans += p[i / 2];
	printf ("%lld\n", ans);

	return 0;
}

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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    string s, t;
    cin >> s >> t;

    auto dp = make_v(0_im, s.length() + 1, t.length() + 1);

    for (size_t i = 0; i < s.length(); ++i) {
        for (size_t j = 0; j < t.length(); ++j) {
            if (s[i] == t[j]) {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }

    string res = "";
    size_t i = s.length(), j = t.length();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j - 1]) {
            --j;
        } else {
            res = s[i - 1] + res;
            --i, --j;
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 70784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	n := io.NextInt()
	s := make([]int, 0, n+1)
	s = append(s, 0)
	for i := 1; i <= n; i++ {
		ai := io.NextInt()
		s = append(s, ai)
	}
	m := 0
	work := make([]int, n+1)
	ans := make([]int, 0, n)
	for i := n; i >= 1; i-- {
		sum := 0
		for j := 2; i*j <= n; j++ {
			sum += work[i*j]
		}
		if sum%2 == s[i] {
			continue
		} else {
			work[i] = 1
			m++
			ans = append(ans, i)
		}
	}
	io.PrintLn(m)
	if m > 0 {
		io.PrintIntLn(ans)
	}
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int A, B;

int main() {
	cin >> A >> B;
	cout << max({ A * 2 - 1,B * 2 - 1,A + B }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int 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()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  vector<vector<ll>> b(n+1, vector<ll>(20,0));
  REP(i, n){
    REP(j, 20){
      ll mask = 1 << j;
      if(mask & a[i]) b[i+1][j] = b[i][j] + 1;
      else b[i+1][j] = b[i][j];
    }
  }
  ll ans = 0;
  FOR(l, 1, n+1){
    ll ok = l;
    ll ng = n+1;
    while(ok+1!=ng){
      ll r = (ok+ng)/2;
      bool flg = true;
      REP(j, 20){
        if(b[r][j]-b[l-1][j] > 1){
          flg = false;
          break;
        }
      }
      if(flg) ok = r;
      else ng = r;
    }
    ans += ok - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 40832
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
#define N 100005
#define mod 1000000007 
#define bitscount 32

using namespace std;


int  main()
{

int n;

double ans;

scanf("%d",&n);

if(n%2 == 1) {
ans = (double)((n/2)+1) / n;

printf("%.9f\n",ans);
}

else{
ans =(double) ((n/2)) / n;

printf("%.9f\n",ans);
}
return 0;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    unordered_map<char, int> m;
    for (int i = 0; i < S.length(); ++i) {
        if (m.count(S[i]) != 0) m[S[i]] += 1;
        else m[S[i]] = 1;
    }
    if (m.size() == 2) {
        bool istwice = true;
        for (auto & it: m) {
            if (it.second != 2) istwice = false;
        }
        if (istwice) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)


ll a[100],b[100],c[100],d[100],now[100]={1},n,m,q;
ll ans;

void dfs(int k)
{
	if(k==11)
	{
		ll sum=0;
		for(int i=1;i<=q;i++)
		{
			if(now[b[i]]-now[a[i]]==c[i])
			sum+=d[i];
		}
		ans=max(ans,sum);
		return ;
	}
	for(int i=now[k-1];i<=m;i++)
	{
		now[k]=i;
		dfs(k+1);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>q;
	for(int i=1;i<=q;i++)
	cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int mx = 1, X, i, j;
	scanf("%d", &X);
	for (i = 2; i <= X; i++) {
		int v = i*i;
		while (v <= X) {
			mx = max(mx, v);
			v *= i;
		}
	}
	return !printf("%d\n", mx);
}

Measured memory_bytes: 256
n_process, quantum = gets.chomp.split.map(&:to_i)
queue = []
n_process.times{
    name, sec = gets.chomp.split
    queue.push [name, sec.to_i]
}

time = 0
until queue.empty?
    process = queue.shift
    # p process
    if process[1] <= quantum
        # p "?¶???????"
        time += process[1]
        puts "#{process[0]} #{time}"
    else
        # p "?¶??????????"
        time += quantum
        queue.push [process[0], process[1] - quantum]
        # p "?????¨#{process[1] - quantum}"
    end
end

Measured memory_bytes: 19808
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int N; cin >> N;
	vector<string> s(N);
	vector<int> t(N);
	for (int i = 0; i < N; i++) cin >> s[i] >> t[i];
	string X; cin >> X;

	int flag = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (flag == 1) ans += t[i];
		if (s[i] == X) flag = 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        //
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int D = int.Parse(Console.ReadLine());
            int E = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());

            if ((E - A) > K)
            { Console.WriteLine(":("); }
            else
            { Console.WriteLine("Yay!"); }

        }

    }
    
}


Measured memory_bytes: 13140
s = input()

a = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

if s == a[0]:
    print(7)
elif s == a[1]:
    print(6)
elif s == a[2]:
    print(5)
elif s == a[3]:
    print(4)
elif s == a[4]:
    print(3)
elif s == a[5]:
    print(2)
elif s == a[6]:
    print(1)


Measured memory_bytes: 3060
N = input()
A = []
for i in range(len(N)):
    A.append(int(N[i]))

for i in range(2 ** 3):
    List = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            List.append(1)
        elif (i >> j) & 1 == 0:
            List.append(0)
    ans = A[0]
    for k in range(len(List)):
        if (List[k]):
            ans += A[k+1]
        else :
            ans -= A[k+1]

    if ans == 7:
        break

print(A[0], end="")
for i in range(3):
    if List[i]:
        print("+", end="")
    else:
        print("-", end="")
    print(A[i + 1], end="")
print("=7",end="")




Measured memory_bytes: 38256
import math
from collections import defaultdict

N,K = map(int,input().split())
mod = 10**9+7
DP = [0]*(K+1)  #DP[i]:gcd=iとなる数列の個数
ans = 0

for i in range(K,0,-1):
    m = K//i    #m:iの倍数の個数
    DP[i] = pow(m,N,mod)
    for j in range(2,m+1):
        DP[i] -= DP[i*j]
    ans += (DP[i]*i) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 11496
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            int e3 = sc.nextInt();
            int e4 = sc.nextInt();
            
            if(e1==e2&&e3==e4 || e1==e3&&e2==e4 || e1==e4&&e2==e3){
                System.out.println("yes");
            }else{
                System.out.println("no");
            
        }
    }
}

           


Measured memory_bytes: 26312
s = input()
if s == "SUN":
    print(7)
elif s =='MON':
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" " ;
#define pb(x) push_back(x)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e6+5;
int n,a[N];
bool check(){
	for(int i=2;i<=n;++i){
		if(a[i]<a[i-1])return false;
	}
	return true;
}
int main()
{

	cin>>n;
	rep(i,1,n+1){
		cin>>a[i];
	}
	if(check()){
		cout<<"YES";
		return 0; 
	} 
	rep(i,1,n+1){
		rep(j,i+1,n+1){
			swap(a[i],a[j]);
			if(check()){
			
				cout<<"YES";
				return 0; 
			} 
			swap(a[i],a[j]);
			
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


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

int main() {
    string s;
    cin>>s;
    int start = 0, end = s.size()-1;
    int ans = 0;
    while(start<end){
        if(s[start] == s[end]){
            start++;
            end--;
        }
        else {
            if(s[start] == 'x'){
                ans++;
                start++;
            }
            else if(s[end] == 'x'){
                ans++;
                end--;
            }
            else {
                ans = -1;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    long long int N;
    scanf("%lli",&N);
    long long int ans=0;
    for(int i=1;i<=N;i++){
        if(i%3==0)continue;
        if(i%5==0)continue;
        ans+=i;
    }
    printf("%lli\n",ans);
    return 0;
}

Measured memory_bytes: 1732
date0=input()
date0=list(date0)
A=int(date0[len(date0)-1])
if A==2 or A==4 or A==5 or A==7 or A==9:
  print("hon")
elif A==0 or A==1 or A==6 or A==8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
	int N,Q;    
	
	cin >> N >> Q;
	
	char S[N];
	int l[Q],r[Q],t[N];

	cin >> S;

	rep(i,0,N){
		t[i] = 0;
	}

	rep(i,0,N){
		if(S[i]=='A' && S[i+1]=='C'){
			t[i+1] = t[i] + 1;
		}
		else{
			t[i+1] = t[i];		
		}
	}

	rep(i,0,Q){
		cin >> l[i] >> r[i];
	}

	rep(i,0,Q){
		cout << (t[r[i]-1]-t[l[i]-1]) << endl;
	}
}

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

typedef long long LL;

const int N=100;
const int db[6][20]={
{},
{1,2},
{0,0,2},
{0,0,0,4,6},
{0,0,0,0,36,108,220,334,384},
{0,0,0,0,0,976,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001,1001}
};

LL n;

void into(){
  scanf("%lld",&n);
}

int dp[N+9];

void Get_dp(){
  dp[1]=0;
  for (int i=2;i<N;++i)
	for (int j=1;2333;++j)
	  if ((1LL<<j)-i>=dp[j]) {dp[i]=j;break;}
}

int Get_dp(LL n){
  if (n<N) return dp[n];
  for (int i=1;2333;++i)
	if ((1LL<<i)-n>=dp[i]) return i;
  return -1;
}

int Dfs_ans(LL n,LL m){
  if (n<m) swap(n,m);
  if (m<63&&(1LL<<m)-n<n) return Dfs_ans((1LL<<m)-n,m);
  if (m>5) return 1001;
  return m?db[m][n]:1;
}

int ans;

void Get_ans(){
  ans=Dfs_ans(n,(LL)Get_dp(n));
  ans+=n==4;
  ans+=(n==7)<<1;
}

void work(){
  Get_dp();
  Get_ans();
}

void outo(){
  printf("%d\n",ans>1000?-1:ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char s[10];
    int n=0,k=0,i=0;
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);
    for(i=0;i<n;i++){
        if(s[k-1] != s[i]){
            s[i] = '*';
        }
    }
    printf("%s",s);
    return 0;
}


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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int solve(int N, vi& F, vvi& P) {
    int sc_max = 0x80000000;
    rep1(p, 1023){
        int sc = 0;
        rep(n, N){
            int cnt = __builtin_popcount(F[n] & p);
            sc += P[n][cnt];
        }
        sc_max = max(sc_max, sc);
    }
    return sc_max;
}

int main() {
    int N; cin >> N;
    vi F(N, 0);
    vector<int> tmp(10);
    rep(n, N){
        rep(i, 10) cin >> tmp[i];
        for (int i=0,m=1; i<10; ++i,m<<=1){
            if (tmp[i]) F[n] |= m;
        }
    }
    vvi P(N, vi(11));
    rep(n, N){
        rep(i, 11) cin >> P[n][i];
    }
    cout << solve(N,F,P) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long N,i,a;
    cin>>N;
    for(i=0;i<N;i++){
        cin>>a;
        if(a%2==1){
            cout<<"first"<<endl;
            return 0;
        }
    }
    cout<<"second"<<endl;
}

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

typedef long long ll;

int main() {
    int N, D, A; cin >> N >> D >> A;
    vector<pair<int, int> > M(N);
    for (int i = 0; i < N; i++) {
        cin >> M[i].first;
        cin >> M[i].second;
    }
    sort(M.begin(), M.end());
    vector<int> inreach(N);
    
    ll dis = 0; 
    int rig = 0;
    for (int i = 0; i < N; i++) {
        if (i > rig) {
            rig = i; dis = 0;
        }
        while (true) {
            if (rig == N-1) {
                inreach[i] = N-1;
                break;
            } else if (dis + (M[rig+1].first - M[rig].first) > 2 * D){
                inreach[i] = rig;
                dis -= M[i+1].first - M[i].first;
                break;
            } else {
                dis += M[rig+1].first - M[rig].first;
                rig++;
            }
        }
    }

    vector<ll> imos(N+1, 0);
    ll dmg = 0; ll ans = 0;
    for (int i = 0; i < N; i++) {
        dmg += imos[i];
        if (M[i].second > dmg) {
            ll ad = ((A-1) + (M[i].second - dmg)) / A;
            ans += ad;
            dmg += ad * A;
            imos[inreach[i]+1] -= ad * A;
        }
    }
    cout << ans << endl;

}

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

int main()
{
	int N,M;
	int a,b;
	int ans[200010]={};
	
	cin >> N >> M;
	for(int i=0;i<M;i++)
	{
		cin >> a >> b;
		if(a==1 && b!=N)ans[b]++;
		else if(a!=1 && b==N)ans[a]++;
	}
	
	for(int i=2;i<=N-1;i++)
	{
		if(ans[i]>1)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A >= 13) {
    cout << B << endl;
  } else if (6 <= A && A <= 12) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){

    int H,W,h,w;
    cin>>H;
    cin>>W;
    cin>>h;
    cin>>w;

    int ans;
    ans=H*W-h*W-H*w+h*w;

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

Measured memory_bytes: 256
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    ans = []
    ans.append(s[0:4])
    ans.append(' ')
    ans.append(s[4:12])
    print(''.join(ans))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 998244353
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
ll a[100002],b[100002];
void solve()
{
	ll n,sum=0,cnt=0;
	cin >> n;
	for (int i = 0; i < n + 1; i++)
	{
		cin >> a[i];
		sum = sum + a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= b[i])
		{
			a[i] = a[i] - b[i];
			b[i] = 0;
		}
		else
		{
			b[i] = b[i] - a[i];
			a[i] = 0;
		}
		if (a[i + 1] >= b[i])
		{
			a[i + 1] = a[i + 1] - b[i];
			b[i] = 0;
		}
		else
		{
			b[i] = b[i] - a[i + 1];
			a[i + 1] = 0;
		}
	}
	for (int i = 0; i < n+1; i++)
	{
		cnt = cnt + a[i];
	}
	cout << sum - cnt;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,t; cin>>x>>t;
    cout<<max(0,x-t)<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
csf = []
for i in range(n-1):
    csf.append(list(map(int,input().split())))

for i in range(n):
    ans = 0
    while i<=n-2:        
        c = csf[i][0]
        s = csf[i][1]
        f = csf[i][2]
        ans = max(s,math.ceil(ans/f)*f)+c
        i+=1
    print(ans)

Measured memory_bytes: 43116
#include <stdio.h>

int main()
{
	int i, A, B, Q;
	long long s[100002], t[100002], x[100001];
	scanf("%d %d %d", &A, &B, &Q);
	for (i = 1; i <= A; i++) scanf("%lld", &(s[i]));
	for (i = 1; i <= B; i++) scanf("%lld", &(t[i]));
	for (i = 1; i <= Q; i++) scanf("%lld", &(x[i]));
	s[A+1] = (long long)1 << 60;
	s[0] = -s[A+1];
	t[B+1] = s[A+1];
	t[0] = -s[A+1];
	
	int l[2], r[2], m;
	long long ans;
	for (i = 1; i <= Q; i++) {
		l[0] = 0;
		r[0] = A + 1;
		while (r[0] - l[0] > 1) {
			m = (r[0] + l[0]) / 2;
			if (s[m] < x[i]) l[0] = m;
			else r[0] = m;
		}
		
		l[1] = 0;
		r[1] = B + 1;
		while (r[1] - l[1] > 1) {
			m = (r[1] + l[1]) / 2;
			if (t[m] < x[i]) l[1] = m;
			else r[1] = m;
		}
		
		ans = x[i] - ((s[l[0]] < t[l[1]])? s[l[0]]: t[l[1]]);
		if (((s[r[0]] < t[r[1]])? t[r[1]]: s[r[0]]) - x[i] < ans) ans = ((s[r[0]] < t[r[1]])? t[r[1]]: s[r[0]]) - x[i];
		if (s[r[0]] - t[l[1]] + s[r[0]] - x[i] < ans) ans = s[r[0]] - t[l[1]] + s[r[0]] - x[i];
		if (s[r[0]] - t[l[1]] + x[i] - t[l[1]] < ans) ans = s[r[0]] - t[l[1]] + x[i] - t[l[1]];
		if (t[r[1]] - s[l[0]] + t[r[1]] - x[i] < ans) ans = t[r[1]] - s[l[0]] + t[r[1]] - x[i];
		if (t[r[1]] - s[l[0]] + x[i] - s[l[0]] < ans) ans = t[r[1]] - s[l[0]] + x[i] - s[l[0]];
		printf("%lld\n", ans);
	}
	fflush(stdout);
	return 0;
}

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


vector<ll> a,b,c,d;
ll n,m,q;

ll dfs(vector<ll> &A){
    if(A.size()==n){//score計算(一組のAに対する)
        ll num=0;
        for(ll i=0;i<q;i++){
            if(A[b[i]]-A[a[i]]==c[i]){num+=d[i];}
        }
        return num;
    }

    ll ans=0;
    ll last=(A.empty()?0:A.back());//要素がなければ追加

    for(ll i=last;i<m;i++){//次の桁は前の桁以上の数なのでlast=A.back()からstart
        A.push_back(i);
        ans=max(ans,dfs(A));
        A.pop_back();
    }
    
    return ans;
}

int main(){
    cin>>n>>m>>q;
    vector<ll> A;
    
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);

    for(ll i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }

    cout<<dfs(A)<<endl;
    return 0;
}

Measured memory_bytes: 3616
import itertools

N = input()
count = 0
list = ["3", "5", "7"]

for i in range(3, len(N)):
    # print(3**i - (2**i) * 3)
    count += 3**i - (2**i) * 3 + 3
# print(count)
for i in itertools.product(list, repeat=len(N)):
    if int("".join(i)) <= int(N):
        if "3" in i and "5" in i and "7" in i:
            # print("".join(i))
            count += 1
print(count)

Measured memory_bytes: 41580
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	string sentence;
	cin >> sentence;
	vector<int> DP(sentence.size() + 1, 0);
	vector<string> word = {"dream", "dreamer", "erase", "eraser"};

	DP[0] = 1;
	for (int i = 0; i < sentence.size(); i++)
	{
		if (DP[i] == 1)
			for (int j = 0; j < 4; j++)
			{
				if (sentence.size() < i + word[j].size())
					continue;

				if (!sentence.compare(i, word[j].size(), word[j]))
					DP[i + word[j].size()] = 1;
			}
	}

	cout << (DP[sentence.size()] ? "YES" : "NO") << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 848
#include <stdio.h>
#include <iostream>
#define M 20
#define N 50000
#define INF 100000000
using namespace std;

int DP[M + 1][N + 1];

int main(void){
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);

    int C[M + 1];
    for(int i = 1; i <= m; i++){
        scanf("%d", &C[i]);
    }

    for(int j = 1; j <= n; j++){
        DP[0][j] = INF;
    }

    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(j - C[i] == 0){
                DP[i][j] = 1;
            }else if(j - C[i] > 0){
                DP[i][j] = min(DP[i][j - C[i]] + 1, DP[i - 1][j]);
            }else{
                DP[i][j] = DP[i - 1][j];
            }
            //printf("DP[%d][%d]: %d\n", i, j, DP[i][j]);
        }
    }

    for(int i = 1; i <= n; i++){
        //printf("%d\n", DP[1][i]);
    }

    printf("%d\n", DP[m][n]);

}



Measured memory_bytes: 7280
#include <iostream>
 
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int in[2];
  std::cin >> in[0];
  std::cin >> in[1];
  in[0] += in[1];
  std::cin >> in[1];
  in[0] += in[1];
  if(in[0] > 21) std::cout << "bust" << "\n";
  else std::cout << "win" << "\n";
  return 0;
}

Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int a[N];
void solve(){
  int n,x=0;cin>>n;
  rep(i,1,n)cin>>a[i],x^=a[i];
  rep(i,1,n)cout<<(x^a[i])<<" ";
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

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

using namespace std;

void Shuffle(int , string&);


int main()
{
	while(1){
		string s;
		cin >> s;
		if (s == "-")
			break;

		int n;
		cin >> n;
		for (int i = 0; i < n; i++){
			int h;
			cin >> h;
			Shuffle(h, s);
		}

		cout << s << endl;
	}

	return 0;
}

void Shuffle(int h, string& s)
{
	string strLeft = s.substr(0, h);
	string strRight = s.substr(h, s.length() - h);
	s = strRight + strLeft;
}



Measured memory_bytes: 3156