akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, M, val;
    cin >> N >> M;
    priority_queue<int> pq;
    for(int i = 0; i < N; i++) {
        cin >> val;
        pq.emplace(val);
    }
    for(int i = 0; i < M; i++) {
        int L = pq.top(); pq.pop();
        pq.emplace(L/2);
    }
    ll acc = 0;
    while(!pq.empty()) {
        acc += pq.top(); pq.pop();
    }
    cout << acc << endl;
    return 0;
}



Measured memory_bytes: 892
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")


Measured memory_bytes: 3064
S = input('')
Q = int(input(''))
head, tail, rev_flag = '', '', 1
for i in range(Q):
    char = input()
    if char == '1':
        rev_flag *= -1
    else:
        t, f, c = char.split()
        if (f == '1' and rev_flag == 1) or (f == '2' and rev_flag == -1):
            head = c + head
        elif (f == '2' and rev_flag == 1) or (f == '1' and rev_flag == -1):
            tail = tail + c
if rev_flag == 1:
    print(head, S, tail, sep='')
else:
    print(tail[::-1], S[::-1], head[::-1], sep='')


Measured memory_bytes: 4064
#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++)
#define MOD 1000000007
int main(void){
    ll n,m;cin>>n>>m;
    vector<pair<ll,pair<ll,ll>>> city(m);
    For(i,m){
        ll p,y;cin>>p>>y;
        city.at(i).first=p;
        city.at(i).second.first=y;
        city.at(i).second.second=i;
    }
    sort(city.begin(),city.end());
    vector<ll> num(m);
    num.at(city.at(0).second.second)=city.at(0).first*1000000+1;
    For1(i,m){
        if(city.at(i-1).first==city.at(i).first){
            num.at(city.at(i).second.second)=num.at(city.at(i-1).second.second)+1;
        }
        else{
            num.at(city.at(i).second.second)=city.at(i).first*1000000+1;
        }
    }
    For(i,m){
        cout<<setfill('0')<<right<<setw(12)<<num.at(i)<<endl;
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll a,b,m;cin>>a>>b>>m;
  vector<ll> A(a);
  vector<ll> B(b);
  ll mn_a=10000000, mn_b=10000000;
  for(int i=0;i<a;i++){
    cin>>A[i];
    mn_a = min(mn_a, A[i]);
  }
  for(int i=0;i<b;i++){
    cin>>B[i];
    mn_b = min(mn_b, B[i]);
  }
  ll ans = mn_a + mn_b;
  for(int i=0;i<m;i++){
    int x,y,c;cin>>x>>y>>c;
    ans = min(ans, A[x-1] + B[y-1] - c);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
    int main() {
    	int A, B, K;
		cin >> A >> B >> K;

		int count = 0;
		for(int i = min(A,B); i >= 1; i--){
            if ((A % i) == 0 && (B % i) == 0){
				count++;
			}
			if (count == K){
				cout << i << endl;
				return 0;
			}
        }
    }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,i,A,B;int x;
map<int,int>m;
int main()
{
    cin>>A>>B;
    a=A;b=B;
    for(i=2;i*i<=A;i++)
    {
        while(a%i==0)
        {
            a/=i;
            m[i]=1;
        }
    }if(a!=1){m[a]=1;}
    for(i=2;i*i<=B;i++)
    {
        while(b%i==0)
        {
            b/=i;
            if(m[i]==1){
                x++;m[i]=2;}
        }
    }
    if(b!=1){if(m[b]==1)x++;}
    cout<<x+1;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;
template <typename T> T In() { T t; cin >> t; return t;}

using AB = pair<int, int>;
int main() {
    int N = In<int>();
    vector<AB> vec(N);
    for(int i = 0; i < N; i++) {
        vec[i] = make_pair<int,int>(In<int>(), In<int>());
    }

    sort(vec.begin(), vec.end(), [](const AB &ab1, const AB &ab2) { 
        return ab1.second < ab2.second; });
    ll time = 0;
    for(const auto &ab: vec) {
        if(time + ab.first > ab.second) {
            cout << "No" << endl;
            return 0;
        }
        else{
            time += ab.first;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define nmax 305
long long a[nmax][nmax],ans=0;
bool ok[nmax][nmax];
int n;
int main()
{
    cin.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            cin>>a[i][j];
    bool o=true;
    for (int k=1;k<=n;k++)
    for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
        if (a[i][j]>a[i][k]+a[k][j]||(a[i][j]==0 &&i!=j))o=false;
    if (o==false)
    {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
        ok[i][j]=true;
    for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
    for (int k=1;k<=n;k++)
        if (a[i][j]==a[i][k]+a[k][j]&& a[i][k]!=0 && a[k][j]!=0)ok[i][j]=false;
    for (int i=1;i<=n;i++)
    for (int j=i+1;j<=n;j++)
        if (ok[i][j]==true)ans=ans+a[i][j];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)			for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<vint> dp;

void print(vector<vint> arr){
	f(arr.size()){
		fj(arr[i].size()) cout<<arr[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

int32_t main() {

    om_shree_ganeshaya_namah();

    in(n);
    vint arr(n);
    f(n) cin>>arr[i];

    vector<vint> prefix(n, vint(n)), dp(n, vint(n));

    for(int l=n-1; l>=0; l--){
    	for(int r = l; r<n; r++){
    		if(l==r){
    			prefix[l][r] = arr[l];
    			continue;
    		}
    		prefix[l][r] = min(prefix[l][r-1]+arr[r], prefix[l+1][r]+arr[l]);
    	}
    }

    for(int l=n-1; l>=0; l--){
    	for(int r = l; r<n; r++){

    		if(l==r){
    			dp[l][r] = arr[l];
    			continue;
    		}

    		int mini = 1e18, ans=0;
    		for(int k = r-1; k>=l && (k+1)<=r; k--){
    			int a = prefix[l][k]+prefix[k+1][r];

				if(l!=k)
					a+=dp[l][k];
				if((k+1)!=r)
					a+=dp[k+1][r];

    			if(a<mini){
    				mini = a;
    				ans = a;
    			}
    		}
    		dp[l][r] = ans;
    	}
    }

    cout<<dp[0][n-1];
}

Measured memory_bytes: 5804
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

const double PI=3.14159265358979323846;

int main() {
  int N;
  cin >> N;
  
  cout << N*PI*2 << endl;

}


Measured memory_bytes: 3784
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
  for (int k = 0; k < n; k++)
		{
			if (k != n - 1) {
				printf("%d ", a[k]);
			}
			else {
				printf("%d\n", a[k]);
			}
		}

	for (int i = 1; i < n; i++)
	{
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int k = 0; k < n; k++)
		{
			if (k != n - 1) {
				printf("%d ", a[k]);
			}
			else {
				printf("%d\n", a[k]);
			}
		}
	}


	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
struct P{double x,y;};
#define rep(i,n) for(int i=0;i<n;i++)
const double EPS = 1e-15;

vector<P> cross(P a, P b)
{
	vector<P> ret;
	
	double x = a.x - b.x , y = a.y - b.y;
	double L = x * x + y * y;
	if(L > 4.0)return ret;
	
	L = sqrt(L);
	double C = atan2(b.y-a.y,b.x-a.x);
	double alpha = acos(L/2);
	
	P r1,r2;
	r1.x = a.x + cos(C+alpha) , r1.y = a.y + sin(C+alpha);
	r2.x = a.x + cos(C-alpha) , r2.y = a.y + sin(C-alpha);
	
	ret.push_back(r1) , ret.push_back(r2);
	return ret;
}

bool check(P cir , P pt)
{
	cir.x -= pt.x , cir.y -= pt.y;
	return (cir.x*cir.x + cir.y * cir.y) <= 1.0 + EPS;
}

int main()
{
	int n;
	while(scanf("%d",&n) && n)
	{
		int ret = 1;
		vector<P> data(n);
		rep(i,n)scanf("%lf,%lf\n",&data[i].x,&data[i].y);
		
		vector<P> search;
		rep(i,n)
		{
			for(int j=i+1;j<n;j++)
			{
				vector<P> get = cross(data[i],data[j]);
				rep(k,get.size())
				{
					search.push_back(get[k]);
				}
			}
		}
		rep(i,search.size())
		{
			int count = 0;
			rep(j,n)count += check(data[j],search[i]);
			ret = max(ret,count);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
n = int(input())
k = int(input())
 
x = tuple([int(t)for t in input().split()]) 
 
ans = 0
for x_i in x:
  if k-x_i>x_i:
    ans+=x_i*2
  else:
    ans+=(k-x_i)*2
    
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500005; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    int n,Q;cin>>n>>Q;
    Query queries[Q];
    int a[n];
    for(int i=0; i<n; ++i) cin>>a[i];
    for(int i=0; i<Q; ++i) {
        int li,ri;cin>>li>>ri;
        li--;
        ri--;
         queries[i].l = li; 
        queries[i].r = ri; 
         queries[i].idx = i; 
    }
    sort(queries, queries+Q, cmp); 
    answeringQueries(a, n, queries, Q); 
    return 0; 
} 

Measured memory_bytes: 17404
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,N, heal=0;
    scanf("%d",&N);
    int yum[N];
    
    for(i=0;i<N;i++){
        scanf("%d",&yum[i]);
    }
    
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            heal += yum[i]*yum[j];
        }
    }
    
    printf("%d\n",heal);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

int main()
{
  int N;
  std::cin >> N;
  long a[3 * N];
  for ( int i = 0; i < 3 * N; i ++ ) std::cin >> a[i];
  
  std::sort(a, a+3*N, std::greater<int>());
  long sum = 0;
  for ( int i = 0; i < N; i++ ) {
    sum += a[2*i+1];
  }

  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 2560
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

struct BIT<T> {
    xs: Vec<T>,
    n: usize,
}

// 1-indexed
impl<T:Add<T,Output=T>+Sub<T,Output=T>+Default+Clone+Copy> BIT<T> {
    fn new(n: usize) -> BIT<T> {
        let mut m = 1;
        while m <= n {
            m *= 2;
        }
        let n = m;
        BIT::<T> {
            xs: vec![T::default(); n+1],
            n: n
        }
    }
    fn sum(&self, i: usize) -> T {
        let mut i = i;
        let mut res = T::default();
        while i > 0 {
            res = res + self.xs[i];
            i = i - (1usize << i.trailing_zeros());
        }
        res
    }
    fn range_sum(&self, l: usize, r: usize) -> T {
        self.sum(r-1) - self.sum(l-1)
    }
    fn add(&mut self, i: usize, x: T) {
        let mut i = i;
        while i <= self.n {
            self.xs[i] = self.xs[i] + x;
            i = i + (1usize << i.trailing_zeros())
        }
    }
}

fn main() {
    let (n,q) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let mut bit: BIT<i64> = BIT::new(n);
    for i in 0..q {
        let (com,x,y) = {
            let xs = read_vec_i64();
            (xs[0] as usize, xs[1] as usize, xs[2] as usize)
        };
        if com == 0 {
            bit.add(x, y as i64);
        }
        if com == 1 {
            let res = bit.range_sum(x, y+1);
            println!("{}", res);
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}



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

using namespace std;

int x[500005], n;
char y[500005];
queue<int> q;
long long ans;

int main() {
	scanf("%s", y);
	n = strlen(y) + 1;
	if (y[0] == '<')
		q.push(0);
	for (int i = 0; i < n - 2; i++)
		if (y[i] == '>' && y[i + 1] == '<')
			q.push(i + 1);
	if (y[n - 2] == '>')
		q.push(n - 1);
	while (!q.empty()) {
		int ta = q.front();
		q.pop();
		if (ta && y[ta - 1] == '>') {
			x[ta - 1] = x[ta] + 1;
			q.push(ta - 1);
		}
		if (ta < n - 1 && y[ta] == '<') {
			x[ta + 1] = x[ta] + 1;
			q.push(ta + 1);
		}
	}
	for (int i = 0; i < n; i++)
		ans += x[i];
	printf("%lld\n", ans);
}

Measured memory_bytes: 3712
words = lambda t : list(map(t, input().split()))
n,m = words(int)
s = words(int)
t = words(int)
MOD = 10**9 + 7

dp = [[0] * (m+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 1
for i in range(m+1):
    dp[0][i] = 1

for i in range(1,n+1):
    for j in range(1,m+1):
#        for k in range(n+1):
#            print(dp[k])
#        print("")
        if s[i-1] == t[j-1]:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD
        else:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]) % MOD

#for k in range(n+1):
#    print(dp[k])


print(dp[-1][-1])


Measured memory_bytes: 72540
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,s=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(int i=0;i<k;i++)
s+=a[i];
cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3592
#![allow(dead_code)]
use crate::scanner::Scanner;
use num_bigint::{BigInt, ToBigInt};
fn main() {
    let mut scan = Scanner::new();
    let x = scan.read::<i64>().to_bigint().unwrap();
    for a in -120..=120 {
        for b in -120..=120 {
            let p: BigInt = a.to_bigint().unwrap();
            let q: BigInt = b.to_bigint().unwrap();
            if p.clone() * p.clone() * p.clone() * p.clone() * p.clone()
                - q.clone() * q.clone() * q.clone() * q.clone() * q.clone()
                == x
            {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}
mod scanner {
    use std::io::{stdin, BufReader, Bytes, Read, Stdin};
    use std::str::FromStr;
    pub struct Scanner {
        buf: Bytes<BufReader<Stdin>>,
    }
    impl Scanner {
        pub fn new() -> Scanner {
            Scanner {
                buf: BufReader::new(stdin()).bytes(),
            }
        }
        pub fn read_next<T: FromStr>(&mut self) -> Option<T> {
            let token = self
                .buf
                .by_ref()
                .map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();
            token.parse::<T>().ok()
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_next().unwrap()
        }
        pub fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read::<T>()).collect()
        }
        pub fn chars(&mut self) -> Vec<char> {
            self.read::<String>().chars().collect()
        }
    }
}



Measured memory_bytes: 2576
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative
import Text.Printf


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

getInts :: Int -> IO [Int]
getInts n = replicateM n readInt

main = putStrLn . f =<< getInts 2
  where f [a, b] = printf "%d %d %.10f" (a `div` b) (a `mod` b) ((fromIntegral a :: Double) / fromIntegral b)


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
 
int main() {

int N;
int Ans=0;
int Bit=0;
cin>>N;
vector<int> A(N);
for(int i=0;i<N;i++){
cin>>A.at(i);
Bit=A.at(i)^Bit;
}
for(int i=0;i<N;i++){
Ans=Bit^A.at(i);
cout<<Ans<<' ';
}

cout<<endl;

}

Measured memory_bytes: 3992
#include <iostream>
#include <cmath>
#include <cstring>

using namespace std;

long long kum[3002],arr[3002];
long long memo[3002][3002];

void createkum(int n){
	for(int i=1;i<=n;i++){
		kum[i]=kum[i-1]+arr[i];
	}
}

long long rangesum(int x,int y){
	return kum[y]-kum[x-1];
}

long long rek(int a,int b){
	if(a==b) return arr[a];
	if(memo[a][b]!=-1) return memo[a][b];
	memo[a][b]=max(arr[a]+rangesum(a+1,b)-rek(a+1,b),arr[b]+rangesum(a,b-1)-rek(a,b-1));
	return memo[a][b];
}

int main () {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	createkum(n);
	memset(memo,-1,sizeof memo);
	cout<<2*rek(1,n)-kum[n];



return 0;
}



Measured memory_bytes: 70912
import sys
from itertools import permutations
def input(): return sys.stdin.readline().strip()


def main():
    a, b, c = map(int, input().split())
    ans = 10 ** 10
    for p, q, r in list(permutations([a, b, c], 3)):
        ans = min(ans, abs(p-q) + abs(q-r))
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 62104
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Measured memory_bytes: 75400
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int h, w;
int M;

int solve(vector<vi>& A, vector<vi>& B){
    vector<vector<vi>> dp(h, vector<vi>(w, vi(M)));
    dp[0][0][A[0][0] - B[0][0] + M/2] = 1;
    dp[0][0][B[0][0] - A[0][0] + M/2] = 1;
    rep(i, h){
        rep(j, w){
            rep(k, M){
                if(not dp[i][j][k]) continue;
                rep(l, 2){
                    int ni = i + l;
                    int nj = j + (1 - l);
                    if(ni >= h or nj >= w) continue;

                    int a = A[ni][nj], b = B[ni][nj];
                    int diff = a - b;
                    for(int sgn = -1; sgn <= 1; sgn += 2){
                        int nk = k + diff * sgn;
                        if(nk < 0 or M <= nk) continue;
                        dp[ni][nj][nk] = 1;
                    }
                }
            }
        }
    }

    int res = 123 * M;
    rep(k, M){
        if(dp[h-1][w-1][k]){
            chmin(res, abs(k - M/2));
        }
    }
    return res;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> h >> w;
    vector<vi> A(h, vi(w));
    rep(i, h) rep(j, w) cin >> A[i][j];
    vector<vi> B(h, vi(w));
    rep(i, h) rep(j, w) cin >> B[i][j];

    M = (w + h) * 80 * 2 + 5;
    cout << min(solve(A, B), solve(B, A)) << endl;

    return 0;
}


Measured memory_bytes: 650868
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int a[4];
int main()
{
  
   string s;

   cin>>s;
   int i,c=0;
    for(i=0;i<3;i++)
    {
      if(s[i]=='R')
      {
        c=1;
      }
    }
    if(s[0]==s[1]&&s[0]=='R')  c=2;
    if(s[1]==s[2]&&s[1]=='R')  c=2;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') c=3;
  cout<<c<<endl;


}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main (void) {
  int p[2], q[2], r[2];
  bool o = false;

  cin >> p[0] >> p[1];
  cin >> q[0] >> q[1];
  cin >> r[0] >> r[1];

  for (int i=0; i<8; i++) {
    if (p[(i>>2)%2] == q[(i>>1)%2] && q[(i>>1)%2] == r[i%2]) o = true;
  }

  if (o == false) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int n;

int main()
{
    cin>>n;
    while(n)
    {
        if(n%10==9) { puts("Yes");return 0; }
        n/=10;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

int32_t main()
{	
	IOS
	int k;
	cin >> k;
	int ans = 0;
	for(int i = 1; i<=k; i++)
	{
		for(int j = 1; j <= k; j++)
		{
			for(int k1 = 1; k1 <= k; k1++)
			{
				int t = __gcd(i, j);
				ans += __gcd(t, k1);
			}
		}
	}
	cout << ans << endl;
    return 0;
}

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

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

    vector<map<int, int> > index(3);
    vector<vector<int> > x, y, z;
    x = y = z = vector<vector<int> >(n, vector<int>(2));
    for(int i=0; i<n; ++i){
        for(int j=0; j<2; ++j){
            cin >> x[i][j] >> y[i][j] >> z[i][j];
            index[0][x[i][j]];
            index[1][y[i][j]];
            index[2][z[i][j]];
        }
    }

    vector<vector<int> > p(3);
    for(int i=0; i<3; ++i){
        int j = 0;
        for(map<int, int>::iterator it=index[i].begin(); it!=index[i].end(); ++it){
            p[i].push_back(it->first);
            it->second = j;
            ++ j;
        }
    }

    int nx = index[0].size() - 1;
    int ny = index[1].size() - 1;
    int nz = index[2].size() - 1;
    vector<vector<vector<int> > > s(nx, vector<vector<int> >(ny, vector<int>(nz, 0)));
    for(int i=0; i<n; ++i){
        for(int a=index[0][x[i][0]]; a<index[0][x[i][1]]; ++a){
            for(int b=index[1][y[i][0]]; b<index[1][y[i][1]]; ++b){
                for(int c=index[2][z[i][0]]; c<index[2][z[i][1]]; ++c){
                    ++ s[a][b][c];
                }
            }
        }
    }

    long long ret = 0;
    for(int a=0; a<nx; ++a){
        for(int b=0; b<ny; ++b){
            for(int c=0; c<nz; ++c){
                if(s[a][b][c] >= k){
                    ret += (long long)(p[0][a+1] - p[0][a]) * (p[1][b+1] - p[1][b]) * (p[2][c+1] - p[2][c]);
                }
            }
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 5228
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<string.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
#define MAX 200000
#define NIL -1

int N;
bool flag;





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

	flag = false;
	cin >> N;
	FOR(i, 0, 3){
		if (N % 10 == 7)flag = true;
		N /= 10;
	}


	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	

	return 0;
}


Measured memory_bytes: 3128
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] X = new int[N];
		int[] L = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = s.nextInt();
			L[i] = s.nextInt();
		}
		
		int[][] ps = new int[N][2];
		for(int i = 0; i < N; i++) {
			ps[i][0] = X[i] + L[i];
			ps[i][1] = X[i] - L[i];
		}
		Arrays.sort(ps, (a, b) -> Integer.compare(a[0], b[0]));
		
		int cur = -Integer.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(cur <= ps[i][1]) {
				ans++;
				cur = ps[i][0];
			}
		}
		System.out.println(ans);
    }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> H(N); REP(i,N) cin >> H[i];
    SORT(H); REVERSE(H);
    ll ans = 0;
    FOR(i,K,N){
        ans += H[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;

int main(){
  string S;
  cin >> S;
  int N=(int)S.size();
  //if(N==1){cout << 0 << endl; return 0;}
  int cnt1=0,cnt0=0;
  rep(i,N){
    (S[i]=='1')?cnt1++:cnt0++;
  }
  int sub=abs(cnt1-cnt0);
  cout << N - sub << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l,r,d; cin >> l >> r >> d;
    ll ans = 0;
    for(ll i = l;i<=r;i++){
        if(i%d == 0)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3632
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/
/**********************************************************************
Main
**********************************************************************/
int main() {
  int r;
  cin >> r;
  printf("%f\n", 2.0f*M_PI*r);
}
/**********************************************************************
Functions
**********************************************************************/


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

int N,value[20],cost[20]; //N is a const

int main() {
  int sum=0,net;
  cin >> N;
  //1st
  for (int i=0;i<N;i++){
    cin >> value[i];
  }
  //2nd
  for (int i=0;i<N;i++){
    cin >> cost[i];
  }

  //Net worth
  for (int i=0;i<N;i++){
    net = value[i] - cost[i];
    if (net > 0){
      sum += net ;
    } 
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
const int maxn = 4e5 + 5;
ll dp[maxn];
string a;
ll solve (int l , int r)
{
    ll now = 0;
    for (int i = l ; i <= r ; i++){
        now = now * 10 + (a[i] - '0');
    }
    return now;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> a;
    int n = a.size();
    a = '#' + a;
    for (int i = 1 ; i <= n ; i++){
        dp[i] = solve(1 , i);
        if (i != 1) dp[i] += dp[1] + solve(2 , i);
        for (int j = 3 ; j <= i ; j++){
            dp[i] += dp[j - 1] + (1ll << (j - 2)) * solve(j , i);
        }
     //   cout << i << " " << dp[i] << endl;
    }
    cout << dp[n] << endl;
    return 0;
}


/*
6 7
1 2 1
2 4 1
1 3 3
3 4 3
4 6 2
4 5 3
5 6 3
4 3
1 2 1
2 3 1
3 4 2
*/



Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
using namespace std;
const int dx[]={-1,-1,-1,0,0,0,1,1,1};
const int dy[]={-1,0,1,-1,0,1,-1,0,1};
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int a[200001];
int main()
{
    fast();
    int n,k;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>k;
        a[k]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;
	if(S[A] != '-'){
		cout << "No" << endl;
		return 0;
	}
	for(int i = 0; i < A + B + 1; i++){
		if(i == A) continue;
		if(S[i] < '0' || S[i] > '9'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
template<typename T>
class NodeAllocator {
public:
    NodeAllocator() = default;
    explicit NodeAllocator(int num): reserved_(num), assigned_(0) {
        buf_ = new T[num];
    };

    T* GetAlloc(int num) {
        if (assigned_ + num >= reserved_) {
            return nullptr;
        }
        int retp = assigned_;
        assigned_ += num;
        return buf_ + retp;
    }

    void ReAlloc(int num){
        DeleteAlloc();
        buf_ = new T[num];
        reserved_ = num;
    }

    ~NodeAllocator() {
        DeleteAlloc();
    }

private:
    void DeleteAlloc() {
        if (reserved_ == 0) {
            return;
        }
        if (reserved_ > 1) {
            delete [] buf_;
        }else{
            delete buf_;
        }

        assigned_ = 0;
        reserved_ = 0;
    }

    int reserved_;
    int assigned_;
    T *buf_;
};

#include <iostream>
#include <vector>


struct Node {
    int key;
    Node *p = nullptr;
    Node *l = nullptr;
    Node *r = nullptr;
};

NodeAllocator<Node> Alloc;

Node *root;

void Insert(int v) {
    Node *p= nullptr;
    Node *x = root;
    Node *k = Alloc.GetAlloc(1);
    k->key = v;
    while (x != nullptr) {
        p = x;
        if (k->key < x->key) {
            x = x->l;
        }else{
            x = x->r;
        }
    }
    k->p = p;
    if (p == nullptr) {
        root = k;
    } else if (k->key < p->key) {
        p->l = k;
    } else{
        p->r = k;
    }
}

Node* Find(Node *r, int key) {
    while(r != nullptr && r->key != key) {
        if (key < r->key) {
            r = r->l;
        }else{
            r = r->r;
        }
    }
    return r;
}

void Preorder(Node* tgt) {
    if (tgt == nullptr) {
        return;
    }
    std::cout << " " << tgt->key;
    Preorder(tgt->l);
    Preorder(tgt->r);
}

void Inorder(Node* tgt) {
    if (tgt == nullptr) {
        return;
    }
    Inorder(tgt->l);
    std::cout << " " << tgt->key;
    Inorder(tgt->r);
}

int main() {
    int n;
    std::cin >> n;
    Alloc.ReAlloc(n);
    for (int i = 0; i < n; i++) {
        std::string str;
        std::cin >> str;
        if (str == "print") {
            Inorder(root);
            std::cout << std::endl;
            Preorder(root);
            std::cout << std::endl;
            continue;
        }
        int k;
        std::cin >> k;
        if (str == "insert") {
            Insert(k);
        }else if (str == "find") {
            if(Find(root, k) != nullptr) {
                std::cout << "yes" << std::endl;
            }else{
                std::cout << "no" << std::endl;
            }
        }
    }
}


Measured memory_bytes: 18320
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int formula(string& s, int& i) {
	if(s[i] == '(') {
		i++;
		int val = formula(s, i);

		char op = s[i];

		i++;
		int val2 = formula(s, i);

		int ret = 0;
		if(op == '+') {
			if(val == 2 || val2 == 2) ret = 2;
			else if(val == 1 || val2 == 1) ret = 1;
			else ret = 0;
		}
		if(op == '*') {
			if(val == 2 && val2 == 2) ret = 2;
			else if((val == 1 || val == 2) && (val2 == 1 || val2 == 2)) ret = 1;
			else ret = 0;
		}

		i++;
		return ret;
	} else if(isdigit(s[i])) {
		int ret = (s[i] - '0');
		i++;
		return ret;
	} else if(s[i] == '-') {
		i++;
		int val = formula(s, i);

		int ret = 0;
		if(val == 0) ret = 2;
		if(val == 1) ret = 1;
		if(val == 2) ret = 0;

		return ret;
	}
}


int main() {
	string s;
	while(cin >> s) {
		if(s == ".") break;

		int ans = 0;
		rep(i, 3) {
			rep(j, 3) {
				rep(k, 3) {
					string t = s;
					rep(l, s.size()) {
						if(t[l] == 'P') t[l] = ('0' + i);
						else if(t[l] == 'Q') t[l] = ('0' + j);
						else if(t[l] == 'R') t[l] = ('0' + k);
					}

					int p = 0;
					if(formula(t, p) == 2) {
						ans++;
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int main()
{
    int n1, n2;
    while (1)
    {
        cin >> n1 >> n2;
        if (n1 == 0 && n2 == 0)
            break;
        if (n1 > n2)
            cout << n2 << " " << n1 << endl;
        else
            cout << n1 << " " << n2 << endl;
    }
    return 0;
}


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

int main() {
  int N, R;
  cin >> N >> R;
  
  if(N >= 10){
    cout << R << endl;
  } else {
    int rate = R + (100 * (10 - N));
    cout << rate << endl;  
  }
  
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        if (n >= 'a' && n <= 'z') {
            ans = 2;
        } else if (n >= 'A' && n <= 'Z') {
            ans = 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26248
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int digits(Int n) {
    return floor(log10l((long double)n)) + 1;
}

int main() {
    int n;
    cin >> n;
    vector<Int> h(n);

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

    bool ans = true;
    for (int i = n - 1; i > 0; i--) {
        if (h[i] < h[i - 1]) {
            h[i - 1]--;
            if (h[i] < h[i - 1]) {
                ans = false;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		int h = scan.nextInt();
		int w = scan.nextInt();
		scan.close();
		System.out.println((H-h)*(W-w));
	}
}

Measured memory_bytes: 23636
n = int(input())
h = [int(i) for i in input().split()]
dp = [0] * n
if n == 2:
  ans = abs(h[1]-h[0])
  
else:
  dp[1] = abs(h[1]-h[0])
  for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
  ans = dp[n-1]
print(ans)
    

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

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int main() {
    off;
    int t;
    //cin>>t;
    t=1;
    while(t--){    
        int n,k;
        cin>>n>>k;
        double ans=0; 
        for(int i=1;i<=n;i++)
            {   int j=0;
                while(i*pow(2,j)<k)
                    ++j;
                ans+=(pow(0.5,j));
            }
            ans/=n;
         cout<<fixed<<setprecision(20)<<ans<<'\n';       
    }
      return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;


map<li, li> cnt;
li a[100100];

int main(void)
{
	li n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	li res = 0;
	rep(i, n) {
		res = max(res, cnt[a[i]] + cnt[a[i] - 1] + cnt[a[i] + 1]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 6912
#[allow(unused_imports)]
use std::cmp::*;

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main() {
    // n
    // v_1 v_2 ... v_n
    // v: [i32; n],
    input!{
        a: usize,
        b: usize,
        c: usize,
    }

    println!("{} {} {}", c, a, b);
}


Measured memory_bytes: 2076
#include <iostream>
#include <cmath>
#include <limits>
#include <string>
#include <iomanip>
#include<vector>
using namespace std;

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

int main(void) {
	int n, k,max=0,b=0;
	cin >> n >> k;
	vector<int> v;
	rep(i, n) {
		double tmp = log2((double)(k) / (double)(i + 1));

		if ( k >= i+1) {
			if (tmp > (double)((int)tmp)) {
				if (max < (int)(tmp)+1)max = (int)(tmp)+1;
				v.push_back((int)(tmp)+1);
			}
			else {
				if (max < (int)tmp)max = (int)tmp;
				v.push_back((int)(tmp));
			}
		}
		else {
			v.push_back(0);
		}
	}

	rep(i, n) {
		 b += pow(2.0f, (max - v[i]) ) ;
	}
	cout << setprecision(12) << (double)b / (double)(n) / pow(2.0f,max);
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> v[3];
    ll num;
    rep(i, n) rep(j, 3)
    {
        cin >> num;
        v[j].push_back(num);
    }

    ll ans = 0;

    for (int bit = 0; bit < (1 << 3); bit++)
    {
        vector<ll> sub;
        rep(i, n)
        {
            ll sum = 0;
            rep(j, 3)
            {
                if (bit & (1 << j))
                    sum += v[j][i];
                else
                    sum -= v[j][i];
            }
            sub.push_back(sum);
        }
        sort(ALL(sub), greater<ll>());
        ll s = 0;
        rep(i, m) s += sub[i];
        ans = max(s, ans);
    }

    OP(ans);
    return 0;
}

Measured memory_bytes: 256
def readinput():
    a=[]
    for i in range(3):
        l=list(map(int,input().split()))
        a.append(l)
    n=int(input())
    b=[]
    for _ in range(n):
        b.append(int(input()))
    return n,a,b

def main(n,a,b):
    sheet=[]
    for i in range(3):
        sheet.append([0,0,0])
    
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if a[j][k]==b[i]:
                    sheet[j][k]=1
    
    bingo=False
    for i in range(3):
        if sheet[i][0]==1 and sheet[i][1]==1 and sheet[i][2]==1:
            bingo=True
        elif sheet[0][i]==1 and sheet[1][i]==1 and sheet[2][i]==1:
            bingo=True
    if sheet[0][0]==1 and sheet[1][1]==1 and sheet[2][2]==1:
        bingo=True
    if sheet[0][2]==1 and sheet[1][1]==1 and sheet[2][0]==1:
        bingo=True
    return bingo

if __name__=='__main__':
    n,a,b=readinput()
    ans=main(n,a,b)
    if ans == True:
        print('Yes')
    else:
        print('No')

    

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

#pragma GCC optimize(3)

using namespace std;

const int  MAXN=3;

int n,h[MAXN],f[MAXN]= {0},cnt=1;

int main() {
	scanf("%d%d%d",&n,&h[0],&h[1]);
	f[1]=abs(h[0]-h[1]);
	for(int i=3; i<=n; ++i) {
		scanf("%d",&h[2]);
		f[2]=min(abs(h[2]-h[0])+f[0],abs(h[2]-h[1])+f[1]);
		f[0]=f[1],f[1]=f[2];
		h[0]=h[1],h[1]=h[2];
	}
	printf("%d\n",f[1]);
	return 0;
}

Measured memory_bytes: 256