akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,w;cin>>n>>w;
    vector<int> arrw(n),arrv(n);for(int i=0; i<n; i++)cin>>arrw[i]>>arrv[i];

    vector<vector<long> > dp(n+1,vector<long> (w+1));
    for(int i=1; i<=n; i++){
      for(int j=1; j<=w; j++){
        if(arrw[i-1]<=j)
        dp[i][j] = max(dp[i][j-1],max(dp[i-1][j],arrv[i-1]+dp[i-1][j-arrw[i-1]]));
        else
        dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
      		
      }

    }
    cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 80256
# Dinic's algorithm by @yaketake08
# https://tjkendev.github.io/procon-library/python/max_flow/dinic.html
from collections import deque
INF = 10**30
class Dinic:
	def __init__(self, n):
		self.n = n
		self.g = [[] for i in range(n)]

	def add_edge(self, fr, to, cap):
		forward = [to, cap, None]
		forward[2] = backward = [fr, 0, forward]
		self.g[fr].append(forward)
		self.g[to].append(backward)

	def add_bidirectional_edge(self, v1, v2, cap1, cap2):
		edge1 = [v2, cap1, None]
		edge1[2] = edge2 = [v1, cap2, edge1]
		self.g[v1].append(edge1)
		self.g[v2].append(edge2)

	def bfs(self, s, t):
		self.level = level = [None]*self.n
		deq = deque([s])
		level[s] = 0
		g = self.g
		while deq:
			v = deq.popleft()
			lv = level[v] + 1
			for w, cap, _ in g[v]:
				if cap and level[w] is None:
					level[w] = lv
					deq.append(w)
		return level[t] is not None

	def dfs(self, v, t, f):
		if v == t:
			return f
		level = self.level
		for e in self.it[v]:
			w, cap, rev = e
			if cap and level[v] < level[w]:
				d = self.dfs(w, t, min(f, cap))
				if d:
					e[1] -= d
					rev[1] += d
					return d
		return 0

	def flow(self, s, t):
		flow = 0
		g = self.g
		while self.bfs(s, t):
			*self.it, = map(iter, self.g)
			f = INF
			while f:
				f = self.dfs(s, t, INF)
				flow += f
		return flow

n = int(input())
a = [-1] + list(map(int, input().split()))
d = Dinic(n+2)
s, t = 0, n+1

for i in range(1, n+1):
	if a[i] > 0:
		d.add_edge(i, t, a[i])
	elif a[i] < 0:
		d.add_edge(s, i, -a[i])
	for j in range(2*i, n+1, i):
		d.add_edge(i, j, INF)

res = d.flow(s, t)
print(sum([x for x in a if x>0]) - res)

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
//void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){char c;cin>>c;string s="aiueo";if(s.find(c)!=string::npos)cout<<"vowel"<<endl;else cout<<"consonant"<<endl;}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){ll A,B;char op;cin>>A>>op>>B;if(op=='+')cout<<A+B<<endl;else cout<<A-B<<endl;}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){string s;cin>> s;cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14)<<endl;}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
void solve(){ll A,B,C,D;cin>>A>>B>>C>>D;cout<<max(A*B,C*D)<<endl;}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    while(scanf("%d%d",&x,&y)==2)
    {
        if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
        {
            printf("Yes\n");
        }
        else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
        {
             printf("Yes\n");
        }
        else if(x == 2 && y==2)
        {
             printf("Yes\n");
        }
        else
        {
             printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int flag=0;

        for(int i=1;i<=n;++i){
            if(i%3==0){
                System.out.print(" "+i);
            }else{
                char[] c=String.valueOf(i).toCharArray();
                for(int j=0;j<c.length;j++){
                    if(c[j]=='3'){
                        flag=1;
                    }
                }
                if(flag==1){
                    System.out.print(" "+i);
                    flag=0;
                }
            }
        }
        System.out.println();
        sc.close();
    }
}



