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

typedef long long ll;

using namespace std;

void solve() {
    int n;

    cin >> n;
    vector< vector<int> > dp(n+1, vector<int>(3));
    vector<int> fun(3);
    for (int i = 0; i < n; i++) {
        cin >> fun[0] >> fun[1] >> fun[2];
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) 
                    dp[i+1][j] = max(dp[i+1][j], dp[i][k] + fun[k]);
            }
        }
    }

    

    cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << endl;
}


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


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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vb vector <bool>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n, k;
void add_self(int& a, int b) {
	a = a + b;
	if (a >= mod) {
		a -= mod;
	}
}
void sub_self(int& a, int b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
}
int main () {
	IOS;
	
	scanf("%d%d", &n, &k);
	vi dp(k + 1);
	dp[0] = 1;
	for (int child = 0; child < n; child++) {
		int up_to;
		scanf("%d", &up_to);
	/*	
		O(n * k^2)
		for (int use = k; use >= 0; use--) {
			for (int here = 1; here <= min(up_to, k - use); here++) {
				dp[use + here] = (dp[use + here] % mod + dp[use] % mod) % mod; 
			}
		}
		*/
		vi fake(k + 1);
		for (int use = k; use >= 0; use--) {
			int temp = dp[use];
			int L = use + 1, R = use + min(up_to, k - use);
			if (L <= R) {
				add_self(fake[L], temp);
				if (R + 1 <= k) {
					sub_self(fake[R + 1], temp);
				}
			}
		}
		int Psum = 0;
		for (int i = 0; i <= k; i++) {
			add_self(Psum, fake[i]);
			add_self(dp[i], Psum);
		}
	}
	printf("%lld\n", dp[k]);
	return 0;
}

Measured memory_bytes: 1024
def howmany(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]


n,m = map(int,input().split())

x = 1
a = [0]*(m+2)
a[0] = -1
a[m+1] = n

if m == 0:
    print(howmany(n+1) % 1000000007)
else:
    for i in range(1,m+1):
        a[i] = int(input())

    if all(a[i+1]-a[i] != 1 for i in range(1,m)):
        for i in range(1,m+1):
            if a[i] - a[i-1] > 1:
                x *= howmany(a[i] - a[i-1] -1)
        if a[m] + 1 == n:
            print(x % 1000000007)
        else:
            x *= howmany(a[m+1]-a[m])
            print(x % 1000000007)
    else: print(0)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
 
#define INF (INT64_MAX/2)
 
