akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
char ch[105][105];
int n, m, x[105], y[105];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		scanf("%s", (ch[i]+1));
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ch[i][j]!='.'){
				x[i]=1;
				continue;
			}
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(ch[j][i]!='.'){
				y[i]=1;
				continue;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(x[i]==0) continue;
		for(int j=1;j<=m;j++) if(y[j]==1) printf("%c", ch[i][j]);
		cout<<endl;
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(){

  cout << fixed << setprecision(6);
  
  double W,H,x,y,ans;
  
  cin >> W >> H >> x >> y;
  
  //面積の大きくないほうの最大値は面積の半分になる(斜めの線なども可能なため）
  ans = W * H / 2;
  
  if((x == W / 2) && (y == H / 2)) cout << ans << ' ' << '1' << endl;
  else cout << ans << ' ' << '0' << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, j, k, w;
  scanf("%d%d", &w, &n);
  int a[n], b[n], now, ans[w + 2];
  for(i = 0; i < n; ++i) scanf("%d,%d", &a[i], &b[i]);
  for(i = 1; i <= w; ++i) {
    now = i;
    for(j = 0; j < n; ++j) {
      if(a[j] == now) now = b[j];
      else if(b[j] == now) now = a[j];
    }
    ans[now] = i;
  }
  for(i = 1; i <= w; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 2672
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}


void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}


string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}