Measured memory_bytes: 29100
#include <iostream>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int A,B,C,D;
	while(cin>>A>>B>>C>>D)
	{
		int ta=max(A,C),tc=min(B,D);
		if(tc-ta<0)
			ta=0;
		else
			ta=tc-ta;
		cout<<ta<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 888
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        //var num = ToInt32(ReadLine());
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine((int)Ceiling((double)ar[0] / 2) >= ar[1] ? "YES" : "NO");
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 11092
#include <iostream>


int main(void){

	int n, x;
	std::cin >> n >> x;

	int* m = new int[n];

	int cnt = 0;
	int min = 1001;
	for(int i = 0; i < n; i++){

		std::cin >> m[i];

		cnt++;
		x -= m[i];

		if(min > m[i]){
			min = m[i];
		}
	}

	while(x - min >= 0){
		cnt++;
		x -= min;
	}

	std::cout << cnt << std::endl;

	delete[] m;

	return 0;
}

Measured memory_bytes: 256
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
import sys
sys.setrecursionlimit(10**6)

n,m=sep()
ar=lis()
ar.sort(reverse=True)
k=ar[m-1]
if k>=((sum(ar)/(4*m))):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61824
#include<bits/stdc++.h>
using namespace std;
long long Pow(long long a,int b)
{
	long long mul=1;
	for(int i=1;i<=b;i++)
	mul*=a;
	return mul;
}
int main()
{
	int x;
	scanf("%d",&x);
	for(long long i=-300;i<=300;i++)
	for(long long j=-300;j<=300;j++)
	if(Pow(i,5)-Pow(j,5)==x){
		printf("%lld %lld",i,j);
		return 0;
	}
}

Measured memory_bytes: 3820
import sys
input=sys.stdin.readline
n,s=int(input()),input()

cnt=0
flag1=[]
ans=[]
for i in range(n-2):
    flag2=[]
    if s[i] in flag1:continue
    flag1.append(s[i])
    for j in range(i+1,n-1):
        if s[j] in flag2:continue
        flag2.append(s[j])
        for k in range(j+1,n):
            ans.append(s[i]+s[j]+s[k])
#print(ans,flag1,flag2)
print(len(set(ans)))


Measured memory_bytes: 227316
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define Rep(i,n)        for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

int main()
{
    LL n;
    cin>>n;


    LL sum=0;

    for(int i=1;i<=n;i++)
    {
        if(i%5!=0 && i%3!=0)
            sum+=i;
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3636
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {

            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            Console.WriteLine((a * b).ToString());
        }

    }

Measured memory_bytes: 17872
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

vector<bool> create_is_prime_table(uint64_t max_value) {
  vector<bool> is_prime(max_value + 1, true); // max_valueまでの素数表
  is_prime[0] = false;
  is_prime[1] = false;
  for (uint64_t i = 2; i <= max_value; ++i) {
    if (not is_prime[i]) continue;
    for (uint64_t j = i * i; j <= max_value; j += i) {
      is_prime[j] = false;
    }
  }

  return is_prime;
}


int main() {
  uint64_t N;
  cin >> N;
  
  if (N < 2) {
    cout << "0" << endl;
    return 0;
  }

  uint64_t sqrtN = uint64_t(floor(sqrt(N)));

  auto is_prime = create_is_prime_table(sqrtN + 1);

  uint64_t operation_cnt = 0;

  uint64_t N_divided = N;
  for (uint64_t i = 2; i <= sqrtN; ++i) {
    if (not is_prime[i]) continue;
    if (N_divided < i) break;
    uint64_t powered_factor = i;
    while (N_divided % powered_factor == 0) {
      operation_cnt += 1;
      N_divided /= powered_factor;
      powered_factor *= i;
    }
  }

  cout << (operation_cnt + (N_divided > sqrtN ? 1 : 0)) << endl;

  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
 
using namespace std;
const int maxn = 50 + 1, mod = 1e9 + 7;
 
int n;
 
struct matrix{
    int c[maxn][maxn];
    void init()
    {
        for(int i=1; i<=n; ++i)
            for(int j=1; j<=n; ++j) c[i][j] = 0;
    }
};
 
matrix cs;
long long k;
 
matrix mul(matrix a, matrix b)
{
    matrix t; t.init();
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=n; ++j) 
            for(int k=1; k<=n; ++k) 
        t.c[i][j] = (t.c[i][j] + (1LL*a.c[i][k]*b.c[k][j]) % mod) % mod;
    return t;
}
matrix power(long long b)
{
    if (b == 1) return cs;
    matrix t = power(b/2);
    t = mul(t, t);
    if (b&1) t = mul(t, cs);
    return t;
}
 
int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=n; ++j) cin >> cs.c[i][j];
    long long ans = 0;
    matrix a = power(k);
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=n; ++j) ans = (ans + a.c[i][j]) % mod;
    cout << ans;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mod 100000000
