akhauriyash/Code-Regression huggingface dataset:
N , K = map(int,input().split())
l = list(map(int,input().split()))

pref_sum = [None]* (N+1)
pref_sum[0] = 0
pref_sum[1] = (l[0]+ 1) / 2

for i in range(1, N):
    t = (l[i]+ 1) / 2
    pref_sum[i+1] = t + pref_sum[i]

ans = -float("inf")

for i in range(K, N+1):
    ans = max(ans, pref_sum[i] - pref_sum[i-K])


print(ans)

Measured memory_bytes: 71792
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 998244353;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

ll dp[301][300*300+1];
ll dp2[301][300*300+1];

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

  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  ll sum = 0;
  rep(i, n) {
    sum += a[i];
  }

  rep(i, 301) {
    rep(j, 300*300+1) {
      dp[i][j] = 0;
    }
  }
  
  dp[0][0] = 1;
  rep(i, n) {
    for(int j=0; j<=300*i; j++) {
      dp[i+1][j] += dp[i][j]*2;
      dp[i+1][j] %= mod;
      dp[i+1][j+a[i]] += dp[i][j];
      dp[i+1][j+a[i]] %= mod;
    }
  }

  dp2[0][0] = 1;
  rep(i, n) {
    for(int j=0; j<=300*i; j++) {
      dp2[i+1][j] += dp2[i][j];
      dp2[i+1][j] %= mod;
      dp2[i+1][j+a[i]] += dp2[i][j];
      dp2[i+1][j+a[i]] %= mod;
    }
  }

  ll tmp = 0;
  for(int i=(sum+1)/2; i<sum; i++) {
    tmp += dp[n][i] + mod*2 - dp2[n][i]*2;
    tmp %= mod;
  }

  ll beki3 = 1;
  ll beki2 = 1;
  rep(i, n) {
    beki3 = beki3*3%mod;
    beki2 = beki2*2%mod;
  }

  ll ans = beki3 + 3*mod - 3*beki2;
  ans %= mod;
  ans = ans + 3*mod - 3*tmp;
  ans %= mod;
  cout << (ans+3)%mod << endl;
}

