akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,a,b,c;cin >> n >>a >>b >>c;
    vl l(n);rep(i,n)cin >> l[i];
    ll ans=INF;
    rep(i,n){
        rep(j,n){
            rep(k,n){
                if(i==j||j==k||k==i)continue;
                vl o;
                rep(p,n){
                    if(p==i||p==j||p==k)continue;
                    o.pb(l[p]);
                }
                ll tmp=INF;
                rep(p,(ll)pow(4,n-3)){
                    ll x=l[i],y=l[j],z=l[k];
                    ll xcos=0,ycos=0,zcos=0;
                    ll d=p;
                    ll t=0;
                    while(d){
                        if(d%4==1){x+=o[t];xcos+=10;}
                        if(d%4==2){y+=o[t];ycos+=10;}
                        if(d%4==3){z+=o[t];zcos+=10;}
                        d/=4;
                        t++;
                    }
                    xcos+=abs(x-a);ycos+=abs(y-b);zcos+=abs(z-c);
                    chmin(tmp,xcos+ycos+zcos);
                }
                chmin(ans,tmp);
            }
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end()); 
    if(a[0]+a[1]==a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main() {
  int a;
  cin >> a;
  if(a == 1){
    cout << 0;
  }else{
    cout << 1;
  }
  
}

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

int main(){
    int ns,nt;
    cin >> ns;
    vector<int> s_array(ns);
    for(int i=0; i<ns; i++) cin >> s_array.at(i);
    cin >> nt;
    vector<int> t_array(nt);
    for(int i=0; i<nt; i++) cin >> t_array.at(i);
    int count=0;
    for(int i=0; i<nt; i++){
        int num = t_array.at(i);
        for(int j=0; j<ns; j++){
            if(num == s_array.at(j)){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long int l,r;
	cin>>l>>r;
	
		int min=2020;
		
		
			if(r-l>=2019){
				min=0;
			}

	else{
		for(long long int i=l;i<=r;i++){
			for(long long int j=i+1;j<=r;j++){
				int s;
				s=(i%2019)*(j%2019)%2019;
				if(s<min){
					min=s;
				
				}
			}
		}
		
	}
	cout<<min<<endl;
		
	return 0;
}

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

struct Node{
    vector<ll> connections;

    void add(ll n){
        connections.push_back(n);
    }
};
vector<ll> A;
vector<ll> LIS;
vector<Node> Nodes;
vector<ll> ANS;

void solve(ll n, ll p){
    // update ANS, LIS
    // back LIS
    ll update_index, previous_value;
    if(p==-1){
        update_index = 0ll;
        previous_value = LIS[0];
        LIS[0] = A[0];
    }else{
        update_index = lower_bound(LIS.begin(), LIS.end(), A[n]) - LIS.begin();
        previous_value = LIS[update_index];
        LIS[update_index] = A[n];
    }
    ANS[n] = lower_bound(LIS.begin(), LIS.end(), LLONG_MAX) - LIS.begin();
    Node node = Nodes[n];
    for(ll i=0ll;i<node.connections.size();i++){
        ll child = node.connections[i];
        if (child == p){
            continue;
        }
        solve(child, n);
    }
    // back
    LIS[update_index] = previous_value;
}

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    for(ll i=0;i<N;i++){
        cin >> a.at(i);
    }
    A = a;
    vector<ll> lis(N, LLONG_MAX);
    LIS = lis;
    vector<Node> nodes(N, Node());
    for(ll i=0;i<N-1;i++){
        ll v, u;
        cin >> u >> v;
        u--;
        v--;
        nodes[u].add(v);
        nodes[v].add(u);
    }
    Nodes = nodes;
    vector<ll> ans(N, 0);
    ANS = ans;
    solve(0, -1);
    for(ll i=0;i<N;i++){
        cout << ANS[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 54304
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a,b,c,d[10005] = {};
string s,t;

int main(){
    
    cin >> s;
    s[3] = '8';
    P(s);
    
	return  0;
}

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

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
 
int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  string X; cin >> X;
  int l = X.length();
  int result = 0, num = 0;
  rep(i,l) {
    num += (X[i]=='S') ? -1 : 1;
    result = max(result, num*2);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int case1 = 1;

int main()
{
    ll n;
    cin >> n;
    int ar[66] = {};
    ll sum = 0;
    ll p = n/500;
    sum += (p*1000);
    /*int rem = n%500;
    int a = (1000*100)/500;
    p = (rem/100);
    sum += (p*a);
    rem = rem%100;
    a = (1000*50)/500;
    p = (rem/50);
    sum += (p*a);
    rem = rem%50;
    a = (1000*10)/500;
    //cout << a << endl;
    p = (rem/10);
    sum += (p*a);
    //cout << rem/10 << endl;
    rem = rem%10;
    a = (1000*5)/500;
    p = (rem/5);
    sum += (p*a);
    */
    p = n%500;
    sum += (p/5)*5;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(mut n:u64, mut m: u64)->u64{
    while m != 0 {
        if m < n {
            let t = m;
            m = n;
            n = t;
        }
        m = m % n;
    }
    n
}

fn main() {

    let k: u64 = read();
    let mut ans = 0;
    for x in 1..=k{
        for y in 1..=k{
            for z in 1..=k{
                ans += gcd(gcd(x,y),z);
            }
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 2148
S=input()
N=len(S)
if S==S[::-1] and S[0:(N-1)//2]==S[0:(N-1)//2][::-1] and S[(N+3)//2-1:N]==S[(N+3)//2-1:N][::-1]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
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; }
using namespace std;

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

    int n; cin>>n;
    vector<pair<int,bool>> a(n*2);
    rep(i,n){
        cin>>a[i].first;
        a[i].second=true;
    }
    rep(i,n){
        cin>>a[i+n].first;
        a[i+n].second=false;
    }
    sort(all(a));

    int acnt=0,bcnt=0;
    int ans=1;
    rep(i,n*2){
        if(a[i].second){
            if(bcnt==0){
                acnt++;
            }else{
                ans=(ans*bcnt)%mod;
                bcnt--;
            }
        }else{
            if(acnt==0){
                bcnt++;
            }else{
                ans=(ans*acnt)%mod;
                acnt--;
            }
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define LINE 8
#define st 1
#define YOKO 17
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int x=min(A,B);
    int y=min(C,D);
    cout<<x+y;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

//最大公約数
ll gcd(ll a,ll b){
    if(b == 0LL) return a;
    return gcd(b , a % b);
}

//最小公倍数
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;

}

int main(){
    
    
    int n;
    int k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i=0;i < n;i++){
        cin >> h[i];
    }

    sort(h.begin(),h.end());
    ll min = 100000000000;
    for(int i=0;i + k - 1 < n;i++){
        
        ll t = abs(h[i] - h[i + k - 1]);
        if(min > t){
            min = t;
        }

    }


    cout << min << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
struct E {
  int v;
  bool vis;
  E *next, *rev;
};

const int N = 100010;

int n, m;
bool vis[N], par[N];
E* g[N];

E* adde(int u, int v) {
  static E pool[N * 2], *p = pool;
  ++p;
  p->v = v;
  p->next = g[u];
  g[u] = p;
  return p;
}

void dfs(int u) {
  vis[u] = true;
  for (E* p = g[u]; p; p = p->next)
    if (!p->vis) {
      p->vis = p->rev->vis = true;
      if (!vis[p->v]) {
        dfs(p->v);
        if (par[p->v]) {
          printf("%d %d\n", p->v, u);
        } else {
          printf("%d %d\n", u, p->v);
          par[u] ^= 1;
        }
      } else {
        printf("%d %d\n", u, p->v);
        par[u] ^= 1;
      }
    }
}

int main() {
  scanf("%d%d", &n, &m);
  if (m % 2) {
    puts("-1");
    return 0;
  }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    E *p = adde(u, v), *q = adde(v, u);
    p->rev = q;
    q->rev = p;
  }
  dfs(1);
  return 0;
}

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define N 3001
using namespace std;
int w,h;
int dx[]={0,1,0,-1};//^>v<
int dy[]={-1,0,1,0};
vector<int> X,Y,d;
map<int,int> x,y;

int compless(vector<int> A,map<int,int> &M){
  sort(A.begin(),A.end());
  int c=0;
  for(int i=0;i<A.size();i++)if(!M.count(A[i]))M[A[i]]=c++;
  return c;
}

int calc(int y,int x,vector<vector<int> >&mp){
  vector<vector<bool> > used(h,vector<bool>(w,0));
  int res=0;
  while(1){
    res++;
    int i=mp[y][x];
    used[y][x]=1;
    while(1){
      y+=dy[i],x+=dx[i];
      if(y<0||x<0||x>=w||y>=h)return res;
      if(mp[y][x]!=-1&&!used[y][x])break;
    }
  }
  assert(0);
}

int main(){
  int n;
  cin>>n;
  X.resize(n),Y.resize(n),d.resize(n);
  for(int i=0;i<n;i++){
    char ch;
    cin>>X[i]>>Y[i]>>ch;
    if(ch=='^')d[i]=0;
    if(ch=='>')d[i]=1;
    if(ch=='v')d[i]=2;
    if(ch=='<')d[i]=3;
  }
  h=compless(Y,y);
  w=compless(X,x);
  vector<vector<int> >mp(h,vector<int>(w,-1));
  for(int i=0;i<X.size();i++)mp[y[Y[i]]][x[X[i]]]=d[i];

  int ans=1;
  for(int i=0;i<n;i++)ans=max(ans,calc(y[Y[i]],x[X[i]],mp));
  cout <<ans<<endl;

  return 0;
}

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

vector<vector<int>> next_idx;

int solve(int now = 0, int fixed = 0)
{
    int res = 0;
    for (int i = 0; i < 10; i++)
    {
        int next = next_idx.at(now).at(i);
        if (next >= 0)
        {
            if (fixed == 2)
            {
                res++;
            }
            else
            {
                res += solve(next + 1, fixed + 1);
            }
        }
    }
    return res;
}

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

    next_idx = vector<vector<int>>(S.size() + 1, vector<int>(10, -1));
    for (int i = S.size() - 1; i >= 0; i--)
    {
        for (int j = 0; j < 10; j++)
        {
            if (S.at(i) - '0' == j)
                next_idx.at(i).at(j) = i;
            else
                next_idx.at(i).at(j) = next_idx.at(i + 1).at(j);
        }
    }
    cout << solve() << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};





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

	int a,b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;

    return 0;
}


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

int main(){
  int N,K;
  cin >>N>>K;
  
  vector<int> H(N),people(N);
  
  for (int i=0;i<N;i++){
    cin >>H.at(i);
  }
  
  for (int i=0;i<N;i++){
    if (H.at(i)>=K){
      people.at(i)=1;
    }
  }
  int sum=0;
    
  for (int i=0;i<N;i++){
    sum+=people.at(i);
  }
  cout <<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int r, c, k;
ll dp[3005][3005][5];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> r >> c >> k;
  int rc[3000][3000];
  REP(i, r) REP(j, c) rc[i][j] = INF + 10;

  REP(i, k) {
    int y, x, v;
    cin >> y >> x >> v;
    y--; x--;
    rc[y][x] = v;
  }

  REP(i, r) REP(j, c) {
    if(rc[i][j] != INF + 10) {
      FOR(k, 1, 4) {
        dp[i + 1][j][0] = max({dp[i + 1][j][0], dp[i][j][k - 1] + rc[i][j], dp[i][j][k]});
      }

      REP(k, 3) {
        dp[i][j + 1][k + 1] = max({dp[i][j + 1][k + 1], dp[i][j][k] + rc[i][j], dp[i][j][k + 1]});
      }
    } else {
      REP(k, 4) {
        dp[i + 1][j][0] = max({dp[i + 1][j][0], dp[i][j][k]});
      }

      FOR(k, 1, 4) {
        dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
      }
    }
  }

  ll ans = 0;

  REP(i, 4) {
    ans = max(ans, dp[r][c - 1][i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 390904
#include <stdio.h>
int main ()
{
  int x, y;
  y=0;
  scanf("%d",&x);
  while(1){
  if(x == 0)break;
  y=y+1;
  printf("Case %d: %d\n",y, x);
  scanf("%d",&x);
  }
 return 0;
}

Measured memory_bytes: 600
#include <iostream> // Day 04 Daily problem
using namespace std;

int main(){
    int n;
    int cont = 1;
    int cambios = 0;
    cin >> n;
    int arr[n];
    for (int i=0;i<n;i++){
        cin >> arr[i];
        if(arr[i]==cont){
            cont++;
        }else{
            cambios++;
            cont++;
        }
    }
    if(cambios==2 || cambios==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))

def main():
    a, b, c, x, y = MII()
    fee = min(a+b,c*2) * min(x,y)
    if x > y: fee += min(a,c*2)*(x-y)
    else: fee += min(b,c*2)*(y-x)
    print(fee)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
function Main(input) {
    var N = parseInt(input[0], 10);
    var B = input.slice(1).map(n => parseInt(n));

    var sum = B[0];
    for (var i = 1; i < N; i++) {
        if (i === N - 1) {
            sum += B[i - 1];
        } else {
            sum += Math.min(B[i - 1], B[i]);
        }
    }
    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
n, m = map(int, input().split())
array = []
for i in range(n):
    array.append([int(x) for x in input().split()][1:])
res = [0 for x in range(m+1)]
for j in array:
    for k in j:
        res[k] += 1

cnt = 0
for i in res:
    if i == n:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=1; i<=(int)(n); i++)
int main(){
  int n; 
  int64_t c=0;
  cin >> n;
 rep(i,1000){
   for(int j=i;j<=1000000;j++){
     if(i*j<n){
      if(i==j) c++;
      else c+=2;
     }
   }
 }
  cout << c << endl;
}
        

Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main(void){
    // Here your code !
  int c=0;
  string W,T;
  
cin>>W;
for(int i=0; i<W.size();i++){
    W[i]=tolower(W[i]);
}

while(true){

cin>>T;

if(T=="END_OF_TEXT") break;
for(int i=0; i<T.size();i++){
    T[i]=tolower(T[i]);
}
if(T==W) c++;
}

cout<<c<<endl;

}

Measured memory_bytes: 1192
import sys
from heapq import heappush as hpu
from heapq import heappop as hpo
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

base = 10 ** 6
sb = [-(b[i] * base + i) for i in range(N) if a[i] != b[i]]
h = []
for t in sb: hpu(h, t)
res = 0
while len(h):
  v = hpo(h)
  i = -v % base
  v = -v // base
  if v < a[i]:
    print(-1)
    exit(0)
  d = v - a[i]
  x = b[i - 1] + b[(i + 1) % N]
  t = d // x
  if t == 0:
    if v == a[i]: continue
    print(-1)
    exit(0)
  b[i] -= x * (t)
  res += t
  hpu(h, -(b[i] * base + i))
print(res)


Measured memory_bytes: 111096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct state{
	ll w,s,v;
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<state> g(n);
	rep(i,n){
		cin>>g[i].w>>g[i].s>>g[i].v;
	}
	sort(begin(g),end(g),[](const state &a,const state &b){
		return a.w+a.s<b.w+b.s;
	});
	vector<vector<ll>> dp(n+1,vector<ll>(20010,0));
	rep(i,n)rep(j,20010){
		dp[i+1][j]=dp[i][j];
		if(0<=j-g[i].w && j-g[i].w<=g[i].s){
			chmax(dp[i+1][j],dp[i][j-g[i].w]+g[i].v);
		}
	}
	cout<<*max_element(begin(dp[n]),end(dp[n]))<<endl;
	/*
	あるブロックの集合を決め打つと, s+wが小さい順に上から積んでいくのが最適
	(自分の位置以上の重さの上限を与えるものなので)
	あとはナップサック
	*/
}

Measured memory_bytes: 160640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,ans;
    cin>>a>>b>>c;
    if(a-b>c){
    	cout<<0;
    	return 0;
	}
	ans=c-(a-b);
    cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ll long long int
#define PI 3.141592653589793
using namespace std;

int main() {
    int A,B,ans;
    
    cin >> A >> B;
    ans = 6 - A - B;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() 
{
  int n;
  cin >> n;
  char a[n];
  int b[n];
  int i;
  for(i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  char c;
  int d;
  c = 'S';
  for(d = 1;d <= 13;d++){
    for(i = 0;i < n;i++){
      if(c != a[i]){
        continue;
      }else if(d != b[i]){
        continue;
      }else{
        break;
      }
    }
    if(i == n){
      cout << c << " " << d << endl;
    }
  }
  c = 'H';
  for(d = 1;d <= 13;d++){
    for(i = 0;i < n;i++){
      if(c != a[i]){
        continue;
      }else if(d != b[i]){
        continue;
      }else{
        break;
      }
    }
    if(i == n){
      cout << c << " " << d << endl;
    }
  }
  c = 'C';
  for(d = 1;d <= 13;d++){
    for(i = 0;i < n;i++){
      if(c != a[i]){
        continue;
      }else if(d != b[i]){
        continue;
      }else{
        break;
      }
    }
    if(i == n){
      cout << c << " " << d << endl;
    }
  }
  c = 'D';
  for(d = 1;d <= 13;d++){
    for(i = 0;i < n;i++){
      if(c != a[i]){
        continue;
      }else if(d != b[i]){
        continue;
      }else{
        break;
      }
    }
    if(i == n){
      cout << c << " " << d << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    int N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N) cin >>A[i];
    sort(all(A));
    ll end1 = 0 ,end2 = 0;
    ll end = A[0];
    int count;
    rep2(i,1,N){
        if(A[i]==end){
            count ++;
            if(count >=4){
                end2 =end;
                end1 = end;
            }
            if(end!=end1){
                end2 = end1;
                end1 = end;
            }
        }
        else count = 1;
        end = A[i];
    }
    cout <<end1*end2<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    std::string S, T; std::cin >> S >> T;
    int cnt(0);
    for(int i(0), i_len(S.length()); i < i_len; ++i){
        if(S[i] != T[i]) ++cnt;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3920
#include<stdio.h>

int main()
{
    int A1,A2,A3;
    scanf("%d %d %d",&A1,&A2,&A3);
    if((A1+A2+A3)>=22)
        printf("bust\n",A1+A2+A3);
    else
        printf("win\n",A1+A2+A3);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) << "..." << endl;
    }
    // printf("%d\n", N);
    return 0;
}

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

int main()
{
  int n, m, ans;
  int i, sum;
  cin >> n;
  cin >> m;
  vector<int> a(m);
  sum = 0;
  for(i=0; i<m; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  ans = n-sum;
  if(n<sum) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  ll r,D,x;
  cin>>r>>D>>x;

  rep(i,10){
    x = r*x - D;
    cout << x << endl;
  }

  // cout << ans << endl;

}

















//


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return (a / gcd(a, b)) * b; }

#if 0
	auto possible = [&](LL t) {

		return false;
	};
	LL left = 1, right = 1000000000;
	while (right - left > 1) {
		LL mid = (left + right) / 2;
		if (possible(mid)) {
			left = mid;
		} else {
			right = mid;
		}
	}
#endif

void solve(long long x) {
	LL ans = !x;
	cout << ans << endl;
}

int main() {
    long long x;
	std::cin >> x;
	solve(x);
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
ll mod = 1e+9 + 7;

int main(){
    ll N;
    cin >> N;

    ll A[N], B[N];
    REP(i, N){
        int a;
        cin >> a;
        A[i] = a%mod;
        if(i == 0) B[i] = A[i];
        else{
            B[i] = B[i-1] + A[i];
            B[i] = B[i]%mod;
        }
    }
    
    ll ans = 0;
    REP(i, N-1){
        ans += A[i+1]*B[i];
        ans = ans%mod;
    }   


    cout << ans << endl;

    return 0;
}


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

int i;
int iCnt;
int N, K;
int iSum;
int A[ 5010 ];

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

	cin >> N;
	cin >> K;

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

	sort( A, A + N );

	iSum = 0;
	iCnt = 0;
	for( i = N - 1; i >= 0; i-- )
	{
		if( iSum + A[ i ] >= K )
			iCnt = 0;
		else
		{
			iCnt++;
			iSum += A[ i ];
		}
	}

	cout << iCnt << endl;

	return 0;
}


Measured memory_bytes: 384
S = str(input())
Q = int(input())
List = [list(map(str, input().split())) for i in range(Q)]

#print(List)

#S='a'
#Q=4
#List=[['2', '1', 'p'], ['1'], ['2', '2', 'c'], ['1']]
han=0
b=''
for a in List:
    if a[0]=='1':
        han+=1
    if a[0]=='2':
        if (a[1]=='1' and han%2==0) or (a[1]=='2' and han%2==1):
            b+=a[2]
        if (a[1]=='2' and han%2==0) or (a[1]=='1' and han%2==1):
            S=S+a[2]
#print(S)
#print(b)
if han%2==0:
    print(b[::-1]+S)
else:
    print(S[::-1]+b)

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

int main() {
    int N, X, Di = 0;
    int Li[100];
    int i, l;

    cin >> N >> X;

    Li[0] = 0;
    for(i=1; i<=N; i++){
        cin >> l;
        Li[i] = l;
    }

    for(i=0; Di<=X; i++){
        Di += Li[i];
    }

    cout << i-1;
    return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define MAXN 5000
#define INF 0x3f3f3f3f
int main(){
	int n=read(),m=read(),X=read(),Y=read();
	for(int i=1;i<=n;i++)
		X=max(X,read());
	for(int i=1;i<=m;i++)
		Y=min(Y,read());
	puts(Y<=X?"War":"No War");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
using ll = long long int;
 
ll lcm(ll a,ll b){
    if(b == 0) return a;
    return lcm(b,a%b);
}
 
int arr[100010] = {};
 
int main(void){
    
    int n,k;
    cin >> n >> k;
    
    bool f = false;
    
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        if(k <= arr[i]) f = true;
    }
    
    int res = arr[0];
    for(int i = 1; i < n; i++){
        res = lcm(res,arr[i]);
    }
    
    if(k%res == 0 && f ){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    
    
    
    
}

Measured memory_bytes: 640
// inputに入力データ全体が入る
function Main(input) {
  var a,b,c;
  a = Number(input.split('\n')[0].split(' ')[0]);
  b = Number(input.split('\n')[0].split(' ')[1]);
  c = Number(input.split('\n')[0].split(' ')[2]);

  console.log(Math.min(Math.floor(b / a), c));
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  vector<ll> ae(5);
  FORi(5){
    cin>>ae[i];
  }
  sort(ae.begin(),ae.end(),[](ll a,ll b){
    return (a-1)%10<(b-1)%10;
  });
  ll num=0;
  FORi(4){
    ll tmp=((ae[4-i]-1)/10+1)*10;
    //cout<<ae[4-i]<<endl;
    num+=tmp;
  }
  num+=ae[0];
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

  if (a == b && b != c || b == c && c != a || c == a && a != b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
s = input()
l = len(s)
ok = 1

for i in range(a):
    if s[i] == '-':
        ok = 0
if s[a] != '-':
    ok = 0
for i in range(a+1, l):
    if s[i] == '-':
        ok = 0
if ok == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>


using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else if(B % 3 == 0){
		cout << "Possible" << endl;
	}
	else if ((A + B) % 3 == 0)
	{
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B >= 2 * C:
    AB = min(X, Y)
    ans += 2 * AB * C
    X -= AB
    Y -= AB
if A >= 2 * C:
    AB = X
    ans += 2 * X * C
    X -= AB
    Y -= AB
if B >= 2 * C:
    AB = Y
    ans += 2 * Y * C
    X -= AB
    Y -= AB

ans += A * max(0, X)
ans += B * max(0, Y)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b;
  ci(a, b);
  if(a > b){
    co(a - 1);
  }
  else{
    co(a);
  }
}


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

int main()
{
	long long N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}

	int loop = 0;
	long long k = 0;
	int firstTown = -1;
	vector<int> visit(N);	// 何回目の移動で町iを訪れたか
	int move = 0;			// 移動回数
	for (int i = 0; i < N; i++) {
		visit[i] = -1;
	}

	int now = 0;	// 今訪れている町
	do
	{
		if (visit[now] != -1) {
			firstTown = now;
			loop = move - visit[firstTown];
			k = K - visit[firstTown];
			break;
		}
		else {
			visit[now] = move;
			move++;
			now = A[now];
		}
	} while (true);

	if (k < 0) {
		now = 0;
		for (int i = 0; i < K; i++) {
			now = A[now];
		}
		cout << now + 1 << endl;
	}
	else {
		k %= loop;
		now = firstTown;
		for (int i = 0; i < k; i++) {
			now = A[now];
		}
		cout << now + 1 << endl;
	}
	return 0;
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

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

  int n, ans = 0;
  cin >> n;
  vector<pair<string, int>> st(n);
  rep(i, n) {
    string s;
    int t;
    cin >> s >> t;
    st[i] = make_pair(s, t);
    ans += t;
  }
  string x;
  cin >> x;

  rep(i, n) {
    ans -= st[i].second;
    if (st[i].first == x) break;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a, b;
      cin >> a >> b;
      if (a % 2 == 1 && b % 2 == 1){
        cout << "Odd" << endl;
      }
      else {
        cout << "Even" << endl;
      }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    #define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define cint int t;cin>>t;while(t--)
    #define rep(i,b) for(int i=0;i<b;i++)
    #define vint vector<int>
    #define all(v) (v).begin(), (v).end()
    #define pii pair<int,int>
    #define pb push_back
    #define N 10005
    #define input(v) for(int i=0;i<n;i++) cin>>v[i];
    #define mm0(X) memset((X), 0, sizeof((X)))
    #define mm1(X) memset((X), -1, sizeof((X)))
    int mod=1e9+7;
    mt19937 mrand(random_device{}());
    int rnd(int x) { return mrand() % x;}
    int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    
    //variables
    int n;
    
    
    int32_t main() {
        faster;
    
        int n,k;
        cin>>n>>k;
    
        cout<<min(n%k,k-n%k)<<endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n, a[100100] = {}, sum = 0;
	cin >> n;
	rep(i, n) cin >> a[i + 1];
	rep(i, n + 1) sum += abs(a[i] - a[i + 1]);
	rep(i, n) cout << sum - abs(a[i] - a[i + 1]) - abs(a[i + 1] - a[i + 2]) + abs(a[i] - a[i + 2]) << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdio>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 300001
 
using namespace std;
typedef unsigned long long ull;
int n,m,L,R;
char s[MAX],o[5];
set<ull> ans;
const ull B = 9973ULL;
const ull inv = 9063375710536127837ULL;
ull H,Bmax;
 
int main()
{
 
  Bmax = 1;
  L = R = 0;
  scanf("%d %d",&n,&m);
  scanf("%s",&s[0]);
  H = s[0];
 
  rep(_,m)
    {
      scanf("%s",&o[0]);
 
      if(o[0] == 'R')
	{
	  if(o[1] == '+')
	    {
	      R++;
	      Bmax *= B;
	      H = H + s[R]*Bmax; 
	    }
	  else
	    {
	      H = H - s[R]*Bmax;
	      Bmax = Bmax*inv;
	      R--;
	    }
	}
      else
	{
	  if(o[1] == '+')
	    {
	      H = (H-s[L])*inv;
	      Bmax *= inv;
	      L++;
	    }
	  else
	    {
	      L--;
	      H = H * B + s[L];
	      Bmax *= B;
	    }
	}
      ans.insert(H);
    } 
 
  cout << ans.size() << endl;
 
  return 0;
}

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

using namespace std;
#define int long long
const int N=1e5+5;

int n,m,sz,ok,ans;
int cnt[N];
vector<int> adj[N];

void dfs(int u,int type){
    if(ok) return;
    if(type) sz++;
    cnt[u]=type;
    for(int i=0;i<adj[u].size();++i){
        int v=adj[u][i];
        if(ok) return;
        if(cnt[v]==-1)
            dfs(v,1-type);
        else if(cnt[v]==type){
            ok=1;
            return;
        }
    }
}
signed main(){
    cin>>n>>m;
    memset(cnt,-1,sizeof cnt);
    for(int i=1;i<=m;++i){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1,1);
    if(ok) ans=((n-1)*n/2)-m;
    else  ans=sz*(n-sz)-m;
    cout<<ans;
}


Measured memory_bytes: 7424