akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
struct node
{
	int a[2000],n;
	void init()
	{
		for(int i=0;i<2000;i++)
		{
			a[i]=0;
		}
		n=1;
	}
	void operator +=(ll x)
	{
		int i=0;
		while(x>0)
		{
			a[i]+=(x%10);
			x=x/10;
			i++;
		}
		if(i>n)
		{
			n=i;
		}
		for(i=0;i<n;i++)
		{
			if(a[i]>9)
			{
				a[i+1]++;
				a[i]-=10;
			}
		}
		if(a[n]>0)
		{
			n++;
		}
	}
}ans;
int main()
{
	int i,j,k,n,m,x;
	scanf("%d%d",&n,&m);
	ans.init();
	if(m&1)
	{
		int a,b,c;
		for(i=1;i<=n;i++)
		{
			a=i%m;
			if(a==0)
			{
				ans+=((n/m)*1ll*(n/m));
			}/*
			if(a==(m>>1))
			{
				b=n/m;
				if((int(n/m)*m+(m>>1))<=n)
				{
					b++;
				}
				ans+=(b*b);
			}*/
		}
	}
	else
	{
		int a,b,c;
		for(i=1;i<=n;i++)
		{
			a=i%m;
			if(a==0)
			{
				ans+=((n/m)*1ll*(n/m));
			}
			if(a==(m>>1))
			{
				b=n/m;
				if((int(n/m)*m+(m>>1))<=n)
				{
					b++;
				}
				ans+=(b*1ll*b);
			}
		}
	}
	for(i=ans.n-1;i>=0;i--)
	{
		printf("%d",ans.a[i]);
	}
	return 0;
}

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

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        $(writeln!(stderr(), "{} = {:?}", stringify!($arg), $arg).unwrap());*
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

static M: i32 = 100005;
static mut N: i32 = 0;
fn lowbit(num: i32) -> i32 {
    num & (-num)
}

fn update(mut pos: i32, val: i32, C: &mut [i32]) {
    while pos <= M * 2 {
        C[pos as usize] += val;
        pos += lowbit(pos);
    }
}
fn sum(mut pos: i32, C: &[i32]) -> i32 {
    let mut res: i32 = 0;
    while pos > 0 {
        res += C[pos as usize];
        pos -= lowbit(pos);
    }
    res
}

unsafe fn check(num: i32, C: &mut [i32], a: &[i32]) -> bool {
    for i in 0..2 * M as usize {
        C[i] = 0;
    }
    let mut s: Vec<i32> = vec![0; (N + 2) as usize];
    for i in 1..(N + 1) as usize {
        s[i] = s[i - 1] + if a[i - 1] >= num { 1 } else { -1 };
    }
    let mut _sum: i64 = 0;
    for i in 0..(N + 1) as usize {
        _sum += sum(s[i] + M, C) as i64;
        update(s[i] + M, 1, C);
    }
    // debug!(num, _sum);
    return _sum >= (N as i64) * (N as i64 + 1) / 4;
}

