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

int t[100010],x[100010],y[100010];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool f = 1;
  for (int i = 1; i <= n; i++) {
    int tt = t[i] - t[i-1];
    int xx = abs(x[i] - x[i-1]);
    int yy = abs(y[i] - y[i-1]);
    if (tt < xx + yy) {
      f = 0;
      break;
    }
    tt -= xx + yy;
    if (tt % 2 != 0) {
      f = 0;
      break;
    }
  }
  cout << (f?"Yes":"No") << endl;
}

/*　【提出前に確認すること】
・コンパイルできるか
・テストケース試したか
・オーバーフローあるか
*/

Measured memory_bytes: 1408
/*___________Bismillahir Rahmanir Rahim__________*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define uni(a)           a.erase(unique(a.begin(),a.end()),a.end())
#define vsum(a)          accumulate(a.begin(),a.end(),0)
#define vmax(a)          *max_element(a.begin(),a.end())
#define vmin(a)          *min_element(a.begin(),a.end())
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define yes              cout<<"YES"<<endl
#define no               cout<<"NO"<<endl
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;
    ll i, j, k, a[n];
    for(i=0; i<n; i++) cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    for(i=0; i<n; i++)
    {
        for(j=0; j<i; j++)
        {
            for(k=0; k<j; k++)
            {
                if(a[k]!=a[j] && a[i]!=a[j] && a[k]+a[j]>a[i])
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*_________________Alhamdulillah_________________*/


Measured memory_bytes: 3600
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vii a;
    vi dp;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>k>>n;
    a.clear();a.reserve(n);

    fo(i,n)
    {
        cin>>x>>y;
        a.pb({x,y});
    }

    dp.resize(2e4+1,INF);
    dp[0]=0;
    lli ans=INF;
    repA(i,1,20000)
    {
        for(auto x:a)
        if(x.X<=i)
            dp[i]=min(dp[i],dp[i-x.X]+x.Y);
        if(i>=k)
            ans=min(ans,dp[i]);
    }

    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

int N,a,b,cnt=0;

int main(){
    cin>>N;
    string A="",B="",C="";
    char tmp;
    rep(i,N){
        cin>>tmp;
        A+=tmp;
    }
    rep(i,N){
        cin>>tmp;
        B+=tmp;
    }
    rep(i,N)C+=(i+1+'0');
    do{
        if(A==C)a=cnt;
        if(B==C)b=cnt;
        cnt++;
    }while(next_permutation(ALL(C)));
    out(abs(a-b));
    
}


Measured memory_bytes: 256
n, m = [int(x) for x in raw_input().split()]
red = [True] + [False] * (n - 1)
cnt = [1] * n
for _ in range(m):
  x, y = [int(x) - 1 for x in raw_input().split()]
  cnt[x] -= 1
  cnt[y] += 1
  if red[x]:
    red[y] = True
    if cnt[x] == 0:
      red[x] = False

print sum(red)

Measured memory_bytes: 7284
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    int ans = 1;
    for(int i = 0;i < N;i++){
        if(ans > K)ans += K;
        else ans *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define pa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define pv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define read(v) fl(i,0,v.size()-1) cin>>v[i];
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define vll vector<ll>
#define sll set<ll>
#define spll set<pll>
#define dl(x) cout<<#x<<"="<<x<<nl;
#define d(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define ff first
#define ss second
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=-1e18;
    ans=max(ans,b*d);
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,a*c);
    cout<<ans<<nl;

}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

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

const int MAX_N = 1e5+12;
int N, T;
ll A[MAX_N];

void solve()
{
	set<ll> prices;
	ll mx = 0, mc = -1;
	for(int i=0;i<N;++i){
		auto it = prices.begin();
		if(it != prices.end() && *it < A[i]){
			if(mx < (A[i]-(*it))){
				mx = A[i]-(*it);
				mc=1;
			}else if(mx == (A[i]-(*it))){
				mc++;
			}
		}
		prices.insert(A[i]);
	}
	cout << mc << '\n';
}