typedef long long int ll;
typedef long double ld;
using namespace std;

string KStones(int *moves, int n, int k) {
  bool dp[k + 1];
  memset(dp, false, sizeof(dp));
  for (int i = 1; i < k + 1; i++) {
    for (int j = 0; j < n; j++) {
      int it = moves[j];
      if (it > i)
        continue;
      if (!dp[i - it])
        dp[i] = 1;
    }
  }
  if (dp[k])
    return "First";
  return "Second";
}

int main() {
  int n, k;
  cin >> n >> k;
  int *moves = new int[n];
  for (int i = 0; i < n; i++)
    cin >> moves[i];
  cout << KStones(moves, n, k) << endl;
  return 0;
}


Measured memory_bytes: 384
# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    solve()


def solve():
    N, K = map(int, input().split())

    total = 0
    for i in range(K, N+1):
        minn = (i-1) * i // 2
        maxn = (N * (N+1) // 2) - ((N-i) * (N-i+1) // 2)
        total += maxn - minn + 1
        total %= 10**9 + 7

    total += 1

    print(total)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    ll H;
    cin >> H;
    ll ans = 0;
    ll p = 1;//モンスターの数
    while(H) {
        ans += p;
        if(H == 1) break;
        H /= 2;
        p *= 2;
    }
    cout << ans << endl;
    return 0;
}


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

int N;
char table[0x100];
string ws[109];
string encoded[109];
int ls[109];
string input;

vector<int> prev[309];
int ans[309];
int p;

void solve(){
	int len = input.length();
	for(int i=0; i<len; i++){
		for(int j=0; j<N; j++){
			if(i + ls[j] <= len && input.substr(i,ls[j]) == encoded[j]){
				prev[i+ls[j]].push_back(j);
			}
		}
	}
}

void dfs(int pos){
	if(pos<=0){
		for(int i=p-1; i>=0; i--){
			printf("%s%s",ws[ans[i]].c_str(),i?" ":".\n");
		}
		return ;
	}
	if(prev[pos].empty()){
		return ;
	}

	for(int i=0; i<(int)prev[pos].size(); i++){
		ans[p++] = prev[pos][i];
		dfs(pos - ls[prev[pos][i]]);
		p--;
	}
	return ;
}

string translate(string str){
	for(int i=0, len=str.length(); i<len; i++){
		str[i] = table[str[i]];
	}
	return str;
}

void init(){
	for(int i=0; i<309; i++) prev[i].clear();
	p = 0;
	for(int i=0; i<N; i++){
		ls[i] = ws[i].length();
		encoded[i] = translate(ws[i]);
	}
}

int main(){
	table['a'] = table['b'] = table['c'] = '2';
	table['d'] = table['e'] = table['f'] = '3';
	table['h'] = table['i'] = table['g'] = '4';
	table['j'] = table['k'] = table['l'] = '5';
	table['m'] = table['n'] = table['o'] = '6';
	table['p'] = table['q'] = table['r'] = table['s'] = '7';
	table['t'] = table['u'] = table['v'] = '8';
	table['w'] = table['x'] = table['y'] = table['z'] = '9';

	while(scanf("%d ",&N),N){
		char buf[1025];
		for(int i=0; i<N; i++){
			scanf("%s ",buf);
			ws[i] = string(buf);
		}
		scanf("%s ",buf);
		input = string(buf);
		init();
		solve();
		dfs((int)input.length());
		puts("--");
	}
	return 0;
}

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

int dx[4]={1,-1,0,0};

int h,w,n;
int cnt;
int a[100005];
int ans[105][105];

