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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " : " << x << '\n'

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

  int ans = 0;
  int N;
  cin >> N;
  int a;
  FOR(i, 0, N) {
    cin >> a;
    ans += a - 1;
  }

  cout << ans << '\n';

  return 0;
}

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

using ll = long long int;

using pll = pair<ll,ll>;

ll dp[100010] = {};

ll solve(ll i){
    
    deque<pll> d;
    
    d.push_front({1,1});
    
    while(true){
        
        pll now = d.front();
        d.pop_front();
        
        if(now.first == 0){
            return now.second;
        }
        
        if(dp[now.first] != 0){
            continue;
        }
        
        dp[now.first] = now.second;
        
        d.push_front({(now.first*10)%i,now.second});
        
        if(now.first % 10 != 9)
            d.push_back({(now.first+1)%i,now.second+1});
        
    }
    
}

int main(void){
    
    ll k;
    cin >> k;
    
    cout << solve(k) << endl;
    
    return 0;
}


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

signed main(void)
{
	int n, k;
	double sum[200010];
	double ans;

	cin >> n >> k;
	ans = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		sum[i] = (double)(a + 1) / 2;
	}
	rep(i, n) sum[i] += sum[i - 1];
	for (int i = k; i <= n; i++)
		ans = max(sum[i] - sum[i - k],ans);
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int a,b,c;cin>>a>>b>>c;
  flag2func(((a==b && a!=c)||(a==c && a!=b)||(b==c && b!=a)));
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
a = []
l = []
for i in range(N+M):
    a.append(list(map(int, input().split())))
