akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl S(N);
  REP(i, N) cin >> S[i];
  if (N <= 2) {
    cout << 1 << endl;
    return 0;
  }
  ll state = 0;
  if (S[0] > S[1])
    state = 1;
  ll ans = 1;
  FOR(i, 2, N) {
    if (S[i - 1] > S[i] && state == 0) {
      state = -1;
      ans++;
    } else if (S[i - 1] < S[i] && state == 1) {
      state = -1;
      ans++;
    } else if (state == -1) {
      if (S[i - 1] < S[i])
        state = 0;
      else if (S[i - 1] > S[i])
        state = 1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int INF = 1001001001;



int main(){
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<ll>> dist(n, vector<ll>(n, INF));
    rep(i, n) dist[i][i] = 0;

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist[i][j], dist[i][k]+dist[k][j]);
    }    
    
    vector<vector<ll>> dist2(n, vector<ll>(n, INF));
    rep(i, n) dist2[i][i] = 0;

    rep(i, n) rep(j, n) {
        if (dist[i][j]<=l) dist2[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        chmin(dist2[i][j], dist2[i][k]+dist2[k][j]);
    }
    ll q;
    cin >> q;

    rep(i, q) {
        ll s, t;
        cin >> s >> t;
        s--; t--;
        ll ans = dist2[s][t] - 1;
        if (ans+1==INF) {
            cout << "-1" << endl;
            continue;
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1920
#include<cstdio>

int n, m;
int h[100005];
bool g[100005];

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &h[i]);
    g[i] = true;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (h[a] <= h[b]) {
      g[a] = false;
    }
    if (h[a] >= h[b]) {
      g[b] = false;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (g[i]) {
      ++ans;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2220
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
using namespace std;
template<typename T>inline void read(T &x){
    T s=0,f=1;char k=getchar();
    while(!isdigit(k)&&k^'-')k=getchar();
    if(!isdigit(k)){f=-1;k=getchar();}
    while(isdigit(k)){s=s*10+(k^48);k=getchar();}
    x=s*f;
}
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
const int MAXN=1e6+7;
static int n,a[MAXN];
inline void init()
{
    read(n);
    Rep(i,1,n)read(a[i]);
    sort(a+1,a+n+1);
}
inline void solve()
{
    static int ans=0;
    Repe(i,n,1)ans+=a[i]*(((n-i)&1)?-1:1);
    cout<<ans<<endl;
}
int main(void){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    input(a,n);
    list<lint>l;
    rep(i,n){
        if(i%2==0)l.push_back(a[i]);
        else l.push_front(a[i]);
    }
    if(n%2==1)reverse(all(l));
    output(l);
}

Measured memory_bytes: 9984
#include <iostream>

using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
    ll n, m, i, dp[500001]={0, 0, 1}, f[500001], dap=1;
    cin>>n>>m;
    
    for(i=3;i<=n;i++)
    {
        dp[i]=(i-1)*(dp[i-1]+dp[i-2]);
        dp[i]%=mod;
    }
    for(i=m;i>(m-n);i--)
        {
            dap*=i;
            dap%=mod;
        }
    
    
    if(m==n)
    {
        dap*=dp[n];
        dap%=mod;
        
    }

    else
    {
        
        f[1]=m-n;
        f[2]=(m-n)*(m-n)+(m-n+1);
        f[2]%=mod;
        for(i=3;i<=n;i++)
        {
            f[i]=(m-n)*(f[i-1])+(i-1)*(f[i-2]+f[i-1]);
            f[i]%=mod;
        }
        
        
        
        dap*=f[n];
        dap%=mod;
        
    }
    cout<<dap;
    return 0;
}

Measured memory_bytes: 10860
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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 nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    struct edge{ll to,cost;};
    vector<edge> es[100005];
    ll a,b,c;
    rep(i,M){
        cin >> a >> b >> c;
        a--;b--;
        es[a].push_back({b,c});
        es[b].push_back({a,c});
    }
    rep(i,N - 1){
        es[i + 1].push_back({i,0});
    }
    vector<ll> dist(N,INF);
    dist[0] = 0;
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0,0));
    while(que.size()){
        P p = que.top();que.pop();
        if(dist[p.second] < p.first)continue;
        for(auto e : es[p.second]){
            if(dist[e.to] > dist[p.second] + e.cost){
                dist[e.to] = dist[p.second] + e.cost;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
    if(dist[N - 1] != INF)cout << dist[N - 1] << endl;
    else cout << "-1\n";
    //vecout(dist);
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll H, A;
    cin >> H >> A;
    _PR(H%A==0?H/A:H/A+1);

    return 0;
}

/*



*/

Measured memory_bytes: 256
N = int(raw_input())
taro_point = 0
hanako_point = 0
for n in range(N):
  str_card = raw_input().split()
  if str_card[0] > str_card[1]:
    taro_point += 3
  elif str_card[0] < str_card[1]:
    hanako_point += 3
  else:
    taro_point += 1
    hanako_point += 1
print '%d %d' % (taro_point, hanako_point)

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

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

    int n,m; string ans="YES";
    cin>>n; Int d[n]={};
    for (int i = 0; i < n; i++)cin>>d[i];
    sort(d,d+n);
    cin>>m; Int t[m]={};
    for (int i = 0; i < m; i++)cin>>t[i];
    sort(t,t+m);
    int j=0;
    for (int i = 0; i < m; i++){
        if(j>=n){
            ans="NO";
            break;
        }else if(t[i]>d[j]){
            j++;
            i--;
        }else if(t[i]<d[j]){
            ans="NO";
            break;
        }else j++;
    }
    cout<<ans<<'\n';
}

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

int main() {
    string S;
    cin >> S;

    if(S.find('A') == string::npos || S.find('B') == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" <<endl;
    }

    return 0;
}

Measured memory_bytes: 384
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll combination(ll n,ll r){
    ll sum=1;
    rrep(i,min(r,n-r)) (sum*=(n-i+1))%=mod;
    return sum;
}

//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,a,b,up=0,abro=0;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    
    rep(i,s.size()){
        if(s[i]=='a'){
            if(up<a+b) {
                cout<<"Yes"<<endl;
                up++;
            }
            else cout<<"No"<<endl;
        }else if(s[i]=='b'){
            if(up<a+b && abro<b){
                cout<<"Yes"<<endl;
                up++;
                abro++;
            }
            else cout<<"No"<<endl;
        }else cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 848
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>

int main(void) {
	std::string s;

	std::cin >> s;

	std::cout << std::count(s.begin(), s.end(), '2') << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


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

	string str;
	int sharp = 0;
	for (int i = 0; i < h; i++) {
		cin >> str;

		for (auto& i : str) {
			if (i == '#')sharp++;
		}
	}

	if (sharp == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

	return 0;

}




Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        h1: i64, m1: i64, h2: i64, m2: i64, k: i64,
    }
    let ans = std::cmp::max((h2 * 60 + m2) - (h1 * 60 + m1) - k, 0);
    println!("{}", ans);
}


Measured memory_bytes: 2160
N= int(input())
A  = list(map(int,input().split()))
B  = list(map(int,input().split()))
short = []
margine = []
for a,b in zip(A,B):
    if a > b :
        margine.append(a-b)
    elif b > a:
        short.append(b-a)
        
ss = sum(short)
sc = len(short)
margine = sorted(margine)
if ss>sum(margine):
    print(-1)
    exit()
while ss>0:
    ss -= margine.pop()
    sc += 1
print(sc)



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    ll cnt = 0;
    rep2(i, 1, N) {
        if (S[i] == S[i - 1]) cnt++;
    }
    cout << min(N - 1, cnt + 2 * K) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 512
inputlist = list(map(int, input().split()))
obsnum = inputlist[0]
roadnum = inputlist[1]
obshigh = list(map(int, input().split()))
obslist = [0] * obsnum
for i in range(roadnum):
    pair_obs = list(map(int, input().split()))
    if obshigh[pair_obs[0] - 1] == obshigh[pair_obs[1] - 1]:
        obslist[pair_obs[0] - 1] = 1
        obslist[pair_obs[1] - 1] = 1
    elif obshigh[pair_obs[1] - 1] < obshigh[pair_obs[0] - 1]:
        obslist[pair_obs[1] - 1] = 1
    else:
        obslist[pair_obs[0] - 1] = 1
print(obslist.count(0))

Measured memory_bytes: 20048
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b>>c;
if(a==b)cout<<c<<endl;
else if(a==c)cout<<b<<endl;
else cout<<a<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n - 1) / max(h, w) + 1 << "\n";
    return 0;
}

Measured memory_bytes: 256
import sys
class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
 
    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
 
 
if __name__ == '__main__':
    sys.setrecursionlimit(1000000)
    n,m=map(int,sys.stdin.readline().split())
    ins = UnionFind(n+1)
    for i in range(m):
        a,b= map(int, sys.stdin.readline().split())
        ins.union(a,b)
    """
    ins.union(0, 1)
    ins.union(2, 3)
    print(ins.find(0, 3))  # False
    ins.union(1, 2)
    print(ins.find(0, 3))  # True
    """
    cnt=[0 for i in range(n+1)]
    for i in range(1,n+1):
        cnt[ins._root(i)]+=1
    print(max(cnt))

Measured memory_bytes: 83972
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  string s;
  cin >> s;
  bool a = false, b = false;
  for (char c : s) {
    if (c == 'C') a = true;
    if (c == 'F' && a) b = true;
  }
  cout << (b ? "Yes" : "No") << endl;

#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

/**
 *
 * @author joeco
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        String s  = in.next();
        String t  = in.next();
        
        
        int res = t.length()-overlaps(s, t);
        System.out.println(res);
        
    }
    
    public static int overlaps(String s, String t) {
        int res = 0;
        for(int i = 0; i < t.length(); i++) {
            if(t.charAt(i)==(s.charAt(i))) res++;
        }
        
        int res2 = 0;
        if(t.length() <= s.length()-1) res2=overlaps(s.substring(1), t);
        
        return Math.max(res, res2);
    }
}

Measured memory_bytes: 36188
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W, h, w = map(int, read().split())

def f(H, W, h, w):
    if H % h == 0 and W % w == 0:
        print('No')
        return
    K = 100_000_000
    base = np.zeros((h, w), np.int64)
    base[0, 0] = K
    base[-1, -1] = -(K + 1)
    A = np.tile(base, ((H + h) // h, (W + w) // w))[:H, :W]
    print('Yes')
    for row in A:
        print(' '.join(map(str, row.tolist())))

f(H, W, h, w)

Measured memory_bytes: 38476
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll n, k;
	scanf("%ld %ld", &n, &k);
	if(k==0){
		printf("%ld\n", n*n);
		return 0;
	}
	ll ans = 0;
	rep(i, k+1, n+1){
		ans += n/i * (i-k) + std::max(0l, n%i-k+1);
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 256
[N,K]=[int(item)for item in input().split()]
p = [int(item) for item in input().split()]
su = sum(p[0:K])
maxsu=su
ind=0
for i in range(0, N-K):
    su=su - p[i] + p[i + K ]
    if su > maxsu:
        ind = i+1
        maxsu=su
#print("{},{}".format(su,maxsu))
#print(p[ind:ind+K])
#print([n*(n+1)/(2*n) for n in p[ind:ind+K]])
print(sum([n*(n+1)/(2*n) for n in p[ind:ind+K]]))

Measured memory_bytes: 25188
N, T = map(int, input().split())
p = []
for i in range(N):
    A, B = map(int, input().split())
    p.append([A, B])
p.sort()

dp = [[0]*3005 for _ in range(3005)]
ans = 0
for i in range(N):
    for j in range(T):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        nextj = j + p[i][0]
        if nextj < T:
            dp[i+1][nextj] = max(dp[i+1][nextj], dp[i][j] + p[i][1])
    now = dp[i][T-1] + p[i][1]
    ans = max(ans, now)

print(ans)


Measured memory_bytes: 117848
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int X;
    in(X);

    if (X >= 30)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }

    return 0;
}

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

int ic(const void *a,const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    char sa[200001],sb[200001];
    scanf("%s %s",sa,sb);
    int sl = strlen(sa);
    char ba = sa[0];
    char bb = sb[0];
    int ca  =0,cb = 0;
    for(int i = 0;i < sl;i++){
        if(sa[i] != ba){ba = sa[i];ca++;}
        if(sb[i] != bb){bb = sb[i];cb++;}
        if(ca != cb){
            puts("No");
            return 0;
        }
    }
    int cara[UCHAR_MAX],carb[UCHAR_MAX];
    for(int i = 0;i < UCHAR_MAX;i++){
        cara[i] = 0;
        carb[i] = 0;
    }
    for(int i = 0;i < sl;i++){
        cara[(unsigned char)sa[i]]++;
        carb[(unsigned char)sb[i]]++;
    }
    qsort(cara,UCHAR_MAX,sizeof(int),ic);
    qsort(carb,UCHAR_MAX,sizeof(int),ic);
    for(int i = 0;i < UCHAR_MAX;i++){
        if(cara[i] != carb[i]){
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  if(k%n==0 || k%m==0) {
    cout << "Yes" << endl;
    return 0;
  }

  for(int i = 1; i < n; ++i) {
    for(int j = 1; j < m; ++j) {
      if(n*m - (i*j + (n-i)*(m-j)) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n; cin >> n;
  set<int> st;
  rep(i,n){
    int tmp; cin >> tmp;
    st.insert(tmp);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


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


def read_str_list():
    return input().split()


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


def read_str():
    return input()


def main():
    N = read_int()
    s = []
    for i in range(N):
      S = read_str()
      s.append(S)
    s.sort()
    s.append('')

    res = []
    M = -1
    m = 1
    for i in range(1, N+1):
      if s[i-1] == s[i]:
        m += 1
      else:
        if m == M:
          res.append(s[i-1])
        if m > M:
          M = m
          res = [s[i-1]]
        m = 1
    print(*res, sep='\n')


main()


Measured memory_bytes: 24424
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  string s;
  cin >> n >> s;
  if(n%2==1){
    cout <<"No\n";
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+n/2]){
      cout <<"No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int gakuseki;
	double tai, sin, bmi;
	
	while (scanf("%d,%lf,%lf", &gakuseki, &tai, &sin) != EOF){
		bmi = tai / (sin * sin);
		if (bmi >= 25) {
			printf("%d\n", gakuseki);
		}
	}
	
	return (0);
}	

Measured memory_bytes: 628
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,answer;
        String op;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			a  = scanner.nextInt();
			op = scanner.next();
			b  = scanner.nextInt();
			
			if(op.equals("+")){
				System.out.println(a+b);
			}
			else if(op.equals("-")){
				System.out.println(a-b);
			}
			else if(op.equals("*")){
				System.out.println(a*b);
			}
			else if(op.equals("/")){
				System.out.println(a/b);
			}
			else{
				break;
			}
		}
    	scanner.close();
    }
}

Measured memory_bytes: 25968
#include<iostream>
using namespace std;
int main (void)
{
  long long int a[200001],b[200001],k,sum1=0,sum2=0;
  int n,m,i,j,ans=0;
  
  cin>>n>>m>>k;
  a[0]=0,b[0]=0;
  for(i=1;i<=n;i++){cin>>a[i];}
  for(i=1;i<=m;i++){cin>>b[i];sum2+=b[i];}
  j=m;
  
  for(i=0;i<=n;i++)
  {
    sum1+=a[i];
    if(sum1>k)break;
    while(sum1+sum2>k)
    {
      sum2=sum2-b[j];
      j--;
    }
    
    if(i+j>ans){ans=i+j;}
  }
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 6728
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]

ans = 0
for i in range(N) :
    calc = C
    for j in range(M) :
        calc += A[i][j]*B[j]
    if calc > 0 :
        ans +=1
print(ans)


Measured memory_bytes: 3060
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.trim().split_whitespace();
    let mut t: Vec<usize> = Vec::with_capacity(n);
    for _ in 0..n {
        let e: usize = ws.next().unwrap().parse().unwrap();
        t.push(e)
    }

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let m: usize = s.trim().parse().unwrap();

    for _ in 0..m {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut ws = s.trim().split_whitespace();
        let p: usize = ws.next().unwrap().parse().unwrap();
        let x: usize = ws.next().unwrap().parse().unwrap();

        let mut a: usize = 0;
        for i in 0..n {
            a += if p == i + 1 {x} else {t[i]};
        }
        println!("{}", a);
    }
}



Measured memory_bytes: 4352
/*
    Author:DurJoy
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int Maxn = 235 + 10;
int ans = 0 , cnt  = 0;
int a[Maxn];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n , m ;
    cin >> n >> m;
    vector<int>v(n);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        if(v[i] >= m){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
number = 1000000007
fib = [1,1,2,3,5,8,13]
def fibon(n):
  if(n+1> len(fib)):
    while(len(fib) < n+1):
      fib.append(fib[-1]+ fib[-2])
  return fib[n]
n,m = map(int,input().split())
start = 0
ans = 1
for i in range(m):
  broken = int(input())
  if broken - start == 0:
    print(0)
    exit(0)
  ans *= fibon(broken-start-1)
  ans = ans % number
  start = broken + 1
else:
  ans *= fibon(n-start)
  ans = ans % number
print(ans)

Measured memory_bytes: 460020
float x[100],y[100],t,u,b;n,i,j,k,c,s;main(m){for(;c=i=scanf("%d",&n)*n;printf("%d\n",m))for(m=1;j=c?scanf("%f,%f",x+c,y+--c):--i;)for(;s=!c&&j--;)for(u=acos(hypot(t=x[j]-x[i],b=y[j]-y[i])/2),t=atan2(b,t);c=0,u<9&&s+3;s-=2)for(k=n;k--;)hypot(x[i]+cos(b)-x[k],y[i]+sin(b=t+s*u)-y[k])<1.1&&++c>m?m=c:0;}

Measured memory_bytes: 772
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    int n,m;
    cin>>n>>m;
    bool a[114514]={false};
    int ka[114514]={};
    a[1]=true;
    for(int i=1;i<=n;i++){
        ka[i]++;
    }
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        if(a[x]){
            if(ka[x]==1){
                a[x]=false;
                a[y]=true;
            }else{
                a[y]=true;
            }
        }
        ka[x]--;
        ka[y]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		String ans = "No";
		if ( A == B && A != C ) {
			ans = "Yes";
		} else if ( A == C && A != B ) {
			ans = "Yes";
		} else if ( B == C && A != B ) {
			ans = "Yes";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21332
#include <cstdio>
#include <cctype>
#define R register ll
const int inf=0x3f3f3f3f;

namespace quick {
#define tp template<typename Type>
	namespace in {
		inline char getc() {
			static char buf[1<<21],*p1=buf,*p2=buf;
			return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
		}
		inline int read(char *s) {
			*s=getc();
			while(!isalpha(*s)) {*s=getc();if(*s==EOF) return 0;}
			while(isalpha(*s)) {s++;*s=getc();}
			*s='\0'; return 1;
		}
		tp inline int read(Type &x) {
			x=0;bool k=false;char c=getc();
			while(!isdigit(c)) {k|=(c=='-');c=getc();if(c==EOF) return 0;}
			while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getc();}
			x*=(k?-1:1); return 1;
		}
		template <typename Type,typename... Args>
		inline int read(Type &t,Args &...args) {
			int res=0;
			res+=read(t);res+=read(args...);
			return res;
		}
	}
	using in::read;
	namespace out {
		char buf[1<<21];int p1=-1;const int p2=(1<<21)-1;
		inline void flush() {
			fwrite(buf,1,p1+1,stdout);
			p1=-1;
		}
		inline void putc(const char &c) {
			if(p1==p2) flush();
			buf[++p1]=c;
		}
		inline void write(const char *s) {
			while(*s!='\0') putc(*s),s++;
		}
		tp inline void write(Type x) {
			static char buf[30];int p=-1;
			if(x<0) {putc('-');x=-x;}
			if(x==0) putc('0');
			else for(;x;x/=10) buf[++p]=x%10+48;
			for(;p!=-1;p--) putc(buf[p]);
		}
		inline void write(char c) {putc(c);}
		template <typename Type,typename... Args>
		inline void write(Type t,Args ...args) {
			write(t);write(args...);
		}
	}
	using out::write;
	using out::flush;
	tp inline Type max(const Type a,const Type b) {
		if(a<b) return b;
		return a;
	}
	tp inline Type min(const Type a,const Type b) {
		if(a<b) return a;
		return b;
	}
	tp inline void swap(Type &a,Type &b) {
		a^=b^=a^=b;
	}
	tp inline Type abs(const Type a) {
		return a>=0?a:-a;
	}
#undef tp
}
using namespace quick;

typedef long long ll;
const ll maxn=405,mod=1e9+7;
ll n,c,a[maxn+50],b[maxn+50];
ll f[maxn+50][maxn+50],sum[maxn+50][maxn+50];

int main(void) {
	for(R i(1);i<=maxn;i++) sum[i][0]=1ll;
	for(R i(1);i<=maxn;i++)
		for(R j(1);j<=maxn;j++)
			sum[i][j]=1ll*sum[i][j-1]*i%mod;
	for(R i(1);i<=maxn;i++)
		for(R j(0);j<=maxn;j++)
			(sum[i][j]+=1ll*sum[i-1][j])%=mod;
	read(n,c);
	for(R i(1);i<=n;i++) read(a[i]);
	for(R i(1);i<=n;i++) read(b[i]);
	f[0][0]=1;
	for(R i(1);i<=n;i++)
		for(R j(0);j<=c;j++)
			for(R k(0);k<=j;k++)
				(f[i][j]+=1ll*f[i-1][j-k]*((sum[b[i]][k]-sum[a[i]-1][k]+mod)%mod)%mod)%=mod;
	write(f[n][c],'\n');
	flush();
	return 0;
}


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

constexpr int dir = 4;

int h, w;
vector<string> field;

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

int main() {
    cin >> h >> w;

    field.resize(h);
    for(int i = 0; i < h; i++) cin >> field[i];

    vector< vector<int> > dist(h, vector<int>(w, 0));

    vector<int> dist_max;

    queue< pair<int, int> > que;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(field[i][j] == '#') continue;
            for(int k = 0; k < h; k++) {
                for(int l = 0; l < w; l++) dist[k][l] = 0;
            }
            que.push({j, i});
            while(!que.empty()) {
                int x = que.front().first;
                int y = que.front().second;
                que.pop();
                for(int d = 0; d < dir; d++) {
                    int _x = x + dx[d];
                    int _y = y + dy[d];
                    if((_x == j && _y == i)
                    || _x < 0 || w <= _x || _y < 0 || h <= _y
                    || field[_y][_x] == '#' || dist[_y][_x] != 0) {
                        continue;
                    }
                    dist[_y][_x] += dist[y][x] + 1;
                    que.push({_x, _y});
                }
            }
            int _dist_max = 0;
            for(int k = 0; k < h; k++) {
                for(int l = 0; l < w; l++) {
                    if(_dist_max < dist[k][l]) _dist_max = dist[k][l];
                }
            }
            dist_max.push_back(_dist_max);

            /*
            for(int k = 0; k < h; k++) {
                for(int l = 0; l < w; l++) {
                    cout << dist[k][l] << "";
                }
                cout << endl;
            }
            cout << endl;
            */
        }
    }

    int ans = 0;
    for(auto v : dist_max) {
        if(ans < v) ans = v;
    }

    cout << ans << endl;

    return 0;
}

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

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int A, B;
	cin >> A>>B;
	if (A >=13)
	cout << B;
	else if ( A>=6)
		cout << B/2;
	else
		cout << 0;
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 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;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int i;
	int a,b;
	for(i=1;;i++){
		cin >>a >>b;
		if(a==0 && b==0)break;
		if(a>b)swap(a,b);
		cout <<a <<" " <<b <<'\n';
	}
	return 0;
}