void dfs(int x,int y,int l,int f){
	ans[x][y]=a[l];
//	cout<<x<<" "<<y<<" "<<l<<endl;
	if(l==h*w)return;
	int xx=x+dx[f];
	if(xx<=h&&xx>0)dfs(xx,y,l+1,f);else dfs(x,y+1,l+1,f^1);
}

int main(){
	cin>>h>>w>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		while(x--){
			a[++cnt]=i;
		}
	}
	dfs(1,1,1,0);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cout<<ans[i][j]<<" ";
		cout<<endl;
	}
}

Measured memory_bytes: 384
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    cnt = 0
    mx = A[0]
    for i in range(1,N):
        if A[i] > mx:
            mx = A[i]
        else:
            cnt += mx - A[i]
    
    print(cnt)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 94148
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720368ll;
void solve()
 { 
  int n;
  string s;
  cin>>n>>s;
  cout<<(n<3200 ? "red" : s);
 }
signed main()
 {
 
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int fun(char *);
int fun(char *s)
{
    int ans=0;
    int i;
    for(i=1;s[i]!='\0';i++)
    {
        if(s[i]!=s[i-1])
        {
            ans++;
        }
    }
    return ans;
}
int main()
{
    char a[100001];
    scanf("%s",a);
    printf("%d\n",fun(a));
    return 0;
}

Measured memory_bytes: 256
def A():
    c = input()
    print(chr(ord(c)+1))

def B():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    K = temp[1]
    M = temp[2]
    A = [int(k) for k in input().split()]
    ans = M*N - sum(A)
    if ans <= K:
        print(max(0, ans))
    else:
        print(-1)

from collections import defaultdict
def C():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    M = temp[1]
    penal = defaultdict(int)
    P = []
    S = []
    for i in range(M):
        temp = input().split()
        P.append(int(temp[0]))
        S.append(temp[1])
    ac_problems = set()

    for i in range(M-1, -1, -1):
        if P[i] not in ac_problems and S[i] == 'AC':
            ac_problems.add(P[i])
        elif P[i] in ac_problems:
            if S[i] == 'WA':
                penal[P[i]] += 1
            elif S[i] == 'AC':
                penal[P[i]] = 0
    
    print(len(ac_problems), sum(penal.values()))

def D():
    temp = [int(k) for k in input().split()]
    H = temp[0]
    W = temp[1]
    S = []
    for i in range(H):
        S.append(input())
    ans = 0
    directions = [(-1, 0), (0, -1), (1, 0), (0, 1)]
    def bfs(x, y):
        to_visit = [(x, y, 0)]
        visited = set()
        ret = 0
        while to_visit:
            x, y, distance = to_visit[0]
            del to_visit[0]
            if (x, y) in visited:
                continue
            visited.add((x, y))
            ret = max(distance, ret)
            for d in directions:
                if x+d[0] < H and x+d[0] >= 0:
                    if y+d[1] < W and y+d[1] >= 0:
                        if (x+d[0], y+d[1]) not in visited:
                            if S[x+d[0]][y+d[1]] == '.':
                                to_visit.append((x+d[0], y+d[1], distance+1))
        #print(memo)
        return ret

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                ans = max(bfs(i, j), ans)
                
    #print(memo)

    print(ans)

D()

Measured memory_bytes: 3444
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C, D = MAP()

S = input()

if S[A:max(C, D)].count("##") >= 1:
    print("No")
    exit()

if C < D:
    print("Yes")
    exit()

if S[B-2:D+1].count("...") >= 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5716
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import deque

N, K = mi()
D = list(map(str, sys.stdin.readline().split()))

for num in range(N, N*10+1):
    flag = 1
    s = str(num)
    for i in range(K):
        if s.count(D[i]):
            flag = 0
            break
    if flag:
        print(num)
        exit()

Measured memory_bytes: 3368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const ll INF = 1LL<<60;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> res;
  res.emplace_back(a[0]);
  for (int i = 1; i < n; ++i) {
    int itr = lower_bound(rall(res), a[i]) - res.rbegin();
    if (itr == 0) res.emplace_back(a[i]);
    else res[res.size() - itr] = a[i];
    // for (auto x:res) debug(x);
    // debug(itr, a[i]);
    // debug();
  }
  cout << res.size() << endl;
  return 0;
}

