akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 07.07.2020 14:48:26
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// Template for ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;
mint fac[MAX], finv[MAX], inv[MAX];

// Combination Table
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep2(i,2,MAX){
        fac[i] = fac[i-1] * (mint)i;
        inv[i] = (mint)MOD - inv[MOD%i] * (mint)(MOD/i);
        finv[i] = finv[i-1] * inv[i];
    }
}

// nCk
mint COM(int n,int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
}

// nPk
mint PER(int n, int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] / fac[n-k];
}

signed main() {

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

    int n, m; cin >> n >> m;
    if (abs(n-m) >= 2) {
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    mint ans = 1;
    if (n != m) {
        ans *= fac[n] * fac[m];
        cout << ans << endl;
        return 0;
    }
    else {
        ans *= fac[n] * fac[n] * 2;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 27040
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#define mm(i,v) memset(i,v,sizeof i);
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
int a[maxn];
char s[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>s;
	int cnt=0;
	int len=strlen(s);
	for(int i=0;i<len;i++)
		a[i]=s[i]-'0';
//	for(int i=0;i<len;i++)
//		cout<<a[i];
//	cout<<"\n";
	for(int i=1;i<len;i++){
		if(a[i]==a[i-1]){
			cnt++;
//			cout<<i<<endl;
			a[i]^=1;
		}
	}

	cout<<cnt<<"\n";
	
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int l,r,d,ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++)
	  if(i%d==0)ans++;
	cout<<ans<<endl;
	return 0;
}

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

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 5e5 + 5;
const int logn = log2(maxn) + 1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    int n;ll k;
    cin >> n >> k;
    vector<ii> a(n);
    for(auto & c : a)cin >> c.first >> c.second;
    sort(a.begin(),a.end());
    for(auto & c : a){
        k -= c.second;
        if(k <= 0)return cout << c.first , 0;
    }
    cout << endl;
}


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


int main(){
  string s;
  cin >>s;
  int n = s.size();
  int ans = 110, ans_temp, left;
  string letter = "abcdefghijklmnopqrstuvwxyz";
  
  rep(j, n){
    left = -1, ans_temp = -1;
    rep(i, n){
      if(s.at(i) == s.at(j)){
        ans_temp= max(abs(i-left-1), ans_temp);
        left = i;
      }
    }
      ans_temp=max(ans_temp, n-1-left);
      ans=min(ans, ans_temp);
    }
    cout << ans;
  }



Measured memory_bytes: 3604
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
ac = Counter(v[::2]).most_common(2)
bc = Counter(v[1::2]).most_common(2)



if ac[0][0] != bc[0][0]:           
    ans =  n - ac[0][1] - bc[0][1] 
else:                               
    if len(bc) == 1 or len(ac) == 1:
        ans = n // 2
    else: 
        ans = n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])
print(ans)

Measured memory_bytes: 15588
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

const int MAXN = 5e3 + 10, INF = 1e9;

int n, n1, n2;
int a[MAXN << 2], b[MAXN << 2];
char s[MAXN], t[MAXN];

