akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 
#endif

#define df(b, e) ((b) > (e))
#define fore(i, b, e) for (auto i = (b) - df(b, e); i != e - df(b, e); i += 1 - 2 * df(b, e))
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second
#define pb push_back

using lli = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5, mod = 1e9 + 7;

template <int mod>
struct Modular {
  int v;
  Modular(lli x = 0) : v(-mod < x && x < mod ? x : x % mod) {
    if (v < 0) v += mod;
    if (v >= mod) v -= mod;
  }

  Modular operator + (const Modular &m) const { return Modular(v + m.v); }
  Modular operator - (const Modular &m) const { return Modular(v - m.v + mod); }
  Modular operator * (const Modular &m) const { return Modular(1LL * v * m.v); }
  Modular inv() const { return Modular(minv(v, mod)); } 
  Modular operator -() const { return Modular(-v); }
  
  Modular& operator += (const Modular &m) { return *this = *this + m; }
  Modular& operator -= (const Modular &m) { return *this = *this - m; }
  Modular& operator *= (const Modular &m) { return *this = *this * m; }
  
  friend ostream & operator << (ostream &os, const Modular &m) { return os << m.v; }
  friend istream & operator >> (istream &is, Modular &m) { return is >> m.v; }
  
private:
  static int minv(int a, int m) {
    a %= m;
    assert(a);
    return a == 1 ? 1 : int(m - lli(minv(m, a)) * lli(m) / a);
  }
};

using mint = Modular<mod>;

mint ans[N], fac[N];
vi graph[N];
int tot[N];
int n;

void dfs1(int u, int p) {
  tot[u] = 1;
  for (int v : graph[u])  {
    if (v == p)   
      continue;
    dfs1(v, u);
    tot[u] += tot[v];
  }
}

void dfs2(int u, int p, mint cur) {
  ans[u] = cur;
  for (int v : graph[u]) {
    if (v == p)
      continue;
    dfs2(v, u, cur * tot[v] * mint(n - tot[v]).inv());
  } 
}

int main() {
  cin.tie(0)->sync_with_stdio(0), cout.tie(0);

  cin >> n;
  fore (i, 0, n - 1) {
    int u, v;
    cin >> u >> v;
    graph[u].pb(v);
    graph[v].pb(u);
  }

  fac[0] = 1;
  fore (i, 1, n + 1)
    fac[i] = fac[i - 1] * i;

  dfs1(1, 0);
  mint cur = fac[n] * accumulate(tot + 1, tot + n + 1, mint(1), [&](mint x, mint y) {
    return x * y;
  }).inv();
  debug(cur);
  dfs2(1, 0, cur);

  fore (u, 1, n + 1)
    cout << ans[u] << '\n';
  
  return 0;
}


Measured memory_bytes: 17840
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w;
char s[500][500];
ll x[800005],y[800005],z[900005];
ll dp[500][500];

