akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size())
    {
        if(s[i] != t[i])ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3856
# Keyence 2020 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
l=[]
for i in range(n):
    a,b=nm()
    l.append([a+b,a-b])
l.sort(key=lambda x:x[0])

cur=-10**9
ans=0
for ll in l:
    if ll[1]>=cur:
        ans+=1
        cur=ll[0]
print(ans)


Measured memory_bytes: 21372
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;

int main(void) {
  int d,n,m;
  cin >> d >> n;
  m = pow(100,d);
  if(n<100) cout << m * n << endl;
  else cout << m * 101 << endl;
}




Measured memory_bytes: 512
#include<stdio.h>

int n;
int a[20];
int flg[10000000];

void dfs(int x,int sum){
	if(x==n){
    flg[sum]=1;
    return;
  }
	dfs(x+1,sum);
	dfs(x+1,sum+a[x]);
}

int main(){
	int i,q,key;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
  	}
  	dfs(0,0);
	
  scanf("%d",&q);
  for(i=0;i<q;i++){
  	
	scanf("%d",&key);
    
	if( flg[key]==1 ){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2084
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto sx = RD;
	auto sy = RD;
	auto tx = RD;
	auto ty = RD;
	auto dx = tx - sx;
	auto dy = ty - sy;
	foreach (i; 0..dy)
	{
		write("U");
	}
	foreach (i; 0..dx)
	{
		write("R");
	}
	write("U");
	foreach (i; 0..dx+1)
	{
		write("L");
	}
	foreach (i; 0..dy+1)
	{
		write("D");
	}
	write("R");

	foreach (i; 0..dx)
	{
		write("R");
	}
	foreach (i; 0..dy)
	{
		write("U");
	}
	write("R");
	foreach (i; 0..dy+1)
	{
		write("D");
	}
	foreach (i; 0..dx+1)
	{
		write("L");
	}
	write("U");
	writeln();
	stdout.flush();
	//readln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s,u;
  int q;
  cin>>s>>q;
  int ct=0;
  rep(i,q){
    int t;
    cin >> t;
    if(t==2){
      int f;
      char c;
      cin >> f >> c;
      if(f==2){
        s+=c;
      }else{
        u+=c;
      }
    }else{
      swap(s,u);
      ct++;
    }
  }
  string ans;
  reverse(u.begin(),u.end());
  ans=u+s;
  
  cout << ans;
}
  


Measured memory_bytes: 4148
from operator import itemgetter
n,m = map(int,input().split())
AB = []
sAB = []

s = 0
c = 0

for i in range(n):
    AB.append(list(map(int,input().split())))

sAB = sorted(AB,key=itemgetter(0))

for i,(a,b) in enumerate(sAB):
    if c + b < m:
        c += b
        s += a*b
    elif c + b >= m:
        for j in range(b):
            if c < m:
                c += 1
                s += a
            else:
                break

print(s)

Measured memory_bytes: 29744
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
template <class K, class Hash> struct chash { const size_t RANDOM; const Hash hash; size_t operator()(K key) const { return hash(key) ^ RANDOM; }
  chash() : RANDOM(  (size_t)make_unique<char>().get() ^ (size_t)chrono::high_resolution_clock::now().time_since_epoch().count()  ), hash() { } };
namespace Hashes { struct hash_pii { size_t operator()(pii key) const { return ((size_t)key.ff << 32) | key.ss; } }; }
// HashMap = umap
template <class K, class V, class Hash=hash<K>>
using umap = __gnu_pbds::gp_hash_table<K,V,chash<K,Hash>>;

class DSU {
  vector<int> p; int c;
  public:
  DSU (int n) : p(n, -1), c(n) { }
  // Get representative of x
  int find(int x) {
    return (p[x] < 0) ? x : p[x] = find(p[x]);
  }
  // Get size of set containg x
  int size(int x) {
    return -p[find(x)];
  }
  // Get # of disjoint sets
  int count() {
    return c;
  }
  // Joins sets containing x, y
  void join(int x, int y) {
    if ((x = find(x)) == (y = find(y))) return;
    if (p[x] < p[y]) swap(x, y);
    p[y] += p[x];
    p[x] = y;
    c--;
  }
};

int deal(vector<pii>& balls, int p, int q, umap<pii,int, Hashes::hash_pii>& ballmap) {
  //cerr << "trying: p=" << p << ", q=" << q<<nl;
  const int n = balls.size();
  DSU lines(n);
  for (int i = 0; i < n; ++i) {
    pii b = balls[i];
    auto it = ballmap.find({b.ff+p, b.ss+q});
    if (it != ballmap.end()) {
      lines.join(i, it->ss);
    }
  }
  return lines.count();
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  
  
  
  int n;
  cin >> n;
  
  vector<pair<int,int>> balls(n);
  umap<pii,int, Hashes::hash_pii> ballmap;
  for(int i = 0; i < n; i++){
    cin >> balls[i].first >> balls[i].second;
    ballmap[balls[i]] = i;
  }
  
  int ans = n;


  forx(i, n) {
    forx(j, n) {
      if (i == j) continue;
      int p = balls[i].first - balls[j].first;
      int q = balls[i].second - balls[j].second;
      ans = min(ans, deal(balls, p, q, ballmap));
    }
  }

  cout << ans << nl;
  
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)

(1..3).each do |p|
	d = 0.0
	n.times do |i|
		d += ((x[i] - y[i]).abs)**p
	end

	puts d**(1.0/p)
end

chebyshev = []
n.times do |i|
	chebyshev.push (x[i] - y[i]).abs
end

puts chebyshev.max

Measured memory_bytes: 6196
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  
  int T = (N - M) * 100 + 1900 * M;
  long double p = 1.0/pow(2, M);
  long double q = 1.0 - p;
  
  long double tmp = p*T;
  p *= q;
  for(int i = 2; i <= 100000; i++){
    tmp += p * T * i;
    p *= q;
  }
  cout << tmp;
}


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


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


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
long long n,k,i,a[1001],ans;
int main ()
{
	ans=0;
	cin>>n>>k;
	for (i=n;i>=1;i--)
	cin>>a[i];
	sort(a+1,a+n+1);
	for (i=n;i>n-k;i--)
	ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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



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

AB = []
for i in range(N):
	AB.append(tuple(map(int, input().split())))
AB.sort(reverse=True)

dp = [[0]*N for _ in range(T)]

max_under = 0
for i in range(N):
	max_under = max(max_under, AB[i][1])
	dp[0][i] = max_under

for t in range(T):
	dp[t][0] = AB[0][1]

for t in range(1,T):
	for i in range(1, N):
		A, B = AB[i]
		if A <= t:
			dp[t][i] = max(dp[t - 1][i], dp[t][i - 1], dp[t - A][i - 1] + B)
		else:
			dp[t][i] = max(dp[t - 1][i], dp[t][i - 1])


print(dp[-1][-1])

Measured memory_bytes: 113628
#include <bits/stdc++.h>
using namespace std;
int n, l; string s[109];
int main() {
	cin >> n >> l;
	for(int i = 0; i < n; i++) cin >> s[i];
	sort(s, s + n);
	for(int i = 0; i < n; i++) cout << s[i];
	cout << endl;
	return 0;
}

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


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

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <queue>
#include <math.h>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <bitset>
#include <list>
#include <ctype.h>
#include <cassert>
#include <stack>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <functional>
#include <ctime>
#include <limits>
#include <tuple>
#include <complex>
#include <numeric>
#include <future>

using namespace std;

#define snd second
#define fst first
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define left _left
#define right _right

const ld pi = acos(-1.0);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

template<typename T>
T sqr(T x) {
    return x * x;
}

template<typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename U, typename V>
ostream &operator<<(ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const vector<U> &x) {
    s << "[";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "]";
    return s;
}

template<typename U>
ostream &operator<<(ostream &s, const set<U> &x) {
    s << "{";
    bool was = false;
    for (auto it : x) {
        if (was) {
            s << ", ";
        }
        was = true;
        s << it;
    }
    s << "}";
    return s;
}

template<int sz>
ostream operator<<(ostream &s, const bitset<sz> &x) {
    for (int i = 0; i < sz; i++) {
        s << x[i];
    }
    return s;
}


//--------------------------------------------------------------------------


int main() {

    srand(time(NULL));

#ifdef LOCAL
    freopen("a.in", "r", stdin);
    //freopen("a.in", "w", stdout);
#else
    //freopen("brackets.in", "r", stdin);
    //freopen("brackets.out", "w", stdout);
#endif

    ll n, k;
    cin >> n >> k;

    ll a = n / k;

    ll ans = a * a * a;

    if (k % 2 == 0) {
        a = 0;
        for (int i = 1; i <= n; i++) {
            if (i % k == k / 2) {
                a++;
            }
        }
        ans += a * a * a;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, num)
    print(z-a+1)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 61936
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main(){
    int x,y;cin>>x>>y;
    int flag=0;
    for(int i=0;i<x+1;i++){
        int j=x-i;
        if(i*2 + j*4 == y) flag=1;
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	double x, y, z, r;
} Coord;

// typedef struct {
// 	int parent, rank;
// } Node;

typedef struct {
	int from, to;
	double weight;
} Edge;

Coord coord[ 100 ];
// Node node[ 100 ];
int node[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	if ( at > bt )
		return 1;
	return 0;
}

int find( int x ) {
	if ( node[ x ] == x )
		return x;
	else
		return node[ x ] = find( node[ x ] );
}

int uniteSame( int x, int y ) {
	int xSet = find( x ), ySet = find( y );

	if ( xSet == ySet )
		return 0;

	node[ ySet ] = xSet;

	return 1;
}

double kruskal( int v, int e ) {
	int i;
	double sum;

	qsort( edge, e, sizeof(Edge), &compare );

	for ( i = 0; i < v; i++ )
		node[ i ] = i;

	sum = 0.0;
	for ( i = 0; i < e; i++ )
		if ( uniteSame( edge[ i ].from, edge[ i ].to ) )
			sum += edge[ i ].weight;

	return sum;
}

int main( void ) {
	int i, j;
	int n, cnt;

	while ( scanf( "%d", &n ), n ) {
		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( sqrt( ( coord[ i ].x - coord[ j ].x ) * ( coord[ i ].x - coord[ j ].x ) + ( coord[ i ].y - coord[ j ].y ) * ( coord[ i ].y - coord[ j ].y ) + ( coord[ i ].z - coord[ j ].z ) * ( coord[ i ].z - coord[ j ].z ) ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}

		printf( "%.3f\n", kruskal( n, n * ( n - 1 ) / 2 ) );
	}

	return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int ans = 1001001;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        int tmp = 1;
        for (int i = 0; i < N; i++)
        {
            if (bit & (1 << i))
                tmp += K;
            else
                tmp *= 2;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <x86intrin.h>

using namespace std;

typedef long long ll;

#define F first
#define S second

#define mp make_pair
#define pb push_back

#define pii pair<int,int>
#define pll pair<ll,ll>

const int N = 30000;
const int INF = int(2e9);
const int MOD = int(1e9) + 7;

string s;

int main()  
{
    freopen("debug.txt","w",stderr);

    int n,a[200100];
    cin >> n;
    int cnt = 0;
    for(int i = 1;i <= n;i ++) {
    	cin >> a[i];
    	if(a[i] % 2 == 1) {
    		++ cnt;
    	}
    }
    if(cnt % 2 == 0) {
    	cout << "YES";
    }
    else {
    	cout << "NO";
    }
	return 0;  
}  

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n);
    int k = a[n-1];
    int sum = 0;
    rep(j,n) sum += a[j];
    if(sum - k > k)cout << "Yes" <<  endl;
    else cout << "No" << endl;
}

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

constexpr int inf = 1e9;

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    auto b = a;
    sort(begin(b), end(b));
    b.erase(unique(begin(b), end(b)), end(b));

    int ans = inf;
    vector<bool> ban(n);
    for(const auto mini : b) {
        vector<int> c;
        for(int i = 0; i < n; ++i) {
            if(ban[i]) continue;
            vector<int> tmp;
            while(i < n && !ban[i]) {
                tmp.push_back(a[i++]);
            }
            sort(begin(tmp), end(tmp));
            for(int j = 0; j < (int)tmp.size() - k + 1; ++j) {
                c.push_back(tmp[j]);
            }
        }

        if((int)c.size() < q) break;

        sort(begin(c), end(c));
        ans = min(ans, c[q - 1] - mini);
        for(int i = 0; i < n; ++i) {
            if(a[i] != mini) continue;
            ban[i] = true;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

state = 1  # 1=buy, 0=sell
cur = (1000, 0)  # yen, stock
for i in range(N - 1):
    if state == 1 and X[i + 1] > X[i]:
        n = cur[0] // X[i]
        cur = (cur[0] - n * X[i], cur[1] + n)
        state = 0
    elif state == 0 and X[i + 1] < X[i]:
        cur = (cur[0] + cur[1] * X[i], 0)
        state = 1

# Last
print(cur[0] + cur[1] * X[-1])


Measured memory_bytes: 61888
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b)
        cout << "Yes";
    else
        cout << "No";
}


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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;
int main() {
    int n = -1;  // < 10^5
    cin >> n;

    ll sum = 0;
    map<int, ll> valcnt;
    rep(i, 0, n) {
        int inp = -1;
        cin >> inp;
        valcnt[inp]++;
        sum += inp;
    }

    int q = -1;
    cin >> q;
    // n
    rep(i, 0, q) {
        int from_val, to_val;
        cin >> from_val >> to_val;

        sum += to_val * valcnt[from_val] - from_val * valcnt[from_val];

        // log n
        valcnt[to_val] += valcnt[from_val];
        valcnt[from_val] = 0;

        cout << sum << endl;

        //     // n
        //     ll ans = 0;
        //     for (auto x : valcnt) {
        //         // cout << x.first << " : " << x.second << endl;
        //         ans += x.first * x.second;
        //     }
        //     cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std;
int a[10005]={0};
int main()
{
	 int n;
	 cin>>n;
	 if(n==25)
	 {
	 	printf("Christmas\n");
	 }
	 else if(n==24)
	 {
	 	printf("Christmas Eve\n");
	 }  else if(n==23)
	 {
	 	printf("Christmas Eve Eve\n");
	 } else if(n==22)
	 {
	 	printf("Christmas Eve Eve Eve\n");
	 } 
	 
 } 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

int p,q,r;

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

        cin >> p >> q >> r;

        cout << p + q + r  - max(p, max(q, r)) << endl;

        return 0;
}


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

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int X,t;

	cin >> X >> t;
  
  	if(X-t>0){
      cout << X-t << endl;
    }else{
      cout << 0 << endl;
    }
  


	
	return 0;
}

Measured memory_bytes: 256
nm=list(map(int,input().split()))
a,b=[],[]
for i in range(nm[0]):
    a.append(input())
for j in range(nm[1]):
    b.append(input())

def check(i,j):
    result="match"
    for k in range(nm[1]):
        if b[k]==a[i+k][j:j+nm[1]]:
            continue
        else:
            result="unmatch"
            break
    return result

flag=0
for i in range(nm[0]-nm[1]+1):
    if flag==0:
        for j in range(nm[0]-nm[1]+1):
            if check(i,j)=="match":
                print("Yes")
                flag=1
                break
if flag==0:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int total=0;
  int i,j,k;
  cin >> N;
  vector<int> jewel(N),value(N);
  for(i=0; i<N; i++){
    cin >> jewel.at(i);
  }
  for(j=0; j<N; j++){
    cin >> value.at(j);
  }
  for(k=0; k<N; k++){
    if(jewel.at(k)-value.at(k)>0){
      total=total+jewel.at(k)-value.at(k);
    }
  }
  cout << total << endl;
}
  
  


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9
def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if a * b * c > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

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

Measured memory_bytes: 41944
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[101010]={},c=0;
	cin>>n;
	FOR(i,0,n){
		cin>>a[i];
		if(a[i]%2==1)c^=1;
	}
	if(c)cout<<"NO"<<endl;
	else cout<<"YES";

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define MAX 300

int main(){
	int i,j,n;
	int dp[MAX];
	while(scanf("%d",&n)==1&&n){
		memset(dp,0,sizeof(dp));
		dp[0]=1;
		for(i=1;i*i<=n;i++){
			for(j=i*i;j<=n;j++){
				dp[j] += dp[j-i*i];
			}
		}
		//for(i=0;i<=n;i++)printf("%d ",dp[i]);
		printf("%d\n",dp[n]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <math.h>
using namespace std;
int ctoi(char c){
    switch(c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default : return -1;
    }
}
int main(){
	string x = "";
	for(;;) {
	   cin >> x;
	   if (x=="0") break;
		int sum = 0;
		for (int i=0; i<x.size(); i++){
			sum += ctoi(x[i]);
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = list(map(int, readline().split()))
if sum(a) > n:
    print(-1)
else:
    print(n - sum(a))


Measured memory_bytes: 9780
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
signed main(){
	double a[50]={};
	int i=0;
	for(;cin>>a[i];i++);
	sort(a,a+i);
	cout<<a[i-1]-a[0]<<endl;
}


Measured memory_bytes: 3248
#include <stdio.h>

int main(){

	int x, y;

	while(1){
		scanf("%d %d", &x, &y);
			if(x==0 && y==0)break;
				if(x<y){
			printf("%d %d\n", x, y);
			}

		else{
			printf("%d %d\n", y, x);
		}
	}
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 100000+5;

struct Edge{
    int to,w,next;
}e[MAXN<<1];

int head[MAXN],cnt,size[MAXN],max[MAXN];
int N;

inline void add(int u,int v,int w){
    e[++cnt] = (Edge){v,w,head[u]};head[u] = cnt;
}

void dfs(int v,int fa){
    size[v] = 1;
    for(int i = head[v];i;i = e[i].next){
        if(e[i].to == fa) continue;
        dfs(e[i].to,v);
        size[v] += size[e[i].to];
        max[v] = std::max(max[v],size[e[i].to]);
    }
    max[v] = std::max(max[v],N-size[v]);
}

LL ans;

void dfs(int v,int fa,LL val){
    size[v] = 1;
    for(int i = head[v];i;i = e[i].next){
        if(e[i].to == fa) continue;
        dfs(e[i].to,v,val+e[i].w);
        size[v] += size[e[i].to];
    }
    ans += val;
}

int main(){
    scanf("%d",&N);
    FOR(i,1,N-1){
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        add(u,v,w);add(v,u,w);
    }
    dfs(1,0);int s=0;
    FOR(i,1,N) if(2*max[i] <= N) s = i;
    dfs(s,0,0ll);int min=INT_MAX;
    for(int i = head[s];i;i = e[i].next){
        if(size[e[i].to] == (N+1)/2){
            min = e[i].w;break;
        }
        else min = std::min(min,e[i].w);
    }
    printf("%lld\n",2*ans-min);
    return 0;
}

Measured memory_bytes: 7808
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;


//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else 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;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	ll N;cin >> N;
	vector<char> a(26);
	a[0] = 'z';
	for(int i = 1; i < 26; i++) a[i] = (char)( i - 1 +'a'); 
	
	string S;
	while(N != 0){
		ll x = N % 26;
		S += a[x];
		
		if(N%26 == 0){
			N /= 26;
			N--;
		}
		else N /= 26;
	}

	reverse(ALL(S));
	cout << S << endl;
}	

Measured memory_bytes: 11012
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, R) = read!(usize, usize);
    let r = if N >= 10 { R } else { R + 100 * (10 - N) };
    println!("{}", r)
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    int x,y;
    while(true){
        cin>>x>>y;
        if (x==0&&y==0) {
            return 0;
        } else if(x<y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
    }
}


Measured memory_bytes: 3076
function Main(input) {
  input = input.split("\n");
  N = parseInt(input[0]);
  tmp = input[1].split(" ");
  a = new Array(N);
  var ans =0;
  for(i=0;i<N;i++){
    while(tmp[i]%2==0){
      ans++;
      tmp[i]/=2;
    }
  }

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S, T= "Yes";
  cin >> N >> S;
  if(S.size() % 2 == 1)
    T = "No";
  else
    for (int i= 0;i < S.size()/2; i++){
      if (S.at(i) == S.at(S.size()/2+i))
        continue;
      else
        T ="No";
        break;
    }
  cout << T << endl; 
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	_ = nextInt()
	K := nextInt()
	S := nextString()
	s := []byte(S)
	log.Println('a' - 'A')
	s[K-1] = s[K-1] + 32
	fmt.Println(string(s))
}

var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type pairs []Pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}
func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int>h;
	for(int i=0;i<n;i++)
	{
		int input;
		cin>>input;
		h.push_back(input);
	}
	int dp[n+1]={0};
	dp[1]=0,dp[2]=abs(h[0]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i-2]-h[i-1]),dp[i-2]+abs(h[i-3]-h[i-1]));
	}
	cout<<dp[n];
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2e5+23;
const int mod = 1e9+7;

vector<int> c[N];
int n, a[N], dp[N];

int rek(int pos) {
  if (pos == n) return 1;
  int &ret = dp[pos];
  if (ret != -1) return ret;
  ret = rek(pos+1);
  if (pos+1 < n && a[pos+1] == a[pos]) return ret;
  int A = upper_bound(c[a[pos]].begin(), c[a[pos]].end(), pos)-c[a[pos]].begin();
  if (A < c[a[pos]].size()) {
    ret = (ret + rek(c[a[pos]][A])) % mod;
  }
  return ret;
}

void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (c[a[i]].size() && c[a[i]].back() == i-1) c[a[i]].pop_back();
    c[a[i]].push_back(i);
    dp[i] = -1;
  }
  printf("%d", rek(0));
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 25712
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)

signed main(){
    int n;
    cin >> n;
    int id[MAX] = {};
    REP(i,n){
        int tmp; cin >> tmp;
        id[tmp] = i+1;
    }
    set<int> S;
    S.insert(0);
    S.insert(n+1);
    int res = 0;
    FOR(i,1,n+1){
        S.insert(id[i]);
        auto itr = S.find(id[i]);
        auto itr1 = next(itr);
        auto itr2 = prev(itr);
        res += i * (*itr - *(itr1) ) * ( *(itr2) - *(itr)  );

    }

    cout << res << endl;
}


Measured memory_bytes: 11136
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let mut ans = 0usize;
    let S: Vec<char> = sc.chars();
    let N = S.len();
    let mut cur = 0;
    while cur < N {
        let c = S[cur];
        while cur < N && S[cur] == c {
            cur += 1;
        }
        ans += 1;
    }
    ans -= 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int N, X, Y, dp[2005][2005], ans[2005];
int main() {
  scanf("%d %d %d", &N, &X, &Y);
  dp[X][Y] = 1;
  for(int i = 1; i < N; ++i) {
    for(int j = i+1; j <= N; ++j) {
      if(j > X && i < Y) {
        dp[i][j] = min(j-i, dp[i][X]+dp[X][Y]+abs(j-Y));
      } else {
        dp[i][j] = j-i;
      }
      dp[j][i] = dp[i][j];
    }
  }
  for(int i = 1; i < N; ++i) {
    for(int j = i+1; j <= N; ++j) {
      ++ans[dp[i][j]];
    }
  }
  for(int i = 1; i < N; ++i) {
    printf("%d\n", ans[i]);
  }
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = (1 << 21);
const int mod = 1e9 + 7;

int n, a[25][25], f[N];

void Enter()
{
     Cin(n);
     For(i, 0, n - 1)
     {
         For(j, 0, n - 1)
         Cin(a[i][j]);
     }
}

bool Get(int x, int i)
{
    return (x >> i) & 1;
}

void Solve()
{
     f[0] = 1;
     vector<int> v;
     For(bit, 1, (1 << n) - 1)
     {
         int j = __builtin_popcount(bit) - 1;
         v.clear();
         For(i, 0, n - 1) if(Get(bit, i)) v.pb(i);
         for(int x: v)
         {
             if(a[x][j]) f[bit] += f[bit - (1 << x)];
             if(f[bit] >= mod) f[bit] -= mod;
         }
     }
     cout << f[(1 << n) - 1];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 8448
#include<iostream>
#include<string.h>
#include<algorithm>

using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int n1=s.length();
    int n2=t.length();
    int max1=0;
    for (int i=0;i+n2<=n1;i++)
    {
        int num=0;
        for (int j=0;j<n2;j++)
        {
            if (s[i+j]==t[j])
                num++;
        }
        if (num>max1)
            max1=num;
    }
    cout<<n2-max1<<endl;
    return 0;
}


Measured memory_bytes: 3624
//40
#include<iostream>
#include<algorithm>

#define S(X) ((X)*(X))

using namespace std;

int main(){
  for(int l[3];cin>>l[0]>>l[1]>>l[2],l[0]|l[1]|l[2];){
    sort(l,l+3);
    int n;
    cin>>n;
    while(n--){
      int r;
      cin>>r;
      cout<<((S(l[0])+S(l[1])<S(2*r))?"OK":"NA")<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define INF 900000000

using namespace std;

int main(){
	int a,b,c,d=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(c%i==0)d++;
	}
	cout<<d<<endl;
	return 0;
}



Measured memory_bytes: 3100
from math import hypot

MAX = 1000

n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

def dist(x1, y1, x2, y2):
    return hypot(x1 - x2, y1 - y2)

def maxDist(x, y):
    res = 0
    for xx, yy in a:
        res = max(res, dist(x, y, xx, yy))
    return res

def f(x):
    left, right = 0, MAX
    for _ in range(80):
        y1 = (left * 2 + right) / 3
        y2 = (left + right * 2) / 3
        if maxDist(x, y1) > maxDist(x, y2):
            left = y1
        else:
            right = y2
    return maxDist(x, left)

left, right = 0, MAX
for _ in range(80):
    x1 = (left * 2 + right) / 3
    x2 = (left + right * 2) / 3
    if f(x1) > f(x2):
        left = x1
    else:
        right = x2
print(f(left))

Measured memory_bytes: 3064