akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
const int INF = 2100000000;

class Heap{
  public:
    vector<int> a;
    Heap(int n){
      a.resize(n+1, INF);
    }

    int get_parent(int x){
      return a[(x)/2];
    }

    int get_left(int x){
      if(x*2 < a.size()-1){
        return a[x*2];
      }
      return INF;
    }

    int get_right(int x){
      if(x*2+1 < a.size()-1){
        return a[x*2+1];
      }return INF;
    }

    void print(){
      cout << "debug print " << endl;
      for(int j = 1; j < a.size(); ++j){
        cout << " " << a[j];
      }cout << endl;
    }

  void mx(int i){
    int l = i*2;
    int r = i*2+1;
    int largest = INF;

    if(l < a.size() && a[l] > a[i]){
      largest = l;
    }else{
      largest = i;
    }

    if(r < a.size() && a[r] > a[largest])
        largest = r;

    if(largest != i){
      swap(a[i], a[largest]);
      mx(largest);
    }
  }

  void rmx(int i){
    int parent;
    int largest = INF;

    while(1){
      parent = i/2;
      if(parent < 1)
        break;

      if(a[parent] < a[i]){
        swap(a[parent], a[i]);
        i = parent;
        continue;
      }
      break;
    }
  }


  void buildMXHeap(){
    for(int i = (a.size()-1)/2; i > 0; --i)
      mx(i);
  }

  void insert(int x){
    a.push_back(x);
    rmx(a.size()-1);
  }

  int extract(){
    int tmp = a[1];
    a[1] = a[a.size()-1];
    a[a.size()-1] = INF;
    a.pop_back();
    mx(1);
    return tmp;
  }
};




int main(void){
  int n, a;
  string str;
  Heap hp(0);

  while(1){
    cin >> str;
    if(str == "insert"){
      cin >> a;
//       cout << "INSERT" << endl;
      hp.insert(a);
    }else if(str == "extract"){
//       cout << "EXTRACT " << endl;
      cout << hp.extract() << endl;
    }else{
      break;
    }
//     cout << "end instruction " << endl;
//    hp.print();
  }

//   for(int i = 1; i < n; ++i){
//     cout << "node " << i << ": key = " << hp.a[i];
//     if(hp.get_parent(i) != INF){
//       cout << ", parent key = " << hp.get_parent(i);
//     }
//     if(hp.get_left(i) != INF){
//       cout << ", left key = " << hp.get_left(i);
//     }
//     if(hp.get_right(i) != INF){
//       cout << ", right key = " << hp.get_right(i);
//     }
//     cout << ", " << endl;
//   }

//   buildMXHeap(hp);
//   hp.print();
  return 0;
}

Measured memory_bytes: 6952
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int Height, Width, h, w;
    cin >> Height >> Width >> h >> w;

    int r;
    r = Height * Width - (Height * w + Width * h) + h * w;
    printf("%d\n",r);
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string minstr(string a, string b) {
    if (a.length() == 0) return b;
    if (b.length() == 0) return a;
    if (a.length() != b.length()) {
        return a.length() < b.length() ? a : b;
    }
    return min(a, b);
}

int main() {
    int N;
    while (cin >> N, N) {
        vs S;
        vs in(N);
        REP(i, N) cin >> in[i];
        SORT(in);
        in.erase(unique(ALL(in)), in.end());
        N = SZ(in);
        REP(i, N) {
            bool ok = true;
            REP(j, N) {
                if (i == j) continue;
                if (in[j].find(in[i]) != string::npos) {
                    ok = false;
                    break;
                }
            }
            if (ok) S.push_back(in[i]);
        }

        N = SZ(S);
        vector<vs> tail(N, vs(N));
        REP(i, N) REP(j, N) {
            if (i == j) continue;
            RREP(k, S[i].length()) {
                if (k < (int)S[j].length()) {
                    bool ok = true;
                    REP(l, k) {
                        if (S[i][S[i].length()-k+l] != S[j][l]) {
                            ok = false;
                            break;
                        }
                    }
                    if (ok) {
                        tail[i][j] = S[j].substr(k);
                        break;
                    }
                }
            }
        }

        vector<vs> dp(N, vs(1<<N));
        REP(i, N) {
            dp[i][1<<i] = S[i];
        }

        REP(X, 1<<N) {
            REP(i, N) if (BIT(X, i)) {
                REP(j, N) if (!BIT(X, j)) {
                    dp[j][X|(1<<j)] = minstr(dp[j][X|(1<<j)], dp[i][X] + tail[i][j]);
                }
            }
        }
        int mi = 1000000;
        REP(i, N) {
            mi = min(mi, (int)dp[i][(1<<N)-1].length());
        }
        cout << mi << endl;
    }
}