int main()
{
	cin >> N >> T;
	for(int i=0; i<N; ++i) cin >> A[i];
	solve();
	return 0;
}

Measured memory_bytes: 9060
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,0,s.size()){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	int count = 0;
	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			count++;
			a[i] /= 2;
		}
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
// S N E W
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

int H, W;
char map[20][20];
P a, b;
int d[20][20];
std::string pattern;

void bfs(){
    REP(i, 20){
        REP(j, 20){
            d[i][j] = INF;
        }
    }

    std::queue<State> q;
    q.push(mp(0, a));
    d[a.second][a.first] = 0;

    while(!q.empty()){
        State s = q.front(); q.pop();
        int cost = s.first;
        P p = s.second;

        if(d[p.second][p.first] < cost){continue;}
        
        REP(i, 4){
            int nx = p.first + dx[i],
                ny = p.second + dy[i];
            if(0 <= nx && nx < W &&
               0 <= ny && ny < H &&
               d[ny][nx] > cost + 1 && map[ny][nx] == '.'){
                q.push(mp(cost+1, mp(nx, ny)));
                d[ny][nx] = cost + 1;
            }
        }
    }
}

State buster(){
    std::string table = "2864";
    int index = 0, t = 1;
    while(t <= 400){
        REP(i, 4){
            if(pattern[index] == table[i]){
                int nx = b.first + dx[i], ny = b.second + dy[i];
                if(0 <= nx && nx < W &&
                   0 <= ny && ny < H){
                    b = mp(nx, ny);
                }
                break;
            }
        }

        if(t >= d[b.second][b.first]){
            return mp(t, b);
        }

        index = (index + 1) % pattern.size();
        t++;
    }

    return mp(t, mp(-1, -1));
}

int main(){
    while(std::cin >> H >> W, H){
        REP(i, H){
            REP(j, W){
                std::cin >> map[i][j];
                if(map[i][j] == 'A'){
                    a = mp(j, i);
                    map[i][j] = '.';
                }else if(map[i][j] == 'B'){
                    b = mp(j, i);
                    map[i][j] = '.';
                }
            }
        }

        std::cin >> pattern;

        bfs();

        // REP(i, H){
        //     REP(j, W){
        //         printf("%d, ", d[i][j]);
        //     }
        //     puts("");
        // }

        State res = buster();
        if(res.first > 400){
            puts("impossible");
        }else{
            printf("%d %d %d\n", res.first, res.second.second, res.second.first);
        }
    }
}