int main()
{
	int x, y;
	cin >> x >> y;
 
	long long ans = y - x;
	if( ans < 0 ) ans = INF;
	if( x > y ) {
		if( x < 0 ) {
			ans = abs( y ) - abs( x ) + 2;
		}
		else {
			if( y < 0 ) {
				if( abs( y ) >= abs( x ) ) {
					ans = abs( y ) - abs( x ) + 1;
				}
				else {
					ans = abs( x ) - abs( y ) + 1;
				}
			}
			else {
				if( y == 0 ) ans = ans = abs( x ) - abs( y ) + 1;
				else ans = abs( x ) - abs( y ) + 2;
			}
		}
	}
	else if( x < 0 ) {
		if( y < 0 ) ans = abs( x ) - abs( y );
		else {
			if( abs( y ) >= abs( x ) ) {
				ans = abs( y ) - abs( x ) + 1;
			}
			else {
				ans = min( ans, (long long)(abs( x ) - abs( y ) + 1) );
			}
		}
	}
 
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, k;
  cin >> n >> k;
  map <int, int> mii;
  rep (i, n) {
    int x;
    cin >> x;
    mii[x]++;
  }

  vector<P> top_k;
  for (auto v : mii) {
      top_k.push_back(make_pair(v.second, v.first));
  }
  sort(top_k.rbegin(), top_k.rend());

  //for (auto v : top_k) {
  //  cout << v.first << "    " << v.second << endl;
  //}

  int ans = 0;
  if (mii.size() > k) {
    for (int i = k; i < top_k.size(); i++) ans += top_k[i].first;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14552
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	n = n % 10;
	string ans = "hon";
	if (n == 3)ans = "bon";
	else if (n == 0 || n == 1 || n == 6 || n == 8)
		ans = "pon";
	cout << ans << endl;
}


Measured memory_bytes: 3584
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int a, b, c, d; cin >> a >> b >> c >> d;

    bool res = false;
    if ( abs(a-c) <= d ) res = true;
    if ( abs(a-b) <= d and abs(b-c) <= d ) res = true;

    if ( res ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#define int long long
using namespace std;
const int MAX_N = 1LL << 17, mod = 1000000007LL;

int gcd(int a, int b){
  if(b > a) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}

int lcm(int a, int b){
  int d = gcd(a,b);
  return a/d*b;
}

int n;
int dat[2*MAX_N-1][2];

void init(int n_){
  n = 1LL;
  while(n < n_) n *= 2LL;
  for(int i = 0; i < 2*n-1; ++i){
    dat[i][0] = 1LL;
  }
}

void update(){
  for(int i = n-2; i >= 0; --i){
    int d = gcd(dat[i*2+1][0],dat[i*2+2][0]);
    dat[i][0] = dat[i*2+1][0]/d*dat[i*2+2][0];
    dat[i][1] = (((dat[i*2+2][0]/d)%mod*dat[i*2+1][1])%mod + ((dat[i*2+1][0]/d)%mod*dat[i*2+2][1])%mod)%mod;
  }
}

//[a, b)テ」ツ?ョlcmテ」ツ?ィretテ」ツ?ョテ・ツ?、テ」ツつ津ヲツアツづ」ツつ?」ツつ凝」ツ??
pair<int,int> query(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return make_pair(1LL,0LL);
  if(a <= l && r <= b) return make_pair(dat[k][0],dat[k][1]);
  else{
    pair<int,int> vl = query(a,b,k*2+1,l,(l+r)/2);
    pair<int,int> vr = query(a,b,k*2+2,(l+r)/2,r);
    int d = gcd(vl.first,vr.first);
    int c = ((vr.first/d)%mod*vl.second%mod + (vl.first/d)%mod*vr.second%mod)%mod;
    return make_pair(vl.first/d*vr.first,c);
  }
}

signed main(){
  int N, Q;
  cin >> N >> Q;
  int P[N];
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
  }
  init(N);
  for(int i = 0; i < N; ++i){
    int cur = P[i], t = 1, c = (i+1)%mod;
    while(cur != i){//テ・ツ按カテァツエツ?」ツ?凝」ツつ嘉」ツ??0テ・ツ崢榲、ツサツ・テ、ツクツ凝」ツ?ァテヲツュツ「テ」ツ?セテ」ツつ?
      c += (cur + 1)%mod;
      c %= mod;
      cur = P[cur];
      ++t;
    }
    dat[i+n-1][0] = t;
    dat[i+n-1][1] = c;
  }
  update();
  int l, r;
  for(int i = 0; i < Q; ++i){
    cin >> l >> r;
    --l;
    cout << query(l,r,0,0,n).second%mod << endl;
  }
  return 0;
} 

/*
int main(){
  int N, Q;
  cin >> N >> Q;
  int P[N];
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
  }
  int LCM[N+1], GCD[N+1], T[N], C[N];
  for(int i = 0; i < N; ++i){
    int cur = P[i], t = 1, c = (i+1)%mod;
    while(cur != i){//テ・ツ按カテァツエツ?」ツ?凝」ツつ嘉」ツ??0テ・ツ崢榲、ツサツ・テ、ツクツ凝」ツ?ァテヲツュツ「テ」ツ?セテ」ツつ?
      c += (cur + 1)%mod;
      cur = P[cur];
      ++t;
    }
    T[i] = t;
    C[i] = c;
  }
  GCD[0] = T[0];
  LCM[0] = T[0];
  for(int i = 0; i < N-1; ++i){
    GCD[i+1] = gcd(GCD[i],T[i+1]);
    LCM[i+1] = lcm(LCM[i],T[i+1]);
  }
  int C_[N];
  C_[0] = C[0];
  for(int i = 1; i < N; ++i){
    C_[i] = LCM[i]/GCD[i]*C[i] + LCM[i]/LCM[i-1]*C_[i-1];
  }
  for(int i = 0; i < N; ++i){
    cout << C_[i] << " ";
  }cout << endl;
  
  int l, r;
  for(int i = 0; i < Q; ++i){
    cin >> l >> r;
    --l;--r;
    int ans, k;
    if(l == 0){
      k = LCM[r]*GCD[r];
      ans = C_[r]/LCM[r]*k - C_[l]/LCM[l]*k;
    }else{
      k = LCM[r]/LCM[l-1]*GCD[r];
      ans = C_[r]/LCM[r]*k - C_[l]/LCM[l]*k;
    }
    ans %= mod;
    cout << ans << endl;
  }

  return 0;
}
*/

Measured memory_bytes: 7992
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;


class Solution{

public:
    int handMoney(int N, const vector<bool>& dislikes){

        int money = N;
        while(!ok(money, dislikes)) money ++;
        return money;
    }

private:
    bool ok(int money, const vector<bool>& dislikes){

        while(money){
            if(dislikes[money % 10]) return false;
            money /= 10;
        }
        return true;
    }
};

int main() {

    int N, K;
    scanf("%d%d", &N, &K);

    vector<bool> dislikes(10, false);
    for(int i = 0; i < K; i ++){
        int x; scanf("%d", &x);
        dislikes[x] = true;
    }

    printf("%d\n", Solution().handMoney(N, dislikes));

    return 0;
}


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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, a, b;
    cin >> n >> a >> b;
    if (n == 1 && a != b || a > b)
    	cout << 0 << endl;
    else
    	cout << (a + (n - 1) * b) - (a * (n - 1) + b) + 1 << endl;
    return 0;
}


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