Measured memory_bytes: 2168
n,x=map(int,input().split())
a=list(map(int,input().split()))
ret=0
if a[0]>x:
  ret+=a[0]-x
  a[0]-=a[0]-x
for i in range(n-1):
  if a[i+1]+a[i]>x:
    ret+=a[i+1]+a[i]-x
    a[i+1]-=a[i+1]+a[i]-x
print(ret)

Measured memory_bytes: 14068
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        W: i64,
        A: i64,
        B: i64,
    }
    println!("{}", max(0, (A-B).abs() - W));
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;


int main()
{
  int A, B;
  cin >> A >> B;

  int score = 0;

  if(A >= B){
    score += A;
    A -= 1;
  }
  else{
    score += B;
    B -= 1;
  }

  score += max(A,B);

  cout << score << endl;

  return 0;
}


Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v > w:
    print("YES" if abs(a - b) / (v - w) <= t else "NO")
elif w > v:
    print("NO")
else:
    print("YES" if abs(a - b) == 0 else "NO")

Measured memory_bytes: 9188
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    s=to_string(n);
    rep(i,Size(s))cnt+=(s[i]-'0');
    if(n%cnt==0)Cout("Yes");
    else Cout("No");
    return 0;
}


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

int N;
void solve(){
    vector<pair<int,int> >R;

    while(N--){
        int p;scanf("%d",&p);
        vector<int>V;

        for(int i=0;i<10;i++){
            int a,b;
            scanf("%d",&a);
            V.push_back(a);
            if(a!=10||i==9){
                scanf("%d",&b);
                V.push_back(b);
            }
            if(a+b>=10&&i==9){
                int c;
                scanf("%d",&c);
                V.push_back(c);
            }
        }
        int ans=0,cur=0;
        for(int i=0;i<9;i++){
            ans+=V[cur];
            if(V[cur]==10){
                ans+=V[cur+1]+V[cur+2];
            }
            else{
                cur++;
                ans+=V[cur];
                if(V[cur-1]+V[cur]==10)ans+=V[cur+1];
            }
            cur++;
        }
        while(cur<V.size())ans+=V[cur++];
        R.push_back(pair<int,int>(ans,9999-p));
    }
    sort(R.rbegin(),R.rend());

    for(int i=0;i<R.size();i++)printf("%d %d\n",-(R[i].second-9999),R[i].first);
}

int main(){
    while(scanf("%d",&N),N)solve();
    return 0;
}

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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}

using namespace std;
pair<ll,ll>arr[2003];
ll dp[2003][2003];   
ll n,x;
ll solve(ll l, ll r)
{
	if (l > r) return 0;
    if(dp[l][r] != -1) return dp[l][r];
    
    ll idx = n - (r - l + 1) + 1;
    ll a =  (ll)abs(arr[idx].second - l) * arr[idx].first + solve(l+1,r);
    ll b = (ll)abs(arr[idx].second - r) * arr[idx].first + solve(l,r-1);
    
    return dp[l][r] = max(a,b);
} 
int main() 
{	
	fast;
	 cin>>n;
	for(ll i = 1; i <= n; i++)
	{
		cin>>x;
		arr[i] = {x,i};
	}
	sort(arr+1,arr+n+1);
	reverse(arr+1,arr+n+1);
	memset(dp,-1,sizeof(dp));
	cout << solve(1,n) << endl;
	return 0;
}

Measured memory_bytes: 35076
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ld N,K;
	ld result=0;
	cin>>N>>K;
	FOR(i,1,N){
		ll n=0;
		while(pow(2,n)<K/(ld)i){
			n++;
		}
		result+=pow((ld)(0.5),n);
	}
	result/=N;
	cout << result << "\n";
	return;
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if (0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

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


X, Y, Z = inp_list()
print(Z, X, Y)


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int n;
		cin >> n;
		int flag=0;
		while(n>0)
		{
			int rem = n%10;
			if(rem==7)
			{
				flag=1;
				break;
			}
			n = n/10;
		}
		if(flag==1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}


Measured memory_bytes: 3656
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static long B;
  static long C;
  static double min = 9999999;
  static long ans = 0;




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

    int N = scanner.nextInt();
    int M = scanner.nextInt();

    int[] map = new int[M];

    int[] sa = new int[M - 1];

    for (int i = 0; i < M; i++) {
      map[i] = scanner.nextInt();
    }
    Arrays.sort(map);
    for (int i = 0; i < M - 1; i++) {
      sa[i] = map[i + 1] - map[i];
    }
    Arrays.sort(sa);

    int total = 0;
//    for (int i = 0; i < M - 1; i++) {
//      System.out.println(sa[i]);
//    }
    for (int i = 0; i < M - N; i++) {
      total += sa[i];
    }
    System.out.println(total);

  }

}