fn main() {
    // println!("{}", 0)
    unsafe {
        N = read!(i32);
    }
    let nums: Vec<i32> = read!([i32]);
    let mut C: Vec<i32> = vec![0; (M * 2 + 1) as usize];
    let mut l: i64 = 0;
    let mut r: i64 = 0;
    for i in nums.iter() {
        r = max(r, (*i) as i64);
    }
    let mut ans = 0;
    while l <= r {
        // debug!(l,r);
        let mid = (l + r) / 2;
        unsafe {
            if check(mid as i32, &mut C, &nums) {
                ans = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int dp[110000];
int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    rep(i,n)dp[i] = INF;
    dp[0] = 0;
    rep(i,n-1){
        for(int j = 1;j<=k;j++){
            if(i+j>n-1)continue;
            dp[i+j] = min(dp[i+j],dp[i]+ abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

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

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;

        while( (line = br.readLine()) != null){
            String[] s = line.split(" ");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            System.out.println(1+(int)Math.log10(a+b));
        }

    }
}

Measured memory_bytes: 24184
#include<algorithm>
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
ll dp[4001][4001];
ll combi[4001][4001];
void setcombi() {
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			combi[i][j] = 0;
		}
	}
	combi[0][0] = 1;
	for (int i = 1; i <= 4000; i++) {
		combi[i][0] += combi[i - 1][0];
		combi[i][0] %= MOD;
	}
	for (int j = 1; j <= 4000; j++) {
		combi[0][j] += combi[0][j - 1];
		combi[0][j] %= MOD;
	}
	for (int i = 1; i <= 4000; i++) {
		for (int j = 1; j <= 4000; j++) {
			combi[i][j] += combi[i][j - 1] + combi[i - 1][j];
			combi[i][j] %= MOD;
		}
	}

}
ll combination(ll a, ll b) {
	if (b > a / 2)b = a - b;
	if (b < 0)return 0;
	if (b == 0)return 1;
	return combi[a - b][b];
}
int main() {
	int n;
	cin >> n;
	vi A(n), B(n), D(n);
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		D[i] = a + b;
		dp[2000 - a][2000 - b] += 1;
	}
	for (int i = 1; i <= 4000; i++) {
		dp[i][0] += dp[i - 1][0];
		dp[i][0] %= MOD;
	}
	for (int j = 1; j <= 4000; j++) {
		dp[0][j] += dp[0][j - 1];
		dp[0][j] %= MOD;
	}
	for (int i = 1; i <= 4000; i++) {
		for (int j = 1; j <= 4000; j++) {
			dp[i][j] += dp[i][j - 1] + dp[i - 1][j];
			dp[i][j] %= MOD;
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += dp[2000 + A[i]][2000 + B[i]];
		ans %= MOD;
	}
	ll same = 0;
	setcombi();
	for (int i = 0; i < n; i++) {
		same += combination(2 * D[i], 2 * A[i]);
		same %= MOD;
	}
	ans = (ans - same) % MOD;
	ans += MOD;
	ans %= MOD;
	if (ans % 2 == 0)ans /= 2;
	else ans = (ans + MOD) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 252672
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
long long n,cur,pas,b[5*N],endz[N*10][30],aft[N*10][30],k,ans;
string s[N];
bool  ss(string s1,string s2){
return s1.size()<s2.size();}
int get(){
	int u=0,pas=0;
	b[0]=1ll<<(s[k][0]-'a');
	for(int i=1;i<s[k].size();i++){
		b[i]=b[i-1]|(1ll<<(s[k][i]-'a'));
	}
	//cout<<s[k].size()<<endl;
	for(int i=s[k].size()-1;i>=0;i--){
		
		
		if(i==0) break;
		for(int j=0;j<=25;j++){
			if(b[i]&(1<<j)) pas+=endz[u][j];
		}if(!aft[u][s[k][i]-'a']) break;
	u=aft[u][s[k][i]-'a'];}
	return pas;
}
void add(){
	int u=0;
	for(int i=s[k].size()-1;i>=1;i--){
		if(!aft[u][s[k][i]-'a']){
			cur++;
			aft[u][s[k][i]-'a']=cur;
		}
		u=aft[u][s[k][i]-'a'];
	}
	endz[u][s[k][0]-'a']++;
}
int main(){
	cin>>n;
	for(k=1;k<=n;k++){
		cin>>s[k];
	}
	sort(s+1,s+n+1,ss);
	long long ans=0;
	for(k=1;k<=n;k++){
		ans+=(long long)get();
		add();
	}
	cout<<ans;
} 


Measured memory_bytes: 292756
#include<iostream>
int X, A, B;
int main() {
	std::cin >> X >> A >> B;
	if (B <= A) {
		std::cout << "delicious\n";
	}
	else if (B > A&&B <= A + X) {
		std::cout << "safe\n";
	}
	else {
		std::cout << "dangerous\n";
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
s = input()
n = len(s) - 1
a = 0
for i in range(2 ** n):
    f = s[0]
    for j in range(n):
        if ((i >> j) & 1):
            f += "+"
        f += s[j + 1]
    a += sum(map(int, f.split("+")))
print(a)

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

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

int main(){
	fast;
	ll s = 6;
	ll a,b; cin >> a >> b;
	cout << s - a - b << endl;
}

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

long long mi (long long a, long long m) {
      long long b = m, u = 1, v = 0;
    while (b) {
        long long 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, a, b;
  cin >> n >> a >> b;
  if (n == 2 && a == 1 && b == 2) {
    cout << 0 << endl;
    return 0;
  }
  long long d = 1000000007, tmp = 0, x = n, y = 1, e, f;
  for (int i = 1; i <= 200000; ++i) {
    tmp = x * mi(y, d);
    tmp %= d;
    x *= n-i;
    x %= d;
    y *= i+1;
    y %= d;
    if (i == a) {
      e = tmp;
    } else if (i == b) {
      f = tmp;
    }
  }
  long long ans = 1;
  x = 2;
  while (n > 0) {
    if (n & 1) ans = ans * x % d;
    x = x * x % d;
    n >>= 1;
  }
  ans = (ans - 1 - e - f) % d;
  if (ans < 0) ans = d + ans;
  cout << ans << endl;
  return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int ans = 0, tmp = 0;
    rep(i,3){
        if(s[i] == 'S'){
            tmp = 0;
        }else{
            tmp++;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

const int MAXN = 1e5 + 10;
int n, m;
int h[MAXN];
vector<int> g[MAXN];

void read() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
}

int ans;

void run() {
	ans = 0;
	for (int i = 0; i < n; i++) {
		bool flag = true;
		for (auto j : g[i]) {
			if (h[i] > h[j]) continue;
			flag = false;
		}
		ans += flag;
	}
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 9172
s=input()
t=input()
length=len(s)
exi={chr(97+i): False for i in range(26)}
jump={chr(97+i): [0 for _ in range(2*length)] for i in range(26)}
cru={chr(97+i):0 for i in range(26)}
pointer=0
flag=True
for i,ch in enumerate(s*2):
    exi[ch]=True
    for j in range(cru[ch],i+1):
        jump[ch][j]=1+i-j
    cru[ch]=i+1
for ch in t:
    if exi[ch]:
        pointer+=jump[ch][pointer%length]
    else:
        flag=False
        break
if flag:
    print(pointer)
else:
    print(-1)

Measured memory_bytes: 133552
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    n = int(stdin.readline()[:-1])   
    #r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0
    print((1+n)*n//2)

if __name__ == '__main__':
    main()


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

int main() {
  string s, t;
  cin >> s >> t;
  int res = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    res += (int)(s[i] != t[i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 3920
s = input()
if s[0] != 'A':
    print('WA')
elif s[2:-1:].count('C') != 1:
    print('WA')
else:
    l = list(s[1::])
    l.remove('C')
    st = ''.join(l)
    if st == st.lower():
        print('AC')
    else:
        print('WA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int gcc(int a,int b)
{
    if(a%b==0)return b;
    return gcc(b,a%b);
}
int main()
{
    int K;
    cin>>K;
    vector<int>A(3,1);
    A.at(0)=0;
    int sum=0;
    do
    {
        
        
        if(A.at(0)==K)
        {
            if(A.at(1)==K)
            {
                A.at(0)=1;
                A.at(1)=1;
                A.at(2)+=1;
            }
            else
            {
                A.at(0)=1;
                A.at(1)+=1;
            }
            
        }else{
            A.at(0)+=1;
        }
        
        sum+=gcc(gcc(A.at(0),A.at(1)),A.at(2));
    }while(A.at(0)+A.at(1)+A.at(2)!=K*3);
    cout<<sum<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
	int i;
	int N,x;
	scanf("%d %d", &N, &x);
	int a[N];
	for (i=0; i<N; i++){
		scanf("%d",&a[i]);
	}
	long count;
	count = 0;
	while(a[0]+a[1]>x){
		if(a[1]>0){
			count++;
			a[1]--;
		}
		else{
			count++;
			a[0]--;
		}
	}			
	for (i=1; i<N-1; i++){
		while (a[i]+a[i+1]>x){
			count++;
			a[i+1]--;
		}
	}
	printf("%ld",count);
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
x = []
temp = sum(a)
for i in range(n):
    if i%2 == 1:
        temp -= 2*a[i]
x.append(temp)
for i in range(n-1):
    x.append(2*a[i]-x[i])
for i in range(n):
    if i != n-1:
        print(x[i],end=" ")
    else:
        print(x[i])

Measured memory_bytes: 14028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//CHEF AND MINIMUM SWAPS
int main(){
    int n;
    cin>>n;
    int a[n],res=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
  	for(int i=0;i<n;i++){
      	if( ((i+1)&1) && (a[i]&1) ){
          	res+=1;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <stack>

int main() {
  int i;
  int cnt = 0;
  std::stack<int> st;
  while(cnt < 50) {
    scanf("%d", &i);
    if(i == 0){
      printf("%d\n", st.top());
      st.pop();
    }else{
      st.push(i);
    }
    cnt++;
  }
  return 0;
}

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

int main(){
	map<int,int>cnt;
  	int n,m;cin>>n>>m;
  	while(m--){
      	int x,y;
      	cin>>x>>y;
    	cnt[x]++;cnt[y]++;
    }
   for(int i=1;i<=n;i++){
   	cout<<cnt[i]<<endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int n;
int p[30];

void solve() {

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int cnt = 0;
	for (int i = 1; i < n - 1; i++) {
		if (min({ p[i - 1], p[i], p[i + 1] }) != p[i] && max({ p[i - 1], p[i], p[i + 1] }) != p[i]) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,T;
	int[] t;
	public void solve() {
		N = nextInt();
		T = nextInt();

		t = new int[N];
		for(int i = 0;i < N;i++){
			t[i] = nextInt();
		}

		int ans = 0;
		for(int i = 0;i < N-1;i++){
			ans += Math.min(T,t[i+1]-t[i]);
		}

		ans += T;

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 43272
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-03-01 21:00:09
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

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

    cout << ceil((float)n/2) << endl;

    return 0;
}


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

int main() {
	
	ios_base::sync_with_stdio(false);

	cin.tie(0);

	long n;
	cin >> n;

	vector<long> d(n);

	for(int i = 0; i < n; ++i)
		cin >> d[i];

	long m;
	cin >> m;

	vector<long> t(m);

	for(long i = 0; i < m; ++i)
		cin >> t[i];

	sort(d.begin(), d.end());
	sort(t.begin(), t.end());

	bool flag = true;

	long k = 0;

	for(long i = 0; i < m; ++i)
	{
		for(long j = k; j < n; ++j)
		{
			if(t[i] == d[j])
			{
				k = j + 1;
				break;
			}
			else if(j == n - 1) flag = false;
		}

		if(!flag) break;

	}

	if(flag) cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 3328
import numpy as np


def is_integer_distance(np_a):
    return isqrt(np.dot(np_a, np_a))


def isqrt(n):
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x * x == n


n, d = map(int, raw_input().split())
x = []
for i in range(n):
    x.append(map(int, raw_input().split()))

np_x = np.asarray(x)

count = 0
for i in range(n):
    for j in range(i+1, n):
        if is_integer_distance(np.subtract(np_x[i], np_x[j])):
            count += 1

print count


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

int main(){
	int n; cin>>n;
	int a=0;
	bool k=false;
	rep(i,n){
		int d1,d2;
		cin>>d1>>d2;
		if(d1==d2) a++;
		else a=0;
		if(a>=3) k=true;
	}
	if(k) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3612
package main

import "fmt"

var N int
var a []int

func find2Power(i int) int {
	num := 0
	for i%2 == 0 {
		i /= 2
		num += 1
	}
	return num
}

func main() {
	fmt.Scan(&N)
	tmp := 0
	a = make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		sum += find2Power(tmp)
		//		a[i] = tmp
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1152
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(begin(p), end(p)));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3576
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.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;}

ll N ;
int check[100005];
map<ll, vector<ll> > tree;
vector<ll> Fennec, Snuke;

void cal(){
    ll a = Fennec.size();
    ll b = Snuke.size();
    if(a+b == 0) return ;
    
    cerr << "s  aaa" << endl;
    rep(i,a){
        ll now = Fennec[0];
        cerr << now << endl;
        Fennec.erase(Fennec.begin()+0);
        rep(j, tree[now].size()){
            if(check[tree[now][j]] != 0) continue;
            check[tree[now][j]] = 1;
            Fennec.pb(tree[now][j]);
        }
    }
    cerr << "t  aaa" << endl;

    rep(i,b){
        ll now = Snuke[0];
        Snuke.erase(Snuke.begin()+0);
        rep(j, tree[now].size()){
            if(check[tree[now][j]] != 0) continue;
            check[tree[now][j]] = 2;
            Snuke.pb(tree[now][j]);
        }
    }


    cal();
    
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    for(ll i = 1 ; i <= N ; i++){
        check[i] = 0;
    }
    
    rep(i,N-1){
        ll a, b;
        cin >> a >> b ;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    
    Fennec.pb(1);
    Snuke.pb(N);
    check[1] = 1;
    check[N] = 2;
    
    cal();
    
    ll f = 0, s = 0;
    for(ll i = 1; i<= N ; i++){
        cerr << i << "----" << check[i] << endl;
        if(check[i] == 1) f++;
        if(check[i] == 2) s++;
    }
    cerr << f <<" " << s << endl;
    if(f > s) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 16256
#%%
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

bc = [0] * (y * z)
q = 0
for i in range(y):
    for j in range(z):
        bc[q] = b[i] + c[j]
        q += 1

bc.sort(reverse=True)
r = len(bc)
bc = bc[:min(k, r)]

abc = [0] * (x * min(k, r))
q = 0
for i in range(min(k, r)):
    for j in range(x):
        abc[q] = bc[i] + a[j]
        q += 1

abc.sort(reverse=True)
for i in range(min(k, x*y*z)):
    print(abc[i])



Measured memory_bytes: 97604
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MODD 998244353
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MODD;
		x = (x*x)%MODD;
		n = n>>1;
	}
	return ans%MODD;
}

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

int t=1;
cin>>t;

set<string> s;

while(t--)
{
	string s1;
	cin>>s1;
	s.insert(s1);
}

cout<<s.size()<<"\n";



return 0;
}


Measured memory_bytes: 19244
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

ll cnt[10];
const ll MAX_N = 1e5 + 10;
map<pair<ll, ll>, bool> on, tried;
ll h, w;

void tr(ll x, ll y) {
    if(tried.find({x, y}) != tried.end() || x < 2 || x > h - 1 || y < 2 || y > w - 1) {return;}
    ll now = 0;
    for(ll i = -1; i < 2; i ++) {
        for(ll j = -1; j < 2; j ++) {
            if(on.find({x + i, y + j}) != on.end()) {
                now += on[{x + i, y + j}];
            }
        }
    }
    cnt[now] ++;
    tried[{x, y}] = true;
}

ll x[MAX_N], y[MAX_N], n;


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> h >> w;
    cin >> n;
    for(ll i = 0; i < n; i ++) {
        cin >> x[i] >> y[i];
        on[{x[i], y[i]}] = true;
    }
    for(ll i = 0; i < n; i ++) {
        for(ll dx = -1; dx < 2; dx ++) {
            for(ll dy = -1; dy < 2; dy ++) {
                tr(x[i] + dx, y[i] + dy);
            }
        }
    }
    cnt[0] += (h - 2) * (w - 2) - tried.size();
    for(int i = 0; i < 10; i ++) {
        cout << cnt[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 64384
from decimal import Decimal

a,b,c = map(str,input().split()) # Decimalを使う場合，文字列で渡す
a_sq = Decimal(a).sqrt()
b_sq = Decimal(b).sqrt()
c_sq = Decimal(c).sqrt()

if a_sq + b_sq < c_sq:
  print("Yes")
else:
  print("No")

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

using namespace std;

int main(){

	int n;
	int nums[101];
	cin >> n;
	// iÜÅÌðgpµÄjª¢­Âìêé©Ìdpe[u
	long long dp[101][21];
	for(int i = 0; i < n; i++){
		cin >> nums[i];
		fill(dp[i],dp[i]+21,0);
	}
	dp[0][nums[0]] = 1;
	for(int i = 1; i < n-1; i++){
		for(int j = 0; j < 21; j++){
			if(j + nums[i] <= 20)
				dp[i][j] += dp[i-1][j+nums[i]];
			if(j - nums[i] >= 0){
				dp[i][j] += dp[i-1][j-nums[i]];
			}
		}
	}

	long long sum = 0;
	sum += dp[n-2][nums[n-1]];
	cout << sum << endl;

	//int x;
	//cin >> x;
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define FOR(i, s, n) for(int i=(int)(s); i<(int)(n); ++i)
#define ALL(n) (n).begin(), (n).end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> mat;

const ll MAX_N = 100000;
const ll INF = 1e9;
const ll MOD = 998244353;

class UnionFindTree{
private:
    vector<int> parent;
    vector<int> rank;
public:
    int n;
    UnionFindTree(int n);
    int root(int x);
    void unite(int x, int y);
    bool isSame(int x, int y);
};

UnionFindTree::UnionFindTree(int n_): parent(n_), rank(n_, 0){
    n = n_;
    // 初期化:すべてのノードの親を自分にする
    REP(i, n) parent[i] = i;
}

int UnionFindTree::root(int x){
    // 経路圧縮を行う
    if (parent[x] == x) return x;
    else return parent[x] = root(parent[x]);
}

void UnionFindTree::unite(int x, int y){
    // 木の結合:高さが低い木を高い木の下にぶら下げる
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    else {
        if (rank[rx] < rank[ry]){
            parent[rx] = ry;
        }else{
            parent[ry] = rx;
            if (rank[rx] == rank[ry]) rank[rx]++;
        }
    }
}

bool UnionFindTree::isSame(int x, int y){
    return root(x) == root(y);
}

int main(){
    int N, M; cin >> N >> M;
    set<int> roots;
    UnionFindTree uf(N);
    REP(i, M){
        int x, y, z; cin >> x >> y >> z;
        uf.unite(x-1, y-1);
    }
    REP(i, N){
        roots.insert(uf.root(i));
    }
    cout << roots.size() << endl;
}

Measured memory_bytes: 5760
n = int(input())
h = list(map(int, input().split()))
ans = 1
p = 0
for i in range(n):
    if h[i] < p:
        ans = 0
        break
    if h[i] > p:
        p = h[i] - 1
if ans == 1:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair 
#define COUT(v) for(int64_t i=0;i<(v).size();i++){ cout << v.at(i) << endl;}
#define REP(i, n) for(int64_t i=0;i<n;i++)
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal>palvec;


typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const int MOD = 1000000007;


ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}

lvec mfactor(ll n){
    bvec ip(n, true);
    lvec mf(n, -1);
    ip[0]=false; ip[1]=false; mf[0]=0; mf[1]=1;
    REP(i, n){
        if(ip[i]){
            mf[i] = i;
            for(ll j=i*i; j<n; j+=i){
                ip[j] = false;
                if(mf[j] == -1) mf[j]=i;
            }
        }
    }
    return mf;
}

palivec get_prime(ll n, const lvec &mf){
    palivec plist;
    while(n != 1){
        int cnt=0;
        ll m=mf[n];
        while(mf[n] == m){
            cnt++;
            n/=m;
        }
        plist.pb(pali(m, cnt));
    }
    return plist;
}

void COMinit(int m, lvec &fac, lvec &finv){
    lvec inv(m);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < m; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k, const lvec& fac, const lvec &finv){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll modinv(ll a, ll m) {
    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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << floor(log(n)/log(k)) + 1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 1000000007
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,m;
vector<vector<int>>adj(100000+9);
ll dp[100000+9];
ll solve(int ind){
    ll a= 0;
    if(dp[ind] != -1)
        return dp[ind];
    for(auto i : adj[ind]){
        a = max(a,solve(i)+1);
    }
    return dp[ind] = a;
}
int main() {
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i = 0;i<m;i++){
        int x ,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    ll mx = 0;
    for(int i = 1;i<=n;i++){
        mx = max(solve(i),mx);
    }
    cout<<mx;
    return 0;
}


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

const int N = 3e3 + 5 , M = 5e3+5;

int n , m , dp[N][N] ;
pair<int,int> pre[N][N];
string s , t;

int solve(int i , int j)
{
    if(i==n||j==m)return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int ret = 0;
    if(s[i]==t[j])
        ret = 1+solve(i+1 , j+1);
    ret = max(ret  , solve(i+1 , j) );
    ret = max(ret  , solve(i , j+1) );

    return dp[i][j]=ret;
}

int main()
{
    memset(dp , -1 , sizeof dp);
    cin>>s>>t;
    n = s.size();
    m = t.size();
    string sol ="";
    solve(0 , 0);
    int i = 0 , j = 0;
    while(i<n && j<m)
    {
        if(s[i]==t[j])
        {
            sol+=s[i];
            i++;
            j++;
        }
        else if( dp[i+1][j] >=dp[i][j+1] )i++;
        else j++;
    }
    cout<<sol;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    if(1 <= n && n <= 9){
        cout << n << endl;
    }else if(10 <= n && n <= 99){
        cout << 9 << endl;
    }else if(100 <= n && n <= 999){
        cout << 9 + n - 100 + 1 << endl;
    }else if(1000 <= n && n <= 9999){
        cout << 9 + 900 << endl;
    }else if(10000 <= n && n <= 99999){
        cout << 909 + n - 10000 + 1 << endl;
    }else if(n == 100000){
        cout << 90909 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int x; cin >> x;
	cout << 10-(x / 200) << endl;
	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int v[MAXN];

ll sum_pref[MAXN], sum_suf[MAXN];

int n, L;
ll ans;

void solve(){
	scanf("%d%d", &L, &n);
	REPN(i, 1, n) {
		scanf("%d", &v[i]);
	}
	REPN(i, 1, n) {
		sum_pref[i] = sum_pref[i - 1] + v[i];
	}
	for(int i = n; i >= 1; i--) {
		sum_suf[i] = sum_suf[i + 1] + L - v[i];
	}
	ans = max(v[n], L - v[1]);
	REP(i, 1, n) {
		int l = i, r = n - i;
		ll cur = 0ll;
		
		if (l <= r) {
			int cnt = r - l + 1;
			cur = 2 * (L - v[n + 1 - cnt]);
			cur += 2ll * sum_pref[l] - v[l];
			cur += 2ll * (sum_suf[l + 1] - sum_suf[n + 1 - cnt]);
		} else {
			int cnt = l - r;
			cur = 2 * v[cnt];
			cur += 2ll * (sum_pref[l] - sum_pref[cnt]) - v[l];
			cur += 2ll * sum_suf[l + 1];
		}
		ans = max(ans, cur);
		
		cur = 0ll;
		if (l < r) {
			int cnt = r - l;
			cur = 2 * (L - v[n + 1 - cnt]);
			cur += 2ll * sum_pref[l];
			cur += 2ll * (sum_suf[l + 1] - sum_suf[n + 1 - cnt]) - (L - v[l + 1]);
		} else {
			int cnt = l - r + 1;
			cur = 2 * v[cnt];
			cur += 2ll * (sum_pref[l] - sum_pref[cnt]);
			cur += 2ll * sum_suf[l + 1] - (L - v[l + 1]);
		}
		ans = max(ans, cur);
		
		/*ll cur = 0ll;
		if (l > r) {
			int cnt = l - r;
			cur = 2 * v[cnt];
			cur += 2ll * (sum_pref[l] - sum_pref[cnt]) - v[l];
			cur += 2ll * sum_suf[l + 1];
		}
		if (l == r) {
			cur = 0ll;
			cur += 2ll * sum_pref[l] - v[l];
			cur += 2ll * sum_suf[l + 1];
			ans = max(ans, cur);
			
			cout << l << " " << cur << endl;
			
			cur = 0ll;
			cur += 2ll * sum_pref[l];
			cur += 2ll * sum_suf[l + 1] - (L - v[l + 1]);
		}
		if (l < r) {
			int cnt = r - l;
			cur = L - v[n + 1 - cnt];
			cur += 2ll * sum_pref[l];
			cur += 2ll * (sum_suf[l + 1] - sum_suf[n + 1 - cnt]) - (L - v[l + 1]);
		}
		ans = max(ans, cur);
		
		cout << l << " " << cur << endl;*/
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 4096
def answer(k: int, s: int) -> int:
    count = 0
    
    for x in range(k + 1):
        y_max = min(k, s - x)
        y_min = max(0, s - x - k)
        comb = y_max - y_min + 1
        
        if 0 < comb:
            count += comb

    return count


def main():
    k, s = map(int, input().split())
    print(answer(k, s))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  ll d = abs(b-a);

  if (d==0)
  {
    cout << "YES" << endl;
    re;
  }

  ll vrel = w-v;
  if (vrel >= 0)
  {
    cout << "NO" << endl;
  }
  else
  {
    vrel = abs(vrel);
    //cout << vrel << " " << d << endl;
    if (t >= d/vrel + (d%vrel?1:0))
    {
      cout << "YES" << endl;
    }
    else
    {
      cout << "NO" << endl;
    }
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  //cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



Measured memory_bytes: 3612
from sys import stdin
from itertools import combinations_with_replacement
input = stdin.readline

N, M, Q = map(int, input().split())

abcd = [list(map(int, input().split())) for _ in range(Q)]

s = list(range(1, M + 1))
ans = 0


for s in combinations_with_replacement(s, N):
    num = 0
    for q in range(Q):
        a, b, c, d = abcd[q]
        if s[b - 1] - s[a - 1] == c:
            num += d
    ans = max(ans, num)

print(ans)


Measured memory_bytes: 67996
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)



int main() {
	int N;
	vector<ll> A;
	cin >> N;
	A.resize(N);
	ll total = 0;
	int count = 0;
	ll min_tmp = INF;
	rep(i, N) {
		cin >> A[i];
		total += abs(A[i]);
		if (A[i] < 0) {
			count++;
		}
		chmin(min_tmp, abs(A[i]));
	}
	if (count % 2 == 0) {
		cout << total;
	}
	else {
		cout << total - 2 * min_tmp;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int n;
void init(){
    n = read();
}
void solve(){
    int t = 7 % n;
    for (int i = 1; i <= n; ++i){
        if (t == 0) {printf("%d\n", i); return ;}
        t = (10 * t + 7) % n;
    }
    printf("%d\n", -1);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3760
from copy import copy, deepcopy # pythonのみ．copyは1次元，deepcopyは多次元．
# from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    h,w,K=map(int,input().split())
    g=[[_ for _ in input()] for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if g[i][j]=='.':
                g[i][j]=0
            else:
                g[i][j]=1
    n=h+w
    cnt=0
    for i in range(2 ** n):
        gg=deepcopy(g)
        for j in range(n):
            if ((i >> j) & 1):
                if j-h<0:
                    for k in range(w):
                        gg[j][k]=2
                else:
                    for l in range(h):
                        gg[l][j-h]=2
        
        ans=0
        for i in range(h):
            for j in range(w):
                if gg[i][j]==1:
                    ans+=1

        if ans==K:
            cnt+=1
    print(cnt)


    
resolve()

Measured memory_bytes: 76336
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;

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

Measured memory_bytes: 4044
from collections import defaultdict
mem = defaultdict(lambda : None)
mem[(0,0,0)] = 0
def dp(a,b,s):
  if mem[(a,b,s)] is not None:
    return mem[(a,b,s)]
  x = a&1
  y = b&1
  xor = s&1
  res = float("inf")
  if x^y != xor:
    mem[(a,b,s)] = res
    return res
  else:
    res = 2*dp(a>>1,b>>1,s>>1)
    if a > 1:
      pants = 2*dp((a-1)>>1,(b+1)>>1,s>>1)+1
      if pants < res:
        res = pants
  mem[(a,b,s)] = res
  return res

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a[2:]:
  s ^= i
b = a[1]
a = a[0]
ans = dp(a,b,s)
if ans == float("inf"):
  ans = -1
print(ans)


Measured memory_bytes: 64712