int N;
struct LL{
  int id;
  string S;
  int P;
  bool operator<(const LL &l) const {
    if(S==l.S) return P>l.P;
    return S<l.S;
  };
};
vector<LL> L;
int main(void){
  cin>>N;
  for(int i=0;i<N;i++){
    LL l;
    l.id=i+1;
    cin>>l.S>>l.P;
    L.push_back(l);
  }
  sort(L.begin(),L.end());
  for(auto l:L) cout<<l.id<<endl;
  return 0;
}


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

#define MOD 998244353
#define MAX_P 1100005
Int fact[MAX_P],inv[MAX_P],finv[MAX_P];

void init(Int mod){
  fact[0]=1;
  for(Int i=1;i<MAX_P;i++)
    fact[i]=(fact[i-1]*i)%mod;

  inv[1]=1;
  for(Int i=2;i<MAX_P;i++)
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  
  finv[0]=1;
  for(Int i=1;i<MAX_P;i++)
    finv[i]=finv[i-1]*inv[i]%mod;
}

//only for prime mod
Int mod_comb3(Int n,Int k,Int mod){
  if(k<0||k>n) return 0;
  return fact[n]*finv[k]%mod*finv[n-k]%mod;
}

Int calc(Int n,Int k,Int i){
  Int j=k-i;
  Int res=0;
  res+=mod_comb3(k,i,MOD);
  res+=MOD-mod_comb3(k,j-(i-n+1),MOD);
  //cout<<n<<" "<<k<<" "<<i<<" "<<j<<":"<<res<<endl;
  return res%MOD;
}

