akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int k;cin>>k;
    int a,b;
    cin>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++){
    	if(i%k==0) flag=1;
    }
	if(flag) cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
//int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d\n",min(b,n*a));
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MOD      = 998244353;
const int MAXVALUE = (int)1e6 + 4321;

int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

int sub(int x, int y) {
	return (x - y < 0 ? x - y + MOD : x - y);
}

int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

int binpow(int x, int y) {
	if(y == 0 || x == 1) {
		return 1;
	}

	if(x == 0) {
		return 0;
	}

	int rez = binpow(x, y / 2);
	rez = mult(rez, rez);

	if(y & 1) {
		rez = mult(rez, x);
	}

	return rez;
}

int divide(int x, int y) {
	return mult(x, binpow(y, MOD - 2));
}

vector<int> divs[MAXVALUE];
int sum[MAXVALUE], n;

void precalc() {
	for(int i = 1; i < MAXVALUE; ++i) {
		for(int j = i; j < MAXVALUE; j += i) {
			divs[j].push_back(i);
		}
	}
}

void solve() {
	cin >> n;
	int full_sum = 0;

	for(int i = 0; i < n; ++i) {
		int value;
		cin >> value;
		full_sum = add(full_sum, value);

		for(auto& i: divs[value]) {
			sum[i] = add(sum[i], value);
		}
	}

	for(int i = 1; i < MAXVALUE; ++i) {
		sum[i] = mult(sum[i], sum[i]);
	}

	for(int i = MAXVALUE - 1; i > 0; --i) {
		for(int j = 2 * i; j < MAXVALUE; j += i) {
			sum[i] = sub(sum[i], sum[j]);
		}
	}

	int answ = 0;

	for(int i = 1; i < MAXVALUE; ++i) {
		int cur = sum[i];
		cur = divide(cur, i);

		answ = add(answ, cur);
	}

	answ = sub(answ, full_sum);
	answ = divide(answ, 2);

	cout << answ << '\n';
}

int main() {
	fast_io();

	precalc();
	solve();

	return 0;
}


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