Measured memory_bytes: 1160
from copy import deepcopy
from itertools import permutations

def valid(r, c):
    if 0 <= r and r < 8 and 0 <= c and c < 8:
        return True
    else:
        return False

def print_board(board):
    for i in range(8):
        print(" ".join(map(lambda x: "T" if x else "F", board[i])))

board = [[False for _ in range(8)] for _ in range(8)]
# board = [False for _ in range(64)]
ldyx = [
    (0, 1),
    (1, 1),
    (1, 0),
    (1, -1),
    (-1, 0),
    (-1, -1),
    (0, -1),
    (-1, 1)
]

lR, lC = [], []
N = int(input())
for _ in range(N):
    r, c = map(int, input().split())
    lR.append(r)
    lC.append(c)
    board[r][c] = True

    # all directions put
    # for dxy in ldyx:
    #     nr, nc = r + dxy[1], c + dxy[0]
    #     while valid(nr, nc):
    #         board[nr][nc] = True
    #         nr, nc = nr + dxy[1], nc + dxy[0]

# test
for perm in permutations(range(8)):
    b = deepcopy(board)
    flag = True
    for i in range(N):
        if perm[lR[i]] != lC[i]:
            flag = False
            break
    
    if not flag:
        continue

    # print(perm)
    flag = True
    for i in range(8):
        if i in lR:
            continue

        ri, ci = i, perm[i]
        b[i][perm[i]] = True
        is_possible = True

        for dxy in ldyx:
            nr, nc = ri + dxy[1], ci + dxy[0]
            while valid(nr, nc):
                if b[nr][nc]:
                    is_possible = False
                    break
                else:
                    # b[nr][nc] = True
                    nr, nc = nr + dxy[1], nc + dxy[0]
            if not is_possible:
                flag = False
                break
    if flag:
        for i in perm:
            si = ['.' if k != i else 'Q' for k in range(8)]
            print("".join(si))


Measured memory_bytes: 6356