//INSERT ABOVE HERE
signed main(){
  init(MOD);
  Int n,k;
  cin>>n>>k;
  Int ans=0;
  for(Int i=k;i>=n;i--){
    Int j=k-i;
    if(i-j<0) continue;
    ans+=calc(n,k-(i==j),i);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 26112
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> Q; // 0:left, 1:right
typedef pair<int, Q> R;
const int INF = 1000000000;

int w, h;
char s[60][40];

int dx[9] = {1, 1, 1, 1, 1, 2, 2, 2, 3}; // left > minas
int dy[9] = {2, 1, 0, -1, -2, 1, 0, -1, 0};

int dp[2][60][30]; // before left : 0
int dijkstra() {
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) dp[0][i][j] = dp[1][i][j] = INF;
  priority_queue<R, vector<R>, greater<R> > que;
  for (int j = 0; j < w; j++) if (s[h - 1][j] == 'S') {
    dp[0][h - 1][j] = dp[1][h - 1][j] = 0;
    que.push(R(0, Q(P(j, h - 1), 1)));
    que.push(R(0, Q(P(j, h - 1), 0)));
  }
  while (!que.empty()) {
    R r = que.top(); que.pop();
    int cost = r.first, x = r.second.first.first, y = r.second.first.second, left = r.second.second;
    if (cost > dp[left][y][x]) continue;
    for (int i = 0; i < 9; i++) {
      int nx = x, ny = y + dy[i];
      if (left == 0) nx -= dx[i];
      else nx += dx[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if (s[ny][nx] == 'X') continue;
      if (s[ny][nx] == 'S') continue;
      if (s[ny][nx] == 'T') {
        return dp[left][y][x];
      } else if (dp[!left][ny][nx] > dp[left][y][x] + (int) s[ny][nx] - '0') {
        dp[!left][ny][nx] = dp[left][y][x] + (int) s[ny][nx] - '0';
        que.push(R(dp[!left][ny][nx], Q(P(nx, ny), !left)));
      }
    }
  }
  int ans = INF;
  for (int j = 0; j < w; j++) if (s[0][j] == 'T') ans = min(ans, min(dp[0][0][j], dp[1][0][j]));
  if (ans == INF) ans = -1;
  return ans;
}

int main() {
  while (1) {
    scanf("%d%d", &w, &h);
    if (w == 0) break;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) scanf(" %c", &s[i][j]);
    printf("%d\n", dijkstra());
  }
}



Measured memory_bytes: 2644
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

unsigned long long int ans=1;

int main()
{
    int n, c = 0;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a+n);
    for (int i = n-2, j = n-1; i >= 0 && c < 2; i--, j--) {
        if (a[i] == a[j]) {
            ans *= a[i];
            i--;
            j--;
            c++;
        }
    }
    if (c == 2) cout << ans << endl;
    else printf("0\n");
    return 0;
}

Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
  priority_queue<pair<int, int> > PQ;
  int color[MAX];
  int d[MAX];
  for ( int i = 0; i < n; i++ ) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while ( !PQ.empty() ) {
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;

    color[u] = BLACK;

    if ( d[u] < f.first * (-1) ) continue;

    for ( int j = 0; j < adj[u].size(); j++ ) {
      int v = adj[u][j].first;
      if ( color[v] == BLACK ) continue;
      if ( d[v] > d[u] + adj[u][j].second ) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }

  for ( int i = 0; i < n; i++ )
    cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
}

int main() {
  int k, u, v, c;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    for ( int j = 0; j < k; j++ ) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}


Measured memory_bytes: 8028
import heapq

n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)

for _ in range(m):
    x = heapq.heappop(a) * -1
    x //= 2
    heapq.heappush(a,-1*x)
print(-sum(a))

