akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin >> h >> w >> n;
    vector<pair<ll,ll> > ab(n);
    set<pair<ll,ll> > abst;  
    REP(i,n){
        cin >> ab[i].fi >> ab[i].se;
        abst.insert(make_pair(ab[i].fi, ab[i].se));
    }
    vector<set<pair<ll,ll> > > st(10);
    ll ans0 = (h-2)*(w-2);
    REP(i,n){
        ll ny = ab[i].fi;
        ll nx = ab[i].se;
        for(ll l = max(1LL,nx-2); l<=nx; ++l){
            for(ll u = max(1LL, ny-2); u<=ny; ++u){
                if(l+2>w||u+2>h) continue;
                int cnt = 0;
                REP(j,3)REP(k,3){
                    auto itr = abst.find(make_pair(u+j, l+k));
                    if(itr!=abst.end()) cnt++;
                }
                st[cnt].insert(make_pair(u, l));
            }
        }
    }
    for(int i=1;i<=9;++i){
        ans0 -= (ll)st[i].size();
    }
    cout << ans0 <<endl;
    for(int i=1;i<=9;++i){
        cout << (ll)st[i].size() << endl;
    }
    return 0;
}

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

string a;
string b;

int main() {
	cin >> a >> b;
	if (a.length() > b.length()) cout << "GREATER" << endl;
	else if (a.length() < b.length()) cout << "LESS" << endl;
	else if (a > b) cout << "GREATER" << endl;
	else if (a < b) cout << "LESS" << endl;
	else cout << "EQUAL" << endl;
	return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s, t;
  cin >> n >> s >> t;
  string ans;
  rep(i, 2 * n) {
    if (i % 2 == 0) {
      ans += s[i / 2];
    } else {
      ans += t[i / 2];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace SandboxForAtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var line1 = Console.In.ReadLine();

            decimal a = decimal.Parse(line1.Split(" ")[0]);
            decimal b = decimal.Parse(line1.Split(" ")[1]);
            b = Math.Floor(b * 100) / 100;

            var result = Math.Floor(a * b);
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27552
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}


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

typedef struct heap
{
    long int *data;
    int size;
    int firstEmpty;
} heap;

void upProcess(heap *h, int index);
void downProcess(heap *h);

heap * initializeHeap(int size)
{
    heap *h = (heap *)malloc(sizeof(heap));
    h->data = (long int *)malloc(sizeof(long int) * (size + 1));
    h->size = size;
    h->firstEmpty = 1;
    return h;
}

void destroyHeap(heap *h)
{
    free(h->data);
    free(h);
}

int insertHeap(heap *h, long int value)
{
    if (h->size < h->firstEmpty)
    {
        return -1;
    }
    else
    {
        int index = h->firstEmpty;
        h->data[index] = value;
        h->firstEmpty++;
        upProcess(h, index);
        return 0;
    }
}

int removeHeap(heap *h)
{
    if (h->firstEmpty <= 1)
    {
        return -1;
    }
    else
    {
        h->firstEmpty--;
        h->data[1] = h->data[h->firstEmpty];
        downProcess(h);
        return 0;
    }
}

void upProcess(heap *h, int index)
{
    int parentIndex;
    long int tmp;
    while (index > 1)
    {
        parentIndex = index / 2;
        if (h->data[parentIndex] < h->data[index])
        {
            tmp = h->data[parentIndex];
            h->data[parentIndex] = h->data[index];
            h->data[index] = tmp;
            index = parentIndex;
        }
        else
        {
            break;
        }
    }
}

void downProcess(heap *h)
{
    int index = 1, childIndex;
    long int tmp;
    while (index * 2 <= h->firstEmpty)
    {
        childIndex = index * 2;
        if (childIndex + 1 < h->firstEmpty)
        {
            if (h->data[childIndex] < h->data[childIndex + 1])
            {
                childIndex++;
            }
        }
        if (h->data[index] < h->data[childIndex])
        {
            tmp = h->data[index];
            h->data[index] = h->data[childIndex];
            h->data[childIndex] = tmp;
            index = childIndex;
        }
        else
        {
            break;
        }
    }
}

long long int totalPrice(heap *h)
{
    long long int total = 0;
    for (int index = 1; index < h->firstEmpty; index++)
    {
        total += h->data[index];
    }
    return total;
}

int main(void)
{
    int inputN, inputM;
    long int inputA, tmp;
    scanf("%d%d", &inputN, &inputM);
    heap *h = initializeHeap(inputN);
    for (int count = 0; count < inputN; count++)
    {
        scanf("%ld", &inputA);
        insertHeap(h, inputA);
    }
    for (int count = 0; count < inputM; count++)
    {
        tmp = h->data[1];
        removeHeap(h);
        insertHeap(h, tmp / 2);
    }
    printf("%lld", totalPrice(h));
    destroyHeap(h);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int dp[3005][3005];
int a[3005];
int main(){
    int n, s;
    scanf("%d%d", &n, &s);
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        for(int j=0;j<=s;j++){
            if(j+a[i] <= s){
                dp[i][j+a[i]] = (dp[i][j+a[i]] + dp[i-1][j])%mod;
            }
            dp[i][j] = (dp[i][j] + dp[i-1][j]*1ll*2)%mod;
        }
    }    
    printf("%d\n", dp[n][s]);
}

Measured memory_bytes: 39056
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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


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

	ll A, B, C;
	cin >> A >> B >> C;
	
	if (A == B && B == C)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	//system("pause");
}

Measured memory_bytes: 256
#coding: utf-8

a, b = (int(i) for i in input().split())

n = [[0 for i in range(b)] for j in range(a)]
m = [0 for i in range(b)]

for i in range(a):
    n[i] = input().split()

for i in range(b):
    m[i] = int(input())

for i in range(a):
    x = 0
    for j in range(b):
        x += int(n[i][j]) * m[j]
    print(x)


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

int main(void)
{
	string s,t;
	cin>>s>>t;
	int q;
	cin>>q;
	vector<int> sa(1,0),sb(sa),ta(sa),tb(sa);
	for (int i = 0; i < s.size(); i++) {
		sa.push_back((s[i]=='A')+sa.back());
		sb.push_back((s[i]=='B')+sb.back());
	}
	for (int i = 0; i < t.size(); i++) {
		ta.push_back((t[i]=='A')+ta.back());
		tb.push_back((t[i]=='B')+tb.back());
	}
	for (int i = 0; i < q; i++) {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int ns,nt;
		nt=(ta[d]-ta[c-1]+(tb[d]-tb[c-1])*2)%3;
		ns=(sa[b]-sa[a-1]+(sb[b]-sb[a-1])*2)%3;
		if(nt==ns)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 2868
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
//#pragma GCC optimize(3)
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define ll long long
#define ull unsigned long long
#define mn 100020
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline void writeln(ll a){
    if(a==0){puts("0");return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    FORD(i,h,1)putchar(c1[i]);putchar('\n');
    return;
}
inline ll Max(ll a,ll b){return (a>b)?a:b;}
inline ll Min(ll a,ll b){return (a<b)?a:b;}
inline ll Abs(ll x){return (x<0)?-x:x;}
inline void Swap(ll &x,ll &y){ll t=x;x=y;y=t;}
int a[mn];
struct node{
	int x,h;
}v[mn],v2[mn];
inline bool cmp(node a,node b){return a.h>b.h;}
int main(){
	int n=read(),x;
	FOR(i,1,n){
		x=read();
		if(i%2)v[x].h++,v[x].x=x;else v2[x].h++,v2[x].x=x;
	}
	sort(v+1,v+int(1+1e5),cmp);
	sort(v2+1,v2+(int)(1+1e5),cmp);
	if(v[1].x==v2[1].x)writeln(Min(n-v[2].h-v2[1].h,n-v[1].h-v2[2].h));
	else writeln(n-v[1].h-v2[1].h);
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[16][16];
	rep(i, N) rep(j, N) cin >> A[i][j];

	ll dp[1 << 16] = {};
	int n = 1 << N;
	rep1(i, N - 1) {
		int M = 1 << i;
		rep(j, M) {
			ll kari = dp[j];
			rep(k, i) if (j >> k & 1) kari += A[i][k];
			dp[M + j] = kari;
		}
	}

	rep1(i, n - 1) {
		for (int j = i - 1 & i; j > 0; j = j - 1 & i) {
			dp[i] = max(dp[i], dp[j] + dp[i ^ j]);
		}
	}

	co(dp[n - 1]);


	Would you please return 0;
}

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

using pp=pair<int,int>;

int main() {
  int R;
  cin >> R;
  if (R<1200) {
    cout << "ABC" << endl;
  }
  else if (R<2800) {
    cout << "ARC" << endl;
  }else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
 
int main()
{
  ll h,w,m;
  cin>>h>>w>>m;
  map<ll,ll> row,col;
  map<pair<ll,ll>,bool> field;
  for (int i = 0; i < m; ++i)
  {
    ll x,y;
    cin>>x>>y;
    x--;y--;
    field[{x,y}]=true;
    row[x]++;
    col[y]++;
  }
  
  ll max_row=0;
  ll max_col=0;
  for(const auto& e: row) 
  {
    max_row=max(max_row,e.second);
  }
  for(const auto& e: col) 
  {
    max_col=max(max_col,e.second);
  }
  ll ans=max_row+max_col;
 
  vector<ll> row_kouho,col_kouho;
  for(const auto& e: row) 
  {
    if(e.second==max_row)
      row_kouho.push_back(e.first);
  }
  for(const auto& e: col) 
  {
    if(e.second==max_col)
      col_kouho.push_back(e.first);
  }
  for (int i = 0; i < row_kouho.size(); ++i)
  {
    for (int j = 0; j < col_kouho.size(); ++j)
    {
      if(!field[{row_kouho[i],col_kouho[j]}])
      {
        cout<<ans<<endl;
        return 0;
      }
    }
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 67808
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll N, W;
vector<ll> w, v;

void input() {
    cin >> N >> W;
    w = vector<ll>(N);
    v = vector<ll>(N);
    for(ll i = 0; i < N; i++) {
        cin >> w.at(i) >> v.at(i);
    }
}

void solve() {
    ll dp[N+1][W+1];
    for(ll i = 0; i <= N; i++) {
        for(ll j = 0; j <= W; j++) {
            dp[i][j] = 0;
        }
    }
    for(ll i = 0; i < N; i++) {
        for(ll j = 0; j <= W; j++) {
            if(j < w[i]) {
                dp[i+1][j] = dp[i][j];
            } else {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
    /*
    for(ll i = 0; i <= N; i++) {
        for(ll j = 0; j <= W; j++) {
            cout << dp[i][j] << ", ";
        }
        cout << endl;
    }
    */

}



int main() {
    input();
    solve();
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> l(m);
    vector<int> r(m);
    int maxl=0,minr=100000;
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        if(maxl<l)maxl=l;
        if(minr>r)minr=r;
    }
    int ans=max(minr-maxl+1,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b)puts("delicious");
	else if(b-a<=x)puts("safe");
	else puts("dangerous");
	return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#include <sched.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>;
using Graph = vector<vector<int>>;

int main(void) {
    int n; cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);

    int sugestind;
    rep(i, n) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0) {
            sugestind = i;
        }
    }

    rep(i,101)
    rep(j,101) {
        bool flag = true;
        int ix = i;
        int iy = j;
        int sggesth = h[sugestind]  + abs(x[sugestind] - ix) + abs(y[sugestind] - iy);
        rep(i,n) {
            int dx = abs(x[i]-ix);
            int dy = abs(y[i]-iy);
            int tmph = max(sggesth - dx - dy, 0);
            if(tmph != h[i]) {
                flag = false;
            }
        }
        if(flag) {
            cout << ix << " " << iy << " " << sggesth << endl;
            return 0;
        }
    }
    return 0;
}


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

#define MAX_LOG10K (100000L)
#define MAX_D (100L)
#define NUM_MOD (1000000007L)
#define SIZE_BUF (30L)

long mod(long n, long k) {
  const long num = n % k;
  if (num >= 0) {
    return num;
  } else {
    return num + k;
  }
}

long dpss[MAX_LOG10K][MAX_D];

int main() {
  // read inputs
  long ks[MAX_LOG10K], num_digits = 0, D;
  char buf[SIZE_BUF], c;
  while ((c = fgetc(stdin)) != '\n') {
    ks[num_digits++] = c - '0';
  }
  scanf("%ld", &D);
  //   for (long i = 0; i < num_digits; i++) {
  //     printf("i = %ld, ks[i] = %ld\n", i, ks[i]);
  //   }

  // solve dp
  // dpss[i][j] : The number of i digit numbers where the mod D of the sum of
  //              the digits is equal to j
  // initialize
  for (long j = 0; j < D; j++) {
    dpss[0][j] = j == 0;
  }
  // update
  for (long i = 1; i <= num_digits; i++) {
    for (long j = 0; j < D; j++) {
      long dp = 0;
      for (long d = 0; d < 10; d++) {
        dp = mod(dp + dpss[i - 1][mod(j - d, D)], NUM_MOD);
      }
      dpss[i][j] = dp;
      //   printf("%ld ", dp);
    }
    // printf("\n");
  }
  // calculate answer
  long ans = 0, sum_digits = 0;
  for (long i = 0; i < num_digits; i++) {
    const long k = ks[i];
    for (long d = 0; d < k; d++) {
      const long s = (sum_digits + d) % D,
                 num = dpss[num_digits - 1 - i][mod(-s, D)];
      ans = mod(ans + num, NUM_MOD);
      //   printf("i = %ld, d = %ld, s = %ld, num = %ld\n", i, d, s, num);
    }
    sum_digits = (sum_digits + k) % D;
  }
  if (sum_digits % D == 0) {
    ans = mod(ans + 1, NUM_MOD);  // add K if its digit sum is divisible by D
  }
  ans = mod(ans - 1, NUM_MOD);  // remove 0
  printf("%ld\n", ans);
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n, m; cin >> n >> m;
  ll k; cin >> k;
  vector<ll> a(n), b(m);  cin >> a >> b;
  ll tot = 0;
  int i=0;
  while(i<n and tot+a[i]<=k){
    tot += a[i++];
  }
  int ans = i, now = i, j = 0;
  i--;
  while(j<m){
    while(j<m and tot+b[j]<=k){
      tot += b[j++];
      now++;
    }
    ans = max(ans, now);
    if(i>=0){
      tot -= a[i--];
      now--;
    } else break;
  }
  cout << ans << "\n";
  return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 A,B,C;
    cin >> A >> B >> C;
    if(A==B and B==C) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll n,d;
    cin>>n>>d;
    cout<<(n+2*d)/(2*d+1)<<endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    l = []
    for i in range(N):
        a = list(map(int, input().split()))
        l.append(a)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if i == j:
                continue
            for k in range(N):
                if k == i or k == j:
                    continue
                if l[i][j] == l[i][k] + l[k][j]:
                    break
                if l[i][j] > l[i][k] + l[k][j]:
                    return -1
            else:
                ans += l[i][j]
    return ans
print(main())


Measured memory_bytes: 42716
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  while(cin >> n, n) {
    vector<int> a(n);
    REP(i,n)
      cin >> a[i];
    sort(ALL(a));
    long long sum = 0, ans = 0;
    REP(i,n) {
      ans += sum;
      sum += a[i];
    }
    cout << ans << endl;
  }
}

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

 
void printString(long long int n) 
{ 
	char str[MAX]; 
	int i = 0; 

	while (n > 0) { 
		// Find remainder 
		int rem = n % 26; 

		// If remainder is 0, then a 'Z' must be there in output 
		if (rem == 0) { 
			str[i++] = 'z'; 
			n = (n / 26) - 1; 
		} 
		else // If remainder is non-zero 
		{ 
			str[i++] = (rem - 1) + 'a'; 
			n = n / 26; 
		} 
	} 
	str[i] = '\0'; 

	// Reverse the string and print result 
	reverse(str, str + strlen(str)); 
	cout << str << endl; 

	return; 
} 


int main() 
{ 
	long long int n;
	cin>>n;
	printString(n);
	return 0; 
} 


Measured memory_bytes: 3564
N=int(input())
S=list(input())
P=list()
jia= N%26
for i in range(len(S)):
  xin= ord(S[i])+jia
  if xin > ord("Z"):
   xin-=26
  zimu=chr(xin)
  P+=zimu
p=''.join(P)
print(p)


Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 
#define CERR if(false) cerr

using namespace std;

vector<int> prime(100001,1);

void sieve(){

    prime[0] = 0;
    prime[1] = 0;

    for(int i = 2; i * i <= 100000; i++){
        if(prime[i] == 1){
            for(int j = i * i; j <= 100000; j = j + i){
                prime[j] = 0;
            }
        }
    }
}

int main(){

    int q,l,r;
    cin >> q;

    sieve();
    vector<int> like2017(100001);

    for(int i = 1; i <= 100000; i = i + 2){
        if(prime[i] == 1 && prime[(i + 1) / 2] == 1){
            like2017[i] = 1;
        }
    }

    for(int i = 1; i <= 100000; i++){
        like2017[i] = like2017[i] + like2017[i - 1];
    }

    rep(i,q){
        cin >> l >> r;

        cout << like2017[r] - like2017[l - 1] << endl;
    }


    return 0; 
}


Measured memory_bytes: 1408
/* B */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	long long int x, r, d;
	cin >> r >> d >> x;
	for(int i = 1; i <= 10; i++){
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int n,a[2000],m,q;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>q;
    bool ch[4001]={1};
    for(int j=0;j<n;j++){
      for(int k=q-1;k>=0;k--) if(ch[k]) ch[k+a[j]]=1;
      if(ch[q]){
        cout<<"yes"<<endl;
        break;
      }

    }
    if(!ch[q]) cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

#define LENGTH 256

int main(void) {
    char input[LENGTH];
    int r, i, sum;
    int n[3];
    fgets(input, LENGTH-1, stdin);
    sscanf(input, "%d %d %d", &n[0], &n[1], &n[2]);
    int tr = n[0] * n[1];
    int ta = n[2];
    if(tr <= ta){
        printf("%d\n",tr);
    }else{
        printf("%d\n",ta);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,X=LI()
IL=LI()

res = 1
cur = 0
for i in IL:
    cur += i
    if cur <= X:
        res += 1

print(res)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int i=0,j=0,k;
    string a;
    string s,f="";
    
    while(1){
        cin>>a;
        if(a=="-"){
            break;
        }
        cin>>j;
        for(i=0;i<j;i++){
            cin>>k;
            f=a.substr(0,k);
            a.erase(0,k);
            a=a+f;
        }
        cout<<a<<endl;
    }
    
    
}



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

using namespace std;

constexpr int C = 1000000007;

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

  unsigned H, W;
  std::cin >> H >> W;
  char arr[H][W];
  int dp[H][W]; 

  for (size_t i = 0; i < H; ++i)
  { 
    for (size_t j = 0; j < W; ++j)
    { 
      std::cin >> arr[i][j];
      dp[i][j] = 0;
    }
  }

  for (size_t j = W; j > 0; --j)
  { 
    if (arr[H-1][j-1] == '#') break;
    dp[H-1][j-1] = 1;
  }

  for (size_t i = H-1; i > 0; --i)
  { 
    for (size_t j = W; j > 0; --j)
    { 
      size_t a = i-1, b = j-1;
      if (arr[a][b] == '#') continue;
      if (b+1 == W)
      {
        dp[a][b] = dp[a+1][b];
      }
      else
      {
        dp[a][b] = (dp[a+1][b] + dp[a][b+1]) % C;
      }
    }
  }

  std::cout << dp[0][0];

  return 0;
}

Measured memory_bytes: 5120
N,A,B,C,D = map(int,input().split())

if N % A == 0:
    a = N // A
else:
    a = N // A + 1

if N % C == 0:
    c = N // C
else:
    c = N // C + 1

x = a * B
y = c * D

print(min(x,y))



Measured memory_bytes: 5596
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    int x = Integer.parseInt(line[0]);
    int y = Integer.parseInt(line[1]);
    System.out.println(x*y+" "+(x+y)*2);
  }
}

Measured memory_bytes: 24000
#include<iostream>
#include<algorithm>
using namespace std;
const int da[] = { 0,0,6,13,18,23,43,58 };
int f(int a, int b, bool c) {
	int p;
	if (a == 1 && b == 2)p = 300;
	else if (a == 1 && b == 3)p = 500;
	else if (a == 1 && b == 4)p = 600;
	else if (a == 1 && b == 5)p = 700;
	else if (a == 1 && b == 6)p = 1350;
	else if (a == 1 && b == 7)p = 1650;
	else if (a == 2 && b == 3)p = 350;
	else if (a == 2 && b == 4)p = 450;
	else if (a == 2 && b == 5)p = 600;
	else if (a == 2 && b == 6)p = 1150;
	else if (a == 2 && b == 7)p = 1500;
	else if (a == 3 && b == 4)p = 250;
	else if (a == 3 && b == 5)p = 400;
	else if (a == 3 && b == 6)p = 1000;
	else if (a == 3 && b == 7)p = 1350;
	else if (a == 4 && b == 5)p = 250;
	else if (a == 4 && b == 6)p = 850;
	else if (a == 4 && b == 7)p = 1300;
	else if (a == 5 && b == 6)p = 600;
	else if (a == 5 && b == 7)p = 1150;
	else if (a == 6 && b == 7)p = 500;
	else p = 114514;
	if (c)p /= 2;
	if (p % 50 != 0)p += 25;
	return p;
}
int main() {
	int a, b, c, d;
	while (cin >> a, a) {
		int h, w; cin >> h >> w;
		b = h * 100 + w;
		cin >> c;
		cin >> h >> w;
		d = h * 100 + w;
		int dis = da[max(a, c)] - da[min(a, c)];
		bool e;
		if (((1730 <= b && b <= 1930) || (1730 <= d && d <= 1930)) && dis <= 40)e = true; else e = false;
		cout << f(min(a, c), max(a, c), e) << endl;
	}
}

Measured memory_bytes: 3072
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid+1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2152
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main(){
  int t, n, x, y, c, sx, sy;
  vector<int> dx = {1,1,0,0,-1,-1}, dy = {1,0,1,-1,0,-1};
  while (cin >> t >> n, t){
    vector< vector<int> > F(121, vector<int>(121,0));
    for (int i = 0; i < n; ++i){
      cin >> x >> y;
      F[x+60][y+60] = -1;
    }
    cin >> sx >> sy;
    F[sx+60][sy+60] = 1;
    queue< vector<int> > que;
    que.push({sx+60,sy+60,0});
    int ans = 1;
    while (!que.empty()){
      x = que.front()[0];
      y = que.front()[1];
      c = que.front()[2];
      que.pop();
      if (c < t){
	++c;
	for (int i = 0; i < 6; ++i){
	  if (!F[x+dx[i]][y+dy[i]]){
	    que.push({x+dx[i],y+dy[i],c});
	    F[x+dx[i]][y+dy[i]] = 1;
	    ++ans;
	  }
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int H;
int btree[251];

int main(){
	scanf("%d",&H);
	for(int i = 1; i <= H; i++){
		scanf("%d",&btree[i]);
	}

	for(int i = 1; i <= H; i++){
		printf("node %d: key = %d, ",i,btree[i]);
		if(i != 1){
			printf("parent key = %d, ",btree[i/2]);
		}
		if(i*2 <= H){
			printf("left key = %d, ",btree[i*2]);
		}
		if(i*2 + 1 <= H){
			printf("right key = %d, ",btree[i*2+1]);
		}
		printf("\n");
	}

	return 0;
}



Measured memory_bytes: 2716
n = int(input())
A = [int(input()) for _ in range(n)]

L = [0] * n
for i in range(1, n):
    L[i] = max(L[i - 1], A[i - 1])


R = [0] * n
for i in range(n - 2, -1, -1):
    R[i] = max(R[i + 1], A[i + 1])

for i in range(n):
    print(max(L[i], R[i]))


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

int main()
{
	int k, s;
	int cnt = 0;

	cin >> k >> s;

	for (int i = 0; i <= k; i++){
		for (int j = 0; j <= k; j++){
			int l = s - i - j;
			if (0 <= l && l <= k) cnt++;
		}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
N = int(input())
T = []
for _ in range(N):
    X,L = map(int, input().split())
    T.append([X-L,L+X])
T = sorted(T, key=lambda x:x[1])

ans = []
ans.append(T[0])
for i in range(1, N, 1):
    if ans[-1][1] <= T[i][0]:
        ans.append(T[i])

print(len(ans))


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

int p[110];

signed main()
{
	int n,a,b,cnt1=0,cnt2=0,cnt3=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		if(p[i]<=a) cnt1++;
		else if(p[i]>b) cnt3++;
		else cnt2++;
	}
	cout<<min(min(cnt1,cnt2),cnt3)<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s,s1;
    cin>>n>>s;
    if(s.size()<=n)cout<<s<<endl;
    else
    {
     s1=s.substr(0,n);
     s1+="...";
     cout<<s1<<endl;
    }
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int &x : A) cin >> x;
    unordered_set<int> odd;
    for (int i = 0; i < N; i += 2) odd.insert(A[i]);
    sort(A.begin(), A.end());
    int ans = 0;
    for (int i = 1; i < N; i += 2) ans += odd.count(A[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var s str
	fmt.Scan(&s)

	var q int
	fmt.Scan(&q)

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < q; i++ {
		sc.Scan()
		cmd := strings.Split(sc.Text(), " ")

		switch cmd[0] {
		case "replace":
			s.replace(toInt(cmd[1]), toInt(cmd[2]), cmd[3])
		case "reverse":
			s.reverse(toInt(cmd[1]), toInt(cmd[2]))
		case "print":
			s.print(toInt(cmd[1]), toInt(cmd[2]))
		}
	}
}

func toInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

type str string

func (s *str) replace(a, b int, p string) {
	*s = str(string((*s)[:a]) + p + string((*s)[b+1:]))
}
func (s *str) reverse(a, b int) {
	var reversed string
	for i := b; i >= a; i-- {
		reversed += string((*s)[i])
	}
	*s = str(string((*s)[:a]) + reversed + string((*s)[b+1:]))
}
func (s str) print(a, b int) {
	fmt.Println(s[a : b+1])
}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int H, W; cin >> H >> W;
    int N; cin >> N;
    vi a(N+1); REP1(i, N) cin >> a[i];
    int ans[H+1][W+1];

    int c = 0;
    int k = 1;
    int h, w = 0;
    while(true)
    {
        h = c / W + 1;
        if(a[k] == 0) k++;
        if((c / W) % 2 == 0)
        {
            ans[h][++w] = k;
            a[k]--;
            c++;
        } 
        else
        {
            ans[h][w--] = k;
            a[k]--;
            c++;
        }
        if(c == H*W) break;
    }

    REP1(i, H)
    {
        REP1(j, W)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

using namespace std;

int main() {
    vector<int> a;

    {
        string tmp;
        cin >> tmp;
        
        a.resize(tmp.size());

        for (int i = 0; i < tmp.size(); i++) {
            a[i] = tmp[i] - '0';
        }
    }

    reverse(a.begin(), a.end());


    int n = a.size();

    int d;
    cin >> d;

    using ll = long long;
    const ll mod = 1000000007;

    static ll dp[100001][2][101];


    dp[n][1][0] = 1;

    for (int i = n; i > 0; --i) {
        for (int k = 0; k < d; k++) {
            for (int t = 0; t < 10; t++) {
                (dp[i - 1][0][(k + t) % d] += dp[i][0][k]) %= mod;
            }

            (dp[i - 1][1][(k + a[i - 1]) % d] += dp[i][1][k]) %= mod;

            for (int t = 0; t < a[i - 1]; t++) {
                (dp[i - 1][0][(k + t) % d] += dp[i][1][k]) %= mod;
            }
        }
    }

    cout << (dp[0][0][0] + dp[0][1][0] - 1 + mod) % mod << endl;
}


Measured memory_bytes: 16640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;

int main() {
	int A, B;
	scanf("%d%d", &A, &B);
	printf("%d\n", (B+(A-3))/(A-1));
	return 0;
}


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

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

  int t[N];
	int x[N];
	int y[N];
  t[0]=x[0]=y[0]=0;
	for (int i = 1; i < N+1; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
  // cout << t[1] << endl;
  // cout << std::abs((-1)%2) << endl;
  for(int j=1;j<=N;j++){
    if(((x[j]-x[j-1]+y[j]-y[j-1])<=(t[j]-t[j-1]))&&(std::abs((x[j]-x[j-1]+y[j]-y[j-1]))%2==std::abs((t[j]-t[j-1])%2))){
      // cout <<x[j]-x[j-1]+y[j]-y[j-1]<< endl;
      // cout << t[j]-t[j-1] <<endl;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(Q);
    vector<long long> x(N, K - Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> A[i];
        A[i]--;

        x[A[i]]++;
    }

    for (int i = 0; i < N; i++)
    {
        if (x[i] <= 0)
        {
            cout << "No" << endl;
        }

        else
        {
            cout << "Yes" << endl;
        }
        
    }

    return 0;
}

Measured memory_bytes: 1792
import numpy as np
N = int(input())
c = np.array([[0 for x in range(10)] for y in range(10)])
buf_1 = []
buf_2 = 0

def func(A) :
    A = str(A)
    return [int(A[0]),int(A[len(A)-1])]

for i in range(1,N+1) :
    buf_1 = func(i)
    #print(buf_1)
    c[buf_1[0],buf_1[1]] += 1

for i in range(10) :
    for j in range(10) :
        buf_2 += c[i][j] * c[j][i]

print(buf_2)
#print(c)

Measured memory_bytes: 12504
#include<iostream>

int main(){
    int n,m;

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

    std::cin >> m;
    int p[m],x[m],ans[m];
    for(int i = 0;i < m;i++){
        std::cin >> p[i] >> x[i];
    }

    for(int i = 0;i < m;i++){
        ans[i] = 0;
        for(int j = 0;j < n;j++){
            if(p[i] == j + 1)
                ans[i] += x[i];
            else
                ans[i] += t[j];
        }
        std::cout << ans[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	cout << M * 2 - N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	float input;
	while(cin >> input){
		if(input <= 48.0){
			cout << "light fly" << endl;
		}else if(input <= 51.0){
			cout << "fly" << endl;
		}else if(input <= 54.0){
			cout << "bantam" << endl;
		}else if(input <= 57.0){
			cout << "feather" << endl;
		}else if(input <= 60.0){
			cout << "light" << endl;
		}else if(input <= 64.0){
			cout << "light welter" << endl;
		}else if(input <= 69.0){
			cout << "welter" << endl;
		}else if(input <= 75.0){
			cout << "light middle" << endl;
		}else if(input <= 81.0){
			cout << "middle" << endl;
		}else if(input <= 91.0){
			cout << "light heavy" << endl;
		}else{
			cout << "heavy" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(void)
{
	double sequence[10];
	double sum;
	int i;

	while (~scanf("%lf", sequence)){
		sum = *sequence;
		for (i = 1; i < 10; i++){
			if (i % 2){
				sequence[i] = sequence[i - 1] * 2;
			}
			else {
				sequence[i] = sequence[i - 1] / 3;
			}
			sum += sequence[i];
		}
		printf("%.8lf\n", sum);
	}

	return (0);
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, m;
    cin >> n >> m;

    priority_queue<ll> a;
    rep(i, 0, n){
        ll tmp;
        cin >> tmp;
        a.push(tmp);
    }

    rep(i, 0, m){
        ll tmp = a.top();
        a.pop();
        a.push(tmp / 2);
    }

    ll sum = 0;
    rep(i, 0, n){
        sum += a.top();
        a.pop();
    }

    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>

const int MAXN=1e5+5;

int ans[MAXN];

int main()
{
	int i;
	for(i=1;i<10;i++) ans[i]++;
	for(i=100;i<1000;i++) ans[i]++;
	for(i=1e4;i<1e5;i++) ans[i]++;
	for(i=1;i<=1e5;i++) ans[i]+=ans[i-1];
	int N;scanf("%d",&N);
	printf("%d",ans[N]);
	return 0;
}


Measured memory_bytes: 640
from math import gcd
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

l = A[0]
for i in range(1,N):
    l = gcd(l,A[i])

m = max(A)
if m < K:
    print('IMPOSSIBLE')
else:
    if l == 1:
        print('POSSIBLE')
    else:
        for i in range(N):
            if abs(A[i]-K)%l == 0:
                print('POSSIBLE')
                break
        else:
            print('IMPOSSIBLE')


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

int main() {
  int N;
  cin >> N;
  vector<int> len(N);
  for (int i = 0; i < N; i++)
  {
    cin >> len.at(i);
  }
  
  sort(len.begin(), len.end());
  
  int result = 0;
  
  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      for (int k = j  + 1; k < N; k++)
      {
        int I = len.at(i);
        int J = len.at(j);
        int K = len.at(k);
        if (K < I + J)
        {
          result++;
        }
        else
        {
          break;
        }
      }
    }
  }
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            Int64[] T = new Int64[N];
            for (int i = 0; i < N; ++i)
            {
                T[i] = Int64.Parse(Console.ReadLine());
            }

            for (int i = 0; i < N - 1; ++i)
            {
                long a = Math.Max(T[i], T[i + 1]);
                long b = Math.Min(T[i], T[i + 1]);
                long aAlt = a;
                long bAlt = b;

                long q = 0;
                long r = 1;

                while (r != 0)
                {
                    q = a / b;
                    r = a - b * q;

                    a = b;
                    b = r;
                    //aが答えになる
                }

                long gcd = a;

                a = aAlt;
                b = bAlt;

                long lcm = a / gcd * b;
                T[i + 1] = lcm;
            }
            Console.WriteLine(T[N-1]);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n, m;
    cin >> n >> m;
    vector<set<int>> graph(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    vector<int> order(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        order[i] = i + 1;
    }

    int ans = 0;
    do {
        int s = 0;
        bool valid = true;
        for (int to : order) {
            if (!graph[s].count(to)) {
                valid = false;
                break;
            }

            s = to;
        }

        ans += valid;
    } while (next_permutation(order.begin(), order.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    # init
    h,w,d = map(int,input().split())
    dic = defaultdict(list)
    for i in range(h):
        nums = [int(x) for x in input().split()]
        for j,num in enumerate(nums):
            dic[int(num)] = [i,j]
    # memo
    ls = [0 for i in range(w*h+1)]
    for i in range(d+1,w*h+1):
        before,after = dic[i-d],dic[i]
        diff = abs(after[0]-before[0]) + abs(after[1]-before[1])
        ls[i] = ls[i-d]+ diff
    # ans
    q = int(input())
    for i in range(q):
        l,r = map(int,input().split())
        print(ls[r]-ls[l])
if __name__ == "__main__":
    main()

Measured memory_bytes: 70364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#define DEBUG
using namespace std;

int main(){

    vector<int> order(5);
    vector<int> rem_zero;
    vector<int> rem_rem;
    vector<int> ans_rem;

    for(int i = 0; i < order.size(); i++){
        cin >> order.at(i);

        if(order.at(i) % 10 == 0){
            rem_zero.push_back(order.at(i));
        }else{
            rem_rem.push_back(order.at(i));
        }
    }
    sort(order.begin(), order.end());
    sort(rem_rem.rbegin(), rem_rem.rend(), [](int x, int y) { return (x%10) < (y%10);});
    sort(rem_zero.rbegin(), rem_zero.rend());
    int ans = 0;

    for(int i = 0; i < rem_zero.size(); i++){
        //cout << rem_zero.at(i) << " ";
        ans_rem.push_back(rem_zero.at(i));
    } 
    for(int i = 0; i < rem_rem.size(); i++){
        //cout << rem_rem.at(i) << " ";
        ans_rem.push_back(rem_rem.at(i));
    } 
    
    for(int i = 0; i < ans_rem.size(); i++){
        ans += ans_rem.at(i);
        while(ans % 10 != 0){
            if(i == 4)
                break;
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

string s;
int main() {
	cin >> s;
	int ret=1;
	int pre=0;
	for(int i=1;i<s.size();i++){
		if(s[i-1]!=s[i]){
			ret=max(ret,min(i,(int)s.size()-pre));
			ret=max(ret,i-pre);
			pre=i;
		}
	}
	ret=max(ret,(int)s.size()-pre);
	cout << ret << endl;


	return 0;
}



Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{	
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	long a = Long.parseLong(sc.next());
	long b = Long.parseLong(sc.next());
	long c = Long.parseLong(sc.next());
	long d = Long.parseLong(sc.next());
	long s = 0;
	
	
	if(c!=d){
		long z = lcm(c,d);
		long x = b/c - (a-1)/c;   
		long y = b/d - (a-1)/d;
		long w = b/z - (a-1)/z;
		s = b-a+1-x-y+w;
	}else{
		long x = b/c - (a-1)/c;
		s = b-a+1-x;
	}	
	
	
	System.out.println(s);
}
private static long lcm(long a, long b){ 	
	return a*b/gcd(a,b);
}
private static long gcd(long a, long b){
	if(a<b) return gcd(b,a);
	if(b==0)return a;
	return gcd(b,a%b);
}
}


Measured memory_bytes: 22612
def main():
    S = input()
    # my swapcase
    for s in S:
        o = ord(s)
        if 97 <= o < 97 + 26:
            o -= 32
        elif 65 <= o < 65 + 26:
            o += 32

        print(chr(o), end="")
    print("")

if __name__ == "__main__":
    main()

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

typedef long long ll;
bool p(string& s) {
	bool y = 1;
	for (int i=0; i<=(int)s.size()/2; i++) y&=s[i]==s[(int)s.size()-i-1];
	return y;
}
int main() {
	string s;
	cin >> s;
	int n = s.size();
	bool y = 1;
	y &= p(s);
	string l = s.substr(0,n/2);
	y &= p(l);
	// cout << l << '\n';
	s.erase(s.begin(),s.begin()+n/2+1);
	// cout << s << '\n';
	y &= p(s);
	cout << (y ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3588