string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

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

    int divisor = 0, cnt = 0;
    for (int i = n; i > 1; --i) {
        for (int j = 1; j <= i; ++j) {
            if (divisor > 8) break;
            if (i % j == 0) {
                ++divisor;
            }
        }
        if (divisor == 8 && i % 2 == 1) ++cnt;
        divisor = 0;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl
int gcd(int x, int y){
    if ((x==1)||(y==1)) {
        return 1;
    }
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

bool sqc(int x){
    for (int i = 0; i*i <= x; i++) {
        if (i*i==x) {
            return true;
        }
    }
    return false;
}

int main() {
    IN(int, n);
    IN(int, d);
    vi2 a(n,vi(d));
    REP(i, n){
        REP(j, d){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    REP(i, n-1){
        FOR(j, i+1, n){
            int sum = 0;
            REP(k, d){
                sum += (a[i][k]-a[j][k]) * (a[i][k]-a[j][k]);
            }
            if (sqc(sum)) {
                ans++;
            }
        }
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

vvi e;
int dist[2][110000];

void dfs(int v, bool b) {
	for (auto vv : e[v]) {
		if (dist[b][vv] != INF)continue;
		dist[b][vv] = dist[b][v] + 1;
		dfs(vv, b);
	}
}

int main() {

	int n, u, v;
	cin >> n >> u >> v;
	u--, v--;
	e.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	rep(i, n)dist[0][i] = dist[1][i] = INF;
	dist[0][u] = dist[1][v] = 0;
	dfs(u, 0);
	dfs(v, 1);

	int ans = 0;
	rep(i, n) {
		if (dist[0][i] >= dist[1][i])continue;
		ans = max(ans, dist[1][i]);
	}
	cout << ans - 1 << endl;

}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)1e9+7;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

void solve(){
	
	char c;
	cin >> c;
	if(c >= 'A' && c<='Z') cout << 'A';
	else cout << 'a';	
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


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

int main(){
int N;
  cin>>N;
  
  vector<char>S(N);
  bool ans=false;
  for(int i=0; i<N; i++){
   cin>>S[i];
   if(S[i]=='Y'){ans=true;}
  }
  if(ans){cout<<"Four"<<endl;}
    else{cout<<"Three"<<endl;}
}

Measured memory_bytes: 256
// 解説前
#include <iostream>
#include <vector>
#include <cstdint>

// 剰余付き累乗を計算する
// 参考：https://stackoverflow.com/questions/8496182/calculating-powa-b-mod-n
template <typename T>
T pow(T x, T y, T m) noexcept {
  T r = 1;
  while (y > 0) {
    // 指数のiビット目を見て、xの2^i乗をかける
    if (y & 1) {
      r *= x;
      if (r >= m) r %= m;
    }

    // xの2^i乗を累積的に計算する
    x *= x;
    if (x >= m) x %= m;

    y >>= 1;
  }
  return r;
}

// 剰余付き組み合わせ数を計算する（pは素数）
// 参考：https://ikatakos.com/pot/programming_algorithm/number_theory/mod_combination
template <typename T>
T combination(T n, T r, T p) noexcept {
  // nCr = nC_{n-r}なので、計算量が少なくなる方を選ぶ
  if (r > n - r) r = n - r;
  
  // 分子（nPr mod p）を計算する
  T num = 1;
  for (T i = 0; i < r; ++i) {
    num *= n - i;
    if (num >= p) num %= p;
  }

  // 分母（r! mod p）を計算する
  T denom = 1;
  for (T i = 1; i <= r; ++i) {
    denom *= i;
    if (denom >= p) denom %= p;
  }

  // 分母の逆数（r!^{-1} mod p = r!^{p-2} mod p）を計算する
  // フェルマーの小定理から導かれる
  const T denom_inv = pow(denom, p - 2, p);

  // 組み合わせ数（nCr mod p）を計算する
  return (num * denom_inv) % p;
}

// L^1ノルムを考えると、(1,2)と(2,1)のどちらの方向でも距離3だけ移動する
// => 到達可能な地点までのL^1ノルムは3の倍数になる
// => 動かした回数はn=(X+Y)/3となる
// 
// すべての移動を(1,2)の方向に動かしたとすると、X=nとなる
// その状態からどこか1つを(2,1)の方向に動かすよう変えた場合、Xは+1だけ増える
// => (2,1)方向に動かした回数はX-nとなる
//
// 進む経路を図に起こすと、その個数はパスカルの三角形を描く
// => 動かす回数をn、(2,1)の方向に動かした回数をrとして、nCrを計算すれば良い 
int solve_D() {
  uint64_t X, Y;
  std::cin >> X >> Y;

  // 経路の数を計算する
  const auto distance = X + Y;  // L^1ノルム
  if (distance % 3 != 0) {
    // (X, Y)に到達できない場合
    std::cout << '0';
  } else {
    // (X, Y)に到達できる場合
	const auto n = distance / 3;  // 移動回数
	const auto r = X - n;  // (2,1)の方向に動かした回数

    // 組み合わせ数（nCr mod 10^9+7）を計算する
    const uint64_t m = 1'000'000'007;
    std::cout << combination(n, r, m);
  }
  return 0;
}

int main() {
  return solve_D();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;
const int MAX = 1e5;

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n),c(n);
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];
    REP(i,n) cin >> c[i];

    sort(a.begin(),a.end());
    sort(c.begin(),c.end());

    ll ans = 0;
    REP(i,n){
        auto itrA = lower_bound(a.begin(),a.end(),b[i]);
        auto itrC = upper_bound(c.begin(),c.end(),b[i]);
        ans += (itrA - a.begin()) * (n - (itrC - c.begin()));
    }
    cout << ans << endl;
}

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

int main()
{
  int N, K;
  // input
  cin >> N >> K;
  
  int inp, p[N], i=0, total_min=0;
  while(cin >> inp){
    p[i] = inp;
    i++;
  }
  
  sort(p, p+i);
  
  
  for(int j=0 ; j<K ; j++){
  	total_min += p[j];
  }
  
  cout << total_min;
  
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  vector<int> a(n),b(n,0);
  rep(i,n) R a[i];
  rep(i,n) if(a[i]>=n) {
    pr(-1);
    return;
  }
  ll M=0,ans=0;
  rrep(i,n) {
    if(a[i]<M) {
      pr(-1);
      return;
    }
    if(M<a[i]) {
      M=a[i];
      ans+=a[i];
    }
    M--;
  }
  if(M>=0) ans=-1;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout<<endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x ; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		char n;
		cin >> n;

		if (int(n) >= 97)
			cout << "a" << endl;
		else
			cout << "A" << endl;


	}
	CLOCK
	return 0;
}



Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int d[50], n, a, b, v[50][50];
pair<int, string>S[30];
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < 2500; i++) { d[i % 50] = 0; v[i / 50][i % 50] = 0; S[i % 30] = make_pair(0, ""); }
		for (int i = 0; i < n; i++) {
			cin >> S[i].second >> a;
			for (int j = 0; j < a; j++) {
				cin >> b; v[i][b] = 1; d[b]++;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 50; j++) {
				if (v[i][j] == 0)continue;
				S[i].first += n + 1 - d[j];
			}
		}
		sort(S, S + n);
		cout << S[0].first << ' ' << S[0].second << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
N = int(input())
LIST = list(map(int, input().split()))

def isApprovedNumber(n):
    if n % 2 != 0:
        return True
    if n % 5 == 0 or n % 3 == 0:
        return True
    return False

def isApprovedArray(list):
    str_ok="APPROVED"
    str_ng="DENIED"
    for number in list:
        if not isApprovedNumber(number):
            return str_ng
    return str_ok

result=isApprovedArray(LIST)
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPEACH(i,k) for(auto& i:k)
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;


signed main() {
	int n;
	cin >> n;
	vector<int> t(n);
	vector<int> a(n);
	REP(i,n){
		cin >> t[i] >> a[i];
		if(i==0){
			continue;
		}
		if(t[i]>=t[i-1]&&a[i]>=a[i-1]){
			continue;
		}
		else{
			int x=t[i];
			int y=a[i];
			int m=(max((t[i-1]+x-1)/x,(a[i-1]+y-1)/y));
			t[i]=x*m;
			a[i]=y*m;
		}
	}
	cout << a[n-1]+t[n-1] << endl;
}

Measured memory_bytes: 256
N = int(input())


a=0
b=0
c=0
d=0

for i in range(N):
    s = input()
    if s=="AC":
        a+=1
    elif s=="WA":
        b+=1
    elif s=="TLE":
        c+=1
    elif s=="RE":
        d+=1 
    
print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

    ll ans = lcm(a,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char s[300000];

int main(void) {
    scanf("%s", s);
    int l = strlen(s);

    long long int r=0;

    int i=0, j=l-1;
    while(i<j) {
        while(j>=0 && s[j] == 'B') j--;
        while(i<l && s[i] == 'W') i++;
        if(i>=j) break;
        r += j-i;
        i++, j--;
    }
    printf("%lld\n", r);
}


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

#define int long long
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
#define rep(i,a,n) for(int i=a; i<n; i++)
#define endl "\n"
#define e "\n"
#define show(arr) REP(i,arr.size()){cout<<arr[i]<<" ";}
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

#define N 5010

int sum(int x)
{
    int sum = 0;
    while (x>0){
        sum += x%10;
        x/=10;
    }
    return sum;
}

void solve()
{
    int n,m=INF;
    cin>>n;
    for (int i=1; i<n/2+2;i++){
        //cout<<sum(i)+sum(n-i)<<e;

        m = min(m,sum(i)+sum(n-i));
    }
    cout<<m;
}

signed main()
{
    int t=1;
    //cin>>t;
    WL(t)solve();

    return 0;
}




Measured memory_bytes: 3580
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>



using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define FOR(I,J,K) for(int I = 0;I < J;I+=K)

	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		FOR(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}

	vector<int> SieveOfEratosthenes(int N) {
		vector<bool> memo(N + 1);
		vector<int> ret;
		memo[0] = true;
		memo[1] = true;
		for (int i = 2; i < N; i++) {
			if (memo[i])continue;
			ret.push_back(i);
			for (int b = 2; true; b++) {
				if (i*b <= N) {
					memo[i*b] = true;
				}
				else break;
			}
		}
		return ret;
	}

	vector<int> SpInput(int N) {
		vector<int> ret(N);
		FOR(i, N, 1) { cin >> ret[i]; }
		return ret;
	}
}

using namespace CsF;


int main() {
	int N, X;
	cin >> N >> X;
	int x0;
	cin >> x0;
	x0 = abs(X - x0);
	int ans = x0;
	int xn;
	for (int i = 1; i < N; i++) {
		cin >> xn;
		xn = abs(X - xn);
		ans = GCD(ans, xn);
	}
	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println((b - a == c - b) ? "YES" : "NO");
    }
}

Measured memory_bytes: 25172
var ans = 0

fun main(args: Array<String>) {
    val n = readInputLine().toLong()

    dfs(n, 0L)

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(n: Long, s: Long) {
    if (s > n) {
        return
    }
    
    val sString = s.toString()
    if (sString.contains('7') && sString.contains('5') && sString.contains('3')) {
        ans++
    }
    
    dfs(n, s * 10L + 7L)
    dfs(n, s * 10L + 5L)
    dfs(n, s * 10L + 3L)
}


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

#define rep(i, n) for (int i=0; i<n; ++i)

const long long mod = 1e9+7;

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  rep(i, m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

  vector<long long int> dp(n+2);
  dp[n] = 1;
  for (int i=n-1; i>=0; i--) {
    if (broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }

  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define siz(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
void cmps(vector<int>&v,int &i){
	i=lower_bound(all(v),i)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int X;cin>>X;
	int now=100;
	rep(i,inf){
		if(now>=X){
			cout<<i<<endl;return 0;
		}
		now=now+now/100;
	}
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
vector<string> mp(12);
bool in_range(int x){
  return 0 <= x && x < 12;
}
bool dfs(int y,int x){
  if (!in_range(x)||!in_range(y)||mp[y][x]=='0') {
    return false;
  }
  mp[y][x] = '0';
  dfs(y+1,x);
  dfs(y,x+1);
  dfs(y-1,x);
  dfs(y,x-1);
  return true;
}
int main(){
  while(1){  
    int ans = 0;
    REP(i,12) cin >> mp[i];
    if(!cin) return 0;
    REP(i,12) REP(j,12) if(dfs(i,j)) ++ans;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3128
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m;
int p[N];
vector < int > edges[N];
void shortest(int x){
	queue < pair < int, int > > q;
	q.push({x, 0});
	bool vis[n + 1];
	memset(vis, 0, sizeof vis);
	while(q.size()){
		int cur = q.front().first;
		int par = q.front().second;
		q.pop();
		if(vis[cur])continue;
		vis[cur] = 1;
		p[cur] = par;
		for(int i = 0; i < edges[cur].size(); ++i){
			q.push({edges[cur][i], cur});
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	int u, v;
	for(int i = 1; i <= m; ++i){
		cin >> u >> v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	shortest(1);
	cout << "Yes\n";
	for(int i = 2; i <= n; ++i){
		cout << p[i] << '\n';
	}
}

Measured memory_bytes: 14456
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

long long x;
bool p;

int main(){

    cin >> x;

    while(true){
        p = true;
        for(long long i = 2; i*i <= x; i++){
            if(x%i == 0){
                p = false;
                break;
            }
        }
        if(p){
            cout << x;
            return 0;
        }
        x++;
    }











}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, M, C, B[20], A, cnt, sum;
int main()
{
  cnt = 0;

  cin >> N >> M >> C;
  REP(i, M)
  {
    cin >> B[i];
  }

  REP(i, N)
  {
    sum = C;
    REP(j, M)
    {
      cin >> A;
      sum += A * B[j];
    }
    if (0 < sum)
      cnt++;
  }

  cout << cnt << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
const int maxn = 100000 + 233;
int f[maxn];
int main()
{
	int n;cin>>n;
	f[0] = 0;
	for(int i=1;i<=n;i++)
	{
		f[i] = f[i-1] + 1;
		for(int k=6;k<=i;k*=6)
			f[i] = min(f[i],f[i-k]+1);
		for(int k=9;k<=i;k*=9)
			f[i] = min(f[i],f[i-k]+1);
	}
	cout << f[n] << endl;
	return 0;
}

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

int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> s;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    s[a] += b;
  }
  long long ans = 0, sum = 0;
  for (auto i = s.begin(); i != s.end(); i++) {
    long long cnt = i->second, mon = i->first;
    while (true) {
      if (sum >= m || cnt <= 0) {
        break;
      }
      ans += mon;
      sum++;
      cnt--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxN = 1e5;
const ll mod = 1e9+7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int sz = 5e5+20;
ll fact[sz], inv[sz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<sz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxN;i++) spf[i]=i;
    for(int i=4;i<mxN;i+=2) spf[i]=2;
    for(int i=3;i*i<mxN;i++){
        if(spf[i]==i){
            for(int j=i*i;j<mxN;j+=i){
                if(spf[j]==j) spf[j]=i;
            }
        }
    }
}

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

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

    cout<< max(b*d,max(b*c,max(a*d,a*c))); 
}

Measured memory_bytes: 3636
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#if __cplusplus >= 201103L

#include <array>

#include <atomic>

#include <chrono>

#include <condition_variable>

#include <forward_list>

#include <future>

#include <initializer_list>

#include <mutex>

#include <random>

#include <ratio>

#include <regex>

#include <scoped_allocator>

#include <system_error>

#include <thread>

#include <tuple>

#include <typeindex>

#include <type_traits>

#include <unordered_map>

#include <unordered_set>

#endif
using namespace std;



int main()
{
	string s;
	cin >> s;
	string ans;
	for (int i = 0;i < s.size();i += 2) {
		ans += s[i];
}
	cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
char a[N],b[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>b+1;
  int x=strlen(a+1),y=strlen(b+1),ans=y;
  for(int i=1;i+y-1<=x;i++){
    int z=0;
    for(int j=1;j<=y;j++){
      z+=b[j]!=a[i+j-1];
    }
    ans=min(ans,z);
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N;
	std::vector<std::tuple<int,int,int>> v;
	std::cin >> N;
	int a=0;
	v.push_back(std::tie(a,a,a));
	for ( int i = 0 ; i < N ; i++ ) {
		int t,x,y;
		std::cin >> t >> x >> y;
		v.push_back(std::tie(t,x,y));
	}
	for ( int i = 0 ; i < N ; i++ ) {
		int t,x,y,tn,xn,yn,aaa;
		std::tie(t,x,y) = v[i];
		std::tie(tn,xn,yn) = v[i+1];
		aaa = (tn-t) - abs(xn-x) - abs(yn-y);
		if(aaa < 0 || aaa%2==1){
			std::cout << "No" << std::endl;
			return 0;
		}
	}
			std::cout << "Yes" << std::endl;
	return 0;
}


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

int main() {
  int a;
  char cm;
  string b;
  int dat[128]={};
  while(cin>>a>>cm>>b) {
    if(b=="AB") b="D";
    dat[b[0]]++;
  }
  cout<<dat['A']<<endl<<dat['B']<<endl<<dat['D']<<endl<<dat['O']<<endl;

  return 0;
}

Measured memory_bytes: 1208
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int a, b, c;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] str1Ary = str.split(" ");
		a = Integer.parseInt(str1Ary[0]);
		b = Integer.parseInt(str1Ary[1]);
		c = Integer.parseInt(str1Ary[2]);
		if (a < b && b < c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24356
/*
 © 2020-08-29 06:57:42 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s, t; cin >> s >> t;
  lli res = 1e18;
  fore(i, 0, sz(s) - sz(t) + 1){
    lli foo = 0;
    fore(j, 0, sz(t)){
      if(s[i + j] != t[j]) foo++;
    }
    res = min(res, foo);
  }
  cout << res << ENDL;
  return 0;
}


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

using namespace std;

int main() {

    double num;

    while(cin>>num,num>0){

        string str;

        for(double i=128,a;i>0.03125;i/=2){

            str+=int(a=num/i)+'0';

            if(a>=1)num-=i;

            if(i==1)str+='.';

        }

        if(num>0)cout<<"NA"<<endl;

        else cout<<str<<endl;

    }

}

Measured memory_bytes: 3176
N = input()

S = list(set(list(N)))
C = []

for s in S:
    C.append(N.count(s))

S2 = list(set(C))
C2 = []

for s in S2:
    C2.append(C.count(s))

x = 0
for s,c in zip(S2,C2):
    x += (s * (s-1)) * c

print(int(1+(len(N)*(len(N)-1)-x)/2))


Measured memory_bytes: 4840
import sys
def input(): return sys.stdin.readline().strip()

i  = lambda: int(input())
s  = lambda: input()

b_a = 0
b = 0
a = 0
count = 0
for _ in range(i()):
    ts = s()
    if ts[0] == 'B' and ts[-1] == 'A':
        b_a += 1
    else:
        if ts[0] == 'B':
            b += 1
        if ts[-1] == 'A':
            a += 1
    count += ts.count('AB')

if b_a == 0:
    print(count + min([b, a]))
else:
    if a + b == 0:
        print(count + b_a -1)
    else:
        print(count + b_a + min([b, a]))

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

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

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {
	ll N, M;
	std::cin >> N >> M;

	map<ll,vector<ll>> edge;
	vector<ll> s(M), g(M);
	rep(i, 0, M) {
		std::cin >> s[i] >> g[i];
		edge[s[i]].push_back(g[i]);
		edge[g[i]].push_back(s[i]);
	}


	ll ans = M;
	rep(i, 0, M) {
		stack<pair<ll, ll>> st;
		vector<bool> isVisited(N+1, false);
		isVisited[s[i]] = true;
		st.push({ g[i], s[i] });

		while (!st.empty()) {
			ll pre = st.top().first;
			ll cur = st.top().second;
			isVisited[cur] = true;
			st.pop();
			
			rep(j, 0, edge[cur].size()) {
				if (pre != edge[cur][j]) {
					if (!isVisited[edge[cur][j]]) {
						if (edge[cur][j] == g[i]) {
							ans--;
							st = stack<pair<ll, ll>>{};
							break;
						}
						else {
							st.push({ cur,edge[cur][j] });
						}
						
					}
				}
			}
		}
	}
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N, K = input().split()

dislike = set(list(map(int, input().split())))

next_map = {}
min_digit = 0
for i in range(10):
    for j in range(i,10):
        if j not in dislike:
            if i == 0:
                min_digit = j
            next_map.update({ i : j })
            break
        next_map.update({ i : min_digit })
max_digit = max(next_map.values())

num = len(list(N))
count = num
cand = []
for n in list(N):
    n = int(n)
    if n in dislike:
        n_ = next_map[n]
        cand.append(n_)
        count -= 1
        cand.extend(count*[min_digit])
        break
    else:
        cand.append(n)
        count -= 1
cand = int("".join(list(map(str, cand))))
if int(N) <= cand:
    print(cand)
else:
    if min_digit == 0:
        next_min = next_map[1]
        cand = [next_min] + num * [0]
    else:
        cand = (num + 1) * [min_digit]
    cand = int("".join(list(map(str, cand))))
    print(cand)



Measured memory_bytes: 9132
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

a = list(map(int, input().split()))

d1 = abs(a[2] - a[0])
d2 = abs(a[0] - a[1])
d3 = abs(a[1] - a[2])

print(d1 + d2 + d3 - max(d1, d2, d3))


Measured memory_bytes: 2940
#include <stdio.h>

int main() {
    double xp1, yp1, xp2, yp2, xp, yp;
    int q;
    scanf("%lf%lf%lf%lf", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &q);
    while(q--) {
        scanf("%lf%lf", &xp, &yp);
        double a = ((xp2-xp1)*(xp-xp1)+(yp2-yp1)*(yp-yp1))/((xp2-xp1)*(xp2-xp1)+(yp2-yp1)*(yp2-yp1));
        printf("%.10lf %.10lf\n", 2*a*xp2+(2-2*a)*xp1-xp, 2*a*yp2+(2-2*a)*yp1-yp);
    }
}



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

int H,W,A,sum=0;
int c[10][10];
#define rep(i,s,n) for(int i=s;i<n;i++)

int main(void){
    cin>>H>>W;
    rep(i,0,10)rep(j,0,10)cin>>c[i][j];
    //rep(i,0,10){cout<<endl;rep(j,0,10)cout<<c[i][j];}
    //1から出発して0,2~9に行くまでの最小コストを求める
    rep(k,0,10)rep(i,0,10)rep(j,0,10)if(c[i][j]>c[i][k]+c[k][j]){c[i][j]=c[i][k]+c[k][j];}
    rep(i,0,H)rep(j,0,W){
        cin>>A;
        if(A==-1 || A==1)continue;
        sum+=c[A][1];
    }        
    //rep(i,0,10)cout<<c[1][i]<<endl;
    cout<<sum<<endl;
    return 0;
}


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

int main() {
    int count=0;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            /* code */
            count++;
        }
    }
    printf("%d ", count);
}

Measured memory_bytes: 256
from itertools import combinations
from collections import Counter

N = int(input())
L = list(map(int, input().split()))

counter = Counter()

for l in L:
    counter[l] += 1

sums = [0]
L_MAX = 10**3

for i in range(1, L_MAX+1):
    sums.append(sums[i-1]+counter[i])

res = 0

for l1, l2 in combinations(L, r=2):
    upper = l1+l2
    lower = abs(l1-l2)

    tmp = sums[min(L_MAX, upper-1)] - sums[lower]
    if l1 < upper and l1 > lower:
        tmp -= 1
    if l2 < upper and l2 > lower:
        tmp -= 1

    res += tmp

print(res//3)



Measured memory_bytes: 45420
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back





int main(){

    ll n,k;
    cin>>n>>k;
    vector<ll> orders(n+1);
    vector<ll> scores(n+1);

    rep(i,n){
        ll tmp;
        cin>>tmp;
        orders.at(i+1)=tmp;
    }

    rep(i,n){
        ll tmp;
        cin>>tmp;
        scores.at(i+1)=tmp;
    }


    ll realanswer=-10000000000000;


    for (ll i=1;i<=n;i++){
      
      ll answer;


        vector<ll> cycle;


        cycle.pb(i);

      

        while (orders.at(cycle.at(int(cycle.size())-1))!=cycle.at(0)){
          ll tmp=orders.at(cycle.at(int(cycle.size())-1));
            cycle.pb(tmp);
    
        }



        ll loopsize=int(cycle.size());

        ll loopsum=0;

        rep(j,loopsize){
            loopsum+=scores.at(orders.at(cycle.at(j)));
        }
      





        if (loopsum<0 or k<=loopsize){

            

            ll isum=scores.at(orders.at(i));

            ll tmpmax=isum;

            for (int z=1;z<min(k,loopsize);z++){
                isum+=scores.at(orders.at(cycle.at(z)));
                if (isum>tmpmax){
                    tmpmax=isum;
                }

            }

            answer=tmpmax;

           
        }
      


        if (loopsum>=0 and k>loopsize){


            ll howmany=k/loopsize;

            ll isum=(howmany-1)*loopsum;


            ll tmpmax=0;

            ll tmpsum=0;

            ll kaisu=k-((howmany-1)*loopsize);

            rep(z,kaisu){
                tmpsum+=scores.at(orders.at(cycle.at(z%loopsize)));
                if (tmpsum>tmpmax){
                    tmpmax=tmpsum;
                }
                
            }

            answer=tmpmax+isum;


        }
      
      if (answer>realanswer){
        realanswer=answer;
      }
      





    }
  
  cout<<realanswer<<endl;








}

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

int main() {
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	b -= a;
	bool r = false;
	for (ll i = 0; i <= n - 1; i++) {
		r |= c * i - d * (n - 1 - i) <= b && b <= d * i - c * (n - 1 - i);
	}
	cout << (r ? "YES" : "NO") << endl;
	return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int A,B,C; cin >> A >> B >> C;
    Yn((A<C&&C<B)||(B<C&&C<A));
 
	return 0;
}


Measured memory_bytes: 256
n = int(input())
N =[2,4,8,16,32,64]

if n == 1:
  print(1)
  
elif 2<=n<4:
  print(2)

elif 4<=n<8:
  print(4)

elif 8<=n<16:
  print(8)
elif 16<=n<32:
  print(16)

elif 32<=n<64:
  print(32)
elif 64<=n<101:
  print(64)

  
  

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

public static class Program
{
  private static readonly Dictionary<string, Func<int, int, int>> operatorDictionary
    = new Dictionary<string, Func<int, int, int>>()
    {
      {"+", (a, b) => b + a},
      {"-", (a, b) => b - a},
      {"*", (a, b) => b * a}
    };  
  private static Stack<string> stack = new Stack<string>();
  
  public static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    
    int length = input.Length;
    for(int i = 0; i < length; i++)
    {
      string str = input[i];
      if(str == "+" || str == "-" || str == "*")
      {
        int a = int.Parse(stack.Pop());
        int b = int.Parse(stack.Pop());
        int result = operatorDictionary[str](a, b);
        stack.Push(result.ToString());
      }
      else
      {
        stack.Push(str);
      }
    }
    
    int answer = int.Parse(stack.Pop());
    Console.WriteLine(answer);
  }
}


Measured memory_bytes: 10424
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int N = 505;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int a[N][N];

void solve() {
	int k; read(k);
	int n = min(k, 500);
	for (int i = 1; i <= n; ++i) {
		int x = 1, y = i;
		for (int j = 1; j <= n; ++j) {
			a[x][y] = i;
			x = x % n + 1;
			y = y % n + 1;
		}
	}
	for (int i = n + 1; i <= k; ++i) {
		int x = 1, y = i - n;
		for (int j = 1; j <= n; ++j) {
			if (j & 1) a[x][y] = i;
			x = x % n + 1;
			y = y % n + 1;
		}
	}
	printf("%d\n", n);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			printf("%d ", a[i][j]);
		}
		puts("");
	}
}

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


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[101];
    a[1]=2;
    cin>>n;
    if(n==1){cout<<1<<endl;return 0;}
    for(int i=2; i<=100; i++)a[i]=a[i-1]*2;
    for(int i=1; i<=100; i++)if(n>=a[i]&&n<a[i+1]){cout<<a[i]<<endl;return 0;}
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef long long ll;

main(){
  int n; cin >> n;
  vi a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(a));
  sort(all(c));

  ll ans = 0;
  rep(i,n){
    auto itra = upper_bound(all(a),b[i]-1);
    auto itrc = lower_bound(all(c),b[i]+1);
    ans += (itra - a.begin()) * (c.end() - itrc);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

const int MAX_N = 2e5 + 10;
ll cnt[MAX_N], arr[MAX_N], ans[MAX_N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
        cnt[arr[i]] ++;
    }
    ll sum = 0;
    for(int i = 0; i < MAX_N; i ++) {
        ans[i] = ((cnt[i]) * (cnt[i] - 1ll)) / 2ll;
        sum += ans[i];
    }
    for(int i = 0; i < n; i ++) {
        ll curr = sum - (((cnt[arr[i]]) * (cnt[arr[i]] - 1ll)) / 2ll);
        cout << (curr + (((cnt[arr[i]] - 1) * (cnt[arr[i]] - 2)) / 2ll)) << endl;
    }
    return 0;
}




Measured memory_bytes: 6784