Measured memory_bytes: 14180
#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) >= r && (x + r) <= W) && ((y + r) >= r && (y + r) <= H)) 
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1000000000;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  ll count = 0;
  vector<ll> a(100, 0);

  for (int i = 1; i <= n; i++) {
    string k = to_string(i);
    int t1 = k[0] - '0';
    int t2 = k[k.size() - 1] - '0';
    if (k[0] == '0') continue;
    if (k[k.size() - 1] == '0') continue;

    a[t1 * 10 + t2]++;
  }
  for (int i = 0; i < 100; i++) {
    if (a[i] == 0) continue;
    count += a[i] * a[i % 10 * 10 + i / 10];
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <array>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <stack>

int main()
{
	//std::cout << std::fixed << std::setprecision(15);

	long long a;
	std::cin >> a;

	std::cout << a * a << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
"""
できなかった

- 操作 = 四則演算 or 関数
- 交換法則などが成り立つかどうか確認する必要がある
- 再帰的(dfs)に実装する場合、何を初期値として終了条件とするかの理解が必要
  - 前提として全探索であること => 1の解に収束する必要がない
    全ての葉を訪れたときに最小・最大値・解への到達が判定できれば良い

- dfsの実装: いまどの高さにいるかを引数として渡す = 何を高さとして定義するか
  - 階層のインデックスは選択可能な配列のインデックス
  - 同階層のノードは選択肢
  - ノードが持つ値は、その選択をした時の合計の値
  - 終了条件A, B, Cを満たす

- 求める長さA, B, Cの竹 -> 選択肢

"""
(N, A, B, C) = map(int, input().split())
l = [int(input()) for _ in range(N)]


def dfs(index, a, b, c):
    if N == index:
        if 0 < min(a, b, c):
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return 10 ** 9
    costs = []
    costs.append(dfs(index + 1, a, b, c))
    costs.append(dfs(index + 1, a + l[index], b, c) + 10)
    costs.append(dfs(index + 1, a, b + l[index], c) + 10)
    costs.append(dfs(index + 1, a, b, c + l[index]) + 10)
    return min(costs)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int in_X1;
    int in_Y1;
    int in_X2;
    int in_Y2;

    int X3;
    int Y3;
    int X4;
    int Y4;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");
      in_X1        = Integer.parseInt(in_str_split[0]);
      in_Y1        = Integer.parseInt(in_str_split[1]);
      in_X2        = Integer.parseInt(in_str_split[2]);
      in_Y2        = Integer.parseInt(in_str_split[3]);


      /*----------------
       * 計算
       *----------------*/
      X3 = in_X2 - (in_Y2 - in_Y1);
      Y3 = in_Y2 + (in_X2 - in_X1);
      X4 = in_X1 - (in_Y2 - in_Y1);
      Y4 = in_Y1 + (in_X2 - in_X1);

      System.out.println(String.format("%d %d %d %d", X3, Y3, X4, Y4));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 23380
#include <iostream>
using namespace std;
int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b) cout << 0 << endl;
	else if (n == 1) cout << (a == b) << endl;
	else cout << (b - a) * (n - 2) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
bool judge(string& s, int n) {
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - 1 - i]) return false;
    }
    return true;
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    string s2 = "";
    for (int i = 0; i < n; i++) {
        if (s[i] != 'x') s2 += s[i];
    }
    if (!judge(s2, s2.length())) {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0, ans = 0;
    for (int i = 0, j = n - 1, cnt2 = 0; i < n; i++) {
        if (s[i] == 'x') {
            cnt++;
        } else {
            while (j >= 0) {
                if (s[j] == 'x') cnt2++, j--;
                else if (s[j] == s[i]) {
                    break;
                } else {
                    j--;
                }
            }
            if (i > j) break;
            ans += abs(cnt - cnt2);
            int tmp = max(cnt, cnt2);
            cnt = tmp;
            cnt2 = tmp;
            j--;
            if (i == j) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 592
h,w=gets.split.map &:to_i
if (h*w)%3==0
  puts 0
else
  min=10**9
  1.upto(h-1) do |i|
    if w%2==0 || (h-i)%2==0
      g=[w*i,w*(h-i)/2]
    else
      if w>h-i
        g=[w*i,(w-1)*(h-i)/2+h-i,(w-1)*(h-i)/2]
      else
        g=[w*i,w*(h-i-1)/2+w,w*(h-i-1)/2]
      end
    end
    min=[min,g.max-g.min].min
  end
  1.upto(w-1) do |i|
    if h%2==0 || (w-i)%2==0
      g=[h*i,h*(w-i)/2]
    else
      if h>w-i
        g=[h*i,(h-1)*(w-i)/2+w-i,(h-1)*(w-i)/2]
      else
        g=[h*i,h*(w-i-1)/2+h,h*(w-i-1)/2]
      end
    end
    min=[min,g.max-g.min].min
  end
  p min
end
  
        

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b;
	cin>>a>>b;
	int res=0;
	if(6<=a&&a<=12) res=b/2;
	else if(a>=13) res=b;
	cout<<res<<'\n';
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int k;
   cin >> k;
   int ans = 0;
   f(a,1,k+1){
      f(b,1,k+1){
         f(c,1,k+1){
            int g = __gcd(a,b);
            g = __gcd(g,c);
            ans += g;
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define N 100009

int main(){
    long n,m;
    cin>>n>>m;
    char data[n+1];
    data[0]='w';
    for (long i=1; i<=n; i++) cin>>data[i];
    
    long num[n+1];
    num[0]=0;
    for (long i=1; i<=n; i++){
        if (data[i-1]=='A' && data[i]=='C') num[i]=num[i-1]+1;
        else num[i]=num[i-1];
    }
    
    for (long i=0; i<m; i++){
        long p,q;
        cin>>p>>q;
        if (p==0) cout<<num[q]<<endl;
        else{
            if (data[p-1]=='A' && data[p]=='C') cout<<num[q]-num[p-1]-1<<endl;
            else cout<<num[q]-num[p]<<endl;
        }
    }
}

Measured memory_bytes: 1664
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

n,m,k=map(int,input().split())
count=0
mod=998244353

N = 3*(10**5)
g1 = [1, 1]
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(k+1):
    a=(m*cmb(n-1,i,mod)%mod)*pow(m-1,n-i-1,mod)
    a%=mod
    count+=a
    count%=mod
    
print(count)

Measured memory_bytes: 137492
#include <iostream>

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int* array = new int[n];
		for (int i=0; i<n; i++) std::cin >> array[i];
		bool turn = true;
		int stones = 32;
		int index = 0;
		while (stones>0) {
			if (turn) stones -= (stones-1) % 5;
			else { stones -= array[index]; index = (index+1) % n; }
			if (stones<0) stones = 0;
			std::cout << stones << std::endl;
			turn = !turn;
		}
	}
	return 0;
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
    int n,i,ans=0,t,k;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    //for(i=1;i<n;i++)ans+=a[i];
    vector<int>v;
    ans=a[n-1];
    t=n-2;
    k=n-2;
    while(1){
        if(!t)break;
        ans+=a[k];
        t--;
        if(!t)break;
        ans+=a[k];
        t--;
        k--;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5204
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
    if(n<1000){
        printf("ABC");
    }
    else {
        printf("ABD");
    }
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
	int X;
	cin >> X;
	switch(X){
	case 3:
		cout << "YES";
		break;
	case 5:
		cout << "YES";
		break;
	case 7:
		cout << "YES";
		break;
	default:
		cout << "NO";
		break;
	}
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from decimal import *


def floor(a,b):
    return a//b


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    A, B = _in[0].split(' ')  # type:list(str)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A = Decimal(A)
    B = Decimal(B)
    cnt = A * B
    cnt = int(floor(cnt, 1))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71416
function Main(arg)
{
  var N = arg.split("\n")[0] - 0;
  var A = arg.split("\n")[1].split(" ").map(Number);
  
  var ans = false;

  for (var i = 0; i < N; i++){
    if (A[i] % 2===0) {
      if (A[i] % 3 === 0) {
        continue;
      }
      else if (A[i] % 5 === 0) {
        continue;
      }

      console.log("DENIED");
      return;

    }
  }

  console.log("APPROVED");
  return;
}

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

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  	string s;
  cin>>s;
    ll n=0;
    for(char i : s) n+= i - '0';
    if(n%9){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}
  

Measured memory_bytes: 3708
a,b,c=map(int,input().split())
num1=0
num2=0
num3=0
if a==b and b==c and a%2==0:
    print(-1)
else:
    for i in range(a*b*c):
        if a%2==1 or b%2==1 or c%2==1:
            break
        num1=a//2
        num2=b//2
        num3=c//2
        a=num2+num3
        b=num3+num1
        c=num1+num2
    print(i)


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

int main() {
  
  string S, T;
  cin >> S >> T;
  
  int m=0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      m++;
    }
  }
  
  cout << m << endl;

return 0;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int t = kbd.nextInt();
	    if(t!=0){
		solve(t);
	    }
	}
    }
  
    static void solve(int t){
	int dotime = 0;
	int n = kbd.nextInt();
	while(n>0){
	    int a = kbd.nextInt();
	    int b = kbd.nextInt();
	    dotime += (b-a);
	    n--;
	}
	if(dotime >= t)
	    System.out.println("OK");
	else 
	    System.out.println(t - dotime);
    }
}

Measured memory_bytes: 23708
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int x = in(), y = in();
    print(x+y/2);
}

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

using namespace std;

long long n, s;
long long w[101];
long long v[101];
long long dp[101][100001];

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

    cin >> n >> s;

    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    for (int i = 1; i <= sum; i++)
        dp[0][i] = s + 1;
    for (int i = 0; i <= n; i++)
        dp[i][0] = 0;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= sum; j++)
        {
            if (j >= v[i] && s >= dp[i - 1][j - v[i]] + w[i])
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    while (sum >= 0)
    {
        if (dp[n][sum] <= s)
        {
            cout << sum;
            return 0;
        }
        sum--;
    }

    return 0;
}