int main() {
  int n;
  while(cin >> n, n) {
    for(int _ = 0; _ < n; _++) {
      int x[4], y[4], ans[4] = {};
      for(int i = 0; i < 4; i++) cin >> x[i];
      for(int i = 0; i < 4; i++) cin >> y[i];
      for(int i = 0; i < 4; i++) {
	for(int j = 0; j < 4; j++) {
	  if(i == j) {
	    if(i+j == 0) ans[0] += x[i]*y[i];
	    else ans[0] -= x[i]*y[i];
	  } else if(i+j == 1 || i+j == 5) {
	    if(i == 3 && j == 2) ans[1] -= x[i]*y[j];
	    else ans[1] += x[i]*y[j]; 
	  } else if(i+j == 2 || i+j == 4) {
	    if(i == 1 && j == 3) ans[2] -= x[i]*y[j];
	    else ans[2] += x[i]*y[j];
	  } else {
	    if(i == 2 && j == 1) ans[3] -= x[i]*y[j];
	    else ans[3] += x[i]*y[j];
	  }
	}
      }
      for(int i = 0; i < 3; i++) cout << ans[i] << ' ';
      cout << ans[3] << endl;
    }
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n,sum=0,num;cin>>n;
        for(ll i=0;i<n;i++){
            cin>>num;
            if(i%2)continue;
            if(num%2)sum++;
        }cout<<sum;


}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <utility>

using namespace std;

int main()
{
    string s;

    cin>>s;
    sort(s.begin(), s.end());
    if (s=="xxx") cout<<"700\n";
    if (s=="ooo") cout<<"1000\n";
    if (s=="oox") cout<<"900\n";
    if (s=="oxx") cout<<"800\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip> 



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

using namespace std;
int a;

int main(){
  cin >> a;
  if(a==22) cout << "Christmas Eve Eve Eve" << endl;
  if(a==23) cout << "Christmas Eve Eve" << endl;
  if(a==24) cout << "Christmas Eve" << endl;
  if(a==25) cout << "Christmas" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int n,t[100010],x[100010],y[100010],f=0;
bool yes_no(int i,int j){
	int way=abs(x[i]-x[j])+abs(y[i]-y[j]);
	if ((t[j]-t[i]-way)%2==0&&way<=t[j]-t[i]) return 0;
	return 1;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>t[i]>>x[i]>>y[i];
	for (int i=0;i<n;i++) if (yes_no(i,i+1)==1){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

long dp[100001];
vector<long> adj[100001];
long dfs(long n)
{
    if(dp[n]!=-1)
        return dp[n];
    long temp=0;
    for(long child:adj[n])
    {
        temp=max(temp,1+dfs(child));
    }
    return dp[n]=temp;
}

void test_case()
{
    long n,m;
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    while(m--)
    {
        long x,y;
        cin>>x>>y;
        x--;
        y--;
        adj[x].pb(y);
    }
    long ans=0;
    for(long i=0;i<n;i++)
    {
        ans=max(ans,dfs(i));
    }
    cout<<ans;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  VEC<int>P(N);
  REP(i,0,N)cin>>P[i];
  int cnt=0;
  REP(i,1,N-1){
    VEC<int> v = {P[i-1], P[i], P[i+1]};
    sort(ALL(v));
    if(P[i]==v[1])cnt++;
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

class RSQ{
	public:
	int n;
	vector<ll> dat;
	RSQ(){}
	RSQ(int size){
		n = 1;
		while(n < size) n *= 2;
		dat.resize(2 * n - 1, 0);
	}
	void add(int k, ll a){
		k += n - 1;
		dat[k] += a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] += a;
		}
	}
	ll getSum(int s, int t){
		return query(s, t + 1, 0, 0, n);
	}
	ll query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l) return 0;
		if(a <= l && r <= b) return dat[k];
		else{
			ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
			ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
			return vl + vr;
		}
	}
};

int main(){
	int n, q;
	cin >> n >> q;
	RSQ rsqa(n);
	for(int i = 0; i < q; i++){
		int com; ll x , y;
		cin >> com >> x >> y;
		if(com == 0){
			x--;
			rsqa.add(x, y);
		}else if(com == 1){
			x--; y--;
			cout << rsqa.getSum(x, y) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4884
#include <cstdio>
using namespace std;
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
int main(){
	register int n, a, b, i, marken, x;
	register long long ans;
	scanf("%d", &n);
	ans = 0, marken = 1, x = 1000000008;
	for (i = 1; i <= n; ++i) {
		scanf("%d %d", &a, &b);
		if (a != b) marken = 0;
		ans += a;
		if (a > b) cmin(x, b);
	}
	if (marken) puts("0");
	else printf("%lld", ans - x);
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_left,bisect
s=input()
t=input()
n=len(s)
m=len(t)
ord_a=ord("a")
s_=[[] for i in range(26)]
for i in range(n):
  s_[ord(s[i])-ord_a].append(i)
k=ord(t[0])-ord_a  
if (not s_[k]):
    print(-1)
    exit()
ans=s_[k][0]
rep=0
for i in range(1,m):
  k=ord(t[i])-ord_a
  #print(s_[k])
  if (not s_[k]):
    print(-1)
    exit()
  if s_[k][-1]<=ans%n:
    rep+=1
    ans=rep*n+s_[k][0]
  else:
    pos=bisect(s_[k],ans%n)
    #print(pos)
    ans+=s_[k][pos]-ans%n
  #print(ans)
print(ans+1)
  

Measured memory_bytes: 46192
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]
stxy = sorted(txy, key=lambda x:(x[0]))

stxy.insert(0, [0, 0, 0])

for i in range(1, N+1):
    if stxy[i][0] - stxy[i-1][0] < abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2]):
        print("No")
        exit()
    elif (stxy[i][0] - stxy[i-1][0] - (abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2])))%2 == 1:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 28956
# coding: utf-8
# Your code here!
x1,y1,x2,y2=map(int,input().split())
deltax=x2-x1
deltay=y2-y1
print(str(x2-deltay)+" "+str(y2+deltax)+" "+str(x1-deltay)+" "+str(y1+deltax))


Measured memory_bytes: 3060
#include <iostream>
#include <assert.h>

int N = 0;
int M = 0;
int C = 0;

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

    int B[M];
    int A[N][M];
    int linear_add = 0;
    int count = 0;

   
    for (int i=-1; i < N; i++){
        for (int j=0; j < M; j++){
            if (i == -1){
                 std::cin >> B[j];
            } else {
                 std::cin >> A[i][j];
            }
        }
    }
    for (int i=0; i < N; i++){
        linear_add = 0;
        for (int j=0; j < M; j++){
            linear_add += B[j]*A[i][j];
        }
        if (linear_add > -C){
            count ++;
        }
    }
    std::cout << count << '\n';
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
 
int i,j,k,l;
 
int main(){
  int N, L;
  int tmp[200], t, ans = 0;
  bool flag = 0;
  scanf("%d %d", &N, &L);
  if(L > 0){
    for(i=2;i<=N;i++) ans += L + i - 1;
    printf("%d", ans);
    exit(0);
  }else if(N<=abs(L) && L < 0){
    for(i=1;i<N;i++) ans += L + i - 1;
    printf("%d", ans);
    exit(0);
  }else if(N>abs(L) || L == 0){
    for(i=1;i<=N;i++) ans += L + i - 1;
    printf("%d", ans);
    exit(0);
  }
    return 0;
}


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

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

const int W = 5;

bool isClear ( VVI& m, int h, int l, int r )
{
	bool hit = true;
	for ( int i = l; i < r; ++i ) {
		hit &= m[h][l] == m[h][i] && m[h][i] != 0;
	}
	return hit;
}
int doClear ( VVI& m, int h, int l, int r )
{
	int sum = 0;
	for ( int i = l; i < r; ++i ) {
		sum += m[h][i];
		m[h][i] = 0;
	}
	return sum;
}

int clear ( VVI& m, int h )
{
	int sum = 0;
	for ( int y = 0; y < h; ++y ) {
		for ( int x = 0; x < W - 2; ++x ) {
			for ( int w = W; w > x + 2; --w ) {
				if ( isClear( m, y, x, w ) ) {
					sum += doClear( m, y, x, w );
				}
			}
		}
	}
	return sum;
}

bool doDrop ( VVI& m, int h )
{
	bool hit = false;
	for ( int y = h - 1; y > 0; --y ) {
		for ( int x = 0; x < W; ++x ) {
			if ( m[y][x] == 0 && m[y - 1][x] != 0 ) {
				hit = true;
				m[y][x] = m[y - 1][x];
				m[y - 1][x] = 0;
			}
		}
	}
	return hit;
}

void drop ( VVI& m, int h )
{
	while( doDrop( m, h ) );
}

int main ( void )
{
	int h;
	while ( cin >> h, h ) {
		VVI m( h, VI( W ) );
		for ( int i = 0; i < h; ++i ) {
			for ( int j = 0; j < 5; ++j ) {
				cin >> m[i][j];
			}
		}

		int ans = 0, t;
		while ( ( t = clear( m, h ) ) != 0 ) {
			ans += t;
			drop( m, h );
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000007;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);


	Int k, x;
	cin >> k >> x;

	for (Int i = x-(k-1); i <= x+(k-1); i++) {
		if (-1000000 <= i && i <= 1000000) printf("%lld ", i);
	}
	printf("\n");
}

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

const int maxn = 3010;
using LL = int64_t;
struct Segment {
  int n;
  LL t[maxn * 2];
  void init(int n) {
    this->n = n;
    memset(t, 0, sizeof t);
  }
  void modify(int p, LL v) {
    if (t[p + n] > v) {
      return;
    }
    for (t[p += n] = v; p > 1; p >>= 1)
      t[p >> 1] = max(t[p], t[p ^ 1]);
  }
  LL query(int l, int r) {
    LL ret = 0;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l&1) ret = max(ret, t[l++]);
      if (r&1) ret = max(ret, t[--r]);
    }
    return ret;
  }
} seg;

int main() {
  ios::sync_with_stdio(false);
  int r, c, k;
  cin >> r >> c >> k;

  map<int, vector<pair<int, int>>> m;
  for (int i = 0; i < k; ++i) {
    int x, y, v;
    cin >> x >> y >> v;
    m[x].push_back({y, v});
  }
  seg.init(3005);
  LL ans = 0;
  for (auto &it : m) {
    auto &v = it.second;
    sort(v.begin(), v.end());
    vector<LL> a(v.size()), b(v.size()), c(v.size());
    LL ma = 0;
    LL mb = 0;
    for (int i = 0; i < v.size(); ++i) {
      a[i] = seg.query(1, v[i].first + 1) + v[i].second;
      b[i] = max(a[i], ma + v[i].second);
      c[i] = max(b[i], mb + v[i].second);
      ma = max(ma, a[i]);
      mb = max(mb, b[i]);
    }
    for (int i = int(v.size()) - 1; i >= 0; --i) {
      seg.modify(v[i].first, c[i]);
      ans = max(ans, c[i]);
    }
  }

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



Measured memory_bytes: 6940
def is_MM(s):
    return (s > 0) and (s < 13)

s = input()
f = int(s[:2])
b = int(s[2:])

if is_MM(f) and is_MM(b):
    print("AMBIGUOUS")
elif is_MM(f):
    print("MMYY")
elif is_MM(b):
    print("YYMM")
else:
    print("NA")

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

using namespace std;

const int NMAX = 1000;

int main()
{
    long long a,b,c,d,n;
    cin >> a >> b >> c >> d >> n;
    long long A = 8*a,B = 4*b,C = 2*c,D = d;
    long long Ans = n / 2 * min(min(A,B),min(C,D));
    if( n % 2 == 1 ) {
        Ans += min(min(A,B),C) / 2;
    }
    cout << Ans << '\n';
    return 0;
}


Measured memory_bytes: 256
/**                                                     **\
 *    created by:   Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
*                                                        */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>


using namespace std;
using namespace __gnu_pbds;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>new_data_set;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define pf push_front
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589


int power(int x, int y) {
    int r = 1, z = x;
    while (y) {
        if (y & 1)r *= z;
        z *= z; y = y >> 1;
    }
    return r;
}
int powerm(int x, int y, int p) {
    int r = 1;
    while (y) {
        if (y & 1)r = (r * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return r % p;
}
int modinv(int x, int m) {
    return powerm(x, m - 2, m);
}
int logarithm(int a, int b) {
    int x = 0;
    while (a > 1) {
        x++;
        a /= b;
    }
    return x;
}
int max3(int a, int b, int c) {
    return max(a, max(b, c));
}
int min3(int a, int b, int c) {
    return min(a, min(b, c));
}
int32_t main() {
    fast;
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] != t[i]) {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

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

int main(){

  int a, b, c, n;
  int p[1111], m[1111], k[1111], q[1111];
  int data[333];

  while(true){
    cin >> a >> b >> c;
    if(!a && !b && !c) break;

    for(int i=1;i<=a+b+c;i++) data[i] = 2;
    
    cin >> n;
    for(int i=0;i<n;i++) cin >> p[i] >> m[i] >> k[i] >> q[i];
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(q[j]) data[p[j]] = data[m[j]] = data[k[j]] = q[j];
	else{
	  if(data[p[j]] == 1 && data[m[j]] == 1) data[k[j]] = 0;
	  if(data[m[j]] == 1 && data[k[j]] == 1) data[p[j]] = 0;
	  if(data[p[j]] == 1 && data[k[j]] == 1) data[m[j]] = 0;
	}
      }
    }
    for(int i=1;i<=a+b+c;i++) cout << data[i] << endl;
  }
  
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T>
void dump(vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
template<class T>
void input(vector<T>& vec,int n){
	vec.resize(n);
	for(int i=0;i<n;i++){
		cin >> vec[i];
	}
}
ll N;
vector<int> ans;
int main(){
	cin >> N;
	int n = 0;
	while((1ll<<(n+1))-1ll<=N)n++;
	N -= (1ll<<n)-1ll;
	bitset<40> bs(N);
	int c = bs.count();
	int d = 0;
	for(int i=1;i<=n;i++){
		if(bs[i-1]==1){
			ans.pb(n+c-d);
			d++;
		}
		ans.pb(i);
	}
	assert(d==c);
	for(int i=1;i<=n+c;i++){
		ans.pb(i);
	}
	cout << ans.size() << endl;
	dump(ans);
	return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
if x < 0:
    x = -x
t = x // d
if k <= t:
    print(x - k*d)
    exit()
x -= t * d
k -= t
if k%2 == 1:
    print(abs(x - d))
else:
    print(x)


Measured memory_bytes: 9168
#include <stdio.h>
#include <stdlib.h>
int ctoi(char c) {
        if (c >= '0' && c <= '9') {
                return c - '0';
        }
        return 0;
}

int main(void){
  char s[10];
  scanf("%s", s);
  int count = 0;
  int i = 0;
  while(s[i]!='\0'){
    count++;
    i++;
  }
  int gap = 1000;
  for(int i=0; i<count-2; i++){
    char ss[3];
    ss[0] = s[i];
    ss[1] = s[i+1];
    ss[2] = s[i+2];
    int x = ctoi(ss[0])*100 + ctoi(ss[1])*10 + ctoi(ss[2]);
    if(abs(x-753)<gap)
      gap = abs(x-753);
  }
  printf("%d\n", gap);
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int c=a*b;
  if(c%2==0) cout << "Even" << endl;
  else cout << "Odd" << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;


int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> v1(x),v2(y),v3(z);
    rep(i,x) cin >> v1[i];
    rep(i,y) cin >> v2[i];
    rep(i,z) cin >> v3[i];

    vector<ll> v;
    rep(i,x){
        rep(j,y){
            v.push_back(v1[i] + v2[j]);
        }
    }    

    vector<ll> v4;
    sort(v.begin(),v.end(),greater<ll>() );
    rep(i, min(k,int(v.size()))){
        rep(j,z){
            v4.push_back(v[i] + v3[j]);
        }
    }
    sort(v4.begin(),v4.end(),greater<ll>() );
    rep(i,k){
        cout << v4[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 43240
#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

int main() {

  int h, w, N; cin >> h >> w >> N;
  map<int, map<int,int> > m;
  int a, b;
  REP(i, N) {
    cin >> a >> b;
    a--; b--;

    for (int j = -1; j < 2; ++j) {
      for (int k = -1; k < 2; ++k) {
        if ( 1 <= (a+j) && (a+j) < h-1
            && 1 <= (b+k) && (b+k) < w-1 ) {
          m[a+j][b+k]++;
        }
      }
    }
  }

  vector<ll> res(10, 0);
  map<int, map<int,int> >::iterator itr1 = m.begin();
  for (; itr1 != m.end(); itr1++) {
    map<int, int>::iterator itr2 = itr1->second.begin();
    for (; itr2 != itr1->second.end(); itr2++) {
      res[itr2->second]++;
    }
  }

  REP(i, 10) {
    if (i == 0) {
      res[i] = (ll)(h-2) * (ll)(w-2);
    } else {
      res[0] -= res[i];
    }
  }

  REP(i, 10) {
    cout << res[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.14159265359
//#define gc() getchar_unlocked();
using namespace std;
clock_t start_time,end_time;

inline float ellapse(){ return (clock()-start_time)*1.0/CLOCKS_PER_SEC; }
//inline int read_int() {register char c = gc();while(c<'0' || c>'9') c = gc();int ret = 0; while(c>='0' && c<='9') {ret = 10 * ret + c - 48; c = gc();}return ret;}
long long int gcd( long long int a , long long int b )
{
    return b == 0 ? a : gcd( b , a%b );
}

long long power( long long a , long long b )
{
    long long ret = 1 ;
    while( b ) {
        if( b%2 == 1 ) ret = ( ret * a ) % mod  ;
        a = (a * a) % mod ;
        b /= 2 ;
    }
    return ret ;
}


#define N 310
int arr[ N ][ N ] , vis[ N ][ N ] ;

int main()
{

    int n , a ;
    cin >> n >> a ;
    cout << n*n - a ;


    return 0 ;
}


Measured memory_bytes: 256
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();
		
		if(a > b) {
			System.out.println(a - 1);
		} else {
			System.out.println(a);
		}
		
	}
}


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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int *a = new int[m];
	int cup = 0;
	int cdown = 0;
	for (int i = 0; i < m; ++i) {
		cin >> a[i];
		if (x < a[i]) {
			cup++;
		}
		if (x > a[i]) {
			cdown++;
		}
	}
	if (cup < cdown) {
		cout << cup;
	}
	else {
		cout << cdown;
	}
	delete[]a;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, x;
  cin >> N >> x;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];
  sort(A.begin(), A.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (x >= A[i]) {
      res++;
      x -= A[i];
    }
  }
  if (res == N && x > 0) res--;
  cout << res << '\n';
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> w(n), e(n);
    for (int i = n-1; i-1 >= 0; i--) e[i-1] = e[i] + (s[i] == 'E');
    for (int i = 0; i+1 < n; i++) w[i+1] = w[i] + (s[i] == 'W');

    int ans = n;
    for (int i = 0; i < n; i++) ans = min(ans, w[i] + e[i]);

    cout << ans << endl;
}


Measured memory_bytes: 3076
//
//  main.cpp
//  ABC081-c
//
//  Created by hiroaki on 2019/02/17.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;

/*int main_b(){
    int n,k;
    cin >>n>>k;
    map<int, int> a;
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >>a.at(i);
    }
    int b[205]={0};
    for (int i=0; i<n; i++) {
        while (a[i]%2==0) {
            a[i]=a[i]/2;
            b[i]++;
        }
    }
    int c=1215752192;
    for (int i=0; i<n; i++) {
        if (b[i]<c) {
            c=b[i];
        }
    }
    cout<<c<<endl;
    return 0;
}*/

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> e,t;
    int b[200005]={0};
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
        if (b[a[i]]==0) {
            e.push_back(a[i]);
        }
        b[a[i]]++;//elments_much_count
    }
    for (int i=0; i<e.size(); i++) {
        t.push_back(b[e[i]]);
    }
    sort(t.begin(), t.end());
    long l=t.size();
    if (l>k) {
        int sum=accumulate(t.end()-k,t.end(),0);
        cout<<n-sum<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}



Measured memory_bytes: 4084
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    map<string, bool> dict;
    for (unsigned long long i = 0; i < n; ++i) {
        string s;
        cin >> s;
        if (dict.count(s) == 0) {
            dict[s] = true;
        }
    }
    cout << dict.size() << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 19192
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

    map<int, int> count;
    for (int i = 0; i < n; i += 1) {
        int num;
        cin >> num;
        count[num] += 1;
    }

    vector<int> groups;
    for (const auto &p : count) {
        groups.push_back(p.second);
    }
    sort(groups.begin(), groups.end());

    int res = 0;
    for (int i = 0; i < (int)groups.size() - k; i += 1) {
        res += groups[i];
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


void solve(){
    int n;
    cin >> n;
    cout << (n < 30 ? "No" : "Yes") << "\n";
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 3612
//file_name:ABC66_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);


    ll ans = a+b+c-max(a,max(b,c));

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



Measured memory_bytes: 256
import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto
        buf = readln.chomp.split.to!(int[]),
        k = buf[0],
        n = buf[1],
        a = readln.chomp.split.to!(int[]),
        l = a[0] + k - a[$-1];
    foreach (i, e; a[1..$])
        l = l.max(e - a[i]);
    (k - l).writeln;
}


Measured memory_bytes: 11348
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	int ans = 0, count;
	for (i = 0; i <= n; i++)
	{
		j = i;
		count = 0;
		while (j > 0)
		{
			count++;
			j /= 10;
		}
		if (count % 2 == 1)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

    /**************************************
     Writter Torisuto 2020/8/15
     三文字の中で連続する'R'の最大個数を求める。
     全通りだすのもあり。
     私は、最初に出てくる'R'を基準としたコードに
     しました。もし四文字以上になった場合は、最大値
     を考える必要があります。
    ***************************************/

int main(){

  string s;
  cin >> s;
  int ans = 0;

  rep(i,3){
    if(ans == 0 && s[i]=='R') ans++;
    else if(s[i-1]=='R' && s[i]=='R'){
      ans++;
    }
  }

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


Measured memory_bytes: 3608
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	fmt.Println(string(a[0]) + string(b[1]) + string(c[2]))
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }


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

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n+1),sum1(n+1,0),sum2(n+1,0);
  FOR(i,1,n+1) cin>>a[i];
  sum1[1]=a[1];
  sum2[n]=a[n];
  FOR(i,2,n+1){
    sum1[i]=gcd(sum1[i-1],a[i]);
  }
  for(int i=n-1;i>=1;i--){
    sum2[i]=gcd(sum2[i+1],a[i]);
  }
  int ans=0;
  FOR(i,1,n+1){
    ans=max(ans,gcd(sum1[i-1],sum2[i+1]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
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: 26212
#include <bits/stdc++.h>
using namespace std;

int main () {
    int A,B;
    cin >> A >> B;

    if (A>=13){
        cout << B << endl;
    }

    if (A<=5){
        cout << 0 <<endl;
    }

    if (A>=6 && A<=12){
        cout << B / 2 << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a[2][200];
  REP(i,2)
  REP(j,N){
    cin >> a[i][j];
  }
  int u = 0, d = a[1][N-1];
  int ans = 0;
  REP(j,N) u += a[0][j];
  ans = max(ans, u + d);
  RREP(i,N){
    if(i == 0) continue;
    d += a[1][i - 1];
    u -= a[0][i];
    ans = max(ans, u + d);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
def main():
    N = int( input())
    X = list( map( int, input().split()))
    now = 10000000
    for i in range(1,101):
        t = 0
        for x in X:
            t += (x-i)**2
        if t < now:
            now = t
    print(now)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
map <string,int> mp;
string s;
int main()
{
    mp["SUN"]=7;
    mp["MON"]=6;
    mp["TUE"]=5;
    mp["WED"]=4;
    mp["THU"]=3;
    mp["FRI"]=2;
    mp["SAT"]=1;
    cin>>s;
    cout<<mp[s];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    string s;
    cin >> s;
    int cntr = 0, idx = s.size() - 1;
    for(int i = 0; i < (((int)s.size())/2); i++)
    {
        if(s[i] != s[idx])
            cntr++;
        idx--;
    }
    cout << cntr;
    return 0;
}


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

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

    long long sum = 0;
    set<long long> T;

    for(long long i = 1; i <= n; i++){
        if(sum >= n){
            break;
        }
        sum += i;
        T.insert(i);
    }

    if(sum > n){
        T.erase(sum - n);
    }

    set<long long>::iterator it;

    for(it = T.begin(); it != T.end(); it++){
        printf("%lld\n", *it);
    }

    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
	
		var ns = Console.ReadLine();
		var n = ns.ToInt();
		long[,] dp = new long[10, 10];
		for(int i = 1; i <= n; i++)
		{
			dp[(int)(i.ToString()[0] - '0'), (int)(i.ToString()[i.ToString().Length - 1] - '0')] ++;
		}
		long wa = 0;
		for(int i = 1; i <= 9; i++)
		{
			for(int j = 1; j <= 9; j++)
			{
				if(i == j)
				{
					wa += dp[i,j] * dp[i,j];
				}
				else
				{
					wa += dp[i,j] * dp[j,i];
					//Console.WriteLine("{0} {1} ={2}", i, j, dp[i,j]);
				}
			}
		}
		Console.WriteLine(wa);
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 15296
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
using P = pair<ll, ll>;

const long long MOD = 1000000007;

ll dp[2][26] = {};
ll cnt[26] = {};

ll modpow(ll a, ll b) {
    if (b == 0) return 1;
    if (b % 2) return (a * modpow((a * a) % MOD, b >> 1)) % MOD;
    return modpow((a * a) % MOD, b >> 1);
}

void solve(long long N, std::string S){
    ll ans = 0;
    for (char c : S) {
        int p = c - 'a';
        dp[1][p] = (1 + dp[0][p] + dp[1][p]) % MOD;
        ans = (dp[0][p] + dp[1][p]) % MOD;
        loop (26, i) {
            if (i == p) continue;
            dp[0][i] = ((ans + MOD - cnt[i]) * modpow(cnt[i] + 1, MOD - 2)) % MOD;
            dp[1][i] = (ans + MOD - dp[0][i]) % MOD;
        }
        cnt[p]++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}



Measured memory_bytes: 512
S = list(input())

sample = []

for moji in S:
  if moji not in sample:
    sample.append(moji)

total = 0
if len(sample) == 2:
  for letter in S:
    if sample[0] == letter:
      total += 1
  if total == 2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for (int i = 0; i < N; ++i) {
    cin >> P[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> Q[i];
  }
  
  vector<int> R(N);
  for (int i = 0; i < N; ++i) {
    R[i] = i + 1;
  }

  int a = -1;
  int b = -1;
  int i = 0;
  do {
    if (R==P) {
      a = i;
    }
    if (R==Q){
      b = i;
    }
    ++i;
  } while (next_permutation(R.begin(), R.end()));

  cout << abs(a - b) << endl;
  
  return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n=0,s=0,e=0,w=0,l=0;
	string a;
	cin>>a;
	l=a.length();
	for(int i=0;i<l;i++){
		if(a.substr(i,1)=="E")e=1;
		if(a.substr(i,1)=="W")w=1;
		if(a.substr(i,1)=="N")n=1;
		if(a.substr(i,1)=="S")s=1;
	}
	if(n==0 && s==0 && e==0 && w==0){
		cout<<"Yes"<<endl;
	}else if(n==1 && s==1 && e==1 && w==1){
		cout<<"Yes"<<endl;
	}else if(n==1 && s==1 && e==0 && w==0){
		cout<<"Yes"<<endl;
	}else if(n==0 && s==0 && e==1 && w==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll k,s;
  cin >> k >> s;
  ll ans = 0;
  REP(x,k+1){
    REP(y,k+1){
      if(s-x-y<=k&&s-x-y>=0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

long long longestRepeatedSubstring(string str) 
{ 
	int n = str.length(); 
	int LCSRe[n+1][n+1]; 

	memset(LCSRe, 0, sizeof(LCSRe)); 

	string res; 
	int res_length = 0;

	int i, index = 0; 
	for (i=1; i<=n; i++) 
	{ 
		for (int j=i+1; j<=n; j++) 
		{ 
			if (str[i-1] == str[j-1] && 
				LCSRe[i-1][j-1] < (j - i)) 
			{ 
				LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 

				if (LCSRe[i][j] > res_length) 
				{ 
					res_length = LCSRe[i][j]; 
					index = max(i, index); 
				} 
			} 
			else
				LCSRe[i][j] = 0; 
		} 
	} 

	if (res_length > 0) 
		for (i = index - res_length + 1; i <= index; i++) 
			res.push_back(str[i-1]); 

	return res.size(); 
} 

int main() 
{ 
	string str;
	long long n;
	cin>>n>>str;
	cout << longestRepeatedSubstring(str); 
	return 0; 
} 


Measured memory_bytes: 97920
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int AA[SIZE];
int main(){
    int N,M; R(N,M);
    REP(i,M){
        int k; R(k);
        REP(j,k){
            int x;
            R(x);
            x--;
            AA[x]|=1<<i;
        }
    }
    int need=0;
    REP(i,M){
        int v;
        R(v);
        if(v==1)need|=1<<i;
    }
    int an=0;
    REP(i,1<<N){
        int now=0;
        REP(j,N){
            if((i>>j)&1)now^=AA[j];
        }
        if(now==need)an++;
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
# ABC162
# A
# B
# C
import math
K=int(input())
ans=0
for x in range(1,K+1):
    for y in range(1,K+1):
        for z in range(1,K+1):
            ans+=math.gcd(x,math.gcd(y,z))
print(ans)
# D
# E
# F


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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 1e9 + 7;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a , b; cin >> a >> b;
	cout << 6 - (a + b);
}
	
		
        


Measured memory_bytes: 256