akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  tourist
 *    created: 04.01.2020 02:49:37       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 5010;

bitset<N> pref[N];
bitset<N> suf[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], k);
  }
  sort(a.begin(), a.end());
  pref[0][0] = 1;
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] | (pref[i] << a[i]);
  }
  suf[0][0] = 1;
  for (int i = 0; i < n; i++) {
    suf[i + 1] = suf[i] | (suf[i] << a[n - 1 - i]);
  }
  int low = 0, high = n;
  while (low < high) {
    int mid = (low + high) >> 1;
    int y = k - 1;
    bool has = false;
    for (int x = 0; x <= k - 1; x++) {
      if (suf[n - 1 - mid][x]) {
        y = max(y, k - 1 - x);
        while (!pref[mid][y]) {
          --y;
        }
        if (x + y >= k - a[mid]) {
          has = true;
          break;
        }
      }
    }
    if (!has) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  cout << low << '\n';
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, c, k;
  cin >> n >> c >> k;

  vll ts(n);
  rep(i, n) cin >> ts[i];
  Sort(ts);

  ll pret = -1;
  ll prec = 0;
  ll ans = 0;
  rep(i, n) {
    ll t = ts[i];
    if (i > 0 && t <= pret + k && prec < c) {
      prec++;
    } else {
      pret = t;
      ans++;
      prec = 1;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type Point struct {
	id, x, y int
}
type ByX []Point

func (a ByX) Len() int           { return len(a) }
func (a ByX) Less(i, j int) bool { return a[i].x < a[j].x }
func (a ByX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type ByY []Point

func (a ByY) Len() int           { return len(a) }
func (a ByY) Less(i, j int) bool { return a[i].y > a[j].y }
func (a ByY) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	R := make([]Point, N)
	for i := 0; i < N; i++ {
		R[i] = Point{i, sc.nextInt(), sc.nextInt()}
	}
	B := make([]Point, N)
	for i := 0; i < N; i++ {
		B[i] = Point{i, sc.nextInt(), sc.nextInt()}
	}
	sort.Sort(ByX(B))
	done := make(map[int]bool)
	for _, pb := range B {
		targets := []Point{}
		for i, pr := range R {
			if pr.x < pb.x && pr.y < pb.y && !done[i] {
				targets = append(targets, pr)
			}
		}
		if len(targets) != 0 {
			sort.Sort(ByY(targets))
			done[targets[0].id] = true
		}
	}

	fmt.Fprintln(wtr, len(done))
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M,Q;
int G[501][501];
int p[100000], q[100000];
int sum[501][501];

int cnt[501];

int main(){
    cin>>N>>M>>Q;
    rep(i,M){
        int l,r;
        cin>>l>>r;
        G[l][r]++;
    }
    rep(i,Q) cin>>p[i]>>q[i];

    repn(i,N){
        repn(j,N){
            sum[i][j]=sum[i-1][j]+sum[i][j-1]+G[i][j]-sum[i-1][j-1];
        }
    }

    rep(i,Q){
        int ans=0;
        int pp=p[i];
        int qq=q[i];
        ans=sum[qq][qq]-sum[pp-1][qq]-sum[qq][pp-1]+sum[pp-1][pp-1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;
int sum(int i){
    int sum=0,r=1;
    while(i){
        r=i%10;
        sum+=r;
        i/=10;
    }
    return sum;
}


int main(void){
    
    int n,a,b;
    cin >> n >> a >> b;
    int i,ans=0;
    
    for(i=1;i<=n;++i){
        
        int su = sum(i);
        
        if(su>=a&&su<=b)ans+=i;
        
        //cout << su << " ";
        
        
    }
    
    
    cout << ans;
    
    
    return 0;
    
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = scanner.nextInt();
            long[] x = new long[N];
            long A = scanner.nextLong();
            long B = scanner.nextLong();
            for (int i = 0; i < N; i++) {
                x[i] = scanner.nextLong();
            }
            long tired = 0l, now = x[0];
            for (int i = 1; i < N; i++) {
                if ((x[i] - now) * A < B) {
                    tired += A * (x[i] - now);
                } else {
                    tired += B;
                }
                now = x[i];
            }
            System.out.println(tired);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<long long int> x(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i);
  }
  long long int ans=100100100100;
  for(int i=0;i<n-k+1;i++){
    long long int l=abs(x.at(i))+abs(x.at(i)-x.at(i+k-1));
    long long int r=abs(x.at(i+k-1))+abs(x.at(i)-x.at(i+k-1));
    ans=min(ans,min(l,r));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    string ans;
    
    ans += string(tx - sx, 'R');
    ans += string(ty - sy, 'U');
    ans += string(tx - sx, 'L');
    ans += string(ty - sy + 1, 'D');
    ans += string(tx - sx + 1, 'R');
    ans += string(ty - sy + 1, 'U');
    ans += 'L';
    ans += 'U';
    ans += string(tx - sx + 1, 'L');
    ans += string(ty - sy + 1, 'D');
    ans += 'R';
    
    cout << ans << endl;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;

struct Segtree{
    int n;
    vector<int> elm;
    Segtree(int n) : n(n), elm(2 * n){
        for(int i = 0; i < n; ++i)
            elm[i + n] = i;
        for(int i = n - 1; i >= 1; --i)
            elm[i] = max(elm[2 * i], elm[2 * i + 1]);
    }

    void update(int x, int val){
        x += n;
        elm[x] = max(val, elm[x]);
        while(x >>= 1)
            elm[x] = max(elm[2 * x], elm[2 * x + 1]);
    }

    int get(int x, int y){
        int l = -MOD, r = -MOD;
        for(x += n, y += n - 1; x <= y; x >>= 1, y >>= 1){
            if(x & 1)
                l = max(l, elm[x++]);
            if(!(y & 1))
                r = max(elm[y--], r);
        }
        return max(l, r);
    }
};

signed main(){
    int n, m, q;
    cin >> n >> m >> q;
    vector<int> d(m), a(m), b(m);
    // day, type, idx
    vector<tuple<int,int,int>> query;
    for(int i = 0; i < m; ++i){
        cin >> d[i] >> a[i] >> b[i];
        --a[i], --b[i];
        query.emplace_back(d[i], 1, i);
    }
    vector<int> e(q), s(q), t(q);
    for(int i = 0; i < q; ++i){
        cin >> e[i] >> s[i] >> t[i];
        --s[i], --t[i];
        query.emplace_back(e[i], 0, i);
    }

    sort(query.begin(), query.end());

    Segtree seg(n);
    vector<int> ans(q, -1);

    // segtree and union findd
    for(auto& que : query){
        int type, i;
        tie(ignore, type, i) = que;
        if(type == 1){
            seg.update(a[i], b[i]);
        }else{
            int pos = -1, nex = s[i];
            while(pos != nex){
                pos = nex;
                nex = seg.get(0, pos + 1);
            }
            seg.update(s[i], pos);
            ans[i] = (pos >= t[i]);
        }
        /*
        if(get<1>(que)){
            cout << get<0>(que) << " : ";
            for(int i = 0; i < n; ++i)
                cout << seg.get(i, i + 1) << " \n"[i == n - 1];
        }
        */
    }
    for(int i = 0; i < q; ++i){
        cout << (ans[i] ? "Yes" : "No") << endl;
    }

}





Measured memory_bytes: 8680
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}
int dp[100010];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, q;
  cin >> n >> q;
  // ll n, m, k;
  // cin >> n >> m >> k;
  string s;
  cin >> s;
  fi(1, n) {
    dp[i] = dp[i - 1];
    if(s[i - 1] == 'A' && s[i] == 'C')
      dp[i]++;
  }
  int l, r;
  fi(0, q) {
    cin >> l >> r;
    cout << dp[r - 1] - dp[l - 1] << endl;
  }
  // cout << ans << endl;
  return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

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



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

typedef long long ll;
const int N = 2e5+ 7;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
#define fi first
#define se second
#define rep(i,a,n) for(int i = a; i <= n; i++)
#define per(i,a,n) for(int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
typedef pair<int,int> P;

int main()
{
	int a, b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	int x=c-a,y=d-b;
	if(y<0){
        y+=60;
        x--;
	}
	printf("%d\n",x*60+y-e);
}


Measured memory_bytes: 3824
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = double;
const int maxn = 105, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, a[maxn];
map<int, int> gp[maxn][maxn], fp[maxn][maxn];

//g - flipping pattern
//f - everything else
#define mul(x, y) ( (x) * 1ll * (y) % mod )

int bp(int a, int p) {
	int r = 1;
	while(p) {
		if(p&1) r = mul(r, a);
		p >>= 1, a = mul(a, a);
	}
	return r;
}
int g(int l, int r, int w) {
	if(gp[l][r].count(w)) return gp[l][r][w];
	int mn = 1<<30;
	for(int i = l; i <= r; i++) mn = min(mn, a[i]);
	if(mn != w) {
		return gp[l][r][w] = mul(bp(2, mn-w), g(l, r, mn));
	}
	
	int ans = 1, len = 0;
	for(int i = l; i <= r; i++) {
		if(a[i] == w) {
			if(len) ans = ans * 1ll * g(i - len, i - 1, w + 1) % mod;
			len = 0;
		} else ++len;
	}
	if(len) ans = ans * 1ll * g(r + 1 - len, r, w + 1) % mod;
	gp[l][r][w] = ans * 2ll % mod;
	return gp[l][r][w];
}

int f(int l, int r, int w) {
	if(fp[l][r].count(w)) return fp[l][r][w];
	int mn = 1<<30;
	for(int i = l; i <= r; i++) mn = min(mn, a[i]);
	if(mn != w) {
		return gp[l][r][w] = f(l, r, mn);
	}
	
	int ans = 1, len = 0;
	for(int i = l; i <= r; i++) {
		if(a[i] == w) {
			if(len) ans = ans * 1ll * (2ll * g(i - len, i - 1, w + 1) + f(i - len, i - 1, w + 1)) % mod;
			ans = ans * 2ll % mod;
			len = 0;
		} else ++len;
	}
	if(len) ans = ans * 1ll * (2ll * g(r + 1 - len, r, w + 1) + f(r + 1 - len, r, w + 1)) % mod;
	fp[l][r][w] = (mod + ans - g(l, r, w)) % mod;
	return fp[l][r][w];
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cout << (g(0, n-1, 1)+f(0, n-1, 1))%mod;
}


Measured memory_bytes: 1280
from bisect import*
N,*L=map(int,open(0).read().split());L.sort()
a=0
l=[]
r=[]
for i in range(1001):
    l.append(bisect_left(L,i))
    r.append(bisect(L,i))
for p in L:
    for q in L:
        x=p+q
        y=abs(p-q)
        a+=(l[x]if x<1001else N)-(r[y]if 0<y<1001else(y>1000)*N)
for p in L:
    x=2*p
    a-=3*(l[x]if x<1001else N)
print((a+2*N)//6)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define vll vector<int>
vll dp(1e5+5,0);

int main()
{
    int i, j, k, n, m, t;
    vll h;

    cin>>n;
    for ( i = 0; i < n; i++)
    {
        cin>>j;
        h.push_back(j);
    }

    dp[1]=fabs(h[1]-h[0]);
    dp[2]=fabs(h[2]-h[0]);
    for ( i = 3; i <= n; i++)
    {
        dp[i]=min(fabs(h[i]-h[i-1])+dp[i-1],fabs(h[i]-h[i-2])+dp[i-2]);
    }
    
    cout<<dp[n-1]<<endl;
        
    return 0;
}

Measured memory_bytes: 4264
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

vector<int> pre, in, post;

int N;

int main(){
  cin >> N;

  int T=0, X=0, Y=0;
  REP(i,N){
    int t,x,y;
    cin >> t>> x >> y;

    if ((t - T) >= abs(X-x) + abs(Y-y)){
      if(((t - T) - (abs(X-x) + abs(Y-y)))%2 != 0){
        cout << "No" << endl;
        exit(0);
      }
    }else{
        cout << "No" << endl;
        exit(0);
    }
    T=t;X=x;Y=y;
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
sums = 0
for i in range(N):
    sums += A[i]
    if sums > x:
        print(i)
        exit()
else:
    if sums == x:
        print(N)
    else:
        print(N - 1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  int N;
  long long a = 1, c = 0;
  cin >> N;
  int A[N];
  long double B[N], sum;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    a *= A[i];
    B[i] = (long double) 1/A[i];
    sum += B[i];
  }
  for (int i = 0; i < N; i++){
    c += a/A[i];
  }
  cout << fixed;
  cout << setprecision(10)　<< (long double) 1/sum << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int l[2000];
int main(){
	int n,x;cin>>n>>x;
	rep(i,n){
		cin>>l[i];	
	}
	int d=0;
	int cnt=0;
	if(d<=x)cnt++;
	rep(i,n){
		d+=l[i];
		if(d<=x)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class StonesOnATree
{
    public:
int minStones(vector <int> p, vector <int> w)
{

}
};
int main()
{
int a,b,c;
while(cin>>a>>b>>c){
    pair<int,int>A[200005]={};
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
                int g;
        cin>>g;
            A[g].F=i;
            A[g].S=j;
        }
    }

    int sum[100005]={};
    for(int i=c;i<=a*b;i++){
        sum[i]=sum[i-c]+abs(A[i].F-A[i-c].F)+abs(A[i].S-A[i-c].S);
    }
    int x;
    cin>>x;
    for(int i=0;i<x;i++){
     int t1,t2;
     cin>>t1>>t2;
        cout<<sum[t2]-sum[t1]<<endl;







    }

}

    return 0;
}


Measured memory_bytes: 3072
n = gets.to_i
w = gets.split.map(&:to_i)

result = 100
(1...n).each do |i|
    hoge = w.first(i).inject(:+)
    piyo = w.last(n - i).inject(:+)
    fuga = (hoge - piyo).abs
    if fuga < result then
        result = fuga
        break if fuga == 0
    end
end

puts result

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A.at(i); }

    int max = A[0];
    int max2 = 0;

    FOR(i, 1, N) {
        if (max <= A[i]) {
            max2 = max;
            max = A[i];
        } else if (max2 <= A[i]) {
            max2 = A[i];
        }
    }

    REP(i, N) {
        if (max == A[i]) {
            cout << max2 << endl;
        } else {
            cout << max << endl;
        }
    }

    return 0;
}


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


int main(){
    long long int n,ans=0;
    cin>>n;
    while(n!=0){
        n=1000-n;
        if(n/100>=5){
            ans+=n/100-4;
        }
        else{
            ans+=n/100;
        }
        if(n%10>=5){
            ans+=n%10-4;
        }
        else{
            ans+=n%10;
        }
        if((n/10)%10>=5){
            ans+=(n/10)%10-4;
        }
        else{
            ans+=(n/10)%10;
        }
        cout<<ans<<endl;
        ans=0;
        cin>>n;
    }
    return 0;
}



Measured memory_bytes: 2988
def main():
        N, K = map(int, input().split())
        P = list(map(int, input().split()))
        sort_P = sorted(P)

        ans = 0
        for i in range(K):
                ans += sort_P[i]

        return ans

if __name__=="__main__":
        ans = main()
        print(ans)

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

using namespace std;

int N, M, vertical, horizontal;
long long K;
char sir[1009][1009], aux[1009][1009];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, long long b)
{
    int p = 1;
    while (b)
    {
        if (b & 1LL) p = mul (p, a);
        a = mul (a, a), b >>= 1LL;
    }
    return p;
}

struct matrix
{
    int v[2][2];
    matrix (bool b)
    {
        v[0][0] = v[1][1] = b;
        v[0][1] = v[1][0] = 0;
    }
}base (0);

matrix operator * (matrix a, matrix b)
{
    matrix c (0);
    for (int i=0; i<2; i++)
        for (int j=0; j<2; j++)
        {
            c.v[i][j] = 0;
            for (int k=0; k<2; k++)
                adto (c.v[i][j], mul (a.v[i][k], b.v[k][j]));
        }
    return c;
}

matrix power (matrix a, long long b)
{
    matrix ans (1);
    while (b)
    {
        if (b & 1LL) ans = ans * a;
        a = a * a, b >>= 1LL;
    }
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %lld\n", &N, &M, &K);
for (int i=1; i<=N; i++)
    scanf ("%s", sir[i] + 1);
for (int i=1; i<=N; i++)
    horizontal |= (sir[i][1] == '#' && sir[i][M] == '#');
for (int j=1; j<=M; j++)
    vertical |= (sir[1][j] == '#' && sir[N][j] == '#');
if (K <= 1)
{
    printf ("1\n");
    return 0;
}
if (vertical == 0 && horizontal == 0)
{
    int cnt = 0;
    for (int i=1; i<=N; i++)
        for (int j=1; j<=M; j++)
            cnt += (sir[i][j] == '#');
    printf ("%d\n", power (cnt, K - 1));
    return 0;
}
if (vertical == 1 && horizontal == 1)
{
    printf ("1\n");
    return 0;
}
if (vertical == 1)
{
    horizontal = 1, vertical = 0;
    memcpy (aux, sir, sizeof (sir));
    for (int i=1; i<=N; i++)
        for (int j=1; j<=M; j++)
            sir[i][j] = 0;
    for (int i=1; i<=N; i++)
        for (int j=1; j<=M; j++)
            sir[j][i] = aux[i][j];
    swap (N, M);
}
int cntPairs = 0, cnt0 = 0, cntLinks = 0, cntBlack = 0;
for (int i=1; i<=N; i++)
{
    cntPairs += (sir[i][1] == '#' && sir[i][M] == '#');
    for (int j=1; j<M; j++)
        cntLinks += (sir[i][j] == '#' && sir[i][j + 1] == '#');
    for (int j=1; j<=M; j++)
        cntBlack += (sir[i][j] == '#');
    for (int j=1; j<=M; j++)
        if (sir[i][j] == '#')
        {
            cnt0 ++;
            int k = j;
            while (sir[i][k] == '#') k ++;
            k --;
            ///[j, k]
            ///
            j = k;
        }
}
if (K == 2)
{
    printf ("%d\n", cnt0);
    return 0;
}
K -= 2;
///ans[0] = cnt0, ans[i] = ans[i - 1] * cntBlack - cntPairs
base.v[1][1] = cntPairs, base.v[0][0] = cntBlack, base.v[1][0] = subtract (0, cntLinks);
matrix ans = power (base, K);
printf ("%d\n", add (mul (cnt0, ans.v[0][0]), mul (cntPairs, ans.v[1][0])));
return 0;
}


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

int main(){
    int N, M; // N: IDカードの枚数 M: ゲートの数
    cin >> N >> M;

    int L[M], R[M];
    for(int i = 0; i < M; i++){
        cin >> L[i] >> R[i];
    }

    int maxL = 1;
    int minR = N;
    for(int i = 0; i < M; i++){
        maxL = max(maxL, L[i]);
        minR = min(minR, R[i]);
    }

    int ans = minR - maxL + 1;
    ans = max(0, ans);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
N = gets.to_i
A, B, C = $<.map{|s| s.split.map &:to_i }

ans = 0
(1..N).each{|i|
  ans += B[A[i-1]-1]
  if i != N && A[i-1] + 1 == A[i]
    # p 1
    ans += C[A[i-1]-1]
  end
}
p ans

Measured memory_bytes: 1788
num = [[] for _ in range(10)]
l = int(input())
s = input()
ans = []
for i in range(l):
    n = int(s[i])
    num[n].append(i)
for i in range(10):
    num[i].sort()
for i in range(10):
    if len(num[i])>0:
        start = num[i][0]
        for j in range(10):
            if len(num[j])>0:
                s=0; e = len(num[j])-1
                nd = -1
                while(s<e):
                    nx = (s+e)//2
                    if num[j][nx]<=start:
                        s= nx+1
                    elif num[j][nx]>start:
                        e = nx
                if num[j][e]>start:
                    nd = num[j][e]
                    for k in range(10):
                        if len(num[k]) > 0:
                            s = 0;
                            e = len(num[k]) - 1
                            while (s < e):
                                nx = (s + e) // 2
                                if num[k][nx] <= nd:
                                    s = nx + 1
                                elif num[k][nx] > nd:
                                    e = nx
                            if num[k][e] > nd:
                                ans.append((i,j,k))
print(len(ans))


Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int p = 1e9 + 7;
int head[N], nxt[N << 1], to[N << 1], tot;
void AddEdge(int u, int v) {
	to[++tot] = v;
	nxt[tot] = head[u];
	head[u] = tot;
}
long long qpow(long long a, int k) {
	long long res = 1;
	while (k) {
		if (k & 1)	res = res * a % p;
		k >>= 1;
		a = a * a % p;
	}
	return res;
}
long long inv(long long x) {return qpow(x, p - 2); }
int siz[N], siz2[N], n;
long long dp[N], dp2[N], fac[N];
void dfs1(int u, int fath) {
	dp[u] = siz[u] = 1;
	for (int i = head[u]; i; i = nxt[i]) {
		int v = to[i];
		if (v != fath) {
			dfs1(v, u);
			siz[u] += siz[v];
			dp[u] = dp[v] * inv(fac[siz[v]]) % p * dp[u] % p;
		}
	}
	dp[u] = dp[u] * fac[siz[u] - 1] % p;
}
void dfs2(int u, int fath) {
	if (!fath)	dp2[u] = dp[u];
	else	dp2[u] = dp2[fath] * siz[u] % p * inv(n - siz[u]) % p;
	for (int i = head[u]; i; i = nxt[i]) {
		int v = to[i];
		if (v != fath) {
			dfs2(v, u);
		}
	}
}
int main() {
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)	fac[i] = fac[i - 1] * i % p;
	for (int i = 1; i < n; i++) {
		int u, v;	scanf("%d %d", &u, &v);
		AddEdge(u, v);
		AddEdge(v, u);
	}
	dfs1(1, 0);
	dfs2(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%lld\n", dp2[i]);
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 12664
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve()
{

    string a, b, c;
    cin >> a >> b >> c;

    int aa = 0, bb = 0, cc = 0;
    char now = 'a';
    while (true)
    {
        if (now == 'a')
        {
            if (aa == a.length())
            {
                cout << "A" << endl;
                return 0;
            }
            now = a[aa];
            aa++;

            
        }else if(now == 'b'){
            if (bb == b.length())
            {
                cout << "B" << endl;
                return 0;
            }
            now = b[bb];
            bb++;

        }else{
            if (cc == c.length())
            {
                cout << "C" << endl;
                return 0;
            }
            now = c[cc];
            cc++;

        }


    }

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define prt(x) printf("%d\n",x)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-2;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,string> pcc;
int a[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=k+1;i<=n;i++)
	{
		if(a[i]>a[i-k])
		cout<<"Yes"<<endl;
		else
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 4408
// https://atcoder.jp/contests/abc117/tasks/abc117_c
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i, M) cin >> X[i];
    if (M <= N)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(X.begin(), X.end());
    vector<int> d(M - 1);
    REP(i, M - 1)
    {
        d[i] = X[i + 1] - X[i];
    }
    ll ans = 0;
    sort(d.begin(), d.end());
    int cntd = M - N;
    REP(i, cntd)
    {
        ans += d[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4064
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,x=0; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i]; x += a[i];
	}
	long long ans1 = 0,ans2=0;
	for (int i = 0; i < N; i++) {
		if (x >= 0) ans1 += pow((x + N - 1) / N - a[i], 2);
		else ans1 += pow((x - N + 1) / N - a[i], 2);
		ans2 += pow(x / N - a[i], 2);
	}
	cout << min(ans1,ans2) << endl;
}



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

int main() {
	int N, a, last = 101, length = 1, ans = 0;
	cin >> N;
	for (int i = 0;i < N;i ++) {
		cin >> a;
		if (last == a) length ++;
		else {
			ans += length / 2;
			length = 1;
			last = a;
		}
	}
	cout << ans + length / 2;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

連続したスライムの列以外は変える必要が無いし、同じ色になる可能性を考慮する必要もない
連続したスライムの長さをAとしよう
この時、Aが偶数なら交互に変えれば良いのでA/2
奇数なら2番目、4番目……と変えれば良いのでA/2
*/

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

using namespace std;

int main()
{
    int n, v1, v2, deck[2001];
    cin >> n >> v1 >> v2;
    for (int i = 0 ; i < n; ++i)
        cin >> deck[i];
    int dif1, dif2 = 0;
    dif1 = deck[n - 1] - v2;
    if (n > 1)
        dif2 = deck[n - 2] - deck[n - 1];
    if (abs(dif1) > abs(dif2))
        v1 = deck[n - 1];
    else {
        v1 = deck[n - 2];
        v2 = deck[n - 1];
    }
    cout << abs(v1 - v2);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,m,i=0,j=0,k=0,p=0,a,b,c,d;
string s;cin>>s;n=s.size();a=(n-3)/2;b=(n+1)/2;c=n-1;d=0;
while(d<c){
    if(s[c]!=s[d]){
        j=1;break;
    }c--;d++;
}d=0;c=n-1;
while(d<a){
    if(s[d]!=s[a]){
        k=1;break;
    }a--;d++;
}while(b<c){
    if(s[c]!=s[b]){
        p=1;break;
    }c--;b++;
}if(p==1||j==1||k==1)
cout<<"No";
else
cout<<"Yes";


    return 0;
  
}

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

const double rate = 1.08;

int main() {
    int n;
    cin >> n;
    int q = n / rate;
    int p = 0;
    while (p < n) {
        p = q * rate;
        if(p == n) {
            cout << q << endl;
            return 0;
        }
        q++;
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//
		while(true){
		//??£?¨??????????????????????
		long sum = 0;
		//1??????????????????
		String line = sc.nextLine();
		//?????£?????\???????????????1???
		
			//?????£?????\????????????1??????0?????£?????´????????????
			if(line.equals("0")){
				break;
				}
			
			//
			for(int i=0;i<line.length();i++){
				sum += Integer.parseInt(String.valueOf(line.charAt(i)));
			}
			//
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 27036
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	double l;
	cin >> l;
	cout << fixed << setprecision(20) << l * l * l / 27 << endl;
}

Measured memory_bytes: 256
//ABC110 rated for me
#include<bits/stdc++.h>
using namespace std;
int main(){
    int R;cin >> R;
    if(R < 1200){
        cout << "ABC" << endl;
    }
    else if(R < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int t = 10;
    for(int i=1;i<=3;i++){
        int k = N % t;
        if(k*10/t==7){
            cout << "Yes" <<endl;
            return 0;
        }
        N -= k;
        t *= 10;
    }
    cout << "No" <<endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    int arr[n];
    for (int i = 0; i != n; ++i)
        cin >> arr[i];
    pair<int, int> kek[m];
    for (int i = 0; i != m; ++i)
        cin >> kek[i].second >> kek[i].first;
    sort(arr, arr + n);
    sort(kek, kek + m);
    for (int i = 0, j = m - 1; i != n && j != -1; ++i)
    {
        if (arr[i] < kek[j].first)
        {
            arr[i] = kek[j].first;
            --kek[j].second;
            if (!kek[j].second)
                --j;
        }
    }
    long long sum = 0;
    for (int i = 0; i != n; ++i)
        sum += arr[i];
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 1408
// G++ MACro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){

  CIN(a,b,c);
  clock_t st=clock();
  ll cou=0;
  while(1){
    if(a%2||b%2||c%2){
      COUT(cou);
      return 0;
    }
    cou++;
    int d=a;int e=b;int f=c;
    a=e/2+f/2;
    b=d/2+f/2;
    c=d/2+e/2;
    clock_t en=clock();
    if((double)en-st>1e6+9e5)break;
  }
  COUT(-1);return 0;

  return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b&&a!=c) {
    cout << c << endl;
  } else if (b==c&&c!=a) {
    cout << a << endl;
  } else {
    cout << b << endl;
  }
  return 0;
}

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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  i64 ans = 0, now = 1;
  for (i64 i = 0; i < n; i++)
  {
    if (a[i] == now)
      now++;
    else
      ans++;
  }
  if (ans == n)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int main(void){
double a,b,c,h,sum,s;
scanf("%lf %lf %lf",&a,&b,&c);
h=sin(c*(M_PI/180))*b;
s=a*h/2;
sum=a+b+sqrt(a*a+b*b-2*a*b*cos(c*(M_PI/180)));
printf("%lf\n%lf\n%lf\n",s,sum,h);
return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define sz(a) (int)(a.size())
#define all(a) begin(a), end(a)
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;

const int MAX = 2005;

vector<ii> v;

lli eval(lli x, lli y) {
    lli ans = 0;
    lli mn = -1;
    for(auto it : v) {
        lli ev = (it.f * x) + (it.s * y);
        if(mn == -1) mn = ev;
        else mn = min(mn, ev);
        ans = max(ans, ev - mn);
    }
    return ans;
}

int main()
{   _
    int n; cin >> n;
    v.resize(n); fore(i, 0, n) cin >> v[i].f >> v[i].s;
    cout << max({eval(1, 1), eval(1, -1), eval(-1, 1), eval(-1, -1)});
    return 0;
}


Measured memory_bytes: 6360
n,k=map(int,input().split())
v=list(map(int,input().split()))
ans=0
for l in range(min(k+1,n+1)):
  for r in range(min(k+1-l,n+1-l)):
    if l==0 and r==0:
      continue
    rem=r+l
    if l==0:
      arr=v[n-r:]
    elif r==0:
      arr=v[:l]
    else:
      arr=v[:l]+v[n-r:]
    arr.sort()
    m=sum(arr)
    idx=0
    while 0<=idx<len(arr) and arr[idx]<0 and rem<k:
      rem+=1
      m-=arr[idx]
      idx+=1
    ans=max(ans,m)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
    
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String strArr[] = str.split(" ");
        
        int x = 0;
        int y = 0;
        int tmp_x = Integer.parseInt(strArr[0]);
        int tmp_y = Integer.parseInt(strArr[1]);
        
        if (tmp_x > tmp_y) {
            y = tmp_x;
            x = tmp_y;
        } else {
            x = tmp_x;
            y = tmp_y;
        }
        
        while(y > 0){
            int r = x % y;
            x = y;
            y = r;
        }

        System.out.println(x);
    }
}


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

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll binPowM(ll a,ll b, ll m)
{ 
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
return ans%m;
}
ll f(ll x,ll y,ll a)
{
  return (a&x)*(a&y);
}

int main()
{
string s;cin>>s;
if(s[1]=='R')cout<<"ABC"<<"\n";
else cout<<"ARC"<<"\n";


  return 0;
}





Measured memory_bytes: 3624
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:x[1])
time = 0
ans = "Yes"
for i in range(N):
    time += AB[i][0]
    if time > AB[i][1]:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 46892
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int gcd(int a,int b){
	while(b>0){
		int t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int lcm(int a,int b){
	return a*b/gcd(a,b);
}

void solve(){  
	int a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

int main(void){

    int N;

    scanf("%d", &N);

    long long L[N+1];

    L[0] = 2, L[1] = 1;

    for(int i = 2; i <= N; i++){
        L[i] = L[i-1] + L[i-2];
    }

    printf("%lld\n", L[N]);

    return 0;
}

Measured memory_bytes: 1732