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

int main(){
  int n;
  cin>>n;
  vector<long> v(n);
  long ans=1e12;
  long temp;
  if(n<=1)cout<<0<<endl;
  else{
   	for(int i=0;i<n;i++)cin>>v[i];
    ans=min(ans,abs(v[1]-v[0]));
    temp=0;
    for(int i=2;i<n;i++){
    	long x=min(temp+abs(v[i]-v[i-2]),ans+abs(v[i]-v[i-1]));
        temp=ans;
        ans=x;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int N,a[1000001];
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;++i) scanf("%d",a+i), a[i]-=i;
	sort(a+1,a+N+1);
	int X=a[N+1>>1];
	long long Ans=0;
	for(int i=1;i<=N;++i) Ans+=X-a[i]<0?a[i]-X:X-a[i];
	printf("%lld\n",Ans);
	return 0;
}

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

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

    string ans = "Yes";

    int n = s.size();

    for (int i=0; i<(n-1)/2; i++) {
        if (s.at(i) != s.at(n-1-i)) {
            ans = "No";
            break;
        }
    }

    for (int i=0; i<(n-1)/4; i++) {
        if (s.at(i) != s.at(((n-1)/2)-1-i)) {
            ans = "No";
            break;
        }
    }

    for (int i=0; i<(n-1)/4; i++) {
        if (s.at(((n-1)/2)+1+i) != s.at(n-1-i)) {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    ll n,h; cin >> n >> h;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    
    ll k = 0,ans = 0;
    for(int i=0;i<n;i++){
        if(b[i] > a[0] && h > 0){
            h -= b[i];
            ans++;
        }else{
            break;
        }
    }
    if(h < 0){
        cout << ans << endl;
        return 0;
    }else{
        int p = h / a[0];
        if(h % a[0] != 0) p++;
        ans += p;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>

#define PI 3.14159265358979323846

using namespace std;

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

    cout << 2 * R * PI << endl;
    return 0;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <cstdio>
int main(){
	int n;long long f0,f1,f2;
	scanf("%d%lld",&n,&f0);
	f1=f2=-1e18;
	for (int i=1;i<n;i++){
		char op;int x;
		scanf(" %c%d",&op,&x);
		if (op=='-') f0=f1=std::max(f0-x,f2=f1+x);
		else f0+=x,f1=std::max(f1-x,f2+=x);
	}
	printf("%lld\n",f0);
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,k = [int(i) for i in read().split()]

a = list(range(n+1))
r = sum(a[n+1-k:])
l = sum(a[:k])

ans = 0
for i in range(k,n+2):
    ans += r-l+1
    l += i
    r += n-i

print(ans%(10**9+7))





Measured memory_bytes: 18076
#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 N,M,H,W;
int A[1024][1024];

int B[1024][1024];
void check() {
	int x,y;
	FOR(y,H) FOR(x,W) {
		B[y+1][x+1]=B[y][x+1]+B[y+1][x]-B[y][x]+A[y][x];
	}
	int ret=0,sum=0;
	int x1,x2,y1,y2;
	FOR(x2,W) FOR(x1,x2+1) FOR(y2,H) FOR(y1,y2+1) {
		int num=B[y2+1][x2+1]-B[y1][x2+1]-B[y2+1][x1]+B[y1][x1];
		if(num%2==1) ret++;
		sum++;
	}
	cout<<ret<<"/"<<sum<<endl;
}


void dfs(int y1,int y2,int x1,int x2) {
	if(y1>y2 || x1>x2) return;
	int my=(y1+y2)/2;
	int mx=(x1+x2)/2;
	A[my][mx]=1;
	dfs(y1,my-1,x1,mx-1);
	dfs(y1,my-1,mx+1,x2);
	dfs(my+1,y2,x1,mx-1);
	dfs(my+1,y2,mx+1,x2);
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	H=(1<<N)-1;
	W=(1<<M)-1;
	
	//usleep(H*500);
	//usleep(W*100);
	
	dfs(0,H-1,0,W-1);
	//check();
	
	FOR(y,H) {
		FOR(x,W) cout<<A[y][x];
		cout<<endl;
	}
	
}


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: 5376
#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    Int(n);
    vi data(n);
    rep(i, n) cin >> data[i];

    sort(all(data));
    reverse(all(data));
    int a = -1;
    Rep(i, n) {
        if (data[i-1] == data[i]) {
            if (a == -1) {
                a = data[i];
                i++;
            } else {
                std::cout << a * data[i] << std::endl;
                return 0;
            }
        }
    }
    std::cout << 0 << std::endl;

    return 0;
}





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


   int a,b,c,d;
   cin>>a>>b>>c>>d;

   int i=1,found=0;

   while(found==0)
   {
       if(i%2!=0)
       {
           c=c-b;
           if(c<=0)
           {
               cout<<"Yes";
               found=1;
               break;
           }
       }
       else
       {
           a=a-d;
           if(a<=0)
           {
               cout<<"No";
               found=1;
               break;
           }
       }
       i++;

   }




}


Measured memory_bytes: 3128
import collections

n = int(input())
a = list(map(int, input().split()))

d = collections.defaultdict(int)
edges = []
for edge in a:
    d[edge] += 1
    if d[edge] % 2 == 0:
        edges.append(edge)

edges.sort(reverse=True)
if len(edges) < 2:
    print(0)
else:
    print(edges[0] * edges[1])


Measured memory_bytes: 18600
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int a[210000],b[210000];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int i,j,q=1,flag=1,k=0;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        if(n%2==0)
        {
            for(i=1; i<=n/2; i++)
            {
                b[i]=a[n-k];
                k+=2;
            }
            for(i=n; i>n/2; i--)
            {
                b[i]=a[n-q];
                q+=2;
            }
        }
        else
        {
            for(i=1;i<=(n+1)/2;i++)
            {
                b[i]=a[n-k];
                k+=2;
            }
            for(i=n;i>(n+1)/2;i--)
            {
                b[i]=a[n-q];
                q+=2;
            }
        }
        for(i=1; i<=n; i++)
        {
            if(i==1)
                printf("%d",b[i]);
            else
                printf(" %d",b[i]);
        }

        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3968
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9 + 7;

long long n, k;
long long mat[55][55], res[55][55];

void solve() {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			res[i][j] = i == j;
		}
	}

	long long tmp[55][55];

	while (k) {
		if (k & 1) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					tmp[i][j] = 0;
					for (int k = 0; k < n; k++) {
						tmp[i][j] = (tmp[i][j] + (res[i][k] * mat[k][j]) % MOD) % MOD;
					}
				}
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					res[i][j] = tmp[i][j];
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				tmp[i][j] = 0;
				for (int k = 0; k < n; k++) {
					tmp[i][j] = (tmp[i][j] + (mat[i][k] * mat[k][j]) % MOD) % MOD; 
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				mat[i][j] = tmp[i][j];
			}
		}

		k >>= 1;
	}
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> mat[i][j];
		}
	}

	solve();

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			ans = (ans + res[i][j]) % MOD;
		}
	}

	cout << ans << '\n';

	return 0;
} 

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

