akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

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



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

void printOut(int *numArray, int listNum)
{
	int i;
	for (i = 0; i < listNum; i++) {
		if (i == listNum - 1) {
			printf("%d\n", numArray[i]);
		}
		else {
			printf("%d ", numArray[i]);
		}
	}
}

void insertionSort(int *A, int N)
{
	int i;
	for (i = 1; i <= N - 1; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;

		printOut(A, N);

	}
}

int main(int argc, char** argv)
{
	int N, i;
	int numlist[100];

	memset(numlist, '\0', sizeof(numlist));

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &numlist[i]);
	}

	printOut(numlist, N);
	insertionSort(numlist, N);
	return 0;
}

Measured memory_bytes: 600
n, m = map(int,input().split())
cards = [1 for _ in range(n)]
L = 0
R = n-1
for _ in range(m):
    l,r= map(lambda x: int(x) - 1,input().split())
    L = max(L,l)
    R = min(R,r)
    
print(max(0,R-L+1))

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
ll N, A[100000];
ll B[100000];
int main() {
	COME_LET_THE_GAMES_BEGIN();
	cin >> N;
	rep(i, N) {
		cin >> A[i];
		if (i == 0) {
			B[i] = A[i];
		}
		else {
			B[i] = B[i - 1];
			if (i % 2 == 0) {
				B[i] += A[i];
			}
			else {
				B[i] -= A[i];
			}
		}
	}
	rep(i, N) {
		if (i == 0) {
			cout << B[N - 1] << " ";
			continue;
		}
		ll ans = 0;
		if (i % 2 == 0) {
			ans += B[N - 1] - B[i - 1];
			ans -= B[i - 1];
		}
		else {
			ans -= B[N - 1] - B[i - 1];
			ans += B[i - 1];
		}
		cout << ans << ((i == N - 1) ? "\n" : " ");
	}
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
from itertools import combinations

n,k = map(int, input().split())

xl = []
yl = []
xy = []
for _ in range(n):
    x,y = map(int, input().split())
    xl.append(x)
    yl.append(y)
    xy.append((x,y))
yl.sort()
xy.sort(key=lambda x:x[1])

res = None
for cx in combinations(xl, 2):
    x1,x2 = cx
    if x2>x1:
        x1,x2 = x2,x1

    for y2 in yl:
        cnt = 0
        for c in xy:
            x,y = c
            if x1>=x>=x2 and y>=y2:
                cnt += 1

            if cnt==k:
                y1 = y
                s = (x1-x2)*(y1-y2)
                if res is None:
                    res = s
                else:
                    res = min(res, s)
                break

print(res)


Measured memory_bytes: 3064
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n=n0()
l=make_divisors(n)
l.sort()
m=len(l)
if m%2==1:
    print(l[m//2]*2-2)
else:
    print(l[m//2-1]+l[m//2]-2)

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef pair<int,int> p;
int main()
{
  int n,m,x,y;
  cin>>n>>m;
  vector<p> c(n+1),t(m+1);
  for(int i=1;i<=n;i++)
    {
      cin>>x>>y;
      c[i]=mp(x,y);
    }
  for(int i=1;i<=m;i++)
  {
    cin>>x>>y;
    t[i]=mp(x,y);
  }
  vector<int> ans(n+1);
  for(int i=1;i<=n;i++){
  int min_d=1e9,d;
    for(int j=1;j<=m;j++){
       d=abs(c[i].first-t[j].first)+abs(c[i].second-t[j].second);
       if(d<min_d)
         {
           ans[i]=j;
           min_d=d;
         }

     }
  }
  for(int i=1;i<=n;i++)
    cout<<ans[i]<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[100009][400];
int n;
long long w[1000];
long long v[1000];
long long solve(long long W,int i) {
    if (W<0)
        return INT_MIN;
    if(i==n||W==0)
       return 0;
   if(dp[W][i]!=-1)
       return dp[W][i];

   return dp[W][i] = max(solve(W,i+1),v[i]+solve(W-w[i],i+1));
}
int main() {
    memset(dp,-1,sizeof dp);
    long long W;
    scanf("%d%lld",&n,&W);
    for(int i=0;i<n;++i){
        scanf("%lld",w+i);
        scanf("%lld",v+i);
    }
    printf("%lld",solve(W,0));
}

Measured memory_bytes: 316232
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

const int N_MAX = 100001;
string S;
int N;
int C[N_MAX] = {};
int i = 0;
int idx = 0;
int R_NUM, L_NUM;


int main() {
	cin >> S;
	N = S.length();
	while (i < N-1) {
		idx = 0;
		while (S[i + idx] == S[i + 1 + idx]) {
			idx++;
			if ((i + idx) >= N) break;
		}
		idx++;
		R_NUM = idx;
		while (S[i + idx] == S[i + 1 + idx]) {
			idx++;
			if ((i + idx) >= N) break;
		}
		idx++;
		L_NUM = idx - R_NUM;
		C[i + R_NUM - 1] = ((R_NUM + (2 - 1)) / 2) + (L_NUM / 2);
		C[i + R_NUM] = ((L_NUM + (2 - 1)) / 2) + (R_NUM / 2);
		i += idx;
	}
	for (int i = 0; i < N; i++) {
		cout << C[i] << endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string s; cin >> s;
  for (int i = 0; i < (int)s.size(); i++) {
    if (i-1 >= 0 && s.at(i-1) == s.at(i)) {
      cout << i << " " << i+1 << endl;
      return 0;
    }
    if (i-2 >= 0 && s.at(i-2) == s.at(i)) {
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
  }
  cout << "-1 -1\n";

  return 0;
}



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


int main(){
	int N,A,B,C,D;

	std::cin >> N;
        A=N/1000;
	B=(N%1000)/100;
	C=((N%1000)%100)/10;
	D=((N%1000)%100)%10;
	if(A+B+C+D==7){
		std::cout << A << "+" << B << "+" << C << "+" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A-B+C+D==7){
		std::cout << A << "-" << B << "+" << C << "+" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A+B-C+D==7){
		std::cout << A << "+" << B << "-" << C << "+" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A+B-C-D==7){
		std::cout << A << "+" << B << "-" << C << "-" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A+B+C-D==7){
		std::cout << A << "+" << B << "+" << C << "-" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A-B-C-D==7){
		std::cout << A << "-" << B << "-" << C << "-" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A-B+C-D==7){
		std::cout << A << "-" << B << "+" << C << "-" << D << "=" << 7 << std::endl;
		return 0;
	}else if(A-B-C+D==7){
		std::cout << A << "-" << B << "-" << C << "+" << D << "=" << 7 << std::endl;
		return 0;
	}

} 

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


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> res(n);
	rep(i,n){
		res[a[i]-1] = i;
	}
	rep(i,n) cout << res[i]+1 << endl;
	return 0;
}


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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] inputString = br.readLine().split(" ");

            int locationX = Integer.parseInt(inputString[0]);
            int locationOfRestaurantA = Integer.parseInt(inputString[1]);
            int locationOfRestaurantB = Integer.parseInt(inputString[2]);

            int distanceAtoX = getDistanceXtoRestaurant(locationX, locationOfRestaurantA);
            int distanceBtoX = getDistanceXtoRestaurant(locationX, locationOfRestaurantB);

            String closerRestaurantIs = distanceAtoX >= distanceBtoX ? "B" : "A";

            System.out.println(closerRestaurantIs);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static int getDistanceXtoRestaurant(int locationX, int locationOfRestaurant) {
        return locationX >= locationOfRestaurant ? locationX - locationOfRestaurant : locationOfRestaurant - locationX;
    }
}

Measured memory_bytes: 21076
N=int(input())

t=x=y=0
judge=True
for i in range(N):
    in_t,in_x,in_y=map(int,input().split())
    dt=in_t-t
    dxy=abs(in_x-x)+abs(in_y-y)
    if dxy>dt or (dxy-dt)%2!=0: judge=False
    t=in_t
    x=in_x
    y=in_y

if judge: print("Yes")
else: print("No")


Measured memory_bytes: 3060
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let H = lines[1].split(/\s/).map((v) => v - 0);
    let dp = new Array(N).fill(Number.MAX_SAFE_INTEGER);
    dp[0] = 0;
    for (let n = 1; n < N; n++) {
        dp[n] = Math.min(dp[n], dp[n-1] + Math.abs(H[n] - H[n - 1]));
        if (n > 1)
        dp[n] = Math.min(dp[n], dp[n-2] + Math.abs(H[n] - H[n - 2]));
    }
    console.log(dp[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],b[N],v[N],bin[31],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	bin[0]=1;
	for(int i=1;i<=30;i++) bin[i]=bin[i-1]<<1;
	sort(b+1,b+n+1);
	for(int i=0;i<=29;i++){
		int now=0;
		for(int j=1;j<=n;j++){
			v[j]=b[j]&((1<<i+1)-1);
			//cout<<v[j]<<' ';
		}
		//cout<<endl;
		sort(v+1,v+n+1);
		for(int j=1;j<=n;j++){
			int x=a[j]&((1<<i+1)-1);
			int y1=max(bin[i]-x,0),y2=(bin[i+1]-x-1),p1=0,p2=0;
			p1=lower_bound(v+1,v+n+1,y1)-v;
			p2=upper_bound(v+1,v+n+1,y2)-v-1;
			now+=(p2-p1+1);
			int y3=(bin[i+1]+bin[i]-x),y4=bin[i+2],p3=0,p4=n;
			p3=lower_bound(v+1,v+n+1,y3)-v;
			now+=(p4-p3+1);
			//cout<<p1<<' '<<p2<<' '<<y1<<' '<<y2<<"  "<<p3<<' '<<p4<<' '<<y3<<' '<<y4<<endl;
		}
		//cout<<i<<' '<<now<<endl;
		if(now&1) ans+=(1<<i);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF = (1LL << 31) - 1;
const double EPS = 1e-9;

struct SegmentTree {
    const int INF = (1LL << 31) - 1;
    vector<int> node;
    int n;
    SegmentTree(vector<int> a) {
        int n_ = a.size();
        n = 1;
        while(n < n_) n <<= 1;
        node.resize(2 * n - 1, INF);
        for(int i = 0; i < n_; i++) {
            node[n - 1 + i] = a[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    void update(int i, int x) {
        i = n - 1 + i;
        node[i] = x;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }
    int find(int a, int b, int k = 0, int l = 0, int r = 0) {
        if (l >= r) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];

        int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N, INF);
    SegmentTree seg(A);
    for (int q = 0; q < Q; q++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.find(x, y + 1) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4740
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio;
    string s;
    int a,b;
cin>>a>>b;
    cout<<(((a*b)%2==0) ? "Even" : "Odd")<<'\n';
    return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
const int inf=1e9+7;
const int N=505;
int sol=inf;
int d[N][N],a[N][N],n,c;
int cnt[3][N];
void Try(int c1, int c2, int c3)
{
	int ans=0,i,j;
	for(i=1;i<=c;i++)
	{
		ans+=cnt[0][i]*d[i][c1];
		ans+=cnt[1][i]*d[i][c2];
		ans+=cnt[2][i]*d[i][c3];
	}
	/*for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if((i+j)%3==0)
			{
				if(a[i][j]!=c1) ans+=d[a[i][j]][c1]; 
			}
			else if((i+j)%3==1)
			{
				if(a[i][j]!=c2) ans+=d[a[i][j]][c2];
			}
			else
			{
				if(a[i][j]!=c3) ans+=d[a[i][j]][c3];
			}
		}
	}*/
	if(ans<sol) sol=ans;
}
int main()
{
	int i,j,k;
	scanf("%i %i",&n,&c);
	for(i=1;i<=c;i++)
	{
		for(j=1;j<=c;j++)
		{
			scanf("%i",&d[i][j]);
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%i",&a[i][j]);
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if((i+j)%3==0)
			{
				cnt[0][a[i][j]]++;
				//if(a[i][j]!=c1) ans+=d[a[i][j]][c1]; 
			}
			else if((i+j)%3==1)
			{
				cnt[1][a[i][j]]++;
				//if(a[i][j]!=c2) ans+=d[a[i][j]][c2];
			}
			else
			{
				cnt[2][a[i][j]]++;
				//if(a[i][j]!=c3) ans+=d[a[i][j]][c3];
			}
		}
	}
	for(i=1;i<=c;i++)
	{
		for(j=1;j<=c;j++)
		{
			for(k=1;k<=c;k++)
			{
				if(i==j || j==k || i==k) continue;
				Try(i,j,k);
			}
		}
	}
	printf("%i\n",sol);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int X; cin >> X;
    if (X >= 30) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(all(a));
    int dp[k+1]; // can win from k and can lose from k
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<a[0];i++) 
    {
        dp[i] = 0;
    }
    for(int i=a[0];i<=k;i++)
    {
        bool win = false;
        for(int j=0;j<n;j++)
        {
            if(a[j]>i) break;
            win = (win or !dp[i-a[j]]);
        }
        dp[i] = win;
    }
    if(dp[k])
        cout << "First\n";
    else cout << "Second\n";

    return 0;
}



Measured memory_bytes: 1024
H, W = map(int, input().split())

ans = 0
if H == 1 or W == 1:
    ans = 1
elif H % 2 == 0:
    ans = (W * H) // 2
else:
    ans = (W * (H - 1)) // 2 + (W + 1) // 2

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    map <int,int>mp;
    REP(i,n){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int answer=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second%2)answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<iostream>
#include<iomanip>
using namespace std;
long long n;
double a[3000], sum, dp[3000][3000];
int main(){
	cin >> n;
	for (int i=1;i<=n;i++) cin >> a[i];
	dp[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=n;j++)
			dp[i][j]=dp[i-1][j]*((double)1-a[i])+(j?dp[i-1][j-1]*a[i]:0);
	for (int i=n;i>=(n+1)/2;i--){
		sum+=dp[n][i];
	}
	cout <<fixed << setprecision(10)<< sum<<'\n';
}

Measured memory_bytes: 70528
package main

import (
    "fmt"
    "os"
    "bufio"
)

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    line := readLine(reader)
    arr := make([]int, 26)

    for _, v := range line {
        arr[v-97]++
    }

    for k, v := range arr {
        if v == 0 {
            fmt.Println(string(k + 97))
            return
        }
    }

    fmt.Println("None")
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 1280
N = gets.to_i
S = readlines.map {|s| s.chomp.chars.sort }

d = {}
ans = 0
(N-1).downto(0) do |i|
    d[S[i]] ||= 0
    d[S[i]] += 1
    ans += d[S[i]] - 1
end
puts ans

Measured memory_bytes: 77164
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>m>>n>>k;
	cout<<n/k-(m-1)/k;
}

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

using namespace std;
typedef long long ll;
const ll mod = 1000'000'007;
const ll maxn = 123456;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    ll ans = 1;
    map<char, int> mp;
    mp[s[0]]++;
    for (int i = 1; i < s.size(); ++i) {
        ans += i - mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}

string s;int n, a[110000],b[110000],c[110000],q[110000];
signed main(){
  cin>>s;n = s.length();
  rep(i,n){
    if(s[i] == 'A')a[i+1]++;
    else if(s[i] == 'B')b[i+1]++;
    else if(s[i] == 'C')c[i+1]++;
    else q[i+1]++;
  }
  repd(i,1,n+1){
    a[i] += a[i-1];
    b[i] += b[i-1];
    c[i] += c[i-1];
    q[i] += q[i-1];
  }
  int ans = 0;
  repd(i,1,n+1){
    if(s[i-1] == 'B' || s[i-1] == '?'){
      int l = (a[i-1]*modpow(3,q[i-1])%MOD + q[i-1]*modpow(3,q[i-1]-1)%MOD)%MOD,
          r = ((c[n]-c[i])*modpow(3, q[n]-q[i])%MOD + (q[n]-q[i])*modpow(3, q[n]-q[i]-1)%MOD)%MOD;
      ans = (ans + l*r%MOD)%MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int a[100010];
int sum[200010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    int normal = 0;
    rep(i, n - 1) normal += (a[i + 1] + m - a[i]) % m;
    rep(i, n - 1) {
        if (a[i] < a[i + 1]) {
            sum[a[i]+m + 1]++;
            sum[a[i + 1]+m + 1] += a[i + 1] - a[i] - 1;
            sum[a[i + 1]+m] -= a[i + 1] - a[i];
        } else {
            sum[a[i] + 1]++;
            sum[a[i]+m + 1]++;
            sum[a[i + 1]+m + 1] += a[i + 1]+m - a[i] - 1;
            sum[a[i + 1]+m] -= a[i + 1]+m - a[i];
        }
    }
    rep(j, 2) rep(i, m * 2) sum[i + 1] += sum[i];
    //rep(i, m * 2 + 1) cout << i << " " << sum[i] << endl;
    int ans = 0;
    REP(i, m, 2 * m) ans = max(ans, sum[i]);
    cout << normal - ans << endl;


    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void){
  int x,a,b;
  int n,kekka;
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  n=x-a;
  kekka=n-(n/b)*b;
  
  printf("%d",kekka);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

typedef long long ll;
ll h, w, a, b, ans, fac[N]{1}, inv[N];
ll M = 1e9 + 7;

ll pow(ll p, ll q) {
	ll re = 1;
	for (; q; q /= 2, p = p * p % M) re = re * (p * (q % 2) + !(q % 2)) % M;
	return re;
}

int main()
{
	ll i, t;
	cin >> h >> w >> a >> b;
	h--, w--;
	for (i = 1; i <= h + w; i++) fac[i] = fac[i - 1] * i % M;
	inv[h + w] = pow(fac[h + w], M - 2);
	for (i = h + w - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % M;
	for (i = b; i <= w; i++) {
		t = fac[i + h - a] * inv[i] % M;
		t = t * inv[h - a] % M;
		t = t * fac[w - i + a - 1] % M;
		t = t * inv[w - i] % M;
		t = t * inv[a - 1] % M;
		ans = (ans + t) % M;
	}
    cout << ans << endl;
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    vector<long long> S(n + 1, 0);
    unordered_map<long long, long long> mp;
    mp[0]++;
    for(int i = 1; i <= n; i++){
        S[i] = S[i - 1] + A[i - 1];
        mp[S[i]]++;
    }

    long long ans = 0;
    for(auto x : mp){
        ans += x.second * (x.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  string S, T;
  bool enough1()
  {
    size_t pos = 0;
    for (int i = 0; i < S.size(); i += 2) {
      pos = T.find_first_of(S[i], pos);
      if(pos == string::npos) {
        return false;
      }
      pos++;
    }
    return true;
  }

  bool enough2()
  {
    size_t pos = 0;
    for (int i = 1; i < S.size(); i += 2) {
      pos = T.find_first_of(S[i], pos);
      if (pos == string::npos) {
        return false;
      }
      pos++;
    }
    return true;
  }

  void solve(std::istream& in, std::ostream& out)
  {
    in >> S >> T;
    if(enough1() || enough2()) {
      out << "Yes\n";
    } else {
      out << "No\n";
    }
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}

Measured memory_bytes: 3200
N, K = map(int, input().split())
#組み合わせ -------------------------------------------------
mod = int(1e9+7) #適宜変更
Max = 2001 #適宜変更
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(K):
    i += 1 #iは1からkまで
    B_sla = Comb(K-1, i-1)
    R = N-K-(i-1)
    if R == 0:
        R_ire = 1
    elif R < 0:
        R_ire = 0
    else:
        R_ire = Comb(R+i, R)

    print(int(B_sla*R_ire%mod))

Measured memory_bytes: 3572
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

ll dp[404][404], a[404], sum[404];

ll slime(int x, int y) {
	if (dp[x][y]) return dp[x][y];
	if (x == y) return 0;
	if (x + 1 == y) return dp[x][y] = a[x] + a[y];

	ll mmin = min(slime(x + 1, y), slime(x, y - 1));
	for (int i = x + 1; i <= y - 1; i++) {
		mmin = min(mmin, slime(x, i) + slime(i + 1, y));
	}

	return dp[x][y] = mmin + sum[y] - sum[x - 1];
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		sum[i] = sum[i - 1] + a[i];
	}

	cout << slime(1, n);
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n,t,ans;
  ans=0;
  t=0;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
    t=max(t,h.at(i));
  }
  for(int i=0;i<t;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(j==0)
      {
        if(h.at(j)>0)
          ans++;
      }
      else
      {
        if(h.at(j)>0)
        {
          if(h.at(j-1)<=0)
            ans++;
        }
      }
    }
    for(int j=0;j<n;j++)
    {
      h.at(j)--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3552
import java.util.Scanner;

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

		String s1 = stdIn.next();
		String s2 = stdIn.next();

		boolean result = s2.startsWith(s1) && s2.length() - s1.length() == 1;

		System.out.println(result ? "Yes" : "No");

		stdIn.close();
	}
}


Measured memory_bytes: 35844
#include<bits/stdc++.h>
using namespace std;
int dp[2][401][401]={};
int main(){
  int n;
  cin>>n;
  int s[401],l[401],p[401];
  
  for(int i=0;i<n;i++)
    cin>>s[i]>>l[i]>>p[i];
  
  for(int i=0;i<n;i++){
    int nw=i%2;
    int nt=!nw;
    for(int j=0;j<400;j++)
      for(int k=0;k<400;k++)
	dp[nt][i][j]=0;
    for(int j=0;j<400;j++){
      for(int k=0;k<400;k++){
	int ny=min(s[i]+j,399);
	int nz=min(l[i]-s[i]+k,399);
	
	/*
	  if(i&&j-s[i-1]>=0&&k-(l[i-1]-s[i-1])>=0)
	  if(dp[i][j-s[i-1]][k-(l[i-1]-s[i-1])])
	    dp[i][j][k]=max(dp[i][j][k],dp[i][j-s[i-1]][k-(l[i-1]-s[i-1])]+p[i-1]);
	*/
	
	
	if(j+k==0){
	  dp[nt][ny][nz]=max(dp[nt][ny][nz],p[i]);
	  dp[nw][ny][nz]=max(dp[nw][ny][nz],dp[nw][j][k]+p[i]);
	}
	dp[nt][j][k]=max(dp[nt][j][k],dp[nw][j][k]);
	
	if(dp[nw][j][k]){
	  dp[nt][ny][nz]=max(dp[nt][ny][nz],dp[nw][j][k]+p[i]);
	  dp[nw][ny][nz]=max(dp[nw][ny][nz],dp[nw][j][k]+p[i]);
	}
      }
    }
  }
  int m,a[400],f=0;
  cin>>m;
  for(int i=0;i<m;i++){
    int w;
    cin>>w;
    int ans=0;
    for(int j=0;j<400;j++){
      for(int k=0;k<400;k++){
	if(j<=w&&j+k>=w)ans=max(ans,dp[n%2][j][k]);
      }
    }
    if(ans==0)f=1;
    a[i]=ans;
  }
  if(f)cout<<-1<<endl;
  else for(int i=0;i<m;i++)cout<<a[i]<<endl;
  return 0;
}



Measured memory_bytes: 4352
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int r1 = sc.nextInt();
		int c1 = sc.nextInt();
		int r2 = sc.nextInt();
		int c2 = sc.nextInt();
		Combination cmb = new Combination(r2 + c2 + 3);
		long ans = cmb.getComb(r2 + c2 + 2, r2 + 1) - cmb.getComb(r2 + c1 + 1, c1) - cmb.getComb(r1 + c2 + 1, r1) + cmb.getComb(r1 + c1, c1) + MOD + MOD; 
		ans %= MOD;
		System.out.println(ans);
   }

}

class Combination {
    static final int MOD = 1000000007;
    long[] fac;
    long[] finv;
    long[] inv;
    
    public Combination (int size) {
        fac = new long [size];
        finv = new long [size];
        inv = new long [size];
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < size; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    
    public long getComb(int n, int k) {
        if (n < k || n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
    
}



Measured memory_bytes: 70612
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int n; cin >> n;) {
		cout << 1 + n*(n + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
class RSQ:
    def __init__(self, length, ini_num = float("inf")):
        self.length = 1
        self.ini_num = ini_num
        if length == 1:
            length = 2
        while self.length < length:
            self.length <<= 1
        self.segtree = [ini_num] * (2 * self.length - 1)

    def update(self, index, num):
        leaf_index = index + self.length - 1
        self.segtree[leaf_index] = num
        while leaf_index > 0:
            leaf_index = (leaf_index - 1) // 2
            self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

    def add(self, index, num):
        leaf_index = index + self.length - 1
        self.segtree[leaf_index] += num
        while leaf_index > 0:
            leaf_index = (leaf_index - 1) // 2
            self.segtree[leaf_index] = self.segtree[2 * leaf_index + 1] + self.segtree[2 * leaf_index + 2]

    def call_search(self, a, b):
        return self.search(a, b, index = 0, l = 0, r = self.length - 1)

    def search(self, a, b, index, l, r):
        if r < a or b < l:
            return self.ini_num            
        elif a <= l <= r <= b:
            return self.segtree[index]
        else:
            return self.search(a, b, index * 2 + 1, l, (l + r) // 2) + self.search(a, b, index * 2 + 2, (l + r) // 2 + 1, r)

v_num, query = map(int, input().split(" "))
rsq = RSQ(v_num, 0)
for _ in range(query):
    comm, index, num = map(int, input().split(" "))
    if comm == 0:
        rsq.add(index - 1, num)
    else:
        print(rsq.call_search(index - 1, num - 1))

Measured memory_bytes: 12912
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val drink = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }.sortedBy { it[0] }
    var count = 0
    var money = 0L
    drink.forEach {
        if(count + it[1] < m){
            money += it[0] * it[1].toLong()
            count += it[1]
        }else{
            money += it[0] * (m-count).toLong()
            count = m
        }
    }
    println(money)
}

Measured memory_bytes: 86536
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x3,y3=map(int,input().split())
s=abs((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))
a=((x1-x2)**2+(y1-y2)**2)**0.5
b=((x2-x3)**2+(y2-y3)**2)**0.5
c=((x3-x1)**2+(y3-y1)**2)**0.5
r=s/(a+b+c)
print(max(a,b,c)*r/(2*r+max(a,b,c)))

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
    long long int N, M;
    cin >> N >> M;
    
    long long int ans=0;
    if(N*2<=M) {
        ans += N;
        M -= N*2;
        
        ans += M/4;
    } else {
        ans += M/2;
    }

    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=0;i<b;i++)
#define REP(i,a,b) for(int i=0;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout <<(f?"Yes":"No")<<endl//fが真の場合Yesを出力、偽の場合Noを出力
#define yes(f) cout <<(f?"yes":"no")<<endl
#define YES(f) cout <<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())

using namespace std;

const int mod=1e9+7;

signed main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ans=0;
    rep(i,n)
    {
        if(k>0)ans+=x;
        else ans+=y;
        k--;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    B = [False] * (N + 1)

    for i, a in reversed(list(enumerate(A, 1))):
        tmp = 0
        for j in range(2 * i, N + 1, i):
            tmp ^= B[j]
        B[i] = a ^ tmp

    ans = [i for i in range(1, N + 1) if B[i]]
    print(len(ans))
    if len(ans) > 0:
        print(' '.join(map(str, ans)))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 111524
n,k = map(int,input().split())
s = input()

L = []
from itertools import groupby
for key ,value in groupby(s):
    L.append((key,len(list(value))))
#print(L)
c = []
for i in range(len(L)):
    c.append(L[i][1])
c = [0] + c

for i in range(1,len(c)):
    c[i] +=c[i-1]
#print(c)
l = 0 
r = 2*k

ans = 0
while True:
    if L[l][0] == "1":
        if l + r +1 < len(L):
            ans = max(ans,c[l+r+1] - c[l])#add 5
        else:
            ans = max(ans,c[len(L)] - c[l])
    elif L[l][0] == "0":
        if l + r < len(L):
            ans = max(ans,c[l+r] - c[l])#add 4
        else:
            ans = max(ans,c[len(L)] - c[l])
    if l == len(L)-1:
        break
    l +=1
print(ans)

Measured memory_bytes: 19984
N=int(input())
    
for i in range(1,3500):
    for j in range(1,3500):
        a=N*i*j
        b=4*i*j-N*j-N*i
        if b>0:
            if (a/b).is_integer()==True:
                print(i,j,int(a/b))
                exit()

Measured memory_bytes: 9080
import sys
def input(): return sys.stdin.readline().strip()


class UnionFind():
    """
    https://note.nkmk.me/python-union-find/
    DFSの上位互換と考えて良い
    ２要素x, yがpath-connectedかどうかをlogオーダーで判定する（螺旋本の14.1節参照）
    さらに連結成分の要素数がO(1)で取得可能なように改造してある
    """
    def __init__(self, n):
        """
        要素数をnとして、各ノードを0,1,...,(n-1)の番号で管理する
        parentsは各ノードの属する木の根を表す
        ただし根ノードのparentには(その木のノード数)*(-1)を格納する
        """
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        xの属する木の根を返す
        このとき同時に経路圧縮して、探索途中のノードを全て根に繋ぎ直す
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        x, yのそれぞれ属する木Tx, Tyの根同士を繋ぐ
        このとき木の要素数が小さい方を大きい方に繋ぐ（rankではなくsizeを用いる）
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """
        xの属する木の要素数を返す
        根の親を要素数の(-1)倍で定めておいたおかげでO(1)で取得可能
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        xとyがpath-connectedかを判定する
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """
        xの属する木の要素を列挙する
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """
        連結成分の代表元のリストを返す
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """
        連結成分の個数を返す
        """
        return len(self.roots())

    def all_group_members(self):
         """
         連結成分およびそれぞれの代表元をまとめた辞書を返す
         代表元がキーになってる
         """
         return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """
        連結成分およびその代表元を出力
        """
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = map(int, input().split())
    P = list(map(int, input().split()))
    invP = [0] * N
    for i, x in enumerate(P): invP[x - 1] = i
    tree = UnionFind(N)
    for _ in range(M):
        x, y = map(int, input().split())
        tree.union(x-1, y-1)

    """
    i番の数字とi番の場所がpath-connectedだったらP[i]=iは実現可能。
    これを全ての頂点に関して実現可能な気がする。
    """

    ans = 0
    for i in range(N):
        if tree.same(i, invP[i]): ans += 1
    print(ans)




if __name__ == "__main__":
    main()


Measured memory_bytes: 85640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

x, y = MAP()


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, int(y/2)) ** 2 % mod
    else:
        return power(x, int((y-1)/2)) ** 2 * x % mod
# nCaとしたときのaのmaxがa_max
a_max = 10 ** 6
# a, bの最大値+2
fact = [1] * (a_max + 2)
# 逆元
for i in range(1, a_max + 1):
    fact[i] = (fact[i-1] * i) % mod
# combination
def C(n, a):
    tmp = 1
    for i in range(n, n-a, -1):
        tmp = (tmp * i) % mod
    return tmp * power(fact[a], mod - 2)


if (x + y) % 3 != 0:
    print(0)
else:
    A =  (2 * x - y) // 3
    B = (-x + 2 * y) // 3
    # ここも必要
    if A < 0 or B < 0:
        print(0)
    else:
        N = A + B
        print(C(N, A) % mod)



Measured memory_bytes: 44868
import sys

n = int(input())
d_list = [num for num in map(int, input().split(' '))]

# print(n)
# print(d_list)

ans = 0

d_max = max(d_list)
layer = [0] * (d_max+1)
touri = [0] * (d_max+1)

if d_list[0] != 0:
  print(0)
  sys.exit()
else:
  layer[0] = 1

for i in range(1, n):
  d = d_list[i]
  if d == 0:
    print(0)
    sys.exit()
  layer[d] += 1

touri[0] = 1
for i in range(1, len(layer)):
  count = layer[i]
  prev_count = layer[i-1]
  
  if prev_count == 1:
    touri[i] = 1
    continue
  
  if count == 1:
    touri[i] = prev_count
    continue
  
  touri[i] = prev_count ** count
    
ans = 1
for i in touri:
  ans = (ans * i) % 998244353
  
# print(layer)
# print(touri)
print(ans)


Measured memory_bytes: 53356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int d = in.nextInt();
			int e = in.nextInt();
			int f = in.nextInt();
			Set<Integer> waters = new HashSet<>();
			Set<Integer> sugars = new HashSet<>();
			for (int i = 0; i <= f; i++) {
				for (int j = 0; j <= f; j++) {
					if ((100*i*a+100*j*b) <= f) {
						waters.add(100*i*a+100*j*b);
					}
					if ((i*c+j*d) <= f) {
						sugars.add(i*c+j*d);
					}
				}
			}

			double ans = 0;
			int answa = 0;
			int anssu = 0;

			for (int wa : waters) {
				for (int su : sugars) {
					if (wa + su > f || e * wa < su * 100 || wa + su == 0) {
						continue;
					}
					if (ans <= (100 * su/((double)wa+su))) {
						ans = (100 * su/((double)wa+su));
						answa = wa;
						anssu = su;
					}
				}
			}
			System.out.println((answa+anssu) +" " + anssu);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 27076
l = list(input())
N = int("".join(l))
L = len(l)
if L == 1:
  t = N
elif L == 2:
  t = 9
elif L == 3:
  t = N - 90
elif L == 4:
  t = 909
elif L == 5:
  t = N - 9090
else:
  t = 90909
print(t)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
const int mod=1e9+7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int k, D[maxn], vis[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>k;
    deque<int>Q;
    Q.push_front(1);
    D[1]=1, vis[1]=1;
    while(sz(Q))
    {
        int v=Q.front();
        Q.pop_front();
        if(!vis[(v*10)%k] || D[v] < D[(v*10)%k])
        {
            Q.push_front((v*10)%k);
            D[(v*10)%k]=D[v];
            vis[(v*10)%k]=1;
        }
        if(!vis[(v+1)%k] || D[v]+1 < D[(v+1)%k])
        {
            Q.push_back((v+1)%k);
            D[(v+1)%k]=D[v]+1;
            vis[(v+1)%k]=1;
        }
    }
    cout<<D[0];
    return 0;
}


Measured memory_bytes: 1280