akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
ab = [[int(x) for x in input().split()] for _ in range(n)]
cd = [[int(x) for x in input().split()] for _ in range(m)]


for i in range(n):
    cnt = 10**9
    num = 0
    for j in range(m):
        c = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if c<cnt:
            cnt = c
            num = j+1
    print(num)


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k[112345],l[112345];
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>k[i]>>l[i];
  }
  
  for(int i=1;i<=a;i++){
    int count=0;
    for(int m=0;m<b;m++){
      if(k[m]==i||l[m]==i){
        count++;
      }
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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 = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, Ma, Mb;
    cin >> N >> Ma >> Mb;

    vec3 f(N + 1, vec2(410, vec(410, 1e18)));
    f[0][0][0] = 0;

    rep1(i, N){
        ll a, b, c;
        cin >> a >> b >> c;
        rep(j, 401) rep(k, 401) if (j >= a and k >= b) chmin(f[i][j][k], f[i - 1][j - a][k - b] + c);
        rep(j, 401) rep(k, 401) chmin(f[i][j][k], f[i - 1][j][k]);
    }

    ll ans = 1e18;
    ll k = 1;
    while(Ma * k <= 400 and Mb * k <= 400){
        chmin(ans, f[N][Ma * k][Mb * k]);
        ++k;
    }
    if(ans == 1e18) drop(-1);
    print(ans);

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b;
	map<int,int> ct;
	for (int i=0; i<2; i++) {
		cin>>a>>b;
		for (int j=a; j<b; j++)
			ct[j]++;
	}
	int ret=0;
	for (auto it : ct)
		if(it.second==2)
			ret++;
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,tmp;
	int m = 0;
	int sum = 0;
	cin >> N;
	for (int i = 0;i < N;i++){
		cin >> tmp;
		m = max(m,tmp);
		sum += tmp;
	}	
	if (sum - m > m){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;

int main(){
    int N; cin >> N;
    vector<pair<int, int>> c(N);//配列の宣言
for(int i = 0; i < N ; i++){
  int a,b;
  cin >> a >> b;
  c[i] = make_pair(b,a);//配列型のpairに代入
}
  sort(c.begin(),c.end());//pair.firstを小さい順にsort
  int sum = 0;
  bool ans = true;
  rep(i,N){
        sum+= c[i].second;
        if(sum > c[i].first){
            ans = false;
            break;
        }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int result_1 = A + B;
		int result_2 = B - A;
		if (B % A == 0){
			System.out.println(result_1);	
		}
		else {
			System.out.println(result_2);
		}
	}
}

Measured memory_bytes: 21844
N = int(input())
S = tuple([input() for _ in range(N)])
AC = 'AC'
acc = 0
WA = 'WA'
wac = 0
TLE = 'TLE'
tlec = 0
RE = 'RE'
rec = 0
for val in S:
    if val == AC:
        acc += 1
    elif val == WA:
        wac += 1
    elif val == TLE:
        tlec += 1
    elif val == RE:
        rec += 1
for i in range(4):
    key = [AC,WA,TLE,RE]
    count = [acc,wac,tlec,rec]
    print("%s x %d"%(key[i],count[i]))


Measured memory_bytes: 16728
s = int(input())
b = s%100
a = (s - b)//100
if (0 < a <= 12 and 0 < b <= 12):
    print("AMBIGUOUS")
elif (0 < a <= 12):
    print("MMYY")
elif (0 < b <= 12):
    print("YYMM")
else:
    print("NA")


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

void Impossible(){
	cout<<"Impossible"<<endl;
	exit(0);
}

const int Nmax=100010;
vi g[Nmax];
bool vis[Nmax];
int a[Nmax];
void dfs(int v,vi&dst){
	if(vis[v])return;
	vis[v]=true;
	dst.PB(a[v]);
	for(auto to:g[v])
		dfs(to,dst);
}

signed main(){
	int n=read(),m=read();
	REP(i,n)a[i]=read();
	REP(i,m){
		int x=read(),y=read();
		g[x].PB(y);
		g[y].PB(x);
	}
	vector<vi> cost;
	int con=0;
	REP(i,n)if(!vis[i]){
		con++;
		vi waf;
		dfs(i,waf);
		cost.PB(waf);
	}
	if(con==1){
		cout<<0<<endl;
		return 0;
	}
	int ans=0;
	vi hog;
	for(auto cs:cost){
		sort(ALL(cs));
		//cerr<<cs<<endl;
		int len=min(con-1,int(cs.size()));
		//cerr<<len<<endl;
		FOR(i,1,len)hog.PB(cs[i]);
		ans+=cs[0];
	}
	//cerr<<hog<<endl;
	if(int(hog.size())<(con-2))
		Impossible();
	sort(ALL(hog));
	ans+=accumulate(hog.begin(),hog.begin()+(con-2),int(0));
	cout<<ans<<endl;
}

Measured memory_bytes: 11060
L,R = (int(i) for i in input().split())

minimum = 2019
checked = set()

start = L
end   = R+1

end2 = min(end, start+1+2019)
for i in range(start, end2):
    a = i % 2019
    if a not in checked:
        checked.add(a)
        endd = min(end, i+1+2019)
        for j in range(i+1, endd):
            v = (i * j) % 2019
            minimum = min([v, minimum])

print(minimum)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }
    const ll maxDigit = 50;
    vector<ll> one(maxDigit, 0), zero(maxDigit, 0);
    REP(i, N)
    {
        REP(j, maxDigit)
        {
            ll num = A[i];
            if ((num >> j) & 1)
            {
                one[j]++;
            }
            else
            {
                zero[j]++;
            }
        }
    }

    ll X = 0;
    ll exp = 1;
    ll ans = 0;
    REP(i, maxDigit - 1)
    {
        exp *= 2;
    }
    for (ll i = maxDigit - 1; i >= 0; --i)
    {
        if (X + exp <= K)
        {
            if (one[i] >= zero[i])
            {
                ans += exp * one[i];
            }
            else
            {
                ans += exp * zero[i];
                X += exp;
            }
        }
        else
        {
            ans += exp * one[i];
        }
        
        exp /= 2;
    }

    cout << ans << endl;
}


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

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    
    char A = toupper(a[0]);
    char B = toupper(b[0]);
    char C = toupper(c[0]);
    
    cout << A << B << C;
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  bool finish = false;
  while (!finish) {
    for (int i=0; i<1; i++) {
      s.pop_back();
    }
    string a = "", b = "";
    for (int i=0; i<s.size()/2; i++) {
      a.push_back(s.at(i));
      b.push_back(s.at(s.size()/2+i));
    }
    if (a == b) {
      finish = true;
      cout << s.size() -1 << endl;
    }
  }
}
      