int main() {
  string s; cin >> s;
  int count0=0 , count1=0;
  rep(i,s.size()){
    if(s[i] == '0') count0++;
    else count1++;
  }

  cout << 2 * min(count0 , count1);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a[3];
	cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<((a[0]&1&a[1]&1&a[2]&1)?a[0]*a[1]:0)<<endl;
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
template<class T>inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
const long long INF=1LL<<60;

//入力
int N;
long long a[100010][3];

//dpテーブル
long long dp[100010][3];

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k){
                    continue;
                }
                chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    long long res=0;
    for(int i=0;i<3;i++){
        chmax(res,dp[N][i]);
    }
    cout<<res<<endl;
}
  
  



Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int h,w,n;
int main()
{
	n=read(),h=read(),w=read();
	cout<<(n-w+1)*(n-h+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  string S; cin >> S;
  ll K; cin >> K;
  ll not_one_num = 101;
  for(ll i = 0;i < S.size();i++){
    if(S[i] != '1'){
      not_one_num = i;
      break;
    }
  }


  if(K > not_one_num)cout << S[not_one_num] << endl;
  else cout << 1 << endl;
  
}


Measured memory_bytes: 256
use std::cmp;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        m:usize,
        student_point:[(i32, i32);n],
        check_point:[(i32, i32);m],
    }
    for i in 0..n{
        let mut ans = 1000000000;
        let mut ans_point = 0;
        for j in 0..m{
            if ans > (student_point[i].0 - check_point[j].0).abs()
            + (student_point[i].1 - check_point[j].1).abs(){
                ans = cmp::min(ans, (student_point[i].0 - check_point[j].0).abs()
                             + (student_point[i].1 - check_point[j].1).abs());
                ans_point = j+1;
            }
        }
        println!("{}", ans_point);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    For1(i,n)ans+=i;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class Snakes
    {
        public static bool CheckA(string input)
        {
            // 先頭は「>'」
            if (input.Substring(0, 2) != ">'") { return false; }
            // 末尾は「~」
            if (input.Substring(input.Length - 1, 1) != "~") { return false; }

            // 真ん中のチェック
            var tmp = input.Substring(2, input.Length - 3).Split('#');
            // 「#」が無いか複数存在
            if (tmp.Length != 2) { return false; }

            string bef = tmp[0], aft = tmp[1];

            if (bef.Length == 0 || aft.Length == 0) { return false; }
            // 「=」以外の文字を含む
            if (bef.Replace("=", "").Length > 0) { return false; }
            if (aft.Replace("=", "").Length > 0) { return false; }
            // 「#」の前と後が同じ長さではない
            if (bef.Length != aft.Length) { return false; }

            return true;
        }

        public static bool CheckB(string input)
        {
            // 先頭は「>^」
            if (input.Substring(0, 2) != ">^") { return false; }
            // 末尾は「~~」
            if (input.Substring(input.Length - 2, 2) != "~~") { return false; }
            // 「Q=」が存在しない
            if (input.Substring(2, input.Length - 4).Length == 0) { return false; }
            // 「Q=」以外の文字列が存在する
            if (input.Substring(2, input.Length - 4).Replace("Q=", "").Length > 0) { return false; }

            return true;
        }

        public static int Main()
        {
            int s = int.Parse(Console.ReadLine());
            for (int i = 0; i < s; i++)
            {
                string input = Console.ReadLine();
                if (CheckA(input)) { Console.WriteLine("A"); }
                else if(CheckB(input)){Console.WriteLine("B");}
                else { Console.WriteLine("NA"); }
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9316
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		// 数値の入力
		int S = sc.nextInt();

		// 入力値の左側２けた
		int L = S / 100;
		// 入力値の右側２けた
		int R = S % 100;

		// 左が12を超えている(LL)
		if (L > 12 || L==0) {
			// 右が0～12の場合
			if (0 < R && R < 13) {
				System.out.print("YYMM");
			} else {
				System.out.print("NA");
			}
		}

		// 左が1～12(MM)の場合
		if (0 < L && L < 13) {
			// 右も1～12の場合
			if (0 < R && R < 13) {
				System.out.print("AMBIGUOUS");
				// 右が12を超えている
			} else if (R > 13 || R==00) {
				System.out.print("MMYY");
			} else {
				System.out.print("NA");
			}
		}
	}
}


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

using namespace std;

int main(){
  vector<int> a = {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 N;
  cin >> N;
  cout << a[N-1];
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n,i,w[100],s=0,t=0,p=0,q;
	scanf("%d", &n);
	q = n-1;
	for (i = 0; i < n;i++) scanf("%d", &w[i]);
	for (i = 0; i < n; i++) {
		if (s < t) {
			s += w[p];
			p++;
		}
		else {
			t += w[q];
			q--;
		}
	}
	s -= t;
	if (s < 0) s *= -1;
	printf("%d", s);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 100000000000000000
#define limit 200005
#define minval -100000000000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 

void input()
{
	lli a,b,c,d;
	cin >> a >> b >> c >> d;

	lli pro = a*c;

	//positive
	if(b >= 0 && d >= 0)
		pro = max(pro, b*d);
	if(a <= 0 && c <= 0)
		pro = max(pro, a*c);

	//pos , neg
	if( b >= 0 && c <= 0)
	{
		pro = max(pro, max(0ll,a)*min(0ll,d));
	}
	//neg positive
	if(a <= 0 && d >= 0)
	{
		pro = max(pro,min(0ll,b)*max(0ll,c));
	}
	cout << pro << '\n';
}	

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 3660
N,T=map(int,input().split())
A=list(map(int,input().split()))
ans=0
max_=0
B=[0]*N
for i in reversed(range(N)):
    B[i]=max(B[i],max_-A[i])
    max_=max(max_,A[i])
m=max(B)
print(B.count(m))

Measured memory_bytes: 84772
#include <stdio.h>
int main(){
	int H,W,i,j;
	for(;;){
	scanf("%d %d", &H, &W);
	if(H == 0 && W == 0)break;
	for ( i = 0; i < H; i++ ){
	for ( j = 0; j < W; j++ ){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
} return 0;
}

Measured memory_bytes: 572
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

class CCellInversion {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,c=0;
        string s;
        in>>n>>s;
        vector<bool> a(2*n);
        fr(i,2*n) a[i]=(s[i]=='B');
        modint ans(1);
        fr(i,2*n){
            if((a[i]+c)%2) ++c;
            else ans*=c,--c;
        }
        if(c!=0) ans=0;
        Fr(i,n) ans*=i;
        out<<ans<<endl;
    }
};

int main() {
    CCellInversion solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 720
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}
int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)	cin>>a[i];
	int zero=0;
	for(int i=0;i<n;i++) if(a[i]==0)zero++;
	if(zero>0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	int ans=1;
	for(int i=0;i<n;i++)
	{
		if(ans<=1000000000000000000/a[i])
			ans*=a[i];
		else
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
	{
		solve();
	}
}




Measured memory_bytes: 4400
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a[101010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


  // cin >> n;
  // for(int i=1;i<=n;i++){
  //   cin >> a[i];
  //   if(a[i]==0){
  //     cout << 0 << endl;
  //     return 0;
  //   }
  // }  
  ld a,b;
  cin >> a >> b;
  ld res = a*b;
  int ans = (int)res;
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
const int INF=100005;
struct big{
	int num[12];
	int len;
};
bool cmp(big a,big b){
	if(a.len!=b.len){
		return a.len>b.len;
	}
	for(int i=9;i>0;i--){
		if(a.num[i]!=b.num[i]){
			return a.num[i]>b.num[i];
		}
	}
	return 1;
}
big dp[10005][12];
int t,n,m,v[12],w[12];
int x[10]={INF,2,5,5,4,5,6,3,7,6};
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>t;
		v[i]=t;
		w[i]=x[t];
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			dp[i][j].len=-1;
			for(int k=1;k<10;k++){
				dp[i][j].num[k]=0;
			}
		}
	}
	for(int i=1;i<=m;i++){
		dp[0][i].len=0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j]=dp[i][j-1];
			if(i>=w[j]&&dp[i-w[j]][j].len!=-1){
				big tt=dp[i-w[j]][j];
				tt.len++;
				tt.num[v[j]]++;
				if(!cmp(dp[i][j],tt)){
					dp[i][j]=tt;
				}
			}
		}
	}
	big tt=dp[n][m];
	for(int i=9;i>0;i--){
		for(int j=0;j<tt.num[i];j++){
			cout<<i;
		}
	}
//	for(int i=0;i<=n;i++){
//		for(int j=1;j<=m;j++){
//			for(int k=1;k<=9;k++){
//				cout<<dp[i][j].num[k]<<" ";
//			}
//			cout<<"\t";
//		}
//		cout<<endl;
//	}
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define endl '\n'


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	//ll t; cin>>t; while(t--)
	{
		ll a,b,c,d,e;
		cin>>a>>b>>c>>d>>e;
		if(a==0)
		cout<<1;
		if(b==0)
		cout<<2;
		if(c==0)
		cout<<3;
		if(d==0)
		cout<<4;
		if(e==0)
		cout<<5;
	}
	
   
	
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
int n , k , pos;
int main()
{
	abdelrahman010
	cin >> n >> k;
	k--;
	for(int i = 1 , x;i <= n;i++)
	{
		cin >> x;
		if(x == 1)
			pos = i;
	}
	int ans = 1e9;
	for(int i = max(1 , pos - k);i <= min(n , pos + k);i++)
		ans = min(ans , (i + k - 2) / k + (n - i + k - 1) / k);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






std::vector<long long> fact_inv, fact;

long long power(long long a, unsigned long long b, long long m){
    long long ret(1);
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
        if(ret < 0) ret += m;
        if(a < 0) a += 0;
    }
    return ret;
}

long long power(long long a, unsigned long long b) {
    return power(a, b, MOD);
}

long long inv(long long a, long long m){ // GCD(a, m) = 1
    return power(a, m-2, m);
}

long long inv(long long a){
    return inv(a, MOD);
}

long long comb(long long a, long long b, long long m){
    if(a < b) return 0;
    if(a < 0 || b < 0) return 0;
    long long ret = fact[a];
    ret = ret * fact_inv[b] % m;
    ret = ret * fact_inv[a-b] % m;
    return ret;
}

long long comb(long long a, long long b){
    return comb(a, b, MOD);
}

void precom(int n, long long m){
    fact.resize(n);
    fact_inv.resize(n);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    for(int i = 2; i < n; ++i) fact[i] = fact[i-1] * i % m;
    for(int i = 2; i < n; ++i) fact_inv[i] = inv(fact[i], m);
    return;
}

void precom(int n){
    precom(n, MOD);
    return;
}


int main(){
    int N, M; std::cin >> N >> M;
    precom(M + 4);
    long long ans(fact[M] * fact_inv[M-N] % MOD);
    long long s(ans);
    for(int i(1); i <= N; ++i){
        int a((i % 2) ? 1 : -1);
        long long c(fact[M-i] * fact_inv[M-N] % MOD);
        c *= comb(N, i);
        ans -= a * (c % MOD);
        ans %= MOD;
        if(ans < 0) ans += MOD;
    }
    ans *= s;
    ans %= MOD;
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 11064
import sys
from math import isinf
def warshall_floyd(v_count: int):
    """ ワーシャルフロイド　(user:htkb)
    :param v_count: 頂点数
    :param matrix:  隣接行列(到達不能はfloat("inf"))
    """
    # 到達不能をfloat("inf")にしておけば余計なチェックを入れなくても
    # inf > inf+(-1) のような到達不能＋負辺が繋がってしまうことはない
    global matrix
    for i in range(v_count):
        for j, c2 in enumerate(row[i] for row in matrix):
            for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3 # min(c1, c2+c3)

if __name__ == "__main__":
    V,E = map(int, input().split())
    matrix = [[float('inf')]*V for _ in range(V)]
    for i in range(V):
        matrix[i][i] = 0

    for _ in range(E):
        s,t,d = map(int, input().split())
        matrix[s][t] = d

    warshall_floyd(V)
    for i in range(V):
        if matrix[i][i] < 0:
            print("NEGATIVE CYCLE")
            sys.exit()
    for mi in matrix:
        print(' '.join( ('INF' if isinf(dij) else str(dij) for dij in mi)))



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

using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    int x[100000];
    int center_index = 2E9;

    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }

    int min_time = 2E9;
    for(int i = 0; i < N - K + 1; ++i){
        int time = 0;
        if(abs(x[i]) <= abs(x[K-1 + i])){
            if(x[i] < 0){
                time += abs(x[i]*2);
            }
                time += x[K-1+i];
        }else{
            if(x[K-1+i] >0){
                time += x[K-1+i] * 2;
            }
            time += abs(x[i]);
        }
        min_time = min(min_time, time);
    }

    cout << min_time << endl;

    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;

int q[55][2];// num, time
int wr[55][15];
vector<tuple<int,int,int> > v1;

int main(){
	int m,t,p,r;
	int i,j,k;
	int a,b,c,d;
	int bef[3];
	while(cin>>m>>t>>p>>r){
		if(!m)break;
		v1.clear();
		memset(wr,0,sizeof(wr));
		memset(q,0,sizeof(q));
		for(i=0;i<r;i++){
			cin>>a>>b>>c>>d;
			b--;
			if(d==0){
				q[b][0]++,q[b][1]+=wr[b][c]*20+a;
			}else wr[b][c]++;
		}
		for(i=0;i<t;i++){
			v1.push_back(make_tuple(q[i][0],-q[i][1],i));
		}
		sort(v1.rbegin(),v1.rend());
		for(i=0;i<t;i++){
			tie(a,b,c)=v1[i];
			if(i!=0){
				if(bef[0]==a && bef[1]==b)cout<<"=";
				else cout<<",";
			}
			cout<<c+1;
			bef[0]=a,bef[1]=b,bef[2]=c;
		}
		cout<<endl;
	}
}
	



Measured memory_bytes: 3112
from heapq import heapify, heappush, heappop
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapify(A)
while M > 0:
    heappush(A, heappop(A) / 2)
    M -= 1
print(-sum(int(i) for i in A))

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  ll n, ans = 0; cin >> n;
  for(ll i = 1; i*i <= n; i++){
    ans = max(ans, (ll)pow(i, 2));
  }
  cout << ans << endl;
  system("pause");
}

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

int main(void){
  int n, a[100], b[100], c[100];
  int ans=0;
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> a[i];
  for (int i=0; i<n; i++) cin >> b[i];
  for (int i=0; i<n-1; i++) cin >> c[i];
  ans=b[a[0]-1];
  for (int i=1; i<n; i++){
    ans += b[a[i]-1];
    if (a[i]==a[i-1]+1) ans += c[a[i-1]-1];
//    cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    ll ans = 0;
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        if (mx > h[i]) {
            ans += mx - h[i];
            h[i] = mx;
        }
        mx = max(mx, h[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3996
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long count = 0;
		for(int i = 0; i < n; i ++) {
			if(scan.nextInt() % 2 == 1 && i % 2 == 0) {
				count++;
			}
		}
		System.out.println(count);	
	}

}

Measured memory_bytes: 27164
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
//input
int A,B,C,K;


//processing
int cnt;


//dpTable
//int dp[100050];

int main(){
    cin >> A >> B >> C >> K;
    while (A >= B){
        cnt++;
        B *= 2;
    }
    while (B >= C){
        cnt++;
        C *= 2;
    }
    if (cnt <= K) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,a[200050];
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	sort(a+1,a+n+1,greater<ll>());
	ll jwb=0;
	for(int i=2; i<=n; i++){
		jwb+=a[(i+1)/2];
	}
	cout << jwb << endl;
}

Measured memory_bytes: 5172
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] l=new int[2*n];
        for (int i = 0; i < 2*n; i++) {
            l[i]=sc.nextInt();
        }
        Arrays.sort(l);
        long ans=0;
        for (int i = 0; i < 2*n; i++) {
            if(i%2==0)ans+=l[i];
        }
        out.println(ans);
    }
}

