akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+50;
int n,a[N],b[N],nxt[N],j;bool f1[N],f2[N];
vector<pair<int,int> >ans;
int read(){
    int x=0,c;
    while(!isdigit(c=getchar()));
    while(isdigit(c))x=x*10+c-48,c=getchar();
    return x;
}
void solve(bool *f){
    for(int i=2,j=0;i<n;i++){
        while(j&&b[i]!=b[j+1])j=nxt[j];
        if(b[i]==b[j+1])j++;
        nxt[i]=j;
    }
    j=0;
    for(int i=1;i<n;i++){
        while(j&&a[i]!=b[j+1])j=nxt[j];
        if(a[i]==b[j+1])j++;
    }
    while(j)f[j]=1,j=nxt[j];f[0]=1;
}
int main(){
    n=read();
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=1;i<=n;i++)b[i]=read();
    for(int i=1;i<n;i++)a[i]^=a[i+1];
    for(int i=1;i<n;i++)b[i]^=b[i+1];
    solve(f1);
    reverse(a+1,a+n);reverse(b+1,b+n);
    solve(f2);
    reverse(a+1,a+n);reverse(b+1,b+n);
    for(int i=n;i;i--)a[i]^=a[i+1];
    for(int i=n;i;i--)b[i]^=b[i+1];
    if(f1[n-1])ans.push_back(make_pair(0,a[1]^b[1]));
    for(int i=1;i<n;i++)
        if(f1[n-i-1]&&f2[i-1]&&(a[n]^a[1])==(b[n-i]^b[n-i+1]))
            ans.push_back(make_pair(i,a[i+1]^b[1]));
    for(int i=0;i<ans.size();i++)printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}