Measured memory_bytes: 256
from itertools import product
N = int(input())

res = [[None]*(N-i-1) for i in range(N-1)]
def register(i,j,c):
    if i > j:
        i,j = j,i
    res[i][j-i-1] = c

d = 1
c = 1
while d < N:
    X = []
    Y = []
    for i in range(0,N,2*d):
        X.extend(range(i,min(N,i+d)))
        Y.extend(range(min(N,i+d), min(N,i+2*d)))

    for x,y in product(X,Y):
        register(x,y,c)
    d *= 2
    c += 1

for r in res:
    print(*r)

Measured memory_bytes: 4976
H,W = map(int,input().split())
a = [""] * H #空白のリスト
for i in range(H):
    a[i] = input()

row = [False] * H #真偽値の2次元配列
col = [False] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == "#": #一つでも#があれば真
            row[i] = True
            col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j],end="")

        print()


Measured memory_bytes: 4468
inputText1 = input()
# inputText1 = "1000000000"
inputNumber1 = int(inputText1)
c500 = 0
c5 = 0
c500 = inputNumber1 // 500
inputNumber1 = inputNumber1 % 500
c5 = inputNumber1 // 5
print((c500 * 1000) + (c5 * 5))


Measured memory_bytes: 2940
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut h: Vec<usize> = sc.vec(n);
    h.sort();
    if n <= k {
        println!("0");
    } else {
        let ans = &h[0..(n - k)].iter().sum::<usize>();
        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 6524
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    if (A > K) {
        cout << K << endl;
        return 0;
    } else if (B > (K - A)) {
        cout << A << endl;
        return 0;
    } else {
        cout << (A - (K - (A + B))) << endl;
        return 0;
    }    
}


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

