akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

const int MAXN = 5005;

struct Node
{
	int ch[26];
	int len,par;
}node[MAXN << 2];

int n,k,id,lst;
int f[MAXN << 2];

char s[MAXN];

bool vis[MAXN << 2];

void extend(int c)
{
	int p = lst,np = ++id;
	node[np].len = node[p].len + 1;
	while (p && !node[p].ch[c])
	{
		node[p].ch[c] = np;
		p = node[p].par;
	}
	if (!p)
		node[np].par = 1;
	else
	{
		int q = node[p].ch[c];
		if (node[q].len == node[p].len + 1)
			node[np].par = q;
		else
		{
			int nq = ++id;
			node[nq].len = node[p].len + 1;
			memcpy(node[nq].ch,node[q].ch,sizeof(node[q].ch));
			node[nq].par = node[q].par;
			node[q].par = node[np].par = nq;
			while (p && node[p].ch[c] == q)
			{
				node[p].ch[c] = nq;
				p = node[p].par;
			}
		}
	}
	lst = np;
}

void DP(int u)
{
	if (vis[u])
		return;
	vis[u] = 1;
	f[u] = 0;
	for (int i = 0;i < 26;i++)
		if (node[u].ch[i])
		{
			DP(node[u].ch[i]);
			f[u] = max(f[u],f[node[u].ch[i]] + 1);
		}
}

void dfs(int u,int d)
{
	if (d > n)
		return;
	for (int i = 0;i < 26;i++)
		if (node[u].ch[i] && f[node[u].ch[i]] >= n - d)
		{
			s[d] = char(i + 'a');
			dfs(node[u].ch[i],d + 1);
			return;
		}
}