Measured memory_bytes: 50644
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if(u < 0)
    u += m;
  return u;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), prime(1000000 + 1, 1), p, m;
  int x = 2;
  ll l = 1, o = 0;

  while(x * x <= 1000000) {
    for(int i = x * 2; i <= 1000000; i += x)
      prime[i] = 0;
    do
      x++;
    while(!prime[x]);
  }
  for(int i = 2; i <= 1000000; i++)
    if(prime[i])
      p.push_back(i);
  m = vector<int>(p.size());

  for(int i = 0; i < n; i++) {
    scanf("%d", &a.at(i));
    int t = a.at(i), pn;
    vector<int>::iterator it;
    for(int i = 0; i < p.size(); i++) {
      pn = 0;
      while(!(t % p.at(i))) {
        pn++;
        t /= p.at(i);
      }
      m.at(i) = max(m.at(i), pn);
      if(t == (*(it = lower_bound(p.begin(), p.end(), t)))) {
        if(!m.at(distance(p.begin(), it)))
          m.at(distance(p.begin(), it)) = 1;
        break;
      }
      if(t == 1)
        break;
    }
  }
  for(int i = 0; i < p.size(); i++)
    for(int j = 0; j < m.at(i); j++)
      l = l * p.at(i) % MOD;
  for(int i = 0; i < n; i++)
    o = (o + (l * modinv(a.at(i)) % MOD)) % MOD;
  cout << o << endl;
}

Measured memory_bytes: 4988
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int r, c, k; cin >> r >> c >> k;
	vector<vector<array<int, 2>>> items(r+1);
	for (int i = 0; i < k; ++i) {
		int x, y, v; cin >> x >> y >> v;
		items[x].push_back({y, v});
	}
	for (auto &vec : items)
		sort(begin(vec), end(vec));

	vector<ll> best(c+1);
	vector<vector<ll>> dp(r+1);
	vector<vector<array<ll, 3>>> dp2(r+1);
	ll ans = 0;
	for (int row = 1; row <= r; ++row) {
		auto &v = items[row];
		auto &cur = dp[row];
		auto &cur2 = dp2[row];
		cur.resize(v.size()); cur2.resize(v.size());
		ll best1 = -1, best2 = -1;
		for (int j = 0; j < (int)v.size(); ++j) {
			auto [col, val] = v[j];
			ll b = 0;
			for (int pos = 0; pos <= col; ++pos)
				b = max(b, best[pos]);
			cur2[j][0] = b + val;
			if (best1 >= 0) cur2[j][1] = best1 + val;
			if (best2 >= 0) cur2[j][2] = best2 + val;
			best1 = max(best1, cur2[j][0]);
			best2 = max(best2, cur2[j][1]);
			cur[j] = *max_element(begin(cur2[j]), end(cur2[j]));
			ans = max(ans, cur[j]);
		}
		for (int j = 0; j < (int)v.size(); ++j)
			best[items[row][j][0]] = max(best[items[row][j][0]], cur[j]);
	}
	cout << ans << '\n';
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

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

using namespace std;
using ull=unsigned long long;

const ull B1=1000000007LL;
const ull B2=1000000009LL;

bool image[1010][1010],pattern[1010][1010][8];

int convert(char c){
	if(isupper(c)) return c-'A';
	if(islower(c)) return c-'a'+26;
	if(isdigit(c)) return c-'0'+52;
	if(c=='+') return 62;
	return 63;
}

ull hash1[1010][1010];
ull hash2[1010][1010];