int main() {
  int64_t a[3];

  for (int i = 0; i < 3; i++) {
    std::cin >> a[i];
  }

  std::sort(std::begin(a), std::end(a));

  std::cout << a[0] + a[1] << std::endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    h.sort()
    ret = float('inf')
    for i in range(K - 1, N):
        ret = min(ret, h[i] - h[i - K + 1])
    print(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
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n,masu[1000][1000];
  while(scanf("%d %d %d",&h,&w,&n),h!=0||w!=0||n!=0){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	scanf("%d",&masu[i][j]);
      }
    }
    int dp[1000][1000]={};
    dp[0][0] = n-1;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(i > 0){
	  if(dp[i-1][j]%2 == 0){
	    dp[i][j] += dp[i-1][j]/2;
	  } else {
	    if(masu[i-1][j] == 0){
	      dp[i][j] += (dp[i-1][j]+1)/2;
	    } else {
	      dp[i][j] += dp[i-1][j]/2;
	    }
	  }
	}
	if(j > 0){
	  if(dp[i][j-1]%2 == 0){
	    dp[i][j] += dp[i][j-1]/2;        
	  } else {
	    if(masu[i][j-1] == 1){
	      dp[i][j] += (dp[i][j-1]+1)/2;
	    } else {
	      dp[i][j] += dp[i][j-1]/2;
	    }
	  }
	}
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	masu[i][j] = (masu[i][j]+dp[i][j])&1;
      }
    }
    int y=0,x=0;
    while(y<h&&x<w){
      if(masu[y][x] == 1) x++;
      else y++;
    }
    printf("%d %d\n",y+1,x+1);
  }
  return(0);
}



Measured memory_bytes: 10908
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define SORT(A) sort(A.begin(), A.end())
#define SORTG(A) sort(A.begin(), A.end(), greater<int>())
#define bit_search(bit, n) REP(bit, 1<<n)
#define bit_check(bit, i) (bit>>i) & 1
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using PII = pair<int, int>;
using ll = long long;
const int INF = 1e9;