Measured memory_bytes: 21460
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, k;
    cin >> n >> k;
    deque<int> v(n);
    rep(i, n) cin >> v[i];

    auto l = initVec2<int>(n + 1, n + 1);
    auto r = initVec2<int>(n + 1, n + 1);
    //vector<int> l(n * 2 + 1), r(n * 2 + 1);
    vector<int> p, m;
    int sp, sm;
    sp = sm = 0;
    rep(i, n){
        if(v[i] >= 0){
            p.push_back(v[i]);
            sp += v[i];
        }else{
            m.push_back(v[i]);
            sm += v[i];
            sort(ALL(m));
        }
        l[i+1][0] = sp + sm;
        int sum = sm;
        int c = 0;
        for(int t = 0; t < SZ(m); t++){
            sum -= m[t];
            c++;
            l[i+1][t+1] = sp + sum;
        }
    }
    p = vector<int>();
    m = vector<int>();
    sp = sm = 0;
    for(int i = n - 1; i >= 0; i--){
        if(v[i] >= 0){
            p.push_back(v[i]);
            sp += v[i];
        }else{
            m.push_back(v[i]);
            sm += v[i];
            sort(ALL(m));
        }
        int j = n - 1 - i;
        r[j+1][0] = sp + sm;
        int sum = sm;
        int c = 0;
        for(int t = 0; t < SZ(m); t++){
            sum -= m[t];
            c++;
            r[j+1][t+1] = sp + sum;
        }
    }

    int ans = 0;
    rep(i, k + 1){
        for(int j = 0; j <= n; j++){
            for(int a = 0; a <= n; a++){
                if(j + a > k || j + a > n){
                    continue;
                }
                for(int b = 0; b <= n; b++){
                    if(j + a + b > k){
                        continue;
                    }
                    for(int c = 0; c <= n; c++){
                        if(j + a + b + c > k){
                            continue;
                        }
                        ans = max(ans, l[j][b] + r[a][c]);

                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
    
x,y = map(int,input().split())


if (x+y)%3 != 0 or not(x <= 2*y and y <= 2*x):
    print(0)
    exit()
else:
    s = (x+y)//3
 
t = min((x-s),(y-s))

print(combination(s,t))

Measured memory_bytes: 3064
from itertools import product


def solve(string):
    d = len(string)
    if d == 1:
        return string
    s0, ss, sn = int(string[0]), int(string[1:-1] or 0), int(string[-1])
    t = [[0] * 10] + [[int("1" * (d - 2) or 0)] * 10 for _ in range(9)]
    for i in range(1, 10):
        t[i][i] += 1
    for i, j in product(range(1, s0), range(10)):
        t[i][j] += 10**(d - 2)
    for j in range(10):
        t[s0][j] += ss + 1 if j <= sn else ss
    return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
     long long a,b;
    while(1){
        cin >> a >> b;
        if(cin.eof()){
            break;
        }
        long long sum = a + b;
        int cnt = 1;
        while(sum/10>=1){
            sum/=10;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int checkPalindrome(char* str, int beg, int end){
	int i;
	for(i=0;i<(end-beg+1)/2;i++){
		if(str[beg+i]!=str[end-i])
			return 0;
	}
	return 1;
}

int main(void) {
	// your code goes here
	char str[100];
	scanf("%s",str);
	int n = strlen(str);
	int ctr = (n - 1)/2;
	int strong = 0;
	if(checkPalindrome(str,0,n-1)==1){
		if(checkPalindrome(str,0,ctr-1)==1){
			if(checkPalindrome(str,ctr+1,n-1)==1)
				strong = 1;
		}
	}
	
	if(strong==1)
		printf("Yes\n");
	else
		printf("No\n");
	
	
	
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int stone[160][1010];
int dp[160][1010][100];
int n,m;
vector<int> node[160];
int dist(int a1,int a2,int b1,int b2)
{
	return (stone[a1][a2]+stone[b1][b2])*abs(a2-b2);
}
int main()
{
	while(1)
	{
		for(int i=0;i<160;i++)
		{
			node[i].clear();
		}
		int ans=INF;
		for(int i=0;i<160;i++)
		{
			for(int j=0;j<1010;j++)
			{
				for(int k=0;k<100;k++)
				{
					dp[i][j][k]=INF;
				}
			}
		}
		for(int i=0;i<160;i++)
		{
			for(int j=0;j<1010;j++)
			{
				stone[i][j]=-1;
			}
		}
		cin >> n >> m;
		if(n==0&&m==0)break;
		for(int i=1;i<=n;i++)
		{
			int k;
			cin >> k;
			for(int j=0;j<k;j++)
			{
				int a,b;
				cin >> a >> b;
				stone[i][a]=b;
				node[i].pb(a);
				if(i==1)
				{
					dp[i][a][m]=0;
				}
				if(i==2&&m>0)
				{
					dp[i][a][m-1]=0;
					//cout << dp[i][a][m-1] << endl;
				}
			}
		}
		for(int i=1;i<n;i++)
		{
			for(int j=0;j<node[i].size();j++)
			{
				for(int l=0;l<=m;l++)
				{
					for(int k=0;k<node[i+1].size();k++)
					{
						dp[i+1][node[i+1][k]][l]=min(dp[i+1][node[i+1][k]][l],dp[i][node[i][j]][l]+dist(i,node[i][j],i+1,node[i+1][k]));
						/*if(i+1>=3&&dp[i+1][node[i+1][k]][l]==0)
						{
							cout << i+1 <<' ' <<node[i+1][k]<<' '<<l<< endl;
							return 0;
						}*/
					}
					for(int k=0;k<node[i+2].size();k++)
					{
						if(l==m)continue;
						dp[i+2][node[i+2][k]][l]=min(dp[i+2][node[i+2][k]][l],dp[i][node[i][j]][l+1]+dist(i,node[i][j],i+2,node[i+2][k]));
						/*if(i+1>=3&&dp[i+2][node[i+2][k]][l]==0)
						{
							cout << i+2 <<' ' <<node[i+2][k]<<' '<<l<< endl;
							return 0;
						}*/
					}
				}
			}
		}
		/*for(int i=1;i<=n;i++)
		{
			for(int j=0;j<node[i].size();j++)
			{
				for(int k=0;k<=m;k++)
				{
					cout <<i<<' '<<node[i][j]<<' '<<k<<' '<< dp[i][node[i][j]][k] << endl;
				}
			}
		}*/
		//cout << dp[1][node[1][0]][m] << endl;
		for(int i=0;i<node[n-1].size();i++)
		{
			for(int j=1;j<=m;j++)
			{
				ans=min(ans,dp[n-1][node[n-1][i]][j]);
				if(dp[n-1][node[n-1][i]][j]==0)cout<<n-1<<' '<<node[n-1][i]<<' '<<j<<endl;
			}
		}
		for(int i=0;i<node[n].size();i++)
		{
			for(int j=0;j<=m;j++)
			{
				ans=min(ans,dp[n][node[n][i]][j]);
				if(dp[n][node[n][i]][j]==0)cout<<n<<' '<<node[n][i]<<' '<<j<<endl;
			}
		}
		//cout << dist(1,node[1][0],2,node[2][0])<< endl;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 64988
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int L, R, d;
	
	cin>>L>>R;
	cin>>d;
	
	int ans = 0;
	
	for(int i = L; i <= R; i++){
		if(i%d == 0)ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
   int a,b;
   cin>>a>>b;
   if(a>=13){
       cout<<b;
   }
   else if(a>=6 and a<=12){
       cout<<b/2;
   }
   else{
       cout<<0;
   } 
   return 0;
}



Measured memory_bytes: 256
/**
*    author:  Dooloper
*    created: 12.05.2020 15:45:57
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>


using namespace std;
typedef unsigned long long ll;

int main() {
    cin.tie(0);
    string S;cin>>S;
    string T;cin>>T;
    S += T.back();
    if(equal(S.begin(), S.end(), T.begin(),T.end()))
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3612