int main(void){
	int w,h,p;
	while(cin >> w >> h >> p,w){
		clr(image,0),clr(pattern,0);
		clr(hash1,0),clr(hash2,0);

		rep(i,h){
			int m=(w+5)/6,jdx=0;
			rep(j,m){
				char c;
				cin >> c;
				int d=convert(c);
				rep(k,6) image[i][jdx++]=(d&(32>>k))?1:0;
			}
		}

		ull PB1=1LL;
		rep(i,p) PB1*=B1;
			
		rep(i,h){
			ull cur=0LL;
			rep(j,p) cur=B1*cur+image[i][j];
			rep(j,w-p+1){
				hash1[i][j]=cur;
				cur=B1*cur-PB1*image[i][j]+image[i][j+p];
			}
		}

		ull PB2=1LL;
		rep(i,p) PB2*=B2;
			
		rep(j,w-p+1){
			ull cur=0LL;
			rep(i,p) cur=B2*cur+hash1[i][j];
			rep(i,h-p+1){
				hash2[i][j]=cur;
				cur=B2*cur-PB2*hash1[i][j]+hash1[i+p][j];
			}
		}

		rep(i,p){
			int m=(p+5)/6,jdx=0;
			rep(j,m){
				char c;
				cin >> c;
				int d=convert(c);
				rep(k,6) pattern[i][jdx++][0]=(d&(32>>k))?1:0;
			}
		}

		rep(i,p)rep(j,p) pattern[i][j][1]=pattern[p-1-j][i][0];
		rep(i,p)rep(j,p) pattern[i][j][2]=pattern[p-1-j][i][1];
		rep(i,p)rep(j,p) pattern[i][j][3]=pattern[p-1-j][i][2];
		
		rep(i,p)rep(j,p) pattern[i][j][4]=pattern[p-1-i][j][0];

		rep(i,p)rep(j,p) pattern[i][j][5]=pattern[p-1-j][i][4];
		rep(i,p)rep(j,p) pattern[i][j][6]=pattern[p-1-j][i][5];
		rep(i,p)rep(j,p) pattern[i][j][7]=pattern[p-1-j][i][6];


		int ans=0;
		set<ull> used;

		rep(it,8){
			ull hashp=0LL;
			rep(i,p){
				ull cur=0LL;
				rep(j,p) cur=B1*cur+pattern[i][j][it];
				hashp=B2*hashp+cur;
			}
			if(used.find(hashp)!=used.end()) continue;
			rep(i,h-p+1)rep(j,w-p+1)if(hash2[i][j]==hashp) ans++;
			used.insert(hashp);
		}

		cout << ans << endl;

		
		/*	
		rep(i,h){
			rep(j,w) cout << image[i][j];
			cout << endl;
		}
		cout << endl;
		rep(i,p){
			rep(j,p) cout << pattern[i][j][0];
			cout << endl;
		}
		cout << endl;
		*/
	}
	return 0;
}

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