Measured memory_bytes: 1232
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	if (s == "AAA" || s == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int max = 0, min = 1919810;
        int N = s.nextInt();
        for(int i = 0; i < N; i++){
            int ai = s.nextInt();
            if(ai > max)
                max = ai;
            if(ai < min)
                min = ai;
        }
        System.out.println(max - min);
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int S=1;
  for (int i=0; i<N; i++) {
    if (2*S<=S+K)
      S=S*2;
    else
      S=S+K;
  }
  cout << S << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const long long mod=1e9+7;
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 check(int a){
    int res=0;
    while(a!=0){
        res+=a-(a/10)*10;
        a/=10;
    }
    return res;
}



int main(){
    int n;
    cin>>n;
    int a,b,count=0;
    cin>>a>>b;
    for(int i=1;i<=n;i++){
       int k=check(i);
       if(k>=a&&k<=b)count+=i;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int n;
  cin >> n;
  vector<vector<ll>> a(n, vector<ll>(n));
  rep(i, n) rep(j, n) cin >> a[i][j];

  // i->j より i->k->j の方が短い場合は -1 を返す
  rep(i, n) {
    rep(j, n) {
      if (i == j) continue;
      rep(k, n) {
        if (i == k || j == k) continue;
        if (a[i][k] + a[k][j] < a[i][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }

  auto b = a;

  // i->j と i->k->j が同じ場合は i->j は削除する
  rep(i, n) {
    rep(j, n) {
      if (i == j) continue;
      rep(k, n) {
        if (i == k || j == k) continue;
        if (a[i][k] + a[k][j] == a[i][j]) {
          b[i][j] = INF;
        }
      }
    }
  }

  ll ans = 0;
  rep(i, n) rep(j, n) {
    if (i < j) continue;
    if (b[i][j] == INF) continue;
    ans += b[i][j];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4708
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
///////////////////////////////////////
ll PowMod_RepeatSquaring(ll N, ll P, ll M) {
	if (P == 0)return 1;
	if (P % 2 == 0) {
		ll t = PowMod_RepeatSquaring(N, P / 2, M);
		return t * t%M;
	}
	return N * PowMod_RepeatSquaring(N, P - 1, M);
}
int main() {
	ll N; cin >> N;
	ll K; cin >> K;
	COMinit();
	ll key = 0;
	vector<ll>sum, SUM;
	sum.push_back(0);
	SUM.push_back(N);
	REP(i, N + 1) {
		sum.push_back(sum[i] + (i + 1));
	}
	REP(i, N+1) {
		SUM.push_back(SUM[i] + (N - 1 - i));
	}
	for (int i = K; i <= N+1;++i) {
		key += (SUM[i - 1] - sum[i - 1] + 1);
		key %= INF;
	}
	cout << key << endl;
	return 0;
}


Measured memory_bytes: 19712
N = int(input())
S = list(input())
Out =  S[:]
while len(S) > 0:
	if S[0] == ")":
		Out.insert(0,"(")
		del S[0]
	elif S[0] == "(":
		for j in range(len(S)):
			if S[j] == ")":
				del S[j]
				del S[0]
				break
			elif j == len(S) - 1 :
				Out.append(")")
				del S[0]
print(''.join(Out))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var M = int.Parse(Console.ReadLine());
        long digitSum = 0;
        long digits = 0;

        for (int i = 0; i < M; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var d = vals[0];
            var c = vals[1];
            digitSum += d * c;
            digits += c;
        }
        var round = (digitSum - 1) / 9 + digits - 1;

        Console.WriteLine(round);
    }
}

Measured memory_bytes: 15380
#pragma GCC opointimize("Ofset_asc")
#pragma GCC opointimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC opointimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        // freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vector<int> v(n);
    int x=0;
    loop(i,0,n)
    {
        IN v[i];
        x^=v[i];
    }
    loop(i,0,n)
    {
        OUT (x^v[i])<<" ";
    }
    OUT endl
    return 0;
}

Measured memory_bytes: 3960
import math
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
h = [0 for i in range(n)]
judge = False
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())
for i in range(0, 101):
    for j in range(0, 101):
        for k in range(0, n):
            if h[k] != 0:
                true_h = h[k] + int(math.fabs(x[k]-i)) + int(math.fabs(y[k]-j))
                break
        judge = True
        for k in range(n):
            dum_h = max(true_h-int(math.fabs(x[k]-i)) - int(math.fabs(y[k]-j)), 0)
            if h[k] != dum_h:
                judge = False
                break
        # print(k)
        if judge is True:
            break
    if judge is True:
        break

print("{} {} {}".format(i, j, true_h))


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll A, B;
    cin >> A >> B;
    if (A >= 13)
        cout << B << endl;
    else if (A >= 6)
        cout << B / 2 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    ll m = min(a, k);
    a -= m;
    k -= m;
    if (k > 0) {
        m = min(k, b);
        b -= m;
        k -= m;
    }
    cout << a << " " << b << endl;
    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i, j, k, h, w, num[27];
	char A[101][101];

	scanf("%d %d",&h, &w);
	for(i = 0;i < h;i ++)
		scanf("%s", A[i]);

	for (i = 0; i < 26; i++)
		num[i] = 0;



	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			for (k = 0; k < 26; k++)
				if (A[i][j] == 'a' + k)
					num[k] ++;

	
	
	int H, W;

	if (h % 2 == 0)
		H = h;
	else
		H = h - 1;

	if (w % 2 == 0)
		W = w;
	else
		W = w - 1;

	int four_n = W * H / 4;
	int two_n = (w * h - W * H) / 2;
	int one_n = (w * h - W * H) % 2;


	int four_c = 0, two_c = 0, one_c = 0;
	for (i = 0; i < 26; i++) {
		four_c += num[i] / 4;
		two_c += (num[i] % 4) / 2;
		one_c += (num[i] % 4) % 2;
	}


	if (four_c >= four_n && one_c == one_n)
		printf("Yes");
	else
		printf("No");

	





	return 0;
}

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

using namespace std;

const int MAX = 100005;
int lt[MAX], rt[MAX];

int main() {
	int w; cin >> w;
	vector<int> a(w);
	for (auto& e : a) cin >> e;
	lt[0] = (a[0] == 0 ? 1e9 : -1);
	for (int i = 1; i < w; ++i) {
		if (a[i] == 0) lt[i] = 1e9;
		else if (a[i] > 0) lt[i] = lt[i - 1] - 1;
		else lt[i] = min(lt[i - 1], -a[i]) - 1;
	}
	rt[w - 1] = (a[w - 1] == 0 ? 1e9 : -1);
	for (int i = w - 2; i >= 0; --i) {
		if (a[i] == 0) rt[i] = 1e9;
		else if (a[i] > 0) rt[i] = rt[i + 1] - 1;
		else rt[i] = min(rt[i + 1], -a[i]) - 1;
	}
	long long ans = 0;
	for (int i = 0; i < w; ++i) {
		if (a[i] <= 0) continue;
		ans += min(a[i] - 1, max(max(lt[i], rt[i]), -1)) + 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
long long a,b,fr[200005],c,d,e[200005],ans;
int findb(int x)
{
	if(fr[x]==x)
	return x;
	else
	return fr[x]=findb(fr[x]);
}
int main()
{
	cin>>a>>b;
	for(int i=0;i<=a;i++)
	fr[i]=i;
	for(int i=0;i<b;i++)
	{
		cin>>c>>d;
		if(findb(c)!=findb(d))
		fr[findb(c)]=findb(d);
	}
	for(int i=1;i<=a;i++)
	e[findb(i)]++;
	for(int i=1;i<=a;i++)
	ans=max(ans,e[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11364
#include<stdio.h>
int main(void){
    int w,h,x,y,r;
    
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    
    if((x+r<=w&&x-r>=0)&&(y+r<=h&&y-r>=0)){
        printf("Yes\n");
    }else{
        printf("No\n");
        
    }
    return 0;
}


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

int N, total=0;

int main() {
    cin >> N; 
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) {
            for(int k=1; k<=N; k++) {
                total++; 
            }
        }
    }
    cout << total << endl; 
}


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


int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(rng(s));
  bool ok = false;
  int cnt = 0, nt = 0;
  rep(i,n) {
    if(s[i]=='T') nt++;
    if(!ok&&s[i]=='T') ok = true;
    else if(ok&&s[i]=='S'&&nt>0) {
      cnt++;
      nt--;
    }
  }
  int ans = n-cnt*2;
  if(ans<0) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3720
import math
n=int(input())
waru=10**9+7

li=[]
li2=[]

for i in range(2,n+1):
    tmp=math.factorial(n)
    flag=1
    for j in range(len(li)):
        if i%li[j]==0:
            flag=0
            break
    if flag==1:
        li.append(i)
        li2.append(0)
        while tmp%i==0:
            li2[len(li)-1]+=1
            tmp=tmp//i
ans=1
# print(li)
# print(li2)
for i in range(len(li2)):
    ans*=li2[i]+1
print(ans%waru)

Measured memory_bytes: 54360
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7


def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)

n, m = MAP()
a = LIST()
a0 = a[0]
aa = 0
while a0 % 2 == 0:
    a0 //= 2
    aa += 1
for i in range(1, n):
    ai = a[i]
    for _ in range(aa):
        if ai % 2 == 1:
            print(0)
            exit()
        ai //= 2
    if ai % 2 == 0:
        print(0)
        exit()

l = 1
for i in range(n):
    l = lcm(l, a[i])
ans = 2 * m // l
ans = ans // 2 + ans % 2
print(ans)

Measured memory_bytes: 85100
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair


int main()
{
    int c=0 , w=0;
  string n ; cin>>n ;

  for(int i =0 ; i<=n.length();i++)
   {

       if(n[i]=='7')
            c++;
        else
            w++;

   }cout<<((c>=1)?"Yes":"No");



}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        if(n/100==n%10){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22736
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
typedef long long ll;
const int N = 1e5+5;
ll minnx[N];
int n;
struct node {
	ll l,r;
}a[N],s[N];

bool cmp(node a,node b){
	return a.l>b.l;
}

int main(){
	cin>>n;
	ll maxx=0,minn=1e17,maxlen=0;
	for(int i=1;i<=n;i++){
		cin>>a[i].l>>a[i].r;
		maxx=max(maxx,a[i].l);
		minn=min(minn,a[i].r);
		maxlen=max(maxlen,a[i].r-a[i].l+1);
	}
	ll ans1=maxlen+max(minn-maxx+1,0ll);
	for(int i=1;i<=n;i++){
		s[i].l=max(minn-a[i].l+1,0ll);
		s[i].r=max(a[i].r-maxx+1,0ll);
	}
	sort(s+1,s+n+1,cmp);
	minnx[n+1]=1e18;
	for(int i=n;i>=1;i--) minnx[i]=min(minnx[i+1],s[i].r);
	ll ans2=0;
	for(int i=1;i<=n-1;i++){
//		cout<<s[i].l<<" "<<s[i].r<<endl;
		ans2=max(ans2,s[i].l+minnx[i+1]);
//		cout<<ans2<<endl;
	}
//	cout<<ans1<<" "<<ans2<<endl;
	cout<<max(ans1,ans2)<<endl;
	
	return 0;
}

Measured memory_bytes: 4224
N, W = map(int, input().split())
dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1, N+1):
    v, w = map(int, input().split())
    
    for j in range(1, W+1):
        dp[i][j] = max(dp[i][j], dp[i-1][j], dp[i][j-1])
        if j >= w:
            dp[i][j] = max(dp[i][j], dp[i][j-w]+v, dp[i-1][j-w]+v)
print(dp[N][W])



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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int x[110], y[110];
signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) { cin >> x[i] >> y[i]; }
    double pi = acos(-1);
    double ans = 0;
    for (double theta = 0; theta < 2 * pi; theta += 1e-6) {
        double a = cos(theta), b = sin(theta);
        double cur = 0;
        for (int i = 0; i < N; i++) {
            double nai = x[i] * a + y[i] * b;
            if (nai > 0) { cur += nai; }
        }
        chmax(ans, cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}


fn main() {
    let _: i64 = input();
    let a_vec = input_vec();
    let mut new_vec = Vec::new();
    for i in 0..a_vec.len() {
        new_vec.push(a_vec[i] - (i + 1) as i64);
    }
    let mut sum = 0;
    // println!("{:?}", new_vec);
    new_vec.sort();
    let median: i64;
    if new_vec.len() % 2 == 0 {
        median = (new_vec[new_vec.len()/2] + new_vec[new_vec.len()/2 - 1]) / 2;
    } else {
        median = new_vec[new_vec.len()/2];
    }
    for n in new_vec {
        sum += (n - median).abs();
    }
    println!("{}", sum);
    
}


Measured memory_bytes: 10492
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
    int n,q;
    cin>>n;
    int* A=(int*)malloc(sizeof(int)*n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    int* m=(int*)malloc(sizeof(int)*q);
    for(int i=0;i<q;i++){
        cin>>m[i];
    }
    int table[20*2000+5]={0};
    table[0]=1;
    for(int i=0;i<n;i++){
        for(int j=20*2000;j>=0;j--){
            if(table[j]==1){
                table[j+A[i]]=1;
            }
        }
    }
    for(int i=0;i<q;i++){
        if(table[m[i]]==1){
            cout<<"yes"<<endl;
        }
        else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3252
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, Q = lr()
STX = [tuple(lr()) for _ in range(N)]
event = []
append = event.append
for s, t, x in STX:
    append((s-x, 0, x))
    append((t-x, -1, x))

for i in range(Q):
    d = ir()
    append((d, 1, i))

event.sort()
answer = [-1] * Q
cur = set()
flag = False
INF = 10 ** 10
min_x = INF
for a, b, c in event:
    if b == 0:
        cur.add(c)
        if c < min_x:
            min_x = c
            flag = True
    elif b == -1:
        cur.remove(c)
        if min_x == c:
            flag = False
    elif b == 1:
        if cur:
            if not flag:
                min_x = min(cur)
                flag = True
            answer[c] = min_x

print('\n'.join(map(str, answer)))


Measured memory_bytes: 134324
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10


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

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}



int main(){
    long long A,B,C; cin >> A >> B >> C;
    long long ans = 0LL;
    if(C-A>=0){
        ans+=A;
        C-=A;

        if(C-B>0){
            ans = ans + 2*B;
            C-=B;
            if(C>0){
                ans++;
            }
        }else{
            ans = ans + B + C;
        }

    } else {
        //C<A
        ans+=C;
        ans+=B;
    }
    cout << ans << endl;



    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<math.h>
#include<stack>
#include<map>
#include<limits.h>
#include<vector>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int N = 2e5+5;
const int Mod = 1e9+7;
#define pi acos(-1)
#define INF 1e9+5
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
/*a[i]+a[j] = j-i(j>i).
a[i]+i = j-a[j];*/
int a[N];
map<int,int> mp;
int main()
{
	int n;sd(n);
	for(int i=1;i<=n;++i) sd(a[i]);
	LL ans = 0;
	for(int i=1;i<=n;++i)
	{
		ans += 1LL*mp[i-a[i]];
		mp[a[i]+i]++;
		//printf("a[i]+i is %d mp is %d\n",a[i]+i,mp[a[i]+i]);
	}
	plr(ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 21668
#include<iostream>
#include<cstdio>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	stack<int> s1;
	stack<pair<int,int> >s2;
	int sum = 0;
	char ch;
	for(int i = 0;cin >> ch;i++){
		if(ch == '\\'){
			s1.push(i);
		}
		else if(ch == '/' && s1.size() > 0){
			int j = s1.top();
			s1.pop();
			int a = i - j;
			sum += a;
			while(s2.size() > 0 && s2.top().first > j){
				a += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j,a));
		} 
	}
	vector<int> ans;
	while(s2.size() > 0){
		ans.push_back(s2.top().second);
		s2.pop();
	}
	cout << sum << endl;
	cout << ans.size();
	reverse(ans.begin(),ans.end());
	for(size_t i = 0;i < ans.size();i++){
		cout << " ";
		cout << ans[i]; 
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3240
//https://beta.atcoder.jp/contests/abc051/tasks/abc051_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int K,S,cnt=0;
    cin >> K >> S;
    for(int X=0;X<=K;X++){
        for(int Y=0;Y<=K;Y++){
            int Z = S - X - Y;
            if(0 <= Z and Z <=K) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
#from collections import deque
N=int(input())
A=[int(input())-1 for i in range(N-1)]
A=[0]+A
table=[[] for i in range(N)]
for i in range(1,N):
    table[A[i]].append(i)
#print(table)

num=[-1]*N
def dfs(s):
    if num[s]!=-1:
        return num[s]
    child=len(table[s])
    if child==0:
        num[s]=0
        return 0
    L=[]
    n=0
    for y in table[s]:
        x=dfs(y)
        L.append(x)
    L.sort()
    for l in L:
        n=max(n+1,l+1)
    num[s]=n
    return n

dfs(0)
#print(num)
print(num[0])



Measured memory_bytes: 117396
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int n,pm[10005],pe[10005],pj[10005];

  while(1){
    scanf("%d",&n);
    if(n==0) break;
    
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
      if(pm[i]==100||pe[i]==100||pj[i]==100){
	printf("A\n");
      }else if(pm[i]+pe[i]>=180){
	printf("A\n");
      }else if(pm[i]+pe[i]+pj[i]>=240){
	printf("A\n");
      }else if(pm[i]+pe[i]+pj[i]>=210){
	printf("B\n");
      }else if(pm[i]+pe[i]+pj[i]>=150&&(pm[i]>=80||pe[i]>=80)){
	printf("B\n");
      }else printf("C\n");
    }
  }

  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

  lint sum = 0;
  map<lint, lint> mp;
  for(lint i=0; i<N; i++) {
    lint A;
    cin >> A;
    mp[A]++;
    sum += A;
  }

  lint Q;
  cin >> Q;
  while(Q--) {
    lint B, C;
    cin >> B >> C;

    sum -= mp[B] * B;
    sum += mp[B] * C;

    mp[C] += mp[B];
    mp[B] = 0;
    cout << sum << endl;
  }

}

Measured memory_bytes: 9436
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		long n=Long.parseLong(scan.next());
		long m=Long.parseLong(scan.next());
		if (n>=2 && m>=2){
			long ans=Math.max(0,n-2)*Math.max(0,m-2);
			System.out.print(ans);
		}else if (n==1&&m==1){
			System.out.print(1);
		}else  {
			System.out.print(Math.max(n, m)-2);
		}

	}
}
//end

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <set>

using namespace std;

//?????????????´???°?????????
vector<int> a;

//m????????????????´???°??????????????????
//m??\????????????????????°??§???????????????????????????????????????
vector<int> f(int m) {
	vector<int> ret; //??????????????????
	for (int i = 0; i < a.size();i++) {
		if (m % a[i] == 0) {
			//?????£???????????°
			int t = m / a[i];
			//?????£???????????????????????°??§????????????continue
			if (t % 7 != 1 && t % 7 != 6)continue;
			//i???m????????????????´???°
			ret.push_back(a[i]);
		}
		if (a[i] >= m) {//m????????§???????????????????´???°??????????????§??????
			return ret;
		}
	}
}

int main() {

	for (int i = 1; i <= 300000; i++) {
		if (i % 7 == 1 || i % 7 == 6) {
			a.push_back(i);
		}
	}
	int n;
	while (cin >> n && n != 1) {
		//n????????????????´???°?????????????±???????
		vector<int> b = f(n);
		cout << n << ":";
		for (int i = 0; i < b.size();i++) {
			//1????????§???????´???°?????°???2?????????
			//n????????????????´??????°????????§??????
			if (b[i] > 1 && f(b[i]).size() == 2) {
				cout << " " << b[i];
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  // char型の2次元配列(H×W要素の)の宣言, dataに読み込み
  vector<vector<char>> data(H, vector<char>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  vector<int> cvec = {};
  vector<int> rvec = {};
  
  for (int i = 0; i < H; i++) {
    int ccheck = 0;
    for (int j = 0; j < W; j++) {  
      if (data.at(i).at(j) == '#') {
        ccheck += 1; // #を含む行をマークする  
      }
    }
    
    if (ccheck){
        cvec.push_back(i); // #を含む行番号をrvecに追加していく
    }
    
  }
  
  for (int j = 0; j < W; j++) {
    int rcheck = 0;
    for (int i = 0; i < H; i++) {
      if (data.at(i).at(j) == '#') {
        rcheck += 1; // #を含む行をマークする  
      }
    }
    
    if (rcheck){
        rvec.push_back(j); // #を含む行番号をcvecに追加していく
    }
    
  }
  
  /*
  for (c:cvec){
    cout << c;
  }
  cout << endl;
  
  for (r:rvec){
    cout << r;
  }
  */
  
  
  for (c : cvec){
    for (r : rvec){
      cout << data.at(c).at(r);
      if (r == rvec.at(rvec.size()-1)){
        cout << endl;
      }
    }
  }
  
  
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n,k,i,x,s=0,maxi=0;
    cin>>k>>n;
    for(i=0;i<n;i++){
        cin>>x;
        s+=x;
        maxi=max(maxi,x);
    }
    cout<<max(0,maxi*2-s-1);
    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 = {1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,625,49,343,121,169,289,361,529,841,961,36,216,100,1000,144,196,225,256,324,400,441,484,576,676,784,900};
  int x = sc.nextInt();
  Arrays.sort(a);
  for(int i = a.length-1;i >= 0;i--){
    if(a[i] <= x){
      System.out.println(a[i]);
      break;
    }
  }
}}


Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <vector>
#include <tuple>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef std::vector<int> vi;
typedef std::vector<ll> vl;
typedef std::vector<vi> vvi;
typedef std::vector<vl> vvl;
typedef std::pair<int,int> pii;
typedef std::pair<int,ll> pil;
typedef std::pair<ll,int> pli;
typedef std::pair<ll,ll> pll;
typedef std::vector<std::pair<int,int>> vpii;
#define fori(n) for(int i = 0; i < (n); i++)
#define forj(n) for(int j = 0; j < (n); j++)
#define fork(n) for(int k = 0; k < (n); k++)
#define isz(x) (int)size(x)
#define all(x) std::begin(x), std::end(x)
#define fi first
#define se second
// Input:
template<typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (auto &it : vec) is >> it;
    return is;
}
template<typename T1, typename T2>
std::istream& operator>>(std::istream& is, const std::pair<T1, T2>& p) {
    is >> p.fi >> p.se;
    return is;
}
// Output:
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
    os << "[";
    for (int i = 0; i < vec.size(); i++) os << (i?", ":"") << vec[i];
    return os << "]\n";
}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
    os << "{";
    if(s.begin()!=s.end()) os << *s.begin();
    for (typename std::set<T>::iterator i = s.begin(); i != s.end(); i++) os << ", " << *i;
    return os << "}\n";
}
template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T1, typename T2, typename T3> 
std::ostream& operator<<(std::ostream& os, const std::tuple<T1, T2, T3>& p) {
    return os << "(" << p.first << ", " << p.second << ", " << p.third << ")";
}
template<typename T1, typename T2>
std::pair<T1, T2> operator+(const std::pair<T1, T2>& p1, const std::pair<T1, T2>& p2) {
    return std::pair<T1, T2>(p1.fi+p2.fi,p1.se+p2.se);
}
template<int>
class residue;
template<int Mod>
residue<Mod> pow(residue<Mod> a, int n);
template<int Mod=int(1e9+7)>
class residue
{
public:
    long long val;
    residue(long long Value){
        val = Value<0?(-Value)%Mod: Value%Mod;if(Value<0)*(this)=*(this)*residue(Mod-1);}
    residue operator+(residue A){return residue((val+A.val) % Mod);}
    residue operator*(residue A){return residue((val*A.val) % Mod);}
    residue operator/(residue A){return *(this)*pow(A, -1);}
    operator int(){return val;}
};
template<int Mod=int(1e9+7)>
residue<Mod> pow(residue<Mod> a, ui n) {
    return n?n&1?pow(a*a, n/2)*a:pow(a*a, n/2):residue<Mod>(1);}
template<int Mod=int(1e9+7)>
residue<Mod> pow(residue<Mod> a, int n){
    return n==-1?pow(a, ui(Mod-2)):n<0?pow(pow(a,-1), ui(-n)):pow(a, ui(n));}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cin.tie(nullptr);
	char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
}

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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  int mi=INT_MAX;
  int sum=0;
  for(i=0;i<n;i++)sum+=a[i];
  for(i=0;i<n;i++){
    if(mi>max(sum-n*a[i],n*a[i]-sum)){
      mi=max(sum-n*a[i],n*a[i]-sum);
      cnt=i;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 256