akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


string bina(ll i,ll x){
    string ans="";
    while(i>0){
        if(i%2==1){
            ans='1'+ans;
            i=i/2;
        }else{
            ans='0'+ans;
            i=i/2;
        }
    }
    while(ans.size()<x){
        ans='0'+ans;
    }
    return ans;
}

ll bi(string i){
    ll c=1;
    ll ans=0;
    for(ll j=i.size()-1;j>=0;j--){
        if(i[j]=='1'){
            ans=ans+c;
        }
        c=c*2;
    }
    return ans;
}

int main(){
    ll n,m;cin>>n>>m;
    ll X[n],Y[n],Z[n];
    rep(i,0,n-1)cin>>X[i]>>Y[i]>>Z[i];
    string s;
    ll x[n],y[n],z[n];
    ll sum[n];
    ll ans=-inf;
    ll total;
    rep(i,0,7){
        s=bina(i,3);
        rep(j,0,n-1){
            if(s[0]=='1')x[j]=X[j];
            else x[j]=-X[j];
            if(s[1]=='1')y[j]=Y[j];
            else y[j]=-Y[j];
            if(s[2]=='1')z[j]=Z[j];
            else z[j]=-Z[j];
        }
        rep(j,0,n-1){
            sum[j]=x[j]+y[j]+z[j];
        }
        sort(sum,sum+n,greater<>());
        total=0;
        rep(j,0,m-1){
            total+=sum[j];
        }
        ans=max(ans,total);
        
    }
    cout<<ans<<endl;
    
    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    Rep(i, K, N){
        if(a[i-K]<a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 9008
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T>
T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T>
T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T>
bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

int A, B, C, D, E, F;

bool is_valid(int s, int ws) {
    if (ws > F) {
        return false;
    }
    return s * (100 + E) <= E * ws;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C >> D >> E >> F;
    A *= 100, B *= 100;
    int res[2];
    double ma = 0.0;
    REP(i, 31) {
        REP(j, 31) {
            int w = A * i + B * j;
            REP(k, F - w + 1) {
                REP(l, F - w + 1) {
                    int s = C * k + D * l;
                    int ws = w + s;
                    if (is_valid(s, ws) && ma <= 1.0 * s / ws) {
                        ma = 1.0 * s / ws;
                        res[0] = ws;
                        res[1] = s;
                    }
                }
            }
        }
    }
    cout << res[0] << " " << res[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vvi in,visit,tmp;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n,m,k,col;
int f(int a,int b,int cl){
	tmp[a][b]=col;
	visit[a][b]=true;
	int sum=1;
	rep(i,4){
		int nx=a+dx[i];
		int ny=b+dy[i];
		if(nx<0||ny<0||nx>=n||ny>=m)continue;
		if(visit[nx][ny])continue;
		if(tmp[nx][ny]==cl){
			sum+=f(nx,ny,cl);
		}
	}
	return sum;
}
int main(){
	while(cin>>n>>m>>k,n+m+k){
		k--;
		in=vvi(n,vi(m));
		rep(i,n)rep(j,m)cin>>in[i][j];
		rep(i,n)rep(j,m)in[i][j]--;
		int out=0;
		rep(i,pow(6,4)){
			int t=i;
			tmp=in;
			rep(j,5){
				visit=vvi(n,vi(m));
				col=(j==4?k:t%6);
				f(0,0,tmp[0][0]);
				t/=6;
//				rep(k,n){rep(l,m)cout<<" "<<tmp[k][l];cout<<endl;}
			}
			visit=vvi(n,vi(m));
			out=max(out,f(0,0,tmp[0][0]));
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1220
a, b, c = map(lambda x: int(x), input().split())
lis = [a, b, c]
lis.sort()
a, b, c = lis[2],lis[1],lis[0]

if abs(a - b) < abs(c - a):
  print(abs(a - b) + abs(b - c))
else:
  print(abs(a - c) + abs(b - c))



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll m=n/(a+b);
	ll md=n%(a+b);
	cout<<m*a+min(md,a);
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define ref goto refrain
int main(){
	string a,b;
	int i=0;
	cin>>a;
	for(int j=0;a[j]!='\0';j++){
		if(a[j]>='A'&&a[j]<='Z'){
			a[j]=a[j]-'A'+'a';
		}
	}
	while(1){
		cin>>b;
		if(b=="END_OF_TEXT") break;
		for(int j=0;b[j]!='\0';j++){
			if(b[j]>='A'&&b[j]<='Z'){
				b[j]=b[j]-'A'+'a';
			}
		}
		if(a==b) i++;
	}
	cout<<i<<endl;
	return 0;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int N;
  cin >> N;
  int h[N + 5];
  int dp[N + 5];
  rep(i, N) cin >> h[i];
  rep(i, N) dp[i] = 1e9;

  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    if (i > 1) {
      dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
                  dp[i - 2] + abs(h[i] - h[i - 2]));
    } else {
      dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
    }
  }
  cout << dp[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 4400
n, k = map(int, input().split())
as_ = list(map(int, input().split()))

if len(set(as_)) <= k:
  print(0)
  exit()

d = {}

for a in as_:
  if a in d:
    d[a] += 1
  else:
    d[a] = 1

ans = 0
d = sorted(d.items(), key=lambda x: x[1])
for k, v in d[:-k]:
  ans += v
print(ans)


Measured memory_bytes: 99656
n = int(input())
s = input()
L = {"R": 0, "G": 0, "B": 0}
R = {"R": s.count("R"), "G": s.count("G"), "B": s.count("B")}
ans = 0
L[s[0]]+=1
R[s[0]]-=1
for i in range(1, n - 1):
	t = s[i]
	if t == "R":
		ans += L["G"] * R["B"] + L["B"] * R["G"]
	elif t == "G":
		ans += L["R"] * R["B"] + L["B"] * R["R"]
	else:
		ans += L["R"] * R["G"] + L["G"] * R["R"]
	for j in range(min(i,n-1-i)):
		ans -= t!=s[i-j-1]!=s[i+j+1]!=t
	L[t]+=1
	R[t]-=1
print(ans)


Measured memory_bytes: 9248
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val ab = mutableListOf<Pair<Int, Int>>()
    for (i in 1..m) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        ab.add(Pair(a - 1, b - 1))
    }

    var bridgeNum = 0
    for (i in 0 until m) {
        val graph = UnionFind(n)
        for (j in 0 until m) {
            if (i == j) continue
            graph.union(ab[j].first, ab[j].second)
        }

        val root = graph.root(0)
        for (i in 1 until n) {
            if (graph.root(i) != root) {
                bridgeNum++
                break
            }
        }
    }
    println(bridgeNum)
}

class UnionFind(private var num: Int) {
    private val parent: IntArray = IntArray(num)
    private val rank: IntArray = IntArray(num)

    init {
        for (i in 0 until num) {
            parent[i] = i
            rank[i] = 1
        }
    }

    fun union(u: Int, v: Int): Int {
        var u = u
        var v = v
        u = root(u)
        v = root(v)
        if (u == v)
            return u
        if (rank[v] < rank[u]) {
            val t = v
            v = u
            u = t
        }
        parent[u] = v
        rank[v] += rank[u]
        rank[u] = -1
        num--

        return v
    }

    fun root(u: Int): Int {
        var u = u
        while (parent[u] != u)
            u = parent[u]
        return u
    }
}

Measured memory_bytes: 37996
#include<iostream>
using namespace std;
int coin[18];
int dp[301];
int a,b,c,d,n;
int main(){
  for(int i=0;i<=300;i++)dp[i]=1;
  for(int i=2;i<=17;i++){
    for(int j=i*i;j<=300;j++){
      a=i*i;
      dp[j]+=dp[j-a];
    }
  }
  //for(int i=1;i<=30;i++)cout<<dp[i]<<endl;


  while(true){
    cin>>n;
    if(n==0)break;
    cout<<dp[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define bitcount(a) __builtin_popcountll(a)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	cout<<n*n*n;
	return 0;
}

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

ll two(ll val){
	ll res = 0;
	while(val % 2 == 0){
		val /= 2;
		res++;
	}
	return res;
}

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

int main(){
	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n) a[i] /= 2;
	int count = 0;
	bool exist = true;
	rep(i,n){
		if(i == 0){
			count = two(a[0]);
		}else{
			if(count != two(a[i])) exist = false;
		}
	}
	if(!exist){
		cout << 0 << endl;
		return 0;
	}
	ll g = 1;
	rep(i,n){
		g = lcm(g, a[i]);
	}
	ll ans;
	ll temp = m/g;
	if(temp % 2 == 0){
		ans = temp /2;
	}else{
		ans = (temp+1)/2;
	}
	cout << ans << endl;
    return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);   
    int x;
    cin >> x;
    if(x == 1) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int popcount(vector<int> const& x){
    return accumulate(x.begin(), x.end(), 0);
}

int popcount(int a){
    int s=0;
    for (int i=0; i<31; ++i)
        s += (a & (1u << i)) ? 1 : 0;
    return s;
}

int f(int r) {
    if (r == 0)
        return 0;
    return f(r % popcount(r)) + 1;
}

vector<int> input_x() {
    string s;
    cin >> s;
    vector<int> x0(s.size());
    for (int i=0; i<s.size(); ++i)
        x0[i] = s[i] - '0';
    return x0;
}

int mod(std::vector<int> const& x, int d) {
    if (d <= 0)
        return 0;
    int m=0;
    for (int i=0; i<x.size(); ++i) {
        m = (m*2 + x[i]) % d;
    }
    return m;
}

void print_answer(vector<int>& a) {
    for (auto x : a)
        cout << x << endl;
}

int main() {
    int n;
    cin >> n;
    const auto x0 = input_x();
    const int pc = popcount(x0);
    vector<int> ans(n);
    for (int k=0; k<2; ++k) {
        const int dpc = (k == 0) ? (pc+1):(pc-1);
        if (dpc <= 0)
            continue;
        const int m = mod(x0, dpc);
        int p=1;
        for (int i=n-1; i>=0; --i) {
            int t;
            if (x0[i] == k) {
                if (k == 0)
                    t = (m + p) % dpc;
                else
                    t = (m - p + dpc) % dpc;
                ans[i] = f(t) + 1;
            }
            p = (p*2) % dpc;
        }
    }
    print_answer(ans);
    return 0;
}

Measured memory_bytes: 4660
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    string pat1="", pat2="";
    REP(i,s.size())
        if(i%2==0)pat1.append("0"), pat2.append("1");
        else pat1.append("1"), pat2.append("0");

    int dif1=0, dif2=0;
    REP(i, s.size()){
        if(s[i]!=pat1[i])dif1++;
        if(s[i]!=pat2[i])dif2++;
    }
    cout << min(dif1, dif2) << endl;
    return 0;
}

Measured memory_bytes: 832
#include<iostream>
using namespace std;
int main() {
    int r,c,i,ii,iii,g[200][200]={};
    cin>>r>>c;
    for(i=1;i<=r;i++){
        for(ii=1;ii<=c;ii++){
            cin>>g[i][ii];
        }
    }
    for(i=1;i<=r;i++){
        for(ii=1;ii<=c;ii++){
            g[i][c+1]+=g[i][ii];
        }
    }
    for(i=1;i<=r;i++){
        for(ii=1;ii<=c;ii++){
            g[r+1][ii]+=g[i][ii];
        }
    }
    for(ii=1;ii<=c;ii++){
        g[r+1][c+1]+=g[r+1][ii];
    }
    for(i=1;i<=r+1;i++){
        for(ii=1;ii<=c+1;ii++){
            cout<<g[i][ii];
            if(c+1==ii){
                cout<<endl;
            }
            else{
                cout<<" ";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3248
#include <iostream>

#include <map>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 1010 };

int hs[MAX];

void precomp()
{
    hs[0] = 0;

    for (int h = 1; h < MAX; ++h)
        hs[h] = (hs[h - 1] + h);
}

int solve(int a, int b)
{
    for (int h = 2; h < MAX; ++h)
    {
        int L = hs[h - 1] - a;
        int R = hs[h] - b;

        if (L == R)
            return L;
    }

    return 1;
}

int main()
{
    ios::sync_with_stdio(false);
    precomp();

    int a, b;
    cin >> a >> b;
        
    cout << solve(a, b) << endl;

    return 0;
}


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

typedef long long ll;
const int N = 100005;
const int M = 1000000007;

ll a[3];

int main() {
  while (~scanf("%lld%lld%lld", &a[0], &a[1], &a[2])) {
    sort(a, a + 3);
    printf("%lld\n", a[0] * a[1] * (a[2] & 1));
  }
}


Measured memory_bytes: 256
template <unsigned int Modulus>
class IntMod {
	typedef unsigned long long ULL;
private:
	unsigned int value_m;

	void Copy(const IntMod& other) { value_m = other.value_m; }
	bool Modulus_is_valid() { return Modulus != 0; }
public:
	IntMod() { value_m = 0; }
	IntMod(unsigned int value) { value_m = value % Modulus; }
	IntMod(const IntMod& other) { Copy(other); }
	IntMod& operator=(const IntMod& other) { Copy(other); return *this; }
	IntMod& operator==(const IntMod& right) const { return value_m == right.value_m; }
	IntMod& operator!=(const IntMod& right) const { return value_m != right.value_m; }
	IntMod& operator++() {
		++value_m; 
		value_m %= Modulus;
		return *this;
	}
	IntMod& operator--() {
		if (value_m == 0) { value_m = Modulus - 1; }
		else { --value_m; }
		return *this;
	}
	IntMod operator-() const {
		if (value_m == 0) return IntMod(0);
		return IntMod(Modulus - value_m);
	}
	IntMod& operator+=(const IntMod& right) {
		ULL sum = (ULL)value_m + right.value_m;
		if (sum >= (ULL)Modulus) { value_m = (unsigned int)(sum - (ULL)Modulus); }
		else { value_m = (unsigned int)sum; }
		return *this;
	}
	IntMod& operator-=(const IntMod& right) {
		(*this) += (-right);
		return *this;
	}
	IntMod operator+(const IntMod& right) {
		IntMod ret(*this);
		ret += right;
		return ret;
	}
	IntMod operator-(const IntMod& right) {
		IntMod ret(*this);
		ret -= right;
		return ret;
	}
	IntMod& operator*=(const IntMod& right) {
		ULL tmp = (ULL)value_m * right.value_m;
		value_m = tmp % (ULL)Modulus;
		return *this;
	}	
	IntMod& operator/=(const IntMod& right) {
		(*this) *= (right.Inverse());
		return *this;
	}
	IntMod operator*(const IntMod& right) {
		IntMod ret(*this);
		ret *= right;
		return ret;
	}
	IntMod operator/(const IntMod& right) {
		IntMod ret(*this);
		ret /= right;
		return ret;
	}
	/* 素数判定は自分でしろ */
	IntMod Inverse() const {
		return (*this).Pow(Modulus - 2);
	}
	IntMod Pow(unsigned int exp) const {
		unsigned int arr[32];		// 32じゃなくてもいい
		ULL sum = 1;
		arr[0] = value_m;
		for (int i = 1; i < 32; ++i) {
			arr[i] = ((ULL)arr[i - 1] * arr[i - 1]) % (ULL)Modulus;
		}
		for (int i = 0; i < 32; ++i) {
			if (exp & (0x1 << i)) {
				sum *= arr[i]; sum %= (ULL)Modulus;
			}
		}
		return (unsigned int)sum;
	}
	unsigned int Get_value() {
		return value_m;
	}
};

typedef IntMod<1000000007> MInt;

#include <iostream>
#include <string>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)

MInt EXP[401][401];
MInt EXPSUM[400][401];
MInt DP[401][401];
int N, C, A[400], B[400];

int main() {
	cin >> N >> C;
	REP(i, 0, N) { cin >> A[i]; }
	REP(i, 0, N) { cin >> B[i]; }

	REP(i, 0, 401) {
		REP(j, 0, C + 1) {
			EXP[i][j] = (j == 0) ? 1 : EXP[i][j - 1] * i;
		}
	}

	REP(i, 0, N) {
		REP(j, 0, C + 1) {
			REP(k, A[i], B[i] + 1) {
				EXPSUM[i][j] += EXP[k][j];
			}
		}
	}

	REP(i, 0, N) {
		REP(j, 0, C + 1) {
			if (i == 0) {
				DP[i][j] = EXPSUM[i][j];
			} else {
				REP(k, 0, j + 1) {
					DP[i][j] += DP[i - 1][k] * EXPSUM[i][j - k];
				}
			}
		}
	}
	cout << DP[N - 1][C].Get_value() << endl;
	return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
	int a,b,c,max = a,ans = 1;
	scanf("%d %d %d",&a,&b,&c);
	if(a >= b && a >= c)
	{
		max = a;
	}
	else if(b >= a && b >= c)
	{
		max = b;
	}
	else{
		max = c;
	}
	if(max == a)  printf("%d\n",b*c/2);
	else if(max == b) printf("%d\n",a*c/2);
	else printf("%d\n",a*b/2);
return 0;
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    sort(h, h + n);
    int Min = INF;
    for (int l = 0, r = k - 1; r < n; l++, r++) {
        Min = min(Min, h[r] - h[l]);
    }
    cout << Min << endl;
    return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll W,H;
const ll M=100000;
ll dp[100][100][4];//from@ chokuue: 0  chokumigi: 1 magatteue: 2 magattemigi: 3
int main()
{
	while(1){
	scanf("%lld%lld",&W,&H);
	if(W==0) return 0;
	fill(dp[0][0],dp[99][100],0);
	dp[0][1][1]=1;
	dp[1][0][0]=1;
	for(ll i=0;i<H;i++){
		for(ll j=0;j<W;j++){
			if(i>0){
				dp[i][j][0]+=(dp[i-1][j][0]+dp[i-1][j][2])%M;
				dp[i][j][2]=dp[i-1][j][1];
			}
			if(j>0){
				dp[i][j][1]+=(dp[i][j-1][1]+dp[i][j-1][3])%M;
				dp[i][j][3]=dp[i][j-1][0];
			}
		}
	}
	printf("%lld\n",(dp[H-1][W-1][0]+dp[H-1][W-1][1]+dp[H-1][W-1][2]+dp[H-1][W-1][3])%M);
	}
}

Measured memory_bytes: 3436
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <utility>

int N, M;
std::pair<int, int> Mat[201];
int dp[201];

int main(){
    while(scanf("%d", &N), N){
        memset(dp, -1, sizeof(dp));
        
        for(int i = 0; i < N; ++i)
            scanf("%d %d", &Mat[i].first, &Mat[i].second);
    
        scanf("%d", &M);
        
        for(int i = 0; i < M; ++i)
            scanf("%d %d", &Mat[i + N].first, &Mat[i + N].second);
        
        std::sort(Mat, Mat + (M + N));
        
        for(int i = 0; i < N + M; ++i)
            dp[i] = 1;
        
        int res = 1;
        for(int i = 0; i < N + M; ++i){
            for(int j = 0; j < i; ++j){
                if(Mat[i].first > Mat[j].first && Mat[i].second > Mat[j].second){
                    dp[i] = std::max(dp[i], dp[j] + 1);
                    
                    res = std::max(res, dp[i]);
                }
            }
        }
        
        std::cout << res << std::endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 1212
import math

A, B, H, M = list(map(int, input().split()))

d = abs((360 * (H * 60 + M) / 720) - (360 * M / 60))

d = min(d, abs(360 - d))

C2 = A * A + B * B - 2 * A * B * math.cos(math.radians(d))

print(C2 ** (1 / 2))

Measured memory_bytes: 9508
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  int M = 9;
  vector<int> data(M);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    A /=400;

    if(A > 7)data[8]++;
    else
    {
      data[A]++;
    }
  }

  int ANS = 0;

  for (int i = 0; i < M - 1; i++)
  {
    if(data[i] > 0) ANS++;
  }


  if(data[8] > 0)
  {
    cout<<max(ANS,(int)1) <<" "<<ANS + data[8]<<endl;
  }
  else
  {
    cout<<ANS<<" "<<ANS<<endl;
  }
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int count=0;
	int k;
	for(int i=0;i<n;i++){
		cin>>k;
		if(k%2==1)
			count++;
	}
	if(count%2==1){
		cout<<"NO";
	}
	else
		cout<<"YES";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

const int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

struct edge{int to, cost;};

class Graph
{
public:
    int N;
    vector<vector<edge>> G;

    Graph(int N): N(N){
        G = vector<vector<edge>>(N, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost = 0){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost = 0){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    Pii dfs(int v, int par = -1){
        Pii p = Pii(0, v);
        for(auto e: G[v]) if(e.to != par){
            Pii q = dfs(e.to, v);
            Max(p, q);
        }
        p.f += 1;
        return p;
    }

};

signed main(){

    int N; cin >> N;
    vec a(N - 1), b(N - 1);
    Graph G(N);
    REP(i, N - 1){
        cin >> a[i] >> b[i];
        G.add_edge2(a[i] - 1, b[i] - 1);
    }   
    Pii p1 = G.dfs(0);
    Pii p2 = G.dfs(p1.s);
    int R = p2.f;
    //debug(R);
    Ans(R % 3 == 2, "Second", "First");

    return 0;
}


Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
int s(vector<vector<int>> &bs,vector<vector<int>> &ws,bool f,int li,int lj,int gi,int gj){
  if(!f)
    return bs[gi][gj]-bs[gi][lj]-bs[li][gj]+bs[li][lj];
  else
    return ws[gi][gj]-ws[gi][lj]-ws[li][gj]+ws[li][lj];
}
int ch(vector<vector<int>> &bs,vector<vector<int>> &ws,bool f,int i,int j,int k){
  int cb,cw;
  if(!f){
    cb=s(bs,ws,0,0,0,i,j)+s(bs,ws,0,0,j+k,i,k*2)
      +s(bs,ws,0,i,j,i+k,j+k)
      +s(bs,ws,0,i+k,0,k*2,j)+s(bs,ws,0,i+k,j+k,k*2,k*2);
    cw=s(bs,ws,1,0,j,i,j+k)
      +s(bs,ws,1,i,0,i+k,j)+s(bs,ws,1,i,j+k,i+k,k*2)
      +s(bs,ws,1,i+k,j,k*2,j+k);
  }else{
    cw=s(bs,ws,1,0,0,i,j)+s(bs,ws,1,0,j+k,i,k*2)
      +s(bs,ws,1,i,j,i+k,j+k)
      +s(bs,ws,1,i+k,0,k*2,j)+s(bs,ws,1,i+k,j+k,k*2,k*2);
    cb=s(bs,ws,0,0,j,i,j+k)
      +s(bs,ws,0,i,0,i+k,j)+s(bs,ws,0,i,j+k,i+k,k*2)
      +s(bs,ws,0,i+k,j,k*2,j+k);
  }
  return cb+cw;
}
int main(){
  int n,k;
  cin>>n>>k;
  vector<vector<int>> b(k*2,vector<int>(k*2,0));
  vector<vector<int>> w(k*2,vector<int>(k*2,0));
  for(int _=0;_<n;_++){
    int x,y;
    char c;
    cin>>x>>y>>c;
    if(c=='B')
      b.at(x%(k*2)).at(y%(k*2))++;
    if(c=='W')
      w.at(x%(k*2)).at(y%(k*2))++;
  }
  vector<vector<int>> bs(k*2+1,vector<int>(k*2+1,0));
  vector<vector<int>> ws(k*2+1,vector<int>(k*2+1,0));
  for(int i=0;i<k*2;i++){
    for(int j=0;j<k*2;j++){
      bs[i+1][j+1]=bs[i][j+1]+bs[i+1][j]-bs[i][j]+b.at(i).at(j);
      ws[i+1][j+1]=ws[i][j+1]+ws[i+1][j]-ws[i][j]+w.at(i).at(j);
    }
  }
  int m=0;
  for(int i=0;i<k;i++)
    for(int j=0;j<k;j++)
      m=max({m,ch(bs,ws,0,i,j,k),ch(bs,ws,1,i,j,k)});
  cout<<m<<endl;
}

Measured memory_bytes: 66076
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	while(cin>>a){
		if(a.length()==2){
			cout<<a<<endl;
		}
		else{
		
		for(int i=2;i>=0;i--){
			cout<<a[i];
		}
		cout<<endl;
		
	}
	}
	
} 

Measured memory_bytes: 256
def get_temp(t,h) :
	return T - h * 0.006

N = int(input())

read_line = input().split()
T = int(read_line[0])
A = int(read_line[1])

height_list = [int(s) for s in input().split()]

diff = 99999
diff_index = 0

for i in range(len(height_list)) :
	temp = get_temp(T,height_list[i])
	
	if (abs(temp - A) < diff) :
		diff = abs(temp -A)
		diff_index = i
	


print (diff_index+1)


Measured memory_bytes: 3064
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007

using namespace std;

const int N=1e5+10;
vi edges[N];
bool visited[N];
int d[N];

void dfs(int i)
{
	visited[i]=1;
	d[i]=-1;
	for(int v : edges[i])
    {
		if(!visited[v]) 
            dfs(v);

		d[i]=max(d[i],d[v]);
	}
	d[i]++;
}

int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) 
    {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
    }
    
    int answer=0;
	for(int i=1;i<=n;i++)
    {
		if(!visited[i]) 
            dfs(i);

		answer=max(answer,d[i]);
	}
    printf("%d\n", answer);

    return 0;
}


Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();

		if(a >= 3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
	}

}


Measured memory_bytes: 22608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

func main() {
	now := time.Now()
	var n int
	fmt.Scanf("%d", &n)
	s := bufio.NewScanner(os.Stdin)
	xs := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		s.Scan()
		xs[i] = readInts(s.Text())
	}
	var m int
	done := make([]bool, n+1)
	for {
		var matches int
		for i := 1; i <= n; i++ {
			done[i] = false
		}
		for i := 1; i <= n; i++ {
			if done[i] || len(xs[i]) == 0 {
				continue
			}
			if m := xs[i][0]; xs[m][0] == i && !done[m] {
				done[m] = true
				done[i] = true
				xs[i] = xs[i][1:]
				xs[m] = xs[m][1:]
				matches++
			}
		}
		if matches == 0 {
			break
		}
		m++
		if time.Now().Sub(now) > time.Duration(1900)*time.Millisecond {
			fmt.Printf("%d\n", n*(n-1)/2)
			return
		}
	}
	for i := 1; i <= n; i++ {
		if len(xs[i]) > 0 {
			fmt.Printf("-1\n")
			return
		}
	}
	fmt.Printf("%d\n", m)
}

func readInts(s string) []int {
	xs := strings.Fields(s)
	ys := make([]int, len(xs))
	for i, x := range xs {
		ys[i], _ = strconv.Atoi(x)
	}
	return ys
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int>q;

    rep(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        int b=q.top();
        q.pop();
        b/=2;
        q.push(b);
    }
    ll ans=0;
    while(q.size()){
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<endl;
    return 0;
}

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

template <typename M>
struct DualSegmentTree {
    using T = typename M::T;

    DualSegmentTree(int n) {
        size = 1;
        height = 1;
        while (size < n) size <<= 1, height++;
        lazy.resize(2 * size, M::id);
    }

    T operator[](int k) {
        k += size;
        propagate(k);
        return lazy[k];
    }

    void update(int l, int r, const T& x) {
        l += size;
        r += size;
        propagate(l);
        propagate(r - 1);
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) lazy[l] = M::op(lazy[l], x), l++;
            if (r & 1) --r, lazy[r] = M::op(lazy[r], x);
        }
    }

private:
    int size, height;
    vector<T> lazy;

    void push(int k) {
        if (lazy[k] == M::id) return;
        lazy[2 * k] = M::op(lazy[2 * k], lazy[k]);
        lazy[2 * k + 1] = M::op(lazy[2 * k + 1], lazy[k]);
        lazy[k] = M::id;
    }

    void propagate(int k) {
        for (int i = height; i > 0; i--) push(k >> i);
    }
};

const ll mod = 998244353;

struct AddMonoid {
    using T = int;
    static inline T id = 0;
    static T op(T a, T b) {
        return (a + b) % mod;
    }
};

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

    int N, K;
    cin >> N >> K;
    vector<int> L(N), R(N);
    for (int i = 0; i < K; i++) cin >> L[i] >> R[i];
    DualSegmentTree<AddMonoid> dp(N + 1);
    dp.update(1, 2, 1);
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < K; j++) {
            if (i + L[j] > N) continue;
            dp.update(i + L[j], min(i + R[j], N) + 1, dp[i]);
        }
    }
    cout << dp[N] << endl;
}

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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> a(9,0);
	long rate;
	for (long i = 1; i <= n; i++) {
		cin >> rate;
		if (rate < 400) { a[0]++; }
		else if (rate < 800) { a[1]++; }
		else if (rate < 1200) { a[2]++; }
		else if (rate < 1600) { a[3]++; }
		else if (rate < 2000) { a[4]++; }
		else if (rate < 2400) { a[5]++; }
		else if (rate < 2800) { a[6]++; }
		else if (rate < 3200) { a[7]++; }
		else{a[8]++;}
	}
	long counter = 0;
	for (long i = 0; i < 8; i++) {
		if (a[i] != 0) { counter++; }
	}
	if (counter == 0) {
		counter = 1;
		a[8]--;
	}

	cout << counter << " " << counter+a[8] << endl;
}

Measured memory_bytes: 256
import fractions

T = int(input())
for i in range(T):
    A, B, C, D = map(int, input().split())
    if A < B:
        print('No')
        continue
    if B > D:
        print('No')
        continue
    if C >= B - 1:
        print('Yes')
        continue
    A = A % B
    D = D % B
    BD = fractions.gcd(B, D)
    A_max = A + BD * ((B - 1 - A) // BD)
    if A_max > C:
        print('No')
    else:
        print('Yes')


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

const ll MX = 1e18;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    int mini = 100100;
    rep(i, n) {
        mini = min(abs(n * a[i] - sum), mini);
    }
    rep(i, n) {
        if(mini == abs(n * a[i] - sum)) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

struct Node{
    int parent;
    int left;
    int right;
};

struct Node T[25];

void pre_P(int u){
    if(u == -1)return;
    printf(" %d",u);
    pre_P(T[u].left);
    pre_P(T[u].right);
}

void in_P(int u){
    if(u == -1)return;
    in_P(T[u].left);
    printf(" %d",u);
    in_P(T[u].right);
}

void pos_P(int u){
    if(u == -1)return;
    pos_P(T[u].left);
    pos_P(T[u].right);
    printf(" %d",u);
}



int main(){
    int n,v,l,r,root = 0;
    cin >> n;
    for(int i = 0;i < n;i++){
        T[i].parent = -1;
    }
    for(int i = 0;i < n;i++){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l != -1)T[l].parent = v;
        if(r != -1)T[r].parent = v;
        
    }
    for(int i = 0;i < n;i++){
        if(T[i].parent == -1)root = i;
    }
    cout << "Preorder" << endl;
    pre_P(root);
  	cout << endl;
    cout << "Inorder" << endl;
    in_P(root);
    cout << endl;
    cout << "Postorder" << endl;
    pos_P(root);
    cout << endl;
    
}


Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 20;

string s[N];
int d[N][N];
int h,w;

int _di[4]={1,-1,0,0}, _dj[4]={0,0,1,-1};

void bfs(pii p){
    queue<pii> Q;
    Q.push(p);
    while(!Q.empty()){
        pii p1=Q.front();Q.pop();
        int i=p1.first,j=p1.second;
        rep(k,4) {
            int di=_di[k],dj=_dj[k];
            if(i+di<0||i+di>h-1||j+dj<0||j+dj>w-1) continue;
            if(s[i+di][j+dj]=='#') continue;
            if(d[i+di][j+dj]>d[i][j]+1){
                d[i+di][j+dj]=d[i][j]+1;
                Q.push(pii(i+di,j+dj));
            }
        }
    }
}

int main() {
	cin>>h>>w;
	rep(i,h) cin>>s[i];
	pii st;
	rep(i,h) rep(j,w) if(s[i][j]=='.') {st.first=i;st.second=j;break;}
	rep(i,h) rep(j,w) d[i][j]=INF;
	d[st.first][st.second]=0;
	bfs(st);
//	while(true){
//		bool flag=false;
//		rep(i,h) rep(j,w) if(s[i][j]=='.'&&d[i][j]==INF) {
//			flag=true;
//			d[i][j]=0;
//			pii st2;
//			st2.first=i;st2.second=j;
//			bfs(st2);
//		}
//		if(!flag) break;
//	}
	int max_d=0;
	pii p;
	rep(i,h) rep(j,w) {
		if(s[i][j]=='.'&&d[i][j]>max_d){
			max_d=d[i][j];
			p.first=i;
			p.second=j;
		}
	}
	rep(i,h) rep(j,w) d[i][j]=INF;
	d[p.first][p.second]=0;
	bfs(p);
	max_d=0;
	int ans=0;
	rep(i,h) rep(j,w) if(s[i][j]=='.') {
		if(d[i][j]>max_d){
			p.first=i;
			p.second=j;
			max_d=d[i][j];
		}
	}
	rep(i,h) rep(j,w) d[i][j]=INF;
	d[p.first][p.second]=0;
	bfs(p);
	max_d=0;
	rep(i,h) rep(j,w) if(s[i][j]=='.') max_d=max(max_d,d[i][j]);
	ans=max(ans,max_d);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int p[100000];
void solve(){
	int ans = 0;
	rep(i, N){
		if(p[i] == i + 1){
			ans++;
			i++;
		}
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		cin >> p[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 640
public class Main {

  private static void solve() {
    long h = nl();
    long w = nl();

    if (h == 1 || w == 1) {
      System.out.println(1);
      return;
    }
    long ret = (h / 2) * w;

    if (h % 2 == 1) {
      ret += (w + 1) / 2;;
    }

    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23508
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[]
for i in range(N):
    a=list(map(int,input().split()))
    A.append(a)
    
X=0
V=0
for i in range(N):
    for j in range(M):
        X+=A[i][j]*B[j]
    X+=C
    if X>0:
        V+=1
    X=0
print(V)

Measured memory_bytes: 3064