akhauriyash/Code-Regression huggingface dataset:
use std::cmp::max;

fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn main() {
    let n: usize = input_one().unwrap();
    let mut cache = vec![vec![None; n]; n];
    for i in 0..n {
        let a: usize = input_one().unwrap();
        for _ in 0..a {
            let (x, y) = input_pair::<usize>();
            cache[x-1][i] = Some(y);
        }
    }
    let mut result = 0;
    for mask in 0..(1 << n) {
        let mut ok = true;
        let mut count = 0;
        for i in 0..n {
            let honest = (mask & (1 << i)) >> i;
            for (j, &test) in cache[i].iter().enumerate() {
                if mask & (1 << j) > 0 {
                    if test == None {
                        continue;
                    }
                    if test != Some(honest) {
                        ok = false;
                        break;
                    }
                }
            }
            if !ok {
                break;
            } else if honest == 1 {
                count += 1;
            }
        }
        if ok {
            result = max(result, count);
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 2120
n=int(input())
mod=10**9+7
fra=[1]*(n+2)
inv=[1]*(n+2)
t1=1
t2=1
for i in range(1,n+2):
    t1*=i
    t1%=mod
    t2*=pow(i,mod-2,mod)
    t2%=mod
    fra[i]=t1
    inv[i]=t2
ans=fra[n]
for i in range((n+1)//2,n):
    ans-=fra[i-1]*inv[2*i-n]*fra[i]%mod
    ans%=mod
print(ans)

Measured memory_bytes: 55916
#include <iostream>
using namespace std;
int main() {
    string s;
    int start,end;
    cin>>s;
    for(int i=0;i<s.length();i++){
       if(s[i]=='A'){
            start=i;
            break;
        }}
        for(int i=0;i<s.length();i++){
         if(s[i]=='Z'){
            end=i;
        }
    }
    cout<<(end-start)+1;
    return 0;
}


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

int main(){
	
	int N;
	cin >> N;
	int arr[N];
	int count=0;
	for(int i=0;i<N;i++)
		cin >> arr[i];
		
	for(int i=0;i<N;i++){
		if( (i+1)%2 != 0  && arr[i]%2 !=0 ){
			count++;
		}
	}
	
	cout << count ;
	
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
using namespace std;
int main(){
    int w[10],k[10];
    for(int i=0;i<10;i++)
        cin>>w[i];
    for(int i=0;i<10;i++)
        cin>>k[i];
    for(int i=0;i<9;i++){
        for(int j=9;j>i;j--){
            if(w[j]>w[j-1]){
                int tmp=w[j];
                w[j]=w[j-1];
                w[j-1]=tmp;
            }
        }
    }
    for(int i=0;i<9;i++){
        for(int j=9;j>i;j--){
            if(k[j]>k[j-1]){
                int tmp=k[j];
                k[j]=k[j-1];
                k[j-1]=tmp;
            }
        }
    }
    cout<<w[0]+w[1]+w[2]<<" "<<k[0]+k[1]+k[2]<<endl;
    return 0;
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;string S[999],a;int P,M[999],O[999],c,C,n,m,i;main(){cin>>n>>m;for(i=0;i<n;i++){cin>>S[i]>>O[i];}for(i=0;i<n;i++){P=0;while(P!=S[i].size()){cout<<"? "<<S[i]<<endl;cin>>a;C++;if(tolower(a[0])==tolower(S[i][P])){ S[i][P]='_';P++;c++; }else{M[i]++;if(M[i]>O[i]){m--;break;}}}if(m<=0){ cout<<"! Game Over"<<endl;return 0; }}cout<<fixed<<setprecision(1)<<"! Game Clear "<<(double)((int)(1000*c/C)/10.0)<<endl;}

Measured memory_bytes: 1304
N=int(input())
field=[[0 for _ in range(101)] for _ in range(101)]

p=[list(map(int,input().split())) for _ in range(N)]
for x,y,h in p:
    if h!=0:
        tem_x=x
        tem_y=y
        tem_h=h
        break

for i in range(101):
    for k in range(101):
        flag=True
        H=tem_h+abs(tem_x-i)+abs(tem_y-k)
        for x,y,h in p:
            if h==max(H-abs(x-i)-abs(y-k),0):
                pass
            else:
                flag=False
        if flag:
            print(i,k,H)
            exit()

Measured memory_bytes: 3064
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double; 
const string FILENAME = "input";
const int MAXN = 370;


int d;
int t[MAXN];
int c[MAXN];
int s[MAXN][29];
int last[MAXN];
int q;
set<int> pos[29];



ll calcCost() {
	for (int i = 1; i <= 26; i++) {
		last[i] = 0;
	}
	ll sat = 0;
	for (int i = 1; i <= d; i++) {
		sat += s[i][t[i]];
		last[t[i]] = i;
		for (int j = 1; j <= 26; j++) {
			sat -= c[j] * (i - last[j]);
		}
	}
	return sat;
}


ll cur;




void addSeg(int l, int r, int i, int mod) {
	l++;
	int t = r - l ;
	if (t <= 0) {
		return;
	}
	cur -= (ll)mod * c[i] * t * (t + 1) / 2;
}



void del(int i, int x) {
	cur -= s[x][i];
	auto it = pos[i].find(x);
	it++;
	int nr = *it;
	it--;
	it--;
	int nl = *it;
	addSeg(x, nr, i, -1);
	addSeg(nl, x, i, -1);
	pos[i].erase(x);
	addSeg(nl, nr, i, 1);
}



void add(int i, int x) {
	cur+= s[x][i];
	pos[i].insert(x);
	auto it = pos[i].find(x);
	it++;
	int nr = *it;
	it--;
	it--;
	int nl = *it;
	addSeg(x, nr, i, 1);
	addSeg(nl, x, i, 1);
	addSeg(nl, nr, i, -1);
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
// 	read(FILENAME);
	cin >> d;
	for (int i = 1; i <= 26; i++) {
		cin >> c[i];
		pos[i].insert(0);
		pos[i].insert(d + 1);
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= 26; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 1; i <= d; i++) {
		cin >> t[i];
		pos[t[i]].insert(i);
	}	
	cur = calcCost();
	cin >> q;
	for (int it = 0; it < q; it++) {
		int id, cs;
		cin >> id >> cs;
		del(t[id], id);
		t[id] = cs;
		add(t[id], id);
		cout << cur << '\n';
	}
	return 0;	 	
}


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

using Lint=long long;
template<int mod> class ModInt
{   
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

mint dp[5010][5010];

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

    dp[0][0]=1;
    for(int i=0;i<N;i++) for(int j=0;j<=i;j++){
        dp[i+1][j+1]+=dp[i][j];
        dp[i+1][j+1]+=dp[i][j];
        dp[i+1][max(j-1,0)]+=dp[i][j];
    }
    mint ans=dp[N][s.size()];
    for(int i=0;i<s.size();i++) ans/=2;
    cout<<ans.value()<<endl;
    return 0;
}

Measured memory_bytes: 196352
#include <iostream>
#include <cmath>
#define llint long long 
#define inf (llint)1e16

using namespace std;

llint N;
llint a[200005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> a[i];
	
	llint y = 0;
	for(int i = 0; i < N; i++) y += a[i];
	
	llint ans = inf, x = 0;
	for(int i = 0; i < N-1; i++){
		x += a[i];
		y -= a[i];
		ans = min(ans, (llint)abs(x-y));
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// AtCoder Beginner Contest 111 - Problem D: Robot Arms (https://beta.atcoder.jp/contests/abc111/tasks/arc103_b)
#include <bits/stdc++.h>

using namespace std;

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

#define REP(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define REPN(i, N) for (int (i) = 0; (i) < N; (i)++)
#define DEC(i, b, a) for (int (i) = (b); (i) >= (a); (i)--)
#define DECN(i, N) for (int (i) = N - 1; (i) >= 0; (i)--)

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : (vec)) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

const int MAX { 1010 };

ii ps[MAX];

int mod2(int a, int b)
{
    return (((a + b) % 2) + 2) % 2;
}

void solve(int N)
{
    // A paridade da soma das coordenadas deve ser a mesma da soma dos comprimentos
    ll x, y;
    tie(x, y) = ps[0];
    auto p = mod2(x, y);

    REPN(i, N)
    {
        tie(x, y) = ps[i];
 
        if (mod2(x, y) != p)
        {
            cout << -1 << endl;
            return;
        }
    }
    
    int m = 31;
    vector<ll> ds;

    for (int i = 0; i < m; ++i)
        ds.push_back(1LL << i);

    if (p == 0)
    {
        ++m;
        ds.push_back(1);
    }

    cout << m << endl;

    REPN(i, m)
        cout << ds[i] << (i + 1 == m ? "\n" : " ");

    if (p == 0)
    {
        --m;
        ds.pop_back();
    }

    REPN(i, N)
    {
        tie(x, y) = ps[i];

        if (p == 0)
            --x;

        string cmds = "";

        DECN(j, m)
        {
            auto d = ds[j];

            if (llabs(x) > llabs(y))
            {
                if (x > 0) 
                {
                    cmds += 'R';
                    x -= d;
                } else
                {
                    cmds += 'L';
                    x += d;
                }
            } else 
            {
                if (y > 0)
                {
                    cmds += 'U';
                    y -= d;
                } else 
                {
                    cmds += 'D';
                    y += d;
                }
            }         
        }

        reverse(cmds.begin(), cmds.end());

        if (p == 0)
            cmds += 'R';

        cout << cmds << '\n';
    }
}

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

    int N;
    cin >> N;

    REPN(i, N)
        cin >> ps[i].first >> ps[i].second;

    solve(N);

    return 0;
}


Measured memory_bytes: 256
import sys
n = int(raw_input())
w0 = str(raw_input())
wlist = [w0]
for i in range(1,n):
	w = str(raw_input())
	wlist.append(w)
	if (wlist.count(w)>=2) | (w0[-1] != w[0]):
		print 'No'
		sys.exit()
	else:
		w0 = w
print 'Yes'

Measured memory_bytes: 2568
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n;
	cin >> n;
	vector<long long> a(n+1),b(n);
	
	REP(i,n+1) cin >> a[i];
	REP(i,n) cin >> b[i];
	
	long long ans=0;
	ans += min(a[0],b[0]);
	b[0] = max((long long)0, b[0]-a[0]);
	for(int i=1; i<n; i++){
		ans += min(a[i],b[i-1]);
		a[i] = max((long long)0, a[i]-b[i-1]);
		ans += min(a[i], b[i]);
		b[i] = max((long long)0, b[i]-a[i]);
	}
	ans+=min(a[n],b[n-1]);
	
	cout << ans << endl;
	
	return 0;
}

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

int main() 
{ 
   	int n , k;
   	cin >> n >> k;
   	int cnt = 0;
   	for(int i = 0 ; i < n ; i++)
   	{
   		int x;
   		cin >> x;
   		if(x >= k)
   			cnt++;
   	}
   	cout << cnt << endl;
	return 0; 
} 

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

int main() {
    int N, A;
    cin >> N;
    std::vector<int> V(N);
    for(int i = 0; i < N-1; i++){
        cin >> A;
        V.at(A-1)++;
    }
    for(int j = 0; j < N; j++){
        cout << V.at(j) << endl;
    }
}

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

int main()
{
    string a,b;
    cin >> a;
    cin >> b;
    int n = a.size() + b.size();
    vector<char> c(n);
    for(int i= 0;i < a.size();i++){
        c[2*i] = a[i];
    }
    for(int i = 0;i < b.size();i++){
        c[2*i + 1] = b[i]; 
    }
    for(int i = 0;i < n;i++) cout << c[i];
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;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--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll buka[200001];

void solve_abc_c() {
	ll n;
	ll ans = 0;

	cin >> n;

	V a(n);
	rep(i, n - 1) {
		cin >> a[i+1];
		buka[a[i+1]]++;
	}

	rep(i, n) {
		cout << buka[i+1] << "\n";
	}
}

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

	solve_abc_c();

	return 0;
}

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ll long long
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;


ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}



ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}



ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

//const long sz=1e6+10;
int main()
{
    fast;
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        ll n;
        cin>>n;
        ll a[n];
        bool yeah=true;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        
        for(int i=n-1;i>0;i--){
            if(a[i-1]-a[i]>=2){
                yeah=false;
                break;
            }else if(a[i-1]-a[i]==1){
                a[i-1]--;
            }
        }
        if(yeah) cout<<"Yes";
        else cout<<"No";

    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;
#define TEST(x) int x; cin>>x; while(x--)
#define ITR(type, var) type::iterator var;
#define ALIAS(type, alias) using alias = type;
#define ALIAS_M(container, A, B, alias) using alias = container<A,B>;

using namespace std;
using ii = pair<int,int>;
using vii = vector<ii>;
using vi = vector<int>;
using vvi = vector<vi>;
using hmapii = unordered_map<int,int>;
using hmapsi = unordered_map<string, int>;
using hmapss = unordered_map<string, string>;
using ll = long long;
using llu = unsigned long long;


int main() {
	FIO;
	int n;
	cin>>n;
	int arr[200010];
	memset(arr, 0, sizeof(arr));
	for(int i = 2; i<=n; i++){
		int inp;
		cin>>inp;
		arr[inp]++;
	}
	
	for(int i= 1; i<=n; i++){
		cout<<arr[i]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <cstdlib>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

struct lazy_segtree {
  int n;
  vector<int> data;
  vector<int> lazy;
  vector<bool> lazyFlag;

  lazy_segtree(const int s) {
    init(s);
  }

  lazy_segtree(const int s, const int u) {
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = u;
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = min(data[i*2+1], data[i*2+2]);
    }
  }

  lazy_segtree(const vector<int> &v) {
    int s = v.size();
    init(s);
    for (int i = 0; i < s; i++) {
      data[i+n-1] = v[i];
    }
    for (int i = n-2; i >= 0; i--) {
      data[i] = min(data[i*2+1], data[i*2+2]);
    }
  }

  void init(const int s) {
    n = 1;
    while (n < s) n <<= 1;
    data = vector<int>(2*n-1);
    lazy = vector<int>(2*n-1);
    lazyFlag = vector<bool>(2*n-1);
  }

  void evaluate(int p, int a, int b) {
    if (lazyFlag[p]) {
      data[p] = lazy[p];
      if (b - a > 1) {
        lazy[p*2+1] = lazy[p];
        lazy[p*2+2] = lazy[p];
        lazyFlag[p*2+1] = true;
        lazyFlag[p*2+2] = true;
      }
      lazy[p] = 0;
      lazyFlag[p] = false;
    }
  }

  void update(int l, int r, int v, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init

    // evaluate lazy value
    evaluate(p, a, b);

    if (r <= a || b <= l) return; // out of range
    if (l <= a && b <= r) { // fully covered
      lazy[p] = v;
      lazyFlag[p] = true;
      evaluate(p, a, b);
    }
    else {
      update(l, r, v, p*2+1, a, (a + b) / 2); // left
      update(l, r, v, p*2+2, (a + b) / 2, b); // right
      data[p] = min(data[p*2+1], data[p*2+2]); // update
    }
    return;
  }

  int query(int l, int r, int p = 0, int a = 0, int b = -1) {
    if (b < 0) b = n; // init
    if (r <= a || b <= l) return 0x7fffffff; // out of range

    // evaluate lazy value
    evaluate(p, a, b);

    if (l <= a && b <= r) return data[p];// fully covered

    int vl = query(l, r, p*2+1, a, (a + b) / 2); // left
    int vr = query(l, r, p*2+2, (a + b) / 2, b); // right
    return min(vl, vr);
  }
};

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

  int n, q;
  cin >> n >> q;
  vector<vector<int> > query(q, vector<int>(4));
  for (int i = 0; i < q; i++) {
    cin >> query[i][0] >> query[i][1] >> query[i][2];
    if (query[i][0] == 0) cin >> query[i][3];
  }

  lazy_segtree lst(n, 0x7fffffff);
  vector<ll> ans;
  for (int i = 0; i < q; i++) {
    if (query[i][0] == 0) { // add
      lst.update(query[i][1], query[i][2]+1, query[i][3]);
    }
    else { // findMin
      ans.push_back(lst.query(query[i][1], query[i][2]+1));
    }
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}



Measured memory_bytes: 11344
#include<bits/stdc++.h>
#define ll long long
#define fr(i,x,y) for(int i=(x);i<=(y);i++)
#define rf(i,x,y) for(int i=(x);i>=(y);i--)
#define frl(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int N=200002;
int n,Q;
ll m;
struct data{
	int x,y,w;
	bool operator < (const data &q)const{ return w<q.w; }
}a[N];
int f[N];

template<class T> void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar());
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+ch-'0';
}

int gf(int x){ return f[x]==x?x:f[x]=gf(f[x]); }

int main(){
	read(n);read(m);read(Q);
	fr(i,1,Q) read(a[i].x),read(a[i].y),read(a[i].w);
	fr(i,1,Q) a[i].x++,a[i].y++;
	sort(a+1,a+1+Q);
	fr(i,1,n) f[i]=i;
	int flag=0;
	fr(i,1,Q){
		if (a[i].w){
			flag=i;
			break;
		}
		int x=a[i].x,y=a[i].y;
		f[gf(x)]=gf(y);
	}
	if (flag) fr(i,flag,Q) if (gf(a[i].x)==gf(a[i].y)) return puts("No"),0;
	int cnt=0;
	fr(i,1,n) if (gf(i)==i) cnt++;
	if (!flag){
		if (m>1LL*cnt*(cnt-1)/2+n-cnt) puts("No");
		 else puts("Yes");
	} else{
		if (cnt<=2||m<n) puts("No");
		 else if (m>1LL*cnt*(cnt-1)/2+n-cnt) puts("No");
		  else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n % 2) {
    cout << "No" << endl;
    return 0;
  }
  int mid = n / 2;
  for (int i = 0; i < mid; i++) {
    if (s[i] != s[mid + i]) {
      cout << "No" << endl;
      return 0;
    }
  }
      cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    scanf("%d %d",&H,&W);
    
    int i,j;
    while (1)
    {
        if (H == 0 && W == 0) {
            break;
        }
        else
        {
            for (i=1; i<H+1; i++)
            {
                for (j=1; j<W+1; j++) {
                    if (j==1||j==W) {
                        printf("#");
                    }
                  
                   else if (i==1||i==H) {
                        printf("#");
                   }
                   else  {
                       printf(".");
                   }
                    
                }
                printf("\n");
            }
            printf("\n");
            scanf("%d %d",&H,&W);
        }
    }
    return 0;
}

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

int main(){
  int n;	cin >> n;
  string s;	cin >> s;
  string t=s;
  sort(t.begin(),t.end());
  int ans=0;
  for(int i=0;i<n;i++){
    if(s[i]==t[i])	continue;
    ans++;
  }
  cout << (ans+1)/2;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> cards(N);
  for (int i = 0; i < cards.size(); ++i)
  {
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  int A = 0, B = 0;
  for (int i = 0; i < cards.size(); ++i)
  {
    A += cards.at(i);
    ++i;
    if (i == cards.size())
      break;
    B += cards.at(i);
  }
  cout << A - B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
#define NONE  0b0000000
#define ZERO  0b0111111
#define ONE   0b0000110
#define TWO   0b1011011
#define THREE 0b1001111
#define FOUR  0b1100110
#define FIVE  0b1101101
#define SIX   0b1111101
#define SEVEN 0b0100111
#define EIGHT 0b1111111
#define NINE  0b1101111

int main(void)
{
  while (true)
  {
    int n;
    cin >> n;
    if ( n == -1 ) break;
    int display = NONE;
    for (int i = 0; i < n; ++i)
    {
      int num;
      cin >> num;
      int buf;
      switch(num)
      {
        case 0:
          buf = ZERO;
          break;
        case 1:
          buf = ONE;
          break;
        case 2:
          buf = TWO;
          break;
        case 3:
          buf = THREE;
          break;
        case 4:
          buf = FOUR;
          break;
        case 5:
          buf = FIVE;
          break;
        case 6:
          buf = SIX;
          break;
        case 7:
          buf = SEVEN;
          break;
        case 8:
          buf = EIGHT;
          break;
        case 9:
          buf = NINE;
          break;
      }
    cout << bitset<7>(buf xor display) << endl;
    display = buf;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

#define DIGIT 63

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  vector<int> count(DIGIT, 0);
  ll k;
  cin >> n >> k;
  ll mask;
  vector<ll> a(n);

  REP(i, n) {
    ll input;
    cin >> input;
    a[i] = input;
    mask = 1;
    REP(j, DIGIT) {
      if (mask & input) {
        count[j]++;
      }
      mask <<= 1;
    }
  }

  mask = 0;
  REP(i, DIGIT) {
    if (count[i] <= n / 2) {
      mask |= (ll) 1 << i;
    }
  }
  ll ans = 0;
  k++;
  RREP(i, DIGIT) {
    if (k & (ll) 1 << i) {
      ll tk;
      tk = (k ^ (ll) 1 << i) | ((ll) 1 << i) - 1;
      ll tmp = 0;
      REP(j, n) {
        tmp += (mask & tk) ^ a[j];
      }
      ans = max(ans, tmp);
    }
  }

  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1152
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, L = list(map(int, sys.stdin.readline().split()))
S = [sys.stdin.readline().rstrip() for _ in range(N)]
S.sort()
print(''.join(S))



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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n;
    cin>>n;
    cout<<360/__gcd(n,360)<<endl;
}

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

Measured memory_bytes: 3660
#include <stdio.h> 

int main() {
  int n,x;
  int b,i,j,k,a;

  while(1) {
    scanf("%d %d",&n,&x);   
    b = 0;
    if( n == 0 && x == 0){
      break;
    }
    for(k = 1; k <= n ; k++) {


      for(j = 1; j <= n ; j++) {

	for(i = 1; i <= n; i++) {
	  
	  if(i == j || j == k || i ==k) {
	    
	  }else{
	    a = i + j + k;
	    if(a == x) {
	     
	      b += 1;
 
	    }
	  }
	  
	}//i
	
      }//j

    }//k
    printf("%d\n",b/6);
  }


  return 0;
}  
      



Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s = "", t = "";
	int a, b;
	cin >> a >> b;
	rep(i, 0, b) s += '0' + a;
	rep(i, 0, a) t += '0' + b;
	if(s <= t) cout << s << endl;
	else cout << t << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define debug(x) cerr<<#x<<": "<<x<<endl

using P = pair<int,int>;

int area(P c){
    return c.first*c.second;
}

namespace std {
    bool operator<(const P a, const P b) {
        return area(a) < area(b);
    }
}

pair<P,P> cut(P c,int s){
    int w = c.first, h = c.second;
    s %= (c.first+c.second)*2;
    P p1,p2;
    if(s < w){
        p1 = {s,h}, p2 = {w-s,h};
    }else if(s < w+h){
        s -= w;
        p1 = {w,s}, p2 = {w,h-s};
    }else if(s < w*2+h){
        s -= w+h;
        p1 = {s,h}, p2 = {w-s,h};
    }else{
        s -= w*2+h;
        p1 = {w,s}, p2 = {w,h-s};
    }
    return {min(p1,p2), max(p1,p2)};
}

int main(void){
    int N,W,H;
    while(cin>>N>>W>>H, N|W|H){
        vector<P> cake = {{W,H}};
        rep(i,N){
            int p,s;
            cin>>p>>s;
            p--;
            pair<P,P> cake_pair = cut(cake[p],s);
            cake.erase(cake.begin()+p);
            cake.push_back(cake_pair.first);
            cake.push_back(cake_pair.second);
        }
        sort(all(cake));
        rep(i,N+1){
            cout<<area(cake[i])<<(i<N ? " " : "\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2972
import collections


N, K = map(int, input().split(' '))
A = input().split(' ')
counter_A = collections.Counter(A)
diversity = len(counter_A) - K
ans = 0
if diversity <= 0:
    print(ans)
    exit()
for item in counter_A.most_common()[-1*diversity:]:
    ans += item[1]
print(ans)


Measured memory_bytes: 44056
#include <iostream>
using namespace std;
int main(void) {
	string S;

	cin >> S;
	if (S == "SUN"){
		cout<<7<<endl;
	}else if (S == "MON") {
		cout << 6 << endl;
	}
	else if (S == "TUE") {
		cout << 5 << endl;
	}
	else if (S == "WED") {
		cout << 4 << endl;
	}
	else if (S == "THU") {
		cout << 3 << endl;
	}
	else if (S == "FRI") {
		cout << 2 << endl;
	}
	else if (S == "SAT") {
		cout << 1 << endl;
	}
	return 0;
}

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

int main()
{
	double a, b, c, d, e, f, x, y;			// ax + by = c 
											// dx + ey = f
	while (cin >> a >> b >> c >> d >> e >> f)
	{
		x = (double)((c*e - b*f) / (a*e - b*d));
		y = (double)(( - (c*d) + a*f) / (a*e - b*d));

		(x == 0) ? x = 0 : x;
		(y == 0) ? y = 0 : y;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1236
import java.util.*;
 
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();
   
   if((a!=b)&&(a!=c)&&(b!=c)) {
	   System.out.println("No");
   }else if((a==b)&&(a==c)) {
	   System.out.println("No");
   }else {
	   System.out.println("Yes");
   }
 
}
	}

Measured memory_bytes: 21972
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,v=parseMap(split(readline()))
    b,w=parseMap(split(readline()))
    t=parseInt(readline())
    dis=abs(a-b)
    if v>w && dis/(v-w)<=t
        println("YES")
    else
        println("NO")
    end
end
main()

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

const ll mod = 1e9+7;

int main(){
  ll n,l;
  cin >> n >> l;
  vector<ll> x(n),a(n);
  rep(i,n)cin >> x[i];
  rep(i,n)cin >> a[i];

  vector<ll> cur(l+1,0);
  cur[l] = 1;

  rrep(i,n){
    vector<ll> nxt(l+1,0);
    ll sum = cur[l];
    rrep(j,l){
      if(j<x[i])break;
      if( a[i]>0 && (j-x[i])%a[i] == 0 ){
	nxt[j] += sum; if(nxt[j]>=mod)nxt[j] -= mod;
      }else if(a[i]==0 && j==x[i]){
	nxt[j] += sum; if(nxt[j]>=mod)nxt[j] -= mod;
      }
      sum += cur[j]; if(sum>=mod)sum -= mod;
    }
    cur = nxt;
  }

  ll res = 0;
  rep(i,l)(res += cur[i]) %= mod;
  cout << res << endl;
}

Measured memory_bytes: 1336
/*input 
10000000
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e7+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int lst[maxn];
int main(){
    lst[1]=1;
    for(int i=2;i<maxn;i++){
        if(!lst[i]){
          lst[i]=i;
            for(int j=i*2;j<maxn;j+=i){
                if(!lst[j]) lst[j]=i;
            }
        }
    }
    int n;
    cin>>n;
    ll anss=0;
    REP1(asd,n){
        int x=asd;
        map<int,int> mp;
        while(x>1){
            mp[lst[x]]++;
            x/=lst[x];
        }
        ll ans=1;
        for(auto x:mp) ans*=(x.s+1);
        anss+=(ans*asd);
    }
    cout<<anss;
} 


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

int mod = 1'000'000'007;
vector<int> dm = {1, 10, 9, 12, 3, 4};

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2 == 0) return modpow(x, y / 2) * modpow(x, y / 2) % mod;
    return x * modpow(x, y - 1) % mod;
}

void dfs(vector<int> &cnt, vector<int> &tmp, vector<int> &data, long long &ans, vector<vector<long long>> &pre){
    bool flag = false;
    int check = - 1;
    for (int i = 0; i < 6; i++){
        if (data[i] == - 1) {
            flag = true;
            check = i;
        }
        if (flag) break;
    }
    if (flag){
        for (int i = 0; i < 13; i++){
            data[check] = i;
            dfs(cnt, tmp, data, ans, pre);
            data[check] = - 1;
        }
    }
    else {
        int check = 0;
        for (int i = 0; i < 6; i++) check += data[i];
        if (check % 13 == 5){
            long long tmp = 1;
            for (int i = 0; i < 6; i++){
                tmp *= pre[i][data[i]];
                tmp %= mod;
            }
            ans += tmp;
            ans %= mod;
        }
    }
}

int main(){
    string s;
    cin >> s;
    int k = (int)s.size();
    vector<int> cnt(6, 0);
    vector<int> tmp(6, 0);
    for (int i = k - 1; i >= 0; i--){
        if (s[i] == '?') cnt[(k - 1 - i) % 6]++;
        else tmp[(k - 1 - i) % 6] += s[i] - '0';
    }
    vector<vector<long long>> pre(6, vector<long long>(13, 0));
    for (int i = 0; i < 6; i++){
        pre[i][(tmp[i] * dm[i]) % 13] = 1;
        for (int j = 0; j < cnt[i]; j++){
            vector<long long> nx(13, 0);
            for (int k = 0; k < 13; k++){
                for (int p = 0; p < 10; p++) nx[(k + p * dm[i]) % 13] += pre[i][k];
            }
            for (int k = 0; k < 13; k++) {
                pre[i][k] = nx[k];
                pre[i][k] %= mod;
            }
        }
    }
    vector<int> data(6, -1);
    long long ans = 0;
    dfs(cnt, tmp, data, ans, pre);
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    float d,t,s;
    cin>>d>>t>>s;

    float tm=d/s;
    if(tm<=t){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
        
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

struct edge {
  int t,d,c;
  edge(){}
  edge(int t,int d,int c):t(t),d(d),c(c){}
};

struct state {
  int n,d,c;
  state(){}
  state(int n,int d,int c):n(n),d(d),c(c){}
  bool operator>(const state& e)const{
    return d>e.d;
  }
};

int n,m;
vector<edge> g[11111];
int cost[11111],v[11111];

int main(void)
{
  int a,b,c,d;
  for(;;) {
    scanf("%d%d",&n,&m); if(n+m==0)break;
    for( int i = 0; i < n; i++ ) g[i].clear();
    for( int i = 0; i < m; i++ ) {
      scanf("%d%d%d%d",&a,&b,&c,&d); --a; --b;
      g[a].push_back(edge(b,c,d));
      g[b].push_back(edge(a,c,d));
    }
    priority_queue<state,vector<state>,greater<state> > q;
    for( int i = 0; i < n; i++ ) {
      v[i] = cost[i] = 1919810893;
    }
    q.push(state(0,0,0));
    v[0] = cost[0] = 0;
    while( !q.empty() ) {
      state p = q.top(); q.pop();
      for( int i = 0; i < int(g[p.n].size()); i++ ) {
        edge& e = g[p.n][i];
        if( cost[e.t] > p.d+e.d ) {
          cost[e.t] = p.d+e.d;
          v[e.t] = e.c;
          q.push(state(e.t,p.d+e.d,p.c+e.c));
        }
        if( cost[e.t] == p.d+e.d ) {
          v[e.t] = min(v[e.t],e.c);
        }
      }
    }
    int res = 0;
    sort(v,v+n);
    for( int i = 0; i < n; i++ ) {
      //printf("%d:%d ",cost[i],v[i]);
      res += v[i];
    }
    //puts("");
    printf("%d\n",res);
  }
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main()
{
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];
  int count = 0;
 
  rep(i,N)
  {
    //同じならスキップ
    while(i+1 < N && A[i] == A[i+1]) i++;
    //増加
    if(i+1 < N && A[i] < A[i+1]){
      while(i+1 < N && A[i] <= A[i+1]) i++;
    }
    //減少
    else if(i+1 < N && A[i] > A[i+1]){
      while(i+1 < N && A[i] >= A[i+1]) i++;
    }
    count++;
  }
  cout << count << endl;
}

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

bool mark1[30],mark2[30];

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

	string s;
	cin>>s;


	int ans = 0;
	for(int i=0;i<n;i++){
		memset(mark1,0,sizeof(mark1));
		memset(mark2,0,sizeof(mark2));

		for(int j=0;j<=i;j++){
			mark1[s[j]-'a']=true;
		}
		for(int j=i+1;j<n;j++){
			mark2[s[j]-'a']=true;
		}
		int sum = 0;
		for(int j=0;j<26;j++){
			if(mark1[j] && mark2[j]){sum++;}
		}
		ans = max(ans,sum);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
// ALDS1_4_D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#define MAX_ITEM 1000000
#define MAX_WEIGHT 10000
using namespace std;
typedef long long llong;
int num_item, num_truck;
llong ITEM[MAX_ITEM];

//許容量Pのトラックnum_truck台にITEMがいくつまで載せられるかチェックする
//"連続する"0個以上の荷物しか載せられないので単純に許容以下なら受け入れ許容より大きいなら次のトラックに投げるだけでいい
int check(llong P) {
    int cur_item = 0;
    for (int cur_truck = 0; cur_truck < num_truck; cur_truck++) {
        llong sum_weight = 0;
        while (sum_weight + ITEM[cur_item] <= P) {
            sum_weight += ITEM[cur_item];
            cur_item++;
            //全て載せきれた=アイテム量を返す
            if (cur_item == num_item)return num_item;
        }
    }
    //載せきれなかった = いくつ乗せられたか返す
    return cur_item;
}

//二分探索で最適解に近づけていく
int solve() {
    llong left = 0;
    llong right = num_item * MAX_WEIGHT;
    llong mid;
    //rightもleftも整数型なのでright - left > 1で判定できる
    while (right - left > 1) {
        mid = (right + left) / 2;
        int v = check(mid);
        //載せきれていたらvは最適値かそれより大きい
        if (v >= num_item) right = mid;
        //載せきれていないならvは最適値未満
        else left = mid;
    }
    //leftは最適値より小さくなりrightが最適値になる
    return right;
}
int main()
{
    cin >> num_item >> num_truck;
    for (int i = 0; i < num_item; i++) std::cin >> ITEM[i];
    llong ans = solve();
    cout << ans << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します



Measured memory_bytes: 3884
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define ALL(v) v.begin(), v.end()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

	string ans = "";
	rep(i, s.size()) {
		if (s[i] == '0') ans += '0';
		if (s[i] == '1') ans += '1';
		if (s[i] == 'B' && ans.size()) ans.erase(ans.end()-1);
	}

	cout << ans << endl;
}

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

int main(void) {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < (int)S.length(); i++) {
    cout << char('A' + (S[i] - 'A' + N) % 26);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, W = map(int,readline().split())
INF = 10**31
ans = INF

# 横二回切る S1,Sw2,Sw3 Sw_min,Sw_max
# 横一回、縦一回 S1,Sh2,Sh3 Sh_min,Sh_max
def solve(H,W,ans):
    for i in range(1,H):
        S1 = i*W
        rem = H - i
        Sw2 = rem // 2 * W 
        Sw3 = (rem - rem // 2) * W
        Sw_min = min(S1,Sw2,Sw3) 
        Sw_max = max(S1,Sw2,Sw3)
        Sh2 = W // 2 *rem
        Sh3 = (W - W // 2) * rem
        Sh_min = min(S1,Sh2,Sh3)
        Sh_max = max(S1,Sh2,Sh3)
        ans = min(Sw_max-Sw_min,Sh_max-Sh_min,ans)
    return ans

ans = solve(H,W,ans)
ans = solve(W,H,ans)
print(ans)

Measured memory_bytes: 73612
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 x = sc.nextInt();
		
		if(a > x) {
			System.out.println("NO");
		}else if(a + b >= x) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21840
num=int(input())
if 400<=num<600:
    print(8)
elif 600<=num<800:
    print(7)
elif 800<=num<1000:
    print(6)
elif 1000<=num<1200:
    print(5)
elif 1200<=num<1400:
    print(4)
elif 1400<=num<1600:
    print(3)
elif 1600<=num<1800:
    print(2)
elif 1800<=num<2000:
    print(1)

Measured memory_bytes: 9184
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define in insert
#define er erase
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define mod(x) (x) %= MOD
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll
 
ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}
 
string binary(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}


//  =========     /\       /|    |====/|
//      |        /  \       |    |   / |
//      |       /____\      |    |  /  |
//      |      /      \     |    | /   |
//  ========= /        \  =====  |/====|  
//  code

int32_t main(){
    init;
    ll n,k,i,j,m,l,p;
    cin >> n >> k;
    vector<ll> a(n + 1) , b(n + 1 , -1);

    for(i = 1; i <= n; i++){
        cin >> a[i];
    }

    i = 1;
    p = 0;
    ll cyclestart = -1 , cyclelength = -1;
    while(true){
        if(b[i] == -1){
            b[i] = p;
            p++;
        }
        else{
            cyclestart = i;
            cyclelength = p - b[i];
            break;
        }
        i = a[i];
        k--;
        if(!k){
            cout << i << endc;
            return 0;
        }
    }

    // cout << k << " " << cyclelength << endc;
    k %= cyclelength;
    i = cyclestart;
    while(k > 0){
        i = a[i];
        k--;
    }
    cout << i << endc;
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int m, k, a, d;
vector<string> g;

bool solve() {
  int x = k - 1;
  rep(y, d) {
    if(g[y][x]) x++;
    else if(x && g[y][x-1]) x--;
  }
  return x == a - 1;
}

int main() {

  while(cin >> m >> k >> a >> d && m) {
    g.clear(); g.resize(d);
    rep(i, d) cin >> g[i];
    rep(i, d) for(auto& e: g[i]) e -= '0';
    if(solve()) {
      cout << "0\n";
      goto next;
    }
    rep(i, d) rep(j, m - 1) {
      if(!g[i][j] && (j == 0 || !g[i][j-1]) && (j + 1 == m - 1 || !g[i][j+1])) {
        g[i][j] = 1;
        if(solve()) {
          cout << i + 1 << " " << j + 1 << endl;
          goto next;
        }
        g[i][j] = 0;
      }
    }
    cout << "1\n";
  next:;
  }
  
  return 0;
}

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

int getgcd(int n, int m)
{
    int r;
    if (n > m)
    {
        int t = m;
        m = n;
        n = t;
    }
    while ((r = m % n) != 0)
    {
        m = n;
        n = r;
    }
    return n;
}

int main()
{
    int n;
    ll out = 0;
    cin >> n;

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            for (int k = 1; k <= n; ++k)
            {
                out += getgcd(getgcd(i, j), k);
            }
        }
    }

    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3676
use proconio::*;

fn main() {
    input! {
        n: usize,
    };

    let mut dp = vec![0; 10000005];

    let mut ans = 0;

    for i in 1..=n {
        ans += i * f(i, &mut dp);
    }

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

fn f(n: usize, dp: &mut Vec<usize>) -> usize {
    let mut res = 1;
    let mut i = 1;

    loop {
        dp[n * i] += 1;
        i += 1;
        if n * i >= dp.len() {
            break;
        }
    }

    dp[n]
}


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

int main() {
  int ans = 1;
    string s, s1, s2;
  	cin >> s;
  	s1 = s[0];
    for(int i = 1; i < s.size(); ++i) {
      s2 += s[i];
      if(s1 != s2) {
        ans++;
        s1 = s2;
        s2 = "";
      }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640