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

inline int rd() {int r;scanf("%d",&r);return r;}
int n,m,d[N];
int main() {
	n = rd(), m = rd();
	for (int i=1;i<=m;i++) d[rd()]++, d[rd()]++;
	int ans = 1;
	for (int i=1;i<=n;i++) if (d[i]&1) ans = 0;
	puts(ans?"YES":"NO");
	return 0;
}


Measured memory_bytes: 640
//https://atcoder.jp/contests/abc048/tasks/arc064_a
//2020-04-27
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    long long num;
    cin >> num;
    long long maximum;
    cin >> maximum;
    vector<long long> v;
    v.push_back(0);
    long long tmp;
    for(int i=0;i<num;i++){
        cin >> tmp;
        v.push_back(tmp);
    }
    long long ans =0;
    for(int i=1;i<=num;i++){
        if(v[i-1]+v[i]>maximum){
            ans += (v[i-1]+v[i])-maximum;
            v[i]=maximum-v[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    lint rect1 = a * b, rect2 = c * d;
    if (rect1 >= rect2)
        cout << rect1 << endl;
    else
        cout << rect2 << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, h; cin >> n >> h;
    vector<pair<pair<ll, ll>, ll>> a(n);
    vector<pair<ll, ll>> b(n);

    // 添字を含んで入力処理
    rep(i, n){
        ll ai, bi; cin >> ai >> bi;
        a.push_back(make_pair(make_pair(ai, bi), i));
        b.push_back(make_pair(bi, i));
    }
    // 降順に整列
    sort(all(a), greater<pair<pair<ll, ll>, ll>>());
    sort(all(b), greater<pair<ll, ll>>());

    // 通常攻撃の最大値
    ll NormalAttack = a[0].first.first;
    ll DontThrowA = a[0].second;

    // 答え算出用
    ll cnt = 0;

    // 通常攻撃の最大値より強いものは投げれるだけ投げる
    ll ThrowAttack = a[0].first.second;
    ll cur = 0;
    if(b[cur].second == DontThrowA) cur++;
    while(h>0 && h>ThrowAttack && cur<n && b[cur].first>NormalAttack){
        // 攻撃を行いHPを減少、攻撃回数を増加
        h -= b[cur].first;
        cnt++;
        // カーソルをずらす（通常攻撃に使うやつだったら更にずらす）
        cur++;
        if(cur<n && b[cur].second == DontThrowA) cur++;
    }

    // 敵のHPが残っているなら
    if(h >= 1){
        // 通常攻撃のほうが強い場合
        if(ThrowAttack == -1 || ThrowAttack <= NormalAttack){
            cnt += ceil(1.0*h/NormalAttack);
        }
        // 投げたほうが強い場合
        else{
            cnt++; h-=ThrowAttack;
            if(h>=1) cnt += ceil(1.0*h/NormalAttack);
        }
    }

    // 結果の出力
    cout << cnt << endl;
}

Measured memory_bytes: 8664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,l;
    cin>>n>>l;
    if(l>=0)
    {    ll su=0;
        for(int x=l+1;x<=n+l-1;x++)
            su+=x;
        cout<<su<<endl;
    }
    else if(l<0 && l+n-1>=0)
    {   ll su=0;
        for(int x=l;x<=n+l-1;x++)
            su+=x;
        cout<<su;
    }
    else
    {
        ll su=0;
        for(int x=l;x<=n+l-2;x++)
            su+=x;
        cout<<su;
    }

}


Measured memory_bytes: 256
s=list(input())
n=len(s)

ans=0
for i in range(2**(n-1)):
    f=[]
    s_=0
    for j in range(n-1):
        if (i>>j) & 1:
            t=s[s_:j+1]
            if len(t)!=0:
                f.append("".join(t))

            s_=j+1

    t=s[s_:]
    if len(t)!=0:
        f.append("".join(t))

    ans+=eval("+".join(f))

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int stu,list,man1,man2;
	int cut_i,cut_j,tem;
	int frn1[501],frn2[501][501];
	int ans[501];

	while(1){
		scanf("%d",&stu); 
		
		scanf("%d",&list);
		
		if((stu|list) == 0){
			break;
		}

		int kyaku = 0;

		for(cut_i=2;cut_i<501;cut_i++){
			frn1[cut_i]=0;
			ans[cut_i]=0;
			for(cut_j=2;cut_j<501;cut_j++){
				frn2[cut_i][cut_j]=0;
			}
		}

		for(cut_i=0;cut_i<list;cut_i++){
			scanf("%d%d",&man1,&man2);
			if(man1>man2){
				tem = man1;
				man1 = man2;
				man2 = tem;
			}
			if(man1 == 1){
				frn1[man2] =1;
			}
			else {
				frn2[man1][man2] =1;
				frn2[man2][man1] =1;
			}
		}

		for(cut_i=2;cut_i<500;cut_i++){
			if(frn1[cut_i] == 1){
				ans[cut_i] = 1;
				for(cut_j = 2; cut_j<501;cut_j++){
					if(frn2[cut_i][cut_j] == 1){
						ans[cut_j] = 1;
					}
				}
			}
		}
		for(cut_i = 2;cut_i < 501; cut_i++){
			kyaku+=ans[cut_i];
		}
		printf("%d\n",kyaku);
	}
	return 0;
}

