akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 62) - 1;

int main(void)
{
    int n, m;
    vector<int> s, c;
    int i, j;
    bool flag;
    int b, g;

    cin >> n >> m;

    s.resize(m);
    c.resize(m);

    rep(i, 0, m)
    {
        cin >> s[i] >> c[i];
    }

    if (n == 1)
    {
        b = 0;
        g = 10;
    }
    if (n == 2)
    {
        b = 10;
        g = 100;
    }

    if (n == 3)
    {
        b = 100;
        g = 1000;
    }

    rep(i, b, g)
    {
        flag = true;
        rep(j, 0, m)
        {
            if (n - s[j] == 2)
            {
                if (i / 100 != c[j])
                {
                    flag = false;
                }
            }

            if (n - s[j] == 1)
            {
                if ((i % 100) / 10 != c[j])
                {
                    flag = false;
                }
            }

            if (n - s[j] == 0)
            {
                if (i % 10 != c[j])
                {
                    flag = false;
                }
            }
        }

        if (flag)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    string S, T;
    cin >> S >> T;
    int ans = LLONG_MAX;
    rep(i, S.length() - T.length() + 1) {
        int cnt = 0;
        rep(j, T.length()) { cnt += S[i + j] != T[j]; }
        chmin(ans, cnt);
    }
    cout << ans << endl;
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, K; cin >> N >> K;
        vector<int> A(N); cin >> A;
        vector<ll> sum(N + 1);
        rep(i, N) sum[i + 1] = sum[i] + A[i];
        vector<ll> range_sum;
        range_sum.reserve(N * (N + 1) / 2);
        rep(i, N) {
            rep(j, i + 1) {
                ll x = sum[i + 1] - sum[j];
                range_sum.push_back(x);
            }
        }
        vector<ll> candidates = range_sum;
        auto update_candidates = [&] (int upper_bit) {
            vector<int> num_bit(upper_bit);
            for(ll x : candidates) {
                rep(i, upper_bit) if(x & (1ll << i)) num_bit[i]++;
            }
            int max_bit = -1;
            rep(i, upper_bit) if(num_bit[i] >= K) max_bit = i;
            cerr << "max_bit " << max_bit << endl;
            if(max_bit >= 0) {
                vector<ll> nxt;
                for(ll x : candidates) if(x & (1ll << max_bit)) nxt.push_back(x);
                candidates = nxt;
            }
            return max_bit;
        };

        int upper_bit = 60;
        vector<ll> prev;

        cerr << "! ";
        for(ll x : candidates) cerr << x << " ";
        cerr << endl;

        while(candidates.size() >= K and upper_bit >= 0) {
            prev = candidates;

            upper_bit = update_candidates(upper_bit);

            cerr << "! ";
            for(ll x : candidates) cerr << x << " ";
            cerr << endl;
        }
        candidates = candidates.size() >= K ? candidates : prev;
        ll ans = candidates[0];
        rep(i, K) {
            ans &= candidates[i];
        }
        cout << ans << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 13176
N,M = map(int, input().split())
edges = []
for _ in range(M):
  u,v,c = map(int, input().split())
  edges.append((-c,u-1,v-1))

INF = float('inf')
dist = [INF] * N
dist[0] = 0
for _ in range(N-1):
  for c,u,v in edges:
    if dist[v] > c+dist[u]:
      dist[v] = c+dist[u]

neg_cycle = [False]*N
for c,u,v in edges:
  if dist[v] > c+dist[u]:
    dist[v] = c+dist[u]
    neg_cycle[u] = True
    neg_cycle[v] = True

if neg_cycle[N-1]:
  print('inf')
else:
  print(-dist[N-1])

Measured memory_bytes: 46040
L = int(input())
A = [int(input()) for _ in range(L)]

def cost(k, a):
    if k == 0 or k == 4:
        return a

    if a % 2:
        a = 1
    elif a >= 2:
        a = 2

    if k == 1 or k == 3:
        return 2 - a

    return 1 - a % 2

dp = [[10**18] * 5 for _ in range(L + 1)]
dp[0][0] = 0

for i, a in enumerate(A, start=1):
    for j in range(5):
        for k in range(j, 5):
            b = dp[i - 1][j] + cost(k, a)
            if dp[i][k] > b:
                dp[i][k] = b

ans = min(dp[L])
print(ans)

Measured memory_bytes: 95824
#include <iostream>

using namespace std;

int main() {
	long long int n, m;
	cin >> n >> m;
	long long int m2 = m/2;
	if (n >= m2) {
		cout << m2 << endl;
	} else {
		long long int m3 = m-n*2;
		m3 /= 4;
		cout << n+m3 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
const int maxn = 110;
const int mod = 1e9 + 7;
using namespace std;

vector<int> vi[4];
long long sum[4][maxn];
int main()
{
	int i, j, k, N, W, w[maxn], v;
	cin >> N >> W;
	for (i = 0; i < N; i ++)
	{
		cin >> w[i] >> v;
		vi[w[i] - w[0]].push_back(v);
	}
	for (i = 0; i < 4; i ++)
	{
		sum[i][0] = 0;
		if (vi[i].size() > 0)
		{
			sort(vi[i].begin(), vi[i].end(), greater<int>());
			for (j = 0; j < vi[i].size(); j ++)
			{
				sum[i][j + 1] = sum[i][j] + vi[i][j];
			}
		}
	}
	long long ans = 0;
	
	for (i = 0; w[0] * i <= W && i <= vi[0].size(); i ++)
	{
		int t1 = W - w[0] * i;
		long long v1 = sum[0][i];

		for (j = 0; (w[0] + 1) * j <= t1 && j <= vi[1].size(); j ++)
		{
			long long v2 = v1 + sum[1][j];
			int t2 = t1 - (w[0] + 1) * j;
			for (k = 0; (w[0] + 2) * k <= t2 && k <= vi[2].size(); k ++)
			{
				int t3 = t2 - (w[0] + 2) * k;
				long long v3 = v2 + sum[2][k] + sum[3][t3 / (w[0] + 3)];
				if (v3 > ans)
					ans = v3;
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main(int argc, char *argv[])
{
    int a, b;
    int h, m;

    cin >> a >> b >> h >> m;

    // \pi/2 - (2 * \pi / 60) * m
    const double theta_m = M_PI_2 - (M_PI / 30. * m);
    const double m_x = b * cos(theta_m);
    const double m_y = b * sin(theta_m);

    // hour: \pi/2 - (2 * \pi / 12) * h
    // min: (2 * \pi / 12 / 60) * m
    const double theta_h = (M_PI_2 - (M_PI / 6. * h)) - (M_PI / 360. * m);
    const double h_x = a * cos(theta_h);
    const double h_y = a * sin(theta_h);

    const double r = sqrt(((h_x - m_x) * (h_x - m_x)) + ((h_y - m_y) * (h_y - m_y)));
    cout << fixed << setprecision(19) << r << endl;

    return 0;
}

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

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

  vector<int> l(n);
  vector<int> r(n);

  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> l[i] >> r[i];

    sum += r[i] - l[i] + 1;
  }

  cout << sum << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
#define MAX_N 400

bool color[MAX_N][MAX_N];
int H, W;
typedef pair<int, int> P;

char ch[MAX_N + 1];

bool isin_(int y, int x)
{
    return 0 <= y && y < H && 0 <= x && x < W;
}

bool check_(int y, int x, int d)
{
    int ny = y + dy[d];
    int nx = x + dx[d];
    if (!isin_(ny, nx)) {
        return false;
    }
    if (color[y][x] == color[ny][nx]) {
        return false;
    }
    return true;
}

bool used[MAX_N][MAX_N];

ll solve()
{
    ll ans = 0;
    ll b = 0, w = 0;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if (used[y][x]) {
                continue;
            }
            b = 0;
            w = 0;
            queue<P> que;
            used[y][x] = true;
            que.push(P(y, x));
            while (!que.empty()) {
                P p = que.front();
                que.pop();
                int cur_y = p.first, cur_x = p.second;
                if (color[cur_y][cur_x]) {
                    b++;
                } else {
                    w++;
                }
                for (int d = 0; d < 4; ++d) {
                    if (!check_(cur_y, cur_x, d)) {
                        continue;
                    }
                    int ny = cur_y + dy[d], nx = cur_x + dx[d];
                    if (used[ny][nx]) {
                        continue;
                    }
                    used[ny][nx] = true;
                    que.push(P(ny, nx));
                }
            }
            ans += b * w;
        }
    }
    return ans;
}

int main()
{
    cin >> H >> W;
    rep(i, H)
    {
        rep(j, W)
        {
            char t;
            cin >> t;
            color[i][j] = t == '#';
        }
    }
    ll ans = solve();
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a, b, c, d, s1, s2;
    cin >> a >> b >> c >> d;
    s1 = a * b;
    s2 = c * d;
    if(s1 > s2) {
        cout << s1 << endl;
    } else {
        cout << s2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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 all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);


int dfs(int x, int depth, vvi &path, vi &checked){
    int n = checked.size() - 1;
    if (checked[x]) return 0;
    if (depth == n) return 1;
    checked[x] = 1;
    int ans = 0;
    rep2(i, 1, n + 1){
        if (path[x][i]) ans += dfs(i, depth + 1, path, checked);
    }
    checked[x] = 0;
    return ans;
}


int main() {
    int n, m;
    cin >> n >> m;
    vvi path(n + 1, vi(n + 1));
    rep(i, m){
        int a, b;
        cin >> a >> b;
        path[a][b] = 1;
        path[b][a] = 1;
    }
    vi checked(n + 1, false);
    cout << dfs(1, 1, path, checked) << endl;
}


Measured memory_bytes: 3576
import Control.Applicative

main = do 
	[h, w] <- toIntList <$> getLine
	if h == 0 && w == 0
	then return ()
	else do 
		mapM_ putStrLn $ showAnswer h w
		putStrLn ""
		main

toIntList :: String -> [Int]
toIntList = map read . words

showAnswer :: Int -> Int -> [String]
showAnswer h w = replicate h $ replicate w '#'


Measured memory_bytes: 4108
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int sum(int a) {
    int sums = 0;
    sums += a / 10000;
    sums += (a % 10000) / 1000;
    sums += (a % 1000) / 100;
    sums += (a % 100) / 10;
    sums += a % 10;
    
    return sums;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0, sums;
    rrep(i, n) {
        sums = sum(i);
        if(sums >= a && sums <= b) ans += i;
    }
    cout << ans << 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;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> b;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (i % 2 == 0) b.push_back(a);
        else b.insert(b.begin(), a);
    }
    
    if (n % 2 == 1) {
        for (int i = n - 1; i >= 0; i--)
        {
            if (i != 0)
                cout << b[i] << " ";
            else
                cout << b[i];
        }
        
    } else {
        for (int i = 0; i < n; i++)
        {
            if (i != n - 1)
                cout << b[i] << " ";
            else
                cout << b[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F         first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cerr << #x << " is " << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
 
void solve(){
    int n,k;
    cin>>n;
    int a[n][3];
    rep(i,0,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3];

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    

    rep(i,1,n){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
 
 
 
int main(){
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   
 
    int t=1,i=1;
   // cin>>t;
    
 
    while(t--){
       // cout<<"Case #"<<i++<<": ";
        solve();
    
    }
 
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
const long double pi= 3.141592653589793238;
void solve(){
    long double a,b,h,m;
    cin>>a>>b>>h>>m;
    long double x1, x2, y1, y2;
    x1=a*sin((h+ m/60)/12 * 2*pi);
    x2=b*sin(m/60 * 2*pi);
    y1=a*cos((h+ m/60)/12 * 2*pi);
    y2=b*cos(m/60 * 2*pi);
    cout<<fixed<<setprecision(18)<<sqrtl((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));

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

Measured memory_bytes: 4184
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n, k; cin >> n >> k;

	vector<int> vis(n);
	for (auto& elem : vis) {
		cin >> elem;
	}

	int max_m_c = min(n, k);
	int ans = 0;

	FOR_LE(m, 0, max_m_c) {
		int d_n = k - m;
		FOR_LE(p, 0, m) {
			vector<int> js;
			FOR_LT(i, 0, p) {
				js.push_back(vis[i]);
			}
			FOR_LT(i, 0, m - p) {
				js.push_back(vis[n - 1 - i]);
			}
			sort(js.begin(), js.end());

			int d_c = 0;
			FOR_LT(i, 0, min(d_n, m)) {
				if (js[i] < 0) d_c++;
			}

			int c_val = 0;
			FOR_LT(i, d_c, m) {
				c_val += js[i];
			}

			ans = max(ans, c_val);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func all(l []bool) bool {
	for _, v := range l {
		if !v {
			return false
		}
	}
	return true
}

func dfs(g [][]int, node int, visited []bool) int {
	if all(visited) {
		return 1
	}

	sum := 0
	for _, neigh := range g[node] {
		if !visited[neigh] {
			visited[neigh] = true
			sum += dfs(g, neigh, visited)
			visited[neigh] = false
		}
	}
	return sum
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, m)
	bs := make([]int, m)
	for i := range as {
		fmt.Scan(&as[i])
		fmt.Scan(&bs[i])
	}

	g := make([][]int, n)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for i, a := range as {
		b := bs[i]
		g[a-1] = append(g[a-1], b-1)
		g[b-1] = append(g[b-1], a-1)
	}

	visited := make([]bool, n)
	visited[0] = true
	fmt.Println(dfs(g, 0, visited))
}


Measured memory_bytes: 512
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String str1 = sc.next();
    String str2 = sc.next();
    int cnt = 0;
    
    for(int i=0; i<3; i++){
      if(str1.charAt(i)==str2.charAt(i)){
        cnt++;
      }
    }
    
    System.out.println(cnt);
  }
}

Measured memory_bytes: 23764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b >> c;

	ans = b / a;
	ans = min(ans , c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for(auto i = 0;i < n;i++)

using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 999;
	REP(i, s.size()-2){
		ans = min(abs(stoi(s.substr(i, 3)) - 753), ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim X, Y, Z As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        X = arr(0) : Y = arr(1) : Z = arr(2)
        Console.WriteLine(Cstr(Z) + " " + CStr(X) + " " + CStr(Y))
    End Sub
End Class


Measured memory_bytes: 13524
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int d[1000000];
int main() {
	int n, q;
	while (cin >> n >> q&&n != 0 && q != 0) {
		fill(d, d + 1000000, 0);
		int m, d2, sum[2] = { -1,0 }, maxd = -1;
		for (int i = 0; i < n; i++) {
			cin >> m;
			for (int i = 0; i < m; i++) {
				cin >> d2;
				d[d2]++;
				maxd = max(d2, maxd);
			}
		}
		for (int i = 0; i <= maxd; i++) {
			if (d[i] > sum[0]) {
				sum[0] = d[i];
				sum[1] = i;
			}
		}
		if (sum[0] >= q) cout << sum[1] << endl;
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ll n,k,r,s,p;
	string T,myH;
	cin >> n >> k >> r >> s >> p >> T;

	ll ans = 0;
	FOR(i,0,k){
		if(T[i]=='r'){
			ans += p;
		}else if(T[i]=='p'){
			ans += s;
		}else if(T[i]=='s'){
			ans += r;
		}
	}
	FOR(i,k,n){
		if(T[i]==T[i-k]){
			T[i] = 'a';
		}
		if(T[i]=='r'){
			ans += p;
		}else if(T[i]=='p'){
			ans += s;
		}else if(T[i]=='s'){
			ans += r;
		}
	}
	cout << ans << endl;

}

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

int main() {
  int a,b,ans;
  
  cin >> a >> b;
  
  if( a%b == 0 || b%a == 0){
  	ans = (a + b)/2; 
  	}else{
    ans = (a + b)/2 + 1;
  	}
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool maki[2][1000],niko[2][100],umi[2][10],eri[1000];
    memset(maki,0,sizeof(maki));
    memset(niko,0,sizeof(niko));
    memset(umi,0,sizeof(umi));
    memset(eri,0,sizeof(eri));
    ll n,ans=0,num=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        
        umi[(i+1)&1][s[i]-'0']=true;
        if(num>=1){
            niko[(i+1)&1][s[i]-'0']=true;
        }
        if(num==2){
            maki[(i+1)&1][s[i]-'0']=true;
            eri[s[i]-'0']=true;
        }
        if(s[i]-'0'==0)num++;
        for(int j=99;j>=0;j--){
            if(maki[i&1][j]||niko[i&1][j]){
                maki[(i+1)&1][j*10+(s[i]-'0')]=true;
                eri[j*10+(s[i]-'0')]=true;
            }
            if(j<10&&umi[i&1][j]){
                niko[(i+1)&1][j*10+(s[i]-'0')]=true;
            }
        }
        for(int j=0;j<100;j++){
            if(j<10){
                if(umi[i&1][j])umi[(i+1)&1][j]=true;
                if(niko[i&1][j])niko[(i+1)&1][j]=true;
                if(maki[i&1][j])maki[(i+1)&1][j]=true;
                if(maki[i&1][j])eri[j]=true;
            }
            else{
                if(niko[i&1][j])niko[(i+1)&1][j]=true;
                if(maki[i&1][j])maki[(i+1)&1][j]=true;
                if(maki[i&1][j])eri[j]=true;
            }
                    
        }
    }
    for(int i=0;i<1000;i++){
        if(eri[i]){
            ans++;
        }
    }

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


Measured memory_bytes: 384
(let* ((n (read))
       (p (make-array (list n))))
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref p i) (read)))
  (format t "~A~%" (loop :for i :from 1 :to (- n 2)
                         :if (or (< (aref p (1- i)) (aref p i) (aref p (1+ i)))
                                 (< (aref p (1+ i)) (aref p i) (aref p (1- i))))
                         :sum 1)))


Measured memory_bytes: 24508
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a; cin >> a;
    cout << (a < 1000 ? "ABC" : "ABD") <<endl; 
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e4+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    char a;
    cin>>a;
    cout<<(a>='a'&&a<='z'?'a':'A');
}

Measured memory_bytes: 3608
#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 n;
  cin >> n;
  cout << n*n*n + n*n +n << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n, k;
	cin >> n;
	cin >> k;

	int arr[n];

	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}


	int dp[n];
	dp[0] = 0;

	for (int i = 1; i < n; ++i) {

		int mi = INT_MAX;
		for (int j = k; j >= 1; --j) {
			if (i - j >= 0) {
				mi = min(mi, abs(arr[i] - arr[i - j]) + dp[i - j]);
			}
		}
		dp[i] = mi;

	}

	cout << dp[n - 1] << endl;


	return 0;
}

Measured memory_bytes: 4388
N = int(input())
W = []
Ws = []
first = []
count = 0
for i in range(N):
    W.append(input())
    Ws.append(list(W[i]))
else:
    first.append(len(W))
    first.append(len(set(W)))
    if first[0] != first[1]:
        print("No")
    else:
        for i in range(N-1):
            maxw = len(Ws[i]) - 1
            if Ws[i][maxw] == Ws[i + 1][0]:
                count += 1
        else:
            if count == N - 1:
                print("Yes")
            else:
                print("No")


Measured memory_bytes: 3064
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 <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


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

int n, y, m, d;

int r = 39 * 5, t = 20 * 10;
int s = r * 2 + t;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &y, &m, &d);
    y--; m--;
    int sum = (y / 3) * s + (y - (y / 3) * 3) * r;
    int temp = m * 20 + d;
    if ((y + 1) % 3 != 0) {
      temp -= m / 2;
      sum += temp;
    } else {
      sum += temp;
    }
    printf("%d\n", s * 333 + 1 - sum);
  }
}



Measured memory_bytes: 2696
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n;

  cin >> n;

  vector<int> a(n);

  fillInt(a, n);

  int mx = -1;
  int sn = -1;
  rep(i, n) {
    if (mx <= a[i]) {
      sn = mx;
      mx = a[i];
    } else if (sn <= a[i]) {
      sn = a[i];
    }
  }

  rep(i, n) {
    if (a[i] == mx) {
      cout << sn << endl;
    } else {
      cout << mx << endl;
    }
  }
}


Measured memory_bytes: 2432
import java.util.Scanner;

class Solver {

    private final int K;

    Solver(Scanner in){
        int N = in.nextInt();
        K = in.nextInt();
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (in.nextInt() >= K) count++;
        }
        System.out.println(count);
    }

    void solve() {

    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 48032
(let ((x (read))
      (k (read))
      (d (read)))
  (if (>= (abs x) (* d k))
      (format t "~A~%" (- (abs x) (* d k)))
      (let* ((a (floor (abs x) d))
             (b (1+ a))
             (p (- (abs x) (* d a)))
             (q (- (* d b) (abs x))))
        (if (evenp (- k a))
            (format t "~A~%" p)
            (format t "~A~%" q)))))


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

pair<ll, int> p[100010]={};
int nd[100010];
vector<vector<int>> desc;
ll dep[100010]={};

ll dfs(int key){
	ll res=dep[key];
	for(int i=0; i<desc[key].size(); ++i){
		dep[desc[key][i]]=dep[key]+1;
		res += dfs(desc[key][i]);
	}
	return res;
}

int main() {
	int N;
	cin >> N;
	for(int i=1; i<=N; ++i){
		ll D;
		cin >> D;
		p[i-1]=make_pair(D, i);
	}
	sort(p, p+N, greater<>());
	desc.resize(N+1);
	for(int i=1; i<=N; ++i) nd[i]=1;
	for(int i=0; i<N-1; ++i){
		int ng=i, ok=N-1;
		ll key=p[i].first-(N-nd[p[i].second]*2);
		while(ng+1<ok){
			int mid=(ng+ok)/2;
			if(p[mid].first<=key) ok=mid;
			else ng=mid;
		}
		if(p[ok].first!=key){
			cout << -1 << endl;
			return 0;
		}
		desc[p[ok].second].emplace_back(p[i].second);
		nd[p[ok].second] += nd[p[i].second];
	}
	if(dfs(p[N-1].second)!=p[N-1].first){
		cout << -1 << endl;
		return 0;
	}
	for(int i=1; i<=N; ++i){
		for(int j=0; j<desc[i].size(); ++j){
			cout << i << ' ' << desc[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int x;
	cin>>x;
	if(x>=30)
	cout<<"Yes";
	else
	cout<<"No";	
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//#define int long long
#define LL long long
#define ULL unsigned long long

const LL LL_INF = ~(ULL)0 >> 1;

struct edge {
    int to, cost;
    edge() {}
    edge(int to, int cost) {
        this->to = to;
        this->cost = cost;
    }
};

typedef pair<int, int> P;

signed main() {
    int n, k;
    while (cin >> n >> k, n) {
        vector<edge> gra[n + 1];
        for (int i = 0; i < k; ++i) {
            int flag;
            cin >> flag;

            if (flag) {
                int c, d, e;
                cin >> c >> d >> e;

                gra[c].push_back(edge(d, e));
                gra[d].push_back(edge(c, e));
            } else {
                int a, b;
                cin >> a >> b;
                LL d[n + 1];
                fill(d, d + n + 1, LL_INF);
                d[a] = 0;
                priority_queue<P, vector<P>, greater<P>> q;
                q.push(P(0, a));

                while (q.size()) {
                    P p = q.top();
                    q.pop();
                    int v = p.second;
                    if (d[v] < p.first) continue;

                    for (int j = 0; j < gra[v].size(); ++j) {
                        edge e = gra[v][j];
                        if (d[v] + e.cost < d[e.to]) {
                            d[e.to] = d[v] + e.cost;
                            q.push(P(d[e.to], e.to));
                        }
                    }
                }

                printf("%ld\n", ((d[b] == LL_INF) ? -1 : d[b]));
            }
        }
    }
}

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

using namespace std;

int main(){
        string s;
        int K;

        cin >> s;
        cin >> K;


        for(int i=0;i<s.length()-1;i++){
                if(('z'-s[i]+1)%26<=K){
                        K-=('z'-s[i]+1)%26;
                        s[i]='a';
//                        cout << "K=" << K << endl;
                }else{
                        continue;
//                      s[i]+=K;
//                        cout << "K=" << K << endl;
                }
        }

        s[s.length()-1] = (s[s.length()-1]-'a'+K)%26 + 'a';

        cout << s << endl;
        return 0;
}


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

int main(void) {
    string str; 
    cin >> str;
    if ((str[0]==str[1] && str[1]==str[2]) || (str[1]==str[2] && str[2]==str[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;
    cin >> N;

    // B1          B2          B3          ...
    // max(A1, A2) max(A2, A3) max(A3, A4) ...

    // A1* == B1
    // A2* == min(B1, B2)
    // A3* == min(B2, B3)
    // ...
    // A(N - 1)* == min(B(N - 2), B(N - 1))
    // AN* == B(N - 1)

    vector<int> B(N - 1);
    for (int &b : B)
    {
        cin >> b;
    }

    int ans = B.front() + B.back();
    for (int i = 0; i < N - 2; i++)
    {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())

def aaa(a,b):
    n = max(a,b)
    m = min(a,b)
    if n % m == 0:
        return 2 * n - m
    else:
        return 2 * m * int(n / m) + aaa(m, n % m)

ans = n + aaa(n-x, x)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n+1);
	vector <ll> num(n+1,0);
	vector <ll> ans;
	for (int z=1;z<=n;z++){
		cin >> arr[z];
	}
	for (int z=n;z>0;z--){
		bool ok = false;
		ll c = 0;
		ll x = 1;
		while (z*x <= n){
			c += num[z*x];
			x++;
		}
		if (arr[z] == 0){
			if (c & 1) ok = true;
		} else {
			if (c % 2 == 0) ok = true;
		}
		if (ok){
			ans.push_back(z);
			num[z]++;
		}
	}
	if (ans.size() == 0) { cout << 0 << endl;}
	else {
		cout << ans.size() << endl;
		for (ll i : ans){
			cout << i << " ";
		} cout << endl;
	}
}

Measured memory_bytes: 5108
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    int n, m, tmp1, tmp2;
    cin >> n >> m;
    vector<int> ans(n);
    rep(i,m) {
        cin >> tmp1 >> tmp2;
        ++ans[tmp1 - 1];
        ++ans[tmp2 - 1];
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3504
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
N=INT()
S=input()
if N<3:
  print(0)
  exit()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*g*b
for i in range(N-2):
  for j in range(i+1,N-1):
    k=j*2-i
    if k>=N:
      continue
    if S[j]!=S[i] and S[k]!=S[i] and S[j]!=S[k]:
      ans-=1
print(ans)

Measured memory_bytes: 9424
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	string s;
	cin >> s;
	(s[0] == s[2])? Yes : No;

	return  0;
}

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

#define D_MAX 30

class People {
public:
    string name;
    vector<int> d;
    int score;
};

int main() {
    while(true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<People> peoples(n);
        for (int i = 0; i < n; i++) {
            int m;
            cin >> peoples[i].name >> m;
            for (int j = 0; j < m; j++) {
                int temp;
                cin >> temp;
                peoples[i].d.push_back(temp);
            }
            peoples[i].score = 0;
        }
        for (int i = 0; i < D_MAX; i++) {
            vector<int> displays;
            for (int j = 0; j < n; j++) {
                if (find(peoples[j].d.begin(), peoples[j].d.end(), i) != peoples[j].d.end()) {
                    displays.push_back(j);
                }
            }
            for (vector<int>::iterator it = displays.begin(); it != displays.end(); it++) {
                peoples[*it].score += n + 1 - displays.size();
            }
        }
        int result_i = 0;
        for (int i = 1; i < n; i++) {
            if (peoples[i].score < peoples[result_i].score
                || (peoples[i].score == peoples[result_i].score && peoples[i].name < peoples[result_i].name)) {
                result_i = i;
            }
        }
        cout << peoples[result_i].score << " " << peoples[result_i].name << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> cnt(1000100,0);
    for(auto u : v){
        if(cnt[u] != 0){
            cnt[u] = 2;
            continue;
        }
        for(int i = u; i < 1000100; i += u){
            cnt[i]++;
        }
    }
    int ans = 0;
    for(auto u : v){
        if(cnt[u] > 1) ans ++;
    }
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 8004
#include <cstdio>

int main()
{
  char s[101];
  long long k;
  scanf("%s %lld", s, &k);
  long long l = 0;
  char *p;
  for (p = s; *p; ++p)
  {
    if (*p != '1')
    {
      l = p - s + 1;
      break;
    }
  }
  if (k < l || *p == 0)
  {
    puts("1");
    return 0;
  }
  printf("%c\n", *p);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int A,B;
  1<=A<=20;
   1<=B<=20;
  cin>>A>>B;
  if(A<=9 && B<=9 ){
     cout<<A*B<<endl;
    }
  else{
    cout<<"-1"<<endl;
     }
}

Measured memory_bytes: 256