akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int longestCommonSubsequence(string text1, string text2, vector<vector<int>>& dp) {
  for (int i = 1; i <= text1.size(); i++) {
    for (int j = 1; j <= text2.size(); j++) {
      if (text1[i-1] == text2[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      dp[i][j] = max(dp[i][j], max(dp[i][j-1], dp[i-1][j]));
    }
  }
  return dp[text1.size()][text2.size()];
}

int main() {
  string s1, s2; cin >> s1 >> s2;
  vector<vector<int>> dp(s1.size()+1, vector<int>(s2.size()+1, 0));
  int count = longestCommonSubsequence(s1, s2, dp); string s = "";
  int i = s1.size(), j = s2.size();
  while (i > 0 && j > 0) {
    if (dp[i-1][j-1]+1 == dp[i][j] && dp[i-1][j]+1 == dp[i][j] && dp[i][j-1]+1 == dp[i][j]) {
      i--; j--; 
      s = s1[i] + s;
    }
    else if (dp[i][j-1] > dp[i-1][j]) {
      j--;
    } else {
      i--;
    }
  }
  cout << s << endl;

  // for (int i = 0; i <= s1.size(); i++) {
  //   for (int j = 0; j <= s2.size(); j++) {
  //     cout << dp[i][j] << ' ';
  //   }
  //   cout << endl;
  // }

  return 0;
}

Measured memory_bytes: 35584
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define VMAX 102
#define EMAX 9905
#define INF (long long)1e18

//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

ll V,E,ans,d[VMAX][VMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
dy[8] = {1,1,0,-1,-1,-1,0,1};

struct edge{
	ll to,cost;
};
vector<edge> G[VMAX];

void solve(){
	for (int i = 0; i < V; ++i)
	{
		for (int j = 0; j < V; ++j)
		{
			for (int k = 0; k < V; ++k)
			{
				if(d[j][i] != INF && d[i][k] != INF){
					d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
				}
			}
		}
	}
}

void debug(){

}

int answer(){
	for (int i = 0; i < V; ++i)
	{
		if(d[i][i] < 0){
			cout << "NEGATIVE CYCLE\n";
			return 0;
		}
	}
	for (int i = 0; i < V; ++i)
	{
		for (int j = 0; j < V; ++j)
		{
			if(i == j){
				cout << "0";
			}else if(d[i][j] == INF){
				cout << "INF";
			}else{
				cout << d[i][j];
			}
			if(j != V-1){
				cout << " ";
			}
		}
		cout << "\n";
	}
	return 0;
}

int main(){
	cin >> V >> E;
	Fill(d,INF);
	for (int i = 0; i < E; ++i)
	{
		ll a,b,c;
		cin >> a >> b >> c;
		G[a].push_back((edge){b,c});
		d[a][b] = c;
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	ans = answer();

	return 0;
}

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

typedef long long int ll;

int main(){
	int n,m;cin >> n >> m;
	if(n >= m)return cout << 0, 0;
	vector<int> arr(m);
	int ans = 0;
	for(int i = 0;i < m;i++)cin >> arr[i];
	sort(arr.begin(), arr.end());
	vector<int> diff;
	for(int i = 1;i < m;i++)diff.push_back(abs(arr[i] - arr[i - 1]));
	sort(diff.begin(), diff.end());
	for(int i = 0;i < m - n;i++)ans += diff[i];
	cout << ans;
}


Measured memory_bytes: 1276
main=getLine>>=print.(\x->f (length x) x 0 0)
 where f 0 _ i j = min i j
       f n (b:x) i j |even n = f (n-1) x (i+(read[b])) (j+1-(read[b]))
                     |odd n  = f (n-1) x (i+1-(read[b])) (j+(read[b]))

Measured memory_bytes: 7164
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,M;
int a[50],b[50],c[50],d[50];

int main(){
    cin>>N>>M;
    rep(i,N) cin>>a[i]>>b[i];
    rep(i,M) cin>>c[i]>>d[i];

    rep(i,N){
        int ans;
        int dis=1001001001;
        rep(j,M){
            int dd=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(dd<dis){
                dis=dd;
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N, M, D;
	cin >> N >> M >> D;
	char **map;
	map = new char*[M];
	for (int i = 0; i < M; ++i) {
		map[i] = new char[N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> map[j][i];
		}
	}
	int **tate,**yoko;
	tate = new int*[M];
	yoko = new int*[M];
	for (int i = 0; i < M; ++i) {
		tate[i] = new int[N];
		yoko[i] = new int[N];
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		yoko[M - 1][i] = map[M - 1][i] == '.' ? 1 : 0;
	}
	for (int i = 0; i < M; ++i) {
		tate[i][N - 1] = map[i][N - 1] == '.' ? 1 : 0;
	}
	for (int i = N - 2; i > -1; --i) {
		for (int j = 0; j < M; ++j) {
			tate[j][i] = map[j][i] == '.' ? tate[j][i + 1] + 1 : 0;
			if (tate[j][i] >= D)++ans;
		}
	}
	for (int i = M - 2; i > -1; --i) {
		for (int j = 0; j < N; ++j) {
			yoko[i][j] = map[i][j] == '.' ? yoko[i + 1][j] + 1 : 0;
			if (yoko[i][j] >= D)++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3172
def solve():
    INF = float('inf')
 
    def max2(x, y): return x if x >= y else y
 
    N = int(input())
    As = [(A, i) for i, A in enumerate(map(int, input().split()))]
 
    As.sort(reverse=True)
 
    dp = [[-INF]*(N+1) for _ in range(N+1)]
    dp[0][0] = 0
    for no, (A, pos) in enumerate(As):
        for i in range(no+1):
            j = no-i
            dp[i+1][j] = max2(dp[i+1][j], dp[i][j] + A*abs(pos-i))
            dp[i][j+1] = max2(dp[i][j+1], dp[i][j] + A*abs(pos-(N-1-j)))
 
    ans = 0
    for i in range(N+1):
        j = N-i
        ans = max2(ans, dp[i][j])
 
    print(ans)
 
 
solve()

Measured memory_bytes: 136016
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  dump(a[1]+a[2]*10+a[0]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    string S;
    cin >> S;
    int a = 0, b = 0, c = 0;
    REP(i, 3) {
        if (S[i] == 'a')a++;
        else if (S[i] == 'b')b++;
        else c++;
    }
    YESNO(a == 1 && b == 1 && c == 1, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int INF=2000000000;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> dp(n+k,INF);
  dp[0]=0;
  for(int i=0; i<n-1; i++){
    for(int j=1; j<=k; j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout << dp[n-1] << endl;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	string s;
	cin >> s;
	int n = s.length();

	vector<int> l(n, -1), r(n, -1);

	int last = -1;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'R') last = i;
		else l[i] = last;
	}

	last = -1;
	for (int i = n-1; i >= 0; --i)
	{
		if (s[i] == 'L') last = i;
		else r[i] = last;
	}

	vector<int> ans(n);
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'L')
		{
			int p = l[i];
			if ((i-p)&1) ++p;
			++ans[p];
		}
		else
		{
			int p = r[i];
			if ((p-i)&1) --p;
			++ans[p];
		}
	}

	for (auto &i : ans)
		cout << i << " \n"[&i==&ans.back()];

	return 0;
}


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

int n, m, q;
string s[1000], b[1000];

int get(unsigned long long x){
	int res = 0;
	while (x > 1){
		res++;
		x >>= 1;
	}
	return res;
}

void solve()
{
	for (int i = 1; i < q; i++){
		for (int j = 0; j < n; j++){
			s[i][j] = '0' + (s[i - 1][j] != s[i][j]);
		}
		/*for (int j = 0; j < m; j++){
			b[i][j] = '0' + (b[i - 1][j] != b[i][j]);
		}*/
	}
	
	static unsigned long long f[1000];
	for (int i = 0; i < m; i++) f[i] = (1ull << n) - 1;
	
	for (int i = 0; i < q; i++){
		for (int j = 0; j < n; j++){
			for (int k = 0; k < m; k++){
				if (s[i][j] != b[i][k]) f[k] &= ~(1ull << j);
			}
		}
	}
	
	for (int i = 0; i < m; i++){
		if (f[i] != (f[i] & -f[i])) printf("?");
		else if (f[i] == 0) printf("?");
		else {
			int t = get(f[i]);
			if (t <= 9) printf("%d", t);
			else printf("%c", 'A' + (t - 10));
		}
	}
	puts("");
}

int main()
{
	while (scanf("%d %d %d", &n, &m, &q), n){
		for (int i = 0; i < q; i++){
			cin >> s[i] >> b[i];
		}
		solve();
	}
}

Measured memory_bytes: 2528
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

ll w, h, x, y;

int main(){
	scanf("%lld%lld%lld%lld", &w, &h, &x, &y);
	if(x * 2 == w && y * 2 == h)
		printf("%lf 1\n", 1.0 * w * h / 2);
	else
		printf("%lf 0\n", 1.0 * w * h / 2);
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>

using namespace std;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    int a[n];
    for(int i=0; i<n; i++) {
    	scanf("%d", &a[i]);
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2; i<n; i++) {
    	dp[i] = dp[i-1]+abs(a[i]-a[i-1]);
    	for(int j=2; j<=k && i-j>=0; j++)
    	dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
    }
    printf("%d\n", dp[n-1]);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int n,a[100010];
using namespace std;
int main(){
    int i,mn = 200000,mx = 0;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        mx = max(mx,a[i]); mn =min(mn,a[i]);
    }
    if(mx-mn>1){
        cout << "No" << endl;
        return 0;
    }
    if(mx==mn){
        if(mx==n - 1 || mx<=n/2) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    int cnt = 0;
    for(i=0;i<n;i++){
        if(a[i]==mn) cnt++;
    }
    int k = mx - cnt;
    if(k>=1 && k<=(n - cnt)/2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=1;i<n;i++){
        cin>>c[i];
    }
    int ans=0;
    
    for(int i=0;i<n;i++){
        ans+=b[a[i]-1];
        if(i>=1){
            if(a[i]-a[i-1]==1){
                ans+=c[a[i-1]];
            }
        }
    }
    
    cout<<ans;
}


Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	a := readIntArray()
	n := a[0]
	k := a[1]
	s := readLine()

	var r []int
	if s[0] == '0' {
		// 番兵
		r = append(r, 0)
	}
	prev := s[0]
	l := 1
	for i := 1; i < n; i++ {
		if prev != s[i] {
			r = append(r, l)
			l = 0
		}
		prev = s[i]
		l++
	}
	if l > 0 {
		r = append(r, l)
	}
	w := k*2 + 1
	var ans int
	lenR := len(r)
	// init
	for j := 0; j < w; j++ {
		if j >= lenR {
			break
		}
		ans += r[j]
	}
	// search
	prevM := ans
	for i := 2; i < lenR; i += 2 {
		m := prevM - r[i-2] - r[i-1]
		for j := w - 2; j < w; j++ {
			if i+j >= lenR {
				break
			}
			m += r[i+j]
		}
		if m > ans {
			ans = m
		}
		prevM = m
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define N 100010
#define swap(a,b) a^=b^=a^=b
using namespace std;
int l,n,m;
int k=2;
int f[N][32]={},a[N]={};
int read(){int s=0,w=1;char ch=getchar();while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();if(ch=='-')w=-1;while(ch<='9'&&ch>='0')s=s*10+ch-'0',ch=getchar();return s*w;}
int main()
{
		n=read();
		for(int i=1;i<=n;++i)a[i]=read();
		l=read();
		for(int i=1;i<=n;++i)
		{
			while(k<=n&&a[k]-a[i]<=l)++k;
			f[i][0]=k-1;
		}
		for(int i=1;i<=30;++i)
			for(int j=1;j<=n;++j)
				f[j][i]=f[f[j][i-1]][i-1];
		m=read();
		for(int i=1;i<=m;++i){
				int x,y;
				int ans=0;
				x=read();y=read();
				if(x>y)swap(x,y);
				for(int j=30;j>=0;--j){
						if(f[x][j]>=y)continue;
						ans+=1<<j,x=f[x][j];
				}
				printf("%d\n",ans+1);
		}
		return 0;
}


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

int main(int argc, const char * argv[]) {
    
    char s[201];
    char copy[201];
    unsigned long len;
    int m;  //シャッフル回数
    int h;  //取り出す枚数
    int i, j, k, l;
    
    for (i=0; i<10; i++) {
        scanf("%s", s);
        if (strcmp(s, "-")==0) {
            break;
        }
        len = strlen(s);//文字数カウント
        scanf("%d", &m);
        for (j=0; j<m; j++) {
            scanf("%d", &h);
            strncpy(copy, s, h);
            //copyをsの後ろにいれる
            for (k=0; k<h; k++) {
                s[len+k] = copy[k];
                //printf("copy付け足し%d回目：%s\n", k+1, s);
            }
            //sを前にずらす
            for (l=0; l<len; l++) {
                s[l] = s[l+h];
                //printf("ずらし%d回目：%s\n", l+1, s);

            }
            //sを整える
            s[len] = '\0';
//            printf("整え後：%s\n", s);
        }
        printf("%s\n", s);
    }
    
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
	vite;
	ll a, b,k=-1;
	cin >> a >> b;
	for (ll i = 2*a; i <= 4 * a;i+=2)
	{
		if(b==i)
		{
			k = 1;
			break;
		}
	}
	if(k==1)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

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

    int n; cin >> n;
    int a; cin >> a;
    int cnt = 0;
    int ans = 0;
    REP(i, n - 1) {
        int b; cin >> b;
        if (a == b) cnt++;
        else {
            if (cnt > 0) {
                ans += (cnt + 1) / 2;
            }
            cnt = 0;
        }
        a = b;
    }
    if (cnt > 0) {
        ans += (cnt + 1) / 2;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		String output = "";
		String[] mozi = input.split(" ");
		String UpperAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		String LowerAlpha = "abcdefghijklmnopqrstuvwxyz";
		int mozi_length = 0;

		int index1 = -1;
		int index2 = -1;
		for (int i = 0; i < mozi.length; i++) {
			mozi_length += mozi[i].length();
			if (i != 0) {
				output += " ";
			}
			for (int j = 0; j < mozi[i].length(); j++) {
				index1 = UpperAlpha.indexOf(mozi[i].charAt(j));
				index2 = LowerAlpha.indexOf(mozi[i].charAt(j));
				if (index1 == -1 && index2 == -1) {
					output += "" + mozi[i].charAt(j);
				} else if (index1 != -1) {
					output += "" + LowerAlpha.charAt(index1);

				} else if (index2 != -1) {
					output += "" + UpperAlpha.charAt(index2);
				}

			}
		}
		if (mozi_length < 1200) {
			System.out.println(output);
		}
	}

}



Measured memory_bytes: 31736
#include <iostream>
#include <vector>
#include <stack>

using namespace std;
typedef long long LL;

static const int MAXN = 100000 + 5;
static const LL MAXC = 100000000 + 5;

int r, c;

struct Point{
    int x;
    int y;
    int id;
    Point(int _x, int _y, int _id) {
        x = _x;
        y = _y;
        id = _id;

    }
    LL val() {
        LL base = MAXC * 10;
        if (x == 0 && y == 0) return 0;
        if (x == 0 && y == c) return 2*base;
        if (x == r && y == c) return 4*base;
        if (x == r && y == 0) return 6*base;
        if (x == 0) return base + y;
        if (y == c) return 3*base + x;
        if (x == r) return 5*base - y;
        if (y == 0) return 7*base - x;

    }
};

bool bound(int x, int y) {
    if (x == 0 || x == r) return true;
    if (y == 0 || y == c) return true;
    return false;
}

static bool cmp(Point p1, Point p2) {
    LL v1 = p1.val();
    LL v2 = p2.val();
    return v1 < v2;
}

int main() {
//    freopen("test.txt", "r", stdin);
    int n, x1, y1, x2, y2;
    scanf("%d%d%d", &r, &c, &n);
    vector<Point> points;
    for (int i = 1; i <= n; i++) {
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        if (bound(x1 ,y1) && bound(x2, y2)) {
            points.push_back(Point(x1,y1,i));
            points.push_back(Point(x2,y2,i));
        }
    }
    sort(points.begin(), points.end(), cmp);
    stack<int> st;
    for (Point p : points) {
        if (st.size() == 0) {
            st.push(p.id);
        }
        else {
            if (st.top() == p.id) {
                st.pop();
            }
            else { // st.top() != p.id
                st.push(p.id);
            }
        }
    }
    if (st.size() == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 4972
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/


int main() {
	int N;
	cin >> N;
	vector<int>D(N);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
	}
	sort(D.begin(), D.end());
	cout <<abs( D[N / 2 - 1] - D[N / 2]) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){  
  int n,d;cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n){
      rep(j,d)cin>>x[i][j];
  }
  map<int,int> sq;
  int res=0;
  rep(i,1000)sq[i*i]+=1;
  rep(i,n){
      for(int j=i+1;j<n;++j){
          lint buf=0;
          rep(k,d){
              buf+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
          }
          if(sq[buf]==1)++res;
      }
  }
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

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

	string s;
	cin >> s;
	if (s[0] != s[1] && s[2] == s[3] && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 892
# from sys import exit
init = False
while(True):
    A, B = [int(n) for n in input().split()]
    if A == 0 and B == 0:
        exit()
    if init:
        print()

    # N = int(input())
    # a = [int(input()) for _ in range(N)]
    # S = str(input())
    # L = len(S)
    # T = str(input())
    # exit()
    aaa = False
    for a in range(A, B+1):
        if a % 4 == 0:
            if a % 100 == 0 and a % 400 != 0:
                continue
            print(a)
            aaa = True
    if (not aaa):
        print("NA")
    init = True



Measured memory_bytes: 5732
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iomanip>

int main(int argc, char const* argv[])
{
	double a, b, c, d, e, f;
	const unsigned precision{3};
	std::cout << std::fixed << std::setprecision(precision);

	std::cin >> a >> b >> c >> d >> e >> f;
	while (!std::cin.eof()) {
		auto x = ( e*c - b*f )/( e*a - d*b );
		auto y = ( d*c - a*f )/( d*b - e*a );
		x = (std::abs(x) < 0.5 / std::pow(10,precision)) ? 0.0 : x;
		y = (std::abs(y) < 0.5 / std::pow(10,precision)) ? 0.0 : y;
		std::cout << x << ' ' << y << std::endl;
		std::cin >> a >> b >> c >> d >> e >> f;
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << s[K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.nextLine());
		String A = in.nextLine();
		String B = in.nextLine();
		String C = in.nextLine();
		in.close();

		System.out.println(diff(A, B, C));
	}

	static int diff(String A, String B, String C) {
		int result = 0;
		for (int i = 0; i < A.length(); ++i) {
			char a = A.charAt(i);
			char b = B.charAt(i);
			char c = C.charAt(i);
			if (a == b && b == c && c == a) {

			} else if (a == b || b == c || c == a) {
				result++;
			} else {
				result = result + 2;
			}
		}
		return result;
	}

}

Measured memory_bytes: 21844
A,B = map(int,input().split())

if A%2 == 0 and B%2 == 1:
	if (B-A-1)%4 == 0:
		print("1")
	else:
		print("0")
elif A%2 == 0 and B%2 == 0:
	if (B-A)%4 == 0:
		print(B)
	else:
		print(B^1)
elif A%2 == 1 and B%2 == 1:
	if (B-A)%4 == 0:
		print(A)
	else:
		print(A^1)
else:
	if (B-A-1)%4 == 0:
		print(A^B)
	else:
		print(A^B^1)

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

int main() {
  int n,m;
  cin >> n;
  cin >> m;
  
  int ans = 0;
  if( n != 0 ) ans =  (n*(n-1) )/2 ;
  if( m != 0 ) ans += (m * (m-1) )/2;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
a.sort()
ans = 0
if n % 2 == 0:
    ans = sum(a[n//2+1:])*2 + a[n//2] - sum(a[:n//2-1])*2 - a[n//2-1]
elif n % 2 == 1:
    ans1 = sum(a[n//2+2:])*2 + a[n//2] + a[n//2+1] - sum(a[:n//2])*2
    ans2 = sum(a[n//2+1:])*2 -sum(a[:n//2-1])*2 -a[n//2] - a[n//2-1]
    ans = max(ans1,ans2)
print(ans)

Measured memory_bytes: 7512
string = input()
if len(string) < 26:
  for i in range(97, 124):
    if chr(i) not in string:
      break
  print(string + chr(i))
else:
  val = [string[-1]]
  for i in string[-2::-1]:
    if i > val[-1]:
      val.append(i)
    else:
      break
  if len(val) == 26:
    print(-1)
  else:
    print(string[:-len(val)-1] + min(i for i in val if i > string[-len(val)-1]))


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

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

ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*  
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

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

int csrand(int l=0, int r=1e9)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define PR(x) cout<<#x<<" : "<<x<<"\n";
#define PR1(x,y) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"\n";
#define PR2(x,y,z) cout<<#x<<" : "<<x<<"  |  "<<#y<<" : "<<y<<"  |  "<<#z<<" : "<<z<<"\n";
#define ED cout<<'\n';

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define endl            '\n'
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define PB              push_back
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first       
#define S               second 
#define mod             1000000007


const int N=2e4+99;


int32_t main()
{       
    IO

    int n;
    cin>>n;

    int ans=n/2;
    if(n%2==0) ans--;
    cout<<ans<<endl;



   

}





Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int areaAB = a * b;
	int areaCD = c * d;

	if (areaAB >= areaCD) {
		cout << areaAB << endl;
	}
	else {
		cout << areaCD << endl;
	}

	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string T;
  cin >> T;
  int ans = 0;
  for(int i=0; i<T.length(); ++i){
    if(i!=0){
      if(T[i-1] == 'P' && T[i] == 'D') ++ans;
      else if(T[i-1] == 'P' && T[i] == '?'){
        ans += 2;
        T[i] = 'D';
      }
      else if(T[i] == '?'){
        ++ans;
        T[i] = 'D';
      }
    }else{
      if(T[i] != 'P'){
        ++ans;
        T[i] = 'D';
      }
    }
  }
  cout << T << endl;
}


Measured memory_bytes: 3728
# coding: utf-8
# Your code here!
N=int(input())

P=[]
for _ in range(N):
    P.append(int(input())-1)
    
#print(P)

root=[-1]*N
count=[0]*N
for item in P:
    if item == 0:
        root[item]=item
        count[root[item]]+=1
        continue
    if root[item-1]==-1:
        root[item]=item
        count[root[item]]+=1
    else:
        root[item]=root[item-1]
        count[root[item]]+=1
"""
print(root)
print(count)
print("===========================")
"""
print(N-max(count))


Measured memory_bytes: 14124
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

void solve() {
  int N, T;
  cin >> N >> T;

  int ans = -1;
  int m = INF;
  for (int i = 1; i <= N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T && m >= c) {
      ans = i;
      m = c;
    }
  }

  if (ans == -1) {
    cout << "TLE" << endl;
  } else {
    cout << m << endl;
  }
}

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


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = list(set(a))
while (10000000):
    a.sort()
    div_flag = True
    for i in range(1, len(a)):
        if a[i]%a[0] != 0:
            div_flag = False
    if div_flag is True:
        print(a[0])
        exit()
    for i in range(1, len(a)):
        a[i] = a[i]%a[0]
    while 0 in a :
        a.remove(0)


Measured memory_bytes: 15276
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define endl "\n"
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
         ll n,k;
         cin>>n>>k;
         ll a[n+5];
         for(int i=1;i<=n;i++)
          cin>>a[i];
          set<ll>st;
          vector<ll>v1;
          st.insert(1);
          v1.pb(1);
         ll curr = 1;
         if(a[1]==1)
         {
            cout<<1<<endl;
            return 0;
         }
         ll k1 = k;
         ll val = -1;
         while(k>0)
         {
             curr = a[curr];
             if(st.find(curr)!=st.end())
             {
                 val = curr;
                 break;
             }
             else
             {
                st.insert(curr);
                v1.pb(curr);
             }
             k--;
             
         }
         // cout<<k<<endl;
         if(k>0)
         {
             vector<ll>v;
             v = v1;
              ll ans = v.size();
              for(int i=0;i<v.size();i++)
              {
                  if(v[i]==val)
                  {
                      k1-=(i);
                      // cout<<k1<<" "<<ans<<endl;
                      ll rem = k1%ans;
                      cout<<v[i+rem]<<endl;
                      return 0;      
                  }
                  else
                  {
                      ans--;
                  }
              }

         }
         cout<<curr<<endl;
         

      }
      






}



























Measured memory_bytes: 14740
[M,D] = list(map(int,input().split()))
output = 0
for m in range(1,M+1):
    month = str(m)
    for d in range(1,D+1):
        day = str(d)
        [d1,d2] = list(str(day.rjust(2, '0')))
        if (int(d1)>=2)and(int(d2)>=2):
            if int(d1)*int(d2)==int(month):
                output += 1
print(output)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

int n, m, k, l;

vector<vector<int>> g;

bool vis[200010];

void dfs(int v) {
    vis[v] = true;
    for (auto &i : g[v]) {
        if (!vis[i]) dfs(i);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    g.resize(n + m);
    for (int i = 0; i < n; ++i) {
        cin >> k;
        for (int j = 0; j < k; ++j) {
            cin >> l;
            l = l - 1 + n;
            g[i].emplace_back(l);
            g[l].emplace_back(i);
        }
    }

    dfs(0);
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 8568
n,w = gets.split.map!(&:to_i)

t = Hash.new(0)
t[0] = 0
n.times do 
    x,y = gets.split.map!(&:to_i)
    s = t.dup

    s.each do |key,value|
        next if key + x > w

        if t[key+x] < value + y
            t[key+x] = value + y
        end
    end
end

puts t.values.max

Measured memory_bytes: 9340
#include <iostream>

using namespace std;

int main() {

    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    int answer = 0;
    for (int a=0; a<=A; a++) {
        for (int b=0; b<=B; b++) {
            for (int c=0; c<=C; c++) {
                if (a*500 + b*100 + c*50 == X) answer++;
            }
        }
    }

    cout << answer << endl;

}

Measured memory_bytes: 256
ABCD = input()
A, B, C, D = [int(x) for x in ABCD]
ops = ["+", "-"]
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            if op1 == "+":
                ans = A + B
            else:
                ans = A - B
            if op2 == "+":
                ans += C
            else:
                ans -= C
            if op3 == "+":
                ans += D
            else:
                ans -= D
            if ans == 7:
                print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D) + "=" + str(ans))
                exit()


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
int main(void)
{
  int N,i;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  int count=0;
  
  for(i=0;i<N-2;i++)
  {
    if(S[i]=='A' && S[i+1]== 'B' && S[i+2]== 'C' )
      count++;
  }
  printf("%d\n",count);  
  
  return 0;
  
}

Measured memory_bytes: 128
/*
    Author : DemonStar
*/

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int main()
{
    fast;
    int n, k;
    cin >> n >> k;
    vi v(n);
    cin >> v;
    vi dp(n + 1, 1e9);
    dp[0] = 0;
    rep(i, 1, n)
    {
        rep(j, 1, k + 1) if (i >= j) dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
    }
    cout << dp[n - 1] << endl;

#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	n := scanNums(1)[0]
	as := scanNums(n)

	ans := calc(as)

	fmt.Println(ans)
}

func calc(as []int) int64 {
	var minusCount int
	var answer int64

	minAbs := abs(as[0])
	for _, ai := range as {
		if ai < 0 {
			minusCount++
		}
		answer += int64(abs(ai))
		minAbs = min(minAbs, abs(ai))
	}
	if minusCount%2 == 0 {
		return answer
	} else {
		answer += int64(minAbs * -2)
	}
	return answer
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 9088
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int f(int x) {
  if (x % 10 == 0) {
    return x;
  } else {
    return (x / 10 + 1) * 10;
  }
}

void solve(int A, int B, int C, int D, int E) {
  int x = max({f(A) - A, f(B) - B, f(C) - C, f(D) - D, f(E) - E});
  printf("%d\n", f(A) + f(B) + f(C) + f(D) + f(E) - x);
}

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  solve(A, B, C, D, E);
  return 0;
}


Measured memory_bytes: 888
str=input()
count=0
max_count=0
for i in str:
    if i=='A' or i=='C'or i=='G'or i=='T':
        count=count+1
    else:
        if max_count<count:
            max_count=count
        count=0
if max_count<count:
    max_count=count
print(max_count)


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX = 105;
int n, a, b;

vint graph[MAX];

int res;
bool used[MAX];
void dfs(int v, int len) {
    chmax(res, len);
    
    for (int i = 0; i < graph[v].size(); ++i) {
        int to = graph[v][i];
        if (used[to]) continue;
        
        used[to] = true;
        dfs(to, len+1);
        used[to] = false;
    }
}

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < MAX; ++i) graph[i].clear();
        
        for (int i = 0; i < n; ++i) {
            cin >> a >> b;
            --a; --b;
            graph[a].PB(b); graph[b].PB(a);
        }
        
        res = 1;
        for (int i = 0; i < MAX; ++i) {
            used[i] = true;
            dfs(i, 1);
            used[i] = false;
        }
        
        cout << res << endl;
    }
    return 0;
}


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

int main() {
    int x;
    
    cin >> x;
    
    vector<int> dp(x + 1);
    
    dp[0] = 1;
    
    for (int i = 100; i <= 105; i++) {
        for (int j = 0; j + i <= x; j++) {
            if (dp[j]) {
                dp[j + i] = 1;
            }
        }
    }
    
    cout << dp[x] << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
    int n,m;
    int a[1001];
    scanf("%d%d",&n,&m);
    int sum = 0;
    for (int i = 0 ; i < n; i++){
        scanf("%d",&a[i]);
        sum += a[i];
    }
    sort(a,a+n);
    bool flag=true;
    for (int i = 0 ; i < m;i++){
        double tmp = 1.0 * sum / (4 * m);
        if(a[n-1-i]< tmp){
            flag = false;
            break;
        }
    }
    if(flag){
        printf("Yes");
    }
    else
        printf("No");
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/26  Problem: ABC 116 C / Link: http://abc116.contest.atcoder.jp/tasks/abc116_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; cin >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	FOR(val, 1, 101) {
		int cnt = 0;
		bool ok = 0;
		FOR(i, 0, N) {
			if (!ok && a[i] >= val) {
				ok = 1;
				cnt++;
			}
			else if (a[i]<val) {
				ok = 0;
			}
		}

		ans += cnt;
	}
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i=0,n,d,x=1;
	scanf("%d%d",&n,&d);
	
	i = 1+d;
	while(i+d < n){
		x++;
		i = i+2*d+1;
	}
	
	printf("%d",x);
	
	return 0;
}

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

bool isBitI1(int bit, int i){
    return (bit >> (i-1) & 1) == 1 ? true: false;
}

int main(){
    char c;
    int s[4];

    for(int i=0; i<4; i++){
        cin >> c;
        s[i]= c - '0';
    }

    int total;
    for(int bit=0 ; bit<(1 << 3); bit++){
        total = s[0];
        for(int i=1; i<4; i++){
            total += s[i] * (isBitI1(bit, i) ? 1 : -1);
        }

        if(total == 7){
            cout << s[0];
            for(int i=1; i<4; i++){
                cout << (isBitI1(bit, i) ? "+" : "-") << s[i];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a=1,b;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    if(b%2==0){
      if(b%3!=0&&b%5!=0){
        a=0;
      }
    }
  }
  if(a==0){
    cout<<"DENIED"<<endl;
  }
  else{
    cout<<"APPROVED"<<endl;
  }
}

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

int main() {
	string g;
	int y, m, d;
	while(1){
		cin >> g >> y >> m >> d;
		if(g=="#") break;
		if(y>31 || (y==31 && m>4)){
			g = "?";
			y -= 30;
		}
		cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
	} 
	return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>

int main(){
    int dish[5];
    int i, j, m, min = 700;
    
    for(i=0; i<5; i++){
        scanf("%d", &dish[i]);
    }

    for(i=0; i<5; i++){
        m = 0;
        for(j=0; j<5; j++){
            if(i == j)
                m += dish[j];
            else{
                if(dish[j] % 10 == 0)
                    m += dish[j];
                else
                    m += dish[j] + (10 - (dish[j] % 10));
            }
        }

        if(min > m)
            min = m;
    }

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

    return 0;
}

Measured memory_bytes: 128