akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/
ll n, m;
vector<vector<ll> > gr;
vector<ll> v;
ll c = 0;
void dfs(ll x){
    v[x] = 1;
    c++;
    for(auto i:gr[x])
        if(!v[i])
            dfs(i);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll n, m;
    cin>>n>>m;
    gr.resize(n+1);
    for(ll i=0;i<m;i++){
        ll x, y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    ll an = 0;
    v.resize(n+1);
    for(ll i=1;i<=n;i++){
        if(!v[i]){
            c = 0;
            dfs(i);
            an = max(an, c);
        }
    }
    cout<<an<<endl;
    return 0;
}


Measured memory_bytes: 21864
use proconio::input;

fn main() {
    input!(text: String);

    let mut max = 0;
    let mut current = 0;

    for c in text.chars() {
        match c {
            'R' => {
                current += 1;
            },
            'S' => {
                max = max.max(current);
                current = 0;
            }
            _ => unreachable!()
        }
    }

    max = max.max(current);
    println!("{}", max);

}


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

int main() {
  int N, sum, n;
  cin >> N;
  n = N;
  for (int i = 0; i < 9;i++) {
    sum = sum + n % 10;
    n = n / 10;
  }
  if (N % sum == 0) {
    cout << "Yes";
  }else {
    cout << "No";
  }
  cout << endl;
}



Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        a: [Usize1; n],
        b: [i64; n],
        c: [i64; n - 1],
    };
    let mut ans = 0_i64;
    let mut p = None;
    for &a_i in a.iter() {
        ans += b[a_i];
        if let Some(i_p) = p {
            if a_i == i_p + 1 {
                ans += c[i_p];
            }
        }
        p = Some(a_i);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2128
#include <iostream>

using namespace std;

int main()
{
    int n, m;
    while (cin >> n >> m, n)
    {
        int a[n] = {0};
        int MAX = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                if (MAX < a[i] + a[j] && a[i] + a[j] <= m)
                {
                    MAX = a[i] + a[j];
                }
            }
        }
        if (MAX == 0)
        {
            cout << "NONE" << endl;
        }
        else
        {
            cout << MAX << endl;
        }
    }
}


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