Measured memory_bytes: 32560
#include<stdio.h>

char s[300000],t[300000];

int main(void){

    int i,cnt = 0;

    scanf("%s %s",s,t);

    for(i = 0; s[i] != '\0'; i++){
        if(s[i] != t[i])
            cnt++;
    }

    printf("%d\n",cnt);

}

Measured memory_bytes: 2116
import math
import itertools

if __name__ == '__main__':
    n = int(input())

    ra = range(math.floor(n / 4) + 1)
    rb = range(math.floor(n / 7) + 1)
    prod = list(itertools.product(ra, rb))

    for a, b in prod:
        if 4 * a + 7 * b == n:
            print('Yes')
            exit(0)

    print('No')


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        long a = 2 * (n / 11), b = n % 11;
        if (b >= 7)
        {
            a += 2;
        }
        else if (b < 7)
        {
            if (b != 0)
                a += 1;
        }
        Console.WriteLine(a);
    }
}



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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>12)
    {
        cout<<12;
    }
   else{
        if(a<=b){
            printf("%d",a);
        }
        else{
            printf("%d",a-1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------


int main(int argc,char** argv){ fastio; myio;
  string s,t;
  cin>>s>>t;
  int ss = s.length();
  int ts = t.length();
  if(ss<ts){  cout<<"UNRESTORABLE"; return 0;}
  drep(i,ss+1-ts){
    string k = s.substr(i,ts);
    // cout<<k<<endl;
    bool f = true;
    rep(j,ts){
      if( k[j]!='?' and k[j]!=t[j]) f = false;
    }
    if(f){
      rep(j,ts){
        s[i+j]=t[j];
      }
      rep(j,ss){
        if(s[j]=='?') s[j]='a';
      }
      cout<<s; return 0;
    }
  }
  cout<<"UNRESTORABLE";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (long long int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;
int cnt = 0;
int main()
{
    int l;
    cin >> l;
    printf("%.12f\n", (double)l * l * l / 27);

    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;

struct node {
    int x, y, steps;
};

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int n, m, map[1005][1005], vis[1005][1005], num, stx, sty;

int bfs() {
    int tot = 0;
    for (int i = 1; i <= num; i++) {
        memset(vis, 0x3f, sizeof vis);
        vis[stx][sty] = 0;
        queue<node> q;
        q.push({ stx, sty, 0 });
        while (!q.empty()) {
            node cnt = q.front(); q.pop();
            if (map[cnt.x][cnt.y] == '0' + i) {
                tot += cnt.steps;
                stx = cnt.x; sty = cnt.y;
                break;
            }
            for (int k = 0; k < 4; k++) {
                int nx = cnt.x + dx[k];
                int ny = cnt.y + dy[k];
                if (nx < 0 || ny < 0 || nx >= n || ny >= m) continue;
                if (map[nx][ny] == 'X' || vis[nx][ny] <= cnt.steps + 1) continue;
                vis[nx][ny] = cnt.steps + 1;
                q.push({ nx, ny, cnt.steps + 1 });
            }
        }
    }
    return tot;
}

int main() {
    scanf("%d %d %d", &n, &m, &num);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            char ch = getchar();
            if (ch == '\n') ch = getchar();
            if (ch == 'S') { stx = i; sty = j; }
            map[i][j] = ch;
        }
    cout << bfs() << endl;
    return 0;
}



Measured memory_bytes: 11096
import java.util.Scanner;	
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int k = stdIn.nextInt();
			if(n + k == 0) break;
			
			int[] ary = new int[k];
			for(int r = 0; r < k; r++) {
				ary[r] = stdIn.nextInt();
			}
			boolean flag = true;
			for(int r = 0; r < n; r++) {
				for(int c = 0; c < k; c++) {
					int blood = stdIn.nextInt();
					ary[c] -= blood;
					if(ary[c] < 0) flag = false;
				}
			}
			
			if(flag) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}

Measured memory_bytes: 96980
program main
 implicit none
 integer*8 N,K,i,ans,one
 integer*8, allocatable::d(:)
 data one /1D0/
 read(*,*) N
 allocate( d(1:N) )
 read(*,*) d
 if(mod(N,2) /= 0) then
  write(*,*) 0
 else
  call quicksort(d,one,N) 
  K = N / 2
  ans = d(K+1) - d(K)
  if(K+1 <= N) then
   if(d(K) == d(K+1)) then
    ans = 0
   end if
  end if
  write(*,*) ans
 end if
contains
 recursive subroutine quicksort(a, first, last)
  implicit none
  integer*8  a(*)
  integer*8 first, last, i, j, x, t
  
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
 end subroutine quicksort
end program main
   

Measured memory_bytes: 1536
#include <iostream>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

int n;
long long h[100100];
long long dp[100100];

long long rec(int i) {
    if (dp[i] < INF) return dp[i];

    if (i == 0) return 0;

    long long res = INF;
    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
    if (i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));

    return dp[i] = res;
}

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

    for (int i = 0; i < 100100; i++) dp[i] = INF;

    cout << rec(n - 1) << endl;
    return 0;
}

Measured memory_bytes: 6528
n, k, s = map(int, input().split())
ans_1 = [s] * k
len_ans2 = n - k

if s == 10**9:
    ans_2 = [s-1] * len_ans2
else:
    ans_2 = [s+1] * len_ans2

ans = ans_1 + ans_2
print(*ans)

Measured memory_bytes: 7380
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	rep(i,n){
		string a,b;
		cin>>a>>b;
		if(a.size()<b.size())swap(a,b);
		while(a.size()!=b.size())b="0"+b;
		for(int i=a.size()-1;i>=0;i--){
			a[i]+=b[i]-'0';
			if(a[i]>'9'){
				a[i]-=10;
				if(i)a[i-1]++;
				else a="1"+a;
			}
		}
		if(a.size()>80)cout<<"overflow"<<endl;
		else cout<<a<<endl;
	}
}

Measured memory_bytes: 1216
import sys
N = int(input())
A = list(map(int, input().split()))
if min(A) == 0:
    print(0)
    sys.exit(0)

ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        sys.exit(0)
print(ans)

Measured memory_bytes: 21652
#include<bits/stdc++.h>
#define F first
#define S second
#define LL long long
#define MP make_pair
#define PB push_back
#define I insert

const LL mod=1000000007, N=200005;
using namespace std;

LL n, m, i, j, k, l, r, t, ans;
LL a[11][1001], b[11];
char c;

void bem(){
	for ( LL i = 0; i < 10; ++i ) b[i] = 0;
}

int main(){
	cin >> n >> m >> k;
	ans = mod;
	for ( i = 0; i < n; ++i ){
		for ( j = 0; j < m; ++j ){
			cin >> c;
			a[i][j] = c - '0';
		}
	}
	for ( i = 0; i < (1<<(n-1)); ++i ){
		t = i;
		vector < LL > v;
		for ( j = 0; j < n - 1; ++j ){
			if ( t % 2 == 0 ) v.PB(j);
			t /= 2;
		}
		bem();
		l = v.size();
		v.PB(n-1);
		for ( j = 0; j < m; ++j ){
			LL w = 0;
			for ( r = 0; r < v.size(); ++r ){
				LL p = 0;
				while ( w <= v[r] ) p += a[w++][j];
				if ( b[r] + p > k ) {
					l++;
					bem();
					break;
				}
			}
			w = 0;
			for ( r = 0; r < v.size(); ++r ){
				while ( w <= v[r] ) b[r] += a[w++][j];
				if ( b[r] > k ) {
					l = mod;
					break;
				}
			}			
		}
		ans = min ( ans, l );/*/
		if ( l == 0 ){
			cout << i << " " << endl;
			for ( LL f = 0; f < v.size(); ++f ) cout << v[f] << " " << b[f] << endl;
		}/**/
	}
	cout << ans << endl;

	return 0;
}
//      IIIIIIIII      OOOOO             A          NN        N    EEEEEEEEEE
//          I         O     O           A A         N N       N    E
//          I        O       O         A   A        N  N      N    E
//          I        O       O        A     A       N   N     N    E
//          I        O       O       AAAAAAAAA      N    N    N    EEEEEEEE
//          I        O       O      A         A     N     N   N    E
//          I        O       O     A           A    N      N  N    E
//          I         O     O     A             A   N       N N    E
//      IIIIIIIII      OOOOO     A               A  N        NN    EEEEEEEEEE ___ KAPANADZE




Measured memory_bytes: 384
//#include<iostream>
//#include<string>
#include<iostream>
#include<string>
#include<math.h>

using namespace std;
//using namespace std;
//using namespace std;

int main(){
    int N,L,SUM_N = 0;
    int min = 500,A;
    int SUM[256];
    cin >> N ;
    cin >> L;
    for(int i=1;i<=N;i++){
        SUM_N = SUM_N + (L + i -1); 
    }
    for(int i=0;i<N;i++){
        SUM[i] = 0;
        for(int j=1;j<=N;j++){
            SUM[i] = SUM[i] + (L + j - 1);
        }
        SUM[i] = SUM[i] - (L + (i + 1) - 1);
    }
    for(int i=0;i<N;i++){
        if(min>abs(SUM_N-SUM[i])){
            min = abs(SUM_N - SUM[i]);
            A = i;
        }
    }

    cout << SUM[A] << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
S = list(input())
X = ["A","C","G","T"]

max_len = 0
cur = 0

for i in S:
    if i in X: cur += 1
    else:
        if cur> max_len:
            max_len = 0
            max_len +=cur
            cur = 0
        else:
            cur = 0

if cur > max_len:
    print(cur)
    sys.exit()

print(max_len)

Measured memory_bytes: 9040
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] = (A[i] - 1) % K;
	}
	vector<int> S(N + 1);
	for (int i = 0; i < N; ++i) {
		S[i + 1] = (S[i] + A[i]) % K;
	}
	map<int, int> d;
	long long ans = 0;
	for (int i = 0; i <= N; ++i) {
		++d[S[i]];
		if (i >= K) --d[S[i - K]];
		ans += d[S[i]] - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
import re
c=0
s=''
p=input().upper()
ptn=re.compile(r'^'+p+r'$')

while True:
    s=input()
    if s =='END_OF_TEXT':
        break
    a=s.upper().split()
    for i in a:
        if re.match(ptn, i):
            c+=1
print(c)

Measured memory_bytes: 7616
h, w = gets.chomp.split.map(&:to_i)
map = []
h.times{map << gets.chomp}
arr = Array.new(h+1){Array.new(w+1){[0,0]}}

sum = 0
(h-1).downto(0){|j|
    (w-1).downto(0){|i|
        arr[j][i][0] = arr[j][i+1][0]
        arr[j][i][1] = arr[j+1][i][1]
        case map[j][i]
        when "J"
            sum += arr[j][i][0] * arr[j][i][1]
        when "O"
            arr[j][i][0] += 1
        when "I"
            arr[j][i][1] += 1
        end
    }
}
puts sum


Measured memory_bytes: 698912
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
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

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int dp[10001];
int AB[10001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H = getint(), N = getint();
	rep1(i, 10000) dp[i] = 1e9;
	rep1(i, 10000) AB[i] = 2e9;

	rep(i, N) {
		int a = getint(), b = getint();
		chmin(AB[a], b);
	}

	double saikou = 1e20;
	rep1(i, 10000) {
		int k = AB[i];
		if (k < 1e9) {
			int ima = k;
			for (int j = i + i; j <= 10000; j += i) {
				ima += k;
				if (AB[j] >= ima) AB[j] = 2e9;
			}
			chmin(saikou, 1.0 * k / i);
		}
	}

	int kotae = 2e9;
	for (int i = 10000; i >= 1; i--) {
		int k = AB[i];
		if (k < 1e9) {
			double kouritu1 = 1.0 * k / i;
			double kouritu2 = 1.0 * kotae / H;
			double are = H * (kouritu1 - kouritu2) / (kouritu1 - saikou);
			int sita = max(0, int(are));

			auto dp2 = dp + i;
			int kazu = max(0, H - i);
			for (int j = 0; j < kazu; j++) if (dp2[j] > dp[j] + k) dp2[j] = dp[j] + k;
			for (int j = max(sita, kazu); j <= H; j++) if (kotae > dp[j] + k) kotae = dp[j] + k;
		}
	}
	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    for i in range(N*2):
        s = S[i]
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
X = int(input())
if X >=400 and X <=599:
    print(8)
elif X >=600 and X <=799:
    print(7)
elif X >=800 and X <=999:
    print(6)
elif X >=1000 and X <=1199:
    print(5)
elif X >=1200 and X <=1399:
    print(4)
elif X >=1400 and X <=1599:
    print(3)
elif X >=1600 and X <=1799:
    print(2)
else:
    print(1)

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

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

    int a = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') {
            a++;
        }
    }

    if (a + (15 - s.size()) >= 8) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int a, b;
    
    cin >> a >> b;
    if(a % 2 == 1 && b % 2 == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll r,c;
     char arr[55][55];
     cin>>r>>c;
     for(int i=0;i<=r+1;i++)
     {
         for(int j=0;j<=c+1;j++)
         {
             arr[i][j]='.';
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             cin>>arr[i][j];
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             if(arr[i][j]=='.')
             {
                 ll cnt;
                 cnt=(arr[i-1][j-1]=='#')+(arr[i-1][j]=='#')+(arr[i-1][j+1]=='#')+(arr[i][j-1]=='#')+(arr[i][j+1]=='#')+(arr[i+1][j-1]=='#')+(arr[i+1][j]=='#')+(arr[i+1][j+1]=='#');
                 arr[i][j]=cnt+48;
             }
         }
     }
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             cout<<arr[i][j];
         }
         cout<<endl;
     }
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <list>

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<const int, int> pii;