Measured memory_bytes: 2012
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
int d[200000];
int main(){
  int n,m; cin >> n >> m;
  rep(i,m){
    int a,b; cin >> a >> b;
    d[a]++,d[b]++;
  }
  rep(i,n+1)
    if(d[i]%2){
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int d(int i,int x)
{
	if(i>x){
		return 0;
	}else{
		return x-i;
	}
}
int main(void)
{
	int a,b,c,x,y,i,m,mini=2147483647;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	for(i=0; i<=100000; i++){
		m=i*2*c+d(i,x)*a+d(i,y)*b;
		if(mini>m){
			mini=m;
		}
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int E[N][N];
    REP(i, N) REP(j, N) {
        if (i == j) E[i][j] = 0;
        else E[i][j] = inf;
    }

    vector<int> P[N][N];
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        E[a][b] = 1;
        E[b][a] = 1;
        P[a][b].eb(i);
        P[b][a].eb(i);
    }

    REP(k, N) {
        REP(i, N){
            REP(j, N){
                if (E[i][j] > E[i][k] + E[k][j]){
                    E[i][j] = E[i][k] + E[k][j];

                    P[i][j].reserve(P[i][k].size() + P[k][j].size());
                    P[i][j].insert(P[i][j].end(), P[i][k].begin(), P[i][k].end());
                    P[i][j].insert(P[i][j].end(), P[k][j].begin(), P[k][j].end());
                }
            }
        }
    }

    int M;
    cin >> M;

    int u[M], v[M];
    REP(i, M) {
        cin >> u[i] >> v[i];
        --u[i]; --v[i];
    }

    ll ans = 0;
    REP(i, 1 << M) {
        ll p = 0;

        int s = 0;
        for(int j=i, k=0; j > 0; j >>= 1, ++k) {
            if(j & 1) {
                for (auto e: P[u[k]][v[k]]) {
                    p |= 1LL << e;
                }
                ++s;
            }
        }

        int cnt = bcnt(p);

        if (s % 2) ans -= pow(2, N - cnt -1);
        else ans += pow(2, N - cnt -1);
    }


    cout << fixed << setprecision(20) << ans << endl;

}


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

int main() {
  int K;
  cin >> K;
  vector<int> V(32);
  V = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << V.at(K - 1) << "\n"; 
}

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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
int a, b, n, ans;

int32_t main() {
	cin >> n >> a >> b;
	if(a + b == 0) return cout << 0, 0;
	ans = n / (a + b);
	ans *= a;
	n %= (a + b);
	n = min(n, a);
	ans += n;
	cout << ans;
}

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

int main() {
	int n;
	cin>>n;
	int v[n],c[n];
	for(int i=0;i<n;++i)
	cin>>v[i];
	for(int i=0;i<n;++i)
	cin>>c[i];
	int ans = 0;
	for(int i=0;i<n;++i)
	if(v[i]>c[i])
	ans+=(v[i]-c[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = [int(i) for i in input().split()]
lcm = c * d // gcd(c, d)
print(b - b // c - b // d + b // lcm - (a - 1) + (a - 1) // c + (a - 1) // d - (a - 1) // lcm)

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

using Graph=vector<vector<int>>;

int main()
{
    int N; cin>>N;
    Graph G(N);
    vector<int> par(N,-1);
    for(int i=0;i<N;i++){
        int u,k; cin>>u>>k;
        while(k--){
            int v; cin>>v;
            G[u].push_back(v);
            par[v]=u;
        }
    }

    vector<int> depth(N);
    function<void(int)> dfs=[&](int v)
    {
        for(int u:G[v]){
            depth[u]=depth[v]+1;
            dfs(u);
        }
    };
    
    depth[0]=0;
    for(int i=0;i<N;i++) if(par[i]==-1) dfs(i);

    for(int i=0;i<N;i++){
        string type;
        if(par[i]==-1) type="root";
        else if(G[i].size()==0) type="leaf";
        else type="internal node";

        printf("node %d: parent = %d, depth = %d, %s, ",i,par[i],depth[i],type.c_str());
        printf("[");
        for(int j=0;j<G[i].size();j++){
            if(j>0) printf(", ");
            printf("%d",G[i][j]);
        }
        printf("]\n");
    }
    return 0;
}


Measured memory_bytes: 6796
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define int long long
#define MAX         2000000000000000000
#define re(i,x,n) for(i=x;i<=n;i++)
typedef long long ll;
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vi graph[200001];
int vis[200001] = {0};
int cost[100001];
int parent = -1;
int costi ;
void dfs(int i)
{
	vis[i] = 1;
	costi = min(cost[i], costi);
	//cout << costi << endl;
	for (auto &it : graph[i])
	{
		if (vis[it] == 0) {

			dfs(it);

		}
	}

}
int pp[100001];
bool isPrime(int n)
{
	int i;
	for (i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
//
int32_t main()
{
	//c_p_c();
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 == 0)
		cout << "1";
	else if (x2 == 0)
		cout << "2";
	else if (x3 == 0)
		cout << "3";
	else if (x4 == 0)
		cout << "4";
	else
		cout << "5";
}

Measured memory_bytes: 8236
using System;

public class Test{
  public static void Main(){
    
    //文字列の読み込み
    string s = System.Console.ReadLine();
    int n = s.Length;

    //1~(N-1)/2文字目の回文判定
    bool strong = true;
    for(int i=0; i < (n-1)/2; ++i){
      if(s[i] != s[n-1-i] || s[i] != s[(n-1)/2-1-i]){
        strong = false;
        break;
      }
    }

    if(strong == true){
     	System.Console.WriteLine("Yes");
    } else {
     	System.Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13140
N, *A = map(int, open(0).read().split())

v_max = max(A)
v_min = min(A)

flg1 = v_max > 0 and v_min >= 0
flg2 = v_max <= 0 and v_min <= 0
flg3 = v_max * v_min < 0 and abs(v_max) >= abs(v_min)
flg4 = v_max * v_min < 0 and abs(v_max) < abs(v_min)

s = sorted([(i + 1, v) for i, v in enumerate(A)], key=lambda x: x[1])
ans = []
if flg1 or flg3:
    if flg3:
        i_max = s[-1][0]
        for j in range(1, N + 1):
            ans.append((i_max, j))
            
    for j in range(1, N):
        ans.append((j, j + 1))
else:
    if flg4:
        i_min = s[0][0]
        for j in range(1, N + 1):
            ans.append((i_min, j))
            
    for j in reversed(range(1, N)):
        ans.append((j + 1, j))
        
print(len(ans))
for v in ans:
    print(*v)


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

#include <iostream>


#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<ull,ull> PUll;
typedef pair<int,int> Pii;
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a*b)/__gcd(a,b)

auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	string s;cin>>s;
	if(s[0]==s[1])
	{
		if(s[2]==s[1])
			cout<<"No\n";
		else{
			if(s[2]==s[3])
				cout<<"Yes\n";
			else
				cout<<"No\n";
		}
		return 0;
	} 
	else if(s[0]==s[2])
	{
		if(s[2]==s[1])
			cout<<"No\n";
		else{
			if(s[1]==s[3])
				cout<<"Yes\n";
			else
				cout<<"No\n";
		}
		return 0;
	}
	else if(s[0]==s[3])
	{
		if(s[2]==s[0])
			cout<<"No\n";
		
		else{
			if(s[1]==s[2])
				cout<<"Yes\n";
			else
				cout<<"No\n";
		}
		return 0;
	}
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

int main() {
  cout << fixed << setprecision(8);
  unordered_map<ll, ll> cost;
  ll n, k;
  cin >> n >> k;
  vl l(n);

  FOR(i,0,n) {
    cin >> l[i];
  }

  cost[0] = 0;
  FOR(i,0,n-1) {
    FOR(j,1,k+1) {
      if(i+j == n)
	break;
      
      if(has(cost, i+j))
	cost[i+j] = min(cost[i+j], cost[i] + abs(l[i] - l[i+j]));
      else
	cost[i+j] = cost[i] + abs(l[i] - l[i+j]);
    }
  }

  cout << cost[n-1] << endl;
}


Measured memory_bytes: 5156
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

int solve(int smallsz, int bigsz, int index, vector<vector<int>> &modM){
    int maxmatch = 0, ans = 0;
    for(int i=0; i<bigsz; i++){
        int cnt = 1, cur = modM[index][i];
        while(i + 1 < bigsz && cur == modM[index][i+1]){
            i++;
            cnt++;
        }
        maxmatch += cnt / 2;
    }

    ans += smallsz;
    int rest = bigsz - smallsz;
    ans += min(rest / 2, maxmatch);

    return ans;
}

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

    int n, m; cin>>n>>m;
    vector<vector<int>> modM(m);
    for(int i=0; i<n; i++){
        int x; cin>>x;
        modM[x%m].emplace_back(x);
    }

    for(int i=0; i<m; i++){
        sort(modM[i].begin(), modM[i].end());
    }

    int half = m / 2;
    int ans = modM[0].size() / 2;
    for(int i=1; i<=half; i++){
        int sz1 = modM[i].size(), sz2 = modM[m-i].size();

        if(sz1 == sz2){
            if(i == m - i) ans += sz1 / 2;
            else ans += sz1;
            continue;
        }

        if(sz1 > sz2) ans += solve(sz2, sz1, i, modM);
        else ans += solve(sz1, sz2, m-i, modM);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0) {
		if (y - r >= 0) {
			if (x + r <= W) {
				if (y + r <= H) {
					cout << "Yes" << endl;
					goto end;
				}
				else {
					goto stop;
				}
			}
			else {
				goto stop;
			}
		}
		else {
			goto stop;
		}
	}
	else {
		goto stop;
	}
stop:
	cout << "No" << endl;
end:
	return 0;
}

Measured memory_bytes: 3100
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N, Q, A, B, C, D, E, F, G = map(int, readline().split())
    d = 0; rx = 0; ry = 0
    *X, = range(N)
    *Y, = range(N)
    def fc(d, x, y):
        if d == 0:
            return x, y
        if d == 1:
            return y, N-1-x
        if d == 2:
            return N-1-x, N-1-y
        return N-1-y, x
    mp = {}
    for i in range(Q):
        c, *g = readline().strip().split()
        c0, c1 = c
        if c0 == "R":
            if c1 == "L":
                d = (d - 1) % 4
            elif c1 == "R":
                d = (d + 1) % 4
            elif c1 == "H":
                if d & 1:
                    rx ^= 1
                else:
                    ry ^= 1
            else: #c1 == "V":
                if d & 1:
                    ry ^= 1
                else:
                    rx ^= 1
        elif c0 == "S":
            a, b = map(int, g); a -= 1; b -= 1
            if c1 == "R":
                if d & 1:
                    if rx != ((d & 2) > 0):
                        a = N-1-a; b = N-1-b
                    X[a], X[b] = X[b], X[a]
                else:
                    if ry != ((d & 2) > 0):
                        a = N-1-a; b = N-1-b
                    Y[a], Y[b] = Y[b], Y[a]
            else: #c1 == "C":
                if d & 1:
                    if ((d & 2) == 0) != ry:
                        a = N-1-a; b = N-1-b
                    Y[a], Y[b] = Y[b], Y[a]
                else:
                    if ((d & 2) > 0) != rx:
                        a = N-1-a; b = N-1-b
                    X[a], X[b] = X[b], X[a]
        elif c0 == "C": #c == "CP":
            y1, x1, y2, x2 = map(int, g); x1 -= 1; y1 -= 1; x2 -= 1; y2 -= 1
            x1, y1 = fc(d, x1, y1)
            x2, y2 = fc(d, x2, y2)
            if rx:
                x1 = N-1-x1; x2 = N-1-x2
            if ry:
                y1 = N-1-y1; y2 = N-1-y2
            key1 = (X[x1], Y[y1]); key2 = (X[x2], Y[y2])
            if key1 not in mp:
                xa, ya = key1
                mp[key2] = (ya*A + xa*B + A + B) % C
            else:
                mp[key2] = mp[key1]
        else: #c == "WR":
            y, x, v = map(int, g); x -= 1; y -= 1
            x, y = fc(d, x, y)
            if rx:
                x = N-1-x
            if ry:
                y = N-1-y
            key = (X[x], Y[y])
            mp[key] = v
    MOD = 10**9 + 7
    h = 314159265
    for y in range(D-1, E):
        for x in range(F-1, G):
            x0, y0 = fc(d, x, y)
            if rx:
                x0 = N-1-x0
            if ry:
                y0 = N-1-y0
            x0 = X[x0]; y0 = Y[y0]
            key = (x0, y0)
            if key in mp:
                v = mp[key]
            else:
                v = ((y0+1)*A + (x0+1)*B) % C
            h = (31 * h + v) % MOD
    write("%d\n" % h)
solve()


Measured memory_bytes: 10004
#include <bits/stdc++.h>
using namespace std;
int countMAX(int x, int k){
    if (k == 0) return 1;
    if (k == 1) return x * 9;
    if (k == 2) return x*(x-1)/2 * 81;
    if (k == 3) return (x*(x-1)*(x-2))/6 * 729;
}
string n;
int nD;
int p;
int dp(int curID, int left, int ok){
    if (curID == nD+1) return (left==0);
    if (left < 0) return 0;
    if (ok){
        return countMAX(nD-curID+1,left);
    }
    int X = n[curID-1]-'0';
    int ans = 0;
    for (int j = 0; j < X; j++){
        ans += dp(curID+1,left-(j!=0),true);
    }
    ans += dp(curID+1,left-(X!=0),false);
    //printf("%d %d %d %d %d\n",curID,left,ok,X,ans);
    return ans;
}
int main(){
    cin >> n >> p;
    nD = n.size();
    printf("%d",dp(1,p,0));

}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50
#define PI 3.141592653589793238462643383279502884197169

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a/g * b; //prevent overflow
}

   ////////////////////////  END OF TEMPLATE ////////////////////////////////////////

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi data(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> data[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        if(data[i] == i+1)
        {
            ans++;
            if(i-1 >= 0 && data[i-1] == i)
            {
                ans--;
                data[i] = -1;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, m; scanf("%d%d", &n, &m);
	std::vector<int> latte(n + 1, 0);
	for(int i = 0; i < m; i++) {
		int l, r; scanf("%d%d", &l, &r);
		
		latte[l - 1]++;
		latte[r]--;
	}
	for(int i = 0; i < latte.size() - 1; i++) latte[i + 1] += latte[i];
	
	int ans = 0;
	for(auto v: latte) if(v == m) ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
int main() {
  int a,b;
  char op;
  cin >> a >> op >> b;
  if(op == '+') cout << a+b << endl;
  else dunk (a-b);
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

int s=15;
for(int i=0;i<5;i++){
	int a;
	cin>>a;
	s-=a;
}
cout<<s;


return 0;
}

Measured memory_bytes: 3620
<?php
$n = trim(fgets(STDIN));
$as = explode(" ", fgets(STDIN));
$sum = 0;
$min = $max = (int)$as[0];
foreach($as as $a) {
    $a = (int)$a;
    $sum += $a;
    if($min>$a) $min = $a;
    if($max<$a) $max = $a;
}
printf("%d %d %d\n", $min, $max, $sum);



Measured memory_bytes: 10976
a,b=map(int,input().split())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors

import random

def is_prime(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True
  
div=list(set(make_divisors(a))&set(make_divisors(b)))
n=len(div)
ans=0
for i in range(n):
  if is_prime(div[i]):
    ans+=1
print(ans+1)

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

long long gcd(long long a, long long b){
  if(a < b) swap(a, b); 
  if(a % b == 0) return b;
  else return gcd( a - b, b);
}

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

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

Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int,input().split())

ans = 10**100

s = [-ans] + [int(input()) for i in range(a)] + [ans]
t = [-ans] + [int(input()) for i in range(b)] + [ans]
x = [int(input()) for i in range(q)]


ans = 10**100

for i in range(q):
    ans = 10**100
    s_idx = bisect.bisect_left(s,x[i])
    t_idx = bisect.bisect_left(t,x[i])
    s_idx -= 1
    t_idx -= 1
    #print(x[i],s_idx,t_idx)
    for j in range(2):
        for k in range(2):
            ans = min(ans,abs(x[i] - s[s_idx+j]) + abs(s[s_idx+j] - t[t_idx+k]),abs(x[i] - t[t_idx+k]) + abs(s[s_idx+j] - t[t_idx+k]))
            
    print(ans)  

Measured memory_bytes: 16132
#include<iostream>
using namespace std;
void calc() {
    string s; cin >> s;
    int max = 0;
    int cnt = 0;
    while (1) {
        if (s.size() == 1) {
            cout << cnt << endl;
            return;
        }
        cnt++;
        if (cnt == 1e9) {
            cout << -1 << endl;
            return;
        }
        for (int i = 1; i < s.size(); ++i) {
            int a = stoi(s.substr(0, i));
            int b = stoi(s.substr(i, s.size() - i));
            //cout << a * b << endl;
            max = max > a * b ? max : a * b;
        }
        s = to_string(max);
        max = 0;
        //cout << "s " << s << endl;
    }
}
int main() {
    int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        calc();
    }
    return 0;
}



Measured memory_bytes: 3272
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int64 n; cin >> n;
		vector<int64> a(n), ans(n);
		rep (i, n) {
			cin >> a[i];
		}
		//最初の頂点をx2と置く
		int64 x2 = 0;
		//ダムは円形につながっているので交互に加算と減算を繰り返す
		rep (i, n) {
			if (i%2) x2 -= a[i];
			else x2 += a[i];
		}
		//ダムの値を利用しているので、山の降水量の半分が求まる
		ans[0] = x2 / 2;
		//求まった山への降水量を利用して残りの山への降水量を求める
		rep (i, n - 1) {
			ans[i + 1] = a[i] - ans[i];
		}
		//2倍して山への降水量を求める
		rep (i, n) ans[i] *= 2;
		rep (i, n) {
			cout << ans[i] << endl;
		}
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 2944
import sys

input = lambda: sys.stdin.readline().rstrip()

n = int(input())
X_L = []
X_L_append = X_L.append
for _ in range(n):
    x, l = map(int, input().split())
    X_L_append((x+l, x-l))
X_L.sort()

ans = n
tmp = X_L[0][0]
for upper, lower in X_L[1:]:
  if lower < tmp:
    ans -= 1
  else:
    tmp = upper

print(ans)

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

int main(){
    int N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    int ans = 0;
    bool odd = true;
    while(odd)
    {
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 == 1 )
            {
                odd = false;
                break;
            } else
            {
                A[i] /= 2;
            }
        }
        if(odd){
            ans++;
        }
    }
    
    cout << ans << endl;
      
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        String s = (a<b && b<c) ? "Yes":"No";
        System.out.println(s);
    }
}



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

int main(){
    int a,b,c,x,y; cin>>a>>b>>c>>x>>y;

    long long int min=100000000000;
  
    long long int s;
    for(int i=0;i<=max(x,y)*2;i+=2){
        
        s=c*i+a*max(0,x-i/2)+b*max(0,y-i/2);

        if(s<min){
            min=s;
        }
    }    

    cout<<min<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    double a, b, x, theta;
    cin >> a >> b >> x;
    if (a * b * a > x * 2) theta = atan(b*b*a*0.5/x);
    else theta = atan(2*b/a - 2*x/(a*a*a));
    theta = theta * 180 / M_PI;
    printf("%.10f\n", theta);
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = (n - 1) * (m - 1);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
use std::io;


fn main() {
    let n = read_one::<usize>();
    let mut an = read::<usize>();
    an.sort();
    an.reverse();

    let mut ans = 0;
    for i in 0..n {
        ans += an[2 * i + 1];
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 13428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b, c;
  cin >> a >> b >> c;
  if(a + b == c || b + c == a || a + c == b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
typedef long long int ll;

ll gcd_stein(ll u, ll v) {
  ll k, t;

  /* u, vどちらかが奇数になるまで2で割り続ける */
  k = 0;
  while((0 == (u & 1)) && (0 == (v & 1))) {
    k++;
    u /= 2;
    v /= 2;
  }

  if ((u & 1) == 0) {
    t = u / 2;
  } else {
    t = -v;
  }

  do {
    /* tが偶数である限り、2で割り続ける */
    while ((t & 1) == 0) t /= 2;

    if (t > 0) {
      u = t;
    } else {
      v = -t;
    }

    t = u - v;
  } while (0 != t);
  return u * (1 << k);
}


int main(){
		ll a, b, r, tmp=0;
		ll cnt=1;
		cin>>a>>b;
    r = gcd_stein(a, b);

		for(ll i = 2; i * i <= r; i++) {
      while(r % i == 0) {
				if(i!=tmp) cnt++;
        r /= i;
				tmp=i;
     }
   }
	 if(r!=1)cnt++;


      cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  if(x<a){
    cout<<x%MOD<<endl;
    return 0;
  }
  
  ll ans=(x-a)/(a-b)+1;
  ans%=MOD;
  b%=MOD;
  x%=MOD;
  ans=ans*b%MOD+x;
  ans=(ans+MOD)%MOD;
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

ModInt<MOD> comb(int n, int r) {
    if (n-r < r) r = n-r;
    ModInt<MOD> ret = 1;
    for (int i = n; i > n-r; i--) ret *= i;
    for (int i = 2; i <= r; i++) ret /= i;
    return ret;
}

ModInt<MOD> kaijou (int n) {
    ModInt<MOD> res = 1;
    for (int i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    if (n > m) swap(n, m);
    if (n + 1 < m) { cout << 0 << endl; return 0; }
    
    ModInt<MOD> ans = kaijou(n);
    ans *= (kaijou(m));
    if (n == m) ans *= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
  ll A, V;
  cin >> A >> V;
  ll B,W;
  cin >> B >> W;
  ll T;
  cin >> T;
  ll D=abs(A-B);
  ll D2=(V-W)*T;
  puts(D<=D2?"YES":"NO");
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int arr[3005][3005];
int dp[3005][3005][4];

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    int r,c,k;
    cin >> r >> c >> k;

    
    

    // dp[r][c][0] did'nt pick this item
    // dp[r][c][1] picked this item , and first to pick
    // dp[r][c][2] picked this item , and second consecutive
    // dp[r][c][3] picked this item , and third consecutive

    for(int i = 1; i <= k; i++)
    {
      int x,y,val;
      cin >> x >> y >> val;
      arr[x][y] = val;
    } 




    

    for(int i = 1; i <= r; i++)
    {
      for(int j = 1; j <= c; j++)
      {
        for(int l = 0; l <= 3; l++)
        {
          dp[i][j][0] = max({dp[i][j][0],dp[i-1][j][l]});
        }

        for(int l = 1; l <= 3; l++)
        {
          dp[i][j][l] = max({dp[i][j][l],dp[i][j-1][l-1] + arr[i][j],dp[i][j-1][l]});
        }

        for(int l = 1; l <= 3; l++)
        {
            for(int p = 1; p <= 3; p++)
            {
               dp[i][j][l] = max(dp[i][j][l],dp[i-1][j][p] + arr[i][j]);
            }
          
        }
      }
    }

  
    cout << max({dp[r][c][0],dp[r][c][1],dp[r][c][2],dp[r][c][3]});




    return 0;
}


Measured memory_bytes: 355688
#include <iostream>
#define int long long
using namespace std;
signed main(){
    int n, sum=0;
    cin >> n;
    int A[n+1]={0}, C[n];
    for(int i=0;i<n;i++){
        cin >> C[i];
        A[C[i]]++;
    }

    for(int i=0;i<=n;i++){
        sum += A[i]*(A[i]-1)/2;
    }

    for(int i=0;i<n;i++){
        cout << sum-A[C[i]]*(A[C[i]]-1)/2+(A[C[i]]-1)*(A[C[i]]-2)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
import math
n, d = input().split()
xi, yi = 0, 0
l = []
cnt = 0
for i in range(int(n)):
    xi, yi = input().split()
    xi, yi = float(xi), float(yi)
    dist = math.sqrt(pow(xi, 2) + pow(yi, 2))
    if dist <= float(d):
      cnt += 1
print(cnt)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define pb push_back
#define fi first
#define se second
 
const ll MOD = 1000000007;

int exponent(int a, int b);

int main() {
   int n; scanf("%d", &n);
   int dgt = (int) log10(n) + 1;
   int ans = 0;
   for (int i = 1; i < dgt; i += 2)
      ans += 9 * exponent(10, i - 1);
   if (dgt % 2 == 1)
      ans += n - exponent(10, dgt - 1) + 1;
   printf("%d", ans);
   return 0;
}
int exponent (int a, int b) {
   int ans = 1;
   for (int i = 0; i < b; ++i)
      ans *= a;
   return ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define LL  long long
#define LIM 3000


LL sum, csum[LIM+5], dp[LIM+5][LIM+5], ara[LIM+5];
bool vis[LIM+5][LIM+5];

LL f(int lft, int rht){
    if(lft == rht) return ara[lft];
    if(lft > rht) return 0;
    if(vis[lft][rht]) return dp[lft][rht];
    vis[lft][rht] = 1;
    LL takeLeft = ara[lft] + (csum[rht]-csum[lft]) - f(lft+1, rht);
    LL takeRight = ara[rht] + (csum[rht-1]-csum[lft-1]) - f(lft, rht-1);
    return dp[lft][rht] = max(takeLeft, takeRight);
}

int main(){
    int n; cin>>n;
    for(int i = 1; i <= n; i++) cin>>ara[i];
    for(int i = 1; i <= n; i++){
        csum[i] = csum[i-1] + ara[i];
        sum += ara[i];
    }

    LL res = f(1, n);
    cout<<(res-(sum-res))<<'\n';
    //cout<<sum<<'\n';
    //cout<<res<<'\n';
}




Measured memory_bytes: 58764
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String  str = br.readLine() ;
		char result = 0 ;  //????????????????????¨???????????????
		StringBuilder data = new StringBuilder(str);
		
		for(int i = 0; i < str.length(); i++) {
		   char msg = str.charAt(i);
		   
		//???????????????????°????????????????????????§??§????????????????????????      
		   if(Character.isLowerCase(msg)){
			    result = Character.toUpperCase(msg);
			 	data.setCharAt(i, result);
		   }
		//????????????????????§???????????????????????§?°?????????????????????????
		   else if(Character.isUpperCase(msg)) {
			    result = Character.toLowerCase(msg);
				data.setCharAt(i, result);    //????????§????????????????????????????????????????????????????????????????????????ch????¨???????????????????
		   }
		}
		System.out.println(data);
	
	}
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    ll n;
    cin >> n;
    map<ll, int> mlli;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            mlli[i]++;
            n /= i;
        }
    }
    int ans = 0;
    if (n != 1)
        ans = 1;
    for (const auto& [key, value] : mlli) {
        int v = value;
        int cnt=1;
        while (v >=cnt) {
            ans++;
            v-=cnt;
            cnt++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3612
input = input()
a,b,c = map(int,input.split())
if a < b :
    if b < c:
        print(f'{a} {b} {c}')
    else :
        print(f'{a} {c} {b}')
elif b < c:
    if a < c:
        print(f'{b} {a} {c}')
    else:
        print(f'{b} {c} {a}')
elif c < a:
    if  b < a:
        print(f'{c} {b} {a}')
    else:
        print(f'{c} {a} {b}')


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

template<typename T, typename E, typename F, typename G, typename H>
class LazySegmentTree {
  int n, height;
  F f; G g; H h; const T ti; const E ei;
  vector<T> dat; vector<E> laz; vector<int> highest;

  void propagate(int k) {
    if(laz[k] != ei) {
      laz[2*k] = h(laz[2*k],laz[k]); laz[2*k+1] = h(laz[2*k+1],laz[k]);
      dat[k] = g(dat[k],laz[k],n/highest[k]);
      laz[k] = ei;
    }
  }
  inline void recalc(int k) {
    while(k >>= 1) dat[k] = f(g(dat[2*k],laz[2*k],n/highest[2*k]),g(dat[2*k+1],laz[2*k+1],n/highest[2*k+1]));
  }
  inline void thrust(int k) {
    for(int i = height; i > 0; i--) propagate(k >> i);
  }
public:
  LazySegmentTree(int _n, F f, G g, H h, T ti, E ei): f(f), g(g), h(h), ti(ti), ei(ei) {
    n = 1; height = 0;
    while(n < _n) n <<= 1, height++;
    dat.assign(2*n,ti); laz.assign(2*n,ei); highest.assign(2*n,0);
    int c = 1;
    for(int i = 1; i < 2*n; i++) {
      if(c*2 <= i) c <<= 1;
      highest[i] = c;
    }
  }
  void set(int k, T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int a, int b, const E x) {
    thrust(a += n); thrust(b += n-1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l],x), ++l;
      if(r & 1) --r, laz[r] = h(laz[r],x);
    }
    recalc(a); recalc(b);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T l = ti, r = ti; b++;
    while(a < b) {
      if(a & 1) l = f(l,g(dat[a],laz[a],n/highest[a])), a++;
      if(b & 1) b--, r = f(g(dat[b],laz[b],n/highest[b]),r);
      a >>= 1; b >>= 1;
    }
    return f(l,r);
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  auto f = [](ll a, ll b){return min(a,b);};
  auto g = [](ll a, ll b, int l){return a+b;};
  auto h = [](ll a, ll b){return a+b;};
  LazySegmentTree<ll,ll,decltype(f),decltype(g),decltype(h)> lst(n+1,f,g,h,INF,0);
  rep(i,n) lst.set(i,0);
  lst.build();
  vector<ll> ans;
  rep(i,q) {
    int t;
    cin >> t;
    if(t == 0) {
      int l, r; ll x;
      cin >> l >> r >> x;
      lst.update(l,r+1,x);
    } else {
      int l, r;
      cin >> l >> r;
      ans.push_back(lst.query(l,r+1));
    }
  }
  for(auto x : ans) cout << x << endl;
  return 0;
}


Measured memory_bytes: 8936
#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 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);
  ll n, a, b;
  cin >> n >> a >> b;
  ll mn = a*(n-1)+b;
  ll mx = a+b*(n-1);
  cout << max(mx-mn+1, 0LL) << "\n";
  return 0;
}


Measured memory_bytes: 3612