Measured memory_bytes: 79232
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(a<b && b<c)
			{System.out.println("Yes");
			}
		else
		{System.out.println("No");
		}
	}
}

Measured memory_bytes: 26396
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFrog1 solver = new AFrog1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFrog1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n + 1];

            // dp[i] -> The minimum cost to reach here.
            int[] dp = new int[n + 1];

            for (int i = 1; i <= n; i++) {
                arr[i] = in.nextInt();
            }

            dp[1] = 0;
            dp[2] = Math.abs(arr[2] - arr[1]);
            for (int i = 3; i <= n; i++) {
                dp[i] = Math.min(dp[i - 1] + Math.abs(arr[i] - arr[i - 1]), dp[i - 2] + Math.abs(arr[i] - arr[i - 2]));
            }

            out.println(dp[n]);
        }

    }
}



Measured memory_bytes: 59520
n = int(input())
data = list(map(int, input().split()))   # 1行にある複数の値を整数にして、リストにしまう
#
vmin = min(data)  # 最小値
vmax = max(data)  # 最大値
vsum = sum(data)  # 合計
#
print(vmin, vmax, vsum)  # 結果表示


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

long long ans;

int main() {
	long long n;
	cin >> n;
	for (int i=1; i<=n; ++i){
		for (int j=i; j<=n; j+=i){
			ans += j;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    vi dp(c+1);
    dp[a]=1;
    REP(i,b+1,d+1){
        //vi ndp(c+1);
        ll sum=0;
        REP(j,1,c+1){
            sum=(sum*(i-1)+dp[j])%mod;
            dp[j]=(dp[j]*(j-1)+sum)%mod;
            //dp[j]%=mod;
        }
    }
    ll ans=0;
    rep(i,c+1){
        ans+=dp[i]*modpow(d,c-i);
        ans%=mod;
    }
    out(ans);
}


Measured memory_bytes: 3628
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
ll dx[4]={0,-1,0,1};
ll dy[4]={1,0,-1,0};
/****************************/
int main()
{
	ios::sync_with_stdio(0);
	string s,t;
	cin>>s>>t;
	rep(i,SZ(s))
	{
		if(s[i]!=t[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
	int n;
	int r = 100000;

	while (cin >> n ){	
		for (; n--; r % 1000 ? r += 1000 - r % 1000: r){
			r *= 1.05;
		} // end for
		cout << r << endl;	
	} // end while

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

const int size=1000001;

int func(int a){
	if(a%2)return 3*a+1;
	return a/2;
}

int main(){
	int s,next;
	cin>>s;
	bool check[size];
	fill(check,check+size,false);
	loop(i,1,size){
		if(check[s]){
			cout<<i<<endl;
			break;
		}
		check[s]=true;
		next=func(s);
		s=next;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
int n;
ll d,x[33],y[33],deq[15000010];
vector<PL> vec[2];
void zen(int idx,int l,int r,ll nx,ll ny){
    if(l >= r) vec[idx].push_back(PL(nx,ny));
    else {
        zen(idx,l+1,r,nx,ny);
        zen(idx,l+1,r,nx+x[l],ny+y[l]);
        zen(idx,l+1,r,nx-x[l],ny-y[l]);
    }
}

int main()
{
    scanf("%d %lld",&n,&d);
    for(int i=0;i<n;i++) scanf("%lld %lld",&x[i],&y[i]);
    
    zen(0,0,n/2,0,0);
    zen(1,n/2,n,0,0);
    
    sort(vec[0].begin(),vec[0].end());
    reverse(vec[0].begin(),vec[0].end());
    sort(vec[1].begin(),vec[1].end());
    
    int s=0,t=0;
    ll ans = 0;
    for(int i=0,j=0;i<vec[0].size();i++){
       while(j < vec[1].size() && vec[0][i].first+vec[1][j].first <= d){
           while(s < t && vec[1][deq[t-1]].second <= vec[1][j].second) t--;
           deq[t++] = j;
           j++;
       }
       while(s < t && vec[0][i].first+vec[1][deq[s]].first < -d) s++;
       if(s < t) ans = max(ans,vec[0][i].second+vec[1][deq[s]].second);
    }
    printf("%lld\n",ans);
    
    return(0);
}



Measured memory_bytes: 488760
#include<iostream>
using namespace std;
int main(){
    int n,a[101],X;
    while(1){
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    cin >> X;
    int high=n-1,low=0,cnt=0;
    while(high>=low){
        cnt++;
        int center=(low+high)/2;
        if(a[center]==X) break;
        else if(a[center]<X) low=center+1;
        else high=center-1;
    }
    cout << cnt << endl;
    }
}

Measured memory_bytes: 1160
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    bool solve(string& s) {
        int N = s.length();
        return isPalindrome(s) && isPalindrome(s.substr(0, (N - 1) / 2)) && isPalindrome(s.substr((N + 3) / 2 - 1));
    }

private:
    bool isPalindrome(const string& s) {
        int n = s.length();
        for (int i = 0, j = n - 1; i < j; ++i, --j) {
            if (s[i] != s[j]) {
                return false;
            }
        }
        return true;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    Solution sol;
    string s;
    cin >> s;
    if (sol.solve(s)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[1001],b[1001],c[1001],d[1001],e,f=0,i,s,t,u,v;
while(1){
scanf("%d\n",&e);
if(e==0){
break;
}
else{
for(i=0;i<e;i++){
scanf("%d %d %d %d\n",&a[i],&b[i],&c[i],&d[i]);
}
scanf("%d %d %d %d\n",&s,&t,&u,&v);
for(i=0;i<e;i++){
if(b[i]<=s && c[i]<=t && d[i]<=u && b[i]*4+c[i]*9+d[i]*4<=v){
printf("%d\n",a[i]);
f++;
}
}
if(f==0){
printf("NA\n");
}
}
f=0;
}
return 0;
}




Measured memory_bytes: 2052
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        int A = Int ();
        int B = Int ();

        Console.WriteLine (Math.Max (0, A - B * 2));
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>

using namespace std;
long long mod = 998244353,cnt[8] = {}; //RGB,RG,RB,GB,R,G,B,no
string s;
int main(){
	int i,n;
	cin >> n >> s;
	cnt[7] = n;
	n *= 3;
	long long ans = 1;
	for(i=0;i<n;i++){
		if(s[i]=='B'){
			if(cnt[1]>0){
				(ans *= cnt[1]) %= mod;
				cnt[0]++; cnt[1]--;
			}else if(cnt[4]>0){
				(ans *= cnt[4]) %= mod;
				cnt[2]++; cnt[4]--;
			}else if(cnt[5]>0){
				(ans *= cnt[5]) %= mod;
				cnt[3]++; cnt[5]--;
			}else if(cnt[7]){
				(ans *= cnt[7]) %= mod;
				cnt[6]++; cnt[7]--;
			}
		}
		if(s[i]=='G'){
			if(cnt[2]>0){
				(ans *= cnt[2]) %= mod;
				cnt[0]++; cnt[2]--;
			}else if(cnt[4]>0){
				(ans *= cnt[4]) %= mod;
				cnt[1]++; cnt[4]--;
			}else if(cnt[6]>0){
				(ans *= cnt[6]) %= mod;
				cnt[3]++; cnt[6]--;
			}else if(cnt[7]){
				(ans *= cnt[7]) %= mod;
				cnt[5]++; cnt[7]--;
			}
		}
		if(s[i]=='R'){
			if(cnt[3]>0){
				(ans *= cnt[3]) %= mod;
				cnt[0]++; cnt[3]--;
			}else if(cnt[5]>0){
				(ans *= cnt[5]) %= mod;
				cnt[1]++; cnt[5]--;
			}else if(cnt[6]>0){
				(ans *= cnt[6]) %= mod;
				cnt[2]++; cnt[6]--;
			}else if(cnt[7]>0){
				(ans *= cnt[7]) %= mod;
				cnt[4]++; cnt[7]--;
			}
		}
		/*cout << i << " " << ans << endl;
		for(int j=0;j<8;j++){
			cout << cnt[j] << " ";
		}
		cout << endl;*/
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 900
#import 
#=input()
#=int(input())
x,k,d=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

q = abs(x) // d
a = abs(x) % d
p = q + 1
l = abs(p * d - abs(x))
if k < q:
    ans = abs(x) - k * d
else:
    if k % 2 == 0:
        if q % 2 == 0:
            ans = a
        else:
            ans = l
    else:
        if q % 2 == 0:
            ans = l
        else:
            ans = a
print(ans)

Measured memory_bytes: 9108