int main() {
	scanf("%d %s %s", &n, s + 1, t + 1);
	for (int i = 1; i < n; ++i) if (s[i] != s[i + 1]) a[(++n1) + n + 20] = i;
	for (int i = 1; i < n; ++i) if (t[i] != t[i + 1]) b[(++n2) + n + 20] = i;
	for (int i = 1; i <= n + 20; ++i) a[n1 + n + 20 + i] = b[n2 + n + 20 + i] = n;
	int ans = INF;
	for (int i = -n1 - 2; i <= n2 + 2; ++i) if ((i & 1) != (s[1] == t[1])) {
		int now = 0;
		for (int j = std::min(0, -i) + n; j <= std::max(n1, -i + n2 + 1) + n + 30; ++j) now += abs(a[j] - b[i + j]);
		ans = std::min(ans, now);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){int p=0;
int N;
cin >> N;
int M;
cin >> M;
vector<int> s(M+1,0);
vector<int> c(M+1,0);
for(int i=0;i<M;i++){
    cin>>s.at(i)>>c.at(i)
;}
vector<int> ans(N+1,0);
if(N>1){ans.at(0)=1;}
vector<bool> vec(N+1,0);
for(int i=0;i<M;i++){
    int j=s.at(i)-1;
  if(vec.at(j)==1&&ans.at(j)!=c.at(i)){cout<<-1<<endl;p++;
  break;}
  else {ans.at(j)=c.at(i);vec.at(j)=1;}
;}

if(p==0){if(ans.at(0)==0&&N>1){cout<<-1<<endl;}
 else{ for(int i=0;i<N;i++){cout<<ans.at(i)
;}cout<<endl;}}
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import deque

n,q=map(int,input().split())
que = deque()
for _ in range(n):
    x,y = input().split()
    que.append([x,int(y)])
time=0
while len(que)!=0:
    x,y=que.popleft()
    if y<=q:
        time+=y
        print(x,time)
    else:
        y-=q
        que.append([x,y])
        time+=q




Measured memory_bytes: 13324
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
int main() {                                                                                          
  ll n;                                                                                               
  int k;                                                                                              
  cin >> n >> k;                                                                                      
  ll digits = 0;                                                                                      
  while (n > 0) {                                                                                     
    digits++;                                                                                         
    n /= k;                                                                                           
  }                                                                                                   
  cout << digits << endl;                                                                             
  return 0;                                                                                           
}   

Measured memory_bytes: 256
N,X = input().split()
n = int(N)
x = int(X)

lis = []
lis = input().split()
list = [int(item) for item in lis]
list.sort()
num = len(list)
count = 0
for l in range(num):
    x = x - list[l]
    count += 1
    if x <= 0:
        break

if x==0:
    print(count)
else:
    print(count-1)


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

int gcd(int x, int y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

int main(){
    int n; cin >> n;
    vector<int> a(n+2);
    a.at(0) = 0; a.at(n+1) = 0;
    vector<int> l(n+1), r(n+2);
    for(int i = 1; i <= n; i++){
        cin >> a.at(i);
    }
    for(int i = 1; i <= n; i++) l.at(i) = gcd(l.at(i-1), a.at(i));
    for(int i = n; i >= 1; i--) r.at(i) = gcd(r.at(i+1), a.at(i));
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, gcd(l.at(i-1), r.at(i+1)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n,k;
	int a[100001];
	while(cin >> n >> k, n){
		int ans = 0;
		rep(i,n){
			cin>>a[i];
		}
		rep(i,k)ans += a[i];
		int sum = 0;
		int tmp = ans;
		for(int i = k; i < n; i++){
			sum = tmp;
			sum -= a[i-k];
			sum += a[i];
			ans = max(ans,sum);
			tmp = sum;
		}
		FIN(ans);
	}

	return 0;
}

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

#define ll long long int

int felicidad[100005][3];
ll memo[100005][3];
int N;

ll maxFeliz(int dia, int act){
	if(!dia) return felicidad[0][act];
	if(memo[dia][act]) return memo[dia][act];
	return memo[dia][act] = felicidad[dia][act]+
					max(maxFeliz(dia-1, (act+1)%3),
						maxFeliz(dia-1, (act+2)%3));
}

int main() {
	cin>>N;
	for(int i = 0; i<N; i++)
		cin>>felicidad[i][0]>>felicidad[i][1]>>felicidad[i][2];
	cout<<max(maxFeliz(N-1,0), max(maxFeliz(N-1,1), maxFeliz(N-1,2)))<<"\n";
	return 0;
}

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

#define pb push_back
#define pob pop_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
const ll Inf = 1e18;
const ll mod = 1e9 + 7;

void solve(){
	int n,x;
	cin>>n>>x;
	int D[n+2],L[n+1];
	for(int i=1;i<=n;i++){
		cin>>L[i];
	}
	D[1] = 0;
	int ans=1;
	for(int i=2;i<=n+1;i++){
		D[i] = D[i-1] + L[i-1];
		if(D[i]<=x) ans++;
	}
	cout<<ans;
}

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


Measured memory_bytes: 256
let () = 
    let (s, h, c, d) = (0, 1, 2, 3) in
    let arr = Array.make_matrix 4 13 false in
    let n = read_int () in
    for _ = 1 to n do 
        let (a, j) = Scanf.scanf "%c %d\n" (fun x y -> (x, y - 1)) in
	match a with
            | 'S' -> arr.(s).(j) <- true
            | 'H' -> arr.(h).(j) <- true
            | 'C' -> arr.(c).(j) <- true
            | 'D' -> arr.(d).(j) <- true
            | _   -> ()
    done;
    let f c = Array.iteri (fun i v -> if not v then Printf.printf "%c %d\n" c (i + 1) ); in
    f 'S' arr.(s);
    f 'H' arr.(h);
    f 'C' arr.(c);
    f 'D' arr.(d);
;;


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

using ll = long long;
using ld = long double;

int main()
{
    string s;
    cin >> s;
    if(s.at(1) == s.at(2) && 
        (s.at(0) == s.at(1) || s.at(2)==s.at(3)))
    {
        cout << "Yes"<< endl;
    }
    else 
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    N, M, K = (int(i) for i in input().split())
    for n in range(N+1):
        for m in range(M+1):
            if m * (N - n) + (M - m) * n == K:
                return print("Yes")
    print("No")

if __name__ == '__main__':
    main()

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

int main()
{
    // input
    int n;
    string s;
    cin >> n >> s;

    // solve
    vector<vector<bool>> list (3, vector<bool>(10));
    rep(i,3)rep(j,10) list[i][j] = false;

    int cnt = 0;
    for(int a=0; a<n-2; a++){
        if(list[0][s[a]-'0']) continue;

        for(int b=a+1; b<n-1; b++){
            if(list[1][s[b]-'0']) continue;

            for(int c=b+1; c<n; c++){
                if(list[2][s[c]-'0']) continue;

                cnt++;
                list[2][s[c]-'0'] = true;
            }
            list[1][s[b]-'0'] = true;
            rep(j,10) list[2][j] = false;
        }
        list[0][s[a]-'0'] = true;
        rep(j,10) list[1][j] = false;
    }

    cout << cnt << endl;
    return 0;
}

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

const ll MAX = 200000+5;
const ll MOD = 1000000007;
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;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N,M,K;
	cin>>N>>M>>K;
    ll S = N*M;
    COMinit();
    
    ll ans = 0;
    rep(i,N-1){
        ans += (((N-(i+1))*(i+1)*(M*M%MOD))%MOD*COM(S-2,K-2))%MOD;
        ans%=MOD;
    }
	rep(i,M-1){
        ans += (((M-(i+1))*(i+1)*(N*N%MOD))%MOD*COM(S-2,K-2))%MOD;
        ans%=MOD;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4992
import numpy as np
n, k = map(int, input().split())
aa = list(map(np.int64, input().split()))
aa = np.array(aa)

def mul(dd):
    mod = 10**9+7
    ret = 1
    for d in dd:
        ret = (ret*d)%mod
    return ret

def sol(aa, n, k):
    mod = 10**9+7
    aap = aa[aa>0]
    aam = aa[aa<0]
    if n == k:
        return mul(aa)
    if len(aap) + 2*(len(aam)//2) < k:
        return 0

    # マイナスのみ
    if len(aam) == n:
        aam.sort()
        if k%2==1:
            return mul(aam[-k:])
        else:
            return mul(aam[:k])

    aap = aa[aa>=0]
    aap.sort()
    aap = aap[::-1]
    aam.sort()

    ret=1
    if k%2 >0:
        k = k-1
        ret *= aap[0]
        aap = aap[1:]

    aap2 = [aap[2*i]*aap[2*i+1] for i in range(len(aap)//2)]
    aam2 = [aam[2*i]*aam[2*i+1] for i in range(len(aam)//2)]
    aap2.extend(aam2)
    aap2.sort(reverse=True)
    aap2 = [i%mod for i in aap2]
    return (ret*mul(aap2[:k//2]))%mod
print(sol(aa, n, k))



Measured memory_bytes: 59724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int N;cin>>N;
    int sum=0;
    int a[N];
    rep(i,N){cin>>a[i];sum+=a[i];}
    int cand1 = ceil((double)sum/N);
    int cand2 = sum/N;
    ll r1=0,r2=0;
    rep(i,N){
        r1+=(cand1-a[i])*(cand1-a[i]);
        r2+=(cand2-a[i])*(cand2-a[i]);
    }
    co(min(r1, r2));
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

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

    int cnt=0;
    rep(i,n){
        if(s[i]=='R'){
            cnt++;
        }
    }

    if(s.size()-cnt<cnt){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


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

using namespace std;

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

    int n; cin>>n; n%=26;

    cin.ignore();
    string s; getline(cin,s);

    char z[s.size()];
    strcpy(z,s.c_str());

    for(size_t i=0;i<s.size();i++){
        for(int j=0;j<n;j++){
            z[i]++;
            if(z[i]>'Z')z[i]='A';
        }
    }

    for(size_t i=0;i<s.size();i++)
        cout<<z[i];
}


Measured memory_bytes: 256
h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    A, B = map(int, input().split())
    a[i] = A
    b[i] = B

ans = [-1] * (h + 1)
ans[0] = 0

for i in range(h):
    if (ans[i] >= 0):
        for j in range(n):
            next = min(h, i + a[j])
            if ans[next] < 0:
                ans[next] = ans[i] + b[j]
            else:
                ans[next] = min(ans[next], ans[i] + b[j])

print(ans[h])

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

using namespace std;

struct team {
    int id, ct, wa[10], pen;
    bool ac[10];
    team(int i=0) : id(i), ct(0), pen(0)
    {
        fill(ac, ac+10, false);
        fill(wa, wa+10, 0);
    }

    void accept(int pid, int time)
    {
        if(!ac[pid-1])
        {
            ac[pid-1] = true;
            ct++;
            pen += time + 1200 * wa[pid-1];
        }
    }
    void wrong(int pid)
    {
        wa[pid-1]++;
    }
};

bool operator<(const team& a, const team& b)
{
    if(a.ct==b.ct)
    {
        if(a.pen==b.pen)
        {
            return a.id<b.id;
        }
        return a.pen<b.pen;
    }
    return a.ct>b.ct;
}

int main()
{
    int t, p, r;
    while(cin >> t >> p >> r, t|p|r)
    {
        team ts[t];
        for(int i=0; i<t; i++)
        {
            ts[i] = team(i+1);
        }
        for(int i=0; i<r; i++)
        {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if(msg=="CORRECT")
            {
                ts[tid-1].accept(pid, time);
            }
            else
            {
                ts[tid-1].wrong(pid);
            }
        }
        sort(ts, ts+t);
        for(team *itr=ts; itr!=ts+t; itr++)
        {
            cout << itr->id << " " << itr->ct << " " << itr->pen << endl;
        }

    }
}

Measured memory_bytes: 3184
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  ll X=A1-B1;
  ll Y=A2-B2;
  if(X<0){
    X=-X;
    Y=-Y;
  }
  ll P=X*T1;
  ll Q=Y*T2;
  if(P+Q==0) cout<<"infinity"<<endl;
  else if(P+Q>0) cout<<0<<endl;
  else{
    ll R=P/(-P-Q);
    if(P==R*(-P-Q)) cout<<2*R<<endl;
    else cout<<2*R+1<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
#define int ll

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"

const int N = 2e5 + 5;
const int oo = 1e16 + 5ll;

int n, ans;

int f(int x) {
    // (n * (n + 1)) / 2 = x
    // n * (n + 1) = x * 2
    int res = sqrtl(x * 2) - 1;
    int nice = res - 2;
    for (int i = res; i <= res + 3; ++i) {
        if ((i * (i + 1)) / 2 <= x) { nice = i; }
    }
    return nice;
}

void solve() {
    cin >> n;
    int nn = n;
    for (int i = 2; i * i <= nn; ++i) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            ++cnt;
        }
        ans += f(cnt);
    }
    if (n > 1) {
        ans += 1;
    }
    cout << ans;
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3684
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	int x, y; cin >> x >> y;
	int mx1 = x + y, mn1 = x + y;
	int mx2 = x - y, mn2 = x - y;
	while (--n) {
		cin >> x >> y;
		mx1 = max(mx1, x + y);
		mn1 = min(mn1, x + y);
		mx2 = max(mx2, x - y);
		mn2 = min(mn2, x - y);
	}
	cout << max(mx1 - mn1, mx2 - mn2) << '\n';
	return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int mod = 1000000007;
  long long sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
    sum %= mod;
  }

  long ans = 0;

  for(int j = 0; j < n; j++){
    sum -= a[j];
    if(sum < 0) sum += mod;
    ans += a[j] * sum;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;

const ll mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<vector<int>> d(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    d[a].push_back(b);
    d[b].push_back(a);
  }
  int ans = 0;
  rep(i, n){
    if (d[i].size()){
      bool ok = true;
      rep(j, d[i].size()) if (h[i] <= h[d[i][j]]) ok = false;
      if (ok) ans++;
    } else {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8736
#include <stdio.h>
#include <math.h>

int main(void){
  int i,j,k,n,tmp;
  int l[3];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&l[0],&l[1],&l[2]);
    for(j=0;j<3;j++){
      for(k=0;k<2;k++){
	if(l[k]<l[k+1]){
	  tmp=l[k];
	  l[k]=l[k+1];
	  l[k+1]=tmp;
	}
      }
    }
    if(pow(l[0],2)==pow(l[1],2)+pow(l[2],2)){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }  

  return 0;
}

Measured memory_bytes: 580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CFennecVsMonster solver = new CFennecVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class CFennecVsMonster {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int n = s.nextInt(), k = s.nextInt();
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = s.nextInt();
            Arrays.sort(a);
            long res = 0;
            for (int i = 0; i < n - k; i++) {
                res += a[i];
            }
            w.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int N = 2e3 + 10;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;

int n, m;

LL x, k, d;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> x >> k >> d)
    {
        if (x < 0) x = -x;

        LL c = x / d;

        if (k <= c)
        {
            cout << x - k * d << endl;
            continue;
        }

        k -= c;
        x -= c * d;

        LL ans;

        LL v1 = x;
        LL v2 = abs(x - d);
        if (k % 2 == 1)
            ans = v2;
        else
            ans = v1;

        cout << ans << endl;
    }
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <math.h>

using namespace std;

int main() {
	double x1, x2, x3, y1, y2, y3, xp, yp;
	double calc1, calc2, calc3;

	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
		calc1 = (x2 - x1) * (yp - y1) - (y2 - y1) * (xp - x1);
		calc2 = (x3 - x2) * (yp - y2) - (y3 - y2) * (xp - x2);
		calc3 = (x1 - x3) * (yp - y3) - (y1 - y3) * (xp - x3);

		if ((calc1 > 0 && calc2 > 0 && calc3 > 0) || (calc1 < 0 && calc2 < 0 && calc3 < 0)) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(string,b);
	REP(i,b.size()){
		switch(b[i]){
		case 'A':
			OUT('T')BR;
			break;
		case 'C':
			OUT('G')BR;
			break;
		case 'G':
			OUT('C')BR;
			break;
		case 'T':
			OUT('A')BR;
			break;
		}
	}
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int A,B;
  cin>>A>>B;
  int max = A+B;
  if(A*B > max)
    max = A*B;
  if(A-B > max)
    max = A - B;
  cout<<max;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//Sort(v);
//v.erase(unique(all(v)),v.end());
//It keeps unique elements in sorted order....
//#define int long long int
void solve(){
	ll x;
	cin>>x;
	ll comp=x/500;
	ll rem=x%500;
	ll sum=comp*1000;
	cout<<sum+((rem/5)*5)<<endl;
 
 
}
 
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
   ll l,r,ans = 2020;
   cin >> l >>r;
   if(r-l>=2019)return cout << 0,0;
   for(ll j=l;j<=r;j++){
     for(ll i=l;i<j;i++)
       ans = min(ans,(i*j)%2019);
     
   }
   cout << ans;
 }
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll A,B,C,D;

ll func(ll A,ll B,ll X){
    return B/X - (A-1)/X;
}

int main(){
    cin >> A >> B >> C >> D;
    ll kosu = B-A+1;
    ll ans = kosu - func(A,B,C) - func(A,B,D) + func(A,B,lcm(C,D));
    pr(ans);
}
    

Measured memory_bytes: 256
def calc(lhs, op, rhs)
  if op == '+'
    lhs + rhs
  else
    lhs - rhs
  end
end

def main
  nums = ARGF.gets.chars.map(&:to_i)

  ['+', '-'].each do |op1|
    ['+', '-'].each do |op2|
      ['+', '-'].each do |op3|
        a = calc(nums[0], op1, nums[1])
        a = calc(a, op2, nums[2])
        a = calc(a, op3, nums[3])

        if a == 7
          puts "#{nums[0]}#{op1}#{nums[1]}#{op2}#{nums[2]}#{op3}#{nums[3]}=7"
          return
        end
      end
    end
  end

  puts 'error'  # 問題の前提上、ありえない
end

if __FILE__ == $0
  main
end


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

int main () {
  string s;
  cin >> s;
  int A_num, Z_num;

  for (int i = 0; i < s.length(); i++){
    if(s[i] == 'A'){
      A_num = i;
      break;
    }
  }
  for (int i = 0; i < s.length(); i++){
    if(s[i] == 'Z'){
      Z_num = i;
    }
  }
    
  cout << Z_num - A_num + 1 << endl; 
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long

const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>

#define N 100
#define BLACK 0
#define WHITE 1
#define INF 100000000
#define NIL -1

void dijkstra(void);

int A[N][N],n;

int main()
{
  int u,k,v,c;

  scanf("%d",&n);

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

  for(int i = 0;i < n; i++)
  {
    scanf("%d%d",&u,&k);
    for(int j = 0; j < k; j++)
    {
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra()
{

  int u,mincost;
  int d[N],pi[N],color[N];

  for(int u = 0; u < n; u++)
  {
    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1)
  {
    mincost = INF;
    for(int i = 0; i < n; i++)
    {
      if(color[i] != BLACK && d[i] < mincost)
      {
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INF) break;

    color[u] = BLACK;

    for(int v = 0; v < n; v++)
    {
      if(color[v] != BLACK && A[u][v] + d[u] < d[v] && A[u][v] != -1){
        pi[v] = u;
        d[v] = A[u][v] +d[u];
      }
    }

  }
  for(u = 0; u < n; u++)
  {
    printf("%d %d\n",u,d[u]);
  }

}



Measured memory_bytes: 2732
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;

int main()
{
	int64_t a, b, c, d, e, f, g;
	scanf("%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64, &a, &b, &c, &d, &e, &f, &g);

	int64_t r = b;
	r += (a / 2) * 2;
	r += (d / 2) * 2;
	r += (e / 2) * 2;
	if (a % 2 == 1 && d % 2 == 1 && e % 2 == 1) {
		r += 3;
	} else if (a % 2 == 1 && d % 2 == 1 && e > 0) {
		r += 1;
	} else if (d % 2 == 1 && e % 2 == 1 && a > 0) {
		r += 1;
	} else if (a % 2 == 1 && e % 2 == 1 && d > 0) {
		r += 1;
	}

	printf("%" PRId64 "\n", r);

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	unsigned int a;
	unsigned int b;
	unsigned int c;
	

	scanf("%d %d %d", &a, &b, &c);
	if(a < b && b < c)
	{
			printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

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

#define MAX(a,b) ((a) > (b)) ? (a) : (b)
#define MIN(a,b) ((a) < (b)) ? (a) : (b)

using namespace std;

int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int x = 0;
	int max_x = 0;
	for (int i = 0; i < n; i++)
	{
		x += (s.at(i) == 'I') ? 1 : -1;
		max_x = MAX(x, max_x);
	}
	cout << max_x;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {                                                                
    char *name[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Fr\
iday", "Saturday"};                                                             
    int day_month[] = {0, 3, -1, 0, 3, 5, 1, 3, -1, 2, 4, 0, 2};                
    int day, month;                                                             
                                                                                
    while (scanf("%d %d", &month, &day), month) {                               
        int d = (day + day_month[month]) % 7;                                   
        printf("%s\n", name[d]);                                                
    }                                                                           
                                                                                
    return 0;                                                                   
}

Measured memory_bytes: 584
def main():
    S = input()#|S| = odd
    N = len(S)
    T = [s for s in S]
    T1 = ''.join(reversed(T[:(N-1)//2]))
    T2 = ''.join(reversed(T[(N+3)//2-1:]))
    if S != ''.join(reversed(T)):print('No');exit()
    elif S[:(N-1)//2] != T1:print("No");exit()
    elif S[(N+3)//2-1:] != T2:print('No');exit()
    print('Yes')
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def min2(x,y):
    return x if x < y else y

N = int(input())
P = make_divisors(N)
L = len(P) + 1
res =float("inf")

for p in P:
    res = min2((p - 1) + (N // p - 1), res)

print(res)

Measured memory_bytes: 67008
N,K=map(int,input().split())
A=list(map(int,input().split()))

for i in range(min(49,K)):
    B = [0 for _ in range(N)]
    for j in range(N):
        l=max(0,j-A[j])
        r=min(N-1,j+A[j])
        B[l]=B[l]+1
        if r+1<N:
            B[r+1]=B[r+1]-1
    for j in range(N-1):
        B[j+1]=B[j+1]+B[j]
    #print(B)
    A=[]
    A=B
    #input()
print(*B)



Measured memory_bytes: 170872
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    VVI cost(n, VI(n, 0));
    ll ans = 0;
    rep(i, n) rep(j, n) cin >> cost[i][j];
    rep(i, n) rep(j, i + 1, n)
    {
        ans += min(cost[i][j], cost[j][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3244
// cout << "Case #" << k << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<ll> ans;
void dfs(int k, string s) {
    if(s.size() == k) {
        ans.push_back(stoll(s));
        return;
    } else {
        int m = s.back() - '0';
        if(m - 1 >= 0) {
            dfs(k, s + to_string(m - 1));
        }
        dfs(k, s + to_string(m));
        if(m + 1 <= 9) {
            dfs(k, s + to_string(m + 1));
        }
    }
}
int main() {
    ll k;
    cin >> k;
    for(int i = 1; i < 11; i++) {
        dfs(i, "1");
        dfs(i, "2");
        dfs(i, "3");
        dfs(i, "4");
        dfs(i, "5");
        dfs(i, "6");
        dfs(i, "7");
        dfs(i, "8");
        dfs(i, "9");
    }
    sort(all(ans));
    cout << ans[k - 1] << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <set>
#include <array>
#include <list>
#include <string>
#include <algorithm>
#include <queue>
#include <numeric>
#include <random>
#include <iomanip>
#include <chrono>

using namespace std;


int main() {

	size_t k, n;
	cin >> n >> k;

	vector<unsigned long long int> vec(n);

	for (auto& v : vec)
	{
		cin >> v;
	}

	vector<unsigned long long int> vecAdd(n + 1);
	vecAdd[0] = 0;
	for (size_t i = 1; i < vecAdd.size(); i++)
	{
		vecAdd[i] = vecAdd[i - 1] + vec[i - 1];
	}

	long double maxVal = 0;
	for (size_t i = 0; i < vecAdd.size() - k; i++)
	{
		const long double add = (vecAdd[i + k] - vecAdd[i] + k) / 2.0;
		maxVal = max(add, maxVal);
	}

	cout << fixed << maxVal << endl;

	return 0;
}


Measured memory_bytes: 3328
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N = int(input())
    act = np.array([[int(item) for item in input().split()] for _ in range(N)])

    dp = np.zeros((2, 3), dtype='int64')
    selector = np.array([[0,1,1], [1,0,1], [1,1,0]])

    for i in range(0,N):
        # print(dp[i%2]*selector)
        # print(np.max(dp[i%2]*selector, axis=1))
        dp[i%2^1] = np.max(dp[i%2]*selector, axis=1) + act[i]
        # print(dp)

    print(max(dp[N%2]))

main()

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

const int N = 3005;
const int MOD = 998244353;

int n, s;
int a[N];

int dp[N][N];
int f(int s, int x) {
  if (s < 0) return 0;
  if (x == n) return s == 0;
  if (~dp[s][x]) return dp[s][x];

  return dp[s][x] = (2LL * f(s, x+1) + f(s-a[x], x+1)) % MOD;
}

int solve() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }

  memset(dp, -1, sizeof dp);

  printf("%d\n", f(s, 0));
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 39292
N=int(input())
cnt=0
l=[tuple(map(int,input().split())) for _ in range(N-1)]
for s in range(N-1):
  cnt=0
  for t in range(s,N-1):
    if not cnt:
      cnt=l[t][0]+l[t][1]
    else:
      n=(cnt-l[t][1])//l[t][2]
      if n<0:
        cnt=l[t][1]+l[t][0]
      elif n*l[t][2]==cnt-l[t][1]:
        cnt=l[t][1]+l[t][2]*n+l[t][0]
      else:
        cnt=l[t][1]+l[t][2]*(n+1)+l[t][0]
  print(cnt)
print(0)

Measured memory_bytes: 3188
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll a,b;
  cin>>a>>b;
  rep(i,0,N)
  {
    if((i*8/100==a)&&(i*10/100==b))
    {
      cout<<i;
      return ;
    }
  }
  cout<<-1;
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 256