int main(){	
	cin>>h>>w>>n;
	for(i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	map<P,ll> cnt; 
	for(i=0;i<n;i++){
		for(j=-1;j<=1;j++){
			for(k=-1;k<=1;k++){
				if(x[i]+j <2 || y[i]+k<2 || x[i]+j>=h || y[i]+k>=w)continue;
				cnt[P(x[i]+j,y[i]+k)]++;
			}
		}
	}
	z[0] = (h-2) * (w-2);
	for(map<P,ll>::iterator a=cnt.begin();a!=cnt.end();a++){
		z[0]--;
		z[a->second]++;
	}
	for(i=0;i<10;i++){
		p(z[i]);
	}	
	return 0;
}

Measured memory_bytes: 66560
//Keep working hard :)
#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e5+5;
int a[N];

void fileIO()
{
        #ifndef ONLINE_JUDGE
        freopen("int.txt","r",stdin);
        freopen("out.txt","w",stdout);
        #endif
}
int main()
{
	IOS;
        //fileIO();
        int a,b;
        char c;
        cin >> a >> c  >> b;
        switch(c)
        {
                case '+':
                        cout << a+b;
                        exit(0);
                case '-':
                        cout << a-b;
                        exit(0);
        }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int i, j, H, W;
    while (1) {
    	cin >> H >> W;
        if(H == 0 && W == 0) {
        	break;
        }
        for (i = 1; i <= H; i++) {
            for (j = 1; j <= W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
	return 0;
}


Measured memory_bytes: 3060
def main():
    h, w = map(int,input().split())
    a = [list(input()) for _ in range(h)]
    cnt=0
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                cnt += 1
    if cnt == h+w-1:
        print('Possible')
    else:
        print('Impossible')

if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll n;
    ll a[100010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    priority_queue<ll> q;
    sort(a,a+n);
    for (int i = 0; i < n-1; i++) {
        if(a[i] == a[i+1]){
            q.push(a[i]);
            i++;
        }
    }
    ll c,d;
    if(!q.empty()){
        c = q.top();q.pop();
    }else{
        std::cout << 0 << std::endl;
        return 0;
    }
    
    if(!q.empty()){
        d = q.top();
    }else{
        std::cout << 0 << std::endl;
        return 0;
    }
    
    std::cout << c*d << std::endl;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();
        Tuple<int, int>[] nums = new Tuple<int, int>[n];
        for (int i = 0; i < n; i++)
        {
            nums[i] = Tuple.Create(sc.NextInt(), sc.NextInt());
        }

        nums = nums.OrderBy(num => num.Item1).ToArray();

        long answer = 0;
        for (int i = 0; i < n; i++)
        {
            var num = nums[i];
            k -= num.Item2;
            if (k <= 0)
            {
                answer = num.Item1;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 26564
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <fstream>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<int, ll> i_ll;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v; ll w; };

const int MOD = 1000000007;
const int _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	sort(a.begin(), a.end());
	vector<ll> sum(N + 1);
	rep(i, N) sum[i + 1] = sum[i] + a[i];
	int ma = 0;
	for (int i = 1; i <= N - 1; i++)
		if (sum[i] * 2 < a[i])
			ma = max(ma, i);
	cout << N - ma << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll k, ans = 0, t = 0;
  cin >> k;
  rep(i, 100000000) {
    t = t * 10 + 7;
    t %= k;
    ans++;
    if (t == 0) {
      cout << ans << endl;
      return 0;
    }
  }

  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Time()	cerr <<'\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define SZ(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,k,n) for(ll (i)=(k);(i)<(n);(i)++) 
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;



void solve(){
	int n;
	cin>>n;
	cout << (n+n*n+n*n*n);






}
int main() {
	FASTER;
	int T = 1;
	//cin >> T;		//cmt if one test case
	while(T--)solve();
}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


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

int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> A(n);
	int tmp;
	for(int i=0;i<n;i++){
		cin >> tmp;
		A[i] = make_pair(tmp,i+1);
	}
	
	sort(A.begin(),A.end());
	
	for(int i=0;i<n;i++){
		cout << A[i].second << " ";
		//cout << A[i].first << " " << A[i].second <<  endl;
	}
	cout << endl; 
	return 0;
}


Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

su = 0

for i in range(1, n):
    su ^= a[i]
    
ans = [su]

for i in range(n-1):
    su = su ^ a[i] ^ a[i+1]
    ans.append(su)
    
print(*ans)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}

int main(){
    int x,y;
    cin >> x >> y;
    int res=x+y+2;
    if(x<y)swap(x,y);
    int g=gcd(x,y);
    int a=x/g;
    int b=y/g;
    for(int i=0;i*a<x+1;i++){
        res--;
    }
    cout << res << endl;
}



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

int compare_int(const void *a, const void *b) {
  return *(int*)a - *(int*)b;
}


int main() {
  int n, count=0;
  cin >> n;
  int d[n];
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  qsort(d, n, sizeof(int), compare_int);
  cout << d[n/2] - d[n/2-1] << endl;
  return 0;
}


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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n, m;
	cin >> n >> m;
	vector<ii> ps;
	int a, b;
	loop(n) {
		cin >> a >> b;
		ps.emplace_back(a, b);
	}
	sort(iter(ps));
	int ans = 0;
	priority_queue<int> q;
	for (int i = 1, j = 0;i <= m and (j < n or !q.empty());i++) {
		while (j < n and ps[j].first <= i) q.push(ps[j].second), j++;
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1908
#include<stdio.h>
long long IN(void)
{
  long long x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
void sub(void)
{
  int N=IN(),S[200],sz=0;long long A[200],x,y[200];
  for(int i=0;i<N;i++){A[i]=IN();}
  for(int i=0;i<N;i++){S[i]=getchar()-'0';}
  for(int i=N-1;i>=0;i--)
  {
    x=A[i];
    if(sz){for(int j=0;j<sz;j++){x=(x<(x^y[j]))?x:x^y[j];}}
    if(x){if(S[i]){puts("1");return;}y[sz++]=x;}
  }
  puts("0");
}
signed main(void){int T=IN();while(T--){sub();}}

Measured memory_bytes: 1492
#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() {
  string s;
  cin >> s;
  rep(i,s.size()) {
    s[i] = 'x';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

ll retmax(ll mi, ll ma, ll len) {
	if (len == 0) return 0;
	int l = 1, r = len;
	
	while (r - l > 2) {
		ll x1 = l + (r - l) / 3;
		ll x2 = l + (2 * (r - l)) / 3;
		
		ll y1 = (mi + x1 - 1) * (ma - x1 + 1);
		ll y2 = (mi + x2 - 1) * (ma - x2 + 1);
		if (y1 > y2) r = x2;
		else l = x1;
	}
	
	ll res = (mi + l - 1) * (ma - l + 1);
	if (l + 2 == r) chmax(res, (mi + l) * (ma - l));
	chmax(res, (mi + r - 1) * (ma - r + 1));
	return res;
}

bool solve(ll x, ll A, ll B) {
	int pa = A, pb = x + 1 - B + 1;
	ll ma = 0;
	
	if (pa < pb) {
		chmax(ma, retmax(1,x + 1, pa - 1));
		chmax(ma, retmax(pa + 1, x - pa + 2, pb - pa));
		chmax(ma, retmax(pb + 1, x + 1 - pb, x + 1 - pb));
	}
	else if (pa > pb) {
		chmax(ma, retmax(1, x + 1, pb - 1));
		chmax(ma, retmax(pb, x + 1 - pb, pa - pb));
		chmax(ma, retmax(pa + 1, x + 1 - pa, x + 1 - pa));
	}
	else {
		chmax(ma, retmax(1, x + 1, pa - 1));
		chmax(ma, retmax(pa + 1, x + 1 - pa, x + 1 - pa));
	}
	
	return ma < A * B;
}

int main() {
	int Q; cin >> Q;
	while (Q--) {
		ll A, B; scanf("%lld %lld", &A, &B);
		
		ll l = 0, r = 1ll<<31;
		while (r - l > 1) {
			ll m = (l + r) / 2;
			if (solve(m, A, B)) l = m;
			else r = m;
		}
		cout << l << endl;
	}
	
	return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, y;
  cin >> n >> y;
  bool ans = false;
  int s, t, u;
  for(int i=0;i<=n;i++) {
    for(int j=0;j<=n-i;j++) {
      if(i*10000+j*5000+(n-i-j)*1000 == y) {
        ans = true;
        s = i;
        t = j;
        u = n - i - j;
      }
    }
  }
  if(ans)
    cout << s << " " << t << " " << u << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[][] sheet;
		
		while (n != 0) {
			sheet = new int[n + 1][n + 1];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					sheet[i][j] = scanner.nextInt();
				}
			}
			
			//sum
			for(int i = 0; i < n; i++) {
				sheet[i][n] = sum(i, n, sheet, true);
				sheet[n][i] = sum(i, n, sheet, false);
			}
			sheet[n][n] = sum(n, n, sheet, false);

			for(int i = 0; i <= n; i++) {
				for(int j = 0; j <= n; j++) {
					System.out.print(String.format("%1$5d", sheet[i][j]));
				}
				System.out.println();
			}

			n = scanner.nextInt();
		}
		scanner.close();
	}

	public static int sum(int num, int n, int[][] data, boolean isRow) {
		int ret = 0;
		if (isRow) {
			for(int i = 0; i < n; i++) {
				ret += data[num][i];
			}
		} else {
			for(int i = 0; i < n; i++) {
				ret += data[i][num];
			}
		}
		return ret;
	}
}

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

int main()
{
   int n;
   cin >> n;
   vector<int>a(n), b(n), c(n);
   rep(i,n) cin >> a[i] >> b[i] >> c[i];
   vvi table = {a,b,c};
   vvi dp(n+1,vector<int>(3,INF));
   rep(i,3) dp[0][i] = 0;

   for(int i =0; i < n; i++)
   {
      for(int j =0; j < 3; j++)
      {
         dp[i+1][j] = max(dp[i][(j+1)%3]+table[j][i],dp[i][(j+2)%3]+table[j][i]);
      }
   }
   int ans =0;
   rep(i,3) ans = max(ans, dp[n][i]);
   cout << ans << endl;
}


Measured memory_bytes: 8052
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        char c[]=sc.nextString().toCharArray();
      
        long d[][]=new long [c.length+1][13];
//        for (int i = 0; i < 13; i++) {
//			d[1][i]++;
//		}
        d[0][0]++;
        for (int i = 1; i <= c.length; i++) {
        	if(c[i-1]=='?') {
        		for (int t = 0; t < 13; t++) {
					for (int j = 0; j < 10; j++) {
						d[i][(10*t+j)%13]+=d[i-1][t];
						if(d[i][(10*t+j)%13]>mod)d[i][(10*t+j)%13]-=mod;
					}
				}
        	} else {
        		int k=c[i-1]-'0';
        		for (int t = 0; t < 13; t++) {
						d[i][(10*t+k)%13]+=d[i-1][t];
						if(d[i][(10*t+k)%13]>mod)d[i][(10*t+k)%13]-=mod;
				}        		
        	}
//			db(d[i]);
		}
        
      
        out.println(d[c.length][5]);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

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

    string s;
    cin >> s;

    string t = "";
    for(int i = 0; i < s.size(); i++){
        if(i % 2) t += 'i';
        else t += 'h';
    }

    if(s.size() % 2 == 0 && s == t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100000][3];
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    //int dp[n][3];
    for (int i = 0; i < 3; ++i)
    {
        dp[0][i]=a[0][i];
    }
    
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            if(j==0)
            {
                dp[i][j]=a[i][j]+max(dp[i-1][1],dp[i-1][2]);
            }
            else if(j==1)
            {
                dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][2]);
            }
            else
            {
                dp[i][j]=a[i][j]+max(dp[i-1][0],dp[i-1][1]);
            }
        }
    }
    
  
    int m=0;
    for (int i = 0; i < 3; ++i)
    {
        if(m<dp[n-1][i])
            m=dp[n-1][i];
    }
    cout<<m;
    cout<<"\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>