int main() {
	int N;
	cin >> N;
	int f = 0;
	int p = 1;
	for (int i = 0;; i++) {
		p *= 10;
		if (N < p / 10) {
			break;
		}
		f += (N % p) * 10 / p;
	}
	if (N % f == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

int main(){
  int n,k,c=1;
  cin>>n>>k;
  fr(i,n){
    if(c>k) c+=k;
    else c*=2;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#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() {
    ll l, r;
    cin >> l >> r;
    r = min(r, l+4038);
    int ans = 2018;
    for (ll i = l; i <= r; i++) {
        for (ll j = i+1; j <= r; j++) {
            int x = i*j%2019;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    int x, n; cin >> x >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];


    int j = 0;
    bool flag;
    while(true){
        flag = true;
        for(int i = 0; i < n; i++){
            if(p[i] == x - j) flag = false;
        }
        if(flag){
            cout << x - j << endl;
            return 0;
        }
        flag = true;

        for(int i = 0; i < n; i++){
            if(p[i] == x + j) flag = false;
        }
        if(flag){
            cout << x + j << endl;
            return 0;
        }
        j++;
    }
}

Measured memory_bytes: 3628
#include <iostream>
int main() {
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  if (a+b > c+d) std::cout << "Left" << std::endl;
  else if (a+b < c+d) std::cout << "Right" << std::endl;
  else std::cout << "Balanced" << std::endl;
}


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

int main() {
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int cost1 = A * X + B * Y;
    int cost2 = 2 * X * C;
    int cost3 = 2 * Y * C;
    
    if (X < Y) cost2 += (Y - X) * B;
    if (X > Y) cost3 += (X - Y) * A;
    int mi = cost1;
    if (mi > cost2) mi = cost2;
    if (mi > cost3) mi = cost3;
    cout << mi << endl;
}

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

const int N = 2e5 + 100;

ll h[N], dp[N];

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll c;
    cin >> n >> c;
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    auto cost = [&](int i, int j) -> ll {
        ll d = h[j] - h[i];
        return dp[j] + d*d + c;
    };
    auto better_at = [&](int i, int j) -> int {
        int lo = 0, hi = i;
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            if (cost(mid, i) < cost(mid, j)) {
                lo = mid + 1;
            }
            else {
                hi = mid;
            }
        }
        return lo - 1;
    };
    deque<int> s;
    s.push_back(n-1);
    for (int i=n-2; i>=0; i--) {
        while (s.size() >= 2 && better_at(s[1], s[0]) >= i) {
            s.pop_front();
        }
        dp[i] = cost(i, s[0]);
        while (s.size() >= 2) {
            int ss = s.size();
            int old = better_at(s[ss-1], s[ss-2]);
            int cur = better_at(i, s[ss-1]);
            if (cur < old) {
                s.push_back(i);
                break;
            }
            s.pop_back();
        }
        if (s.size() == 1) {
            int cur = better_at(i, s[0]);
            if (cur >= i-1) {
                s.pop_back();
            }
            if (cur >= 0) {
                s.push_back(i);
            }
        }
    }
    cout << dp[0] << '\n';
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;++i)
using namespace std;
int n,q1,q2;
double a[86400],L,t;
bool check(double x){
  double p=L;
  r(i,86400){
    p-=a[i]-x;
    if(p>L)p=L;
    if(p<0)return 0;
  }
  double tx=p;
  r(i,86400){
    tx-=a[i]-x;
    if(tx>L)tx=L;
    if(tx<0)return 0;
  }
  return p-tx<1e-5;
}
int main(){
  while(cin>>n>>L,n){
    memset(a,0,sizeof(a));
    r(i,n){
      cin>>q1>>q2>>t;
      for(int i=q1;i<q2;i++)a[i]=t;
    }
    double r=1e11,l=0;
    r(i,77){
      double mid=(r+l)/2.0;
      if(check(mid))r=mid;
      else l=mid+1e-10;
    }
    printf("%.10f\n",l);
  }
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll a,b,c; cin>>a>>b>>c;
    ll x; cin>>x;
    ll res=0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(i*500+j*100+k*50==x) res++;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

struct Dinic {
    struct Edge {int to, rev, cap;};
    vector<vector<Edge>> Graph;
    vector<int> dist, iter;
    Dinic(int v) : Graph(v) {}
    void AddEdge(int from, int to, int cap) {
        Graph[from].push_back({to, SZ(Graph[to]), cap});
        Graph[to].push_back({from, SZ(Graph[from]) - 1, 0});
    }
    bool bfs(int s, int t) {
        dist.assign(SZ(Graph), -1);
        queue<int> q;
        dist[s] = 0;
        q.push(s);
        while (!q.empty() && dist[t] == -1) {
            int v = q.front();
            q.pop();
            for (const auto &e: Graph[v]) {
                if (e.cap > 0 && dist[e.to] == -1) {
                    dist[e.to] = dist[v] + 1;
                    q.push(e.to);
                }
            }
        }
        return dist[t] != -1;
    }
    int dfs(int now, int t, int mn) {
        if (now == t) return mn;
        for (int &i = iter[now]; i < SZ(Graph[now]); ++i) {
            Edge &e = Graph[now][i];
            if (e.cap > 0 && dist[now] + 1 == dist[e.to]) {
                int d = dfs(e.to, t, min(mn, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    Graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    int MaxFlow(int s, int t) {
        int ans = 0;
        while (bfs(s, t)) {
            iter.assign(SZ(Graph), 0);
            int f = 0;
            while ((f = dfs(s, t, 1001001001)) > 0) ans += f;
        }
        return ans;
    }
};

int main() {
    int v, e;
    cin >> v >> e;
    Dinic D(v);
    REP(i, e) {
        int u, v, c;
        cin >> u >> v >> c;
        D.AddEdge(u, v, c);
    }
    cout << D.MaxFlow(0, v - 1) << "\n";
    return 0;
}



Measured memory_bytes: 3172
s = input()
ca,cb,cc = 0,0,0
for i in range(len(s)):
    if s[i] == "a":
        ca += 1
    elif s[i] == "b":
        cb += 1
    else:
        cc += 1
mx = max(max(ca,cb),cc)
mn = min(min(ca,cb),cc)
if mx - mn >= 2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 9036
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	char c;
	cin>>c;
	int z=c+1;
	c=z;
	cout<<c<<endl;
}




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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n;
int x[100000], t[100000], y[100000];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 0; i < n; i++){
        if(t[i] >= abs(x[i]+y[i]) && t[i] % 2 == (x[i]+y[i]) % 2){
            continue;
        }
        else{
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  bool zero = false;
  rep(i, N) {
    cin >> A[i];
    if(A[i] == 0) zero = true;
  }
  if(zero) cout << 0 << endl;
  else {
    ll ans = 1;
    ll tmp = ans;
    rep(i, N) {
      ans *= A[i];
      if(ans < tmp || ans > 1000000000000000000LL) {
        cout << -1 << endl;
        return 0;
      }
      tmp = ans;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define int long long
int calc(int c,int d,int n,int k){
  return c*(n-1-k)-d*k;
}
signed main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  int x=abs(b-a);
  int tmp=(d-c)*(n-1);
  int l=0,r=n-1;
  while(l+1<r){
    int m=(l+r)/2;
    if(x<calc(c,d,n,m)) l=m;
    else r=m;
  }
  bool flg=0;
  for(int i=max(0LL,l-10);i<=min(n-2,r+10);i++){
    if(x<calc(c,d,n,i)) continue;
    //cout<<i<<":"<<x<<" "<<calc(c,d,n,i)<<" "<<tmp<<endl;
    flg|=x-calc(c,d,n,i)<=tmp;
  }
  if(flg) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <iterator>

using namespace std;

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

	int max = a + b;

	if (max < a - b)
	{
		max = a - b;
	}
	
	if (max < a * b)
	{
		max = a * b;
	}

	cout << max << endl;
	
	return 0;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
 double a , c ;
 cin >> a>> c ;
 cout << (c*2.0)-a ;

return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define llint long long
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

const int FACT_MAX = 200005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

llint n, m, k;

int main(void)
{
	cin >> n >> m >> k;
	
	llint C = 1;
	for(int i = 0; i < k-2; i++){
		C *= (n*m-2-i), C %= mod;
		C *= modpow(i+1, mod-2), C %= mod;
	}
	if(k == 2) C = 1;
	//cout << C << endl;
	
	llint ansx = 0;
	for(llint i = 1; i <= m; i++){
		ansx += (m-i)*i%mod, ansx %= mod;
	}
	ansx *= n*n%mod, ansx %= mod;
	ansx *= C, ansx %= mod;
	
	llint ansy = 0;
	for(llint i = 1; i <= n; i++){
		ansy += (n-i)*i%mod, ansy %= mod;
	}
	ansy *= m*m%mod, ansy %= mod;
	ansy *= C, ansy %= mod;
	
	cout << (ansx+ansy)%mod << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int c[9];
  for ( int i = 0; i < 9; i++ ) std::cin >> c[i];

  if ((c[1] - c[0] == c[4] - c[3]) && (c[4] - c[3] == c[7] - c[6]) && (c[2] - c[1] == c[5] - c[4]) &&(c[5] - c[4] == c[8] - c[7])) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
}


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

int main() {
	int a[3], b[3];
	bool list[4][4] = {0};
	for (int i = 0; i < 3; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		list[a[i]][b[i]] = list[b[i]][a[i]] = true;
	}
	
	bool used[4] = {};
	used[0] = true;
	bool ans = false;
	for (int i = 0; ; ) {
		bool flag = false;
		for (int j = 0; j < 4; j++) {
			if (used[j])continue;
			if (list[i][j]) {
				flag = true;
				i = j;
				used[j] = true;
				break;
			}
		}
		if (!flag)break;
		if (used[1] && used[2] && used[3]) {
			ans = true;
			break;
		}
	}
	if (ans)cout << "YES" << endl;
	else cout << "NO" << endl;

}

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

int gcd(int m,int n){
 if(n==0)return m;

 return gcd(n,m%n);
}

int main(){
 int W,H,C;
 cin>>W>>H>>C;

 int g=gcd(W,H);

 cout<<W/g*H/g*C<<endl;

return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int R, G, B, N;

int main(){
	cin >> R >> G >> B >> N;
	int res = 0;
	for(int i = 0; i * R <= N; i++){
		for(int j = 0; j * G <= N; j++){
			if((N - i * R - j * G) % B != 0) continue;
			if((N - i * R - j * G) / B >= 0) res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        long[] tmp = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).OrderByDescending(a=>a).ToArray();
        long ans = 0;

        while(tmp[0]>itemCount-1 && tmp[0]-tmp.Last()>=itemCount) {
			long diff = tmp[0] - (tmp.Length - 1);
            long div = diff / tmp.Length;
            if (diff % tmp.Length > 0)
			{
				div++;
			}
			tmp[0] -= (itemCount) * div;
            for (int i = 1; i < itemCount; i++) {
                tmp[i] += div;
            }
            ans += div;
            tmp = tmp.OrderByDescending(a => a).ToArray();
		}
        if(tmp.Last()>=itemCount) {
            long addAns = tmp.Last() - (itemCount - 1);
            tmp = tmp.Select(a => a - addAns).ToArray();
            ans += addAns*tmp.Length;
        }
        while(tmp[0]>itemCount-1) {
            tmp = tmp.Select(a => a + 1).ToArray();
            tmp[0] -= (itemCount + 1);
            tmp = tmp.OrderByDescending(a => a).ToArray();
            ans++;
        }
        Console.WriteLine(ans);

    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

10
1000 193 256 777 0 1 1192 1234567891011 48 425


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 17616
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

next_minus = 0
total = 0
for i in range(N):
    targets = A[i] - next_minus
    rest = B[i] - targets

    total += B[i]
    if rest > 0:
        if A[i+1] > rest:
            next_minus = rest
        else:
            next_minus = A[i+1]
            total -= (rest - A[i+1])
    else:
        next_minus = 0
    
print(total)

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

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

const long long INF = 1LL << 60;

vector<vector<long long>> dp(110, vector<long long>(100001, 0));

struct Item {
    long long w, v;
};

int main() {
    int N, W;
    cin >> N >> W;
    vector<Item> I(N + 1);
    for (int i = 1; i <= N; i++) {
        scanf("%lld%lld", &I[i].w, &I[i].v);
    }

    for (int i = 1; i <= N; i++) {
        for (int w = 1; w <= W; w++) {
            if (I[i].w <= w) {
                chmax(dp[i][w], dp[i - 1][w - I[i].w] + I[i].v);
            }
            chmax(dp[i][w], dp[i - 1][w]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,W,T;
int w[10],v[10];
int X[10],Y[10];
vector<int>lis[10],cost[10];

int tabled[1<<7],tablev[1<<7];

int F[10010];

void pre_calc(int b){
    memset(F,0,sizeof(F));
    rep(i,N){
        if(!(b>>i&1))continue;
        rep(j,W){
            rep(k,lis[i].size()){
                int vv=v[lis[i][k]]-cost[i][k];
                int ww=w[lis[i][k]];
                if(j+ww<=W)chmax(F[j+ww],F[j]+vv);
            }
        }
    }

    vector<int>p;
    rep(i,N)if(b>>i&1)p.pb(i);

    int min_dist=1001001001;
    do{
        int dist=0;
        rep(i,p.size()-1){
            dist+=abs(X[p[i+1]]-X[p[i]])+abs(Y[p[i+1]]-Y[p[i]]);
        }
        dist+=abs(X[p[0]])+abs(Y[p[0]]);
        dist+=abs(X[p[p.size()-1]])+abs(Y[p[p.size()-1]]);
        chmin(min_dist,dist);
    }while(next_permutation(all(p)));

    tabled[b]=min_dist;
    tablev[b]=F[W];
}

signed main(){
    cin>>N>>M>>W>>T;
    vector<string>hoge(M);
    rep(i,M){
        cin>>hoge[i]>>w[i]>>v[i];
    }
    rep(i,N){
        int l;
        cin>>l>>X[i]>>Y[i];
        lis[i].resize(l);cost[i].resize(l);
        rep(j,l){
            string s;
            cin>>s>>cost[i][j];
            lis[i][j]=find(all(hoge),s)-hoge.begin();
        }
    }

    reps(i,1,1<<N)pre_calc(i);

    memset(F,0,sizeof(F));
    rep(i,1<<N){
        for(int j=0;j<=T;j++){
            if(j+tabled[i]<=T){
                chmax(F[j+tabled[i]],F[j]+tablev[i]);
            }
        }
    }

    cout<<F[T]<<endl;
    return 0;
}

Measured memory_bytes: 3308
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int H, W, N;
  cin >> H >> W >> N;
  cout << ceil((double)N / max(H, W)) << endl;
  return 0;
}

Measured memory_bytes: 888
def is_month(mm):
    if 1 <= mm <= 12:
        return True
    return False


s = input()
yy, mm = s[:2], s[2:]
yy = int(yy)
mm = int(mm)


if is_month(yy) and is_month(mm):
    print('AMBIGUOUS')
elif is_month(yy):
    print('MMYY')
elif is_month(mm):
    print('YYMM')
else:
    print('NA')


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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  ll n;
  cin >>  n;
  string s;
  cin >> s;
  
  int wCountR = 0;
  int rCountR = 0;
  for(auto c:s){
    if('W'==c)wCountR++;
    else rCountR++;
  }
  
  int wCountL = 0;
  int rCountL = 0;

  int minCount = 200001;
  for(int i=0;i<=n;i++){
    minCount = min(minCount,max(wCountL,rCountR));
    if(i==n)break;
    if('W'==s[i]){
      wCountL++;
      wCountR--;
    }
    else{
      rCountL++;
      rCountR--;
    }
  }
  cout << minCount << endl;
  
  return 0;
}



Measured memory_bytes: 3820
def power_func(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, p)
        return d * d % p
    if b % 2 == 1:
        return (a * power_func(a, b - 1, p)) % p

S = input()
ansl = [0]*2019
temp = 0
for i in range(len(S)):
    temp = (temp+int(S[-i-1])*power_func(10,i,2019))%2019
    ansl[temp]+=1
ans = (ansl[0]+1)*ansl[0]/2

for i in range(1, 2019):
    ans+=ansl[i]*(ansl[i]-1)/2

print(int(ans))

Measured memory_bytes: 9208
#include "bits/stdc++.h"
using namespace std;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll ;
typedef long double ldb ;
 
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl "\n"
 
#define all( x ) x.begin(),x.end()
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );

int main( ) {
	timesaver ;
	int r;
	cin >> r;
	cout << (float)44*r/7;
  return 0;
}

Measured memory_bytes: 3796
# abc134_c
n = gets.to_i

va = []
va2 = []
n.times do |i|
  v =  gets.to_i
  va << v
  va2 << v
end

va2.sort!
va2.reverse!
for v in va do
  puts v != va2[0] ? va2[0]: va2[1]
end



Measured memory_bytes: 10940
H, W = map(int, input().split())
sList = []
xList = [1, 1, 0, -1, -1, -1, 0, 1]
yList = [0, 1, 1, 1, 0, -1, -1, -1]

for i in range(H):
    sList.append(input())

for i in range(H):
    tmplist = list(sList[i])
    for j in range(W):
        if sList[i][j] == '#':
            continue

        tmpCnt = 0
        for k in range(8):
            tmpi = i + yList[k]
            tmpj = j + xList[k]
            if tmpi < 0 or tmpi >= H:
                continue
            if tmpj < 0 or tmpj >= W:
                continue
            if sList[tmpi][tmpj] == '#':
                tmpCnt += 1

        tmplist[j] = str(tmpCnt)
    print(''.join(tmplist))

Measured memory_bytes: 3064
function main(input){
	const args=input.split(' ');
	const a=parseInt(args[0],10);
	const b=parseInt(args[1],10);
	
	if((a*b)%2===0){
		console.log('Even');
	}else{
		console.log('Odd');
	}
		
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29544
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

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

  int N; cin >>N;
  vi A(N);
  vll B(N+1);
  int mod=pow(10,9)+7;
  rep(i,0,N) {
    cin >>A[i];
    B[i+1]=B[i]+A[i];
  }
  ll ans=0;
  rep(i,0,N) {
    ll sum=(B[N]-B[i+1])%mod;
    ans+=A[i]*sum;
    ans%=mod;
  }
  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<ll> p(A), q(B), r(C);
	priority_queue<pair<ll, int>> pq;
	REP(i, A) {
		cin >> p[i];
		pq.emplace(p[i], 0);
	}
	REP(i, B) {
		cin >> q[i];
		pq.emplace(q[i], 1);
	}
	REP(i, C) {
		cin >> r[i];
		pq.emplace(r[i], 2);
	}
	int num[3] = { 0 };
	stack<ll> st[3];
	ll res = 0;
	REP(i, X + Y) {
		ll x;
		int idx;
		tie(x, idx) = pq.top();
		pq.pop();
		res += x;
		num[idx]++;
		st[idx].emplace(x);
	}
	if (num[0] > X) {
		int n = num[0] - X;
		REP(i, n) {
			res -= st[0].top();
			st[0].pop();
			while (true) {
				ll x;
				int idx;
				tie(x, idx) = pq.top();
				pq.pop();
				if (idx != 0) {
					res += x;
					break;
				}
			}
		}
	}
	else if (num[1] > Y) {
		int n = num[1] - Y;
		REP(i, n) {
			res -= st[1].top();
			st[1].pop();
			while (true) {
				ll x;
				int idx;
				tie(x, idx) = pq.top();
				pq.pop();
				if (idx != 1) {
					res += x;
					break;
				}
			}
		}
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 12780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
   string a, b, c;
   cin >> a >> b >> c;
   cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
   return 0;
}


Measured memory_bytes: 256
s = input()
s_len = len(s)
ans = 0
for i in range(2 ** (s_len - 1)):
    shiki = ""
    # print("pattern {}: ".format(i), end="")
    for j in range(s_len):
        shiki += s[j]
        if i>>j & 1:
            shiki += '+'
    ans += eval(shiki)
    # print(shiki)
print(ans)

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

int main(){
    int a, b;
    char op;
    while (true)
    {
        cin >> a >> op >> b;
        if(op == '?') break;
        else if(op == '+') cout << a + b << endl;
        else if(op == '-') cout << a - b << endl;
        else if(op == '*') cout << a * b << endl;
        else if(op == '/') cout << a / b << endl;
    }
    
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = A * X + B * Y;
    ll max_cnt = max(X, Y) + 1;
    rep(i, max_cnt) {
        ll now = A * max(0LL, X - i) + B * max(0LL, Y - i) + C * 2 * i;
        chmin(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

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

  ll d = c - a - b;
  if(d > 0 && d * d > 4 * a * b){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static long gcd(long a,long b) {
        long temp;
        while ((temp=a%b)!=0) {
            a=b;
            b=temp;
        }
        return b;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = Integer.parseInt(sc.next());
        long B = Integer.parseInt(sc.next());
        System.out.println(A*B/gcd(A, B));
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
int main ()
{
  int n;
  scanf ("%d",&n);
  int i,j=1; 

  while (j)
  {
    i = (j*1000) - n;
  if (i>=0)break;

  j++;
  
  }printf("%d\n",i);
    
return 0;}

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

#define lli long long int
#define BIG 1000000007
void debug_c(char **dp, int h, int w)
{
	printf("----debug\n");
	int i = 0;
	int j = 0;
	while (i < h)
	{
		j = 0;
		while (j < w)
		{
			printf("%d,",dp[i][j]);
			j++;
		}
		printf("\n");
		i++;
	}
	printf("----debug\n");
}
void debug(int **dp, int h, int w)
{
	printf("----debug\n");
	int i = 0;
	int j = 0;
	while (i < h)
	{
		j = 0;
		while (j < w)
		{
			printf("%d",dp[j][i]);
			j++;
		}
		printf("\n");
		i++;
	}
	printf("----debug\n");
}
int main(void)
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i = 0;
	int j = 0;
	char **a;
	int **dp;
	a = (char **)malloc(sizeof(char *)*(h));
	dp = (int **)malloc(sizeof(int *)*(w));
	while (i < w)
	{
		dp[i] = (int *)malloc(sizeof(int)*(h));
		i++;
	}
	while (j < h)
	{
		a[j] = (char *)malloc(sizeof(char)*(w));
		j++;
	}
	i = 0;
	j = 0;
	while (i < h)
	{
		j = 0;

		scanf("%s",a[i]);
		while (j < w)
		{
			dp[j][i] = 0;
			if(a[i][j] == '#')
			{
				dp[j][i] = -1;
			}
			j++;
		}
		i++;
	}
//	debug_c(a,h,w);
//	debug(dp,h,w);
	dp[0][0] = 1;
	i = 1;
	j = 1;
	while (i < h)
	{
		if(dp[0][i] == -1)
		{
			dp[0][i] = 0;
		}
		else
		{
			dp[0][i] = dp[0][i-1];
		}
		i++;
	}
	while (j < w)
	{
		if(dp[j][0] == -1)
		{
			dp[j][0] = 0;
		}
		else
		{
			dp[j][0] = dp[j-1][0];
		}
		j++;
	}

	i = 1;
	j = 1;
	while (i< h)
	{
		j = 1;
		while (j < w)
		{
			if(dp[j][i] == -1)
			{
				dp[j][i] = 0;
			}
			else
			{
				dp[j][i] = (dp[j-1][i]+dp[j][i-1])%BIG;
			}
			j++;
		}
		i++;
	}
//	debug(dp,h,w);
	printf("%d\n",dp[w-1][h-1]);
	return (0);
}


Measured memory_bytes: 5120
from itertools import combinations as com
def comb(a,b):
  if a == 0:
    return 1
  r = 1
  for i in range(b):
    r *= a
    a -= 1
  r = r // [1,2,6][b-1]
  return r
n = input()
nl = len(n)
k = int(input())
i = 0
c = 0
while i < nl:
  if i+1 >= nl:
    break
  if i+1 < k:
    pass
  else:
    if k == 1:
      c += 9
    elif k == 2:
      c += 81 * i
    else:
      c += 729 * (i*(i-1))//2
  i += 1
lis = []
if k == 1:
  for cur in range(1,10):
    cur = cur * 10**i
    lis.append(cur)
elif k == 2:
  for j in range(i):
    for k in range(1,10):
      for cur in range(1,10):
        cur = cur * 10**i + k * 10**j
        lis.append(cur)
else:
  for j,k in com(range(i),2):
    for l in range(1,10):
      for m in range(1,10):
        for cur in range(1,10):
          if cur < int(n[0]):
            c += 1
          else:
            cur = str(cur) + '0'*(i-k-1) + str(l) + '0'*(k-j-1) + str(m) + '0'*j
            if cur <= n:
              c += 1
n = int(n)
for i in lis:
  if i <= n:
    c += 1
print(c)

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=2e5+5;
const int mod=2019;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

char s[N];
int n,sum[N];
int box[N];
ll ans;

int main()
{
    // cout<<1817*100000%mod<<endl;
    scanf("%s",s+1);
    n=strlen(s+1);
    int ten=1;
    _Rep(i,n,1)sum[i]=sum[i+1]+ten*(s[i]-'0'),sum[i]%=mod,ten*=10,ten%=mod;
    // Rep(i,1,n)printf("%d%c",sum[i],i==n?'\n':' ');
    Rep(i,0,n)box[sum[i]]++;
    Rep(i,0,2019)ans+=1ll*box[i]*(box[i]-1)/2;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,x;
    cin>>n>>x;
    if(x==1||x==2*n-1) cout<<"No";
    else{
        cout<<"Yes"<<endl;
        vector<int> A,B;
        rep(i,2*n-1) B.push_back(i+1);
        B.erase(B.begin()+x),B.erase(B.begin()+x-1),B.erase(B.begin());
        B.insert(B.begin()+n-2,x+1),B.insert(B.begin()+n-2,x),B.insert(B.begin()+n-2,1);
        rep(i,2*n-1) cout<<B[i]<<endl;
    }
}

Measured memory_bytes: 2420
import java.util.*;

// "static void main" must be defined in a public class.
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        if(A + B == 0){
            System.out.println(0);
        }
        long sum = N / (A + B) * A + Math.min(N % (A + B), A);
        System.out.println(sum);
    }
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace FunProCon
{
    class FunProConSummer
    {
        static void Main(string[] args)
        {
            string[] s = ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[2]);
            if (s[1] == "+")
            {
                WriteLine(a+b);
            }
            else
            {
                WriteLine(a - b);
            }

        }

    }
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i, 0, n)cin >> a[i];
    rep(i, 0, n-k){
        if(a[k+i]>a[i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a;
  cin >>a;
  
  cout << (a-1)/2 <<endl;
    
}


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

int main(){
	double x1, y1, x2, y2, xq, yq, x, y;
	
	while( scanf(" %lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF){
	
		if(x1==x2){ //y軸と平行
			y=yq;		
			x=2*x1-xq;
		}
		else if(y1==y2){ //x軸と平行
			x=xq;
			y=2*y1-yq;
		}
		else{
			double m=(y1-y2)/(x1-x2);
			double n=-1.0/m;
			
			double b1=y1-m*x1, b2=yq-n*xq;
			double xm=(b2-b1)/(m-n);
			double ym=n*xm+b2;
			
			x=2*xm-xq;
			y=2*ym-yq;
		}
		
		printf("%lf %lf\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main(void){
  double w,h,x,y;
  scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
  double q=w*h/2;
  if(x==w/2&&y==h/2){
    printf("%lf 1",q);
  }
  else{
    printf("%lf 0",q);
  }
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main()
{
	int n,m;
	string u,t;
	set<string>s;
	for(cin>>n;n--;)
	{
		cin>>u;
		s.insert(u);
	}
	bool f=0;
	for(cin>>m;m--;)
	{
		cin>>t;
		if(s.find(t)==s.end())
			cout<<"Unknown ";
		else
		{
			if(f)cout<<"Closed by ";
			else cout<<"Opened by ";
			f=!f;
		}
		cout<<t<<endl;
	}
	return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    string s;
    cin>>s;
    n=s.length();
    set<char> o,e;
    rep(i,0,n) {
        if(i%2==0) o.insert(s[i]);
        else e.insert(s[i]);
    }    
    for(auto it:o){
        if(it=='L') ret("No")
    }
    for(auto it:e){
        if(it=='R') ret("No")
    }
ret("Yes")
    return 0;
}

Measured memory_bytes: 256
<?php
    $p = explode(' ', trim(fgets(STDIN)));
    $k = $p[0];
    $n = $p[1];
    
    $arr = explode(' ', trim(fgets(STDIN)));
    sort($arr);
    $sum = 0;
    for($i = 0; $i < $n; $i++){
        $sum += $arr[$i];
    }
    echo $sum;

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

using namespace std;
using ll = long long;

int main() {
	const ll INF = 1e18;
	ll L;
	cin >> L;
	vector<ll> A(L + 1);
	for (int i = 1; i <= L; ++i) { cin >> A[i]; }

	vector<vector<ll>> dp(L + 1, vector<ll>(5, INF));
	dp[1][0] = A[1];
	dp[1][1] = A[1] % 2;
	if (A[1] == 0) { dp[1][1] = 2; }
	dp[1][2] = 1 - (A[1] % 2);
	for (int i = 2; i <= L; ++i) {
		for (int j = 0; j < 5; ++j) {
			ll tmp = INF;
			for (int k = 0; k <= j; ++k) { tmp = min(tmp, dp[i - 1][k]); }

			dp[i][j] = tmp;
			if ((j == 0) || (j == 4)) { dp[i][j] += A[i]; }
			if ((j == 1) || (j == 3)) { 
				if (A[i] == 0) { dp[i][j] += 2; }
				else { dp[i][j] += (A[i] % 2); }
			}
			if (j == 2) {
				dp[i][j] += (1 - (A[i] % 2));
			}
		}
	}

	ll res = INF;
	for (int i = 0; i < 5; ++i) { res = min(res, dp[L][i]); }

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N = 400 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll d[N][N], p[N][N], a[N];
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    ll n, k;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        d[i][i] = a[i];
    }
    for(int s = 2; s <= n; s++)
    {
        for(int l = 1; l + s - 1 <= n; l++)
        {
            int r = l + s - 1;
            p[l][r] = 1e18;
            for(int i = l; i < r; i++)
            {
                if(p[l][r] > p[l][i] + p[i + 1][r] + d[l][i] + d[i + 1][r])
                {
                    d[l][r] = d[l][i] + d[i + 1][r];
                    p[l][r] = p[l][i] + p[i + 1][r] + d[l][r];
                }
            }
        }
    }
    cout << p[1][n];
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

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

  bool flag = true;
  rep(i,n){
    if(a[i]%2 == 0){
      if(a[i]%3 != 0 && a[i]%5!=0){
	flag = false;
      }
    }
  }
  
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
  return 0;
}


Measured memory_bytes: 3612
#!/usr/bin/env run-cargo-script

#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(x: u32, t: u32) -> u32 {
    if x < t { 0 } else { x - t }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352