akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int tri(int a,int b, int c){
    if((a < (b + c)) && (b < (c + a)) && (c < (a + b))){
        return 1;
    }else{
        return 0;
    }
}
 
int main() {
    int N, ans = 0;
    cin >> N;

    int L[N];
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L,L+N,greater<int>());

    for (int i = 0; i + 2 < N; i++)
    {
        for (int j = i + 1; j + 1 < N; j++)      
        {
            for (int k = j + 1; k < N; k++)
            {
                if(tri(L[i], L[j], L[k])){
                    ans++;
                }else{
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j;
  int n,q;
  cin >> n >> q;
  dsu d(n);
  while(q--){
      int t,u,v;
      cin >> t >> u >> v;
      if(t == 0) d.merge(u,v);
      else if(d.same(u,v)) cout<<1<<endl;
      else cout<<0<<endl;
  }
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
using Graph = vector<vector<int>>;
Graph G;
int n, u, v;
//vは今見ている頂点　pはその親
//uからの距離
int dis[100010];
int cnt = 0;
int dis2[100010];
bool ok[100010];
int dfs(int v, int p)
{
    for (auto np : G[v])
    {
        if (np == p)
            continue;
        if(ok[v]){
            dis[np] = dis[v] + 1;
            ok[np] = true;
        }
        else{
            dis[np] = dis[v] + 1;
        }
        dfs(np, v);
    }
}
bool ok2[100010];
int dfs2(int v, int p)
{
    for (auto np : G[v])
    {
        if (np == p)
            continue;
        if (ok2[v])
        {
            dis2[np] = dis2[v] + 1;
            ok2[np] = true;
        }
        else
        {
            dis2[np] = dis2[v] + 1;
        }
        dfs2(np, v);
    }
}
signed main()
{
    cin >> n >> u >> v;
    u--, v--;
    ok[u] = true;
    ok2[v] = true;
    G.assign(n, vector<int>());
    for (int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);

    }
    dfs(v, -1);
    dfs2(u, -1);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(dis[i]>=dis2[i]){
            chmax(ans, dis[i]);
        }
    }
    cout << ans - 1 << endl;

    return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 1e6 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll ps[N];

ll nCr(ll n, ll r){
	if(ps[n] - ps[r] - ps[n - r]) return 0;
	return 1;
	return min(1ll, ps[n] - ps[r] - ps[n - r]);
}

ll n, a[N];

ll Solve(){
	ll res = 0;
	for(int i = 0; i < n; i++) res ^= nCr(n - 1, i) * (a[i] & 1);
	return res;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ps[0] = 0;
	for(int i = 1; i < N; i++) ps[i] = ps[i - 1] + __builtin_ctz(i);
	cin >> n;
	char c;
	for(int i = 0; i < n; i++){
		cin >> c;
		a[i] = c - '1';
	}
	if(Solve() == 1) return cout << "1\n", 0;
	for(int i = 0; i < n; i++){
		if(a[i] == 1) return cout << "0\n",0 ;
		a[i] /= 2;
	}
	cout << Solve() * 2 << '\n';
	return 0;
}


Measured memory_bytes: 15872
import math
A, B = map(int, input().split())


def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    a.sort()
    return a

#「公約数は最大公約数の約数」
# ans = 最大公約数の素因数の個数

# A,Bの最大公約数
temp = math.gcd(A, B)
# 最大公約数を素因数分解する
temp = prime_factorize(temp)
# setにして重複除く
temp = set(temp)
# 長さを取得
ans = len(list(temp))

print(ans)


Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll k,q; cin >> k >> q;
	vl d(k); rep(i,k) cin >> d[i];
	while(q--){
		ll n,x,m; cin >> n >> x >> m;
		ll s = 0;
		vl e(k);
		ll cnt = 0;
		rep(i,k){
			e[i] = d[i] % m;
			if(e[i] == 0) cnt++;
			s += e[i];
		}
		ll qq = (n-1) / k;
		ll rr = (n-1) % k;
		ll ss = 0;
		cnt *= qq;
		ll now = x + qq * s;
		rep(i,rr){
			if(e[i]==0) cnt++;
			now += e[i];
		}
		ll ans = n-1 - cnt - (now/m - x/m);
		cout << ans << endl;
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

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

    if (s.size() <= k) {
        cout << s << "\n";
    } else {
        string ans = s.substr(0, k);
        ans += "...";
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int n = s.length();
      int[] dp = new int[n];
      dp[0]=1;
      if(n>=2&&s.substring(0,1).equals(s.substring(1,2)))dp[1]=1;
      else if(n>=2)dp[1]=2;
      if(n>=3&&s.substring(1,2).equals(s.substring(2,3)))dp[2]=2;
      else if(n>=3&&dp[1]==1)dp[2]=2;
      else if(n>=3)dp[2]=3;
      for(int i = 3;i <= n-1;i++){
      	if(s.substring(i-1,i).equals(s.substring(i,i+1)))dp[i]=dp[i-3]+2;
        else dp[i]=dp[i-1]+1;
      }
      System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 42984
#include <stdio.h>
#include <string.h>

#define N 1000
#define max(a,b) ( a > b ? a : b )

int main(void)
{
    int iii, i, j, m, n;
    char x[N], y[N];
    int table[N+1][N+1];
    int num;
    scanf( "%d", &num );

    for( iii=0; iii<num; ++iii ) {
        scanf( "%s", x );
        scanf( "%s", y );

        m = strlen(x);
        n = strlen(y);

        for( i=0; i<=m; ++i )
            for( j=0; j<=n; ++j )
                table[i][j] = 0;

        for( i=1; i<=m; ++i )
            for( j=1; j<=n; ++j )
                if ( x[i-1] == y[j-1] )
                    table[i][j] = table[i-1][j-1] + 1;
                else
                    table[i][j] = max( table[i][j-1], table[i-1][j] );

        printf( "%d\n", table[m][n] );
    }

    return 0;
}

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

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, k;
	cin >> n >> k;

	if(k == 1){
		cout << 0 << endl;
	}else{
		cout << n - k << endl;
	}

}


Measured memory_bytes: 764
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>

using namespace std;

int main(void) {
	int N, T, minprice, maxgain, cost;
	vector<int> A(100000), m(100000);
	
	cin >> N >> T;

	for (int i = 0; i < N; i++) cin >> A[i];

	minprice = INT_MAX;
	maxgain = -INT_MAX;
	for (int i = 0; i < N; i++) {
		minprice = min(minprice, A[i]);
		m[i] = A[i] - minprice;
		if (maxgain < m[i]) maxgain = m[i];
	}

	cost = 0;
	for (int i = 0; i < N; i++) if (maxgain == m[i]) cost++;

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
using namespace std;

int main(){

    char c[100];
    cin>>c;
    char a[]="ABC";
    char b[]="ARC";
    if(strcmp(c,a)==0){
        cout<<b;
    }
    else if(strcmp(c,b)==0){
        cout<<a;
    }
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
#include <functional>
using namespace std;

int main() {
	int A[2][100];
	int max = 0;
	int N;
	int sum[2][100];

	cin >> N;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
			if (i == 0) {
				if (j == 0) {
					sum[i][j] = A[i][j];
				}
				else {
					sum[i][j] = A[i][j] + sum[i][j - 1];
				}
			}
		}
	}
	sum[1][N - 1] = A[1][N-1];
	for (int i = N-2; i >= 0;i--) {
		sum[1][i] = A[1][i] + sum[1][i + 1];
	}
	for (int i = 0; i < N; i++) {
		if (sum[0][i] + sum[1][i] > max) {
			max = sum[0][i] + sum[1][i];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i = 0; 7 * i <= N; ++i) {
        if ((N - 7 * i) % 4 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    
    long long k;
    cin>>k;
    long long n;
    cin>>n;

    long long A[n];

    rep(i,n)cin>>A[i];

    long long sum[2*n];

    rep(i,2*n){
        sum[i]=A[i%n]+k*(i/n);
    }
    long long ans=INF;
    rep(i,n){
        ans=min(ans,sum[i+n-1]-sum[i]);
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] values = line.split(" ");
        long n = Long.parseLong(values[0]);
        long a = Long.parseLong(values[1]);
        long b = Long.parseLong(values[2]);
        long ta = n % (a + b);
        long tb = n / (a + b);
        long tc = 0;
        if (ta >= a) {
            tc = a;
        } else {
            tc = ta;
        }
        System.out.println(((tb * a) + tc));
    }
}

Measured memory_bytes: 23252
package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	cnt := 0
	nw := 0
	for i, c := range s {
		if c == 'W' {
			cnt += i - nw
			nw += 1
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <bitset>
#include <cstdlib>
#include <cstdio>
#include <string>

using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double

int check(string str)
{
    // Compute sum of digits
    int n = str.length();
    int digitSum = 0;
    for (int i=0; i<n; i++)
        digitSum += (str[i]-'0');

    // Check if sum of digits is divisible by 9.
    return (digitSum % 9 == 0);
}

// Driver code
int main()
{
    string str = "";
    cin>>str;
    check(str)?  cout << "Yes" : cout << "No ";
    return 0;
}

Measured memory_bytes: 3352
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
int mul[214514];
int divi[214514];
#define inf 1000000007
int bit[114514],n;
struct edge{int u,v,cost;};
edge es[214514];
int zero=0;
int dp[55][55][3000];
string alph("abcdefghijklmnopqrstuvwxyz");


signed main(){
    int n,m;cin>>n>>m;
    int g=m/n;
    int count=1;
    int ans=0;
    while(count<=g){
        ans++;
        count*=2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = (1 << 17) + 5;
const int maxm = maxn - 5;
const int mod = 1e9 + 7;
ll invf[maxn],f[maxn];
ll dp[20][maxn];
ll n,m,a[20];
ll mypow(ll a,ll b)
{
	ll res = 1;
	for(;b;b >>= 1,a = a * a % mod)
	{
		if(b & 1)
		{
			res = res * a % mod;
		}
	}
	return res;
}
ll c(ll n,ll k)
{
	if(n < k)
	{
		return 0;
	}
	return f[n] * invf[k] % mod * invf[n - k] % mod;
}
void init()
{
	f[0] = 1;
	for(int i = 1;i <= maxm; ++i)
	{
		f[i] = f[i - 1] * i % mod;
	}
	invf[maxm] = mypow(f[maxm],mod - 2);
	for(int i = maxm;i >= 1; --i)
	{
		invf[i - 1] = invf[i] * i % mod;
	}
	invf[0] = 1;
	dp[0][0] = 1;
}
ll getbit(ll state)
{
	ll res = 0;
	while(state)
	{
		res += state & 1;
		state >>= 1;
	}
	return res;
}
int main(int argc, char const *argv[])
{
	scanf("%lld%lld",&n,&m);
	for(int i = 1;i <= m; ++i)
	{
		scanf("%lld",&a[m - i + 1]);
	}
	init();
	int final = (1 << n);
	for(int i = 0;i < m; ++i)
	{
		for(int state = 0;state < final; ++state)
		{
			if(dp[i][state])
			{
				(dp[i + 1][state] += dp[i][state]) %= mod;
				for(int j = 0;j < n; ++j)
				{
					if(((1 << j) & state) == 0)
					{
						(dp[i + 1][state | (1 << j)] += 
							(dp[i][state] * f[(1 << j)] % mod * 
							c(final - state - a[i + 1],
							(1 << j) - 1)) % mod) %= mod;
					}
				}
			}
		}
	}
	ll ans = 0;
	for(int state = 0;state < final; ++state)
	{
		ll cnt = getbit(state);
		ll fg = (cnt & 1) ? -1 : 1;
		(ans += fg * dp[m][state] * f[final - state - 1] % mod) %= mod;
	}
	ans = (ans + mod) % mod;
	printf("%lld\n",(ans * final) % mod);
	return 0;
}

Measured memory_bytes: 18688
N, M = map(int, input().split())

Red = [0]*N
Red[0] = 1
Num = [1]*N

for i in range(M):
  In, Out = map(int, input().split())
  In -= 1
  Out -= 1
  Num[In] -= 1
  Num[Out] += 1
  if Red[In]:
    Red[Out] = 1
  if Num[In] == 0:
    Red[In] = 0

print(sum(Red))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
int main() {
    int x , y;
    cin >> x >> y;
    if(y%2==0&&y<=4*x&&y>=2*x){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
        return 0;
    }
}

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

int n;
int x[101];
int y[101];
int h[101];      

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> h[i];
    int Cx, Cy, H;
	int Cx_ans, Cy_ans, H_ans;
	
	for (int i = 0; i <= 100; ++i){
		for(int j = 0; j <= 100; ++j){
			Cx = i;
			Cy = j;
			for(int k = 0; k < n; ++k){
				if(h[k] > 0){
					H = h[k] + abs(x[k] - Cx) + abs(y[k] - Cy);
					break;
				}
				if(k == n-1) H = 0;
			}

			for(int k = 0; k < n; ++k){
				if(h[k] != max(H - abs(x[k] - Cx) - abs(y[k] - Cy), 0)) break;
				if(k == n-1){
					Cx_ans = Cx;
					Cy_ans = Cy;
					H_ans = H;
					goto Goal;
				}
			}
		}
	}
	Goal: cout << Cx_ans << " " << Cy_ans << " " << H_ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
 
    int ans = 0;
    int tmp = 0;
    for(int i=0;i<3;i++){
        if (S[i] == 'R'){
            tmp++;
        } else {
            ans = max(tmp, ans);
            tmp = 0;
        }
    }
    ans = max(tmp, ans);
 
    cout<<ans;
 
    return 0;
}

Measured memory_bytes: 3584
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  
  int n;
  cin>>n;
  for(int i=0;i<=100;++i){
    for(int j=0;j<=100;++j){
      if(4*i+7*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int main() {
	int n;
	scanf("%d", &n);
	if (n%100 > n/100*5) cout <<0<<endl;
	else cout <<1<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	x, n = read();
	if n:
		arr = read()
	else:
		print(x)
		exit()
	t = x
	while t in arr:
		t -= 1
	s = x
	while s in arr:
		s += 1
	if abs(x-t) > abs(x-s):
		print(s)
	elif abs(x-t) == abs(x-s):
		print(t)
	else:
		print(t)







if __name__ == "__main__":
	solve()

Measured memory_bytes: 9432
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x(x%mod){}
    mint& operator+=(const mint a){
        if ((x+= a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if ((x+= mod - a.x) >= mod) x-= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x*=a.x)%=mod;
        return *this;
    }
    mint operator+(const mint a) const{
        mint ans(*this);
        return ans+= a;
    }
    mint operator-(const mint a) const{
        mint ans(*this);
        return ans-= a;
    }
    mint operator*(const mint a) const{
        mint ans(*this);
        return ans*= a;
    }
};

int gcd(int a, int b){
    return (b%a == 0? a : gcd(b%a,a));
}
ll l(int a, int b){
    return (ll) a*b/gcd(min(a,b),max(a,b));
}

int main(){
    ll a,b;
    cin >> a >> b;
    int c,d;
    cin >> c >> d;
    cout << b-(a-1)-(b/c - (a-1)/c + b/d - (a-1)/d) + b/l(d,c) -(a-1)/l(d,c) ;
}


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

int d[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

int main(){
  int H,W; cin >> H >> W;
  string s[50]; for(int i=0; i<H; i++) cin >> s[i];
  int reached[50][50];
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      reached[i][j]=-1;
    }
  }
  queue<vector<int>> q;
  q.push({0,0});
  reached[0][0]=0;
  while(q.empty()==0){
    int tx=q.front()[0], ty=q.front()[1];
    for(int i=0; i<4; i++){
      if(tx+d[i][0]>=0&&tx+d[i][0]<H
         &&ty+d[i][1]>=0&&ty+d[i][1]<W){
        if(s[tx+d[i][0]][ty+d[i][1]]=='.'
           &&reached[tx+d[i][0]][ty+d[i][1]]==-1){
          reached[tx+d[i][0]][ty+d[i][1]]=reached[tx][ty]+1;
          q.push({tx+d[i][0],ty+d[i][1]});
        }
      }
    }
    q.pop();
  }
  if(reached[H-1][W-1]==-1){
    cout << -1 << endl;
  }else{
    int dotsum=0;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        if(s[i][j]=='.') dotsum++;
      }
    }
    cout << dotsum-reached[H-1][W-1]-1 << endl;
  }
}

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

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

  long long int num = n;
  
  long long sum = 0;
  while(true) {
    int mod = n % 10;
    sum += mod;

    long long int syo = n / 10;
    n = syo;

    if (sum == sum + n) break;
    continue;
  }

  //cout << sum << "\n";
  //cout << n % sum << "\n";
  
  if (num % sum == 0) cout << "Yes" << "\n";
  else cout << "No" << "\n";

  return 0;
}


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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;


int main() {
  str(s);
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
    prln("Yes");
  }else{
    prln("No");
  }
  
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) break;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					if(i % 2 == j % 2) System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, K; 
    cin>>N>>K;
    vi P(N);
    REP(i, 0, N) cin >> P[i];
    sort(P.begin(), P.end());
    int ans = 0;
    REP(i, 0, K) ans += P[i];
    cout << ans << endl;
}

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

int main(){
  long N;
  cin >> N;
  string S;
  cin >> S;
  long number=0;
  char before_cha;
  before_cha=S[0];
  for(int i=1; i<S.size(); i++){
    if(before_cha==S[i])continue;
    before_cha=S[i];
    number+=1;
  }
  number+=1;
  cout << number << endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main(){
  string s,temps[]={"dream","dreamer","erase","eraser"};
  cin >> s;
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++){
    reverse(temps[i].begin(),temps[i].end());
  }
  bool pre=true;
  for(int n=0;n<s.size();){
    bool ck=false;
    for(int l=0;l<4;l++){
      if(temps[l] == s.substr(n,temps[l].size())){
        ck = true;
        n += temps[l].size();
      }
    }
    if(!ck){
      pre = false;
      break;
    }
  }
  if(pre){
    cout << "YES";
  }else{
    cout << "NO";
  }
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, ws;
    cin >> n >> ws;
    ll w[102], v[102];
    cin >> w[1] >> v[1];
    for(int i = 2; i <= n; i++){
        cin >> w[i] >> v[i];
        w[i] -= w[1];
    }
    w[0] = w[1];
    w[1] = 0;
    ll lar = 0;
    ll dp[101][101][301];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(ll k = 0; k <= 300; k++){
                if(k - w[i] >= 0){
                    dp[i][j][k] = max(dp[i - 1][j][k], v[i] + dp[i - 1][j - 1][k - w[i]]);
                }
                else dp[i][j][k] = dp[i - 1][j][k];
                if(j * w[0] + k <= ws) lar = max(lar, dp[i][j][k]);
            }
        }
    }
    cout << lar << endl;
}

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

int dp(vector<int>& h, vector<int>& mem, int n, int k) {
    if( n < k && n >= 0) {
        mem[n] = abs(h[n] - h[0]);
        return mem[n];
    }
    mem[n] = INT_MAX;
    for(int i = n-1; i >= n-k; i--) {
        int temp_dp = mem[i] > -1? mem[i]: dp(h, mem, i, k); 
        mem[n] = min(mem[n], abs(h[n]-h[i]) + temp_dp);
    }
    return mem[n];
}

int main() {
    int n, k;
    cin >> n;
    cin >> k;
    vector<int> ht(n, 0);
    vector<int> mem(n, -1);
    for(int i = 0; i < n; i++) {
        cin >> ht[i];
    }

    cout << dp(ht, mem, n-1, k);

    return 0;
} 

Measured memory_bytes: 8832
#include<stdio.h>
#define INFTY 2100000001
int L[500000], R[500000];
int cnt = 0;
void merge(int *a,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0;i < n1; i++){
     L[i] = a[left + i];
   }
  for(i = 0;i < n2; i++){
    R[i] = a[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;
  for( k = left; k < right; k++){
    if(L[i] <= R[j]){
       a[k] = L[i];
       i++;
       cnt++;
     }else{
       a[k] = R[j];
       j++;
       cnt++;
     }
  }
}
void mergeSort(int *a, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
}
int main(){
  int n,a[500001],i;
  scanf("%d",&n);
  for(i =0;i < n;i++) scanf("%d",&a[i]);
  mergeSort(a,0,n);
  for(i =0;i < n - 1;i++) printf("%d ",a[i]);
  printf("%d",a[i]);
  printf("\n%d\n",cnt);
  return 0;
}



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

int main()
{
    long long int a[100001] = {};
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        //long long int t;
        cin >> a[i];
    }

    sort(a,a+n,greater<int>());
  
    bool isClear = false;
    long long int num1 = 0;
    long long int num2 = 0;
    for(int i = 0; i < n && !isClear; ++i)
    {
        if(a[i] == a[i+1])
        {
            //cout << "check" << endl;
            if(num1 == 0)
            {
                num1 = a[i];
            }
            else
            {
                num2 = a[i];
                isClear = true;
            }
            ++i;
        }
    }
    if(isClear)
    {
        cout << num1*num2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
else:
    ans=float('inf')
    for i in range(1,h):
        c=max(i*(w//2),i*(w-w//2),(h-i)*w)-min(i*(w//2),i*(w-w//2),(h-i)*w)
        if ans>c:
            ans=c
        #print(ans)
    for i in range(1,w):
        d=max(i*(h//2),i*(h-h//2),(w-i)*h)-min(i*(h//2),i*(h-h//2),(w-i)*h)
        if ans>d:
            ans=d
        #print(ans)
    print(min(ans,h,w))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int W, H, N; cin >> W >> H >> N;
  int t=H, b=0, l=0, r=W;

  rep(i, N) {
    int x, y, a; cin >> x >> y >> a;
    if (a==1) l = max(l, x);
    else if (a==2) r = min(r, x);
    else if (a==3) b = max(b, y);
    else if (a==4) t = min(t, y);
  }

  int result = max(0, t-b) * max(0, r-l);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 101

int main(void)
{
	int vectorA[N][N] = { 0 };
	int vectorB[N][N] = { 0 };
	long long vectorans[N][N] = { 0 };//表示にもメモリーの気を遣って
	int n, m, l;
	int i, j, k;

	scanf("%d %d %d", &n, &m, &l);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &vectorA[i][j]);
		}
	}

	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			scanf("%d", &vectorB[i][j]);
		}
	}
	//----------------------------------
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			for (k = 0; k < m; k++) {
				vectorans[i][j] += vectorA[i][k] * vectorB[k][j];
			}
		}
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			if (j == l - 1) {
				printf("%lld", vectorans[i][j]);
			}
			else {
				printf("%lld ", vectorans[i][j]);
			}
		}
		printf("\n");
	}
	
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N;
    cin >> N;
    vector<ll>h(N);
    bool fla=true;
    for(ll i = 0;i < N;i++)
        cin >> h.at(i);

    for(ll i = N-1;i > 0;i--){
        if(h.at(i) >= h.at(i-1))
            continue;
        else if(h.at(i) == (h.at(i-1)-1))
            h.at(i-1)--;
        else{
            fla = false;
            break;
        }
        
    }

    if(fla)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

using namespace std;


int arr[100];

int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++)cin >> arr[i];

  sort(arr,arr+n);

  double prev=(double)(arr[0]);

  for(int i=1;i<n;i++)
  {
    double x=(double)(arr[i]);
    prev=prev+x;
    prev=prev/2.0;
  }

  cout << fixed << setprecision(9) << prev;

}


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

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll>> Z(N);
    for (int i = 0; i < N; i++) cin >> Z[i].first >> Z[i].second;
    sort(Z.begin(), Z.end(), [](auto x, auto y){return x.first+x.second < y.first+y.second;});
    
    ll inf = 1e18;
    vector<vector<ll>> dp(N+1, vector<ll>(N+1, inf));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        dp[i][0] = 0;
        for (int j = 0; j <= i-1; j++) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if (dp[i-1][j] <= Z[i-1].first) {
                dp[i][j+1] = min(dp[i][j+1], dp[i-1][j]+Z[i-1].second);
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (dp[N][i] != inf) ans = i;
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 195968
#include <stdio.h>

int main(void) {
  while(1) {
  int i, j, n, max = 0, min = 1000;
  scanf("%d", &n);
  if(!n) break;
  for(i = 0; i < n; ++i) {
     int sum = 0, a;
     for(j = 0; j < 5; ++j) {
       scanf("%d", &a);
       sum += a;
     }
     if(sum > max) max = sum;
     if(sum < min) min = sum;
  }
  printf("%d %d\n", max, min);
  }
  return 0;
}


Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

using P = complex<double>;
P ps[21];

const double EPS = 1e-9;
const double INF = 1e9;
vector<int> go[21][21];
double dp[10001][21][21];
double d[21][21];

int main() {
    int n;
    double r, th;
    cin >> n >> r >> th;
    th = th*acos(-1)/180;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        ps[i] = P(x, y);
    }
    rep(i, n) rep(j, n) {
        if (i == j) continue;
        go[i][j].clear();
        rep(k, n) {
            if (j == k) continue;
            double phi = arg((ps[k] - ps[j]) / (ps[j] - ps[i]));
            if (abs(phi) <= th + EPS) {
                go[i][j].push_back(k);
                //dump(i, j, k);
            }
        }
        d[i][j] = abs(ps[i] - ps[j]);
    }
    rep(i, 10001) rep(j, 21) rep(k, 21) dp[i][j][k] = INF;
    rep(i, n) if (i && d[0][i] <= r + EPS) dp[1][0][i] = d[0][i];
    FOR(i, 1, 10001) {
        rep(j, n) rep(k, n) {
            if (dp[i][j][k] == INF) continue;
            for (auto &l : go[j][k]) {
                dp[i+1][k][l] = min(dp[i+1][k][l], dp[i][j][k] + d[k][l]);
            }
        }
    }
    double ans = 0;
    rrep(i, 10001) rep(j, n) rep(k, n) {
        if (dp[i][j][k] <= r + EPS) {
            //dump(i, j, k);
            ans = i;
            goto END;
        }
    }
 END:;
    cout << ans << endl;
}

Measured memory_bytes: 38056
import os



inputs = str(input()).split(' ')
inputs = [int(i) for i in inputs]
A, B, C, X, Y = inputs


def cost(a, b, c):
	return a*A+b*B+c*C

cost_list = []
maxc = max([X*2, Y*2])
for i in range(0, maxc+1):
	c = i
	a = max([X - int(c/2), 0])
	b = max([Y - int(c/2), 0])
	cst = cost(a, b, c)
	cost_list.append(cst)

mincost = min(cost_list)
print(int(mincost), end='')


Measured memory_bytes: 11032
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h, w;
	cin >> h >> w;
	vector<vector<int> > a;
	vector<vector<int> > b;
	a.resize(h);
	b.resize(h);
	for(int i = 0; i < h; ++i) {
		a[i].resize(w);
		b[i].resize(w);
	}
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			cin >> b[i][j];
		}
	}
	vector<vector<vector<int> > > dp;
	dp.resize(h);
	for(int i = 0; i < h; ++i) {
		dp[i].resize(w);
		for(int j = 0; j < w; ++j) {
			dp[i][j].resize(6405);
		}
	}
	dp[0][0][abs(a[0][0] - b[0][0])] = 1;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			for(int k = 0; k < dp[i][j].size(); ++k) {
				if(dp[i][j][k] == 1) {
					if(i + 1 < h) {
						int t1 = abs(k - abs(a[i + 1][j] - b[i + 1][j]));
						int t2 = abs(k + abs(a[i + 1][j] - b[i + 1][j]));
						if(t1 < dp[i + 1][j].size()) {
							dp[i + 1][j][t1] = 1;
						}
						if(t2 < dp[i + 1][j].size()) {
							dp[i + 1][j][t2] = 1;
						}
					}
					if(j + 1 < w) {
						int t1 = abs(k - abs(a[i][j + 1] - b[i][j + 1]));
						int t2 = abs(k + abs(a[i][j + 1] - b[i][j + 1]));
						if(t1 < dp[i][j + 1].size()) {
							dp[i][j + 1][t1] = 1;
						}
						if(t2 < dp[i][j + 1].size()) {
							dp[i][j + 1][t2] = 1;
						}
					}
				}
			}
		}
	}
	for(int i = 0; i < dp[h - 1][w - 1].size(); ++i) {
		if(dp[h - 1][w - 1][i] == 1) {
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 160640
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;
 
 
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin >> a >>b;
cout << max({a+b,a-b,a*b}) << '\n';
return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#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())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

bool check(ll a, ll b, vll x){
  bool flagA = false, flagB = false;

  REP(i, x.size()){
    if(x[i] == a)
      flagA = true;
    if(x[i] == b)
      flagB = true;
  }

  return flagA && flagB;
}

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

  ll a, b;
  cin >> a >> b;

  vll x = {1,3,5,7,8,10,12};
  vll y = {4,6,9,11};
  vll z = {2};

  if(check(a,b,x) || check(a,b,y) || check(a,b,z))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

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

#define Canuc80k cin.tie(0); cout.tie(0);
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
#define I_AM ios_base::sync_with_stdio(0);
#define FORS(i,a,b,c) for (int i=a;i<=b;i+=c)
#define FORSD(i,a,b,c) for (int i=a;i>=b;i-=c)

const ll N = 1e6 + 1;
const ll M = 1e9 + 7;

int n;
ll a[N], st[N * 4];
ii lb[N];

// l u v r
// u l r v
int getMax(int index, int l, int r, int u, int v) {
    if (u > r || v < l) return -INT_MAX;
    if (u <= l && v >= r) return st[index];

    int mid = (r + l) / 2;
    return max(getMax(index * 2, l, mid, u, v), getMax(index * 2 + 1, mid + 1, r, u, v));
}

void update(int index, int l, int r, int pos, int val) {
    if (l > pos || r < pos) return;
    if (l == r) {
        st[index] = val;
        return;
    }

    int mid = (r + l) / 2;
    update(index * 2, l, mid, pos, val);
    update(index * 2 + 1, mid + 1, r, pos, val);

    st[index] = max(st[index * 2], st[index * 2 + 1]);
}

int main() {
    I_AM Canuc80k

    cin >> n;
    FOR (i, 1, n) {
        cin >> a[i];
        lb[i].first = a[i];
        lb[i].second = i;
    }

    sort(lb + 1, lb + n + 1);
    
    int count = 0;
    FOR (i, 1, n) {
        if (lb[i].first == lb[i - 1].first) 
            a[lb[i].second] = count;
        else a[lb[i].second] = ++ count;
    }

    int res = 1;
    update(1, 0, 1e6, a[1], 1);
    FOR (i, 2, n) {
        int temp = 0;
        if (a[i] != 0) temp = getMax(1, 0, 1e6, 0, a[i] - 1);
        // cout << i << " " << temp << endl;
        res = max(res, temp + 1);
        update(1, 0, 1e6, a[i], temp + 1);
    }

    cout << res << endl;
}


Measured memory_bytes: 6360
using System;
using System.Linq;

namespace AtCoder093D
{
    class Program
    {
        static void Main(string[] args)
        {
            const int N = 100;
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            char[,] board = new char[N, N];
            for (int i = 0; i < N / 2; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    board[i, j] = '#';
                    board[i + N / 2, j] = '.';
                }
            }
            int a = ab[0] - 1;
            int b = ab[1] - 1;
            for(int i = 1; i < N / 2 - 1; i += 2)
            {
                for (int j = 1; j < N - 1; j += 2)
                {
                    if (a > 0)
                    {
                        board[i, j] = '.';
                        a--;
                    }
                    if (b > 0)
                    {
                        board[N - 1 - i, j] = '#';
                        b--;
                    }
                    if (a <= 0 && b <= 0) break;
                }
            }
            Console.WriteLine("{0} {1}", N, N);
            char[] ans = board.Cast<char>().ToArray();
            for (int i = 0; i < N * N; i += N)
            {
                Console.WriteLine(new string(ans.Skip(i).Take(N).ToArray()));
            }
        }
    }
}


Measured memory_bytes: 13408
#include <stdio.h>
#include <stdlib.h>
int main(){
    long i, n, *a;
    long long cnt=0;
    scanf("%ld", &n);
    a = calloc(n, sizeof(long));
    for(i=0; i<n; i++) scanf("%ld", &a[i]);

    for(i=1; i<n; i++){
        while(a[i-1] > a[i]){
            a[i]++;
            cnt++;
        }
    }
    printf("%lld", cnt);
    return 0;
}


Measured memory_bytes: 3260
import sys
sys.setrecursionlimit(10**5)

n = int(input())
a = list(map(int, input().split()))
dp = [[None]*(2) for _ in range(n+1)]

dp[n-1][0] = a[n-1]
dp[n-1][1] = -a[n-1]

for i in reversed(range(n-1)):
    for j in range(2):
        #print('\n# i: ' + str(i))
        # Unexe
        unexe_unexe = a[i] + dp[i+1][0]
        exe_unexe = -a[i] + dp[i+1][1]
        dp[i][0] = max(unexe_unexe, exe_unexe)

        # Exe
        unexe_exe = a[i] + dp[i+1][1]
        exe_exe = -a[i] + dp[i+1][0]
        dp[i][1] = max(unexe_exe, exe_exe)

#print(dp)
#print(max(dp[0][0], dp[0][1]))
print(dp[0][0])




Measured memory_bytes: 73632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(Arrays.stream(arr).sum() - n);
    }
}

Measured memory_bytes: 29264
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], k = tmp[1];
	int ans = (n%k) == 0 ? 0 : 1;
	WriteLine(ans);
    }
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int l,r,d;
    cin>>l>>r>>d;

    cout<<(r/d)-((l-1)/d)<<"\n";

    return 0;

}

Measured memory_bytes: 3588