using namespace std;

string str;
int a[16][16];

int main(){

	while(cin>>str, !cin.eof()){
		
		memset(a, 0, sizeof(a));
		
		for(int i=0; i<10; ++i){
			a[10][i] = str[i]-'0';
		}

		for(int t=10; t>=2; --t){

			for(int i=0; i<t; ++i){
				a[t-1][i] = (a[t][i] + a[t][i+1])%10;
			}
		}
		
		cout << a[1][0] << endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> asi(n), dp(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> asi[i];
  }
  dp[0] = 0;
  dp[1] = abs(asi[1] - asi[0]);
  for (int i = 2; i < n; ++i) {
    dp[i] = min(dp[i - 1] + abs(asi[i] - asi[i - 1]),
                dp[i - 2] + abs(asi[i] - asi[i - 2]));
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int t[10][10];
int s[10][10];
int u[10][10];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				scanf("%d",&t[i][j]);
		for(int i=0;i<(1<<10);i++){
			for(int j=0;j<10;j++)
				for(int k=0;k<10;k++){
					s[j][k]=t[j][k];
					u[j][k]=0;
				}
			for(int j=0;j<10;j++)if(i&(1<<j)){
				s[0][j]=(s[0][j]+1)%2;
				if(j<9)s[0][j+1]=(s[0][j+1]+1)%2;
				if(j)s[0][j-1]=(s[0][j-1]+1)%2;
				s[1][j]=(s[1][j]+1)%2;
				u[0][j]=1;
			}
			for(int j=1;j<10;j++){
				for(int k=0;k<10;k++){
					if(s[j-1][k]%2){
						u[j][k]=1;
						s[j][k]=(s[j][k]+1)%2;
						s[j-1][k]=(s[j-1][k]+1)%2;
						if(k)s[j][k-1]=(s[j][k-1]+1)%2;
						if(k<9)s[j][k+1]=(s[j][k+1]+1)%2;
						if(j<9)s[j+1][k]=(s[j+1][k]+1)%2;
					}
				}
			}
			bool ok=true;
			for(int j=0;j<10;j++)if(s[9][j]%2)ok=false;
			if(!ok)continue;
			else{
				for(int j=0;j<10;j++){
					for(int k=0;k<10;k++){
						if(k)printf(" ");
						printf("%d",u[j][k]);
					}
					printf("\n");
				}
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
int n, Q;
queue<int>q[1010];
int main() {
	cin >> n >> Q;
	while (Q--) {
		int z, t, x;
		cin >> z >> t;
		if (z == 0) {
			cin >> x;
			q[t].push(x);
		}
		if (z == 1 && !q[t].empty())cout << q[t].front() << endl;
		if (z == 2 && !q[t].empty())q[t].pop();
	}
	getchar();getchar();
	return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k;
vector <char> magicList;
string ans = "No";
bool isValid(){
    int tmpA = a, tmpB=b,tmpC=c;
    for(int i = 0; i < magicList.size(); i++){
        switch (magicList[i])
        {
        case /* constant-expression */'a':
            /* code */
            tmpA*=2;
            break;
        case /* constant-expression */'b':
            /* code */
            tmpB*=2;
            break;
        
        case /* constant-expression */'c':
            /* code */
            tmpC*=2;
            break;
        default:
            break;
        }
    }
    if((tmpA<tmpB)&&(tmpB<tmpC)){
        return true;
    }else{
        return false;
    }
}
void dfs(char c){
    magicList.push_back(c);
    if(magicList.size()==k){
        if(isValid()){
            ans="Yes";
        }
    }else{
        dfs('a');
        magicList.pop_back();
        dfs('b');
        magicList.pop_back();
        dfs('c');
        magicList.pop_back();
    }
    return; 
}
int main(){
    cin >> a >> b >> c >> k;
        dfs('a');
        magicList.pop_back();
        dfs('b');
        magicList.pop_back();
        dfs('c');
        magicList.pop_back();
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

    ll N, K;
    vector<ll> X;
    cin >> N >> K;
    for(int i = 0; i < N; i ++){
        ll x;
        cin >> x;
        X.pb(x);
    }
    ll ans = 300000005;
    for(int i = 0; i + K - 1 < N; i ++){
        ll tmp = X[i + K - 1] - X[i];
        if(X[i] > 0)tmp += X[i];
        else if(X[i + K - 1] < 0)tmp -= X[i + K - 1];
        else tmp += min(X[i + K - 1], -X[i]);
        ans = min(ans,tmp);
    }
    cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1400
def m():
    h, w = map(int, input().split())
    a = [list(("."+input()+".")) for _ in range(h)]
    a.insert(0, ['.' for _ in range(w+2)])
    a.insert(h+1, ['.' for _ in range(w+2)])
    for i in range(1,h+1):
        for j in range(1,w+1):
            if a[i][j] != "#":
                continue
            if a[i+1][j] == "#":
                continue
            if a[i][j+1] == "#":
                continue
            if a[i-1][j] == "#":
                continue
            if a[i][j-1] == "#":
                continue
            return "No"
    return "Yes"

print(m())

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

#define NMAX 100000
#define INF 100001

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

using namespace std;

int n;
int diff[NMAX];

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

    sort(diff, diff + n);

    int mid = n / 2 - 1;
    cout << diff[mid + 1] - diff[mid] << '\n';
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include <stdio.h>
#include <string.h>
 
using namespace std;
int main()
{
	long long s = 0;
        long long i, j, ans = 0;
	long long N = 0;
	long long K = 0;
	long long A[100001] = {};
	long long a, b = 0;
 
	cin >> N;
    cin >> K;
 
	for (i = 0; i <= N-1; i++) {
		cin >> a;
		cin >> b;
		A[a] += b;
	}
 
	for (j = 1; j <= 100001; j++) {
		s += A[j];
		ans = j;
		if (s >= K)
			break;
	}
 
	cout << ans;
 
	return 0;
}

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

int main() {
  int a, b, cnt;
  cin >> a >> b;
  for(int i = a; i <= b; i++){
    if(i / 10000 == i % 10 && i / 1000 % 10 == i % 100 / 10){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

int main()
{
	long long a,b,c,d;
	string s;
	
	cin >> s;
	
	b = -1;
	for(a=0;a<s.size();a++)
		if(s[a] == 'A')
		{
			b = a;
			break;
		}
	c = -1;
	for(a=s.size()-1;a>=0;a--)
		if(s[a] == 'Z')
		{
			c = a;
			break;
		}

	if(b != -1 && c != -1 && c-b>0)
	{
		cout << c-b+1;
	}


}

Measured memory_bytes: 640
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	string str;
	while(cin >> str){
		int joicnt=0,ioicnt=0;
		for(int i=0;i<str.size()-2;i++){
			if(str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I'){
				joicnt++;
			}
			if(str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I'){
				ioicnt++;
			}
		}
		cout << joicnt << endl;
		cout << ioicnt << endl;
	}
	return 0;
}
	

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int combination(int N, int c){
    int temp=1;
    for(int i=0;i<c;i++){
        temp = temp*(N-i);
    }
    for(int i=0;i<c;i++){
        temp = temp/(1+i);
    }
    return temp;
}

signed main(){
    string N;
    int K;
    cin>>N;
    cin>>K; 

    int len = N.size();

    if(len<K){
        cout<<0<<endl;
        return 0;
    }    
    int index=0;

    for(int i=K;i<len;i++){
        index+= combination(i-1, K-1)*pow(9,K);
    }
//    index+= (combination(len-1, K-1)-1)*
    if(K==1){
        index+=charToInt(N.at(0));
    }else if(K==2){
        index += ((len-1)*9)*(charToInt(N.at(0))-1);
        int tt=1;
        while(tt<len){
            if(charToInt(N.at(tt))!=0){
                break;
            }
            tt++;
        }
        if(tt<len){
            index += ((len-tt-1)*9 + charToInt(N.at(tt)));
        }
    }else{
        index += ((len-1)*(len-2)*9*9/2)*(charToInt(N.at(0))-1); //最上位桁が最大値でない
        int tt1=1;
        while(tt1<len-1){
            if(charToInt(N.at(tt1))!=0){
                break;
            }
            tt1++;
        }

        if(tt1<len-1){
            index += ((len-tt1-1)*9)*(charToInt(N.at(tt1))-1) + (len-tt1-1)*(len-tt1-2)/2*9*9; // 最上位けたが最大値かつ2桁目が最大値でない

            int tt2=tt1+1;
            while(tt2<len){
             if(charToInt(N.at(tt2))!=0){
                break;
                }
            tt2++;
            }

        if(tt2<len){
            index += ((len-tt2-1)*9 + charToInt(N.at(tt2)));
        }

        }
    }

    cout<<index<<endl;


    return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    REP(i,Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i],--b[i];
    }
    ll ans = 0;
    auto dfs = [&](auto && dfs, vector<int> v) -> void{
        if(v.size() == N){
            ll tmp = 0;
            REP(i,Q){
                if(v[b[i]] - v[a[i]] == c[i]){
                    tmp += d[i];
                }
            }
            chmax(ans, tmp);
        }
        else{
            if(v.empty()){
                for(int i=1;i<=M;i++){
                    auto tmp = v;
                    tmp.push_back(i);
                    dfs(dfs, tmp);
                }
            }
            else{
                for(int i=v.back();i<=M;i++){
                    auto tmp = v;
                    tmp.push_back(i);
                    dfs(dfs, tmp);
                }
            }
        }
    };
    vector<int> v;
    dfs(dfs, v);
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
 
int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i) cin >> s[i];
    for (int i = 0; i < B; ++i) cin >> t[i];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
 
    for (int _ = 0; _ < Q; ++_) {
        long long x; cin >> x;
        
        long long res = 1LL<<60;
        
        // 先に s
        int it = lower_bound(s.begin(), s.end(), x) - s.begin();
        for (int i = max(0, it-1); i < min(A, it+1); ++i) {
            long long y = s[i]; 
            int it2 = lower_bound(t.begin(), t.end(), y) - t.begin();
            for (int j = max(0, it2-1); j < min(B, it2+1); ++j) {
                chmin(res, abs(x - y) + abs(y - t[j]));
            }         
        }
 
        // 先に t
        it = lower_bound(t.begin(), t.end(), x) - t.begin();
        for (int i = max(0, it-1); i < min(B, it+1); ++i) {
            long long y = t[i]; 
            int it2 = lower_bound(s.begin(), s.end(), y) - s.begin();
            for (int j = max(0, it2-1); j < min(A, it2+1); ++j) {
                chmin(res, abs(x - y) + abs(y - s[j]));
            }         
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 2944
import java.util.*;

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

        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        int x21 = x2 - x1;
        int y21 = y2 - y1;
        
        int x3 = x2 - y21;
        int y3 = y2 + x21;

        int x4 = x3 - x21;
        int y4 = y3 - y21;

        System.out.println(x3 + " " + y3 + " " + x4 + " " + " " + y4);


    }
}

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

// input
int N, c;
vector<int> S, T, C;

vector<tuple<int, int, int>> w;
map<int, set<int>> ms, mt;


void input() {
    cin >> N >> c;
    S = T = C = vector<int>(N);
    rep(i, N) cin >> S[i] >> T[i] >> C[i];
}


int main() {
    input();
    rep(i, N) {
        w.push_back(make_tuple(S[i], 0, C[i]));
        w.push_back(make_tuple(T[i], 1, C[i]));
        ms[S[i]].insert(C[i]);
        mt[T[i]].insert(C[i]);
    }
    sort(w.begin(), w.end());
    int ans = 0;
    int s = 0;
    for (auto t : w) {
        if (get<1>(t) == 0) {
            if (mt[get<0>(t)].count(get<2>(t)) == 0) s++;
        } else {
            if (ms[get<0>(t)].count(get<2>(t)) == 0) s--;
        }
        ans = max(ans, s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 34640
import numpy as np
a, b, c, x = int(input()), int(input()), int(input()), int(input())
i = 500 * np.arange(a+1)
j = 100 * np.arange(b+1)
k = 50 * np.arange(c+1)
product = i[:, None, None]+j[None, :, None]+k[None, None, :]
print(np.count_nonzero(product==x))

Measured memory_bytes: 13432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int x;
  cin >> x;
  vector<int> v;
  v.push_back(1);
  for (int i = 2; i <= 31; i++){
    int p = 2;
    while(1){
      int num = pow(i, p);
      if (num <= 1000) {
        v.push_back(num);
        p++;
      } else {
        break;
      }
    }
  }
  v.push_back(1001);
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++){
    if (x < v[i]){
      cout << v[i-1] << endl;
      return 0;
    }
  } 
}

Measured memory_bytes: 3996
let get_line () =
    read_line ()
    |> Str.split (Str.regexp "")

let rec play a b c turn =
    match turn with
    | "a" when a <> [] ->
        play (List.tl a) b c (List.hd a)
    | "b" when b <> [] ->
        play a (List.tl b) c (List.hd b)
    | "c" when c <> [] ->
        play a b (List.tl c) (List.hd c)
    | _ ->
        String.uppercase turn

let () =
    let a = get_line () in
    let b = get_line () in
    let c = get_line () in
    play a b c "a"
    |> print_endline


Measured memory_bytes: 384
N = input()
S = input()

def main(N,S):
    N = int(N)
    if N%2 == 1:
        print('No')
    else:
        l=int(N/2)

        S1 = S[:l]
        S2 = S[-l:]

        if S1 == S2:
            print('Yes')
        else:
            print('No')


main(N,S)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int x[100010];
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        a[i]++;
        x[a[i]]++;
        x[a[i]-1]++;
        x[a[i]+1]++;
    }
    int mx = 0;
    for(int i = 0;i < 100010;i++){
        mx = max(mx,x[i]);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int k;
	string s;
	cin >> k >> s;
	if (k < s.size()) {
		for (int i = 0; i < s.size(); i++) {
			if (i < k)	cout << s[i];
		}
		cout << "..." << endl;
	}
	else {
		cout << s << endl;
	}
}


Measured memory_bytes: 3592
from math import *
from collections import Counter
def factorize(n):
	res = []
	while n%2 == 0:
		res.append(2)
		n = n//2
	for i in range(3,int(sqrt(n))+1,2):
		while n%i == 0:
			res.append(i)
			n = n//i
	if n > 2:
		res.append(n)

	return set(res)

n = int(input())
primes = factorize(n)
ans = 0
for i in primes:
	c = i
	while n%c == 0:
		n = n // c
		c = c * i
		ans+=1
print(ans)



Measured memory_bytes: 9480
#include <stdio.h>
using namespace std;

int main() {
  int n, m, sum=0, count=0;
  scanf("%d %d", &n, &m);
  int a[n];
  for (int i = 0; i < n; i++)
  {
    int v;
    scanf("%d", &v);
    sum+=v;
    a[i] = v;
  }
  for (int i = 0; i < n; i++) {
    double c = (double)sum / (4 * m);
    if(a[i] < c) {
      count++;
    }
  }
  if(m <= n - count) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int h, w;
	while (cin >> h >> w, h && w) {
		vector<string> r(h);
		for (string& i : r) cin >> i;
		string s;
		cin >> s;
		int ans = s.size();
		pair<int, int> a;
		for (char& i : s) {
			pair<int, int> b;
			for (int j = 0; j < h; ++j) {
				for (int k = 0; k < w; ++k) {
					if (i == r[j][k]) {
						b.first = j;
						b.second = k;
					}
				}
			}
			ans += abs(a.first - b.first) + abs(a.second - b.second);
			a = b;
		}
		cout << ans << endl;
	}
}


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

class Node{
public :
	int x;
	int y;
	void print(){
		cout<<"("<<x<<","<<y<<")"<<endl;
	}
};
int dx[]={-1, 0, 1, 0};
int dy[]={ 0,-1, 0, 1};
enum DIR{LEFT,DOWN,RIGHT,UP};
int xMin,xMax,yMin,yMax;
Node numList[201];
void init(){
//	cout<<"init "<<endl;
	xMin=0;
	xMax=1;
	yMin=0;
	yMax=1;
	for(int i=0;i<201;i++){numList[i].x=0;numList[i].y=0;}
	numList[0].x=1;
	numList[0].y=1;
//	cout<<"init complete"<<endl;
}
int main(){
	while(true){
		int d;
		cin>>d;
		if(!d)break;
		init();
//		cout<<"DATASET:"<<d<<endl;
		for(int i=1;i<d;i++){
			int num,dir;
			cin>>num>>dir;
//			cout<<"i:"<<i<<endl;
			numList[i].x=numList[num].x+dx[dir];
			numList[i].y=numList[num].y+dy[dir];
			if(xMax<numList[i].x)xMax=numList[i].x;
			if(xMin>numList[i].x-1)xMin=numList[i].x-1;
			if(yMax<numList[i].y)yMax=numList[i].y;
			if(yMin>numList[i].y-1)yMin=numList[i].y-1;
//			numList[i].print();
		}
		cout<<(xMax-xMin)<<" "<<(yMax-yMin)<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    string s, t;
    read(s, t);

    const int lenS = s.length();
    const int lenT = t.length();

    vector<string> cancidate;
    rep(i, 0, lenS - lenT + 1) {
        bool match = true;
        rep(j, 0, lenT) {
            match &= (s[i + j] == '?' || s[i + j] == t[j]);
        }
        if (!match) continue;

        string ans = s;
        rep(j, 0, lenT) {
            if (ans[i + j] == '?') ans[i + j] = t[j];
        }
        for (char &ch : ans) if (ch == '?') ch = 'a';

        cancidate.emplace_back(move(ans));
    }

    if (cancidate.empty()) {
        print("UNRESTORABLE");
    } else {
        print(*min_element(all(cancidate)));
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int K, S, ans = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++){
        for (int j = 0; j <= K; j++){
            if (S - i - j >= 0 && K >= S - i - j){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int N;
string S;
vector<int> C;
vector<int> RL;

void input_init(void) {
	cin >> S;
	N = S.length();
	C.resize(N, 0);
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == 'R' && S[i + 1] == 'L')
			RL.push_back(i);
	}
}

void count_R(int r) {
	int p = 0;
	while (true) {
		if (r - p < 0)
			break;
		if (S[r - p] != 'R')
			break;
		if (p % 2 == 0)
			++C[r];
		else
			++C[r + 1];
		++p;
	}
}

void count_L(int l) {
	int p = 0;
	while (true) {
		if (l + p >= N)
			break;
		if (S[l + p] != 'L')
			break;
		if (p % 2 == 0)
			++C[l];
		else
			++C[l - 1];
		++p;
	}
}

void solve(void) {
	for (int i = 0; i < (int)RL.size(); ++i) {
		int pos_R = RL[i];
		count_R(pos_R);
		count_L(pos_R + 1);
	}
}

int main(void) {
	input_init();
	solve();
	for (int i = 0; i < N; i++) {
		cout << C[i];
		cout << ((i == N - 1) ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int ans = 999;
  for (int i = 0; i < s.size() - 2; i++) {
    int a = (s[i]-'0') * 100 + (s[i+1]-'0') * 10 + (s[i+2]-'0');
    ans = min(ans, abs(a - 753));
  }
  cout << ans << endl;
}


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

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

    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){ cout << k << endl; return 0; }
    if(a + b >= k){ cout << a << endl; return 0; }
    cout << a-(k - a - b) << endl;
    return 0;
}

Measured memory_bytes: 3544