akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl



int main(){
    int n,k;
    cin >> n >> k;
    double ans = 0;
    if(n<=k){
        FOR(i,1,n+1){
            int t = i;
            double kaku = 1.0/n;
            while(t<k){
                t *= 2;
                kaku /= 2.0;
            }
            ans += kaku;
        }
        cout << setprecision(20) << ans << endl;
    }
    else{
        FOR(i,1,k){
            int t = i;
            double kaku = 1.0/n;
            double kaku1 = 1.0/n;
            while(t<k){
                t *= 2;
                kaku /= 2.0;
            }
            ans += kaku1-kaku;
        }
    cout << setprecision(20) << 1-ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true)
    {
        c=c-b;
        if(c<=0)
        break;
        a=a-d;
        if(a<=0)
        break;
    }
    if(c<=0)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <set>

using namespace std;

int main()
{
    int n, ans=0, x, y;
    set<pair<int, int>> r, b;
    cin>>n;
    for (int i=0; i<n; i++) { cin>>x>>y; r.insert({x, y}); }
    for (int i=0; i<n; i++) { cin>>x>>y; b.insert({x, y}); }
    for (auto u : b)
    {
        x=-200; y=-200;
        for (auto v : r)
        {
            if (v.first<u.first && v.second<u.second)
            {
                if (v.first>x && v.second>y)
                {
                    x=v.first;
                    y=v.second;
                }
            }
        }
        if (x!=-200 && y!=-200) { r.erase({x, y}); ans++; }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
p = 10**9+7
N = int(input())
S1 = input().strip()
S2 = input().strip()
cur = 0
while cur<N:
    if cur==0:
        if S1[cur]==S2[cur]:
            cnt = 3
            cur += 1
        else:
            cnt = 6
            cur += 2
    else:
        if S1[cur]==S2[cur]:
            if S1[cur-1]==S2[cur-1]:
                cnt = (cnt*2)%p
            cur += 1
        else:
            if S1[cur-1]==S2[cur-1]:
                cnt = (cnt*2)%p
            else:
                cnt = (cnt*3)%p
            cur += 2
print(cnt)                

Measured memory_bytes: 61584
using System;
using System.Linq;

class PG{
    static void Main(string[] args){
        while(true){
            int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if(nums[0]==0&&nums[1]==0){
                break;
            }
            for(int i=0;i<nums[0];i++){
              for(int j=0;j<nums[1];j++){
                    Console.Write("#");
                }
                Console.WriteLine();
            } 
            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 16316
#include <iostream>
#include <vector>
#include <unordered_map>


using namespace std;
using vi = vector<int>;
using vvi = vector <vi>;
using graph = vvi;


graph read_graph(int n_nodes, int n_edges, int off_set){
    graph g(n_nodes, vi());
    for (int i = 0; i != n_edges; ++i){
        int a, b;
        cin >> a >> b;
        g[a - off_set].push_back(b - off_set);
        g[b - off_set].push_back(a - off_set);
    }
    return g;
}

vi find_groups(graph g){
    int n_nodes = g.size();
    vi groups(n_nodes, 0);
    for (int i = 0; i != n_nodes; ++i) groups[i] = i;
    for (int v = 0; v != n_nodes; ++v){
        if (groups[v] != v) continue;
        vi stk(g[v]);
        while (not stk.empty()){
            int u = stk.back();
            stk.pop_back();
            groups[u] = v;
            for (auto w : g[u]){
                if (groups[w] != v) stk.push_back(w);
            }
        }
    }
    return groups;
}

int main() {
    ios::sync_with_stdio(false);
    int N, K, L;
    cin >> N >> K >> L;
    auto bus_routes = read_graph(N, K, 1);
    auto train_routes = read_graph(N, L, 1);
    auto bus_groups = find_groups(bus_routes);
    auto train_groups = find_groups(train_routes);
    unordered_map<long long, int> counter(N);
    long long LN = N;
    for (int v = 0; v != N; ++v){
        counter[bus_groups[v] * LN + train_groups[v]] += 1;
    }
    for (int v = 0; v != N; ++v){
        cout << counter[bus_groups[v] * LN + train_groups[v]] << (v == N - 1 ? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 25628
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int solve(const vector<int>& values) {
    int result = __gcd(values[0], values[1]);
    for (auto i = 1u; i < values.size(); i++) result = __gcd(result, values[i]);
    return result;
}

int main()
{
    int N;
    cin >> N;
    vector<int> numbers;
    for (auto i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        numbers.push_back(Ai);
    }
    cout << solve(numbers) << endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    int zero = 0, one = 0;
    cin >> s;
    for(int i = 0; i < (int)s.size(); i++){
        if((s[i] == '0' && !(i & 1)) || (s[i] == '1' &&  (i & 1))) ++one;
        if((s[i] == '0' &&  (i & 1)) || (s[i] == '1' && !(i & 1))) ++zero;
    }
    cout << (one < zero ? one : zero) << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void) {
	static char str[100000];
	int cnt1, cnt0, ans;
	int i, j, k;
	cnt1 = cnt0 = 0;

	scanf("%s", str);
	for (i = 0; str[i] != '\0'; i++) {
		if (str[i] == '1') {
			cnt1++;
		}
		else {
			cnt0++;
		}
	}
	if (cnt1 > cnt0) {
		ans = cnt0 * 2;
	}
	else {
		ans = cnt1 * 2;
	}
	printf("%d\n", ans);
	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;

//dp解
//dp[i][j] -> i,jから始めた時一致している長さ
int dp[5005][5005];

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  for (int i = N-1; i >= 0; i--) {
    for (int j = N-1; j >= 0; j--) {
      if(s[i] != s[j] )dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int res = 0;
  rep(i,N)rep(j,N) {
    if (i >= j) continue; // i < j 
    int now = min(dp[i][j], j - i);//i文字目を終端とした時のlenの最大
    res = max(res,now);
  }
  
  cout << res << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, L;
VL x, rx;

int main() {
    cin >> L >> N;
    x.resize(N);
    rx.resize(N);
    VECCIN(x);
    REP(i, N) rx[i] = L - x[N - 1 - i];
    ll ans = 0;
    REP(lp, 2) {
        VL ccw(N + 1, 0), cw(N + 1, 0);
        REP(i, N) {
            ccw[i + 1] += ccw[i] + x[i];
            cw[i + 1] += cw[i] + rx[i];
        }
        // FOREACH(x, ccw) cout << x << " ";
        // cout << "\n";
        // FOREACH(x, cw) cout << x << " ";
        // cout << "\n";
        REP(i, N) {
            int r = (N - i + 1) / 2;
            int l = N - i - r;

            ll tmp = 2 * (ccw[i + r] - ccw[i]);
            tmp += 2 * cw[l];
            if(l != r) {
                tmp -= x[i + r - 1];
            } else {
                tmp -= rx[l - 1];
            }
            ans = max(ans, tmp);
        }
        swap(x, rx);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6528
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N, K;
  string S;
  cin >> N >> K >> S;
  K--;
  for (int i = 0; i < N; i++) {
    if (i == K) {
      cout << (char) tolower(S[i]);
    } else {
      cout << S[i];
    }
  }
  cout << endl;
  return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string s, t;
	cin >> s >> t;
	if(s == t){
		cout << "No" << endl;
		return 0;
	}

	sort(all(s));
	sort(all(t));
	reverse(all(t));
	set<string> st;
	st.insert(s);
	st.insert(t);

	bool ans = true;
	if(*st.begin() != s) ans = false;

	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public void solve(){
		Scanner sc = new Scanner(System.in);
		int x ;
		x = sc.nextInt();
		System.out.print(x = x*x*x);
		System.out.println();
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
int main(){
    long k,ans=0;
    cin >> k;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                long c = gcd(gcd(i,j),l);
                ans += c;
            }
        }
    }
    cout << ans << endl;
}

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

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

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
constexpr int INF = 1<<30;
constexpr ll LINF = 1LL<<60;
constexpr ld PI = 3.1415926535897932;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }


int n, m, q, a[50], b[50], c[50], d[50];
int ans = 0;
vector<int> v;

void dfs(int i, int x) {
  if(i == n) {
    int res = 0;
    rep(j, q) {
      if(c[j]==v[b[j]]-v[a[j]]) res+=d[j];
    }
    chmax(ans,res);
    return;
  }
  REP(j, x, m+1) {
    v.push_back(j);
    dfs(i+1, j);
    v.pop_back();
  }
}


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n >> m >> q;
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i], a[i]--, b[i]--;
  dfs(0, 1);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3608
N = int(input())
list1 = []
count = 0
for i in range(N):
  a = input()
  list1.append(a)
for i in range(N-1):
  if list1[i][-1] == list1[i+1][0]:
    pass
  else:
    count +=1
aaa = set(list1)
if len(aaa) == len(list1):
  pass
else:
  count+=1
if count == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9164
import java.util.Scanner

import scala.collection.mutable

/**
 *
 */

object Main extends App {
  val sc = new Scanner(System.in)
  val (a, b, c) = (sc.nextInt, sc.nextInt, sc.nextInt)

  val checked = mutable.HashSet[(Int, Int, Int)]()

  def count(a: Int, b: Int, c: Int): Option[Int] = {
    if (checked.contains((a, b, c))) None
    else if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1) Some(0)
    else {
      checked.+=((a, b, c))
      count(b / 2 + c / 2, c / 2 + a / 2, a / 2 + b / 2).map(_ + 1)
    }
  }

  val ans = count(a, b, c)
  println(ans.getOrElse(-1))
}

Measured memory_bytes: 27340
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int T,n,m;
ll num[maxn];
ll step[maxn];
int main() {
	cin>>n>>m;
	int flag = 0;
	for(int i=0;i<m;i++){
		int t;
		cin>>t;
		num[t]=1;
		if(i>0&&num[t]&&num[t-1])
			flag = 1;
	}
	if(num[1]==1){
		step[2]=1;
	}
	else if(num[2]==1){
		step[1]=1;
	}
	else {
		step[1]=1;
		step[2]=2;
	}
//	cout<<step[1]<<endl<<step[2]<<endl;
	if(flag){
		cout<<0<<endl;
		//cout<<11111<<endl;
		return 0;
	}
	else {
		for(int i=3;i<=n;i++){
			if(num[i]){
				//cout<<11111<<endl;
				step[i]=0;
				step[i+1]=step[i-1];
				i++;
			}
			else {
				step[i]=step[i-1]+step[i-2];
				step[i]%=mod;
			}
		}
	}
	cout<<step[n]<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

// const int MAX = 1010;

int main()
{
    string N;
    cin >> N;
    ll total = 0;
    for (char c : N)
    {
        total += int(c - '0');
    }
    if (total % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int k, a, b; cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    } 
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3636
import java.lang.Math.floor

//

fun main() {
    abc172d()
}

fun abc172d() {
    val n = readLine()!!.toLong()
    var count = 0L
    for (i in 1L..n) {
        val y = floor(n / i.toDouble()).toLong()
        count += y * (y + 1) * i / 2
    }
    println(count)
}

Measured memory_bytes: 34684
#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;
  int a[2][N];
  rep(i,2) rep(j,N) cin >> a[i][j];
  
  int candy[2][N];
  rep(i,2) rep(j,N) candy[i][j] = 0;
  
  candy[0][0] = a[0][0];
  
  rep(i,2)
  {
    rep(j,N)
    {
      if(i > 0)
      {
        candy[i][j] = max(candy[i-1][j] + a[i][j], candy[i][j]);
      }
      if(j > 0)
      {
        candy[i][j] = max(candy[i][j-1] + a[i][j], candy[i][j]);
      }
    }
  }
  cout << candy[1][N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<int> g[100010];
int n,m,q;
int dp[100010][11];

void dfs(int v,int d,int c){
  if(d<0||dp[v][d]) return;

  dp[v][d]=c;
  for(auto to:g[v]){
    dfs(to,d-1,c);
  }
  return;
}


int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  cin>>q;
  int v[q],d[q],c[q];
  for(int i=0;i<q;i++){
    cin>>v[i]>>d[i]>>c[i];
  }

  for(int i=q-1;i>=0;i--){
    for(int j=d[i];j>=0;j--){
      dfs(v[i],j,c[i]);
    }
  }

  for(int i=1;i<=n;i++){
    cout<<dp[i][0]<<endl;
  }

  return 0;
}


Measured memory_bytes: 12024
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, C, XV):
    rXV = [(C - x, v) for x, v in reversed(XV)]
    ans1 = solve(N, C, XV, rXV)
    ans2 = solve(N, C, rXV, XV)
    print(max(ans1, ans2))

def solve(N, C, XV, rXV):
    M = [0]
    px = 0
    now = 0
    tmp = 0
    for x, v in rXV:
        now += v - (x - px)
        tmp = max(tmp, now)
        M.append(tmp)
        px = x

    res = 0
    px = 0
    now = 0
    for i, (x, v) in enumerate(XV):
        now += v - (x - px)
        res = max(res, now)
        res = max(res, now - x + M[N - i - 1])
        px = x
    return res

if __name__ == '__main__':
    input = sys.stdin.readline
    N, C = map(int, input().split())
    XV = [tuple(map(int, input().split())) for _ in range(N)]
    main(N, C, XV)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();
            var count = s.Count();
            var a = CountChar(s, 'o');
            var k = 15 - count;
            if (a + k >= 8)
            {
                WriteLine("YES");
            }
            else
            {
                WriteLine("NO");
            }
        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


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

int main()
{
    int N,W;
    cin>>N>>W;
    vector<vector<int>>dp(N+1,vector<int>(W+1));
    for (size_t i = 1; i <= N; i++)
    {   int v,w;
        cin>>v>>w;
        rep(j,W+1)
        {   
            if(j<=W&&j-w>=0)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v);
            else dp[i][j]=dp[i-1][j];
        }
      // cout<<dp[i][5-w]+v<<endl;
    }
   /* rep(i,N+1)
    {
        rep(j,W+1)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[N][W]<<endl;

    return 0;
}


Measured memory_bytes: 6752
import java.util.Scanner;

//Roman Figure
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			int sum = 0;
			int i;
			for(i=0;i<s.length-1;i++){
				if(f(s[i])>=f(s[i+1]))sum+=f(s[i]);
				else{
					sum += f(s[i+1])-f(s[i]);
					i++;
				}
			}
			if(i<s.length)sum += f(s[i]);
			System.out.println(sum);
		}
	}
	
	public static int f(char c){
		return c=='I'?1:
			c=='V'?5:
			c=='X'?10:
			c=='L'?50:
			c=='C'?100:
			c=='D'?500:1000;
	}
}

Measured memory_bytes: 11000
//usr/bin/g++ -O2 -std=c++14 -DTr___ $0 -o $0.run; exec $0.run; exit
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int (i)=(a),(_b)=(b);(i)<=(_b);++(i))
#define ROF(i,a,b) for(int (i)=(a),(_b)=(b);(i)>=(_b);--(i))
#define REP(i,a,b) for(int (i)=(a),(_b)=(b);(i)<(_b);++(i))
#define PER(i,a,b) for(int (i)=(a),(_b)=(b);(i)>(_b);++(i))
#define llint long long
#define fi first
#define se second
#define mt make_tuple
#define BIT(x, i) (((x)>>(i))&1ll)
#define MASK(i) (1ll<<(i))
#define db(x) cout << #x << " = " << (x) << endl;
#define mini(x, y) ((x)>(y)?(x)=(y),1:0)
#define maxi(x, y) ((x)<(y)?(x)=(y),1:0)
using namespace std;

void openFile() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef Tr___
    freopen("../test.inp", "r", stdin);
    freopen("../test.out", "w", stdout);
#else
    //freopen("tname.inp", "r", stdin);
    //freopen("tname.out", "w", stdout);
#endif
}

const int maxn=(int)2e5+5;
const int maxv=(int)2e5;
const int maxm=(int)1e6 + 5;
const llint inf=(llint)1e9 + 7;

int N,M;
int l[maxn],r[maxn];
vector<tuple<int,int>>v;

void enter() {
    cin>>N>>M;
    FOR(i,1,N){
        int l,r;
        cin>>l>>r;
        v.push_back(mt(l,r));
    }
}

int it[maxn*4],lz[maxn*4],L[maxn*4],R[maxn*4];
void buildTree(int x,int low,int high) {
    L[x]=low;R[x]=high;
    lz[x]=it[x]=0;
    if(low==high){
        return;
    }
    int mid=(low+high)/2;
    buildTree(x<<1,low,mid);
    buildTree(x<<1|1,mid+1,high);
}

void pushDown(int x) {
    it[x]+=lz[x];
    if(L[x]!=R[x]){
        lz[x<<1]+=lz[x];
        lz[x<<1|1]+=lz[x];
    }
    lz[x]=0;
}

void update(int x,int low,int high,int val) {
    pushDown(x);
    if(L[x]>high||R[x]<low)return;
    if(low<=L[x]&&R[x]<=high){
        lz[x]+=val;
        pushDown(x);
        return;
    }
    update(x<<1,low,high,val);
    update(x<<1|1,low,high,val);
    it[x]=max(it[x<<1],it[x<<1|1]);
}

int query(int x,int low,int high){
    pushDown(x);
    if(L[x]>high||R[x]<low)return 0;
    if(low<=L[x]&&R[x]<=high){
        return it[x];
    }
    return max(query(x<<1,low,high),query(x<<1|1,low,high));
}

void solve() {
    buildTree(1,1,M);
    sort(v.begin(),v.end());
    FOR(i,1,M){
        update(1,i,i,i);
    }
    int res=max(0,N-M);
    for(auto x:v) {
        int l,r;
        tie(l,r)=x;
        ++l;--r;
        update(1,l,r,1);
        int mx=query(1,l,M);
        res=max(res,mx-l+1-M);
    }
    cout<<res<<endl;
}

int main() {
    openFile();
    enter();
    solve();
    return 0;
}

Measured memory_bytes: 14192
#include<bits/stdc++.h>
#define forn(i, a, b) for(int i=(a); i<=(b); i++)
#define rforn(i, a, b) for(int i=(a); i>=(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define gcd __gcd
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define mod 1000000007
#define endl '\n'
#define int ll
using namespace std;
#define N 100005
#define inf 100000000000009LL


int32_t main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    clock_t clk = clock();

    int n , k;
    cin >> n >> k;
    vi a;
    forn(i ,1 , n){
        int x; cin >> x;
        a.push_back(x);
    }
    vi dp(n , INT_MAX);
     
   dp[0] = 0;
    for(int i = 1; i < n; i++){
        
       for(int j = 1; j <= k ; j++){
            if(i - j >= 0)
                dp[i] = min( dp[i-j] + abs(a[i] - a[i-j]) , dp[i]);
               
        }
        
    }
   // for(auto x:dp) cout << x << "  ";

    cout << dp[n-1] << endl;
    
    cerr<< "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
}

Measured memory_bytes: 5060
// E - Coprime
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rpd(i,s,e,d) for(int i=(s);i<(int)(e);i+=(d))

int gcd_all(vi &A){ int g = 0; for(int a:A) g = gcd(g, a); return g; }

int sum_array(vi &C, int start, int end, int step){
	int c = 0;
	rpd(i, start, end, step) c += C[i];
	return c;
}

bool is_pairwise(vi &A){
	int MAX_A = 1000000 + 1;
	vi C(MAX_A, 0); for(int a:A) C[a]++;
	if(sum_array(C, 2, MAX_A, 2) > 1) return false;
	rpd(i, 3, MAX_A, 2) if(sum_array(C, i, MAX_A, i) > 1) return false;
	return true;
}

int solve(vi &A){
	if(is_pairwise(A)) return 0;
	if(gcd_all(A) == 1) return 1;
	return 2;
}

int main(){
	int N; cin>>N;
	vi A(N); rpd(i, 0, N, 1) cin>>A[i];
	cout<< vector<string>{"pairwise","setwise","not"}[solve(A)] <<" coprime\n";
}


Measured memory_bytes: 11176
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  
  long long power = 1;
  
  for(int i = 1; i < N + 1; i++){
    power *= i;
    if(power > 1000000007){
      power = power % 1000000007;
    }
  }
  
  cout << power << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<complex>
#include<unordered_map>
#define deg(x) cout<<#x<<"="<<x<<endl;
#define fd(x) for(int i=0;i<x;i++)
#define fdd(a,x) for(int i=a;i<x;i++)
#define fx(x,n) for(int i=n-1;i>=x;i--)
#define mst(x) memset(x,0,sizeof(x));
#define fi first
#define se second
#define TB ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ok "ok"
#define HH puts("");
#define ls rt<<1
#define rs rt<<1|1
#define pb(a,b) a.push_back(b);
#define FIN  freopen("1.in","r",stdin);
#define FOUT freopen("1.out","w",stdout);
using namespace std;
typedef long long ll;typedef long long LL;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> pss;
typedef unsigned long long ull;
const ll mod=1e9+7;
const ll inf=1e9+7;
const long double eps=1e-8;
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
const double pi=acos(-1);
//__builtin_popcount
string s;
ll f1[203040],f2[203040];

int fun(int q){
    if(q==0) return 0;
    return 1+fun(q%__builtin_popcount(q));
}

int main()
{
    TB
    int n;
    cin>>n;
    cin>>s;
    ll m=count(s.begin(),s.end(),'1'),sum1=0,sum2=0,flag1=1,flag2=1;
    ll m1=m-1;ll m2=m+1;
    ll flog=0;
    if(m==1){
        m1++;flog=1;//deg(ok)
    }
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
            sum1+=flag1;
            sum2+=flag2;
            sum1%=m1;
            sum2%=m2;
        }
        f1[i]=flag1;
        f2[i]=flag2;
        flag1*=2;
        flag2*=2;
        flag1%=m1;flag2%=m2;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            if(flog){
                cout<<0<<'\n';
                continue;
            }
            ll ans=1,mo=(sum1-f1[i]+m1)%m1;
            ans+=fun(mo);
            cout<<ans<<'\n';
        }else{
            ll ans=1,mo=(sum2+f2[i]+m2)%m2;
            ans+=fun(mo);
            cout<<ans<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 6900
<?php
$n = trim(fgets(STDIN));
$as = explode(" ", fgets(STDIN));
$sum = 0;
$min = $max = (int)$as[0];
foreach($as as $a) {
    $a = (int)$a;
    $sum += $a;
    if($min>$a) $min = $a;
    if($max<$a) $max = $a;
}
printf("%d %d %d\n", $min, $max, $sum);


Measured memory_bytes: 10976
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo        \
    {              \
        no return; \
    }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false)
{
    vector<T> a = vector<T>(n + oneIndexed);

    for (ll i = 0; i < n; i++)
    {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }

    return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1)
{
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++)
    {
        // printf("%lu ", a[i]);
        cout << a[i] << " ";
    }
    cout << endl;
}

template <typename T, typename A>
void papair(vector<T, A> const &a, ll begin = 0, ll end = -1)
{
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++)
    {
        // printf("%lu ", a[i]);
        cout << a[i].first << " " << a[i].second << endl;
    }
}

void solve()
{

    string s;
    cin >> s;
    for (ll i = 0; i < s.length(); i++)
    {
        if (s[i] == '?')
            s[i] = 'D';
    }
    cout << s;
    // vector<ll> arr = ga(n);
}

int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // ll t;cin >> t;while(t--)
    solve();
    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(N);
  vector< ll > a(N);
  REP(i, N) {
    cin >> a[i];
    a[i] -= (i + 1);
  }

  sort(ALL(a));
  ll center = a[N / 2];
  ll ans = 0;
  REP(i, N) {
    ans += abs(a[i] - center); 
  }
  cout << ans << endl;

  

  return 0;
}



Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
A = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

n=input()<<A>>int
memo = {}
for i in range(n):
    x = input()<<A>>int
    if x in memo:
        memo[x] += 1
    else:
        memo[x] = 1;

ret = 0
for x in memo.values():
    ret += x % 2

print(ret)



Measured memory_bytes: 24156
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
    int a, b;
    scanf("%d %d", &a, &b);
    double da, db;
    da = double(a);
    db = double(b);
    printf("%d %d %f\n", a / b, a % b, da/db);
    return 0;
}



Measured memory_bytes: 3224
#include<iostream>

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    int num[n];
    rep(i, n) num[i] = 0;
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        num[a[i]]++;
        num[b[i]]++;
    }
    rep(i, n) cout << num[i] << endl;
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int cnt = 0;
int k;

template<typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}

void gen(int at, string cur, int len) {
  if (at == len) {
    cnt++;
    if (cnt == k) {
      cout << cur << endl;
      exit(0);
    }
    return;
  }
  int mi = 0;
  if (at == 0) mi = 1;
  for (int i = mi; i < 10; ++i) {
    if (at > 0 && abs(cur[at - 1] - '0' - i) > 1) {
      continue;
    }
    gen(at + 1, cur + string(1, '0' + i), len);
  }
}

int main()
{
  cin >> k;
  for (int len = 1; ; ++len) {
    gen(0, "", len);
  }

  return 0;
}


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

int main(){
	std::string s;
	std::cin>>s;
	
	int numW=0;
	long long begPos=0;
	long long endPos=0;

	for(int i=0; i<s.size(); i++){
		if(s[i]=='W'){
			numW++;
			begPos+=i;
		}
	}

	for(int i=0; i<numW; i++)
		endPos+= i;


	std::cout<<begPos-endPos<<std::endl;

	return 0;
}

Measured memory_bytes: 640
list_S = list(input())
n = len(list_S)
ans = 0
for i in range(n):
    list_S.pop(-1)
    for j in range(1, n-i):
        if "".join(list_S[:j]) == "".join(list_S[j:]):
            k = 2*j
            ans = max(ans, k)

print(ans)

Measured memory_bytes: 3060
module Main where

import Debug.Trace

main :: IO ()
main = do
  [a, _] <- map read . words <$> getLine
  s <- map read . words <$> getLine
  --a `traceShow`
  --(take 10 $ iterate (+1) 0) `traceShow`
  print $ solve a s

solve :: Int -> [Int] -> Int
solve a s = check a s (take 110 $ iterate (+1) 0)


check :: Int -> [Int] -> [Int] -> Int
check a s (p:ps)
  | not (a - p `elem` s) = a - p
  | not (a + p `elem` s) = a + p
  | otherwise = check a s ps


Measured memory_bytes: 4344
import heapq

class Dijkstra:
    """
        Dijkstra's algorithm: find the shortest paths from a vertex
        complexity:
            O(E + logV)
    """
    def __init__(self, V, E, start, INF=10**9):
        """
        :param V: the number of vertices
        :param E: adjacency list (all edge in E must be non negative)
        :param start: start vertex
        :param INF: Infinity distance
        """
        self.V = V
        self.E = E
        self.dijkstra(start, INF)

    def dijkstra(self, start, INF):
        que = list()
        self.distance = [INF] * self.V
        self.prev = [-1] * self.V
        self.distance[start] = 0
        heapq.heappush(que, (0, start))
        while len(que) > 0:
            dist, fr = heapq.heappop(que)
            if self.distance[fr] < dist:
                continue
            for to, cost in self.E[fr]:
                if self.distance[fr] + cost < self.distance[to]:
                    self.distance[to] = self.distance[fr] + cost
                    heapq.heappush(que, (self.distance[to], to))
                    self.prev[to] = fr

    def get_path(self, end):
        path = [end]
        while self.prev[end] != -1:
            end = self.prev[end]
            path.append(end)
            return path[::-1]


V = int(input())
edges = [[] for _ in range(V)]
for _ in range(V):
    u, _, *e = map(int, input().split())
    for t, d in zip(e[::2], e[1::2]):
        edges[u].append((t, d))

djk = Dijkstra(V, edges, 0)
for i, d in enumerate(djk.distance):
    print(i, d)


Measured memory_bytes: 6216
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int a,b,k;
	int i;
	int MaxK[101];
	int cnt=1;
	scanf("%d %d %d",&a,&b,&k);
	for(i=a; i>0; i--){
		if(a%i==0 && b%i==0){
			MaxK[cnt] = i;
			cnt++;
		}
	}
	printf("%d",MaxK[k]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long ans = 1;
  while (N != 0) {
    ans *= N;
    ans %= MOD;
    N--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, M;
	cin >> N >> M;

	vector<ll> H(N);
	REP(i, N) {
		cin >> H[i];
	}

	vector<vector<ll>>	G(N);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}

	ll ans = 0;
	REP(i, N) {
		bool isOk = true;
		for (auto gOne : G[i]) {
			if (H[i] <= H[gOne]) {
				isOk = false;
				break;
			}
		}
		if (isOk) {
			ans++;
		}
	}

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


Measured memory_bytes: 9860
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define INF 1e18
#define pi 3.1415926535897932384626433832795028841971

#define MAX 100005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	char ch;
	db aa,bb,cc;
	string s1,s2,s3,str;
    lli i,j,k,a,b,n,m,sum=0,ans=0,temp,t;
    cin >> n;
    lli arr[n];
    lli f[n+1];
    rep(i,0,n)	cin >> arr[i];
    rep(i,0,n+1)	f[i]=0;
    rep(i,0,n)	f[arr[i]]++;
    for(i=1;i<=n;i++){
    	a=f[i];
    	ans+=a*(a-1)/2;
	}
	for(i=0;i<n;i++){
		temp=ans;
		a=f[arr[i]];
		temp-=a*(a-1)/2;
		a--;
		temp+=a*(a-1)/2;
		cout << temp << endl;
	}
    
    
    return 0;
}

















/* UJJWAL KESHRI */

Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
# 整数の入力
import copy

a = int(input())
nums = [0]*a

for i in range(a):
    nums[i] = int(input())
    
maxnum = max(nums)
maxenum = [i for i, x in enumerate(nums) if x == maxnum]
maxquant = len(maxenum)


if maxquant != 1:
    for j in range(a):
        print(maxnum)
else:
    for j in range(a):
        if nums[j] != maxnum:
            print(maxnum)
        else:
            copylist = copy.deepcopy(nums)
            copylist[maxenum[0]] = 0
            print(max(copylist))

Measured memory_bytes: 20960
import math

n, a, b, c, d = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = input()
list = list(s)

#print(n, m)
#print(table)
#print(light)

flag = 1



#A-C B-Dまでの間に岩が2個並んでいたらアウト

for i in range(a-1, c-1) :
    if ( list[i] == '#') :
        if ( list[i+1] == "#") :
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "#") :
        if ( list[i+1] == "#") :
            flag = 0

# D < C　のとき、B-Dまでの間に、3個以上空白がなければアウト

if (d < c) :
    flag = 0
    for i in range(b-2, d-1) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

if (flag == 1) :
    print("Yes")
else :
    print("No")

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

#define MOD (long long)(1e9 + 7)
#define MAX 5000000

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<MOD>> _fact, _rfact, _inv;
  Combination(long long nsize = MAX)
      : _fact(nsize + 1), _rfact(nsize + 1),
        _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for(int i = 1; i <= nsize; i++)
      _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for(int i = nsize - 1; i >= 0; i--)
      _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= nsize; i++)
      _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<MOD> fact(int k) const { return _fact[k]; }

  inline ModInt<MOD> rfact(int k) const {
    return _rfact[k];
  }

  inline ModInt<MOD> inv(int k) const { return _inv[k]; }

  ModInt<MOD> P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<MOD> C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  ModInt<MOD> H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

long long r1, r2, c1, c2;
Combination com;

ModInt<MOD> solve();

int main() {
  cin >> r1 >> c1 >> r2 >> c2;
  cout << solve() << endl;
  return 0;
}

ModInt<MOD> solve() {
  return com.C(r1 + c1, r1) - com.C(r1 + c2 + 1, r1) -
         com.C(r2 + c1 + 1, r2 + 1) +
         com.C(r2 + c2 + 2, r2 + 1);
}

Measured memory_bytes: 58880
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<iomanip>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
	string t;
	cin>>t;
	if(t=="SUN")
	{
		cout<<"7"<<endl;
		return 0;
	}
	if(t=="MON")
	{
		cout<<"6"<<endl;
		return 0;
	}
	if(t=="TUE")
	{
		cout<<"5"<<endl;
		return 0;
	}
	if(t=="WED")
	{
		cout<<"4"<<endl;
		return 0;
	}
	if(t=="THU")
	{
		cout<<"3"<<endl;
		return 0;
	}
	if(t=="FRI")
	{
		cout<<"2"<<endl;
		return 0;
	}
	if(t=="SAT")
	{
		cout<<"1"<<endl;
		return 0;
	}
}

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

const int n = 39;

int main(){
	long a, b, c, d, ans;
	long x, y;
	cin >> a >> b;
	c = 1;
	ans = 0;
	for (int i = 0; i < n; ++i){c *= 2;}
	d = a%2 + (b-a)%4;
	if (d == 1 || d == 2) ans++;
	for (int i = 0; i < n; ++i){
		x = a / c; a %= c;
		y = b / c; b %= c;
		ans += ((x*(a%2) + y*((b+1)%2))%2)*c;
		c /= 2;
	}
	cout << ans;
}

Measured memory_bytes: 384
n = int(input())
ans = list()
while n>0:
    x = n % 26
    if x == 0:
        x = 26
        n=n-1
    ans.append(x)
    n = int(n / 26)


str_ans = ""
for x in ans[::-1]:
    str_ans += chr(x+96)

print(str_ans)

Measured memory_bytes: 9096