int main()
{
    int D, G;
    cin >> D >> G;
    PII pro[D];
    REP(i, D) cin >> pro[i].first >> pro[i].second;
    int ans = INF;

    bit_search(bit, D)
    {
        VB flg(D, false);
        int ct = 0;
        int score = 0;
        REP(i, D)
        {
            if (bit_check(bit, i))
            {
                ct += pro[i].first;
                score += pro[i].first * (i+1) * 100 + pro[i].second;
                flg.at(i) = true;
            }
        }
        if (score >= G) ans = min(ans, ct);
        else
        {
            REPR(i, D)
            {
                if (flg.at(i)) continue;
                else
                {
                    int p = pro[i].first;
                    if (score+(p-1)*(i+1)*100>=G)
                    {
                        int dif = G - score;
                        ct += ceil((double)dif/(double)((i+1)*100));
                        ans = min(ans, ct);
                        break;
                    }
                    else
                    {
                        score += (p-1)*(i+1)*100;
                        ct += p-1;
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// No.210400012020
// @ UBUNTU
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 2020
using namespace std;

int n, m, Q, sum[N][N], emmm[N][N], emm[N][N];
char s[N][N];

inline int getsum(int x1, int y1, int x2, int y2) {
    return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
}

inline int getemmm(int x1, int y1, int x2, int y2) {
    return emmm[x2][y2] - emmm[x1 - 1][y2] - emmm[x2][y1] + emmm[x1 - 1][y1];
}

inline int getemm(int x1, int y1, int x2, int y2) {
    return emm[x2][y2] - emm[x1][y2] - emm[x2][y1 - 1] + emm[x1][y1 - 1];
}

int main() {
#ifdef LOCAL_JUDGE
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n >> m >> Q;

    for (int i = 1; i <= n; ++i)
        scanf("%s", s[i] + 1);

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (s[i][j] == '1');
            emmm[i][j] = emmm[i - 1][j] + emmm[i][j - 1] - emmm[i - 1][j - 1];
            emm[i][j] = emm[i - 1][j] + emm[i][j - 1] - emm[i - 1][j - 1];
            if (s[i][j] == '1' && s[i][j - 1] == '1') ++emmm[i][j];
            if (s[i][j] == '1' && s[i - 1][j] == '1') ++emm[i][j];
        }

    while (Q--) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        printf("%d\n", getsum(x1, y1, x2, y2) - getemmm(x1, y1, x2, y2) - getemm(x1, y1, x2, y2));
    }

    return 0;
}


Measured memory_bytes: 53504
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

int N;
vector<long long> A;
vector<vector<long long>> D;

int main() {
	cin >> N;
	A.resize(N + 1);
	for (int n = 1; n <= N; n++)cin >> A[n];
	D.resize(20, vector<long long>(N + 1, 0));
	for (int n = 2; n <= N; n++) {
		for (int c = 0; c < 20; c++) {
			if ((A[n - 1] >> c) & 1)D[c][n] = n - 1;
			else D[c][n] = D[c][n - 1];
		}
	}
	long long ans = 0;
	for (int n = 1; n <= N; n++) {
		long long temp = LLONG_MAX;
		for (int c = 0; c < 20; c++) {
			if ((A[n] >> c) & 1)temp = min(temp, n - D[c][n]);
			else temp = min(temp,n-D[c][D[c][n]]);
		}
		ans += temp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 34688
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
#define maxx 110000
typedef long long ll;
string a;

int main()
{
    int n;
    cin>>n;
    cin>>a;
    int lenl=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='.')
        {
            lenl++;
        }
    }
    int ans1=lenl,ans2=0;
    for(int i=0;i<=n-1;i++)
    {
        if(a[i]=='#') ans2++;
        else lenl--;
        ans1=min(ans1,lenl+ans2);
    }
    cout<<ans1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
int find_length(vector<int>&v,map<int,vector<int>>&graph,int id){
  if(v[id]!=-1)return v[id];
  if(graph[id].size()==0)return 0;
  int x=0;
  for(int i=0;i<graph[id].size();i++){
    x=max(x,find_length(v,graph,graph[id][i]));
  }
  v[id]=x+1;
  return v[id];

}
int32_t main(){
  int n,m;
  map<int,vector<int>>graph;
  cin>>n>>m;
  int k,l;
  for(int i=0;i<m;i++){
    cin>>k>>l;
    graph[k].push_back(l);
  }
  vector<int>v(n+1,-1);
  int ans=0;
  for(int i=1;i<=n;i++){
    if(v[i]==-1){
      ans=max(ans,find_length(v,graph,i));
    }
  }
  cout<<ans;
}


Measured memory_bytes: 16768
using System;

namespace abca094
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, x;
            string[] str = Console.ReadLine().Split(' ');
            a =int.Parse(str[0]);
            b =int.Parse(str[1]);
            x =int.Parse(str[2]);
            if (a <= x && a + b >= x)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            Console.ReadKey();

                 




        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, T;
	cin >> n >> T;
	vector<int> t(n);
	rep(i, n) cin >> t[i];
	ll ans = 0;
	rep(i, n - 1) {
		ans += min(T, t[i + 1] - t[i]);
	}
	ans += T;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e6+10;
typedef long long ll;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
bool check(ll x)
{
    if(x==1)    return false;
    for(ll i=2;i<=x/i;i++)
    if(x%i==0)  return false;
    return true;
}
ll a[N];
int main()
{
    ll x,y;
    cin>>x>>y;
    int cnt=0;
    ll c=min(x,y),d=max(x,y);
    for(ll i=1;i<=c/i;i++)
    {
        if(c%i==0)  
        {
            a[cnt++]=i;
            a[cnt++]=c/i;
        }
    }
    int res=0;
    for(int i=0;i<cnt;i++)
    if(check(a[i])&&d%a[i]==0) res++;
    cout<<res+1;
}

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

int s[200009];
map<int, int> mp;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        int a; cin >> a; a--;
        s[i] = (s[i - 1] + a) % k;
        mp[s[i]] = 0;
    }
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i >= k) mp[s[i - k]]--;
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 10496
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, N)cin >> A[i];
    int tot = accumulate(A.begin(), A.end(), 0);

    int cnt = 0;
    for (auto a : A) {
        if (a * 4 * M >= tot)cnt++;
    }
    output(cnt >= M ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;
 
using namespace std;
 
int main(){
    cin.tie(0), ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;
 
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
 
    vector<bool> jud(n,false);
    int ans=0;
    REP(i,n){
        int max=-1;
        for(int j=0;red[j].f1<blue[i].f1&&j<n;j++){
            if(jud[j]) continue;
            if(red[j].s2 < blue[i].s2){
                if(max==-1||red[max].s2 < red[j].s2) max=j;
            }
        }
        if(max>-1){
            jud[max] = true;
            ++ans;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int x = 0; x <= K; ++x)
	{
		for (int y = 0; y <= K; ++y)
		{
			if ((S - x - y) <= K && (S - x - y) >= 0)
			{
				ans++;
			}
		}
	}

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

Measured memory_bytes: 3600
#include <iostream> 
 
using namespace std; 
 
int main(){ 
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	for(int i = 1; i < n; i++){
		cin >> c[i];
	}
	
	int pre_num = -100;
	int satisfaction = 0;
	for(int i = 0; i < n; i++){
		int dish_num = a[i]-1;
		satisfaction += b[dish_num];
		if(dish_num == pre_num+1) satisfaction += c[dish_num];
		pre_num = dish_num;
	}
	cout << satisfaction << endl;
	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 char ch[1000000];
int main(){
     int a,b,h;
     cin>>a>>b>>h;
      int ans=a+b;
       long long res=(0.5)*(ans*h);
     cout<<res<<endl;
    return 0;
   }

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    ll a;
    string b;
    cin >> a >> b;
    //ll b = 1;
    int now = 0;
    for (auto x : b)
    {
        if (x == '.')
            continue;
        else
        {
            now = now * 10 + (x - '0');
            //DBG(now);
        }
    }
    //DBG(now);
    ll ans = a * now / 100;
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(0);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n, h, w; cin >> n >> h >> w;

    cout << (n-h+1) * (n-w+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int check(int x){
  int k=10;
  int ret=1;
  while(true){
    if(k>x){
      return ret;
    }
    ret++;
    k*=10;
  }
}
int main(){
  int N; cin >> N;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(check(i)%2==1){
      ans++;
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

#define alice cout<<"Alice"<<endl
#define bob cout<<"Bob"<<endl
int main(){
    
    int a,b;
    cin>>a>>b;
    if(a==1&&b!=1){
        alice;
    }
    else if(a!=1&&b==1){
        bob;
    }
    else if(a==b){
        cout<<"Draw"<<endl;
    }
    else{
        (a>b) ? alice :bob;
    }





}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
flag = [0] * (N+1)
cnt = [0] * (N+1)
now = 0
i = 1
while(flag[i] == 0 and K > now):
  flag[i] = 1
  cnt[i] = now
  i = A[i-1]
  now += 1
if(K <= now):
  print(i)
else:
  loop = now-cnt[i]
  kn = (K-now)%loop
  for j in range(kn):
    i = A[i-1]
  print(i)

Measured memory_bytes: 92752
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    double PI = 3.14159265359;
    int A,B,H,M;
    cin >> A >> B >> H >> M;
    
    double ans = 0;
    double time = 30.0f * H + 0.5f * M;
    double mini = 6.0f * M;
    double sum = abs(mini - time);;
    
    ans = A*A + B*B - (2*A*B*cos(sum * PI / 180.0f));
    cout << fixed << setprecision(20);
    cout << sqrt(ans) << endl;
}

Measured memory_bytes: 4188
a, b, c, k = gets.split.map(&:to_i)
total = 0
if a <= k
 total += a
 k -= a
else
 total += k
 puts total
 exit
end
if k == 0 || k <= b 
  puts total
  exit
else
  k -= b
end
if k == 0
  puts total
  exit
end
total -= k
puts total


Measured memory_bytes: 14320
import numpy

N, D = map(int, input().split())

lstMain = list()
for i in range(0, N):
    lstMain.append(list(map(int, input().split())))

count = 0
for i in range(0, N):
    for j in range(i+1, N):
        y = numpy.array(lstMain[i])
        z = numpy.array(lstMain[j])
        u = z - y
        distance = float(numpy.linalg.norm(u))
        if distance.is_integer():
            count += 1

print(count)

Measured memory_bytes: 12424
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){//最大公約数
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

ll lcm(ll a, ll b){//最小公倍数
    return a * b / gcd(a, b);
}

ll sosuu(ll x){
    for(int i = 2; i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}


//入力
int n, k, s;

int main(){

    cin >> n >> k >> s;
    int tmp = -1;

    if(s == 1) tmp = 1;

    int ans[n+1];
    for(int i = 1; i <= n; i++){
        if(i <= k){
            ans[i] = s;
        }
        else{
            ans[i] = s + tmp;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
    p.at(i) = (1 + p.at(i)) / 2.0;
  }
  vector<double> q(N - K + 1);
  double a = 0;
  for (int i = 0; i < K; i++) {
    a += p.at(i);
  }
  double M = a;
  for (int i = 0; i < N - K; i++) {
    a += p.at(i + K) - p.at(i);
    M = max(a, M);
  }
  printf("%.08lf\n", M);
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e5 + 5;
const long oo = 1e15;

long n;
long a[MAXN] , b[MAXN] , c[MAXN] , dp[MAXN][3];

void Solve() {
    dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
    ft(i , 2 , n) {
        dp[i][0] = max(dp[i - 1][1] , dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0] , dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][1] , dp[i - 1][0]) + c[i];
    }
    //cout << dp[2][0];
    cout << max(dp[n][0] , max(dp[n][1] , dp[n][2]));
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("VACATION.inp", "r", stdin);
    //freopen("VACATION.out", "w", stdout);
}

void Input() {
    cin >> n;
    ft(i , 1 , n) cin >> a[i] >> b[i] >> c[i];
}

int main() {
    FastInput();
    Input();
    Solve();
}

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

int main(void){
    int n, q;
    int i, j;
    int *S, *T;
    S = (int*)malloc(sizeof(int) *10000);
    T = (int*)malloc(sizeof(int) *500);
    int cnt = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }

    for (i = 0; i < q; i++){
        for (j = 0; j < n; j++){
            if (T[i] == S[j]){
                cnt++;
                break;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1820
def main():
    def trial_division(n):
        divs = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divs.add(i)
                if i != n//i:
                    divs.add(n//i)
        return divs

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    N = int(input())
    ans = 0
    divs = trial_division(N) | trial_division(N-1)
    for d in divs:
        if d == 1:
            continue
        num = N
        while num % d == 0 and d <= num:
            num //= d
        if num % d == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

vector<vector<int>> to;
vector<int> ord, low;
vector<bool> is_articulation;
vector<pair<int, int>> bridge;
int num = 0;

void dfs(int v, int p=-1) {
    ord[v] = num++;
    low[v] = ord[v];
    int child = 0;
    for (auto u : to[v]) {
        if (ord[u] == -1) {
            child++;
            dfs(u, v);
            low[v] = min(low[v], low[u]);
            if (p != -1 && ord[v] <= low[u]) is_articulation[v] = true;
            if (ord[v] < low[u]) bridge.emplace_back(min(v, u), max(v, u));
        } else if (u != p) {
            low[v] = min(low[v], ord[u]);
        }
    }
    if (p == -1 && child >= 2) is_articulation[v] = true;
}

void lowlink(int v) {
    ord.resize(v, -1);
    low.resize(v);
    is_articulation.resize(v);
    dfs(0);
    sort(bridge.begin(), bridge.end());
}

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

    int v, e;
    cin >> v >> e;
    to.resize(v);
    rep(i, e) {
        int s, t;
        cin >> s >> t;
        to[s].pb(t);
        to[t].pb(s);
    }
    lowlink(v);
    rep(i, sz(bridge)) cout << bridge[i].fi << " " << bridge[i].se << endl;
}



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

int main()
{
    int n , summ=0 , k;
    cin>>n>>k;
    int arr[n];
    for( int i=0 ; i<n ; i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0 ; i<k ; i++){
        summ+=arr[i];
    }
    cout<<summ;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main(){
int w;
int h;
int b;
int c;
while(cin >>w>>h){
if(w==0&&h==0){break;}
int a[w][h][2][2];//w列h行で2個前東、北、一個前
b=1;
while(b<w){
a[b][0][0][0]=1;
a[b][0][0][1]=0;
a[b][0][1][0]=0;
a[b][0][1][1]=0;
b=b+1;}
b=1;
while(b<h){
a[0][b][0][0]=0;
a[0][b][0][1]=0;
a[0][b][1][0]=0;
a[0][b][1][1]=1;
b=b+1;}
b=1;
while(b<w){
c=1;
while(c<h){
a[b][c][0][0]=(a[b-1][c][0][0]+a[b-1][c][1][0])%100000;
a[b][c][0][1]=(a[b][c-1][0][0])%100000;
a[b][c][1][0]=(a[b-1][c][1][1])%100000;
a[b][c][1][1]=(a[b][c-1][0][1]+a[b][c-1][1][1])%100000;
c=c+1;}
b=b+1;}
cout <<(a[w-1][h-1][0][0]+a[w-1][h-1][0][1]+a[w-1][h-1][1][0]+a[w-1][h-1][1][1])%100000<<endl;}}

Measured memory_bytes: 1316
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
x = abs(A - B)
v = V - W
if v <= 0:
        print('NO')
else:
    if T < x // v:        
        print('NO')
    elif T == x // v and x % v > 0:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 9192
using System;

public class Hello
{
    public const int Prime = 1000000007;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var res = 0L;
        Array.Sort(a);
        if (n % 2 == 0)
            if (checkEven(a, n))
            {
                res = goPow(n / 2);
                Console.WriteLine(res);
            }
            else Console.WriteLine(0);
        else
            if (checkOdd(a, n))
        {
            var w = (long)Math.Pow(2, (n - 1) / 2);
            res = goPow((n - 1) / 2);
            Console.WriteLine(res);
        }
        else Console.WriteLine(0);
    }
    public static int goPow(int n)
    {
        var ret = 1;
        for (int i = 0; i < n; i++)
        {
            ret *= 2;
            ret %= Prime;
        }
        return ret;
    }
    public static bool checkEven(int[] a, int n)
    {
        for (int i = 1; i <= n - 1; i += 2)
            if (a[i - 1] != i | a[i] != i) return false;
        return true;
    }
    public static bool checkOdd(int[] a, int n)
    {
        if (a[0] != 0) return false;
        for (int i = 1; i <= n - 2; i += 2)
            if (a[i] != i + 1 | a[i + 1] != i + 1) return false;
        return true;
    }
}

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

const int maxN = 5005, mod = 1e9 + 7;

int n, ans, m, cnt;
int f[maxN + 1][maxN + 1];
int pa[maxN + 1], sz[maxN + 1], s[maxN + 1];
bool flag[maxN + 1], vis[maxN + 1];

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline int find(int x) { return pa[x] == x ? x : pa[x] = find(pa[x]); }

inline void merge(int x, int y)
{
	x = find(x), y = find(y);
	if(x == y) return;
	pa[x] = y;
	sz[y] += sz[x];
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) pa[i] = i, sz[i] = 1;

	for(int i = 1; i <= n; i++)
	{
		int x;
		scanf("%d", &x);
		if(x == -1) { m ++; vis[i] = true; continue; }
		merge(x, i);
	}

	for(int i = 1; i <= n; i++)
		if(vis[i]) flag[ find(i) ] = true;
	
	ans = 1ll * n * mpow(n - 1, m) % mod;
	for(int i = 1; i <= n; i++)
		if(find(i) == i)
		{
			if(!flag[i]) ans = SUB(ans, mpow(n - 1, m));
			else ans = SUB(ans, 1ll * mpow(n - 1, m - 1) * (sz[i] - 1) % mod), s[++ cnt] = sz[i];
		}

	f[0][0] = 1;
	for(int i = 1; i <= m; i++)
		for(int j = 0; j <= i; j++)
		{
			f[i][j] = f[i - 1][j];
			if(j) f[i][j] = ADD(f[i][j], 1ll * f[i - 1][j - 1] * s[i] % mod);
		}
	
	int t = 1;
	for(int i = 2; i <= m; i++) 
	{
		ans = SUB(ans, 1ll * mpow(n - 1, m - i) * t % mod * f[m][i] % mod);
		t = 1ll * t * i % mod;
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 70608
S_list = list(input())


a_flg = 0
b_flg = 0
i = 0
while i < 3:
  if (S_list[i] == "A"):
    a_flg = 1
  else:
    b_flg = 1
  i += 1

if (a_flg == 1 and b_flg ==1):
  print("Yes")
else:
  print("No")
#


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

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

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

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

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; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cout << fixed << setprecision(9);
	ld n, k;
	cin >> n >> k;

	ld ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ld tmp = 1 / n;
		int now = i;
		while(now < k){ now *= 2; tmp /= 2; }
		ans += tmp;
	}

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

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

int main()
{
	int n; scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j+=i)
			ans+=j;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3812
n = int(input())
a = list(map(int, input().split()))

a_dic = {}
for i in range(n):
    if a[i] in a_dic.keys():
        a_dic[a[i]] += 1
    else:
        a_dic[a[i]] = 1

res = 0
for k, v in a_dic.items():
    if k == v:
        continue
    elif k > v:
        res += v
    else:
        res += v-k
print(res)

Measured memory_bytes: 18160
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from functools import reduce

def calc_gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def main():
  n, k = map(int, input().split())
  la = list(map(int, input().split()))
  if max(la) >= k and k % (reduce(calc_gcd, la)) == 0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')
  
if __name__=='__main__':
  main()



Measured memory_bytes: 14596
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > > 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define err(n) cout<<n<<" ";
#define t1 cout<<",";

void err_mask(ll n){
	if(n==0)return;
	while(n){
		cout<<n%2;
		n/=2;
	}
	cout<<" ";
}
ll MOD= 98244353;

void add_self (ll& a, ll b){
	a+= b;
	a%=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

ll mul(ll a, ll b){
	a*=b;
	a%=MOD;
	return a;
}

void min_self(double& a, double b){
	a= min(a,b);
}


bool conflict(pll a, pll b){
	if(b.fr> a.sc)return 0;
	else return 1;
}


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j;

ll n;cin>>n;
ll d[n];repup(0,n-1,i)cin>>d[i];

ll ans=0;
repup(0,n-1,i){
	repup(i+1,n-1,j){
		ans+= (d[i]*d[j]);
	}
}
cout<<ans;
}
	

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill( (T*)array, (T*)(array+N), val ); }
#define INF 1e9
#define PI (acos(-1))
#define mod (int)1e9+7
int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    a[n] = 0, b[m] = 0;
    REP(i, n)cin >> a[i];
    REP(i, m)cin >> b[i];
    ll book=0,time=0;
    int ai=-1, bi=-1,max;
    
    while (time + a[ai+1] <= k && ai+1 < n) {
        ai++;
        time += a[ai];
        book++;
    }
    while (time + b[bi + 1] <= k && bi+1 < m) {
        bi++;
        time += b[bi];
        book++;
    }
    max = book;
    while (ai >= 0 && bi+1 < m) {
        time -= a[ai];
        ai--;
        book--;
        while (time + b[bi + 1] <= k && bi+1 < m) {
            bi++;
            time += b[bi];
            book++;
        }
        if (max < book)max = book;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 6416