Measured memory_bytes: 421504
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int n; cin >> n; int a[n]; bool check[1010100] = {};
  int G = a[0];
  rep(i, n){
    cin >> a[i]; G = gcd(G, a[i]); check[a[i]]=true;
  }
  bool pa = true;
  sort(a, a+n);
  rep(i, n-1){
    if(a[i]==a[i+1] && a[i]!=1) pa=false;
  }
  for(int i=2; i<=1010000; i++){
    int cnt = 0;
    for(int j=i; j<=1010000; j+=i){
      if(check[j]) cnt++;
    }
    if(cnt>=2) pa = false;
  }
  if(pa) cout << "pairwise coprime" << endl;
  else if(G==1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 8360
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

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

    int e;
    while (1)
    {
        cin >> e;
        if (e == 0)
            break;
        int ans = INF;
        for (int i = 0; i * i * i <= e; i++)
        {
            for (int j = 0; i * i * i + j * j <= e; j++)
            {
                int num = e - i * i * i - j * j;
                if (num >= 0)
                    ans = min(ans, i + j + num);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
    using namespace std;
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < int , int >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 1000005

    int main()
    {

      // unordered_map< pair<char,int> ,ll> :: iterator itr;
      map<ll,ll>m1,m2;
      map<ll,ll> :: iterator itr;
        ll n,k;
        cin>>n>>k;

        ll ap[n];
        ll pre=n*(1*k+(n-1))/2;
        ll sum[n],sum1=0;
        forl(i,1,n,n+1){
        ll ans=i*(2*k+(i-1))/2;
        sum[i]=ans;
       // cout<<sum[i]<<endl;
        ap[i]=k+i-1;

        }
        sum1=sum[n];
        ll rans=0,p=0,p1=INT_MAX,q=0;
        //cout<<"PRE"<<pre<<endl;
        forl(i,1,n,n+1)
        {
            p=sum1-ap[i];
            //cout<<"P"<<p<<endl;
            q=abs(sum1-p);
           // cout<<p<<" "<<q<<endl;
            if(p1>q)
            {
                p1=q;
                rans=p;
            }
        }
        cout<<rans<<endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }



struct C
{
	ll x = 0;
	ll y = 0;
	ll z = 0;
	ll value() { return abs(x) + abs(y) + abs(z); }
	ll value(int mode) const {
		ll result = 0;
		result += (mode & 1) ? x : -x;
		result += (mode & 2) ? y : -y;
		result += (mode & 4) ? z : -z;
		return result;
	}
};

int main(int argc, char* argv[])
{
	for (;;) {
		int N, M;

		cin >> N >> M;
		if (cin.fail()) break;

		vector<int> V(N + 1, 0);
		for (int i = 0; i < M; i++) {
			int L, R;
			cin >> L >> R;
			V[L - 1]++;
			V[R]--;
		}
		int sum = 0, res = 0;
		for (int i = 0; i < N; i++) {
			sum += V[i];
			if (sum == M) res++;
		}
		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void)
{
	char mozi[10000];
	int i, x, y;
	while(scanf("%s", mozi)!=EOF)
	{
		x=0;
		y=0;
		for(i=0; mozi[i+2]!=0; i++)
		{
			
			if(mozi[i+1]=='O'&&mozi[i+2]=='I')
			{
				if(mozi[i]=='J')
				{
					x++;
				}
				if(mozi[i]=='I')
				{
					y++;
				}
			}
		}
		printf("%d\n%d\n", x, y);
	}
	
	return 0;
}


Measured memory_bytes: 2752
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();

    let sum = a + b + c;
    let max = [a, b, c].iter().max().unwrap().clone();
    println!(
        "{}",
        ((if (max * 3) % 2 == sum % 2 { 0 } else { 1 } + max) * 3 - sum) / 2
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
    int tmp;
    vector<int> xs;
    for(int i=0; i<3; i++){
        cin >> tmp;
        xs.push_back(tmp);
    }
    
    sort(xs.begin(), xs.end());

    cout << xs[0] + xs[1] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val n, m = sc.nextInt
  val gates: Array[(Int, Int)] = Array.fill(m)((sc.nextInt, sc.nextInt))
  val (l, r) = gates.foldLeft((0, Int.MaxValue)){case ((maxL, minR), (l, r)) => (maxL max l, minR min r)}
  println(if (r < l) 0 else r - l + 1)
}

Measured memory_bytes: 74064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String line;
        // ????????\???
        while((line=br.readLine()) != null) {
            // ??\???????????????????§???????????????§????????????
            String[] input = line.split(" ");
            int[] in = new int[input.length];
            
            // ??????????????°????????????
            for(int i = 0; i < input.length; i++) {
                in[i] = Integer.parseInt(input[i]);
            }
            
            // a < b < c ??§Yes???????????\??????No?????¨???
            if(in[0] < in[1] && in[1] < in[2]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            
        }
    }
}

Measured memory_bytes: 24208
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    i64 l,r;
    cin>>l>>r;

    i64 n = r - l;
    if(n >= 2019){
        cout<<0<<endl;
        return 0;
    }

    int ml = l % 2019;
    i64 ans = INF;
    for(i64 i=l;i<r;i++){
        for(i64 j=i+1;j<=r;j++){
            ans = min(ans, (i * j) % 2019 );
            
        }
    }
    cout<<ans<<endl;

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

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

int main(){

    int n;
    cin >> n;
    
    map<string, int> mp;
    string s;
    rep(i, n) {
        cin >> s;
        mp[s]++; 
    }

    int mx = 0;
    for (auto i : mp) {
        mx = max(i.second, mx);
    }
    for (auto i : mp) {
        if (i.second == mx) {
            cout << i.first << endl;
        }
    }

    return 0;
} 


Measured memory_bytes: 19212
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    cout << ((b == 1) ? 0 : (a - b)) << endl;
}




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

int counting(int n){
    int res=0;
    while(n%2==0){
        res++;
        n/=2;
    }
    return res;
}

int main(){
    int n;
    scanf("%d",&n);
    int res=0;
    for(int i=0;i<n;i++){
        int num;
        scanf("%d",&num);
        if(num%2==0) res+=counting(num);
    }
    printf("%d\n",res);
    return 0;
}

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

int v[2005];
int n,sum;
bitset<4000005> dp;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        for(int i = 0; i < n; i++)
            cin >> v[i];
        sum = accumulate(v, v + n, 0);
        dp.reset(); dp.set(0);
        for(int i = 0; i < n; i++)
            dp |= dp << v[i];
        for(int i = (sum+1)/2; i <= sum; i++)
            if(dp[i])
            {
                cout << i << '\n';
                break;
            }
    }
    return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[222222];
vector<vector<ll>> mp(222222);
int pla[222222];

int main(){
	
	int n;cin >> n;
	vector<ll> v(n);
	REP(i, n)cin >> v[i];
	
	v.erase(unique(ALL(v)), v.end());
	REP(i, v.size())mp[v[i]].PB(i);	
	
	dp[0] = 1;
	REP(i, v.size()){
		int now = v[i];
		ll tmp = 0;
		if(pla[now] > 0){
			tmp = dp[mp[now][pla[now] - 1] + 1];
		}
		pla[now]++;
		
		dp[i+1] = (dp[i] + tmp) % MOD;
	}
	
	cout << dp[v.size()] << endl;
	
		
	return 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n,a,b;
    while(cin >> n >> a >> b){
        if(n == 0 && a == 0 && b == 0)return 0;
        vector<int> vec;
        for(int q = 0;q < n;q++){
            int e;cin >> e;
            vec.push_back(e);
        }
        sort(vec.begin(), vec.end());
        int ma = -1e9;
        int ans = 0;
        for(int i = n-b-1;i < n-a;i++){
            if(vec.at(i+1) - vec.at(i) > ma){
                ma = vec.at(i+1) - vec.at(i);
                ans = n-i-1;
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3040
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	LL n,m;
	cin>>n>>m;
	LL ans=0;
	if(n*2<m){
		ans+=n;
		m-=2*n;
		ans+=m/4;
	}else{
		ans=m/2;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
            String s = sc.next();
            if(s.equals("-")) {
                break;
            }
            int m = sc.nextInt();

            for(int i=0; i<m; i++) {
                int h = sc.nextInt();
                s = s.substring(h) + s.substring(0,h);
            }
            System.out.println(s);

        }
        sc.close();
    }
}



Measured memory_bytes: 26536
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        if(N % i == 0 && N / i >= 1 && N / i <= 9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3580
//InTheNameOfGod
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn =200;
int n,a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    int re=0;
    cin>>n;
    rep(i,0,n)
    {
        cin>>a[i];
    }
    rep(i,0,n)
    {
        int x=i,t=0;
        while(x<n&&a[x]==a[i])
        {
            t++;
            x++;
        }
        x--;
        i=x;
        re+=t/2;
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
def main():
    import math
    from functools import reduce
    def gcd_list(l):
        return reduce(math.gcd, l)
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    g = gcd_list(A)
    m = max(A)
    if k % g == 0 and k <= m:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()


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

int main()
{
  int64_t x, n, p, ans, dif = (1LL << 30);
  cin >> x >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++)
  {
    cin >> p;
    mp[p]++;
  }
  for (int i = -10000; i <= 10000; i++)
  {
    if (mp.count(i))
      continue;
    if (abs(i - x) < dif)
    {
      ans = i;
      dif = abs(i - x);
    }
  }
  cout << ans << endl;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e6 + 5;
const int inf = 1e16 + 2;

int m[N] , p[N];
void solve(int Case) {
    int n ;
    cin >> n;
    int a[n] , mx = 0 , g;
    
    for(int i = 0 ; i < n ; i ++) {
        cin >> a[i] ;
        if(i == 0) g = a[0];
        else g = gcd(g , a[i]);
        mx = max(mx , a[i]);
        m[a[i]] ++;
    }
    int ans = 0 ;
    
    for(int i = 2 ; i <= mx ; i ++) {
        int cnt = 0;
        if(p[i] == 0) {
            for(int j = i ; j <= mx ; j += i) {
                cnt += m[j];
                p[j] = 1;
            }
        }
        ans = max(ans , cnt);
    }
    if(ans <= 1) cout << "pairwise coprime" << '\n';
    else if(g == 1) cout << "setwise coprime" << '\n';
    else cout << "not coprime" << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int C = 1;
    while(testcase --) {
        solve(C ++);
    }
    return 0;
}


Measured memory_bytes: 26956
#!/usr/bin/env python
# coding: utf-8

# In[18]:


import itertools


# In[19]:


def sieve(x):
    p = []
    b = [1]*(x+1)
    for i in range(2,x+1):
        if b[i]:
            p += [i]
            for j in range(2*i,x+1,i):
                b[j] = 0
    return p
p=sieve(10**5)


# In[27]:


s = set(i for i in p if i<5*10**4)
l = [0]*(10**5)
for i in p[1:]:
    if i//2 + 1 in s:
        l[i] = 1
S = list(itertools.accumulate(l))


# In[30]:


Q = int(input())
for _ in range(Q):
    l,r = map(int, input().split())
    print(S[r]-S[l-1])


# In[ ]:






Measured memory_bytes: 13624
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }


const ll MOD = 1000000007;
 ;
const int M = 100001;
vector<int> graph[M];
ll connect[M];
int visit[M];

ll bfs(int start, int k) {
  ll ans = k;
  queue<int> remain;
  remain.push(start);
  visit[start] = 0;
  while (remain.size() > 0) {
    int from = remain.front(); remain.pop();
    for (int to: graph[from]) {
      if (visit[to] != -1) continue;
      remain.push(to);
      ll colors = k - connect[from] - 1;
      // cout << from << " " << to << " " << colors << endl;
      if (colors <= 0) return 0;
      ans *= colors % MOD;
      ans %= MOD;
      ++connect[from];
      ++connect[to];
      visit[to] = 0;
    }
  }
  return ans % MOD;
}

int main() {
  memset(visit, -1, sizeof(visit));
  memset(connect, 0, sizeof(connect));

  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n-1; ++i) {
    int from, to;
    cin >> from >> to;
    graph[from].push_back(to);
    graph[to].push_back(from);
  }
  ll ans = bfs(1, k);
  cout << ans << endl;
}


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

int main(){
  long long int N, K, X;
  string S;
  cin >> S;
  if(S == "SUN") cout << 7 << endl;
  if(S == "MON") cout << 6 << endl;
  if(S == "TUE") cout << 5 << endl;
  if(S == "WED") cout << 4 << endl;
  if(S == "THU") cout << 3 << endl;
  if(S == "FRI") cout << 2 << endl;
  if(S == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
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; }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  vector<pair<int,int>>v;
  rep(i,0,n){
    int a; cin >> a;
    v.push_back(make_pair(a,i));
  } 
  sort(rALL(v));
  rep(i,0,n){
      if(i==v[0].second) cout << v[1].first << endl;
      else cout << v[0].first << endl;
  }

}  

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

int main() {
	long long n, a, b, ans;
	cin >> n;
	a = n % 11;
	b = (n - a) / 11;
	if (a == 0)ans = 2 * b;
	else if (a <= 6)ans = 2 * b + 1;
	else ans = 2 * b + 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

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

  string s;
  cin >> s;

  ll pa = s.find('A');
  ll pz = s.rfind('Z');
  cout << pz - pa + 1 << endl;

  return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
String str = scan.next();
  
 String[] num=str.split("");
  
  int i=0;
  int sum=0;
  for(i=0;i<(num.length)/2;i++){
  if(num[i].equals(num[num.length-1-i])){
  sum=sum+1;
  }
  }
  System.out.println((num.length/2)-sum);
  
}
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,x;
	int box[101];
	int i;
	int cnt;
	int sum;
	cin>>n>>x;
	box[0]=0;
	for(i=1;i<=n;i++)	cin>>box[i];
	sum=0;
	cnt=0;
	for(i=0;i<=n;i++){
		sum+=box[i];
		if(sum>x)	break;
		cnt++;
		
	}
	cout<<cnt<<endl;
	return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int MOD = 1e9+7;
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  vector<vector<int>> dp(h, vector<int>(w, 0));
  for(int i=0; i<h; i++) {
 	for(int j=0; j<w; j++) {
     cin >> grid[i][j];
    }
  }
  dp[0][0] = (grid[0][0] == '.') ? 1 : 0;
  for(int i=1; i<h; i++) {
    if(grid[i][0] == '.') {
      dp[i][0] = dp[i-1][0];
    }
  }
  for(int i=1; i<w; i++) {
    if(grid[0][i] == '.') {
      dp[0][i] =dp[0][i-1];
    }
  }
   for(int i=1; i<h; i++) {
 	for(int j=1; j<w; j++) {
     if(grid[i][j] == '.') {
       dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
     }
    }
  }
  cout << dp[h-1][w-1]%MOD;
  return 0;
}



Measured memory_bytes: 8496
import java.util.*;


public class Main {
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);
		Integer[] mount = new Integer[10];
		int i = 0;
		while(i != 10){
			mount[i] = sc.nextInt();
			i++;
		}
		sort(mount);
		sc.close();
	}
	public static void sort(Integer[] mlist){
		Arrays.sort(mlist);
		for(int i=9; i >= 7; i--){
			System.out.println(mlist[i]);
		}
	}
	
}

Measured memory_bytes: 25932
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

// {person, is_honest}
vector<vector<pair<int, int>>> statements;

int bits_count(int x) {
    int cnt = 0;
    while (x != 0) {
        if (x & 0x1) cnt++;
        x >>= 1;
    }
    return cnt;
}

int solve(const int N) {
    int ans = 0;

    for (int bits = 0; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            if ((bits & (1 << i)) != 0) {
                for (auto &ss : statements[i]) {
                    bool is_honest = (bits & (1 << ss.first)) != 0;
                    if ((is_honest && ss.second == 1) || (!is_honest && ss.second == 0)) {
                        // do nothing
                    } else {
                        ok = false;
                    }
                }
            }
        }
        if (ok) {
            chmax(ans, bits_count(bits));
        }
    }

    return ans;
}

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

    statements.resize(N);
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        for (int j = 0; j < A; j++) {
            int x, y;
            cin >> x >> y;
            x--;
            statements[i].push_back({x, y});
        }
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 256
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0);p=*0..gets.to_i;f=->a{a==p[a]?a: p[a]=f[p[a]]};a,b=$<.map(&:split).transpose.map{|a|S=i=0;a.map{|a|[a.to_i,i+=1]}.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};(a+b).sort_by{|a|a[0]}.map{|c,a,b|(S+=c;p[p[b]]=p[a])if f[a]!=f[b]};p S