Measured memory_bytes: 7920
namespace sample {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [ab, bc, ca]: number[] = (await sc.getLine())
      .split(' ')
      .map((x) => +x);
    console.log((ab * bc) / 2);
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7500
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
int main() {
    int h, w, k; scanf("%d%d%d", &h, &w, &k);
    bool result = false;
    repeat (y, h + 1) {
        repeat (x, w + 1) {
            if (y * w + x * h - 2 * y * x == k) {
                result = true;
            }
        }
    }
    printf("%s\n", result ? "Yes" : "No");
    return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1;

const ll INF = 1LL << 60;

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

// a^n mod を計算 再帰
ll modpow(ll a,ll n,ll &mod){
  if(!n) return 1;
  ll x = modpow(a,n/2,mod)%mod;
  x *=x;
  if(n%2==1)x*=a;
  return x%mod;
}

int main(){
  ll n,m;cin>>n>>m;
  vector<ll> hs(n),good(n,1);
  rep(i,n)cin>>hs[i];
  rep(i,m){
    int a,b;cin>>a>>b;
    if(hs[a-1]>hs[b-1])good[b-1]*=0;
    else if(hs[a-1]<hs[b-1])good[a-1]*=0;
    else {good[a-1]*=0;good[b-1]*=0;}
  }
  ll ans=0;
  rep(i,n)ans+=good[i];
  cout<<ans;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = 2000;

pair <char, int> v[2 * MAXN + 1];

int dp[2 * MAXN + 1][MAXN + 1];

int aib[2 * MAXN + 1];
int pos[2][MAXN + 1];
int n;

inline void update(int pos, int val) {
    for(int i = pos; i <= 2 * n; i += lsb(i))
        aib[i] += val;
}

inline int query(int pos) {
    int ans = 0;
    for(int i = pos; i > 0; i -= lsb(i))
        ans += aib[i];
    return ans;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= 2 * n; i++) {
        cin >> v[i].first >> v[i].second;
        if(v[i].first == 'B')
            pos[0][v[i].second] = i;
        else
            pos[1][v[i].second] = i;
    }
    for(int len = 1; len <= 2 * n; len++) {
        for(i = 1; i <= 2 * n; i++) {
            aib[i] = 0;
        }
        for(i = 1; i <= len; i++) {
            if(i <= n)
                update(pos[1][i], 1);
            else
                update(pos[0][i - n], 1);
            dp[len][i] = 1e9;
        }
        for(i = max(0, len - n); i <= min(len, n); i++) {
            int val = 1e9;
            if(i > 0) {
                val = dp[len - 1][i - 1] + pos[0][i] - len + query(2 * n) - query(pos[0][i]);
                if(i > len - n)
                    update(pos[0][i], 1);
            }
            if(i < len) {
                update(pos[1][len - i], -1);
                val = min(val, dp[len - 1][i] + pos[1][len - i] - len + query(2 * n) - query(pos[1][len - i]));
            }
            dp[len][i] = val;
        }
    }
    cout << dp[2 * n][n];
    //cin.close();
    //cout.close();
    return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int a,b;
  cin>>a>>b;

  if(a>=13)cout<<b<<endl;
  else if(a>=6)cout<<b/2<<endl;
  else cout<<0<<endl;
  

return 0;}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    return if b % a == 0 {
        (a + b).to_string()
    } else {
        (b - a).to_string()
    }
}


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


void solve () {
    int n, k;
    cin >> n >> k;
    vector<long long> pos, neg;
    pos.push_back(0);
    while(n--) {
        long long x;
        cin >> x;
        if (x >= 0) {
            pos.push_back(x);
        }
        else {
            neg.push_back(-1 * x);
        }
    }
    neg.push_back(0);
    reverse(neg.begin(), neg.end());
    long long ans = INT_MAX;
    for (int i = 0, j = k; i <= k; i++, j--) {
        if(i >= (int) neg.size() || j >= pos.size()) {
            continue;
        }
        if(neg[i] > pos[j]) {
            swap(neg[i], pos[j]);
        }
        ans = min(ans, (neg[i] * 2) + pos[j]);
    }
    cout <<  ans;

}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4452
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  vi v(26);
  char c;
  while((c = getchar()) != EOF){
    if(isupper(c)){
      c = tolower(c);
    }
    v[c-'a']++;
  }
  rep(i,26){
    cout << (char)(i+'a') << " : " << v[i] << endl;
  }
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    int c = 0;
    while(n--) {
        int x, y;
        cin >> x >> y;
        if(x == y)
            c++;
        else
            c = 0;
        if(c == 3) {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    string s,t;
    cin>>s>>t;

    int ans = 0;
    for(int i = 0;i < 3;i++) {
        if(s[i]==t[i])
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
int main() {
	int n; std::cin >> n;
	std::vector<int> terms(n); for (auto& t : terms) std::cin >> t;
	const auto min = *std::min_element(terms.begin(), terms.end());
	const auto sum = std::accumulate(terms.begin(), terms.end(), 0LL);
	if (n % 2 == 0) {
		if (min % 2 == 0 && sum % 2 == 0) {
			std::cout << "Second\n";
		}
		else {
			std::cout << "First\n";
		}
	}
	else {
		std::cout << ((sum % 2 == 0) ? "Second\n" : "First\n");
	}
}


Measured memory_bytes: 3556
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
      string[] input = Console.ReadLine().Split(' ');
      int n = int.Parse(input[0]);
      HashSet<string> hs = new HashSet<string>();
      for(int i = 0;i < n;i++) hs.Add(Console.ReadLine());
      Console.WriteLine(hs.Count);
	}
}

Measured memory_bytes: 47208
#include <stdio.h>
#include <limits.h>

int main(void) {
	int a,b,r,tmp;
	long long x;

	scanf("%d %d",&a,&b);
	x=(long long)a*b;
	
	if(a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	r = a%b;
	while(r) {
		a = b;
		b = r;
		r = a%b;
	}
	printf("%lld",x/b);

	return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
ans=[None]*n
while k>0:
  d=input()
  a=list(map(int,input().split()))
  #print (d,a)
  for i in a:
    ans[i-1]=d
  k-=1
count=0
for item in ans:
  if item==None:
    count+=1
print (count)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    /*char ch;
    cin >> ch;
    if(ch>='A'&&ch<='Z')
        cout << 'A' << endl;
    else
        cout << 'a' << endl;*/
    int a[10000];
    int n,k;
    cin >> n>> k;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout << ans << endl;

}


Measured memory_bytes: 3632
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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 , 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" ) } ; }

fn main() {
    input! {
        w: chars
    }

    let c = count(&w);
    let mut is_ok = true;
    for v in c.values() {
        if *v % 2 != 0 {
            is_ok = false;
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl a(n);
	cin>>a;
	sort(all(a));

	vector<pll> p(m);
	rep(i,m){
		ll q,w;cin>>q>>w;
		p[i].sc=q, p[i].fs=w;
	}
	sort(rall(p));
	int index=0;
	for(auto pp:p){
		ll c,b; tie(c,b)=pp;
		rep(i,b){
			if(a[index]<c){
				a[index]=c;
				index++;
				if(index==n)break;
			}else break;
		}
		if(index==n)break;
	}
	// puta(a);
	puta(sum(a));
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define int long long

signed main() {
	map<string, int> k;

	int n, c = 0;
	int ans = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	for (int i = 0; i < n; i++){

		k[s[i]]++;
	

	}
	for (auto hoge = k.begin(); hoge != k.end(); hoge++){
		ans += (hoge->second*(hoge->second-1))/2;

	}
	
	cout << ans << endl;
	/*int a[2];
	map<string, int> mp;
	mp["abc"]++;
	mp["ab"] = 5;
	mp["abc"]++;
	cout << mp["abc"] << endl;
	cout << mp["ab"] << endl;
	for (auto it = mp.begin(); it != mp.end();++it){
		cout << it->second << endl;
	}*/
	return 0;
}



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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "Trace On! (Line: " << __LINE__ << ")\n"; d_f(string(#args), args); } while(0)
	void d_f(__attribute__((unused)) string str) {}
	template<typename Head, typename... Tails> void d_f(string str, Head H, Tails... T) { cerr << "\t" << str.substr(0, str.find(", ")) << " <=> [" << H << "]\n"; d_f(str.substr(str.find(", ") + 2), T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	constexpr int MOD = 998244353;
	auto add = [](ll x, ll y) { return (x + y) % MOD; };
	auto sub = [](ll x, ll y) { auto res = (x - y) % MOD; if(res < 0) res += MOD; return res; };
	auto mul = [](ll x, ll y) { return (x * y) % MOD; };

	int n, s;
	cin >> n >> s;

	vector<int> arr(n);
	for(auto& i: arr) cin >> i;

	ll dp[n + 1][s + 1] = {};

	for(int i = 1; i <= n; ++i){
		++dp[i - 1][0];
		for(int j = 0; j <= s; ++j){
			dp[i][j] += dp[i - 1][j];
			if(arr[i - 1] <= j) dp[i][j] += dp[i - 1][j - arr[i - 1]];
			dp[i][j] %= MOD;
		}
	}

	#ifdef SANYAM1101
	cerr << "DP Table" << "\n";
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= s; ++j)
			cerr << dp[i][j] << " \n"[j == s];
	#endif

	ll ans = 0;

	for(int i = 1; i <= n; ++i)
		ans = add(ans, mul(sub(dp[i][s], dp[i - 1][s]), n - i + 1));

	cout << ans << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


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

int main(void){
    int h, w, a[510][510], b[510][510], n = 0;
    cin >> h >> w;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
            b[i][j] = a[i][j];
        }
    }
    
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j < w; j++) {
            if (a[i][j] % 2 != 0 && a[i][j + 1] % 2 != 0) {
                n++;
                a[i][j]--;
                a[i][j + 1]++;
            }
            if (a[i][j] % 2 != 0 && a[i][j + 1] % 2 == 0) {
                n++;
                a[i][j]--;
                a[i][j + 1]++;
            }
        }
    }
    for (int i = 1; i < h; i++) {
        if (a[i][w] % 2 != 0 && a[i + 1][w] % 2 != 0) {
            n++;
            a[i][w]--;
            a[i + 1][w]++;
        }
        if (a[i][w] % 2 != 0 && a[i + 1][w] % 2 == 0) {
            n++;
            a[i][w]--;
            a[i + 1][w]++;
        }
    }
    cout << n << endl;
    
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j < w; j++) {
            if (b[i][j] % 2 != 0 && b[i][j + 1] % 2 != 0) {
                b[i][j]--;
                b[i][j + 1]++;
                cout << i << " " << j << " " << i << " " << j + 1 << endl;
            }
            if (b[i][j] % 2 != 0 && b[i][j + 1] % 2 == 0) {
                b[i][j]--;
                b[i][j + 1]++;
                cout << i << " " << j << " " << i << " " << j + 1 << endl;
            }
        }
    }
    for (int i = 1; i < h; i++) {
        if (b[i][w] % 2 != 0 && b[i + 1][w] % 2 != 0) {
            b[i][w]--;
            b[i + 1][w]++;
            cout << i << " " << w << " " << i + 1 << " " << w << endl;
        }
        if (b[i][w] % 2 != 0 && b[i + 1][w] % 2 == 0) {
            b[i][w]--;
          b[i + 1][w]++;
            cout << i << " " << w << " " << i + 1 << " " << w << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
const int maxn=1000000+10;
int gcd[maxn],maxSum=0;
int GCD(int a,int b){
   if(b==0) return a;
   return GCD(b,a%b);
}
void slide(int x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
        {
           gcd[i]++;
           while(x%i==0) x/=i;
        }
    }
    if(x>1) gcd[x]++;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int gc=m;
    for(int i=2;i<=n;i++)
    {
        cin>>m;
        maxSum=max(maxSum,m);
        gc=GCD(gc,m);
        slide(m);
    }
    if(gc==1)
    {
        for(int i=2;i<=maxSum;i++)
        {
            if(gcd[i]>1)
            {
                cout<<"setwise coprime"<<endl;
                return 0;
            }
        }
        cout<<"pairwise coprime"<<endl;
                return 0;
    }
    cout<<"not coprime"<<endl;
    return 0;
}


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

n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

startWar = True
for Z in range(X+1, Y+1):
    warOccur = False
    if max(x) < Z:
        pass
    else:
        warOccur = True

    if Z <= min(y):
        pass
    else:
        warOccur = True

    if warOccur == True:
        continue
    else:
        startWar = False
        break

if startWar:
    print("War")
else:
    print("No War")


Measured memory_bytes: 3060
function main()
  
  N = parse(Int,readline())
  
  check = false
  
  for i in 1:9
    
    if N % i == 0 && 1 <= N / i <= 9
      
      check = true
      println("Yes")
      break
      
    end
    
  end
  
  if check == false
    println("No")
  end
  
end

main()

Measured memory_bytes: 112156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

ll solve(ll x, ll y) {
    if (x == 0 || y == 0) return 0;

    if (x < y && y % x == 0) return (y / x) * x * 2 - x;
    if (y < x && x % y == 0) return (x / y) * y * 2 - y;

    if (x < y){
        return solve(x, y - (y / x) * x) + (y / x) * x * 2;
    }
    else if (x > y){
        return solve(x - (x / y) * y, y) + (x / y) * y * 2;
    }
    else{
        return x;
    }
}

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N, X;
    cin >> N >> X;
    ll ans = solve(X, N - X) + N;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
A = [[0] * (n+2) for i in range(n+2)]

for i in range(m):
    l, r = map(int, input().split())
    A[l][r] += 1

for i in range(n+1):
    for j in range(n+1):
        A[i][j+1] += A[i][j]
        A[i+1][j] += A[i][j]
        A[i+1][j+1] -= A[i][j]

B = []
for i in range(q):
    p, q = map(int, input().split())
    B.append(A[q][q] - A[q][p-1] - A[p-1][q] + A[p-1][p-1])
    
for b in B:
    print(b)

Measured memory_bytes: 17608
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int h, w;
char c[1005][1005];
ll ans = 0;
ll dp[1005][1005];

int main() {
    cin >> h >> w;
    rep(i, h)rep(j, w) cin >> c[i][j];
    rep(i, h)rep(j, w) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i, h) c[i][w] = '#';
    rep(j, w) c[h][j] = '#';
    rep(i, h)rep(j, w){
        if(i==h-1 and j==w-1) break;
        
        if (c[i+1][j]=='.'){
            dp[i+1][j] = (dp[i+1][j] +  dp[i][j]) % mod;
        }

        if (c[i][j+1]=='.'){
            dp[i][j+1] = (dp[i][j+1] +  dp[i][j]) % mod;
        }
    }

    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ans=n;
	int v,t=1;
	for(int i=1;i<=n;i++)
	{
		cin>>v;
		if(v==t)
			ans--,t++;
	}
	if(ans==n)
		ans=-1;
	cout<<ans;
} 

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

int64_t lyuka(int N) {
  int64_t ln, ln1, ln2;
  
  if (N == 0) {
    ln = 2;
  }
  else if (N == 1) {
    ln = 1;
  }
  else if (N > 1) {
    ln1 = 1;
    ln2 = 2;
    for (int i=2; i < N+1; i++) {
      ln = ln1 + ln2;
      ln2 = ln1;
      ln1 = ln;
    }
  }
  
  return ln;
}

int main() {
  int N;
  cin >> N;
  
  cout << lyuka(N) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n = int(input())
card =[[c for c in input().rstrip().split()] for i in range(n)]
card = [c[0] + c[1] for c in card]
picture = ("S", "H", "C", "D")
numeric = tuple(str(num) for num in range(1, 14))
for c in picture:
    for num in numeric:
        if c + num not in card:
            print("{0} {1}".format(c, num))
            


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

int main() {
  int N, A;
  cin >> N >> A;
  int ans =0;
  ans =A - (N % 500);
  if (ans >= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
info = [int(s) for s in input().split(' ')]
A = info[0]
B = info[1]
C = info[2]
D = info[3]

def atack(T,A):
    T[0] = T[0] - A[1]
    return T,A

takahasi = [A,B,'t']
aoki = [C,D,'a']
result = 0
while True:
    aoki,takahasi = atack(aoki,takahasi)
    if aoki[0] <= 0:
        result = 1
        break

    takahasi,aoki = atack(takahasi,aoki)
    if takahasi[0] <= 0:
        result = -1
        break

if result == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+10;
const int mod=1e9+7;

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int n,fac[N],ifac[N],f[N],nf[N],siz[N],g[N],mn=1e9;
vector<int> E[N];

void dfs(int u,int fa) {
	siz[u]=1;
	for(auto v:E[u])
		if(v^fa) {
			dfs(v,u),siz[u]+=siz[v];
			g[u]=max(g[u],siz[v]);
		}
	g[u]=max(g[u],n-siz[u]);
	mn=min(mn,g[u]);
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<n;i++) cin>>u>>v,E[u].push_back(v),E[v].push_back(u);
	fac[0]=1;for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);
	for(int i=n;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
	dfs(1,0);
	int x=0,y=0;
	for(int i=1;i<=n;i++)
		if(g[i]==mn) (x?y:x)=i;
	if(y) cout<<1ll*fac[n/2]*fac[n/2]%mod;
	else {
		f[0]=1;int sum=0,ans=0;
		for(auto u:E[x]) {
			dfs(u,x);memset(nf,0,sizeof(nf));
			for(int i=0;i<=sum;i++)
				for(int j=0;j<=siz[u];j++)
					nf[i+j]=(nf[i+j]+1ll*f[i]*fac[siz[u]]%mod*fac[siz[u]]%mod*ifac[j]%mod*ifac[siz[u]-j]%mod*ifac[siz[u]-j])%mod;
			swap(f,nf);sum+=siz[u];
		}
		for(int i=0;i<n;i++) ans=(ans+1ll*f[i]*((i&1)?mod-1:1)%mod*fac[n-i])%mod;
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define int long long
// int MOD = 2147483647LL;
int MOD = 2305266692540551LL;
int BASE = 4001;
signed main() {
  ios::sync_with_stdio(false);
  string S, T; cin >> S >> T;
  if(S.size() < T.size()) swap(S, T);
  vector<vector<int>> u(T.size() + 1);
  int alpha[26];
  alpha[0] = 1;
  for(int i = 1; i < 26; ++i) {
    alpha[i] = (alpha[i - 1] * BASE) % MOD;
  }
  for(int l = 1; l <= (int)T.size(); ++l) {
    int hash = 0;
    REP(i,l) {
      hash += alpha[T[i] - 'a'];
      hash %= MOD;
    }
    u[l].push_back(hash);
    // cerr << T.substr(0, l) << " => " << hash << endl;
    for(int i = 1; i < (int)T.size() - l + 1; ++i) {
      hash -= alpha[T[i - 1] - 'a'];
      if(hash < 0) hash += MOD;
      hash += alpha[T[i - 1 + l] - 'a'];
      hash %= MOD;
      u[l].push_back(hash);
      // cerr << T.substr(i, l) << " => " << hash << endl;
    }
    sort(u[l].begin(), u[l].end());
  }
  for(int l = (int)T.size(); l >= 1; --l) {
    int hash = 0;
    REP(i,l) {
      hash += alpha[S[i] - 'a'];
      hash %= MOD;
    }
    if(binary_search(u[l].begin(), u[l].end(), hash)) {
      cout << l << endl;
      return 0;
    }
    // cerr << S.substr(0, l) << " => " << hash << endl;
    for(int i = 1; i < (int)S.size() - l + 1; ++i) {
      hash -= alpha[S[i - 1] - 'a'];
      if(hash < 0) hash += MOD;
      hash += alpha[S[i - 1 + l] - 'a'];
      hash %= MOD;
      // cerr << S.substr(i, l) << " => " << hash << endl;
      if(binary_search(u[l].begin(), u[l].end(), hash)) {
        cout << l << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 77080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A._753
{
    class Program
    {
        static void Main(string[] args)
        {
            int years = int.Parse(Console.ReadLine());

            switch (years)
            {
                case 7:
                case 5:
                case 3:
                    Console.WriteLine("YES");
                    break;
                default:
                    Console.WriteLine("NO");
                    break;
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <queue>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	priority_queue<int> pq;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		pq.push(a);
	}
	while (m) {
		int t = pq.top(); pq.pop();
		pq.push(t / 2);
		m--;
	}
	long long ans = 0;
	while (!pq.empty()) {
		ans += pq.top(); pq.pop();
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
ll getFact(ll n){
	ll ans = 1;
	for (int i = 1; i <= n; ++i)
	{
		ans = ans * i;
		ans = ans % mod;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	ll n,m;
	cin>>n>>m;
	if(abs(n-m) > 1)
	{
		cout<<0<<endl;
	}
	else if(n == m){
		cout<<(2*getFact(m)*getFact(n))%mod<<endl;
	}
	else{
		cout<<(getFact(m)*getFact(n))%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int N, M;
	cin >> N >> M;
	map<int, int> A;
	for(int cnt = 0; cnt < N; ++cnt){
		int K;
		cin >> K;
		for(int index = 0; index < K; ++index){
			int a;
			cin >> a;
			A[a] += 1;
		}
	}

	int result = 0;
	for(auto itr = A.begin(); itr != A.end(); ++itr){
		if (itr->second == N){
			++result;
		}
	}
	cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for i in range(m):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)

Measured memory_bytes: 18736
n,t = list(map(int,input().split()))
a = [input() for i in range(n)]
cost = 1001
x = 0

for i in range(n):
  b = list(map(int,a[i].split()))
  if t >= b[1] and cost >= b[0]: 
    cost = b[0]
    
if cost == 1001:
  print("TLE")
else:
  print(cost)

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int N;
	N = A+B+1;
	
	char S[N];
	scanf("%s", &S);
	
	int y = 0;
	for(int i = 0; i < N; i++){
		if(i!=A){
		if(S[i] >= '0' && S[i] <= '9'){
			y+=1;
		}
		}else if (S[i] == '-'){
			y+=1;
		}
	}
	
	if(y == A + B + 1){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main(void) {
  int i, a, b, c, d, sum, k;

  scanf("%d %d %d", &a, &b, &c);
  
  scanf("%d", &k);
  
  sum = a + b + c;
  d = a < b ? (b < c ? c : b) : (a < c ? c : a);
  for (i = 0; i < k; i++) {
    sum += d;
    d *= 2;
  }
  
  printf("%d", sum);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;

vector<int> dx, dy, dz;

int n, m, t;
int b[7][7][7];

bool in(int x, int y, int z) {
	return 0 <= x && x < n && 0 <= y && y < n && 0 <= z && z < n;
}

int check() {
	for(int x = 0; x < n; x++) {
		for(int y = 0; y < n; y++) {
			for(int z = 0; z < n; z++) {
				for(int i = 0; i < dx.size(); i++) {
					int nx = x, ny = y, nz = z;
					int sum = 0;
					for(int j = 0; j < m; j++) {
						if(!in(nx, ny, nz)) break;
						sum += b[nx][ny][nz];
						nx += dx[i], ny += dy[i], nz += dz[i];
					}
					if(sum == m) {
						return 1;
					}
					if(sum == -m) {
						return -1;
					}
				}
			}
		}
	}
	return 0;
}

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

	for(int x = -1; x <= 1; x++) {
		for(int y = -1; y <= 1; y++) {
			for(int z = -1; z <= 1; z++) {
				if(x != 0 || y != 0 || z != 0) {
					dx.push_back(x);
					dy.push_back(y);
					dz.push_back(z);
				}
			}
		}
	}

	while(cin >> n >> m >> t, n | m | t) {
		memset(b, 0, sizeof b);
		int res = 0;
		int x[344], y[344];
		for(int i = 1; i <= t; i++) {
			cin >> x[i] >> y[i];
			x[i]--, y[i]--;
		}
		for(int i = 1; i <= t; i++) {
			int z = 0;
			while(b[x[i]][y[i]][z] != 0) z++;
			if(i % 2 == 1) b[x[i]][y[i]][z] = 1;
			else b[x[i]][y[i]][z] = -1;
			res = check();
			if(res == 1) {
				cout << "Black " << i << endl;
				break;
			}
			if(res == -1) {
				cout << "White " << i << endl;
				break;
			}
		}
		if(res == 0) {
			cout << "Draw" << endl;
		}
	}
}

Measured memory_bytes: 3028
import java.util.Scanner;

public class Main {
    static final char NULL = '\0';

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n != 0) {
            char[] input = sc.next().toCharArray();
            StringBuilder out = new StringBuilder();
            char buf = NULL;
            for (int i = 0; i < input.length; i++) {
                switch (input[i]) {
                case '1':
                    if (buf != NULL && buf != ' ') {
                        switch (buf) {
                        case '.':
                            buf = ',';
                            break;
                        case ',':
                            buf = '!';
                            break;
                        case '!':
                            buf = '?';
                            break;
                        case '?':
                            buf = ' ';
                            break;
                        }
                    } else
                        buf = '.';
                    break;
                case '2':
                    if (buf != NULL && buf != 'c') {
                        buf += 1;
                    } else
                        buf = 'a';
                    break;
                case '3':
                    if (buf != NULL && buf != 'f') {
                        buf += 1;
                    } else
                        buf = 'd';
                    break;
                case '4':
                    if (buf != NULL && buf != 'i') {
                        buf += 1;
                    } else
                        buf = 'g';
                    break;
                case '5':
                    if (buf != NULL && buf != 'l') {
                        buf += 1;
                    } else
                        buf = 'j';
                    break;
                case '6':
                    if (buf != NULL && buf != 'o') {
                        buf += 1;
                    } else
                        buf = 'm';
                    break;
                case '7':
                    if (buf != NULL && buf != 's') {
                        buf += 1;
                    } else
                        buf = 'p';
                    break;
                case '8':
                    if (buf != NULL && buf != 'v') {
                        buf += 1;
                    } else
                        buf = 't';
                    break;
                case '9':
                    if (buf != NULL && buf != 'z') {
                        buf += 1;
                    } else
                        buf = 'w';
                    break;
                case '0':
                    if (buf != NULL) {
                        out.append(buf);
                        buf = NULL;
                    }
                    break;
                }
            }
            System.out.println(out.toString());
            n--;
        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
bool chk(int num, int i) {
    return num>>i&1;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,kk;
    cin>>h>>w>>kk;
    vector<string> s(h);
    rep(i,h) {
        cin>>s[i];
    }
    int sep = 0;
    vector<ll> count, col;
    int res = h+w-2;
    rep(i,1<<(h-1)) {
        bool flg = false;
        int sep_count = 0;
        int row_sep = __builtin_popcount(i);
        count.clear();
        col.clear();
        count.assign(row_sep+1,0);
        col.assign(row_sep+1,0);
        rep(j,w) {
            ll cur = 0;
            rep(ii,row_sep+1) {
                col[ii]=0;
            }
            bool flg2 = true;
            rep(k,h) {
                col[cur] += int(s[k][j]=='1'); 
                if (col[cur]>kk) {
                    flg = true;
                    break;
                }
                if (count[cur]+col[cur]>kk) {
                    sep_count+= flg2;
                    flg2 = false;
                    rep(ii,row_sep+1) {
                        count[ii]=0;
                    }

                }
                if (chk(i, k)) {
                    cur++;
                }

            }
            if (flg) {break;}
            rep(ii,row_sep+1) {
                count[ii]+=col[ii];
            }
        }
        if (flg) {continue;}
        chmin(res,row_sep+sep_count);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const int MAX = 3000000;

// fac: 階乗, finv: 階乗の逆元, inv: 逆元
ll fac[MAX], finv[MAX], inv[MAX];

void cominit(){
    fac[0] = fac[1] = 1LL;
    finv[0] = finv[1] = 1LL;
    inv[1] = 1LL;

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

ll com(ll n, ll k){
    if (n<k) return 0LL;
    if (n<0 or k<0) return 0LL;
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    int x, y;
    cominit();
    cin >> x >> y;
    if ((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    ll n = (ll)(2*y-x)/3;
    ll m = (ll)(2*x-y)/3;

    if (n<0 or m<0){
        cout << 0 << endl;
        return 0;
    }
    cout << com(n+m, n) << endl;

    return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(ll i = 0; i < n; i++) cin >> h[i];
    ll ans = 0;
    ll temp = 0;
    for(ll i = 0; i < n; i++){
        if(i == n - 1){
            ans = max(ans, temp);
        }else if(h[i] >= h[i + 1]) temp++;
        else{
            ans = max(ans, temp);
            temp = 0;
        }
    }

    cout << ans << endl;

    
}


Measured memory_bytes: 1024
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a,b,c,d = na()

while a > 0 and c > 0:
  a = a-d
  c = c-b
if c <= 0 and a <= 0:
  print("Yes")
elif c <= 0 and a > 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
n,q=map(int,input().split())
s=input()
hantei=[0]
for i in range(1,len(s)):
  if s[i-1]=="A" and s[i]=="C":
    hantei.append(hantei[i-1]+1)
  else:
    hantei.append(hantei[i-1])
#print(hantei)
#ここまではあってる

for i in range(q):
  l,r=map(int,input().split())
  print(hantei[r-1]-hantei[l-1])
    

Measured memory_bytes: 6076
N, K = [int(i) for i in input().split()]
V = [int(i) for i in input().split()]

M = min(N, K)
ma = 0
for l in range(M + 1):
    for r in range(M - l + 1):
        G = V[:l] + V[N - r:]
        G.sort()
        for i in range(K - l - r + 1):
            ma = max(ma, sum(G[i:]))
print(ma)

Measured memory_bytes: 3064
from math import cos,radians,sqrt

def calcAngle(h,m): 
        if (h == 12): 
            h = 0
        if (m == 60): 
            m = 0
        hour_angle = 0.5 * (h * 60 + m) 
        minute_angle = 6 * m 
        angle = abs(hour_angle - minute_angle)  
        angle = min(360 - angle, angle)  
        return angle

def main():
    a,b,h,m=map(int,input().split())
    ang=calcAngle(h,m)
    dist=sqrt(abs(a*a+b*b-2*a*b*cos(radians(ang))))
    print(dist)

main()

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if((c == 'a') ||(c == 'i') ||(c == 'u') ||(c == 'e') ||(c == 'o')){
    cout << "vowel";
  }
  else{
    cout << "consonant";
  }
}

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

int main() {
    int i=0,x,m,n=0;
    cin>>x>>m;
    x=x-1;
    int j=m;
    int s=(2*x)-1;
    int h[s];
    for(i=0;i<x;i++){
        j--;
        h[n]=j;
        n++;
    }
    j=m;
    h[n]=j;
    n++;
    for(i=0;i<x;i++){
        j++;
        h[n]=j;
        n++;
    }
    int k=n;
    sort(h,h+k);
    for(i=0;i<n;i++)
        cout<<h[i]<<" " ;
    return 0;
}
 

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

int main(void)
{
	vector<string> S(3);
	for(int i=0; i<3; i++)
		cin >> S[i];

	string ret("");
	for(int i=0; i<3; i++)
		ret += S[i].front();

	cout << ret << endl;

	return 0;
}


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

int main(void){
    int X,A,B,N;
    double Adot;
    scanf("%d",&X);

    
    for(B=-120;B<120;B++){
        for(A=-120;A<120;A++){
            if(pow(A,5.0)-pow(B,5.0)==X){
                goto out;
            }

        }
        // N=X+pow(B,5.0);
        // Adot=pow(N,0.2);
        // A=Adot;
        // if(ceil(Adot)==floor(Adot)){
        //     printf("%d %d",A,B);
        //     break;
        
    }
out:
    printf("%d %d",A,B);
    return 0;


}

Measured memory_bytes: 2560
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      x.begin(),x.end()
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,a,b,t);
  putv(t/a*b);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")


using namespace std;
using ll = long long;

int main(){
    int N;cin >> N;
    string s;cin >> s;
    string ans;
    for(auto a : s){
        int w = a - 'A';
        ans.push_back((w + N)%26 + 'A');
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256