for i in range(0, N):
    l = []
    for j in range(0, M):
        d = abs((a[i][0] - a[N+j][0])) + abs((a[i][1] - a[N+j][1]))
        l.append(d)
    #print(l)
    print(l.index(min(l))+1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	map<char, ll> cnt;
	ll ans = 0;
	for(int i = n-1; i >= 0; i--){
		ans += n - 1 - i - cnt[s[i]];
		cnt[s[i]]++;
	}
	ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
#!/usr/bin/env python3
from functools import reduce
import sys

MOD = 1000000007  # type: int


def solve(N: int):
    print(reduce(lambda a, b: a * b % MOD, range(1, N + 1), 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

int hlen[2001][2001];
int vlen[2001][2001];

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    rep(y, H) {
        for (int head = 0, x = 0, len = 0; x < W; ++x) {
            if (S[y][x] == '#') {
                for (int i = head; i < x; ++i) {
                    hlen[y][i] = len;
                }
                hlen[y][x] = 0;
                len = 0;
                head = x + 1;
            } else {
                ++len;
                if (x == W-1) {
                    for (int i = head; i < W; ++i) {
                        hlen[y][i] = len;
                    }
                }
            }
        }
    }

    rep(x, W) {
        for (int head = 0, y = 0, len = 0; y < H; ++y) {
            if (S[y][x] == '#') {
                for (int i = head; i < y; ++i) {
                    vlen[i][x] = len;
                }
                vlen[y][x] = 0;
                len = 0;
                head = y + 1;
            } else {
                ++len;
                if (y == H-1) {
                    for (int i = head; i < H; ++i) {
                        vlen[i][x] = len;
                    }
                }
            }
        }
    }

    int ans = 0;
    rep(y, H) rep(x, W) ans = max(ans, vlen[y][x] + hlen[y][x] - 1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int main(){
	int H, K;
	cin>>H>>K;
	vector< int > vc;

	for(int i=1; i<=H; i++){
		int a;
		cin>>a;
		vc.push_back(a);
	}

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

	long long sum =0;
	for(int i=vc.size()-1; i>=0; i--, K--){
		if(K<=0) sum+=vc[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){

  int ans = 0;
  int x = 0;
  string s;

  cin >> s;

  for(int i=0;i<s.size();i++){
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
      x++;
      if(ans<x){
        ans = x;
      }
    }
    else{
      x = 0;
    }
  }

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

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

#define S_MAX 20000
#define N_MAX 20000
#define M_MAX 1000
#define INF 2000000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int h, w;
int i, j;
ull k;

ull a[N_MAX];
ull b[N_MAX + 1];

typedef struct {
	int in;
	int out;
} twoway;

void solve(){

	b[0] = 0;

	for (i = 1; i <= n; i++) {
		ull rgmin = INF, rgmax = 0;
		ull result = ~0;

		for (j = 0; j < m && j < i; j++) {
			ull cand;
			if (a[i - j - 1] < rgmin) rgmin = a[i - j - 1];
			if (a[i - j - 1] > rgmax) rgmax = a[i - j - 1];
			cand = b[i - j - 1] + (j + 1) * (rgmax - rgmin);
			// printf("range [%d-%d] %llu\n", i - j - 1, i - 1, cand);
			if (cand < result) result = cand;
		}
		b[i] = k + result;

		// printf("deb: %d %llu\n", i, b[i]);
	}

	printf("%llu\n", b[n]);

	return;
}

int main (void) {
	scanf("%d%d%llu", &n, &m, &k);
	for (i = 0; i < n; i++) scanf("%llu", &a[i]);

	solve();
	
	return 0;
}

Measured memory_bytes: 916
#include <iostream>

using namespace std;

int main() {
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0){
        cout << "1" << endl;
    } else if(b==0) {
        cout << "2" << endl;
    } else if(c==0) {
        cout << "3" << endl;
    } else if(d==0) {
        cout << "4" << endl;
    } else if(e==0) {
        cout << "5" << endl;
    }
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string str;

int main() {
    cin >> str;
    int sum = 0;
    if (str.size() == 1) {
        cout << str[0]-'0' << endl;
        return 0;
    }
    rep(i,str.size()) sum += str[i]-'0';
    bool ok = true;
    for (int i = 1; i < str.size(); i++) {
        if (str[i] != '9') ok = false;
    }
    if (ok) cout << sum << endl;
    else cout << str[0]-'1'+(str.size()-1)*9 << endl;
}
































Measured memory_bytes: 256
#include <iostream>
//#include <cstdio>
#include <cmath>
using namespace std;
  
//0002
int main(){
    int a, b, c;
    while(cin >> a >> b){
        c = a + b;
        cout << 1 + (int)log10(c) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.HashSet;
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++) {
            int a = in.nextInt();
            if(set.contains(a)) set.remove(new Integer(a));
            else set.add(a);
            
        }
        System.out.println(set.size());
    }
}

Measured memory_bytes: 63148
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int n, m;

int a[maxn], b[maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", b + i);
  }
  return 1;
}

pair<int, int> c[maxn], d[maxn];

void solve() {
  a[n] = b[m] = inf;

  long long res = 0;

  for (int i = 0; i < n; ++i) {
    c[i] = mp(a[i], i);
  }

  for (int i = 0; i < m; ++i) {
    d[i] = mp(b[i], i);
  }
  sort(c, c + n);
  sort(d, d + m);

  for (int i = 0, j = 0; i < n || j < m;) {
    if (i < n && (j == m || c[i].first < d[j].first)) {
      res += (long long) c[i].first * (m - j + 1);
      ++i;
    } else {
      res += (long long) d[j].first * (n - i + 1);
      ++j;
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2688
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

class UFTree {
  vector<int> m_parent;
  vector<int> m_height;
  vector<int> m_size;

 public:
  UFTree(int size) {
    for (int i = 0; i < size; i++) {
      m_parent.push_back(i);
      m_height.push_back(0);
      m_size.push_back(1);
    }
  }

  int root(int node) {
    if (m_parent[node] == node) {
      return node;
    }
    return m_parent[node] = root(m_parent[node]);
  }
  void merge(int n0, int n1) {
    int r0 = root(n0), r1 = root(n1);
    if (r0 == r1) {
      return;
    }
    if (m_height[r0] < m_height[r1]) swap(r0, r1);
    if (m_height[r0] == m_height[r1]) m_height[r0]++;
    m_parent[r1] = r0;
    m_size[r0] += m_size[r1];
  }
  int size(int node) { return m_size[node]; }
};

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> result(N, 0);
  UFTree s(N);

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    result[a]--;
    result[b]--;
    s.merge(a, b);
  }

  rep(i, N) { result[i] += s.size(s.root(i)) - 1; }

  rep(i, K) {
    int c, d;
    cin >> c >> d;
    c--;
    d--;

    if (s.root(c) == s.root(d)) {
      result[c]--;
      result[d]--;
    }
  }

  rep(i, N) { cout << result[i] << " "; }
  cout << endl;

  return 0;
}

Measured memory_bytes: 2668
#include<bits/stdc++.h>
#define ll long long int


using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll i;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll s=0;
    for(i=0;i<k;i++)
    s+=a[i];
    cout<<s<<endl;
  
  return 0;
}

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

ll abs64(ll a) {
	if (a>=0) return a;
	else return -a;
}

ll height(ll H, ll CX, ll CY, ll X, ll Y) {
	return max(H - abs64(X-CX) - abs64(Y-CY), 0LL);
}

int main() {
	ll n;
	cin >> n;
	vector<ll> x(n), y(n), h(n);
	ll dx, dy, dh;
	dx = 0;dy = 0;dh = 0;
	rep(i,n) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i]>=dh) {
			dx = x[i];dy = y[i];dh = h[i];
		}
	}
	ll ans_x, ans_y, ans_h;
	rep(cx, 101) {
		rep(cy, 101) {
			ll H = dh + abs64(dx-cx) + abs64(dy-cy);
			bool flag_p = true;
			rep(i,n) if (height(H,cx,cy,x[i],y[i]) != h[i]) flag_p = false;
			if (flag_p) {ans_x=cx;ans_y=cy;ans_h=H;}
		}
	}
	printf("%lld %lld %lld\n", ans_x, ans_y, ans_h);
	/*
	vector<int> x(N), y(N), h(N);
	vector<vector<bool>> f_center(N_max + 1, vector<bool>(N_max + 1));
	vector<vector<long long int>> h_center(N_max + 1, vector<long long int>(N_max + 1));

	REP(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}

	REP(i, N_max + 1) {
		REP(j, N_max + 1) {
			f_center[i][j] = true;
		}
	}

	REP(i, N) {
		if (i == 0) {
			REP(j, N_max + 1) {
				REP(k, N_max + 1) {
					h_center[j][k] = h[i] + abs(x[i] - j) + abs(y[i] - k);
				}
			}
		}
		else {
			REP(j, N_max + 1) {
				REP(k, N_max + 1) {
					if (h_center[j][k] != h[i] + abs(x[i] - j) + abs(y[i] - k)) {
						f_center[j][k] = false;
					}
				}
			}

		}
	}

	REP(i, N_max + 1) {
		REP(j, N_max + 1) {
			if (f_center[i][j] == true) {
				cout << i << " " << j << " " << h_center[i][j] << endl;
			}
		}
	}
	*/
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vi vec[200001];
int x[200001]={};
int dp[200001];

int main() {
	int r;
	cin>>r;
	printf("%d",r*r);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

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

int main()
{
	ll h,w,ans=0,a;
	vvll v(10,vll(10));
	cin >> h >> w;
	rep(i,10)rep(j,10) cin >> v[i][j];
	rep(k,10)rep(i,10)rep(j,10) chmin(v[i][j],v[i][k]+v[k][j]);
	rep(i,h){
		rep(j,w){
			cin >> a;
			if(a!=-1) ans+=v[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
n,k=map(int,input().split())
import sys
mod=998244353 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as frac  #frac(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

dp=[0]*(n*2+10)
#dp[0]=1
S=[0]*(n*2+10)
K=[list(map(int,input().split())) for i in range(k)]
for x,y in K:
  S[x]+=1
  S[y+1]-=1
#print(S)
for i in range(1,n):
    dp[i]= (dp[i-1]+S[i])%mod
    if dp[i]==0:continue
    for x,y in K:
        S[i+x]+= dp[i] % mod
        S[i+y+1]-= dp[i] % mod
#print(K,dp)
print(dp[n-1]%mod)

Measured memory_bytes: 79504
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main() {
    int N;
    string ans = "Yes";
    cin >> N;
    int H[N]; 
    for (int i=0; i<N; i++) scanf("%d", &H[i]);

    for (int i=N-1; i>0; i--) {
        if (H[i] < H[i-1]) {
            H[i-1]--;
            if (H[i] < H[i-1]) {
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
int par[300002];
int rk[300002];
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
		rk[i]=0;
	}
}
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rk[x]==rk[y]) rk[x]++;
	}
}
bool same(int x, int y){
	return find(x)==find(y);
}
int main()
{
	int n;
	cin>>n;
	int a[600001];
	bool all1=1;
	ll ct[300001]={};
	for(int i=0; i<n; i++){
		cin>>a[i];
		ct[a[i]]++;
		if(a[i]>1) all1=0;
		a[i+n]=a[i];
	}
	if(all1){
		ll ans=1;
		for(ll i=1; i<=n; i++) ans=ans*i%MOD;
		cout<<ans<<endl;
		return 0;
	}
	int mn[300001], mx[300001];
	fill(mn, mn+n+1, -1);
	int i0=0;
	for(int i=1; i<n; i++){
		if(a[i]!=a[0]){
			i0=i;
			break;
		}
	}
	int p=-1;
	for(int i=i0; i<n+i0; i++){
		if(p!=a[i]){
			if(p!=-1) mx[p]=i-1;
			p=a[i];
			if(mn[p]>0){
				cout<<0<<endl;
				return 0;
			}
			mn[p]=i;
		}
	}
	mx[p]=n+i0-1;
	if(mn[1]==-1){
		cout<<0<<endl;
		return 0;
	}
	int d=mx[1]-mn[1]+1;
	for(int i=2; i<=n; i++){
		if(mn[i]>0 && mx[i]-mn[i]+1>d){
			cout<<0<<endl;
			return 0;
		}
	}
	for(int i=1; i<=n; i++){
		ct[i]+=ct[i-1];
	}
	init(n);
	ll e=0;
	ll ans=1;
	for(int i=1; i<=n; i++){
		if(mn[i]>0){
			for(int j=mn[i]; j<=mx[i]; j++){
				if(a[(j+n-1)%n]<=i){
					if(!same((j+n-1)%n, j%n)){
						unite((j+n-1)%n, j%n);
						e++;
					}
				}
				if(a[(j+1)%n]<=i){
					if(!same((j+1)%n, j%n)){
						unite((j+1)%n, j%n);
						e++;
					}
				}
			}
		}
		if(mn[i]>0){
			int i1=(mn[i]-1+n)%n, i2=(mx[i]+1)%n;
			if(mx[i]-mn[i]+1<d && a[i1]>i && a[i2]>i){
				cout<<0<<endl;
				return 0;
			}
			if(a[i1]>i || a[i2]>i) continue;
			ans*=((ll)(mn[i]-mx[i]+d));
			ans%=MOD;
		}else{
			if(e<n-1){
				ans*=(ct[i]-((ll)d-1)*(ct[i]-e)-(ll)i+1);
				ans%=MOD;
			}else{
				ans*=((ll)(n-i+1));
				ans%=MOD;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int H, W; cin >> H >> W;
    
    int fi[H+1][W+1];
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> fi[i][j];
    vector<tuple<int, int, int, int>> ans;

    for(int i=1; i<=H; i++){
        if(i%2 == 1){
            for(int j=1; j<=W; j++){
                if(i == H && j == W) continue;
                if(fi[i][j]%2 == 1 && j != W){
                    ans.push_back(make_tuple(i, j, i, j+1));
                    fi[i][j+1]++;
                } else if(fi[i][j]%2 == 1 && j == W){
                    ans.push_back(make_tuple(i,j,i+1,j));
                    fi[i+1][j]++;
                } 
            }
        } else {
            for(int j=W; j>=1; j--){
                if(i == H && j == 1) continue;
                if(fi[i][j]%2 == 1 && j != 1){
                    ans.push_back(make_tuple(i,j,i,j-1));
                    fi[i][j-1]++;
                } else if(fi[i][j]%2 == 1 && j == 1){
                    ans.push_back(make_tuple(i,j,i+1,j));
                    fi[i+1][j]++;
                }
            }
        }
    }


    cout << ans.size() << endl;
    for(auto e:ans){
        printf("%d %d %d %d\n", get<0>(e), get<1>(e), get<2>(e), get<3>(e));
    }
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N,K;
    cin >> N >> K;
    int H[N],sum = 0;
    for(int i=0;i<N;i++){
        cin >> H[i];
        sum += H[i];
    }
    
    sort(H,H+N,greater<int>());
    
    int k = 0;
    
    for(int i=0;i<min(N,K);i++){
        k += H[i];
    }
    
    cout << sum - k << endl;
    return 0;
}


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

int main(){
	int N, ans = 0;
	cin >> N;
	for(int i=0 ; i < N ; i++ ){
		int s;
		cin >> s;
		bool f = false;
		for(int x = 1 ; 2 * (x * x + x) <= s ; x++ ){
			if( ((s - x) % (2 * x + 1)) == 0 ){
				f = true;
				break;
			}
		}
		if( !f ) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

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


void Calc() {

  int n = in;
  string s = in;
  string ans;
  int cnt = 0;
  for (auto& i : s) {
    if (i == '(')cnt++;
    else {
      cnt--;
      if (cnt < 0) {
        ans = '(' + ans;
        cnt = 0;
      }
    }
    ans += i;
  }
  rep(i, cnt)ans += ')';
  cout << (ans) << endl;


}


Measured memory_bytes: 256
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::BinaryHeap;

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [usize; n]
    }
    let mut pq = BinaryHeap::new();
    for i in 0..n {
        pq.push(v[i]);
    }
    for _ in 0..m {
        let x = pq.pop().unwrap();
        pq.push(x >> 1);
    }
    println!("{}", pq.iter().cloned().sum::<usize>());
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include <stack>
#include <queue>
#include <map>
#include<math.h>
#include<string.h>

using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define pb push_back

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

ll MOD = 1e9 + 7; 

int main(){
    ll n;
    cin >> n;
    ll ans = 1;
    for(ll i=1; i<=n; ++i){
        ans *= i;
        ans %=MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000;
int main()
{
   ll sum,a,b;
   cin>>a>>b;
   if(a<b) swap(a,b); //a>b
   if(a>2&&b>2)
    sum=a*b-(2*a+2*b-4);
   else if(b==1&&a!=1)
    sum=a-2;
   else if(b==2)
    sum=0;
   else if(a==1&&b==1)
    sum=1;
   cout<<sum<<endl;

}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())

ans=A*X+B*Y
a=0

for i in range(min(X,Y)+1):
    a=A*(X-i)+B*(Y-i)+C*i*2
    if(a<ans):
        ans=a
a=C*max(X,Y)*2
if(a<ans):
    ans=a
print(ans)

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


l = make_divisors(n)
x = int(l[len(l) // 2] + n / l[len(l) // 2] - 2)

print(x)

Measured memory_bytes: 3268
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  int A = in();
  int B = in();
  puts((B - A) % 2 == 0 ? "Alice" : "Borys");
  return 0;
}


Measured memory_bytes: 764
#階乗
F = 10**6+5
mod = 10**9+7
fact = [1]*F
inv = [1]*F
for i in range(2,F):
    fact[i]=(fact[i-1]*i)%mod
inv[F-1]=pow(fact[F-1],mod-2,mod)
for i in range(F-2,1,-1):
    inv[i] = (inv[i+1]*(i+1))%mod

x,y=map(int,input().split())
t=(x+y)//3
if (x+y)%3!=0 or x<t or y<t:
    print(0)
else:
    print(fact[t]*inv[x-t]*inv[2*t-x]%mod)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    ll H, A;
    cin >> H >> A;
    ll ans = 0;
    while(H > 0){
        H -= A;
        ans++;
    }

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


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

const int N = 1e6 + 10;
const int Q = 1e6 + 10;
const int K = 1e6 + 10;

int n , q , a[N] , bel[N] , cnt[K] , ans[Q] , now;

struct Mo_Team{
	int l , r , id;
	bool operator < (const Mo_Team &a) const
	 {
		return (bel[l] ^ bel[a.l]) ? bel[l] < bel[a.l] : ((bel[l] & 1) ? r < a.r : r > a.r);
	}
}Ques[Q];

void Add(int pos){
	now += !(cnt[a[pos]]++);
}

void Del(int pos){
	now -= !(--cnt[a[pos]]);
}

int main(){
	scanf("%d %d" , &n , &q);
	for(int i = 1; i <= n; i++) scanf("%d" , &a[i]);
	int num = sqrt(n) , siz = ceil(1.0 * n / num);
	for(int i = 1; i <= num; i++)
		for(int j = (i - 1) * siz + 1; j <= i * siz; j++) bel[j] = i;
	for(int i = 1; i <= q; i++)
		scanf("%d %d" , &Ques[i].l , &Ques[i].r) , Ques[i].id = i;
	sort(Ques + 1 , Ques + q + 1);
	int l = 1 , r = 0;
	for(int i = 1; i <= q; i++){
		while(l < Ques[i].l) Del(l++);
		while(l > Ques[i].l) Add(--l);
		while(r < Ques[i].r) Add(++r);
		while(r > Ques[i].r) Del(r--);
		ans[Ques[i].id] = now;
	}
	for(int i = 1; i <= q; i++) printf("%d\n" , ans[i]);
	return 0;
}	

Measured memory_bytes: 17440
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=1e5+1;
const int mod=998244353;
ll a[N], b[N], c[N];

ll dp[101][N];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    
    string a, b;
    cin>>a>>b;
    int na=a.length(), nb=b.length();

    vector<vector<string> > dp(2, vector<string>(nb+1, ""));
    for(int i=1;i<=na;++i){
        for(int j=1;j<=nb;++j){
            if(dp[(i-1)&1][j].length()>dp[i&1][j-1].length()){
                dp[i&1][j]=dp[(i-1)&1][j];
            }
            else{
                dp[i&1][j]=dp[i&1][j-1];
            }
            
            if(a[i-1]==b[j-1]){
                string str=dp[(i-1)&1][j-1];
                str.pb(a[i-1]);
                if(dp[i&1][j].length()<str.length()){
                    dp[i&1][j]=str;
                }
            }
        }
    }

    cout<<dp[na&1][nb]<<endl;

}

Measured memory_bytes: 8576
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def BellmanFord(g, s):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v.keys()))
    V = set(V)

    dist = defaultdict(lambda: sys.maxsize)
    pred = defaultdict(lambda: -1)

    dist[s] = 0

    N = len(V)
    for i in range(N+1):
        for u in g:
            for v in g[u]:
                if dist[v] > dist[u] + g[u][v]:
                    if i == N:
                        return 'inf'
                    dist[v] = dist[u] + g[u][v]
                    pred[v] = u
    return dist



@mt
def slv(H, W, S):
    g = defaultdict(dict)
    for i in range(H):
        for j in range(W):
            for x, y in ((0, 1), (1, 0)):
                if 0 <= i + x < H and 0 <= j+y < W:
                    if S[i][j] == '.' and S[i+x][j+y] == '#':
                        c = 1
                    else:
                        c = 0
                    g[(i, j)][(i+x, j+y)] = c
    g[0][(0, 0)] = 1 if S[0][0] == '#' else 0

    def bfs(s=0):
        q = deque()
        q.append(s)
        d = defaultdict(lambda: sys.maxsize)
        d[s] = 0
        while q:
            u = q.popleft()
            for v, c in g[u].items():
                if d[u] + c < d[v]:
                    d[v] = d[u] + c
                    if c == 0:
                        q.appendleft(v)
                    else:
                        q.append(v)

        return d

    return bfs()[(H-1, W-1)]


def main():
    H, W = read_int_n()
    S = [read_str() for _ in range(H)]
    print(slv(H, W, S))

    # H = 100
    # W = 100
    # S = [''.join(random.choices('.#', k=W)) for _ in range(H)]
    # print(slv(H, W, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 69868
#include <iostream>
#include <unordered_map>

int main(int argc, char *argv[]) {
  int n, m;
  std::cin >> n >> m;
  std::unordered_map<int, int> a;
  for (int i = 1; i <= m; ++i)
    a.insert({i, 0});

  for (int i = 0; i < n; ++i) {
    int k, ai;
    std::cin >> k;
    for (int j = 0; j < k; ++j) {
      std::cin >> ai;
      ++a.at(ai);
    }
  }

  int count = 0;
  for (auto &v : a) {
    if (v.second == n)
      ++count;
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	S = input().rstrip()
	bcnt = 0
	ans = 0
	for i in range(len(S)):
		if S[i] == 'B': bcnt += 1
		if S[i] == 'W': ans += bcnt
	
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3500
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;


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

	// long long?
	ll N, K;
	cin >> N >> K;

	int ans = 0;
	rep(i, N) {
		int h = 0;
		cin >> h;
		if (h >= K) ans++;
	}

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

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e4 + 5);
const ll MOD = (ll)(1e9 + 7);

/////////////////////////////////////////////////////////////
class CombinationModulo {
public:
  static const int MAX_N_LIB = (int)(2e5 + 100);
  static const ll MOD_LIB = (ll)(1e9 + 7);

  ll fact[MAX_N_LIB];
  ll inv[MAX_N_LIB];
  ll fact_inv[MAX_N_LIB];

  CombinationModulo(int n) {
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD_LIB - (MOD_LIB / i) * inv[MOD_LIB % i] % MOD_LIB) % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD_LIB;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
  	return fact[n] * fact_inv[r] % MOD_LIB * fact_inv[n - r] % MOD_LIB;
  }
};
/////////////////////////////////////////////////////////////

int n, k;

CombinationModulo cm(MAX_N);

ll calc(int cur_k) {
  ll base = cm.comb(n - k + 1, cur_k);

  ll remain = (ll)(k - cur_k);

  ll add = cm.comb(cur_k + remain - 1, remain);

  return (base * add) % MOD;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 1; i <= k; ++i) {
    printf("%lld\n", calc(i));
  }

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf (1ll<<60)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll A, B, Q; cin >> A >> B >> Q;
    vll s(A); rep(i, A) cin >> s[i];
    vll t(B); rep(i, B) cin >> t[i];
    vll x(Q); rep(i, Q) cin >> x[i];

    sort(all(s)), sort(all(t));
    s.insert(s.begin(), -inf);
    s.push_back(inf);
    t.insert(t.begin(), -inf);
    t.push_back(inf);
    rep(i, Q) {
        vll ns(2), nt(2);
        ll pos = x[i];
        ll left = 0, right = s.size() - 1;
        ll mid;
        while (right - left > 1) {
            mid = (left + right) / 2;
            if (s[mid] < pos && pos <= s[mid + 1]) {
                ns[0] = s[mid], ns[1] = s[mid + 1];
                break;
            }

            if (pos <= s[mid]) right = mid;
            else left = mid;
        }
        ns[0] = s[mid], ns[1] = s[mid + 1];
        left = 0, right = t.size() - 1;
        while (right - left > 1) {
            mid = (left + right) / 2;
            if (t[mid] < pos && pos <= t[mid + 1]) {
                nt[0] = t[mid], nt[1] = t[mid + 1];
                break;
            }

            if (pos <= t[mid]) right = mid;
            else left = mid;
        }
        nt[0] = t[mid], nt[1] = t[mid + 1];

        ll min_num = inf;
        rep(i, 2) rep(j, 2) {
            min_num = min(
                min_num,
                abs(ns[i] - pos) + abs(nt[j] - ns[i])
            );
        }

        rep(i, 2) rep(j, 2) {
            min_num = min(
                min_num,
                abs(nt[i] - pos) + abs(ns[j] - nt[i])
            );
        }
        cout << min_num << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100002
#define int long long
using namespace std;
const int mod=1000000007;
int n,m,t,t1,i,j,a[N],b[N],tmp[N],tree[N],ans=1;
pair<int,int> c[N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
int my_comp(const pair<int,int> &x,const pair<int,int> &y)
{
	if(x.first==y.first) return x.second>y.second;
	return x.first<y.first;
}
int lowbit(int x)
{
	return x&(-x);
}
void modify(int x,int y)
{
	for(int i=x;i<=t1;i+=lowbit(i)) tree[i]=(tree[i]+y)%mod;
}
int ask(int x)
{
	int ans=0;
	for(int i=x;i>=1;i-=lowbit(i)) ans=(ans+tree[i])%mod;
	return ans;
}
signed main()
{
	n=read();m=read();
	for(i=1;i<=n;i++) a[i]=read();
	for(i=1;i<=m;i++) b[i]=read();
	for(i=1;i<=n;i++){
		if(a[i]>b[1]&&a[i]<b[m]){
			j=lower_bound(b+1,b+m+1,a[i])-b;
			if(a[i]!=b[j]){
				c[++t]=make_pair(a[i]-b[j-1],b[j]-a[i]);
				tmp[t]=b[j]-a[i];
			}
		}
	}
	sort(tmp+1,tmp+t+1);
	t1=unique(tmp+1,tmp+t+1)-tmp-1;
	for(i=1;i<=t;i++) c[i].second=lower_bound(tmp+1,tmp+t1+1,c[i].second)-tmp;
	sort(c+1,c+t+1,my_comp);
	t=unique(c+1,c+t+1)-c-1;
	for(i=1;i<=t;i++){
		int sum=ask(c[i].second-1)+1;
		ans=(ans+sum)%mod;
		modify(c[i].second,sum);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main() {
    int r,D,newx,x;
    cin >> r >> D >> x;
    newx =x*r-D;
    for(int i=1;i<=10;++i){
       cout << newx <<endl;
        newx = newx*r-D;
       
        
         }
    return 0;
}

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

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

vector<int> a(N);
vector<bool> visited(N);
for (int i = 0; i < N; i++) {
    cin >> a[i];
    visited[i] = false;
}

int ans = 0;
int curr_but = 1;
while (true) {
    visited[curr_but - 1] = true;
    if (curr_but == 2){
        cout << ans << endl;
        return 0;
    }
    ans++;
    curr_but = a[curr_but - 1];
    if (visited[curr_but - 1]) {
        cout << -1 << endl;
        return 0;
    }
}

}

Measured memory_bytes: 640
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;

public class Main {
	public Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj0085().doIt();
	}
	class aoj0085{
		void doIt() {
			while(true){
				int n = sc.nextInt();
				int s = sc.nextInt();
				if(n + s == 0)break;
				int a[] = new int [n+1];
				a[0] = 1;
				int cnt = 0;
				int num = 0;
				int out = 1;
				while(true){
					if(cnt == n-1)break;
					if(a[out] == 0){
						num++;
						if(num == s){
							a[out]++;
							cnt++;
							num = 0;
						}
					}
					out = (out + 1) % (n+1); 
				}
				for(int i = 1;i <= n;i++){
					if(a[i] == 0)System.out.println(i);
				}
			}
		}
	}
}

Measured memory_bytes: 17600
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int t[] = new int[10];
        t[0] = scan.nextInt();
        t[1] = scan.nextInt();
        t[2] = scan.nextInt();
        t[3] = scan.nextInt();
        t[4] = scan.nextInt();
        t[5] = scan.nextInt();
        t[6] = scan.nextInt();
        t[7] = scan.nextInt();
        t[8] = scan.nextInt();
        t[9] = scan.nextInt();
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 - i; j++) {
                if (t[j] < t[j + 1]) {
                    int temp = t[j];
                    t[j] = t[j + 1];
                    t[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < 3; i++) {
            System.out.println(t[i]);

        }
    }

}



Measured memory_bytes: 26216
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n=int(input())
k=n
s=""
while(k>0):
    t=k%26
    if t==0:
        t=26
        k-=26
    s+=chr(t+96)
    k//=26
print(s[::-1])


Measured memory_bytes: 61896