Measured memory_bytes: 125964
A, B, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

min = a.min + b.min
M.times do |i|
  x, y, c = gets.split.map(&:to_i)
  price = a[x-1] + b[y-1] - c
  if price < min
    min = price
  end
end

puts min

Measured memory_bytes: 18588
#include <bits/stdc++.h>
using namespace std; 
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m, s = 0, a[100];
	cin >> n >> m;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		s += a[i];
	}
	double K = s / (4.0 * m);
	for(int i = 0; i < n; ++i) {
		if(a[i] >= K) --m;
	} 
	if(m <= 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

namespace ARC061D {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int H = input[0];
            int W = input[1];
            int N = input[2];
            List<long> list = new List<long>();
            for (int i = 0; i < N; i++) {
                int[] inputb = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                for (int j = inputb[0] - 1; j <= inputb[0] + 1; j++) {
                    for (int k = inputb[1] - 1; k <= inputb[1] + 1; k++) {
                        if (j >= 2 && j <= H - 1 && k >= 2 && k <= W - 1) {
                            list.Add((long)(j - 1) * W + k);
                        }
                    }
                }
            }
            list.Sort();
            long temp = 0;
            int num = 0;
            long[] ans = new long[10];
            ans[0] = (long)(H - 2) * (W - 2);
            for (int i = 0; i < list.Count; i++) {
                if (list[i] != temp) {
                    if (temp != 0) {
                        ans[num]++;
                        ans[0]--;
                    }
                    temp = list[i];
                    num = 1;
                } else {
                    num++;
                }
            }
            ans[num]++;
            ans[0]--;
            for (int i = 0; i < 10; i++) {
                Console.WriteLine(ans[i]);
            }
        }
    }
}


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