const int MAXN = 1e5 + 1;
const int inf = 1e9 + 5;
const long double eps = 1e-8;

vector<int> g[MAXN];
set<int> s[MAXN];

void removeNode(map<int, int> &q, int v) {
    for (int i = 0; i < g[v].size(); i++) {
        if (q.find(g[v][i]) != q.end()) {
            int c = q[g[v][i]];
            s[c].erase(g[v][i]);
            s[c - 1].insert(g[v][i]);
            q[g[v][i]]--;
        }
    }
    s[q[v]].erase(v);
    q.erase(v);
}

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

    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    map<int, int> q;

    for (int i = 0; i < n; i++) {
        q[i] = g[i].size();
        s[g[i].size()].insert(i);
    }

    while (!q.empty()) {
        if (!s[0].empty()) {
            cout << "First";
            return 0;
        }
        int v;
        if (!s[1].empty()) {
            v = *(s[1].begin());
        } else
            return 13;

        for (int i = 0; i < g[v].size(); i++) {
            if (q.find(g[v][i]) != q.end()) {
                removeNode(q, g[v][i]);
            }
        }
        s[q[v]].erase(v);
        q.erase(v);
    }

    cout << "Second";

    return 0;
}

Measured memory_bytes: 19968
import sys
from itertools import combinations_with_replacement,product
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    li=[]
    for i in range(n):
        lia=[]
        A=int(input())
        for j in range(A):

            x,y=map(int, input().split())
            x-=1
            lia.append([x,y])
        li.append(lia)
    ans = 0
    for k in list(product([0,1],repeat=n)):
        if ans >= sum(k):
            continue
        kt = list(k)
        for y in range(n):
            if kt[y]==1:
                for g in li[y]:
                    if g[1] != kt[g[0]]:
                        break
                else:
                    continue
                break
        else:
            ans = sum(k)
            
    print(ans)



