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

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

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

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

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

Measured memory_bytes: 512
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
vll p;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;
    cin >> K;

    rep(ni,N){
        cin >> ltmp;
        p.push_back(ltmp);
    }
    sort(p.begin(),p.end());

    ll sump=0;
    rep(ki,K){
        sump += p[ki];
    }
    cout << sump << endl;
    

}

Measured memory_bytes: 3656
import math
import sys

n = int(sys.stdin.readline().rstrip())
v = list(map(int, sys.stdin.readline().rstrip().split()))
v1 = v[::2]
v2 = v[1::2]
v1d = {}
v2d = {}
for vi in v1:
    if vi in v1d:
        v1d[vi] += 1
    else:
        v1d[vi] = 1
for vi in v2:
    if vi in v2d:
        v2d[vi] += 1
    else:
        v2d[vi] = 1

if max(v1d, key=v1d.get) != max(v2d, key=v2d.get):
    print(len(v1) - max(v1d.values()) + len(v2) - max(v2d.values()))
else:
    ans1 = 0
    if len(v1d.values()) == 1:
        tmp = 0
    else:
        tmp = sorted(v1d.values())[-2]
    ans1 = len(v1) - tmp + len(v2) - max(v2d.values())
    ans2 = 0
    if len(v2d.values()) == 1:
        tmp = 0
    else:
        tmp = sorted(v2d.values())[-2]
    ans2 = len(v1) - max(v1d.values()) + len(v2) - tmp
    print(min(ans1, ans2))

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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  string S = input<string>();
  int64 K = input();

  int leading_1 = 0;
  while (leading_1 < S.size() && S[leading_1] == '1') leading_1++;

  if (K <= leading_1) cout << 1 << endl;
  else cout << S[leading_1] << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


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

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = k;
  rep(i,n){
    ans *= k-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a;
	b=a;
	reverse(b.begin(),b.end());
	for (int i=0;i<b.length();i++)
	{
		if (b[i]=='b')b[i]='d';
		else if (b[i]=='d')b[i]='b';
		else if (b[i]=='p')b[i]='q';
		else  if (b[i]=='q')b[i]='p';
	}
	if(a==b)
	{
		cout<<"Yes"<<'\n';
		return 0;
	}
	cout<<"No"<<'\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void c_otoshidama(void) {
	int n, y;
	cin >> n >> y;
	int total = 0;

	for (int k = 0; k <= n; k++) {
		for (int j = 0; j <= n - k; j++) {
			int i = n - k - j;
			total = 10000 * k + 5000 * j + 1000 * i;
			if (total == y) {
				cout << k << " " << j << " " << i << endl;
				return;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

int main()
{
    c_otoshidama();
    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();

		if (line == null) {
			System.out.println(0);
			return;
		}

		String[] params = line.split(" ");

		if (params.length < 2) {
			System.out.println(0);
			return;
		}

		int maxCnt = Integer.parseInt(params[0]);
		int maxWeight = Integer.parseInt(params[1]);

		Map<Integer, Integer> last = new HashMap<>();
		last.put(0, 0);

		int idx = 0;
		while (idx < maxCnt) {
			line = br.readLine();

			if (line == null) {
				break;
			}

			params = line.split(" ");
			if (line.length() < 2) {
				break;
			}

			idx++;
			Map<Integer, Integer> current = new HashMap<>();
			current.putAll(last);

			List<Integer> pair = Arrays.stream(params)
					.map(Integer::parseInt)
					.collect(Collectors.toList());
			Integer currentValue = pair.get(0);
			Integer currentWeight = pair.get(1);

			for (Map.Entry<Integer, Integer> entry : last.entrySet()) {
				int totalWeight = entry.getValue() + currentWeight;
				if (totalWeight <= maxWeight) {
					merge(current, entry.getKey() + currentValue, totalWeight);
				}
			}
			merge(current, currentValue, currentWeight);
			last = current;
		}
		System.out.println(Collections.max(last.keySet()));
	}

	private static void merge(Map<Integer, Integer> current, int newValue, int newWeight) {
		current.merge(newValue, newWeight,
				(oldWgt, newWgt) -> {
					if (oldWgt < newWgt) {
						return oldWgt;
					} else {
						return newWgt;
					}
				});
	}
}


Measured memory_bytes: 66008
import java.util.Scanner;

public class Main {
	    public static void main (String[] args) {
	    	Scanner scanner = new Scanner(System.in);
	    	int temp = scanner.nextInt();
	    	if(temp >= 30) {
	    		System.out.println("Yes");
	    	}else {
	    		System.out.println("No");
	    	}
	    	scanner.close();
	    }
	}

Measured memory_bytes: 27020
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int lt,ls,i,j,tt,ans=0x7fffffff;
char s[1010],t[1010];
int main () {
	scanf ("%s%s",s+1,t+1);
	ls=strlen (s+1);
	lt=strlen (t+1); 
	for (i=1;i<=ls-lt+1;i++) {
        tt=0;
		for (j=i;j<=i+lt-1;j++) {
			if (s[j]!=t[j-i+1]) {
				tt++;
			}
		}
		ans=min (tt,ans); 
	}
	printf ("%d\n",ans);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;



int main() {
    int a,b;cin>>a>>b;
    cout<<a*(a-1)/2 + (b*(b-1)/2)<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h+1, vector<char>(w+1, '.'));
	rep(i,h)rep(j,w) cin >> a[i][j];
	queue<P> que;
	que.push(P(0, 0));
	while(!que.empty()){
		P p = que.front();
		que.pop();
		a[p.first][p.second] = '.';
		int ny = p.first + 1, nx = p.second;
		if(ny < h && a[ny][nx] == '#'){
			que.push(P(ny, nx));
			continue;
		}
		ny = p.first; nx = p.second + 1;
		if(nx < w && a[ny][nx] == '#'){
			que.push(P(ny, nx));
		}
	}
	rep(i,h)rep(j,w){
		if(a[i][j] == '#'){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	cout << "Possible" << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n == 0:break
    ans = [0 for i in range(10)]
    for l in range(n):
        a = int(input())
        ans[a] += 1
    for i in range(10):
        if ans[i] == 0: print('-')
        else:
            for j in range(ans[i]):
                print('*',end='')
            print('')



Measured memory_bytes: 7588
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if(c>=a&&c<=b){
  cout << "Yes" << endl;
 }else{
  cout << "No" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int totaltime(int m1,int s1,int m2,int s2,int m3,int s3,int m4,int s4);
int main()
{
    int i,n,c1,m1,s1,m2,s2,m3,s3,m4,s4,topid[2],worstid[2],toptime[2],worsttime[2],time;

    while(1){
        scanf("%d",&n);
        if(n==0) break;
        for(i=0;i<n;i++){
            scanf("%d %d %d %d %d %d %d %d %d",&c1,&m1,&s1,&m2,&s2,&m3,&s3,&m4,&s4);
            time =totaltime(m1, s1, m2, s2, m3, s3, m4, s4);
            if(i==0){
                toptime[0] = time;
                toptime[1] = 14400;
                worsttime[0] = time;
                worsttime[1] = 0;
                topid[0]=c1;
                worstid[0]=c1;
            }else{
                if(toptime[0]>time){
                    toptime[1] = toptime[0];
                    toptime[0] = time;
                    topid[1] = topid[0];
                    topid[0] = c1;
                }else if(toptime[1]>time){
                    toptime[1] = time;
                    topid[1] = c1;
                }
                if(worsttime[0]<time){
                    worsttime[1] = worsttime[0];
                    worsttime[0] = time;
                    worstid[1] = worstid[0];
                    worstid[0] = c1;
                }else if(worsttime[1]<time){
                    worsttime[1] = time;
                    worstid[1] = c1;
                }
            }
        }
        printf("%d\n%d\n%d\n" ,topid[0],topid[1],worstid[1]);
    }
    return 0;
}

int totaltime(int m1,int s1,int m2,int s2,int m3,int s3,int m4,int s4){
    int result;
    result = m1*60+s1+m2*60+s2+m3*60+s3+m4*60+s4;
    return result;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define MOD 100000007LL
using namespace std;

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

int main(void){
	int rz,wz,c,r;
	while(1){
		scanf("%d%d%d%d",&rz,&wz,&c,&r);
		if(rz==0 && wz==0)break;
		int rest=wz*c-rz;
		rest=(rest+r-1)/r;
		printf("%d\n",max(0,rest));
	}
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint h, w, K;
llint dp[105][10];

int main(void)
{
	cin >> h >> w >> K;
	
	llint s = 1<<(w-1);
	
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int k = 0; k < s; k++){
				if(k & (k<<1)) continue;
				int nj = j;
				if(k & (1<<j)) nj++;
				if(j > 0 && (k & (1<<(j-1)))) nj--;
				dp[i+1][nj] += dp[i][j];
				dp[i+1][nj] %= mod;
			}
		}
	}
	
	cout << dp[h][K-1] << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    
    int x[3];
    int a;
    int A,B;
    int counter=0;
    
    for(int i=0;i<3;i++){
        cin >> x[i];
    }
    
    for(int i=0;i<2;i++){
        for(int j=0;j<2-i;j++){
            if(x[j]>x[j+1]){
                a=x[j+1];
                x[j+1]=x[j];
                x[j]=a;
            }
        }
    }
    
    A=(x[2]-x[0])/2;
    counter+=A;
    B=(x[2]-x[1])/2;
    counter+=B;
    
    A=(x[2]-x[0])%2;
    B=(x[2]-x[1])%2;
    
    if(A+B==1) counter+=2;
    else if(A+B==2) counter+=1;
    
    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static boolean[][] cards=new boolean[4][13];
	private static int n;
	public static void main (String[] args){
		n=sc.nextInt();
		setAllCardsExist();
		printMissingCards();
	}
	private static void setAllCardsExist(){
		for(int i=0;i<n;i++){
			setCardExist();
		}
	}
	private static void setCardExist(){
		char shape=sc.next().charAt(0);
		int num=sc.nextInt();
		switch(shape){
		case 'S':
			cards[0][num-1]=true;
			break;
		case 'H':
			cards[1][num-1]=true;
			break;
		case 'C':
			cards[2][num-1]=true;
			break;
		case 'D':
			cards[3][num-1]=true;
			break;
		}
	}
	private static void printMissingCards(){
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				printMissingCard(i,j);
			}
		}
	}
	private static void printMissingCard(int i,int j){
		if(cards[i][j]==false) System.out.println(getShape(i)+" "+(j+1));
	}
	private static char getShape(int i){
		switch(i){
		case 0:
			return 'S';
		case 1:
			return 'H';
		case 2:
			return 'C';
		case 3:
			return 'D';
		default:
			return ' ';
		}
	}
}

Measured memory_bytes: 26228
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))
answer=0

if n>=q:
    for i in range(q):
        if T[i] in S:
            answer+=1

else:
    for i in range(n):
        if S[i] in T:
            answer+=1

print(answer)



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

using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    char c = s[i] == '1' ? '9' : '1';
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
//const double eps=1e-6;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//isalnum() decimal digit or an uppercase or lowercase letter
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=1e6+1;
int n;
LL c;
LL x[N],v[N];
LL l[N],r[N],b[N];
LL L[N],R[N];
int main() {
	cin>>n>>c;

	FOR(i,1,n){
		cin>>x[i]>>v[i];
		b[i]=c-x[i];
		L[i]=v[i];
		v[i]+=v[i-1];
	}
	for(int i=n;i;i--){
		L[i]+=L[i+1];
	}
	FOR(i,1,n){
		//go back
		l[i]=max(l[i-1],v[i]-x[i]*2);
		//dont go back
		r[i]=max(r[i-1],v[i]-x[i]);
	}
	
	LL ans=0;
	FOR(i,0,n){
		LL A=l[i]+L[i+1]-b[i+1];
		LL B=r[i]+L[i+1]-b[i+1]*2;
		ans=max(max(A,B),ans);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 18816
import java.util.Scanner;

public class Main {


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

		int n = scan.nextInt();

		int[] nAry = new int[n];

		for(int i = 0; i < n ; i++){
			nAry[i] = scan.nextInt();
		}

		int maxBenefit = Integer.MIN_VALUE;
		int min = nAry[0];
		int tmpBenefit;

		for(int i = 1; i < n ; i++){

			tmpBenefit = nAry[i] - min;

			if(maxBenefit < tmpBenefit){
				maxBenefit = tmpBenefit;
			}

			if(min > nAry[i]){
				min = nAry[i];
			}
		}

		System.out.println(maxBenefit);
	}

}

Measured memory_bytes: 100364
def resolve():
    N = int(input())
    P = list(map(int, input().split()))
    ans = 0

    for i in range(1, N - 1):
        tmp = [P[i - 1], P[i], P[i + 1]]
        tmp.sort()

        if tmp[1] == P[i]:
            ans += 1

    print(ans)


resolve()

Measured memory_bytes: 3060
/*input
6
7 6 8 6 1 1
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
// template<typename T>
// using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
using namespace std;
#define N  405
lld pre[N];
lld a[N];
lld dp[N][N];
lld solve2(lld pos1,lld pos2)
{
	if(pos1>pos2)
	{
		return 1e18;
	}
	else if(pos1==pos2)
	{
		return 0;
	}
	if(dp[pos1][pos2]!=-1)
	{
		return dp[pos1][pos2];
	}
	lld minn=1e18;
	for(lld i=pos1;i<pos2;i++)
	{
		minn=min(minn,solve2(pos1,i)+solve2(i+1,pos2)+pre[pos2]-pre[pos1-1]);
	}
	dp[pos1][pos2]=minn;
	return minn;
}
void solve()
{
	lld n;
	cin >> n; 
	rep(i,0,n)
	{
		cin >> a[i];
	}
	pre[0]=a[0];
	rep(i,1,n)
	{
		pre[i]=pre[i-1]+a[i];
	}
	memset(dp,-1,sizeof dp);
	cout << solve2(0,n-1) << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int N=S.size();
  int ans=0;
  rep(i,0,N){
    if(S[i]!=S[N-i-1]) ans++;
  }
  ans/=2;
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
fn main(){
  let m: usize = 10000;
  let nk: Vec<usize> = read_vec();
  let n = nk[0];
  let k = nk[1];

  let mut pv: Vec<usize> = vec![0; n + 1];
  
  for _ in 0 .. k {
    let ab: Vec<usize> = read_vec();
    let a = ab[0];
    let b = ab[1];

    pv[a] = b;
  }

  let mut dp: Vec<Vec<usize>> = vec![vec![0; 6]; n + 1];

  match pv[1] {
    0 => {
      dp[1][0] = 1;
      dp[1][2] = 1;
      dp[1][4] = 1;
    },
    1 => {
      dp[1][0] = 1;
    },
    2 => {
      dp[1][2] = 1;
    },
    _ => {
      dp[1][4] = 1;
    },
  }

  for i in 2 .. n + 1 {
    match pv[i] {
      0 => {
        dp[i][0] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5]) % m;
        dp[i][1] = dp[i-1][0];
        dp[i][2] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][4] + dp[i-1][5]) % m;
        dp[i][3] = dp[i-1][2];
        dp[i][4] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][2] + dp[i-1][3]) % m;
        dp[i][5] = dp[i-1][4];
      },
      1 => {
        dp[i][0] = (dp[i-1][2] + dp[i-1][3] + dp[i-1][4] + dp[i-1][5]) % m;
        dp[i][1] = dp[i-1][0];
      },
      2 => {
        dp[i][2] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][4] + dp[i-1][5]) % m;
        dp[i][3] = dp[i-1][2];
      },
      _ => {
        dp[i][4] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][2] + dp[i-1][3]) % m;
        dp[i][5] = dp[i-1][4];
      },
    }
  }

  let mut ans: usize = dp[n].iter().sum();
  ans %= m;
  
  println!("{}", ans);
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5032
a = input().split()
a = [int(i) for i in a]
query = []
citydict = dict()
for i in range(a[1]):
	temp = input().split()
	temp = [int(i) for i in temp]
	query.append(temp)
	try:
		citydict[temp[0]].append(temp[1])
	except:
		citydict[temp[0]] = [temp[1]]
		
indexdict = dict()
for i in citydict:
	citydict[i] = sorted(citydict[i])
	indexdict[i] = dict()
	for j in range(len(citydict[i])):
		indexdict[i][citydict[i][j]] = j
		
for i in query:
	print ("%06d%06d" % (i[0],indexdict[i[0]][i[1]] + 1))

Measured memory_bytes: 123992
import java.util.*;
import java.io.*;
class Main {
    static int min;
    static int count(int[] a, int[][] queries) {
        int ans = 0;
        for(int[] q: queries) {
            if(a[q[1]]-a[q[0]]==q[2])
                ans+=q[3];
        }
        return ans;
    }
    static void recurse(int[] a, int idx, int prev, int m, int[][] queries) {
        if(idx==a.length) {
            min = Math.max(min, count(a, queries));
            return;
        }
        for(int i = prev; i<=m; i++) {
            a[idx] = i;
            recurse(a, idx+1, i, m, queries);
        }
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int[][] queries = new int[q][];
        for(int i = 0; i<q; i++)
            queries[i] = new int[]{sc.nextInt()-1, sc.nextInt()-1, sc.nextInt(), sc.nextInt()};
        int[] a = new int[n];
        min = Integer.MIN_VALUE;
        recurse(a, 0, 1, m, queries);
        System.out.println(min);
    }
}

Measured memory_bytes: 37348
#include <stdio.h>
int main(void){
    // Here your code !
    unsigned int  a,b;
    unsigned int work;
    unsigned int cnt=0;
    int i;
    for(i=0;i<200;i++){
        cnt=1;
        if(scanf("%d %d",&a,&b) == EOF) break;
        work = (a+b)/10;
        while(work){
            cnt++;
            work = work/10;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;


int main() {
    int k, n;
    scanf("%d%d", &n, &k);
    vector<int> data(n);
    rp(i, 0, n) {
        scanf("%d", &data.at(i));
    }
    sort(data.begin(), data.end());
    int ans = data.at(k-1) - data.at(0);
    rp(i, 0, n-k+1) {
        ans = min(ans, data.at(k-1+i)-data.at(i));
    }
    printf("%d", ans);
    return 0;

} 


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

int main(void){
  string s, t, ans="Yes";
  int j;
  cin >> s >> t;
  j = t.size() - 1;
  rep(i,j){
    if(s[i]==t[i]) continue;
    ans="No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int  long long int
#define pb push_back
#define inf 1e18
#define slld(x) scanf("%lld",&x)
#define plld(x) printf("%lld\n",x)
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define MOD 998244353
#define endl "\n" 
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("out.txt","w",stdout);
    // #endif  
    CHAL_BAAP_KO_MT_SIKHA
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(auto i:s){
        if(i=='R')
            cnt++;
    }
    int count=0;
    for(int i=0;i<cnt;i++){
        if(s[i]=='W')
            count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3724
#include <iostream>

using namespace std;

int main()
{
   int i,h,m,s;
   cin >> i;
   h = i / 3600;
   m = (i - h * 3600) / 60;
   s = (i - h * 3600 - m * 60) /1;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<string>
using namespace std;
//akasaka
string a;
int main(){
	cin>>a;
	int n=(a.size()-1)/2,m=(a.size()+3)/2,t=1;
	for(int i=0;i<=(n+1)/2-2;i++)
	{
		if(a[1+i-1]!=a[n-i-1])
		{
			t=0;
			break;
		}
	}
	if((a.size()-m)%2==1)
	for(int i=0;i<=(a.size()-m)/2-1;i++)
	{
		if(a[m+i-1]!=a[n-i-1])
		{
			t=0;
			break;
		}
	}
	else
	for(int i=0;i<=(a.size()-m)/2;i++)
	{
		if(a[m+i-1]!=a[n-i-1])
		{
			t=0;
			break;
		}
	}
	for(int i=0;i<=(a.size()+1)/2-2;i++)
	{
		if(a[1+i-1]!=a[a.size()-i-1])
		{
			t=0;
			//cout<<"p"<<endl;
			//break;
		}
	}
	if(t==1)
	cout<<"Yes";
	else
	cout<<"No";
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a;
	cin >> a;
	cout << 3 * a * a << endl;



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n, q, i, c, z, d;
	scanf( "%d", &n );
	int s[n];
	for( i = 0; i < n; i++ ){
		scanf( "%d", &s[i] );
	}
	scanf( "%d", &q );
	int t[q];
	for( i = 0; i < q; i++ ){
		scanf( "%d", &t[i] );
	}
	
	c = 0;
	d = 0;
	for( i = 0; i < q; i++ ){
		for( z = 0; z < n; z++ ){
			if( t[i] == s[z] ){
				d = 1;
				s[z] = -1;
			}
		}
		if( d == 1 ){
			c++;
		}
		d = 0;
	}
	
	printf( "%d\n", c );
	
	return 0;
}


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

int main () {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (K <= A)
    cout << K << endl;
  else if (K <= A + B)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;
}

Measured memory_bytes: 3592
N,D= map(int,input().split())
str_list = []
for i in range(N):
    str_list.append(list(input().split()))
#print(str_list)
b=int()
for i in range(N):
    a=[]
    a += str_list[i]
    x = (int(a[0]))**2+(int(a[1]))**2
    if x<=D**2:
        b+=1
    else:
        b+=0
print(b)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> B[i];
  }
  
  int MxM = M * M;
  bool flg = false;
  for (int i = 0; i < N - M + 1; ++i) {
    if (flg) {
      break;
    }
    for (int j = 0; j < N - M + 1; ++j) {
      int cnt = 0;
      bool flg2 = true;
      for (int k = 0; k < M; ++k) {
        if (!flg2) {
          break;
        }
        for (int l = 0; l < M; ++l) {
          char N_p = A[i+k][j+l];
          char M_p = B[k][l];
          if (N_p == M_p) {
            ++cnt;
          } else {
            flg2 = false;
            break;
          }
        }
      }
      if (cnt == MxM) {
        flg = true;
        break;
      }
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

const int MAX=300200;
int p[MAX];
int q[MAX];

int l=0;

void prime(){ 
  int n=0;
  
  for(int i=6;i<MAX;i++){
    bool flag=1;
    if(i%7==1||i%7==6){
      q[n]=i;
      for(int j=0;q[j]<i;j++){
	if(i%q[j]==0){
	  flag=0;
	  break;
	}
      }
      if(flag==1)p[l++]=q[n++];
    }
  }
}

int main(){
  int num;

  prime();
  
  while(1){
    cin>>num;
    if(num==1)break;
    cout<<num<<":";
    for(int i=0;p[i]<=num;i++){
      if(num%p[i]==0)cout<<" "<<p[i];
    }
    cout<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 1448
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll,ll>pll;
const  ll MAX=100000;
const  ll MOD=1e9+7;
vector<ll>sot,unsot;
ll f[MAX+100];
int main()
{

   string s;

   ll n;

cin>>n;


  cin>>s;


  if(n>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;














}




Measured memory_bytes: 3588
import math
mod=10**9+7

def main():
    N,M=map(int,input().split())
    ans=0
    
    if abs(N-M)>=2:
        print(0)
    else:
        if N==M:
            ans+=(math.factorial(N)*math.factorial(M))*2
            ans%=mod
            print(ans)
            
        else:
            ans+=(math.factorial(N)*math.factorial(M))
            ans%=mod
            print(ans)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

int main() {
    fastio;
    int k;
    cin >> k;
    queue<ll> q;
    rep1(i,9) q.push(i);
    ll lun;
    int i=0;
    while (true) {
        lun = q.front(); q.pop();
        if (++i == k)
            break;
        ll r = lun % 10;
        ll m = lun*10 + r;
        if (r != 0)
            q.push(m-1);
        q.push(m);
        if (r != 9)
            q.push(m+1);
    }
    cout << lun << endl;
}


Measured memory_bytes: 4756
// 2011/09/16 Tazoe

#include <iostream>
#include <string>
#include <map>
using namespace std;

int main()
{
	while(true){
		int n, k;
		cin >> n;
		cin >> k;
		if(n==0&&k==0)
			break;

		string C[10];
		for(int i=0; i<n; i++)
			cin >> C[i];

		map<string, bool> memo;

		for(int i0=0; i0<n; i0++){
			for(int i1=0; i1<n; i1++){
				if(i1==i0)
					continue;

				if(k>=3)
					for(int i2=0; i2<n; i2++){
						if(i2==i0||i2==i1)
							continue;

						if(k>=4)
							for(int i3=0; i3<n; i3++){
								if(i3==i0||i3==i1||i3==i2)
									continue;

								string num = C[i0]+C[i1]+C[i2]+C[i3];
								if(memo[num])
									continue;
								else
									memo[num] = true;
							}
						else{
							string num = C[i0]+C[i1]+C[i2];
							if(memo[num])
								continue;
							else
								memo[num] = true;
						}
					}
				else{
					string num = C[i0]+C[i1];
					if(memo[num])
						continue;
					else
						memo[num] = true;
				}
			}
		}

		cout << memo.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 0
//4doll cake 7doll donatu
#include<stdio.h>
int main(void){
    int N,onoff=0;

    scanf("%d",&N);
    int i,j;
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(4*i+j*7==N)onoff=1;
        }
    }
    if(onoff==1)printf("Yes");
    else printf("No");
    return 0;
}

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

int main() {
    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> pref(n+1, 0);

    for (int i = 1; i < n; i++) {
        bool flag = false;
        if (s[i - 1] == 'A' && s[i] == 'C')
            flag = true;
        pref[i] = pref[i - 1] + flag;
    }

    while(q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;

        cout << pref[r] - pref[l] << endl;
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int d[]={0,2,5,5,4,5,6,3,7,6};
int dp[10009];

int main(){
  int n,m;
  int a[19];
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>a[i];
  sort(a,a+m);
  reverse(a,a+m);
  for(int i=1;i<=n;i++)dp[i]=-INF;
  for(int i=0;i<=n;i++){
    for(int j=0;j<m;j++){
      if(i-d[a[j]]>=0){
	dp[i]=max(dp[i],dp[i-d[a[j]]]+1);
      }
    }
  }
  int now=n;
  while(now){
    for(int i=0;i<m;i++){
      if(now-d[a[i]]>=0&&dp[now-d[a[i]]]==dp[now]-1){
	cout<<a[i];
	now-=d[a[i]];
	break;
      }
    }
  }   
  cout<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> dic;
  for (int i = 1; i <= n; i++) {
    string s;
    int p;
    cin >> s >> p;
    p *= -1;
    dic.push_back(tie(s, p, i));
  }
  sort(all(dic));
  for (int i = 0; i < n; i++) {
    cout << get<2>(dic[i]) << endl;
  }
}


Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define next next228


ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s;
	cin >> s;
	int n = (int)s.size();
	int cnt = 0;
	int res = 0;
	vector<bool> used(n);
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] == 'B' && s[i + 1] == 'C') {
			used[i] = used[i + 1] = 1;
		}
	}
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == 'A') res += cnt;
		else if (used[i]) {
			if (s[i] == 'B') ++cnt;
		} else cnt = 0;
	}
	cout << res << '\n';
    return 0;
} // kek;








Measured memory_bytes: 720
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 2e5+10;
int n,mx;
ll a[N],b[N],c[N];

int top;
PA stk[N];
inline double slope(PA a,PA b){
	return (double)(b.fi-a.fi)/(b.se-a.se);
}

int main(){
	n=read(),mx=0;
	For(i,1,n) a[i]=read(),mx=a[mx]<a[i]?i:mx;
	For(i,1,n) b[i]=read();
	rotate(a+1,a+mx,a+n+1),rotate(b+1,b+mx,b+n+1),a[++n]=a[1],b[n]=b[1];
	FOR(i,2,n) c[i+1]=2*(b[i]+c[i])-c[i-1];
	For(i,1,n) a[i]-=c[i];
	stk[top=1]=mp(a[1],1);
	For(i,2,n){
		while (top>1&&slope(stk[top-1],stk[top])<slope(stk[top-1],mp(a[i],i))) --top;
		stk[++top]=mp(a[i],i);
	}
	ll ans=0;
	FOR(i,1,top){
		int l=stk[i].se,r=stk[i+1].se;
		ans=ans+a[l]*(r-l+1)+a[r]*(r-l-1);
	}
	FOR(i,1,n) ans+=2*c[i];
	printf("%0.12lf\n",1.0*ans/2/(n-1));
}

Measured memory_bytes: 11452
let (n,a,b) = Scanf.scanf "%d %d %d\n" (fun x y z -> (x,y,z))

let pr x = print_endline (string_of_int x)

let (--) m n =
  let rec iter i res =
    if i >= m then iter (i - 1) (i::res)
    else res in
  let rec iter' i res =
    if i <= m then iter' (i + 1) (i::res)
    else res in
  if m <= n then iter n []
  else iter' n []

let digit_list_of_num n =
  let digit n = int_of_float (floor (log10 (float_of_int n))) in
  let base digit = int_of_float (10.0 ** (float_of_int digit)) in
  let rec iter rem res =
    let base = digit rem
              |> base in
    let top = rem / base in
    if base = 1 then top :: res
    else iter (rem - (top * base)) (top :: res) in
  iter n []

let digit_sum n =
  digit_list_of_num n
  |> List.fold_left (fun sum x -> x + sum) 0
    
let () = List.fold_left
           (fun sum x ->
             let ds = digit_sum x in
             if ds >= a && ds <= b then
               sum + x
             else sum) 0 (1--n)
         |> pr


Measured memory_bytes: 1792
def slove():
    import sys
    input = sys.stdin.readline
    abc = list(map(int, input().rstrip('\n').split()))
    abc.sort()
    k = int(input().rstrip('\n'))
    for i in range(k):
        abc[-1] *= 2
    print(sum(abc))


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38356
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;


int main(){
    string S;
  int A[5],min=124,k,ans=0;

  for(int i=0;i<5;i++){
    cin>>A[i];
  }
  for(int i=0;i<5;i++){
    if(A[i]%10 != 0 && A[i]%10 < min){
      min = A[i]%10;
      k = i;
    }
  }

  for(int i=0;i<5;i++){
    if(k==i)
      ans += A[i];
    else if(A[i]%10 == 0)
      ans +=A[i]-A[i]%10;
    else
      ans += A[i]-A[i]%10+10;
  }

  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i * i <= n; i++) ans = i * i;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#define ll long long

using namespace std;
ll MOD = 1000000007;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll fun(ll a){
    ll ans = 1;
    ll mod = 1000000007;
    for(ll i = 1; i <= a; i++)
        ans = ans * i % mod;
    return ans;
}
ll comb(ll n, ll r){
    ll child = 1, mother = 1;
    ll mod = 1000000007;
    for(ll i = 1; i <= r; i++){
        child = child * (n-i+1) % mod;
        mother = mother * i % mod;
    }
    mother = modpow(mother, mod-2, mod);
    ll ans = child * mother % mod;
    return ans;
}

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    ll tn = modpow(2, n, MOD);
    ll nca = comb(n,a);
    ll ncb = comb(n, b);
    ll ans;
    ans = tn-1-nca;
    if(ans<0) ans+=MOD;
    ans-=ncb;
    if(ans<0) ans += MOD;
    cout << ans << endl;
   return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A[3][3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(y,3) FOR(x,3) {
		cin>>A[y][x];
	}
	
	for(y=1;y<=2;y++) for(x=1;x<=2;x++) {
		if(A[0][0]+A[y][x]!=A[y][0]+A[0][x]) return _P("No\n");
	}
	
	_P("Yes\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

N, K = MAP()
A = LIST()

cnt = 0
while 1:
	a = [0]*(N+1)
	flg = 1
	for i in range(N):
		a[max(0, i-A[i])] += 1
		a[min(N, i+A[i]+1)] -= 1
		if max(0, i-A[i]) == 0 and min(N, i+A[i]+1) == N:
			flg *= 1
		else:
			flg *= 0
	A = list(accumulate(a))
	cnt += 1
	if cnt == K:
		print(*A[:-1])
		exit()
	if flg:
		break

A = [N]*N
print(*A)


Measured memory_bytes: 181712
N, K = map(int, input().split())
L = []
mini = float('inf')

for i in range(N):
    h = int(input())
    L.append(h)

L.sort(reverse=True)

for i in range(len(L)-K+1):
    if L[i] - L[i+K-1] < mini:
        if L[i] - L[i+K-1] == 0:
            print(0)
            exit()
        else:
            mini = L[i] - L[i+K-1]

print(mini)

Measured memory_bytes: 13348
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n := readInt()
	a := make([]int, n)
	total := 0
	for i := range a {
		a[i] = readInt()
		total += a[i]
	}

	ans := math.MaxInt64
	sum := 0
	for _, v := range a[:len(a)-1] {
		sum += v
		ans = min(ans, abs(total-sum*2))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n+1], b[n+1], c[n];
for(int i = 1; i <= n; ++i){
	cin >> a[i];
}
for(int i = 1; i <= n; ++i){
	cin >> b[i];
}
for(int i = 1; i < n; ++i){
	cin >> c[i];
}
int pts = b[a[1]];
for(int i = 2; i <= n; ++i){
	pts += b[a[i]];
	if(a[i] - a[i-1] == 1) 
		pts += c[a[i-1]];
}
cout<<pts;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  cin >> n;
  vector<uint64_t> a(n);
  cin >> a;
  map<uint64_t, size_t> cnt;
  for(const auto i: a) ++ cnt[i];
  vector<pair<uint64_t, size_t>> b;
  b.reserve(n);
  for(const auto &pr: cnt)
    if(pr.second > 1) b.push_back(pr);

  if(b.empty())
    cout << 0;
  else if(b.back().second > 3)
  {
    const auto pr = b.back();
    cout << pr.first * pr.first;
  }
  else if(b.size() == 1)
    cout << 0;
  else
  {
    const auto x = b.back().first;
    const auto y = b[b.size() - 2].first;
    cout << x * y;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 7296
from itertools import combinations
import copy
H,W,K = map(int,input().split())
cs = [list(input()) for i in range(H)]
HC = [i for i in range(H)]
WC = [i for i in range(W)]
fBlackCount=0
for i in range(H):
  fBlackCount += cs[i].count('#')
cBlackCount=fBlackCount
c=0
for i in range(H+1):
  for j in range(W+1):
    for selectRows in combinations(HC,i):
      for selectCols in combinations(WC,j):
        #print(selectRows)
        #print(selectCols)
        cBlackCount=fBlackCount
        for m in range(H):
          for n in range(W):
            if cs[m][n] == '#':
              if m in selectRows or n in selectCols:
                cBlackCount-=1
        if cBlackCount == K:
          #print(i)
          #print(j)
          #print(selectRows)
          c+=1
print(c)
          
  

Measured memory_bytes: 9352