using namespace std;

int main()
{
    int total, x;
    while (cin >> total, total) {
        for (int i = 0; i < 9; i++) {
            cin >> x;
            total -= x;
        }
        cout << total << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define GC getchar
#define fi first
typedef int INT;
#define int long long
#define se second
#define SZ(x) ((int)(x).size())
#define FOR(i,a,b) for(int i=(a),__l=(b);i<=__l;++i)
#define DEP(i,a,b) for(int i=(a),__l=(b);i>=__l;--i)
using namespace std;
typedef double db;
typedef long long LL;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int inf=1000000005;
const int _L=1<<21;char _Buf[_L],*__S,*__T;
inline char Fast_getchar(){
if(__S==__T){__T=(__S=_Buf)+fread(_Buf,1,_L,stdin);if(__S==__T)return EOF;}return *__S++;}
template <class __T> inline void read_string(__T s[]){
	char c;for(c=GC();c<33||c>126;c=GC());
	for(;33<=c&&c<=126;*s++=c,c=GC());*s=0;}
template <class __T> inline void read(__T& x){
	x=0;char c=GC();int f=1;
	for(;!isdigit(c);c=GC())c=='-'?f=-1:0;
	for(;isdigit(c);c=GC())x=(x<<1)+(x<<3)+(c^'0');f<0?x=-x:0;}

/*----------------------------------------------------------------------------*/

const int N=1200005;
pii G(pii a,pii b){
	if(a.fi>b.fi) return a;
	if(a.fi<b.fi) return b;
	return a.se>b.se ? a:b;
}
pii merge(pii a,pii b){
	pii A=a,B=b,C=pii(a.se+b.se,max(a.se,b.se));
	return G(A,G(B,C));
}
int l,n,a[N];
pii A[N];
INT main() {
//	freopen("in.in","r",stdin);
	read(l);n=1<<l;int x;
	FOR(i,0,n-1) read(x),a[i]=x,A[i]=pii(x,x);
	FOR(j,0,l-1)FOR(i,0,n-1)
		if(i>>j&1) A[i]=merge(A[i],A[i^(1<<j)]);
		//a[i]=a[i]+a[i^(1<<j)];
	int mx=A[0].fi;
	FOR(i,1,n-1){
	//	A[i]=merge(A[i],A[i-1]);
		mx=max(mx,A[i].fi);
		cout<<mx<<'\n';
		//cout << A[i].fi << '\n';
	}
	return 0;
}


Measured memory_bytes: 15360
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] NK = ReadLineParseIntArray();
        int N = NK[0];
        int K = NK[1];
        int cmb = Combination(N - 1, 2);
        if(cmb < K)
        {
            WriteLine(-1);
            return;
        }
        int count = cmb - K;
        WriteLine(N - 1 + count);
        for(int i = 2; i <= N; i++)
        {
            WriteLine($"1 {i}");
        }
        for(int i = 2; i < N; i++)
        {
            for(int j = i + 1; j <= N; j++)
            {
                if (count == 0) return;
                WriteLine($"{i} {j}");
                count--;
            }
        }
    }
      static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
    static int Combination(int n, int m)
    {
        if (m == 0) return 1;
        return Combination(n, m - 1) * (n - m + 1) / m;
    }
}