int main()
{
    int K, X,output;
    cin >> K >> X;
    for(int i=0; i<2*K-1; i++){
        cout << X-(K-1)+i;
        if(i < 2*K-1 -1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
data = input().split()
data = data[:N]

for i in range(N):
	data[i] = int(data[i])

data.sort(reverse=True)

listA = []
listB = []
for i in range(N):
	if(i % 2 == 0):
		listA.append(data[i])
	else:
		listB.append(data[i])

print(sum(listA) - sum(listB))



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

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

vector<vector<ll>> matdot(vector<vector<ll>> A, vector<vector<ll>> B) {
  if (A[0].size()!=B.size()) return {{}};
  ll h = A.size(), w = B[0].size(), x = A[0].size();
  vector<vector<ll>> result(h,vector<ll>(w,0));
  rep(i,h) rep(j,w) rep(k,x) result[i][j] = (result[i][j] + A[i][k]*B[k][j])%MOD;
  return result;
}

vector<vector<ll>> matpow(vector<vector<ll>> A, ll n) {
  if (A.size()!=A[0].size()) return {{}};
  int N = A.size();
  vector<vector<ll>> result(N,vector<ll>(N,0)), now;
  copy(all(A),back_inserter(now));
  rep(i,N) result[i][i] = 1;
  ll p2 = 1; 
  while (n>=p2) {
    if (n&p2) result = matdot(result,now);
    now = matdot(now,now); p2 *= 2;
  }
  return result;
}

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

int main() {
  ll N, K; cin >> N >> K;
  vector<vector<ll>> a(N,vector<ll>(N));
  rep(i,N) rep(j,N) cin >> a[i][j];

  vector<vector<ll>> mat = matpow(a,K);
  ll result = 0; rep(i,N) rep(j,N) result = (result+mat[i][j]) % MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	fmt.Println((n+999)/1000*1000 - n)
}


Measured memory_bytes: 1776
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int d,t,s; cin >> d >> t >> s;
    if(d<=t*s) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  vector<vector<char>>C(100,vector<char>(100));
  for(int i=0;i<100;i++){
  for(int j=0;j<50;j++)
    C[i][j]='.';
    for(int j=50;j<100;j++)
      C[i][j]='#';
  }for(int i=0;i<A-1;i++){
  int a=i/25;a*=2;
    int b=i%25;
    b=(2*b+51);
    C[a][b]='.';
  }for(int i=0;i<B-1;i++){
  int a=i/25; a*=2;
    int b=i%25;
    b*=2;
    C[a][b]='#';
  }cout<<100<<" "<<100<<endl;
  for(int i=0;i<100;i++){
  for(int j=0;j<100;j++)
    cout<<C[i][j];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0;
    for(int i= 0;i<n;i++)
    {
        if(s[i] == 'R')
        r++;
    }
    if(r > n - r)
    {
        cout << "Yes";
    }
    else
    {
        cout <<"No";
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
temp = list(map(int, input().split()))
d = []
for i in range(N):
  d.append(temp[i])
total = 0
for i in range(N):
  for j in range(i, N):
    if(i!=j):
      total += d[i] * d[j]
print(total)

Measured memory_bytes: 3064
char s[2<<17];p[2<<17][256];i,j,L;main(m){for(i=L=strlen(gets(s));i--;p[i][s[i]]=m+1)for(m=L,j=97;j<123;j++)m=fmin(m,p[i][j]=p[i+1][j]);for(;++i<L;){for(m=j=97;j<123;j++)m=p[i][j]<p[i][m]?j:m;for(putchar(m);i<L&&s[i]-m;i++);}}

Measured memory_bytes: 201088
n, ma, mb = map(int,input().split())
a = [0] * (n + 1)
b = [0] * (n + 1)
c = [0] * (n + 1)
for i in range(1, n + 1):
    a[i], b[i], c[i] = map(int,input().split())

#iまでの薬品で、aがj(g),bがk(g)となるときの最小コスト
dp = [[[10 ** 15 for i in range(n + 1)] for j in range(401)] \
    for k in range(401)]

dp[0][0][0] = 0
sa = [0] * (n + 1)
sb = [0] * (n + 1)

for i in range(1, n + 1):
    sa[i] = sa[i - 1] + a[i]
    sb[i] = sb[i - 1] + b[i]

for i in range(1, n + 1):
    for j in range(sa[i] + 1):
        for k in range(sb[i] + 1):
            if j < a[i] or k < b[i]:
                dp[k][j][i] = dp[k][j][i - 1]
            else:
                dp[k][j][i] = min(dp[k][j][i - 1], \
                    dp[k - b[i]][j - a[i]][i - 1] + c[i])

i = 1
ans = 10 ** 15
while True:
    if i * ma > 400 or i * mb > 400:
        break
    ans = min(ans, dp[i * mb][i * ma][n])
    i += 1

if ans == 10 ** 15:
    ans = -1

print(ans)

Measured memory_bytes: 115548
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n , l = IN()
	al = [l+i-1 for i in range(1,n+1)]
	al=sorted(al, key = lambda v : abs(v))
	ret = sum(al)-al[0]
	#pa(al[0])
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int N, stk, mi = 1500, ma = -1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> stk;
		mi = min(mi, stk);
		ma = max(ma, stk);
	}
	cout << ma - mi << endl;
}


Measured memory_bytes: 256