akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll M,D;
    cin >> M >> D;
    ll ans=0;
    for(int i=1;i<=M;i++){
        for(int j=10;j<=D;j++){
            ll j1 = j%10;
            ll j2 = j/10;
            if(j1>=2 && j2>=2 && j1*j2 == i) {
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 3e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, sz, col[222], cnt[7], ans, d[222];
bool us[N];
vector <int> g[222];
inline void dfs(int v, int t) {
    col[v] = t;
    for (int to : g[v]) {
        if (!col[to]) {
            dfs(to, 3 - t);
        } else {
            if (col[v] == col[to]) {
                cout << -1;
                exit(0);
            }
        }
    }
}
inline void bfs(int v) {
    queue <int> q;
    fo(i, 1, n, 1) us[i] = 0, d[i] = INF2;
    d[v] = 0;
    q.push(v);
    us[v] = 1;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        chmax(ans, d[v] + 1);
        for (int to : g[v]) {
            if (us[to]) continue;
            if (d[to] > d[v] + 1) {
                d[to] = d[v] + 1;
                us[to] = 1;
                q.push(to);
            }
        }
    }
}
main() {
    file("censor");
    ios;
    cin >> n;
    fo(i, 1, n, 1) fo(j, 1, n, 1) {
        char d;
        cin >> d;
        if (d == '1') {
            g[i].eb(j);
        }
    }
    dfs(1, 1);
    fo(i, 1, n, 1) bfs(i);
    cout << ans;
    return 0;
}
/**

*/


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		int n=scan.nextInt();
		int a[]=setArray(n);
		int b[]=setArray(n);
		int c[]=setArray(n-1);
		int sum=b[a[0]-1];
		for(int i=1;i<n;i++) {
			if(a[i]==a[i-1]+1) {
				sum+=c[a[i]-2];
			}
			sum+=b[a[i]-1];
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 24276
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = [[0] * W for _ in range(H)]
flg = 0
i = 0
for h in range(H):
    flg ^= 1
    if flg:
        w_list = list(range(W))
    else:
        w_list = reversed(list(range(W)))
    for w in w_list:
        if A[i]:
            ans[h][w] = i+1
            A[i] -= 1
        else:
            i += 1
            ans[h][w] = i+1
            A[i] -= 1
for h in range(H):
    print(*ans[h])


Measured memory_bytes: 42608
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,i,ans,cnt=0;
  cin>>n;
  vector<int64_t> a(n);
  for(i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(n==2) cout<<a.at(0)<<endl;
  else{
    ans=a.at(0);
    cnt+=2;
    for(i=1;i<n;i++){
      ans+=2*a.at(i);
      cnt+=2;
      if(cnt>=n){
        if(cnt>n) ans-=a.at(i);
        break;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 4816
#include <stdio.h>

#include <string.h>

#include <stack>

#include <iostream>


using namespace std;

int main(){
    
    int input;
    stack<int> train;
    while (scanf("%d",&input)!=EOF) {
//        scanf("%d",&input);
        if (input!=0)train.push(input);
        else {
            printf("%d\n",train.top());
            train.pop();
        }
    }
}
    //        if(strcmp(c,pu) == 0){
    //
    //            scanf("%s",&color);
    //
    //            st.push(color);
    //
    //        }
    //
    //        if(strcmp(c,po) == 0){
    //
    //            cout<<st.top()<<endl;
    //
    //            st.pop();
    //
    //        }
    //
    //        if(strcmp(c,qu) == 0){
    //
    //            return 0;
    //
    //        }
    //
    //    }
    
    //}

Measured memory_bytes: 1192
import sys
input = sys.stdin.readline
N,x = map(int,input().split())
A = list(map(int,input().split()))

class SegmentTree:
    def __init__(self,data,op,default):
        N = len(data)
        self.N = N
        self.op = op
        self.default = default
        self.l = 2**((N-1).bit_length())
        self.data = [default]*self.l + data + [default]*(self.l-N)
        for i in range(self.l-1,0,-1):
            self.data[i] = op(self.data[2*i], self.data[2*i+1])

    def get_data(self, i=None):
        if i is None:
            return self.data[self.l:self.l + self.N]
        else:
            return self.data[self.l+i]

    def set(self,i,val):
        i += self.l
        self.data[i] = val
        i = i//2
        while i > 0:
            self.data[i] = self.op(self.data[2*i], self.data[2*i+1])
            i = i//2

    def get(self,i,j):
        i += self.l
        j += self.l
        s = self.default 
        while j-i > 0:
            if i & 1:
                s = self.op(s,self.data[i])
                i += 1
            if j & 1:
                s = self.op(s,self.data[j-1])
                j -= 1
            i, j = i//2, j//2
        return s


A2 = A+A
inf = 10**15
cand = []
seg = SegmentTree(A2,min,inf)
for i in range(N):
    temp = i*x
    for j in range(N):
        temp += seg.get(N+j-i,N+j+1)
    cand.append(temp)
print(min(cand))


Measured memory_bytes: 74572
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int n , k;
int h[305];
ll dp[305][305][305];
const int INF = 1000 * 1000 * 1000;
int main() {
    cin >> n >> k;
    vector<int> choises;
    choises.pb(0);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
        choises.pb(h[i]);
    }
    sort(choises.begin() , choises.end());
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            for(int k = 0; k <= n; k++)
                dp[i][j][k] = INF * (ll)INF;
    dp[0][0][0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            ll mn = INF * (ll)INF;
            for(int next = 0; next <= n; next++)
            {
                mn = min(mn , dp[i][j][next] - choises[next]);
                dp[i + 1][j + (h[i] != choises[next])][next] = min(dp[i + 1][j + (h[i] != choises[next])][next] , mn + choises[next]);     
            }
            mn = INF * (ll)INF;
            for(int next = n; next >= 0; next--)
            {
                mn = min(mn , dp[i][j][next]);
                dp[i + 1][j + (h[i] != choises[next])][next] = min(dp[i + 1][j + (h[i] != choises[next])][next] , mn);     
            }
        }
    }
    ll ans = INF * (ll)INF;
    for(int j = 0; j <= k; j++)
        for(int l = 0; l <= n; l++)
            ans = min(ans , dp[n][j][l]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 219392
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const int mod = 1000000007;

LL gcd(LL x, LL y) {
	return y ? gcd(y, x%y) : x;
}

LL p2[200123]{1};

int main()
{
	Rep(i, 200000) {
		p2[i] = p2[i-1] * 2;
		if(p2[i] >= mod) p2[i] -= mod;
	}
	int n, sum = 0;
	cin >> n;
	map<pair<LL, LL>, int> p, q;
	LL x, y;
	rep(i, n) {
		scanf("%lld%lld", &x, &y);
		if(x == 0 && y == 0) continue;
		LL t = gcd(x, y);
		x /= t; y /= t;
		if(y < 0) x = -x, y = -y;
		if(x == 1 && y == 0) x = -1;
		if(x >= 0) ++q[{x, y}];
		else ++p[{y, -x}];
		++sum;
	}
	LL ans = 1, z = n - sum;
	for(auto& kv: p) {
		auto it = q.find(kv.first);
		if(it == q.end()) continue;
		sum -= it->second + kv.second;
		ans = ans * (p2[it->second] + p2[kv.second] - 1) % mod;
	}
	ans = ans * p2[sum] % mod;
	--ans;
	ans += z;
	if(ans < 0) ans += mod;
	if(ans >= mod) ans -= mod;
	cout << ans << endl;
	return 0;
}


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

int main()
{
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1 == m2)
  {
    cout << 0;
  }
  else
  {
    cout << 1;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

using P = pair<ll, ll>;

int main(void){
  ll H, W, M;
  cin >> H >> W >> M;
  vector<ll> h(M), w(M);
  map<P, ll> mp;
  REP(i, M){
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    mp[P(h[i], w[i])]++;
  }
  vector<ll> a(H, 0), b(W, 0);
  REP(i, M) a[h[i]]++, b[w[i]]++;

  ll c = *max_element(ALL(a));
  ll d = *max_element(ALL(b));
  vector<ll> p, q;
  REP(i, H) if(a[i] == c) p.emplace_back(i);
  REP(i, W) if(b[i] == d) q.emplace_back(i);
  
  ll n = p.size(), m = q.size();
  ll ans = c+d-1;
  REP(i, n) REP(j, m){
    mp[P(p[i], q[j])];
    if(!mp[P(p[i], q[j])]){
      ans = c+d;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 54816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll tmp = x / d;
    if (tmp >= k)
    {
        cout << x - (k * d) << endl;
        return 0;
    }
    else
    {
        x = x % d;
        k -= tmp;
        if (k % 2 == 0)
        {
            cout << x << endl;
            return 0;
        }
        else
        {
            cout << d - x << endl;
            return 0;
        }
    }
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_147
{
    class F
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] nxd = ReadLongs();
            long n = nxd[0];
            long x = nxd[1];
            long d = nxd[2];
            if (d == 0)
            {
                if (x == 0)
                {
                    WriteLine(1);
                }
                else
                {
                    WriteLine(n + 1);
                }
                return;
            }
            if (d < 0)
            {
                x *= -1;
                d *= -1;
            }
            long baseVal = long.MinValue / 10;
            long[][] ranges = new long[n+1][];
            long minVal = 0;
            long maxVal = 0;
            for(int i = 0; i <= n; i++)
            {
                long fixVal = x * i - baseVal;
                long margin = fixVal % d;
                long min = minVal + fixVal / d;
                long max = maxVal + fixVal / d;
                ranges[i] = new long[3] { margin, min, max };
                minVal += i;
                maxVal += n - i - 1;
            }
            ranges = ranges.OrderBy(a => a[1]).OrderBy(a => a[0]).ToArray();
            long res = 0;
            long prev = -1;
            long prevRight = 0;
            for(int i = 0; i <= n; i++)
            {
                if (ranges[i][0] != prev) prevRight = -1;
                prev = ranges[i][0];
                if (prevRight < ranges[i][1])
                {
                    res += ranges[i][2] - ranges[i][1] + 1;
                    prevRight = ranges[i][2];
                }
                else if(prevRight<ranges[i][2])
                {
                    res += ranges[i][2] - prevRight;
                    prevRight = ranges[i][2];
                }
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 41696
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Miguel Mini
 */

#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define set_to(x, v) fill(all(x), v)
#define eb emplace_back
#define lso(x) ((x)&-(x))
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
vi g[maxn];

int add(int a, int b) {
    return a + b < mod ? a + b : a + b - mod;
}

int mul(ll a, ll b) {
    return a * b % mod;
}

int ex(int a, int b) {
    int r = 1;
    while (b > 0) {
        if (b & 1) r = mul(r, a);
        a = mul(a, a);
        b >>= 1;
    }
    return r;
}

int sz[maxn];
int inv2 = (mod + 1) / 2;
int dp[maxn];
void dfs(int x, int p) {
    sz[x] = 1;
    for (int v : g[x]) {
        if (v == p) continue;
        dfs(v, x);
        sz[x] += sz[v];
    }
    dp[x] = ex(inv2, sz[x]);
    for (int v : g[x]) {
        if (v == p) continue;
        dp[x] = add(dp[x], mul(ex(inv2, sz[x] - sz[v]), add(1, mod - ex(inv2, sz[v]))));
    }
}

void dfs_reroot(int x, int p) {
    if (p != 0) {
        dp[x] = mul(dp[x], ex(inv2, sz[p] - sz[x]));
        dp[x] = add(dp[x], mul(ex(inv2, sz[x]), add(1, mod - ex(inv2, sz[p] - sz[x]))));
        sz[x] = sz[p];
    }
    for (int v : g[x]) {
        if (v == p) continue;
        dfs_reroot(v, x);
    }
}

class FSurroundedNodes {
public:

    void solveOne(istream& in, ostream& out) {
        int n;
        in >> n;
        re(i, 1, n+1) {
            g[i].clear();
        }
        re(i, 1, n) {
            int a, b;
            in >> a >> b;
            g[a].eb(b);
            g[b].eb(a);
        }
        dfs(1, 0);
        dfs_reroot(1, 0);
        int res = 0;
        re(i, 1, n+1) {
            res = add(res, add(inv2, mod - dp[i]));
        }
        out << res << endl;
    }

    void solve(istream& in, ostream& out) {
        int testNumber = 1;
        //in >> testNumber;
        re(tc, 1, testNumber+1) {
            //out << "Case #" << tc << ": ";
            solveOne(in, out);
        }
    }
};


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	FSurroundedNodes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 23936
#include <stdio.h>
typedef struct{
    int midterm;
    int final;
    int make_up;
}student;
int main(void){
    student exam;
    while(1){
        scanf("%d %d %d", &exam.midterm, &exam.final, &exam.make_up);
        if(exam.midterm == -1 && exam.final == -1 && exam.make_up == -1){
            break;
        }else if(exam.midterm == -1 || exam.final == -1 || exam.midterm+exam.final < 30){
            printf("F\n");
        }else if(exam.midterm+exam.final >= 80){
            printf("A\n");
        }else if(exam.midterm+exam.final >= 65){
            printf("B\n");
        }else if(exam.midterm+exam.final >= 50 || (exam.midterm+exam.final >= 30 && exam.make_up >= 50)){
            printf("C\n");
        }else{
            printf("D\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2092
<?php
list($x,$n)=explode(" ",trim(fgets(STDIN)));
if($n==0){
  echo $x;
  exit;
}
$p=explode(" ",trim(fgets(STDIN)));
$i=0;
while(1){
  if(!in_array($x-$i,$p)){
    echo $x-$i;
    exit;
  }
  if(!in_array($x+$i,$p)){
    echo $x+$i;
    exit;
  }
  ++$i;
}

Measured memory_bytes: 16232
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
int main() {

    int n=3;
    string a;
    cin >> a;

    //n個についてbit全探索
    //t[i]をtrue,falseで判断
    int ans=0;
    vector<int> t(n);
    for(int bit=0; bit <(1<<n); ++bit) {
        for(int i=0;i<n;i++) {
            if(bit & (1<<i))    t[i]=true;
            else    t[i]=false;
        }
        //ここから処理を書く
        int ans=(a[0]-'0');
        rep(i,n) {
            if(t[i])    ans+=(a[i+1]-'0');
            else    ans-=(a[i+1]-'0');
        }
        if(ans==7) {
            rep(i,n) {
                cout<<a[i];
                if(t[i])    cout<<'+';
                else    cout<<'-';
                if(i==n-1)  cout<<a[i+1]<<"=7";
            }
            return 0;
        }
    }
 
 return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

LL INF = 1 << 30;  // (2^10)^3 > 10^9

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

LL merge(int* A, int left, int mid, int right) {
    LL cnt = 0;

    int n1 = mid - left, n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];

    REP(i, n1) L[i] = A[left + i];
    REP(i, n2) R[i] = A[mid + i];

    L[n1] = INF; R[n2] = INF; // sentinel

    int i = 0, j = 0;

    FOR(k, left, right) {
        if(L[i] < R[j]) {
            A[k] = L[i];
            ++i;
        } else {
            A[k] = R[j];
            ++j;
            cnt += (n1 - i);
        }
    }

    return cnt;
}

LL mergeSort(int* A, int left, int right) {
    LL cnt = 0;

    if ((left + 1) < right) {
        int mid = (right + left) / 2;
        cnt += mergeSort(A, left, mid);
        cnt += mergeSort(A, mid, right);
        cnt += merge(A, left, mid, right);
    }

    return cnt;
}

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

    int n;
    cin >> n;

    int S[n];
    REP(i, n) cin >> S[i];

    LL num_inv = mergeSort(S, 0, n);

    cout << num_inv << endl;

}



Measured memory_bytes: 4720
object Main extends App {
  val n =  scala.io.StdIn.readInt()
  var xy = Vector.empty[Seq[Int]]
  for(i<-1 to n) {
    val xyInput = scala.io.StdIn.readLine()
    xy :+= xyInput.split(" ").map(_.toInt).toSeq
  }
  val xyPattern = xy.permutations
  var sum = 0d
  xyPattern.foreach { xyList =>
    for(i<-1 to n - 1) {
      val beforeX = xyList(i - 1)(0)
      val beforeY = xyList(i - 1)(1)
      val afterX = xyList(i)(0)
      val afterY = xyList(i)(1)
      sum += math.sqrt(math.pow(beforeX - afterX, 2) + math.pow(beforeY - afterY, 2))
    }
  }
  println(sum / xy.permutations.length)
}

Measured memory_bytes: 42688
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
stack<int> q;
int l[N],r[N];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",&arr[i]);
	}
	for(int i=0;i<=n+1;i++){
		l[i]=1;r[i]=n;
	}
	while(!q.empty()) q.pop();
	for(int i=1;i<=n;i++){
		while(!q.empty()&&arr[q.top()]>arr[i]) q.pop();
		if(!q.empty()) l[i]=q.top()+1;else l[i]=1;
		q.push(i);
	}
	
	while(!q.empty()) q.pop();
	for(int i=n;i>=1;i--){
		while(!q.empty()&&arr[q.top()]>arr[i]) q.pop();
		if(!q.empty()) r[i]=q.top()-1;
		q.push(i);
	}
	/*
	for(int i=1;i<=n;i++) cout<<l[i]<<" ";
	cout<<'\n';
	for(int i=1;i<=n;i++) cout<<r[i]<<" ";
	cout<<'\n';
	*/
	int ans=0;
 	for(int i=1;i<=n;i++) ans+=arr[i]*((i-l[i]+1)*(r[i]-i+1));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

vector<string> memo;

int main(void) {
    string s;
    int K;
    cin >> s >> K;

//    vector<string> memo;
    int cnt = 0;


    for (int i = 0; i < 26; ++i) {
        char search = char('a' + i);
        for (int j = 0; j < s.length(); ++j) {
            if (s[j] == search) {
                for (int k = 1; k <= 5, s.length() - j; ++k) {
                    string sub = s.substr(j, k);
                    memo.push_back(sub);
//                    cnt++;
//                    if (cnt > 100) break;
                    if (k == 5) break;
                }
            }
//            if (cnt > 500) break;
        }
//        if (cnt >= 4) break;
    }
//    for (int i = 0; i < memo.size(); ++i) {
//        cout << memo[i] << endl;
//    }


    sort(memo.begin(), memo.end());
//    cout << "sorted" << endl;
//    for (int i = 0; i < memo.size(); ++i) {
//        cout << memo[i] << endl;
//    }

    unique(memo.begin(), memo.end());
//    cout << "uniqued" << endl;
//    for (int i = 0; i < memo.size(); ++i) {
//        cout << memo[i] << endl;
//    }

    cout << memo[K - 1] << endl;

//    cout << memo[K] << endl;
//    string ans;
//    if (K == memo.size()) {
//        ans = memo[K - 1];
//    } else {
//        cnt = 0;
//        for (int i = 1; i < memo.size(); ++i) {
//            if (memo[i - 1] != memo[i]) {
//                cnt++;
//                if (cnt == K) {
//                    ans = memo[i - 1];
//                    break;
//                }
//            }
//        }
//    }
//
//    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
 int A,B,ans;
  cin >> A;
  cin >> B;
  if (A<=5){
    ans = 0;
  } else if(A<=12) {
  	ans = B/2;
  } else {
   ans = B; 
  }
  cout  << ans << endl;
    return 0; 
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int n;
    if(b / 10 == 0){
        a = a * 10;
    }else if(b / 100 == 0){
        a = a * 100;
    }else{
        a = a * 1000;
    }
    n = a + b;
    for(int i=0; i!=100000; i++){
        if(n == i * i){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N =int(input())

facters = {}

for i in range(1, N+1):
  # 約数を求める
  arr = factorization(i)
  for key,value in arr:
    if key in facters:
      facters[key] += value
    else:
      facters[key] = value

ans = 1

facters.pop(1)

for value in facters.values():
  ans *= value + 1 
  ans = ans % (10**9 + 7)
print(ans)

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

using namespace std;

int main(){
  long long n,m;
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    long long z;cin >> z;
    n -= z;
  }
  if(n < 0) cout << -1;
  else cout << n;
}

Measured memory_bytes: 3624
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if(!(i & 1)) cout << s[i];
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define ld double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)
#define DOW(i, n) for(int i = n - 1; 0 <= i; --i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);


using namespace std;

const int nax = 4e5 + 111;

int n;
pair<int, int> t[nax];
vector <int> vec;
int pref[nax];

map <int, int> mapa;

int main() {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &t[i].fi, &t[i].se);
		mapa[t[i].fi] = t[i].se;
	}
	sort(t + 1, t + n + 1);
	for (int i = 1; i <= n; ++i) {
		vec.pb(t[i].fi);
		vec.pb(t[i].fi + t[i].se);
		if(t[i].fi - t[i].se >= 0) vec.pb(t[i].fi - t[i].se);
	}
	
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	for(int i = 0; i < ss(vec); ++i) {
		if(i) pref[i] = max(pref[i], pref[i - 1]);
		if(mapa.find(vec[i]) == mapa.end()) continue;
		int x = vec[i];
		int l = mapa[x];
		int prawo = (int) (lower_bound(vec.begin(), vec.end(), x + l) - vec.begin());
		int lewo = (int) (upper_bound(vec.begin(), vec.end(), x - l) - vec.begin()) - 1;
		int ja = 1;
		if(lewo >= 0) ja += pref[lewo];
	//	cout << x << ""  << ja << " " << lewo << " " << prawo << " " << i << endl;
		pref[prawo] = max(pref[prawo], ja);
	}
	printf("%d", pref[ss(vec) - 1]);
	
	
	return 0;
}


Measured memory_bytes: 9968
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#ifdef ONLINE_JUDGE
#define getchar gc
inline char gc(){
	static char buf[1<<16],*p1=buf,*p2=buf;
	if(p1==p2){
		p2=(p1=buf)+fread(buf,1,1<<16,stdin);
		if(p2==p1) return EOF;
	}
	return *p1++;
}
#endif
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=2e5+5;
long long ans;
int n,a[N],cnt[N];

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=n;i;i--){
		if(a[i]+i<=n) ans+=cnt[a[i]+i];
		if(i>=a[i]) cnt[i-a[i]]++;
	}
	write(ans);
}

Measured memory_bytes: 5176
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        long a = in.nextLong();
        long b = Math.round(in.nextDouble() * 100);
      
        /*
            Directly multiply float and int could result in precision errors.
            First convert float to int and calculate the result. Then if needed it could
            be converted back to float.
            All multiply float by 100 could not work as expected. for example,
            9.79 * 100 = 978. To handle such cases use Math.round which rounds the value to 
            nearest integer.
        */
        
        long ans = (a * b) / 100;
        println(ans); 
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static String[] readString(int N) throws IOException { 
    	String arr[] = new String[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void debug(Object ... O) { 
    	for(Object obj: O){
    		System.out.print(obj + " ");
    	}
    	System.out.println();
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 25524
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL<<60;

int main(){
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];
    vector<vector<ll>> dp(N+1,vector<ll>(H+1,INF));
    dp[0][0] = 0;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=H;j++){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][min(j+A[i],H)],dp[i+1][j]+B[i]);
        }
    }
    ll ans = INF;
    /*for(ll i=0;i<=N;i++){
        chmin(ans,dp[i][H]);
    }*/
    cout << dp[N][H] << endl;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------
int main(void) {
  int n;
  cin >> n;

  prt(0);
  string s;
  cin >> s;
  if(s=="Vacant") return 0;

  int r=n, l=0;

  while(r-l>1){
    int mid = (r+l)/2;
    string tmp;
    prt(mid);
    cin >> tmp;
    if(tmp=="Vacant") return 0;
    if(mid%2^s==tmp) l=mid;
    else r=mid;
  }
}


Measured memory_bytes: 3832
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

ll n, memo[128][32];

ll rec(vint& v, int p, int a)
{
	if(a < 0 || 20 < a) return 0;
	
	if(p == n - 1) return a == v[p];
	if(0 <= memo[p][a]) return memo[p][a];
	
	return memo[p][a] = rec(v, p + 1, a + v[p]) + rec(v, p + 1, a - v[p]);
}

int main()
{
    while(cin >> n && n)
	{
		memset(memo, -1, sizeof(memo));
		vint v(n);
		
		rep(i, n) cin >> v[i];
		
		cout << rec(v, 1, v[0]) << endl;
	}
}

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

int main() {
  #define int long long
  string s;
  cin >> s;
  int n = s.size() - 1;
  int res = 0;
  
  for (int bit = 0; bit < (1<<n); bit++) {
    int t = s.at(0) - '0';
    for (int i = 0; i < n; i++) {
      if ((1<<i) & bit) {
        res += t;
        t = s.at(i + 1) - '0';
      }
      else {
        t *= 10;
        t += s.at(i + 1) - '0';
      }
    }
    res += t;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N_MAX = 50;
int main()
{
  int n,m=0,mm,t=0,b=-1,i,j,res=0;
  int d[N_MAX];
  bool h[24],h0[24];
  vector<int> v;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> d[i];
  sort(d,d+n);
  fill(h0,h0+24,0);
  h0[0]=1;
  for(i=0;i<n;i++){
    if(d[i]==b){
      t++;
    }else{
      b=d[i];
      t=1;
    }
    if(b==0 || b==12){
      if(b==0 || t>=2){
        cout << "0" << endl;
        return 0;
      }
      h0[b]=1;
    }else if(t==1){
      v.push_back(b);
    }else if(t==2){
      v.pop_back();
      h0[b]=1;
      h0[24-b]=1;
    }else if(t>=3){
      cout << "0" << endl;
      return 0;
    }
  }
  m=v.size();
  mm=1<<m;
  for(i=0;i<mm;i++){
    t=i;
    copy(h0,h0+24,h);
    for(j=0;j<m;j++){
      if(t%2==1){
        h[v[j]]=1;
      }else{
        h[24-v[j]]=1;
      }
      t>>=1;
    }
    b=0;
    t=24;
    for(j=1;j<24;j++)
      if(h[j]==1){
        t=min({j-b,b+24-j,t});
        b=j;
      }
    t=min({j-b,b+24-j,t});
    res=max(res,t);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long int ll;


int main()
{
	int n,m;
	cin>>n>>m;
	stack<int> *toList = new stack<int>[n];
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		toList[a].push(b);
	}
	bool ans = false;
	while( toList[0].empty() != true){
		int firstIsle = toList[0].top();
		toList[0].pop();
		while(toList[firstIsle].empty() != true){
			int secondIsle = toList[firstIsle].top();
			toList[firstIsle].pop();
			if(secondIsle == n-1){
				ans = true;
				break;
			}
		}
	}
	if( ans == true){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}



Measured memory_bytes: 135040
#include<stdio.h>
#include<string.h>

int main(void){
  char S[50];
  char T[50];
  
  int SLen;
  int TLen;
  int i,j;
  int isfit;
  int nofit;
  nofit = 1;

  scanf("%s", S);
  scanf("%s", T);
  
  SLen = strlen(S);
  TLen = strlen(T);
  

  for(i=(SLen-TLen); i>=0; i--){
    isfit = 1;

    for(j=0; j<TLen; j++){
      if((S[i+j] == T[j]) || (S[i+j]=='?')){
        continue;
      }else{
        isfit = 0;
      }
    }
    
    if(isfit==1){
      nofit=0;
      for(j=0; j<TLen; j++){
        S[i+j] = T[j];
      }
      break;
    }
  }

  
  if(nofit==1){
    printf("UNRESTORABLE\n");
  }else{
    for(j=0; j<SLen; j++){
      if(S[j]=='?'){
        S[j]='a';
      }
    }
    S[SLen]='\0';
    printf("%s\n", S);
  }
  

  return 0;
}


Measured memory_bytes: 128
H,W=map(int,input().split())
mat=[]
for i in range(H):
  line=list(map(int,input().split()))
  mat.append(line)
  
#print(mat)
oplist=[]
for i in range(H):
  for j in range(W):
    if mat[i][j]%2==1:
      if i==H-1 and j==W-1:
        break
      if j==W-1:
        mat[i][j]-=1
        mat[i+1][j]+=1
        oplist.append([i+1,j+1,i+2,j+1])
      else:
        mat[i][j]-=1
        mat[i][j+1]+=1
        oplist.append([i+1,j+1,i+1,j+2])
        
print(len(oplist))
for op in oplist:
  op_str=map(str,op)
  print(" ".join(op_str))

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

typedef long long ll;
typedef pair<ll, ll> P;

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    string s,t; cin >> s >> t;
    int ans = inf;
    for(int i = 0; i < s.size()-t.size()+1;i++){
        int cnt = 0;
        for(int j = 0; j < t.size(); j++){
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

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

int main(){
    char c[2][3];
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++)cin >> c[i][j];
    }

    if(c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0])cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
import collections

lis = collections.Counter(a)
ans = 0
memo = 0
#print(lis)

for i in range(10**5):
    memo = lis[i-1] + lis[i] + lis[i+1]
    #print(lis[i-1], lis[i], lis[i+1])
    if memo > ans:
        ans = memo


print(ans)





Measured memory_bytes: 20792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long mult_mod(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, p; cin >> a >> p;
  	
  	cout << (p + a * 3) / 2;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
MOD = 10**9 + 7
def extgcd(a, b):
    r = np.array([1,0,a], dtype=int)
    w = np.array([0,1,b], dtype=int)
    while w[2] != 1:
        q = r[2] // w[2]
        r, w = w, r - q*w
    return w[:2]

def mod_inverse(a, m):
    x, y = extgcd(a, m)
    return (m + x % m) % m

def solve(x, y):
    a = -y + 2*x
    b = 2*y - x
    if (a < 0) or (b < 0):
        return 0
    if a % 3 + b % 3 != 0:
        return 0
    a //= 3
    b //= 3
    n, k = a+b, a
    p, q = 1, 1
    for i in range(k):
        p = p * (n-i) % MOD
        q = q * (i+1) % MOD
    return (p * mod_inverse(q, MOD)) % MOD

x, y = map(int, input().split())
print(solve(x, y))

Measured memory_bytes: 12516
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int a, b;
    io.read(a, b);
    string ans = "Odd";
    if(a * b % 2 == 0) ans = "Even";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define N 36

typedef struct pp{
  char name;
  int value;
}CARD;


int n;
CARD data[N],data1[N];


void BubbleSort(CARD* ,int);
void SelectionSort(CARD* ,int);
int isStable(CARD*,CARD*,int);


int main(){
  int i,j,m;
  char t;

  scanf("%d",&n);

  scanf(" %c",&data[0].name);
  scanf("%d",&data[0].value);
  data1[0]=data[0];
  for(j=1;j<n;j++){
    scanf(" %c",&data[j].name);
    scanf("%d",&data[j].value);
    data1[j]=data[j];
  }

  
  BubbleSort(data,n);

  SelectionSort(data1,n);

  m=isStable(data,data1,n);

  printf("%c%d",data[0].name,data[0].value);
  for(j=1;j<n;j++) printf(" %c%d",data[j].name,data[j].value);
  printf("\nStable\n");

  printf("%c%d",data1[0].name,data1[0].value);
  for(j=1;j<n;j++) printf(" %c%d",data1[j].name,data1[j].value);
  if(m==0) printf("\nNot stable\n");
  else printf("\nStable\n");

  return 0;
  
  
}

void BubbleSort(CARD *B,int n){
  int i,j;
  CARD temp;
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(B[j].value<B[j-1].value){
	temp=B[j];
	B[j]=B[j-1];
	B[j-1]=temp;
      }
    }
  }

  return;
}

void SelectionSort(CARD *S,int n){
  int i,j,min;
  CARD temp;

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(S[j].value<S[min].value) min=j;
    }
    temp=S[i];
    S[i]=S[min];
    S[min]=temp;
  }

  return;
}

int isStable(CARD *in,CARD *out,int n){
  int i,j,a=0,b=0;

  for(i=0;i<n;i++){
    if(strcmp(&in[i].name,&out[i].name)==0) a++;
  }
  for(i=0;i<n;i++){
    if(in[i].value==out[i].value) b++;
  }
  

  if(a==b) return 1;

  else return 0;
}



Measured memory_bytes: 2820