Measured memory_bytes: 13396
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n, c = ns()

    dist = []
    value = []
    dist_r = []
    value_r = []
    for _ in range(n):
        di, vi = ns()
        dist.append(di)
        value.append(vi)
        dist_r.append(c - di)
        value_r.append(vi)

    dist_r.reverse()
    value_r.reverse()

    cum = []
    cum_r = []

    value_sum = 0
    value_max = -INF
    for di, vi in zip(dist, value):
        value_sum += vi
        value_max = max(value_max, value_sum - di)
        cum.append(value_max)

    value_sum = 0
    value_max = -INF
    for di, vi in zip(dist_r, value_r):
        value_sum += vi
        value_max = max(value_max, value_sum - di)
        cum_r.append(value_max)

    ans = 0
    for i in range(n):
        a = cum[i]
        c = cum_r[i]
        b, d = 0, 0
        if i != n - 1:
            b = cum[i] - dist[i] + cum_r[n - 2 - i]
            d = cum_r[i] - dist_r[i] + cum[n - 2 - i]
        ans = max(ans, a, b, c, d)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97748
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

ll a[500000], b[500000], ans = 0, dp[2300][2300];

int main() {
	speed;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++)
		dp[i][0] = 1;
	for (int i = 0; i <= m; i++)
		dp[0][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
		{
			if (a[i - 1] == b[j - 1])
				dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
			else
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
			dp[i][j] += mod;
			dp[i][j] %= mod;
		}
	cout << dp[n][m];
}

