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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

bool used[810][810];
void solve(){
    ll h,w,k;
    cin>>h>>w>>k;
    vec<string> a(h);
    REP(i,h) cin>>a[i];

    queue<tuple<int,int,int>> que; 
    ll ans=INF;
    REP(i,h) REP(j,w){
        if(a[i][j]=='S'){
            que.push(make_tuple(0,i,j));
            ll d=min({(ll)i, h-1-i, (ll)j, w-1-j});
            chmin(ans, (d+k-1)/k);
            used[i][j]=true;
        }
    }

    int dx[4] = {1,-1,0,0};
    int dy[4] = {0,0,1,-1};
    while(que.size()){
        int kk, x, y;
        tie(kk,y,x) = que.front();que.pop();
        ll d=min({(ll)y, h-1-y, (ll)x, w-1-x});
        chmin(ans, (d+k-1)/k);
        
        if(kk==k) continue;
        REP(v,4){
            int nx=x+dx[v];
            int ny=y+dy[v];
            if(nx>=w or nx<0 or ny>=h or ny<0) continue;
            if(a[ny][nx]=='#' or used[ny][nx]) continue;
            que.push(make_tuple(kk+1,ny,nx));
            used[ny][nx]=true;
        }
    }

    cout<<ans+1<<en;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 1536
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define int ll
#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;



signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    
    int n;
    cin >> n;
    int sum = 0;
    int ans = 0;
    fo(i , n){
        int x;
        cin >> x;
        ans = (ans % MOD  + (x * sum) % MOD) % MOD;
        sum = (sum + x) % MOD;
    }
    cout << ans << '\n';

    return 0;
}
 


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main()
{
    int n,t,c=0,r,i;
    char a[100];
    scanf("%d",&n);
    scanf("%s",a);
    if(n%2!=0)
    {
        printf("No");
    }
    else
    {
        r=n/2;
        for(i=0,t=r; i<r,t<n; i++,t++)
        {

            if(a[i]==a[t])
            {

                c++;
            }
        }
        if(c==r)
        {
            printf("Yes");
        }
        else
            printf("No");
    }
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int i, n = 0;
    stack<char> a;
    string s;
    cin >> s;
    a.push('2');
    for(i=0; i<s.length(); i++){
        if(a.top() == '2'){
            a.push(s[i]);
        }else if(a.top() == '0'){
            if(s[i] == '1'){
                a.pop();
                n += 2;
            }else{
                a.push(s[i]);
            }
        }else if(a.top() == '1'){
            if(s[i] == '0'){
                a.pop();
                n += 2;
            }else{
                a.push(s[i]);
            }
        }
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 512
def digit_sum(num):
    ds = 0
    while num > 0:
        ds += num % 10
        num //= 10
    return ds


K = int(input())
candidates = []
digit_sums = []
for i in range(15):
    base = 10**i
    for j in range(1, 150):
        candidate = j * base + (base - 1)
        candidates.append(candidate)

candidates = sorted(list(set(candidates)))
digit_sums = [digit_sum(candidate) for candidate in candidates]

snuke_nums = []
smaller_as_snuke = lambda n, m, ds_n, ds_m: True if n * ds_m <= m * ds_n else False
for i, candidate in enumerate(candidates):
    ds_cand = digit_sums[i]
    for j in range(i + 1, len(candidates)):
        other_num = candidates[j]
        ds_other = digit_sums[j]
        if not smaller_as_snuke(candidate, other_num, ds_cand, ds_other):
            break
    else:
        snuke_nums.append(candidate)

for snuke_num in snuke_nums[:K]:
    print(snuke_num)


Measured memory_bytes: 41200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char[] ch = strToCharArray(sc.nextLine());
        ArrayList<Character> list = new ArrayList<>();
        for(int i = 0; i < ch.length; i++) {
        	char c = ch[i];
        	
        	switch(c) {
        	case '0':
        	case '1':
        		list.add(c);
        		break;
        	case 'B':
        		if(list.size() > 0) {
        			list.remove(list.size() -1);
        		}
        	}
        }
        for(char c: list) {
        	System.out.print(c);
        }
    }

    static String[] strCompare(String[] array) {
    	Arrays.sort(array, new Comparator<String>() {
    		public int compare(String s1, String s2) {
    			if(compareLength(s1, s2) == 0) {
    				return s1.compareTo(s2);
    			}
    			return compareLength(s1, s2);
    		}
    	});
    	return array;
    }

    static int compareLength(String s1, String s2) {
    	if(s1.length() > s2.length()) {
    		return 1;
    	} else if (s1.length() < s2.length()) {
    		return -1;
    	} else {
    		return 0;
    	}
    }
    
    static String[] strCompareReverse(String[] array) {
    	Arrays.sort(array, new Comparator<String>() {
    		public int compare(String s2, String s1) {
    			if(compareLengthReverse(s1, s2) == 0) {
    				return s1.compareTo(s2);
    			}
    			return compareLengthReverse(s1, s2);
    		}
    	});
    	return array;
    }

    static int compareLengthReverse(String s1, String s2) {
    	if(s1.length() > s2.length()) {
    		return 1;
    	} else if (s1.length() < s2.length()) {
    		return -1;
    	} else {
    		return 0;
    	}
    }

    static int[] toIntArray(String[] str) {
    	int[] num = new int[str.length];
    	for(int i = 0; i < str.length; i++) {
    		num[i] = Integer.parseInt(str[i]);
    	}
    	return num;
    }

    static char[] strToCharArray(String str) {
    	char[] chAr = new char[str.length()];
    	chAr = str.toCharArray();
    	return chAr;
    }


    static String[] toStringArray(String str, String delim) {
    	String[] stAr = str.split(delim);
    	return stAr;
    }

    static int[] strToIntArray(String str, String delim) {
    	String[] strAr = str.split(delim);
    	int[] intAr = new int[strAr.length];
    	for(int i = 0; i < strAr.length; i++) {
    		intAr[i] = Integer.parseInt(strAr[i]);
    	}
    	return intAr;
    }

    static int toInt(String str) {
    	int num = Integer.parseInt(str);
    	return num;
    }

    static double[] strToDoubleArray(String str, String delim) {
    	String[] strAr = str.split(delim);
    	double[] dAr = new double[str.length()];
    	for(int i = 0; i < strAr.length; i++) {
    		dAr[i] = Double.parseDouble(strAr[i]);
    	}
    	return dAr;

    }
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<lli> a(n);
    each (i, a) cin >> i;
    map<lli, lli> cnt;
    vector<lli> v;
    for (int i = 0; i < a.size(); ++i) {
      if (i) v.push_back(v.back() + a[i]);
      else v.push_back(a[i]);
      v.back() %= m;
      ++cnt[v.back()];
    }
    lli sum = cnt[0];
    each (i, cnt) {
      sum += i.second * (i.second - 1) / 2;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 6008
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

satB = b.inject(:+)
satC = 0

(n - 1).times do |i|
  if a[i] + 1 == a[i + 1]
    satC += c[a[i] - 1]
  end
end

puts satB + satC

Measured memory_bytes: 1788
#include <stdio.h>

int main(void) {
    int N, M, C, total, ans = 0;
    scanf("%d %d %d", &N, &M, &C);

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

    for (int i = 0; i < N; i++) {
        total = 0;
        for (int j = 0; j < M; j++) {
            scanf("%d", &A[i][j]);
            total += A[i][j] * B[j];
        }

        if (total + C > 0) {
            ans += 1;
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 128
//use proconio::input;
use std::cmp::max;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};
    ($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};
    ($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};
    ($iter:expr, usize1) => {read_value!($iter, usize) - 1};
    ($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};
}


fn main() {
    input! {
        n: usize,
        m: usize,
        xy: [(usize, usize); m],
    }

    let mut g = vec![Vec::new(); n];
    for (x, y) in xy {
        g[x - 1].push(y - 1);
    }

    let mut dp = vec![None; n];

    let mut r = 0;
    for x in 0..n {
        r = max(r, rec(&g, &mut dp, x));
    }
    println!("{}", r);
}

fn rec(g: &Vec<Vec<usize>>, dp: &mut Vec<Option<usize>>, x: usize) -> usize {
    if let Some(dpx) = dp[x] { return dpx };

    let mut r = 0;
    for nx in &(*g)[x] {
        r = max(r, rec(g, dp, *nx) + 1);
    }
    (*dp)[x] = Some(r);
    r
}

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

int main() {
  int N, D, ans;
  double d;
  cin >> N >> D;
  vector<vector<int>>X(N, vector<int>(D));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> X.at(i).at(j);
    }
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      d = 0;
      for (int k = 0; k < D; k++) {
        d += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      }
      d = pow(d, 0.5);
      if (d == floor(d)) {
        ans++;
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
s = int(input())
a = []
a.append(s)
for i in range(1,1000000):
  if a[-1]%2 == 0:
    q = a[-1]//2
  else:
    q = 3*a[-1] + 1
  if q in a:
    print(i+1)
    break
  a.append(q)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;
int main(void)
{
  int n,max_v,sum;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
    cin >> v[i];

  max_v=*(max_element(v.cbegin(),v.cend()));
  sum=accumulate(v.cbegin(),v.cend(),0,plus<int>());
  if(max_v<sum-max_v)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

int main() {
    int64_t N;
    string S;
    cin >> N >> S;
    int64_t ans = 0;
    for (int64_t i = 0; i < S.size(); i++) {
        if (S.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

void inttovec(int n, vector<char> &v)
{
    v.clear();
    v.push_back('0' + (n / 100));
    n %= 100;
    v.push_back('0' + (n / 10));
    n %= 10;
    v.push_back('0' + n);
}

int main(int argc, char const *argv[])
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    rep(i, 1000)
    {
        vector<char> v;
        inttovec(i, v);
        int cur = 0;
        rep(j, n)
        {
            if (s[j] == v[cur])
            {
                cur++;
                if (cur == 3)
                {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false); 
int a[712][712],dp[712][712];
vector<vi> adj(712);
int haha[712],visit[712],col[3];

int dfs(int cur,int color){
	haha[cur]=color;
	visit[cur]=1;
	col[color]++;
	color^=1;
	int i;
	rep(i,adj[cur].size()){
		if(!visit[adj[cur][i]]){
			dfs(adj[cur][i],color);
		}
		else{
			if(color!=haha[adj[cur][i]]){
				cout<<-1<<endl;
				exit(0);
			}
		}
	}
	return 0;

}
int wowo[712][712];
vii vec;
int compute(int n,int j){
	if(j==-1){
		if(n==0)
			return 1;
		return 0;
	}
	if(wowo[n][j])
		return dp[n][j];
	wowo[n][j]=1;
	if(vec[j].ff<=n){
		dp[n][j]=max(dp[n][j],compute(n-vec[j].ff,j-1));
	}
	if(vec[j].ss<=n){
		dp[n][j]=max(dp[n][j],compute(n-vec[j].ss,j-1));
	}
	return dp[n][j];
}
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    int m;
    cin>>n>>m;
    int i;
    int u,v;
    rep(i,m){
    	cin>>u>>v;
    	u--;
    	v--;
    	a[u][v]=1;
    	a[v][u]=1;
    }
    int j;
    rep(i,n){
    	rep(j,n){
    		if(!a[i][j] && i!=j){
    			adj[i].pb(j);
    		}
    	}
    }
    
    rep(i,n){
    	if(!visit[i]){
    		col[0]=0;
    		col[1]=0;
    		dfs(i,0);
    		vec.pb(mp(col[0],col[1]));
    	}
    }
    int mini=inf;
    rep(i,n){
    	if(compute(i,vec.size()-1)){
    		mini=min(mini,(i*(i-1)+(n-i)*(n-i-1))/2);
    	}
    }
    cout<<mini<<endl;

    return 0;  
    
}



Measured memory_bytes: 6400
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=[list(map(int,input().split())) for _ in range(N)]
    f=[[True]*N for _ in range(N)]
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if A[i][j]>A[i][k]+A[k][j]:
                    print(-1)
                    exit()
                elif i!=k and j!=k and A[i][j]==A[i][k]+A[k][j]:
                    f[i][j]=False
    ans=0
    for i in range(N):
        for j in range(N):
            ans+=A[i][j]*f[i][j]
    print(ans//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 43484
import sys
S = input()
if len(S) < 26:
    for i in range(97, 97 + 26):
        if chr(i) not in S:
            print(S+chr(i))
            break
else:
    S_rev = S[::-1]
    for i in range(len(S_rev)-1):
        if S_rev[i] > S_rev[i+1]:
            for j in range(len(S_rev)):
                if S_rev[j] > S[-(i+2)]:
                    print(S[:len(S)-(i+1)-1]+S_rev[j])
                    sys.exit(0)
    print(-1)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, m; 
char a[60][60], b[60][60];

bool check(int x, int y) {
    rep(i,0,m) rep(j,0,m) {
        int p = x + i;
        int q = y + j;
        if(b[i][j] != a[p][q]) return false;
    }
    return true;
}

signed main() {
    cin >> n >> m;
    rep(i,0,n) rep(j,0,n) cin >> a[i][j];
    rep(i,0,m) rep(j,0,m) cin >> b[i][j];

    bool ans = false;
    rep(i,0,n-m+1) {
        rep(j,0,n-m+1) {
            if(check(i,j)) ans = true;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long  mod=1e9+9;
const int N=1e6+2;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>a>>b;
    if(b%2==0 && 2*a<=b && 4*a>=b)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<endl;
}



Measured memory_bytes: 3620
import copy

N=int(input())

tmp0=[]
tmp1=[3,5,7]
res=[3,5,7]
for i in range(1,9):
  for j in tmp1:
    for k in [3,5,7]:
      res.append(j*10+k)
      tmp0.append(j*10+k)
  tmp1=copy.deepcopy(tmp0)
  tmp0=[]

res2=[]
for i in res:
  if len(set(str(i)))==3:
    res2.append(i)
#print(res2)

ans=0
for i in res2:
  if i<=N:
    ans+=1
print(ans)

Measured memory_bytes: 6052
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int r, g, b;
  cin >> r >> g >> b;
  if((100*r+10*g+b)%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

	cout << (C >= A && C <= B ? "Yes" : "No") << endl;

    return 0;
}


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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    bool works = true;
    for (int i = 0; i < n; ++i) {
    	int x;
    	cin >> x;
    	if (x % 2 == 0) 
    		if (x % 3 && x % 5) works = false;
    }
    cout << (works ? "APPROVED" : "DENIED") << '\n';
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);


	int n;
	cin >> n;

	ll sum = 0;
	int a[n];
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		sum += a[i];
	}

	ll res = 9e18;
	ll pref = 0;
	for(int i = 0; i + 1 < n; ++i){
		pref += a[i];
		ll suff = sum - pref;
		res = min(res, abs(pref - suff));
	}

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

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

if len(str(N)) == 1:
    print(N)
if len(str(N)) == 2:
    print(9)
if len(str(N)) == 3:
    print(N-100+1+9)
if len(str(N)) == 4:
    print(909)
if len(str(N)) == 5:
    print(N-10000+1+909)
if len(str(N)) == 6:
    print(90909)

Measured memory_bytes: 3064
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n,a,b,c,d;
char s[MAXN+1];

bool solve() {
	while(b<d) {
		if(b-1>=0&&s[b-1]!='#'&&b+1<n&&s[b+1]!='#'&&c>d) break;
		if(b+1<=d&&s[b+1]=='.') { s[b]='.',++b,s[b]='#'; continue; }
		if(b+2<=d&&s[b+2]=='.') { s[b]='.',b+=2,s[b]='#'; continue; }
		return false;
	}
	while(a<c) {
		if(a+1<=c&&s[a+1]=='.') { s[a]='.',++a,s[a]='#'; continue; }
		if(a+2<=c&&s[a+2]=='.') { s[a]='.',a+=2,s[a]='#'; continue; }
		return false;
	}
	while(b<d) {
		if(b+1<=d&&s[b+1]=='.') { s[b]='.',++b,s[b]='#'; continue; }
		if(b+2<=d&&s[b+2]=='.') { s[b]='.',b+=2,s[b]='#'; continue; }
		return false;
	}
	return true;
}

void run() {
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d); --a,--b,--c,--d;
	scanf("%s",s); assert(strlen(s)==n);
	printf("%s\n",solve()?"Yes":"No");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M = 998244353;
const ll inf = 1e18+5;
const ll INF=INT_MAX;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
ll arr[500000],st[500000];
void buildtree(int si,int ss,int se){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si];
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
void update(int si,int ss,int se,int qi){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi);
	else update(2*si+1,mid+1,se,qi);
	st[si]=min(st[2*si],st[2*si+1]);
}
ll max3=1e5;

void solve(){
	ll n,v;
    cin>>n;
    ll a[100001]={0};
    for(ll x=1;x<=100;x++)
    {
        for(ll y=1;y<=100;y++)
        {
            for(ll z=1;z<=100;z++)
            {
               ll  in=x*x+y*y+z*z + x*y+ y*z +z*x;
               a[in]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    cout<<a[i]<<endl;

	
 }
int main(){
	fast();
	solve();
	return 0;
}


Measured memory_bytes: 4392
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int r = Integer.parseInt(sc.next());
		int g = Integer.parseInt(sc.next());
		out.println(r*r-g);
		out.flush();	
	}
}

Measured memory_bytes: 23252
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
A = III()

A.sort()
for i in range(len(A)-1):
    if A[i]==A[i+1]:
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 82288
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	long long N, K;
	cin >> N >> K;

	if (K >= 2) {
		long long ans = 0;
		if (K % 2 == 0) {
			long long num = (2 * N) / K;
			if (num % 2 == 0) {

				ans = num * num * num / 4;
			}
			else {
				ans = (num - 1) * (num - 1) * (num - 1) / 8 + (num + 1) * (num + 1) * (num + 1) / 8;
			}
		}
		else {
			long long num = N / K;
			ans = num * num * num;
		}
		cout << ans << endl;
	}
	else if (K == 1) {
		cout << N * N * N << endl;
	}

	return 0;
}

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

int main(){
  int S;
  cin >> S;
  
  int count=0;
  
  for(int i =0; i<3; i++){
   
  	if(S%10 == 1){
    	count++;
  	}
  
  	S = S/10;
  }
  
  cout << count << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  int i;
  for (i = a; i <= b; i++) {
    if (i / 10000 == i % 10 && (i / 1000) % 10 == (i % 100) / 10) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
def main
  s = gets.chomp

  min = 1000000000
  0.upto(s.length-3) do |i|
    ps = s[i, 3]
    # puts ps

    part = ps.to_i

    abs_part = (part - 753).abs

    if abs_part < min
      min = abs_part
    end
  end

  puts min
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}

void main()
{
  int n, k; readV(n, k);
  int[] x, y; readC(n, x, y);

  auto xc = x.dup.sort().uniq.array, nxc = xc.length.to!int;
  auto yc = y.dup.sort().uniq.array, nyc = yc.length.to!int;

  auto r = 4*10L^^18;
  foreach (i1; 0..nxc-1)
    foreach (i2; i1+1..nxc)
      foreach (j1; 0..nyc-1)
        foreach (j2; j1+1..nyc) {
          auto c = 0;
          foreach (p; 0..n)
            if (xc[i1] <= x[p] && x[p] <= xc[i2] && yc[j1] <= y[p] && y[p] <= yc[j2])
              ++c;
          if (c >= k) r = min(r, (xc[i2]-xc[i1]).to!long * (yc[j2]-yc[j1]));
        }

  writeln(r);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int count = 0;
  vector<int> a(3);
  for (int i = 0; i < 3; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  count += a[2] - a[1];
  count += (a[1] - a[0]) / 2;
  if ((a[1] - a[0]) % 2 == 0) {
    cout << count << endl;
  } else {
    count += 2;
    cout << count << endl;
  }
  return 0;
}

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

struct Query{
    int type;
    long long int x,s,t;
    Query(const int ty,const long long int xx,const long long int ss,const long long int tt){
        type=ty;
        x=xx,s=ss,t=tt;
    }
};

int main() {
    int N,Q;
    long long int L,R;
    cin>>N>>Q>>L>>R;
    vector<long long int>v(N);
    for(auto &i:v)cin>>i;
    //v.push_back(1LL<<63);
    //cout<<(1LL<<63)<<endl;
    sort(v.begin(),v.end());
    vector<Query>q;
    for(int i=0;i<Q;i++){
        long long int a,b,c,d;
        cin>>a>>b>>c>>d;
        q.push_back(Query(a,b,c,d));
    }
    //cout<<"hoge"<<endl;
    int Lindex=0;
    int l=-1,r=v.size();
    while(r-l>1){
        int mid=(l+r)/2;
       //cout<<l<<" "<<r<<endl;
        long long int num=v[mid];
        for(auto i:q){
                if(i.type==1){
                    if(i.x<=num){
                        num+=i.s;
                        num*=i.t;
                    }
                }
                else {
                    if(i.x>=num){
                        num-=i.s;
                        if(num)num=(abs(num)/i.t)*(num/abs(num));
                    }
                }
        }
        if(num>=L)r=mid;
        else l=mid;
    }
    Lindex=l;
    l=-1,r=v.size();
    int Rindex=0;
    while(r-l>1){
        int mid=(l+r)/2;
        long long int num=v[mid];
        for(auto i:q){
                if(i.type==1){
                    if(i.x<=num){
                        num+=i.s;
                        num*=i.t;
                    }
                }
                else {
                    if(i.x>=num){
                        num-=i.s;
                        if(num)num=(abs(num)/i.t)*(num/abs(num));
                    }
                }
        }
        //cout<<mid<<" "<<num<<endl;
        if(num>R)r=mid;
        else l=mid;
    }
    Rindex=l;
    //cout<<Rindex<<" "<<Lindex<<endl;
    cout<<Rindex-Lindex<<endl;
    return 0;
}


Measured memory_bytes: 12728
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

class UnionFindTree:

    def __init__(self, N):
        self.par = list(range(N))

    def find_root(self, x):
        if self.par[x] != x:
            self.par[x] = self.find_root(self.par[x])
        return self.par[x]

    def union(self, a, b):
        a_root = self.find_root(a)
        b_root = self.find_root(b)
        self.par[a_root] = b_root
        return


def solve(N: int, K: int, L: int, p: "List[int]", q: "List[int]", r: "List[int]", s: "List[int]"):
    k_uf = UnionFindTree(N)
    l_uf = UnionFindTree(N)
    ret = [1] * N
    for i in range(K):
        k_uf.union(p[i] - 1, q[i] - 1)
    for i in range(L):
        l_uf.union(r[i] - 1, s[i] - 1)

    pars = []
    for i in range(N):
        pars.append((k_uf.find_root(i), l_uf.find_root(i), i))
    pars.sort()
    #print(pars)
    ret = [1] * N
    tmp = set()
    for i in range(1, N):
        if pars[i][0] == pars[i - 1][0] and pars[i][1] == pars[i - 1][1]:
            tmp.add(pars[i][2])
            tmp.add(pars[i - 1][2])
        else:
            cnt = len(tmp)
            for x in tmp:
                ret[x] = cnt
            tmp = set()
    for x in tmp:
        ret[x] = len(tmp)
    print(' '.join([str(r) for r in ret]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    p = [int()] * (K)  # type: "List[int]" 
    q = [int()] * (K)  # type: "List[int]" 
    for i in range(K):
        p[i] = int(next(tokens))
        q[i] = int(next(tokens))
    r = [int()] * (L)  # type: "List[int]" 
    s = [int()] * (L)  # type: "List[int]" 
    for i in range(L):
        r[i] = int(next(tokens))
        s[i] = int(next(tokens))
    solve(N, K, L, p, q, r, s)

if __name__ == '__main__':
    main()


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

int main(){
  constexpr int Nbit= 1e5;
  int N,M;
  cin >> N >> M;

  vector<int> data(N, 1);
  bitset<Nbit> plausible;
  plausible.set(0);
  int from,to;
  for(int j=0; j<M; j++){
    cin >> from >> to;
    from--; to--; // 1-indexed -> 0-indexed
    data.at(from)--;
    data.at(to)++;
    if(plausible.test(from)){
      plausible.set(to);
    }
    if(data.at(from)==0){
      plausible.reset(from);
    }
  }

  int ans= plausible.count();

  cout << ans << endl;
}

Measured memory_bytes: 3704
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Weather Forecast
public class Main{

	int[][] cover = {
			{0,1,4,5},
			{1,2,5,6},
			{2,3,6,7},
			{4,5,8,9},
			{5,6,9,10},
			{6,7,10,11},
			{8,9,12,13},
			{9,10,13,14},
			{10,11,14,15}
	};
	int move[][] = {
			{0,1,2,3,6},
			{0,1,2,4,7},
			{0,1,2,5,8},
			{0,3,4,5,6},
			{1,3,4,5,7},
			{2,3,4,5,8},
			{0,3,6,7,8},
			{1,4,6,7,8},
			{2,5,6,7,8}
	};
	
	long trans(int[] a){
		String s = "";
		for(int x:a)s+=x;
		return Long.parseLong(s);
	}
	
	int n;
	boolean sun[][];
	Set<Long>[][] set;
	
	//xツ禿コツづ可雲ツつェposツづ可仰渉づづヲツつ「ツつゥ
	boolean ok(int x, int pos){
		for(int i=0;i<4;i++)if(sun[x][cover[pos][i]])return false;
		return true;
	}
	
	boolean get(int x, int pos, int[] a){
		if(x==n)return true;
		if(set[x][pos].contains(trans(a)))return false;
		if(!ok(x, pos)){
			set[x][pos].add(trans(a));return false;
		}
		for(int j=0;j<5;j++){
			int[] t = new int[16];
			for(int i=0;i<16;i++)t[i]=a[i]-1;
			int nx = move[pos][j];
			for(int i=0;i<4;i++)t[cover[nx][i]] = 6;
			boolean f = true;
			for(int i=0;i<16;i++)if(t[i]<0)f = false;
			if(!f)continue;
			if(get(x+1, nx, t))return true;
		}
		set[x][pos].add(trans(a));
		return false;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			sun = new boolean[n][16];
			for(int i=0;i<n;i++)for(int j=0;j<16;j++)sun[i][j] = sc.nextInt()==1;
			set = new HashSet[n][9];
			for(int i=0;i<n;i++)for(int j=0;j<9;j++)set[i][j] = new HashSet<Long>();
			int[] a = new int[16];
			Arrays.fill(a, 5);
			if(!ok(0, 4)){
				System.out.println(0);continue;
			}
			for(int j=0;j<4;j++)a[cover[4][j]] = 6;
			System.out.println(get(0, 4, a)?1:0);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(void){
  int s;
  cin>>s;
  bool flg[1000000];
  flg[s]=true;
  for(int i=0;i<1000000;i++){
      if(s%2==0) s=s/2;
      else s=3*s+1;
      if(flg[s]){
          cout<<i+2<<endl;
          return 0;
      }
      flg[s]=true;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

const int mxn = 5e5 + 100;
int a[mxn], last[mxn];
vector<int> t(4 * mxn);

int query(int v, int tl, int tr, int l, int r)
{
	if(l > r)
		return 0;
	if(l == tl && r == tr)
		return t[v];
	else
	{
		int mid = (tl + tr) / 2;
		return query(2 * v, tl, mid, l, min(r, mid)) + query(2 * v + 1, mid + 1, tr, max(l, mid + 1), r);
	}
}

void update(int v, int tl, int tr, int pos, int val)
{
	if(tl == tr)
		t[v] = val;
	else
	{
		int mid = (tl + tr) / 2;
		if(pos <= mid)
			update(2 * v, tl, mid, pos, val);
		else
			update(2 * v + 1, mid + 1, tr, pos, val);
		t[v] = t[2 * v] + t[2 * v + 1];
	}
}

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

	int n, q, i, l, r;
	cin >> n >> q;
	mset(last, -1);
	rep(i, 0, n)
		cin >> a[i];
	//build(1, 0, n - 1);
	vector<vpii> que(n);
	vi ans(q);
	rep(i, 0, q)
	{
		cin >> l >> r;
		l--; r--;
		que[r].pb({l, i});
	}
	
	rep(i, 0, n)
	{
		update(1, 0, n - 1, i, 1);
		if(last[a[i]] != -1)
			update(1, 0, n - 1, last[a[i]], 0);
		last[a[i]] = i;
		for(pii& curr : que[i])
			ans[curr.ss] = query(1, 0, n - 1, curr.first, i);
	}

	rep(i, 0, q)
		cout << ans[i] << endl;
}

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

long long q, h, s, d, n;
int main()
{
	cin >> q >> h >> s >> d >> n;
    cout << n / 2 * min(min(q * 8, h * 4), min(s * 2, d)) + n % 2 * min(q * 4, min(h * 2, s)) << endl;
    return 0;
}

Measured memory_bytes: 256
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# 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 string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N=int(input())
    l=[]
    for i in range(N):
        l.append(str(input()))
    L=Counter(l)
    print(len(L))



resolve()

Measured memory_bytes: 128936
#include<stdio.h>
#include<vector>
#include<climits>
#include<math.h>
using namespace std;

int min(const int& a, const int& b){
    return a < b? a : b;
}
int updateUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& v, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return tree[k];
    if(l >= L && r <= R){
        tree[k] = v;
        if(l < r){
            lazy[2*k+1] = v;
            lazy[2*k+2] = v;
        }
    }
    else{
        int mid = l+(r-l)/2;
        tree[k] = min(updateUtil(tree, lazy, L, R, v, 2*k+1, l, mid), updateUtil(tree, lazy, L, R, v, 2*k+2, mid+1, r)); 
    }
    return tree[k];
}

void update(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R, const int& v){
    updateUtil(tree, lazy, L, R, v, 0, 0, n-1);
}

int findUtil(vector<int>& tree, vector<int>& lazy, const int& L, const int& R, const int& k, const int& l, const int& r){
    if(k > tree.size() || l > r) return INT_MAX;
    if(lazy[k] >= 0){
        tree[k] = lazy[k];
        if(l < r){
            lazy[2*k+1] = lazy[k];
            lazy[2*k+2] = lazy[k];
        }
        lazy[k] = -1;
    }
    if(l > R || r < L) return INT_MAX;
    if(l >= L && r <= R) return tree[k];
    int mid = l+(r-l)/2;
    return min(findUtil(tree, lazy, L, R, 2*k+1, l, mid), findUtil(tree, lazy, L, R, 2*k+2, mid+1, r));
}

int find(vector<int>& tree, vector<int>& lazy, const int& n, const int& L, const int& R){
    return findUtil(tree, lazy, L, R, 0, 0, n-1);
}
int main(){
    int n, q, com, s, t, x;
    scanf("%d %d", &n, &q);
    int h = (int)ceil(log2(n));
    int max_size = 2*(int)pow(2, h)-1;
    vector<int> tree(max_size, INT_MAX);
    vector<int> lazy(max_size, -1);
    for(int i = 0; i < q; i++){
        scanf("%d", &com);
        if(com == 0){
            scanf("%d %d %d", &s, &t, &x);
            update(tree, lazy, n, s, t, x);
        }
        else if(com == 1){
            scanf("%d %d", &s, &t);
            printf("%d\n", find(tree, lazy, n, s, t));
        }
        else printf("undefined com\n");
    }    
}



Measured memory_bytes: 4744
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])
    new_str = ""
    for i, c in enumerate(inputs[1]):
        if i == K-1:
            new_str += c.lower()
        else:
            new_str += c
    return new_str


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 3316
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = I()
    b = I()
    c = I()
    x = I() // 50
    r = [0] * (x+1)
    r[0] = 1
    u = [0] * (x+1)
    for i in range(c):
        if i+1 > x:
            break
        r[i+1] = 1
    for i in range(1,b+1):
        for j in range(x):
            if i*2+j > x:
                break
            u[i*2+j] += r[j]
    for i in range(x+1):
        r[i] += u[i]
    u = [0] * (x+1)
    for i in range(1,a+1):
        for j in range(x):
            if i*10+j > x:
                break
            u[i*10+j] += r[j]
    for i in range(x+1):
        r[i] += u[i]

    return r[x]



print(main())




Measured memory_bytes: 5464
open System

let sumChar (ss: string) =
    Seq.map (Char.GetNumericValue >> int) ss |> Seq.sum

let [|N; A; B|] = stdin.ReadLine().Split(' ') |> Array.map int

[1..N]
|> Seq.map string
|> Seq.sumBy (fun c -> if A <= (sumChar c) && (sumChar c) <= B then int c else 0)
|> printf "%d"


Measured memory_bytes: 34244