int main()
{
	scanf("%d%d%s",&n,&k,s + 1);
	k = min(k,20);
	reverse(s + 1,s + n + 1);
	while (k--)
	{
		reverse(s + 1,s + n + 1);
		id = lst = 1;
		memset(node,0,sizeof(node));
		for (int i = 1;i <= n;i++)
			extend(s[i] - 'a');
		for (int i = n;i >= 1;i--)
			extend(s[i] - 'a');
		memset(vis,0,sizeof(vis));
		for (int i = 1;i <= id;i++)
			DP(i);
		dfs(1,1);
	}
	puts(s + 1);
	return 0;
}

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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  rep(i, 0, K + 1) {
    rep(j, 0, K + 1) {
      int tmp = S - (i + j);
      if (tmp >= 0 && tmp <= K) ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

z = 0
ans = a*x + b*y
for i in range(max(x, y)):
    x = max(x-1, 0)
    y = max(y-1, 0)
    z += 2
    ans = min(ans, a*x + b*y + c*z)

print(ans)


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

using namespace std;

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

	vector<int> f(n + 1);
	for(int i = 1; i <= n; ++i) {
		for(int j = i; j <= n; j += i) {
			f[j] += 1;
		}
	}

	long long ans = 0;
	for(int i = 1; i <= n; ++i) {
		ans += 1LL * i * f[i];
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 42332
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<string>
#include<stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; ++i )
#define         rep1(i,n)      for ( i=1 ; i<=n ; ++i )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         input(a)       for(auto &it : a) cin>>it
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         vcl            vector<ll>
#define         vpl            vector<pair<ll,ll>>
#define         pb             push_back
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         sc             second
#define         spc            ' '
#define         nn             '\n'
#define         ikarus_101     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){ikarus_101

    ll tc,n,m,a,b,c,d,x,y,i,j,k,ans,sum,tot,cnt,mx,mn,idx,tmp;

    cin>>n>>m;
    sum=0;
    while(m--)
    {
        cin>>a;
        sum+=a;
    }
    cout<<(n<sum?-1:n-sum)<<nn;
    return 0;
}


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

int main() {
  double w, h, x, y;
  cin>>w>>h>>x>>y;

  double max = w * h /2;
  cout<<max<<" ";
  if(w == x*2 && h== y*2) cout<<"1"<<endl;
  else cout<<"0"<<endl;
  return 0;
}

Measured memory_bytes: 256
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import heapq
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  D=list(map(int,pin().split()))
  M=int(pin())
  T=list(map(int,pin().split()))
  
  if M>N:
    print("NO")
    return 
  D+=[10**9+1]
  T+=[10**9+1]
  heapq.heapify(D)
  heapq.heapify(T)
  j=0
  for i in range(M):
    p=heapq.heappop(T)
    while j<N:
      q=heapq.heappop(D)
      j+=1
      if p==q:
        break
    else:
      print("NO")
      return 
  print("YES")
  return 
main()
      

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

using namespace std;

int main() {
  set<char> dict;
  dict.insert('A');
  dict.insert('T');
  dict.insert('C');
  dict.insert('G');
  string s;
  cin >> s;
  s += '$';
  int ans = 0, num = 0;
  for (int i = 0; i < (int) s.length(); i++) {
    if (dict.count(s[i])) {
      num++;
    } else {
      ans = max(ans, num);
      num = 0;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

const int MAX = 7000;

// fac[]・・・a! finv[]・・・(a!)^(-1) inv[]・・・a^(-1)

long long N, M, ans, fac[MAX], finv[MAX], inv[MAX], two[MAX], six[MAX];

void pre_comb(void){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	two[0] = 1; two[1] = 2;
	six[0] = 1; six[1] = 6;
	for(int i=2; i<MAX; i++){
		fac[i] = fac[i-1] * i % M;
		inv[i] = M - inv[M % i] * (M/i) % M;
		finv[i] = finv[i-1] * inv[i] % M;
		two[i] = two[i-1] * 2 % M;
		six[i] = six[i-1] * 6 % M;
	}
}

long long comb(int n, int k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % M) % M;
}

long long mpow(long long n, long long r){
	if(r == 1) return n;
	if(r % 2 == 1) return n * mpow(n, r-1) % M;
	else{
		long long a = mpow(n, r/2);
		return a * a % M;
	}
}

long long inve(long long n){
	return mpow(n, M-2);
}

int main(){
	cin >> N >> M;
	pre_comb();
	rep(i, N+1){
		rep(j, (3*N/2)+1){
			if(3*N - 2*j - 3*i >= j){
				long long t1 = (fac[3*N] * finv[3*N-3*i-2*j] % M) * two[i] % M;
				long long t2 = t1 * inve(six[i] * two[j] % M) % M;
				ans = (ans + (t2 * finv[i] % M) * finv[j] % M) % M;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 512
N, A, B = map(int, input().split())

if A == 0:
    print(0)
elif N >= A+B:
    if N%(A+B) >= A:
        blue = A * (N // (A+B)) + A
    else:
        blue = A * (N // (A+B)) + N%(A+B)
    print(blue)
elif N < A+B:
    if N < A:
        print(N)
    else:
        print(A)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vll a(n), ans(n);
    rep(i, n) cin >> a[i];
    ll first = a[0] * 2;
    for (int i = 1; i < n; i++)
    {
        first = a[i] * 2 - first;
    }
    ans[0] = first / 2;
    for (int i = 1; i < n; i++)
    {
        ans[i] = (a[i - 1] - ans[i - 1] / 2) * 2;
    }
    view(ans);

    return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        int k = sc.nextInt();
        //        ArrayList<Integer> list = new ArrayList<Integer>();
        //
        //        for (int i = 0; i < n; i++) {
        //            list.add(sc.nextInt());
        //        }

        sc.close();

        int tmp = (int) Math.ceil(n / 2);

        if (tmp >= k) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }
}


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

def dfs(s):

    if int(s) > N:
        return 0

    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 

    for c in '753':
        ret += dfs(s + c)
    
    return ret

print(dfs('0'))


Measured memory_bytes: 2940
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        v: [chars; n]
    }
    let mut set = HashSet::new();
    for i in 0..n {
        set.insert(v[i].clone());
    }
    println!("{}", set.len());
}


Measured memory_bytes: 38072
N= map(int,input().split())
S = input()
syukei = [0,]
num = 0
count = 0
while len(S) > count:
    for i in S:
        count +=1
        if i == 'I':
            num +=1
            syukei.append(num)
        else:
            num -=1
            syukei.append(num)

print(max(syukei))

Measured memory_bytes: 9060
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
int n,m;
int f[200004],sum[200004];
int Find(int x){
    if(x==f[x])return x;
    int temp=Find(f[x]);
    sum[x]+=sum[f[x]];
    f[x]=temp;
    return f[x];
}
int LiangJiaJun(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<=n;i++){
        f[i]=i;sum[i]=0;
    }
    for(int i=1;i<=m;i++){
        int a,b,s,p,q;
        scanf("%d%d%d",&a,&b,&s);
        p=Find(a);q=Find(b);
        if(p==q){
            if(abs(sum[b]-sum[a])!=s)return puts("No"),0;
        }
        else{
            f[p]=q;
            sum[p]=sum[b]+s-sum[a];
        }
    }
    puts("Yes");
    return 0;
}





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

maxa = a[n-1]
sa = 0
res = 1
for i in range(n-1,-1,-1):
    if a[i] > maxa:
        maxa = a[i]
    tsa = maxa - a[i]
    if tsa > sa:
        sa = tsa
        res =1
    elif tsa == sa:
        res += 1

print(res)

Measured memory_bytes: 14292
#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 all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int mod = 1e9+7;

template<class T, T monoid>
class SegmentTree{
public:
  vector<T> dat;
  int _n;

  SegmentTree(int size) : _n{1}{
    while(size > _n) _n *= 2;
    dat.resize(2*_n-1, monoid);
  } 

  void update(int k, int a){
    k += _n-1;
    dat[k] += a;

    while(k > 0){
      k = (k-1) / 2;
      dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
    }
  }

  T query(int a, int b){
    return _query(a, b, 0, 0, _n);
  }

  void print(){
    for(const auto& v: dat) cout << v << " ";
    cout << endl;
  }
private:
  T _query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) {
      return monoid;
    }
    if(a <= l && r <= b) {
      return dat[k];
    }
    else {
      T v1 = _query(a, b, k * 2 + 1, l, (l + r) / 2);
      T v2 = _query(a, b, k * 2 + 2, (l + r) / 2, r);

      return v1 + v2;
    }
  }
};

int main(){
  int n, k; cin >> n >> k;
  int a[n+1];
  FOR(i, 1, n+1) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(k+1, 0));
  vector<SegmentTree<ll, 0LL>> st(n+1, SegmentTree<ll, 0LL>(k+1));
 
  dp[0][0] = 1; st[0].update(0, 1);
  FOR(i, 1, n+1)REP(j, k+1){
    int l = max(0, j-a[i]), r = j+1;
    (dp[i][j] += st[i-1].query(l, r)) %= mod;
    st[i].update(j, dp[i][j]);
  }

  cout << dp[n][k] << endl;
  return 0;
}


Measured memory_bytes: 288752
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int keta(int N){
  int counter = 1;
  while(N/10 > 0){
    N /= 10;
    counter ++;
  }
  return counter;
}

int ketasum(int N){
  int x = keta(N);
  int sum = 0;
  for(int i = 0; i < x; i++){
    sum += N % 10;
    N /= 10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  if(N % ketasum(N) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
    int N;
    string S;
    cin>>N;
    cin>>S;
    long long sum = 0;
    for(int i = 0;i<N-1;i++)
    {
        if(S[i]==S[i+1])
        {
            sum++;
        }
    }
    cout<<N-sum<<endl;
}

Measured memory_bytes: 512
function main(arg) {
    var size = arg.split("\n")[0].split(" ")
    var sel = arg.split("\n")[1].split(" ")
    console.log(size[0]*size[1]-size[1]*sel[0]-(size[0]-sel[0])*sel[1])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
//============================================================================
// Name        : abc141_e.cpp E - Who Says a Pun?
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : https://atcoder.jp/contests/abc141/tasks/abc141_e
//============================================================================

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

// 最長共通接頭辞数の配列を返す
vector<int> Zalgorithm(const string &s, int n) {
	vector<int> z(n, 0);

	int L = 0, R = 0;
	// s と s[i...] が何文字目まで一致しているか調べる
	for (int i = 1; i < n; ++i) {
		if (i > R) {
			// i は R を超えているので、過去の情報がない区間にこれから入る
			L = R = i; // 仕切りなおしてインデックスが i の位置から調べる
			while (R < n && s[R - L] == s[R]) { // 一致する間は後ろまで見ていく
				R++;
			}
			R--;
			// s[L...R] と s[0...(R-L)] が一致する
			// <=> 長さ (R-L+1) だけ一致する
			z[i] = R - L + 1; // prefix-substring の長さ
		} else {
			// i は計算済みの区間内にいるので、過去の情報を使える
			int k = i - L;
			// L は i 以下のまま更新されていない状態の値。
			// (i-L) で、イテレーションがいくつ進んだかが出せる。
			// この文字数分だけ s[0...] の先頭を削ってできる文字列は s[i...] と同じ prefix

			// s[i...] と s[(i-L)...] は少なくとも (R-i+1) 文字一致している
			// <=> s[i...R] と s[(i-L)...(R-L)] は少なくとも一致している
			// <=> s[i...R] と s[k...(k+(R-i))] は少なくとも一致している
			if (z[k] < R - i + 1) {
				// s[0...] と s[k...] とで一致している文字数が (R-i+1) 未満
				// <=> s[0...] と s[i...] が一致している文字数も高々、s[k...] の場合と同じ
				z[i] = z[k];
			} else {
				L = i;
				// s[k...(R-L)] が s[0...(R-i)] と一致する、すなわち
				// s[i...R] が s[0...(R-i)] と一致することはわかっているので、R がどこまで右に動かせるか調べる
				while (R < n && s[R - L] == s[R]) { // 一致する間は後ろまで見ていく
					R++;
				}
				R--;
				z[i] = R - L + 1; // prefix-substring の長さ
			}
		}
	}
	return z;
}

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

	int N, Lmax = 0;
	string S, Stmp;

	cin >> N;
	cin >> S;

	int strlen;
	for (int start = 0; start < N; ++start) {
		Stmp = S.substr(start);
		strlen = N - start;
		vector<int> sary = Zalgorithm(Stmp, strlen);
		// std::*_element は，イテレーターを返すので '*' で値を取得する
		// Lmax = max(Lmax, *max_element(sary.begin(), sary.end()));
		for (int i = 0; i < strlen; ++i) {
			Lmax = max(Lmax, min(i, sary[i]));
		}
	}
	cout << Lmax << '\n';
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cotu cout
#define itn int
const int INF = 1e9 + 7;

int main(){
    double a,h,x; cin>>a>>h>>x;
    if((h*a*a)/2>=x) cout<<fixed<<setprecision(10)<<90-atan((2*x)/(h*h*a)) * 180 / 3.14159265359;
    else cout<<fixed<<setprecision(10)<<atan((2*(a*a*h-x))/(a*a*a)) * 180 / 3.14159265359;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define in auto&it
#define out auto it
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
const double pi = acos(-1);
#define err(x) cerr<<#x<<" = "<<x<<'\n';
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif
	fastio
	double d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3736
N = int(input())
A = tuple(map(int, input().split()))
limit = sum(A)
alive = 1
total = 0
for a in A:
    alive -= a
    limit -= a
    if alive < 0:
        print(-1)
        break
    total += alive + a
    alive = min(alive * 2, limit)
else:
    print(total)

Measured memory_bytes: 20932
N, *D = map(int, open(0).read().split())

D = [(d1, d2) for d1, d2 in zip(*[iter(D)] * 2)]

for i in range(N - 2):
    if all(D[i + j][0] == D[i + j][1] for j in range(3)):
        print("Yes")
        break
else:
    print("No")


Measured memory_bytes: 9128
# -*- coding: utf-8 -*-

import sys
from bisect import bisect_right

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

def LIS(A: list):
    L = [A[0]]
    for a in A[1:]:
        if a >= L[-1]:
            # aがLの末尾以上なら増加部分列を延長する(今回は広義(=を含む))
            L.append(a)
        else:
            # そうでなければ、「a以下の最大要素の次」をaにする
            # 該当位置は、二分探索で特定できる
            L[bisect_right(L, a)] = a
    return len(L)

# 後ろからLIS
print(LIS(A[::-1]))


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

int main(){
    int W, H, N; cin >> W >> H >> N;
    int state[H][W];
    for (int h=0; h<H; h++){
        for (int w=0; w<W; w++){
            state[h][w] = 0;
        }
    }
    int x, y, a;
    for (int i=0; i<N; i++){
        cin >> x >> y >> a;
        if (a==1){
            for (int h=0; h<H; h++){
                for (int w=0; w<x; w++){
                    state[h][w] = 1;
                }
            }
        }
        if (a==2){
            for (int h=0; h<H; h++){
                for (int w=x; w<W; w++){
                    state[h][w] = 1;
                }
            }
        }
        if (a==3){
            for (int h=0; h<y; h++){
                for (int w=0; w<W; w++){
                    state[h][w] = 1;
                }
            }
        }
        if (a==4){
            for (int h=y; h<H; h++){
                for (int w=0; w<W; w++){
                    state[h][w] = 1;
                }
            }
        }
    }
    int ans = 0;
    for (int h=0; h<H; h++){
        for (int w=0; w<W; w++){
            if (state[h][w] == 0){
                ans += 1;
            }
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
    int n = sc.nextInt();
    ArrayList<Integer> p = new ArrayList<Integer>();
    boolean f = true;
    if(n == 0) f = false;

    for(int i=0; i<n; i++) {
      int tmp = sc.nextInt();
      p.add(tmp);
    }

    Collections.sort(p);
    int ans = 101;
    for(int i=0; i<102; i++) {
      if(p.contains(i)) continue;
      //System.out.println(Math.abs(x-i));
      ans = Math.min(ans, Math.abs(x-i));
      //System.out.println(ans);
    }

    if(f = true) {
      if(p.contains(x-ans)) {
        System.out.println(x+ans);
      } else {
        System.out.println(x-ans);
      }
    } else {
      System.out.println(x);
    }

	}
}


Measured memory_bytes: 35940
n = int(input())

count = 0


def dfs(i, s):
    global count
    if i > 10:
        return

    ok = True
    for c in ['3', '5', '7']:
        if c not in s:
            ok = False
    if ok and int(s) <= n:
        count += 1

    for c in ['3', '5', '7']:
        dfs(i + 1, s + c)


dfs(0, '')
print(count)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr1 := make([]int, n + 2)
	sum := 0
	for i := 1; i < n + 1; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr1[i] = tmp
		sum += abs(arr1[i - 1] - tmp)
	}
	sum += abs(arr1[n])
	for i := 1; i < n + 1; i++ {
		tmp := sum - abs(arr1[i] - arr1[i - 1]) - abs(arr1[i] - arr1[i + 1])
		tmp += abs(arr1[i - 1] - arr1[i + 1])
		fmt.Println(tmp)
	}
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}

int main() {
	int h, w, i, j, s, t, u,c[33];
	cin >> h >> w;
	char a;
	for (i = 0; i < 26; i++)
		c[i] = 0;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> a;
			c[a - 'a']++;
		}
	}
	s = (h / 2)*(w / 2);
	t = (h / 2)*(w % 2)+(h%2)*(w/2);
	u = (h % 2)*(w % 2);
	for (i = 0; i < 26; i++) {
		while (c[i] >= 4 && s > 0) {
			c[i] -= 4;
			s--;
		}
		while (c[i] >= 2 && t > 0) {
			c[i] -= 2;
			t--;
		}
		while (c[i] > 0 && u > 0) {
			c[i]--;
			u--;
		}
	}
	if (s == 0 && t == 0 && u == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif

const unsigned BITS_WIDTH = 1e+5 + 10;
typedef std::bitset<BITS_WIDTH> Animals;

#ifdef __DEBUG__
std::ostream& operator<<(std::ostream &os, const Animals &a)
{
  os << a.to_string();
  return os;
}
#endif

bool search(unsigned N, const std::string &s, Animals &result)
{
  std::vector<Animals> dp[2];
  dp[0] = std::vector<Animals>();
  dp[1] = std::vector<Animals>();
  
  N_TIMES(i, 4) {
    dp[0].emplace_back(i);
  }
  
  for (unsigned n = 1; n <= N; ++n) {
    for (const Animals &a : dp[(n - 1) % 2]) {
      Animals b(a);
      if (s[n - 1] == 'o') {
        b[n + 1] = a[n] ?  a[n - 1] : !a[n - 1];
      } else {
        b[n + 1] = a[n] ? !a[n - 1] :  a[n - 1];
      }
      dp[n % 2].push_back(b);
    }
    
    if ((n + 1) <= N) dp[(n - 1) % 2].clear();
  }
  
  for (const Animals &a : dp[N % 2]) {
    if ((a[0] == a[N + 0]) && (a[1] == a[N + 1])) {
      result = Animals(a);
      return true;
    }
  }
  
  return false;
}

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::string s;
  std::cin >> s;
  
  Animals a;
  if (!search(N, s, a)) {
    std::cout << -1 << std::endl;
  } else {
    for (unsigned n = 1; n <= N; ++n) {
      std::cout << (a[n] ? 'S' : 'W');
    }
    std::cout << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    long long int a,b,x;
    cin>>a>>b>>x;
    long long int ansa=a/x+1,ansb=b/x+1,ans;
    if(a==0)ans=ansb;
    else if(a%x==0)ans=ansb-ansa+1;
    else ans=ansb-ansa;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX_N 10
#define MAX_M 100
typedef pair<int, int> P;
int n, c, v;
int dis[MAX_N + 1];
vector<P> Adjacency_list[MAX_N + 1];
const int INF = 10000000;
void Dijkstra(int s, int g){
  priority_queue<pair<int, int>, std::vector<P>, std::greater<P>> que ;
  for(int i = 0; i <= MAX_N; i++){
    dis[i] = INF;
  }
  que.push({0, s});
  dis[s] = 0;
  while(que.size()){
    P p = que.top();
    que.pop();
    for( int i = 0; i < Adjacency_list[p.second].size(); i++ ){
      if(Adjacency_list[p.second][i].first + dis[p.second]  < dis[Adjacency_list[p.second][i].second]){
        dis[Adjacency_list[p.second][i].second] = Adjacency_list[p.second][i].first + dis[p.second];
        que.push({dis[Adjacency_list[p.second][i].second],Adjacency_list[p.second][i].second });
      }
    }
  }
}

int main(){
    int H, W;
    cin >> H >> W;
    for(int i = 0; i <= 9; i++){
        for(int k = 0; k<= 9; k++){
            cin >> c;
            Adjacency_list[i].push_back({c, k});
        }
    }
    int ans = 0;
    for(int i = 1; i <= H; i++){
        for(int k = 1; k<= W; k++){
            cin >> n;
            if( n!= -1){
                Dijkstra(n, 1);
                ans += dis[1];
            }
        }
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static private final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static private final int upper(long v) {return (int)(v >> 32);}
	static private final int lower(long v) {return (int)(v & 0xFFFFFFFF);}

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

	static private final long load(int end, int length) {
		return pair(end, length);
	}
	static private final int end(long load) {
		return upper(load);
	}
	static private final int length(long load) {
		return lower(load);
	}
	static private final long score(int count, int last) {
		return pair(count, last);
	}
	static private final int count(long score) {
		return upper(score);
	}
	static private final int last(long score) {
		return lower(score);
	}

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

	public void exec() throws Exception{
		final int N = sc.nextInt();
		final String S = sc.next();
		if(N%2 == 1) {
			out.println("No");
			return;
		}
		for(int i=0;i<N/2;i++) {
			if(S.charAt(i)!=S.charAt(i+N/2)) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}
}


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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

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

	int a[] = { 111,222,333,444,555,666,777,888,999, };

	cout << *find_if(a, a + sizeof(a) / sizeof(a[0]), [N](int x){ return x >= N; }) << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int main() {
	long long a, b, x;
	cin >> a >> b >> x;
	
	long long ans;
	if (a == 0) ans = b / x + 1;
	else ans = b / x - (a - 1) / x;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
A,B,C,D = (int(x) for x in input().split())
while (A>0) and (C>0):
    C = C-B
    if C<=0:
        Flag = True
        break
    A = A-D
    if A<=0:
        Flag = False
        break

if Flag:
    print('Yes')
else:
    print('No')

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

using namespace std;

using int64 = long long;


map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return (ret);
}

int main() {
  map< int64_t, int > div;
  int N;
  cin >> N;
  for(int i = 1; i <= N; i++) {
    auto x = prime_factor(i);
    for(auto &p : x) div[p.first] += p.second;
  }

  vector< int64 > dp1(77);
  dp1[1] = 1;
  for(auto &p : div) {
    for(int k = 76; k >= 0; k--) {
      for(int j = p.second; j > 0; j--) {
        dp1[min(76, k * (j + 1))] += dp1[k];
      }
    }

  }

  cout << dp1[75] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	int sl=s.size(),tl=t.size();
	if(sl<tl){
		cout<<"UNRESTORABLE";
		exit(0);
	}
	int fla=1;
	for(int i=sl-tl;i>=0;i--){
		int fl=1;
		for(int j=0;j<tl;j++){
			if(s[i+j]!=t[j] && s[i+j]!='?'){
				fl=0;
			}
		}
		if(fl){
			for(int j=0;j<tl;j++){
				s[i+j]=t[j];
			}
			for(int j=0;j<sl;j++){
				if(s[j]=='?') s[j]='a';
			}
			fla=0;
			cout<<s;
			break;
		}
	}
	if(fla) cout<<"UNRESTORABLE";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, M;
const int MAX_M = 100000;
int a[MAX_M], b[MAX_M];


int main(){
  cin >> N >> M;
  map<int, int > mp;
  REP(i, M){
    cin >> a[i] >> b[i];
    mp[a[i]]++;
    mp[b[i]]++;
  } 

  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if(itr->second % 2 ==  1) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}



Measured memory_bytes: 5120
N = int(input())
A = []
B = []
dam = []
for i in range(N):
    aa,bb = (int(i) for i in input().split())
    A.append(aa)
    B.append(bb) 
    dam.append((i,aa+bb))

dam = sorted(dam, key=lambda x: x[1], reverse=True)
aok = dam[0::2]
tak = dam[1::2]

asum = 0
for i in aok:
    asum = asum + A[i[0]]

bsum = 0
for i in tak:
    bsum = bsum + B[i[0]]

print(asum - bsum) 


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

class UnionFind
{
public:
    vector<int> parent;
    vector<int> sz;
    
    UnionFind(int n): parent(n), sz(n)
    {
        for(int i=0;i<n;i++)
        {
            parent[i] = i;
            sz[i] = 1;
        }
    }

    int root(int x)
    {
        return parent[x]==x ? x : parent[x] = root(parent[x]);
    }

    bool same(int x, int y)
    {
        return root(x)==root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (sz[x] < sz[y])
            {
                parent[x] = y;
                sz[y] += sz[x];
            }
            else
            {
                parent[y] = x;
                sz[x] += sz[y];
            }
        }
    }

    int size(int x)
    {
        return sz[root(x)];
    }
};

int main()
{
    int N, M;
    cin>>N>>M;
    vector<int> A(M), B(M);
    for (int i=0; i<M; i++)
    {
        cin>>A[i]>>B[i];
        A[i]--, B[i]--;
    }

    UnionFind UF(N);
    for (int i=0; i<M; i++)
        UF.unite(A[i], B[i]);
    int ans = 0;
    for (int i=0; i<N; i++)
        ans = max(ans, UF.size(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 6048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k){
    cout<<":(";
  }
  else{
    cout<<"Yay!";
  }
  return 0;
}


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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める

int main()
{
	cout << setprecision(10);
	ll n; cin >> n;
	ll m ; cin  >> m;
	vector<tuple<ll,ll,ll>> information(m);
	rep(i,m){
		ll prefacture,year;
		cin >>prefacture >> year;
		information[i] = make_tuple(prefacture,year,i);
	}

	SORT(information);

	map<ll, pair<ll,ll>> ans;
	ll count ;
	ll befprefacture;
	rep(i,m){
		ll x,y,z;
		tie(x,y,z) = information[i];
		if(i == 0 ){
			count = 1;
			befprefacture = x;
		}
		else if(x == befprefacture){
			count ++;
		}
		else{
			count = 1;
			befprefacture=x;
		}
		ans[z] = make_pair(x,count);
	}

	rep(i,m){
		printf("%06lld",ans[i].first);
		printf("%06lld\n",ans[i].second);
	}
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n,m;cin >> n >> m;
  int ans = n*(n-1)/2;
  ans += m*(m-1)/2;
  cout << ans << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 1000000;
long long n,m,k,h,bsum=0,amax=0;
long long maxm, minm;
pair<long long, long long> red[MAX_N], blue[MAX_N];
long long a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N], t[MAX_N];
long long s1[MAX_N], s2[MAX_N];
long long solve(){
    long long count = 0;
    sort(b, b+n);
    reverse(b, b+n);
    int ii = 0;
    while(b[ii]>amax&&h>0){
       h -= b[ii++];
       count++;
    }
    if(h>0){
        m = h/amax;
    if(h % amax != 0)   m++;
        count += m;
    }
    return count;
}
int main(){
    cin >> n >>h;
    for(int i=0 ; i<n ; i++){
        cin >> a[i] >> b[i];
        bsum += b[i];
        amax = max(a[i], amax);
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] a = Read.ints();
        Console.WriteLine(Math.Abs(a[0]-a[1])>Math.Abs(a[0]-a[2])?"B":"A");
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < Math.Sqrt(n); i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

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

int main ()
{
    vector<bool> num(100000, true);
    num[0] = num[1] = false;
    for (int i = 2; i < num.size() / 2; i++) {
        for (int j = 2; j * i <= num.size(); j++) {
            num[i * j] = false;
        }
    }
    vector<int> prim;
    for (int i = 0; i < num.size(); i++) {
        if (num[i]) prim.push_back(i);
    }


    int m, a, b;
    while (cin >> m >> a >> b, (m || a || b)) {
        int r = 0;
        int l = 0;
        for (int i = 0; i < prim.size() && prim[i] < m; i++) {
            for (int j = 0; j <= i; j++) {
                if (prim[i] * prim[j] > m) break;
                if (l * r < prim[i] * prim[j] && (double)a / b <= (double)prim[j] / prim[i]) {
                    l = prim[j];
                    r = prim[i];
                }
            }
        }

        cout << l << " " << r << endl;
    }

    return 0;
}

Measured memory_bytes: 1332
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char x = sc.next().charAt(0);
    char y = sc.next().charAt(0);
    if (x - 'A' < y - 'A') System.out.println("<");
    else if (x - 'A' == y - 'A') System.out.println("=");
    else System.out.println(">");
  }
}


Measured memory_bytes: 23508
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H, N = map(int, input().split())
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [INF] * 10000100
    dp[0] = 0
    for i in range(H):
        if dp[i] == INF:
            continue
        for n in range(N):
            dp[i+A[n]] = min(dp[i+A[n]], dp[i] + B[n])
    
    ans = INF
    for i in range(H, 10000100):
        ans = min(ans, dp[i])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 419876
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int n;
	cin >> n;
	queue<int>que;
	rep1(i, 10) {
		que.push(i);
	}
	int ans;
	rep(i, n) {
		ans = que.front();
		que.pop();
		if (ans % 10 != 0)que.push(ans * 10 + ans%10 - 1);
		que.push(ans * 10 +ans%10);
		if(ans%10 !=9)que.push(ans * 10 + ans%10 + 1);
	}
	print(ans);
}


Measured memory_bytes: 5064
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int n, m;
vector<vector<char>>arr;
bool valid(int i, int j){
	return i > -1 && j > -1 && i < n&&j < m&&arr[i][j] == '.';
}
int dp[1001][1001];
int sol(int i, int j){
	if (i == n - 1 && j == m - 1)
		return 1;
	if (!valid(i, j))
		return 0;
	int &ret = dp[i][j];
	if (~ret)
		return ret;
	int ch1 = sol(i + 1, j) % mod;
	int ch2 = sol(i, j + 1) % mod;
	return ret = (ch1 + ch2) % mod;
}
int main(){
	K_K();
	cin >> n >> m;
	arr.resize(n, vector<char>(m));
 	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)
			cin >> arr[i][j];
	}
	clr(dp, -1);
	cout << sol(0, 0);
}

Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

const int N = 100;
vector <vector<int>> A(N + 1, vector<int>(N + 1));
void func(int l, int r, int x, int y, int c) {
	for (int i = l; i <= r; i++) {
		for (int j = 1; j <= N; j++) {
			if(c > 0 && i % 2 == 0 && j % 2 == 1) {
				A[i][j] = x;
				c--;
			}
			else {
				A[i][j] = y;
			}
		}
	}
}
int main() {
	int a, b;
	cin >> a >> b;
	func(1, 50, 0, 1, a - 1);
	func(51, 100, 1, 0, b - 1);
	string s = ".#";
	cout << N << " " << N << "\n";
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cout << s[A[i][j]];
		}
		cout << "\n";
	}
}


Measured memory_bytes: 256