if __name__=='__main__':
    main()

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

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

    bool cof = false;

    if(s[2] == s[3]){
        cof = true;
    }
    if(s[4] == s[5]){
    }else{
        cof = false;
    }

    if(cof){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n;
ll a[N],b[N],sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a[i]);
		a[i]*=2;
		if(i&1)sum+=a[i];
		else sum-=a[i];
	} 
	sum/=2;//b[1]
	b[1]=sum;
	for(int i=1;i<=n;++i)
	b[i+1]=a[i]-b[i];
	for(int i=1;i<=n;++i)
	printf("%lld%c",b[i]," \n"[i==n]);
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    double a[n];
    double sum = 0;
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
        sum += a[i];
    }
    sum /= n;
    double diff = abs(a[0] - sum);
    int k = 0;
    for(int i = 1 ; i< n ; i++ ){
        if(abs(sum - a[i]) < diff){
            diff = abs(sum - a[i]);
            k = i;
        }
    }
    cout<<k<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Data
{
public:
    int t, c, tRest;
    Data(){}
    Data(int t0, int c0){
        t = tRest = t0;
        c = c0;
    }
    bool operator<(const Data& d) const{
        return t < d.t;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<Data> d(n);
        for(int i=0; i<n; ++i){
            int t, c;
            cin >> t >> c;
            d[i] = Data(t, c);
        }
        sort(d.begin(), d.end());

        deque<Data> lane1, lane2;
        for(int i=0; i<n; ++i)
            lane1.push_back(d[i]);

        int ret = 0;
        while(!lane1.empty() || !lane2.empty()){
            ++ ret;
            for(unsigned i=0; i<lane1.size(); ++i)
                -- lane1[i].tRest;
            for(unsigned i=0; i<lane2.size(); ++i)
                -- lane2[i].tRest;
            if(lane1.size() > 0 && lane1[0].tRest == 0){
                vector<Data> d;
                while(!lane1.empty() && lane1[0].tRest <= 0){
                    lane1[0].tRest = lane1[0].t;
                    d.push_back(lane1[0]);
                    lane1.pop_front();
                }
                sort(d.begin(), d.end());
                for(unsigned i=0; i<d.size(); ++i)
                    lane2.push_back(d[i]);
            }
            if(lane2.size() > 0 && lane2[0].tRest == 0){
                vector<Data> d;
                while(!lane2.empty() && lane2[0].tRest <= 0){
                    -- lane2[0].c;
                    if(lane2[0].c > 0){
                        lane2[0].tRest = lane2[0].t;
                        d.push_back(lane2[0]);
                    }
                    lane2.pop_front();
                }
                sort(d.begin(), d.end());
                for(unsigned i=0; i<d.size(); ++i)
                    lane1.push_back(d[i]);
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 920
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

int memo[110000];

int rec(int n) {
	if (n == 0) return 0;
	if (memo[n] != -1) return memo[n];

	int res = n;
	for (int i = 1; i <= n; i *= 6)res = min(res, rec(n - i) + 1);
	for (int j = 1; j <= n; j *= 9)res = min(res, rec(n - j) + 1);
	
	return memo[n] = res;
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < 110000; i++)memo[i] = -1;

	cout << rec(n) << endl;

	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int ds(int x) {
    int sum = 0;
    while (x > 0) { sum += x % 10; x /= 10; }
    return sum;
}

int main(int argc, char** argv) {
    int n; cin >> n;
    int ans = 100000;
    for (int a = 1; a < n; a++) {
        int b = n - a;
        ans = min(ans, ds(a) + ds(b));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
var
  sum,i,j:longint;
  s:ansistring;
  a:array[0..100000] of longint;
begin
  readln(s);
  for i:=1 to length(s) do
  begin
    if s[i]='1' then begin inc(sum);a[sum]:=1;end
      else if s[i]='0' then begin inc(sum);a[sum]:=0;end
      else if sum<>0 then sum:=sum-1;
  end;
  for i:=1 to sum do write(a[i]);
  writeln;
end.

Measured memory_bytes: 128
import math
A, B, H, M = map(int, input().split())
h = 30 * H + M / 2
m = 6 * M
alpha = abs(h-m)

if alpha > 180:
    alpha = 360 - alpha

theta = 2 * math.pi * alpha / 360
ans = (A**2 + B ** 2 - 2 * A * B * math.cos(theta))**0.5

print("{:.15f}".format(ans))


Measured memory_bytes: 9512
#include<bits/stdc++.h>
#define WR "txt"

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
int Read()  {
	int val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

struct Node  {
	string s;
	int v, id;
	bool operator < (const Node b)  {
		if (s != b.s) return s < b.s;
		return v > b.v;
	}
}a[105];

int n;

void work()  {
	n = Read();
	for (int i = 1;i <= n; i++)  {
		cin >> a[i].s >> a[i].v;
		a[i].id = i;
	}
	sort(a + 1, a + 1 + n);
	for (int i = 1;i <= n; i++)  
		printf("%d\n", a[i].id);
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()

t = [0] * (N+2)
t[0] = 1 if S[:2] == 'AC' else 0

for i in range(N-1):
    t[i+1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for _ in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1]) 

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

int main(void) {
	int i,l;
	char N[ 200000 ];
	int total=0;

	scanf("%s", N);
	l = strlen(N);
	for (i = 0; i < l ; i++) {
		total += N[i] -'0';
	}

	if (total % 9 == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}


Measured memory_bytes: 1864
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll a,b; cin>>a>>b;
		cout<<a*b;
	}

	signed main()
	{

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

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int i;
    long long ans = 0;
    for(i = 1; i <= N; ++i){
        if(i % 3 == 0 || i % 5 == 0){ continue; }
        ans += i;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1736
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long h = sc.nextLong();
        long[] a = new long[n];
        long[] b = new long[n];
        long amax = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            amax = Math.max(amax, a[i]);
        }
        Arrays.sort(b);
        int bcnt = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (amax > b[i]) {
                break;
            }
            bcnt++;
        }
        long ans = 0;
        int i = bcnt;
        while (h > 0 && i > 0) {
            h -= b[n - bcnt + i - 1];
            i--;
            ans++;
        }
        while (h > 0) {
            h -= amax;
            ans++;
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 67656
N, M = map(int, input().split())
G = [[0 for i in range(N)] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1][b - 1] += 1
    G[b - 1][a - 1] += 1
for i in range(N):
    s = 0
    for j in range(N):
        s += G[i][j]
    print(s)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N;
string S;
// set<int> ans;
int main() {
    cin >> N;
    cin >> S;
    int res = 0;
    for(int i = 0; i < 1000; i++) {
        int f = i % 10;
        int s = (i/10) % 10;
        int t = (i/100) % 10;
        bool flag = false;
        bool flag2 = false;
        bool isFinish = false;
        rep(j, S.size()) {
            if(isFinish) continue;

            if(f == (S[j] - '0') && flag2) {
                if(flag) {
                    res++;
                    isFinish = true;
                }
            }
            if(s == (S[j] - '0') && flag) {
                flag2 = true;
            }
            if(t == (S[j] - '0')) {
                flag = true;
            }

        }

    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,s;

int main(){
    while(true){
        cin >> n >> m >> s;
        if(n==0){
            break;
        }
        int mod=pow(10,5);
        n=pow(n,2);
        m-=n;
        s-=(n*(n+1))/2;
        int m3=min(max((s+1)/n+1,1),m);
        vector<vector<int>> dp(s+1,vector<int>(m3+1,0));
        dp[0][0]=1;
        for(int i=0;i<n;i++){
            int m2=min(max((s+1)/(n-i)+1,1),m);
            vector<vector<int>> dp2(s+1,vector<int>(m2+1,0));
            for(int j=0;j<s+1;j++){
                for(int k=0;k<m3+1;k++){
                    if(j+k<=s){
                        dp2[j+k][k]+=dp[j][k];
                    }
                }
            }
            for(int l=-(m2+1);l<s+2;l++){
                for(int j=max(0,l)+1;j<min(s,m2+l)+1;j++){
                    dp2[j][j-l]=(dp2[j][j-l]+dp2[j-1][j-l-1])%mod;
                }
            }
            dp=dp2;
            m3=m2;
        }
        cout << accumulate(dp[s].begin(),dp[s].end(),0)%mod << endl;
    }
}


Measured memory_bytes: 27608
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int d[1000][1000];

void warshall_floyd(int n){
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

struct edge{
	long long int to, cap, rev; // 
};

#define MAX_V 2100

vector<edge> G[MAX_V] = {};
bool used[MAX_V];

// 
void add_edge(long long int from, long long int to, long long int cap){
	G[from].push_back((edge){to, cap, (long long int)G[to].size()});
	G[to].push_back((edge){from, 0, (long long int)G[from].size() - 1}); // 
	// G[to].push_back((edge){from, cap, G[from].size() - 1}); // 
}

// 
long long int dfs(int v, int t, long long int f){
	if(v == t){
		return f;
	}
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			long long int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// 
long long int max_flow(int s, int t){
	long long int flow = 0;
	while(true){
		fill(used, used + MAX_V, 0);
		long long int f = dfs(s, t, INF);
		if(f == 0){
			return flow;
		}
		flow += f;
	}
}

int main(){
    while(true){
        int N, M, L;
        cin >> N >> M >> L;
        if(N == 0){
            break;
        }
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
        for(int i = 0; i < M; i++){
            int u, v, d_;
            cin >> u >> v >> d_;
            d[u][v] = d[v][u] = d_;
        }
        warshall_floyd(N);
        long long int p[1100], t[1100];
        for(int i = 0; i < L; i++){
            cin >> p[i] >> t[i];
        }
        for(int i = 0; i < MAX_V; i++){
            G[i].clear();
        }
        for(int i = 1; i <= L; i++){
            add_edge(0, i, 1);
            add_edge(i + L, 2 * L + 1, 1);
        }
        for(int i = 0; i < L; i++){
            for(int j = 0; j < L; j++){
                if(i != j && t[j] - t[i] >= d[p[i]][p[j]]){
                    add_edge(i + 1, j + 1 + L, 1);
                }
            }
        }
        cout << L - max_flow(0, 2 * L + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 50352
// Coordinate compression

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
 
#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)

int a[100010][3],n,k;
int dp[100010][3];

int fun(int x,int y)
{
  if(x>n)return 0;
  if(dp[x][y]!=-1)return dp[x][y];
  int ret=0;
  rep(j,0,3)
  {      
        if(y!=j)
        ret=max(ret,a[x][y]+fun(x+1,j));
  }
  dp[x][y]=ret;
  return ret;
  
}


int solve(){     

memset(dp,-1,sizeof(dp));
cin>>n;
rep(i,1,n+1)
rep(j,0,3)cin>>a[i][j];
cout<<max({fun(1,0),fun(1,1),fun(1,2)});

return 0;
}

 
signed main()
{    


   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);  

 
 int t=1;                                                                                                                  
 //cin>>t;
    while(t--)
     {
      solve();
     }
    return 0;
}

Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
typedef long long ll;
using namespace std;
struct point_t { double x, y; };
bool operator < (point_t const & a, point_t const & b) { return make_pair(a.x,a.y) < make_pair(b.x,b.y); }
point_t operator + (point_t const & a, point_t const & b) { return { a.x + b.x, a.y + b.y }; }
point_t operator - (point_t const & a, point_t const & b) { return { a.x - b.x, a.y - b.y }; }
double cross(point_t const & a, point_t const & b) { return a.x * b.y - a.y * b.x; }
double ccw(point_t const & a, point_t const & b, point_t const & c) { return cross(b - a, c - a); }
vector<point_t> convex_hull(vector<point_t> ps) {
    int n = ps.size();
    sort(ps.begin(), ps.end());
    vector<point_t> ch(2*n);
    int k = 0;
    for (int i = 0; i < n; ch[k++] = ps[i++]) { // lower hull
        while (k >= 2 and ccw(ch[k-2], ch[k-1], ps[i]) <= 0) -- k;
    }
    const int t = k+1;
    for (int i = n-2; i >= 0; ch[k++] = ps[i--]) { // upper hull
        while (k >= t and ccw(ch[k-2], ch[k-1], ps[i]) <= 0) -- k;
    }
    ch.resize(k-1);
    return ch;
}
int solve(vector<point_t> const & ps) {
    vector<point_t> qs = convex_hull(ps);
    return ps.size() - qs.size();
}
int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        vector<point_t> ps(n);
        char dummy;
        for (auto && p : ps) cin >> p.x >> dummy >> p.y;
        cout << solve(ps) << endl;
    }
    return 0;
}

Measured memory_bytes: 1268
K,N=gets.split.map(&:to_i)
A=gets.split.map(&:to_i)
d=(A+A.map{|i|i+K}).each_cons(2).map{|l,r|r-l}
a=s=d[0...N-1].sum
N.times do |i|
  s-=d[i]
  s+=d[i+N-1]
  a=[a,s].min
end
p a


Measured memory_bytes: 35548
n = gets.to_i
ans = ""
i = 1
while n != 0
  if n%2 == 0
    ans += "0"
  else
    ans += "1"
    n -= i
  end
  n /= 2
  i = i == 1 ? -1 : 1
end
puts ans.reverse.to_i

Measured memory_bytes: 1788
program main
      implicit none
      integer(16) :: h
      integer(8) :: k, a, ppow

      read *, h

      if ( h == 1 ) then
         print *, '1'
      else
        k = 0
        do
          h = h/2
          k = k + 1
          if ( h == 1 ) exit
        end do
        a = 2
        call pow(a,k+1,ppow)
        print *, ppow - 1 
      end if

contains
subroutine pow(a, n, ppow)
        implicit none
        integer(8), intent(in) :: a, n
        integer(8), intent(out) :: ppow
        integer(8) :: ntmp, atmp

        ppow = 1
        atmp = a
        ntmp = n
        do while ( ntmp > 0 )
          if ( iand(ntmp,1) > 0 ) then
            ppow = ppow * atmp
          end if
          atmp = atmp * atmp
          ntmp = ishft( ntmp, -1 )
        end do

end subroutine pow

end program main


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>

using namespace std;

const int N = 4e5 + 10;
int n, a[N], b[N], cnta[N], cntb[N], ans[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnta[a[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        cntb[b[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        if (cnta[i] + cntb[i] > n) {
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i = 1; i <= n; i++) ans[i] = b[n - i + 1];
    for (int i = 1; i <= n;i++) {
        if (ans[i] == a[i]) {
            int pt = 0;
            while (i + pt <= n && ans[i + pt] == a[i + pt]) pt++;
            pt--;
            for (int j = 1; j <= n; j++) {
                if (a[j] != a[i] && ans[j] != ans[i]) {
                    swap(ans[j], ans[i + pt]);
                    pt--;
                    if (pt < 0) break;
                }
            }
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) cout << ans[i] << " ";
    cout << ans[n] << endl;
    return 0;
}

Measured memory_bytes: 7476
#include<iostream>
#include<algorithm>
using namespace std;
#define chmax(p,q)(p=max(p,q))
long long R,C,K,r,c,v;
long long map[3000][3000],dp[3000][3000][4];
int main(){
    cin>>R>>C>>K;
    for(int i=0;i<K;i++){
        cin>>r>>c>>v;
        map[r-1][c-1]=v;
    }
    dp[0][0][1]=map[0][0];
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            if(i){
                chmax(dp[i][j][0],max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]}));
                chmax(dp[i][j][1],dp[i][j][0]+map[i][j]);
            }
            if(j){
                for(int k=0;k<4;k++)chmax(dp[i][j][k],dp[i][j-1][k]);
                for(int k=0;k<3;k++)chmax(dp[i][j][k+1],dp[i][j-1][k]+map[i][j]);
            }
        }
    }
    cout<<max({dp[R-1][C-1][0],dp[R-1][C-1][1],dp[R-1][C-1][2],dp[R-1][C-1][3]})<<endl;
    return 0;
}

Measured memory_bytes: 355128