Measured memory_bytes: 41344
import fractions

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

a, b, c, d = map(int, input().split())
c_ = b//c - (a-1)//c
d_ = b//d - (a-1)//d
cd_ = b//lcm(c, d) - (a-1)//lcm(c, d)
print(b - a + 1 - (c_ + d_ - cd_))

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef pair<double,double> P;

int main() {
  int n;
  while(cin >> n && n) {
    P a[n];
    for(int i=0,x,y,z; i<n; i++) {
      cin >> z >> x >> y;z--;
      a[z]=P(x,y);
    }
    int m;
    cin >> m;
    while(m--) {
      int s,t;
      cin >> s >> t;s--,t--;
      int p[n];double d[n];
      fill(d,d+n,1<<30);
      d[s]=0;
      p[s]=-1;
      priority_queue<P,vector<P>,greater<P> > que;
      que.push(P(0,s));
      while(!que.empty()) {
        P pp=que.top();que.pop();
        int x=pp.S;
        double c=pp.F;
        if(d[x]<c) continue;
        for(int i=0; i<n; i++) {
          double dd=sqrt((a[i].F-a[x].F)*(a[i].F-a[x].F)+(a[i].S-a[x].S)*(a[i].S-a[x].S));
          if(dd<=50&&d[i]>d[x]+dd) {
            d[i]=d[x]+dd;
            p[i]=x;
            que.push(P(d[i],i));
          }
        }
      }
      if(d[t]==1<<30) {
        cout << "NA" << endl;
        continue;
      }
      vector<int> ans;
      while(t!=s) {
        ans.push_back(t);
        t=p[t];
      }
      ans.push_back(s);
      reverse(ans.begin(),ans.end());
      for(int i=0; i<ans.size(); i++) {
        if(i) cout << " ";
        cout << ans[i]+1;
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3116
def m():
    h, w, d = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    pre = [0] * ((h*w)+1)
    for i in range(h):
        for j in range(w):
            pre[a[i][j]] = (i+1, j+1)
    accum = [0] * len(pre)
    for i in range(d+1, len(pre)):
        accum[i] = accum[i - d] \
                   + abs(pre[i][0] - pre[i - d][0])\
                   + abs(pre[i][1] - pre[i - d][1])

    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        power = accum[r] - accum[l]
        print(power)

m()

Measured memory_bytes: 59868
#include <bits/stdc++.h>
using namespace std;
const int MAXN=51,MOD=1e9+7;
inline int add(register int a,register int b) {return a+=b,a>=MOD?a-MOD:a;}
inline int del(register int a,register int b) {return a-=b,a<0?a+MOD:a;}
inline int mul(register int a,register int b) {return 1LL*a*b%MOD;}
int f[MAXN][MAXN],g[MAXN][MAXN],C[MAXN][MAXN],n;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(register int i=0;i<=n;i++) C[i][0]=1;
	f[1][0]=f[1][1]=1;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=i;j++) C[i][j]=add(C[i-1][j],C[i-1][j-1]);
	for(register int i=1;i<n;i++)
		for(register int j=0;j<=i;j++)
			if(f[i][j])
				for(register int x=0;x<=n-i;x++)
					for(register int y=0;y<=n-x-i;y++)
						if((x+y)&&(x+y>=j)&&(!((x+y-j)&1))) f[x+y+i][abs(((x+y-j)>>1)+j-x)]=add(f[x+y+i][abs(((x+y-j)>>1)+j-x)],mul(f[i][j],mul(C[x+y+i][x+y],C[x+y][x])));
	cout<<f[n][0]<<endl;
	return 0;
}

Measured memory_bytes: 256
daylist = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
week = ["Wednesday", "Thursday", "Friday", "Saturday",
        "Sunday", "Monday", "Tuesday"]

while(1):
    m, d = map(int, input().split())
    if m == 0:
        break

    day = 0
    for i in range(m-1):
        day += daylist[i]
    day += d

    w = week[day % 7]
    print(w)



Measured memory_bytes: 5592
#include <iostream>
#include <numeric>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    bool operator<(const ModInt& b) const { return val < b.val; }
    bool operator<=(const ModInt& b) const { return val <= b.val; }
    bool operator>(const ModInt& b) const { return val > b.val; }
    bool operator>=(const ModInt& b) const { return val >= b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept {
        lint v;
        is >> v;
        x = v;
        return is;
    }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

using lint = long long;

void solve() {
    lint h, w, t;
    std::cin >> h >> w >> t;

    lint sz = std::gcd(h, t) * std::gcd(w, t);
    h /= std::gcd(h, t), w /= std::gcd(w, t);

    std::cout << (mint(2).pow(h) + mint(2).pow(w) - 3 +
                  mint(2).pow(std::gcd(h, w)))
                     .pow(sz)
              << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    bool b1= false;
    int x, a, b, c;
    cin>> x;
    int a1[x];
    for (int i = 0; i<x; i++){
        cin>> a1[i];
    }
    a = -1;
    c = -1;
    for (int i = 0; i<x; i++){
        if (a1[i] >= a1[a]){
            a = i;
            c = a1[a];
            
        }
    }
    b = 0;
    for (int i = 0; i< x; i++){
        if (i == a){
            continue;
        }
        b+=a1[i];
    }
//    cout << c << " " << b;
    if (c<b){
        b1 = true;
    }
    if (b1== true){
        cout << "Yes";
    }
    if (b1== false){
        cout << "No";
    }
    
    
    return 0;
}

Measured memory_bytes: 256
n, k, q = gets.chomp.split(" ").map(&:to_i)
point = Array.new(n,k-q)
q.times do
  correct = gets.to_i
  point[correct-1] += 1
end
point.each do |p|
  if p > 0
    puts "Yes"
  else
    puts "No"
  end
end

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

using namespace std;

const int maxn=1e5;

int l[maxn], dp[maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> l[i];
	}
	for(int i=1; i<n; i++){
		if(i==1){
			dp[i]=abs(l[i-1]-l[i]);
		}
		else{
			dp[i]=min(dp[i-1]+abs(l[i-1]-l[i]), dp[i-2]+abs(l[i-2]-l[i]));
		}
	}
	cout << dp[n-1] << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
 int a, b;
  int acc = 0;
  scanf("%d %d", &a, &b);
  if(a-b > a+b)
  acc = a-b;
  else
    acc = a+b;
  
  if(a*b > acc)
    acc = a*b;
  
  printf("%d\n", acc);
  
  return 0;
}

Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    string s; cin >> s;

    // 全て異なる文字の場合は、それぞれのオンオフ考慮して-1なので2*n-1
    // 重複文字がある場合は重複文字に関してはその重複数通り
    map<char, ll> m;
    REP(i, n) {
        if (m.find(s[i]) == m.end()) {
            m[s[i]] = 0;
        }
        m[s[i]]++;
    }
    ll res = 1;
    for (auto e:m) {
        // 同じ文字の中からの選び方は、どれかを選ぶかどれも選ばないか
        res *= (e.second + 1);
        res %= 1000000007;
    }
    // すべての文字を選ばないことはできないので-1
    res -= 1;
    res %= 1000000007;

    cout << res << endl;
    return 0;
}

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

int main(void){
  int n,x,count;
  vector<int> v;
  count=0;
  while(1){
  	cin>>n>>x;
  	if(n==0){
  	  break;
  	}
  	for(int i=1;i<n+1;i++){
  	  for(int j=i+1;j<n+1;j++){
  	  	for(int l=j+1;l<n+1;l++){
  	  		if(i+j+l==x){
  	  		  count++;
  	  		}
  	  	}
  	  }
  	}
  	v.push_back(count);
  	count=0;
  }
  for(int i=0;i<int(v.size());i++){
  	cout<<v[i]<<endl;
  }
}



Measured memory_bytes: 3092
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll a,b,c,d,e,f,x,y,k,t,A=0,mod,B=0,L,j,i,l,r,m,n,C=0,ans=0,sum=0,sum1=0;
    vector<ll>v,v1;
    queue<ll>qu;
    cin>>n;
    if(n%1000==0){
    cout<<0<<endl;
    return 0;}
    m=n%1000;
    cout<<1000-m<<endl;

    return 0;
}



Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();
        System.out.println((a * (n / (a + b))) + Math.min(n % (a + b), a));
    }
}


Measured memory_bytes: 23764