akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static long GetInteger() { return long.Parse(Console.ReadLine()); }
    public static IEnumerable<long> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)); }
}

namespace AtCoder.A
{
    public class Program
    {
        public static long N { get; private set; }
        public static long A { get; private set; }
        public static long B { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            N = inputs[0];
            A = inputs[1];
            B = inputs[2];

            // 差が偶数の場合は明らか
            if ((B - A) % 2 == 0)
            {
                return (B - A) / 2;
            }

            // 差が奇数の場合
            var min = long.MaxValue;
            if (A - 1 <= N - B)
            {
                // 1卓で待ち合わせ
                min = Math.Min(min, B - 1);
                // 1卓で折り返し
                min = Math.Min(min, A + (B - A - 1) / 2);
            }
            if (A - 1 >= N - B)
            {
                // N卓で待ち合わせ
                min = Math.Min(min, N - A);
                // N卓で折り返し
                var stepUntilReachB2N = N - B + 1;
                min = Math.Min(min, stepUntilReachB2N + (N - (A + stepUntilReachB2N)) / 2);
            }

            return min;
        }
    }
}


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

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

int main() {
    ll N, M, Q; cin >> N >> M >> Q;
    
    vector<vector<ll>> V(N, vector<ll>(N));
    for(int i = 0; i < M; i++) {
        ll l, r; cin >> l >> r;
        l--; r--;
        for(int i = r; i < N; i++)V[l][i]++;
    }
    for(int num = 0; num < Q; num++){
        ll p, q; cin >> p >> q; p--;q--;
        ll ans = 0;
        for(int i = p; i <= q; i++) { //始点　
            ans += V[i][q];
        }
        cout << ans << endl;


    }
}

Measured memory_bytes: 2944
#include<iostream>

using namespace std;

void MATRIX_CHAIN_ORDER(int n, int p[]){
    int m[n+1][n+1];
    int s[n][n+1];

    for(int i = 1; i <= n; i++){
        m[i][i] = 0;
    }
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n-l+1; i++){
            int j = i + l - 1;
            m[i][j] = 2000000000;
            for(int k = i; k <= j-1; k++){
                int q = m[i][k] + m[k+1][j] + (p[i-1] * p[k] * p[j]);
                if(q < m[i][j]){
                    m[i][j] = q;
                    s[i][j] = k;
                }
            }
        }
    }
    cout << m[1][n] << endl;
}

int main(){
    int n;
    cin >> n;
    int p[n+1];
    for(int i = 1; i <= n; i++){
        cin >> p[i-1];
        cin >> p[i];
    }
    MATRIX_CHAIN_ORDER(n, p);
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin >> s;
    int dp[100010] = {0};
    dp[s] = 1;
    int f = 1;
    int cnt = 0;
    while(1)
    {
        cnt++;
        if(dp[s] == 2 && f == 0)
        {
            cout << cnt;
            break;
        }
        if(s%2 != 0)
        {
            dp[3*s+1]++;
            s = 3*s+1;
            f = 0;
        }
        else
        {
            dp[s/2]++;
            s = s/2;
            f = 0;
        }
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int D[10];
int main(){
    int n, k, n_copy, cnt; cin >> n >> k;
    for (int i=0; i < k; i++) cin >> D[i];
    for (int i=0; i<100000-n; i++)
    {
        n_copy = n+i;
        int decimal_place = 10000;
        cnt = 5;
        while (n_copy / decimal_place == 0){
            decimal_place /= 10;
            cnt--;
        }
        bool flag = false;
        for (int j=0; j < cnt; j++)
        {
            for (int l = 0; l < k; l++)
            {
                if (n_copy / decimal_place % 10 == D[l])
                {
                    flag = true;
                }
            }
            decimal_place /= 10;
            if(flag) break;
        }
        if(flag)continue;
        cout << n+i << endl;
        return 0;
    }
    
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize, a: usize, b: usize,
        x: [usize; n],
    }

    let mut ans = 0;
    for i in 0..n - 1 {
        ans += min((x[i + 1] - x[i]) * a, b);
    }
    println!("{}", ans);
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> flg(n, false);

    int d, x;
    rep(i, k) {
        cin >> d;
        rep(j, d) {
            cin >> x;
            x--;
            flg[x] = true;
        }
    }

    int ans = n;
    rep(i, n) {
        ans -= flg[i];
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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;
}


Measured memory_bytes: 3600
import math

A,B,C,D,E,F = map(int, input().split())

ans = 0
ans1 = 0
ans2 = 0

for a in range(math.ceil(F / (A*100))+1):
  for b in range(math.ceil(F / (B*100))+1):
    for c in range(1000):
      for d in range(1000):
        if a == 0 and b == 0 and c == 0 and d == 0:
          continue
        
        if 100*A*a + 100*B*b + C*c + D*d > F:
          continue

        if (C*c)+(D*d) > E * (A*a+B*b):
          continue

        tmp = (C*c+D*d)*100 / (100*A*a + 100*B*b + C*c + D*d)
        if tmp > ans:
          ans = tmp
          ans1 = 100*A*a + 100*B*b + C*c + D*d
          ans2 = C*c + D*d

if ans2 == 0:
  print("{0} {1}".format(600, ans2))
else:
  print("{0} {1}".format(ans1, ans2))

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class T> using MAX_pq = priority_queue<T>;
template <class T> using MIN_pq = priority_queue<T,vector<T>,greater<T>>;
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r,q;
int ans[100010];
vector<int> mi[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >>n>>s;
  if(s.size()<=n) cout <<s<<'\n';
  else{
    for(int i=0;i<n;i++) cout <<s[i];
    cout <<"...\n";
  }
  return (0);
}


Measured memory_bytes: 6004
#include <iostream>
using namespace std;
int main(){
  int a[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
    cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  int b[n];
  for(int i = 0; i < n; i++)cin >> b[i];
  for(int i = 0; i < 3; i++){
    for(int k = 0; k < 3; k++){
      for(int j = 0; j < n; j++){
      	if(b[j] == a[i][k])a[i][k]=0;
      }
    }
  }
  for(int i = 0; i < 3; i++){
    if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  for(int j = 0; j < 3; j++){
    if(a[0][j]==a[1][j]&&a[1][j]==a[2][j]){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]){
    cout << "Yes" << endl;
    exit(0);
  }
  if(a[0][2]==a[1][1]&&a[1][1]==a[2][0]){
    cout << "Yes" << endl;
    exit(0);
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n, q = map(int,input().split())
l = []
for i in range(n):
  t=[]
  for j in input().split():
    t+=[j]
  t[1]=int(t[1])
  l+=[t]
 
c=0
while len(l)>0:
  if l[0][1]>q:
    l[0][1]-=q
    l+=[l[0]]
    l.pop(0)
    c+=q
  else:
    c+=l[0][1]
    print(l[0][0],c)
    l.pop(0)



Measured memory_bytes: 13784
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,cnt=0;
    cin>>a;
    stringstream ss;
    string s;
    ss<<a;
    ss>>s;
    for(int i=0;i<SZ(s);i++)
    {
        int k=s[i]-'0';
        cnt+=k;
    }
    if(a%cnt==0)
    {
        cout<<"Yes"<<NL;
    }
    else
    {
        cout<<"No"<<NL;
    }
    return 0;
}


Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);
 
    public static void main(String[] args) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int ab = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int ans1 = a * x + b * y;
        int ans2 = x < y ? ab * x * 2 + b * (y - x) : ab * y * 2 + a * (x - y);
        int ans3 = ab * Math.max(x, y) * 2;
        System.out.println(Math.min(Math.min(ans1, ans2), ans3));
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <climits>

using namespace std;

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> x(N), y(N);
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i] >> y[i];
        X[i] = x[i];
        Y[i] = y[i];
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    
    ll ans = LLONG_MAX;
    for(int a = 0; a < N; ++a){
        int left = X[a];
        for(int b = a + 1; b < N; ++b){
            int right = X[b];
            for(int c = 0; c < N; ++c){
                int below = Y[c];
                for(int d = c + 1; d < N; ++d){
                    int up = Y[d];
                    int cnt = 0;
                    
                    for(int i = 0; i < N; ++i){
                        if(x[i] < left || x[i] > right || y[i] < below || y[i] > up)    continue;
                        
                        cnt++;
                    }
                    if(cnt >= K){
                        ll temp = (ll)(right - left) * (up - below);
                        ans = min(ans, temp);
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  int q = in();
  rep(i,q){
    int a = in();
    int b = in();
    int k = in();
    cout << accumulate(line.begin()+a,line.begin()+b,0,
                       lambda(int,int a,int b){
                         return a + (b==k?1:0);
                       }) << endl;
  }
}



Measured memory_bytes: 3264
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9+7

def count(li):
    l = 1-len(li)
    cnt = 0
    for ind, i in enumerate(li):
        cnt += i*(l+2*ind)
    return cnt%mod

print((count(x)*count(y))%mod)


Measured memory_bytes: 18576
from collections import defaultdict
 
N = int(input())
A = list(map(int, input().split()))
if all(a == 0 for a in A):
    print(0)
    exit()
 
position = defaultdict(list)
for i, a in enumerate(A):
    position[a].append(i)
 
ans = 0
use = 0
link = 0
for a in sorted(set(A), reverse=True):
    use += len(position[a])
    for i in position[a]:
        if i > 0 and A[i] < A[i - 1]:
            link += 1
        if i < N - 1 and A[i] <= A[i + 1]:
            link += 1
    ans = max(ans, use - link)
print(ans)


Measured memory_bytes: 34900
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n,m;
cin >> n >> m;

vector<pii> v(m); // pairを要素にもつvector
rep(i,m){
    int a,b;
    cin >> a >> b;
    v[i] = {a,b};
}

sort(v.begin(), v.end(), [](pii i1, pii i2) { 
    return i1.second < i2.second;
});

int res = 0;
int cur = -10; // cur := 現在選んでいる区間のうち、最も右にあるやつの右端
rep(i,m){
    if (cur > v[i].first) continue; // 被るやつは飛ばす
    ++res;
    cur = v[i].second;
}

cout << res << endl;


return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	map<string, long long> mp;
	string S;
	while (cin >> S) mp[S]++;
	long long MAXA = 0, MAXB = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		MAXA = max(MAXA, it->second);
		MAXB = max(MAXB, (long long)(it->first.size()));
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->second == MAXA) cout << it->first << " ";
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		if (it->first.size() == MAXB) cout << it->first << endl;
	}
}


Measured memory_bytes: 3008
#include <cstdio>
#define MATRIX_SIZE_MAX 100
using Matrix = int[MATRIX_SIZE_MAX][MATRIX_SIZE_MAX];

long long  product_elem(Matrix A, Matrix B, int m, int i, int j) {
  long long sum = 0;

  for(int k = 0; k < m; k++) {
    sum += A[i][k] * B[k][j];
  }

  return sum;
}


int main() {
  int n, m, l;
  Matrix A, B;

  scanf("%d %d %d%*c", &n, &m, &l);


  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      scanf("%d", &A[i][j]);
    }
  }

  for(int i = 0; i < m; i++) {
    for(int j = 0; j < l; j++) {
      scanf("%d", &B[i][j]);
    }
  }

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      long long elem = product_elem(A, B, m, i, j);

      printf("%lld", elem);

      if(j != l - 1) {
        printf(" ");
      }
    }
    printf("\n");
  }
}



Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,g,x,t,h,k=0,f,l=0,c=0;
    cin>>n;
    ll a[n+10],b[n+10];

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

    }

    sort(a,a+n);

    for(int i = 0; i < n; i++)
    {
        if(a[i]!=b[i])
        {
            c++;
        }

    }
    if(c > 2)
    {
        cout<<"NO\n";
    }
    else
    {
        cout<<"YES\n";
    }


}


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

int main(){
    int N;
    int H[21] = {};
    int ans = 0, max = 0;
    cin >> N;
    for(int i=1; i<=N;i++){
        cin >> H[i];
        if(max <= H[i]){
            ans++;
            max = H[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

p = list(map(int, input().split()))

for i in range(1, len(p)):
  p[i] += p[i-1]
ans = p[k-1]
for i in range(k, n):
  ans = max(ans, p[i]-p[i-k])

print((k+ans)/2)

Measured memory_bytes: 98664
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
	int N;
	cin >> N;
	while (N--) {
		string str;
		cin >> str;
		int s = str.size();
		set<string> dt;
		for (int i=1; i<s; i++) {
			string s1, s2, rs1, rs2;
			s1 = string(str.begin(), str.begin()+i);
			s2 = string(str.begin()+i, str.end());
			rs1 = string(s1.rbegin(), s1.rend());
			rs2 = string(s2.rbegin(), s2.rend());
			dt.insert( s1+ s2);
			dt.insert( s1+rs2);
			dt.insert(rs1+ s2);
			dt.insert(rs1+rs2);
			dt.insert( s2+ s1);
			dt.insert( s2+rs1);
			dt.insert(rs2+ s1);
			dt.insert(rs2+rs1);
		}

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

	return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  int64_t sum=0;
  for(int i=0;i<N-K;i++){
    sum+=vec.at(i);
  }
  cout<<sum<<endl;
  
  
  
}

Measured memory_bytes: 1024
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
dt = []
for i in range(n):
    t,d = inm()
    dt.append((d,t))
dt.sort(reverse=True)
a = dt[:k] # oisisa max, ignore variety

vals = [z[0] for z in a]
dsum = sum(vals)
typs = set([z[1] for z in a])
ntyp = len(typs)
mx = dsum+ntyp**2 # satisfy for a

b = dt[k:]
h = {}
for d,t in b:
    if t in typs:
        continue
    elif t not in h:
        h[t] = d
    else:
        h[t] = max(h[t],d)
c = [h[t] for t in h]
c.sort(reverse=True)
# for types not in a, max oisisa

h = {}
for d,t in a:
    if t not in h:
        h[t] = d
    else:
        h[t] = max(h[t],d)
vals = []
for d,t in a:
    if t in h and d==h[t]:
        del h[t]
    else:
        vals.append(d)
vals.sort()
# oisisa list for second or below for each type

for i in range(min(len(vals),len(c))):
    dsum += c[i]-vals[i]
    ntyp += 1
    mx = max(mx,dsum+ntyp**2)
print(mx)


Measured memory_bytes: 69208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

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

	int len = (int)s.size();

	cout << s[0] << len - 2 << s[len - 1] << endl;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int N;

int main(){

   int N;
   cin >> N;

   int c = 1000000001 , b = 0 ; 
   //c最小値b最大値

   for(int i = 0 ; i < N; ++i ){

      int A;
      cin >>A;

      if (A > b){
         b = A ;
      }
      if (A < c){
         c = A ;
      }
   }
   int ans = b - c;
   cout << ans << endl ;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[derive(Eq, PartialEq, Clone, Debug)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    let n = get!(usize);
    let mut aa = util::gets::<u64>();

    aa.sort_by_key(|&a| Rev(a));

    let ans = (0..2 * n)
        .filter(|&i| i % 2 == 1)
        .map(|i| aa[i])
        .sum::<u64>();

    println!("{}", ans);
}


Measured memory_bytes: 13428
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, a[100000], g[100000],c[100000],cnt[100000];
vector<int>V[100000];
queue<int>q;
int main() {
	cin >> N;
	for (int i = 1; i != N; ++i) {
		cin >> a[i];
		--a[i];
		V[a[i]].push_back(i);
		++c[a[i]];
	}
	for (int i = 0; i != N; ++i) {
		if (!c[i])
			q.push(i);
	}
	while (true) {
		vector<int>v;
		for (int j = 0; j != V[q.front()].size(); ++j) {
			v.push_back(g[V[q.front()][j]]);
		}
		sort(v.begin(), v.end());
		for (int i = 0; i != v.size(); ++i) {
			g[q.front()] = max(g[q.front()] + 1, v[i] + 1);
		}
		if (!q.front())break;
		++cnt[a[q.front()]];
		if (cnt[a[q.front()]] == c[a[q.front()]])
			q.push(a[q.front()]);
		q.pop();
	}
	cout << g[0] << endl;
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;

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

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

bool field[102][102];
bool vis[102][102];

int main() {
    int W, H; cin >> W >> H;
    memset(field, 0, sizeof(field));
    memset(vis, 0, sizeof(vis));
    for(int y = 0; y < H; y++) {
        for(int x = 0; x < W; x++) {
            cin >> field[y+1][x+1];
        }
    }

    queue<P> Q;
    Q.push(P(0, 0));
    vis[0][0] = true;

    while(!Q.empty()) {
        P p = Q.front(); Q.pop();
        for(int i = 0; i < 6; i++) {
            int ny = p.first + dy[p.first%2][i];
            int nx = p.second + dx[p.first%2][i];
            if(0 <= ny && ny < H + 2 && 0 <= nx && nx < W + 2 && field[ny][nx] == false && vis[ny][nx] == false) {
                vis[ny][nx] = true;
                Q.push(P(ny, nx));
            }
        }
    }
    int ans = 0;
    for(int y = 1; y <= H; y++) {
        for(int x = 1; x <= W; x++) {
            if(field[y][x]) {
                for(int i = 0; i < 6; i++) {
                    int ny = y + dy[y%2][i];
                    int nx = x + dx[y%2][i];
                    if(0 <= ny && ny < H + 2 && 0 <= nx && nx < W + 2 && vis[ny][nx] == true) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1244
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        var b = long.Parse(line[2]);
        var c = long.Parse(line[3]);
        var d = long.Parse(line[4]);
        for (long i = 0; i < n -1; i++)
        {
            long af = n - 1 - i;
            long t0 = c * af - d * i;
           long t1 = d * af - c * i;
            if (t0 <= b - a && t1 >= b - a) { Console.WriteLine("YES"); goto end; }
        }
        Console.WriteLine("NO");
    end:;
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<map>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;
typedef long long ll;

int main() {

	int N;
	cin >> N;
	vector<long> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];
	int ans = 0;
	for (int i = 0; i < N-1; i++) {
		if (a[i] == a[i + 1]) {
			ans++;
			a[i + 1] = -1;
		}
	}
	cout << ans << endl;
	//cin >> N;



	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,w;cin >> n >>w;
    vvl it(4);
    ll x;cin >> x;
    ll p;cin >> p;it[0].pb(p);
    rep(i,n-1){
        ll a,b;cin >> a >>b;
        it[a-x].pb(b);
    }
    ll ans=0;
    sort(all(it[0]));rev(all(it[0]));
    sort(all(it[1]));rev(all(it[1]));
    sort(all(it[2]));rev(all(it[2]));
    sort(all(it[3]));rev(all(it[3]));
    rep(i,it[0].size()+1){
        rep(j,it[1].size()+1){
            rep(k,it[2].size()+1){
                rep(l,it[3].size()+1){
                    ll val=0;
                    rep(a,i){
                        val+=it[0][a];
                    }
                    rep(b,j){
                        val+=it[1][b];
                    }
                    rep(c,k){
                        val+=it[2][c];
                    }
                    rep(d,l){
                        val+=it[3][d];
                    } 
                    if(w>=x*(i+j+k+l)+j+2*k+3*l){
                        chmax(ans,val);
                    }                   
                }
            }
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vec = std::vector<T>;
template <class T> using vvec = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

void rec(int i, int p, int x, const vvec<int>& od, const vec<int>& c, vec<int>& result)
{
    result[i] += x;
    for (auto& o : od[i])
    {
        if (o != p) rec(o, i, x + c[o], od, c, result);
    }
    return;
}

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

    int N, Q; cin >> N >> Q;
    vvec<int> od(N, vec<int>());
    REP(i, 0, N - 1)
    {
        int a, b; cin >> a >> b;
        --a, --b;
        od[a].push_back(b);
        od[b].push_back(a);
    }

    vec<int> c(N);
    REP(i, 0, Q)
    {
        int p, x; cin >> p >> x;
        c[p - 1] += x;
    }

    vec<int> r(N);
    rec(0, 0, c[0], od, c, r);

    REP(i, 0, N)
    {
        cout << r[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 30592
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
#define MAXN 1000
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(false);
	//freopen("../in", "r", stdin);
	//freopen("../out", "w", stdout);
	ll a, b;
	cin >> a >> b;
	ll k = __gcd(a, b);
	ll top = sqrt(k);
	ll ans = 1;
	for (ll i = 2; i <= top; i++)
	{
		if(k%i==0)
		{
			while(k%i==0)
				k/=i;
			ans++;
		}
	}
	if(k!=1)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;
    cin>>n;
    vi s(n);
    rep(i,n){
        cin>>s[i];
    }
    sort(been(s));
    int res =0;
    rep(i,n)res+=s[i];
    rep(i,n){
        if(res%10==0&&s[i]%10!=0)res-=s[i];
    }
    rep(i,n){
        if(res%10==0&&s[i]%10==0)res-=s[i];
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace myapp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            int a = input[0];
            int b = input[1];
            int c = input[2];
            int result = c - (a -b);
            if (result < 0) {
                 Console.WriteLine(0);
            } else {
                Console.WriteLine(result);
            }
        }
    }
}


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

using namespace std;

int main(){

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

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

   long long int n,x;
   cin >> n >> x;

   if(abs(n - x) < n){
       long long int temp = n % x;
       while( abs(temp-x) < temp){
          temp = abs(temp-x);
       }
      
     cout << temp << endl;
     
   }else{
      cout << n << endl;
   }


   

    return 0;
}

Measured memory_bytes: 256
// 3_abc129_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> broken(n + 1);
    rep(i, n + 1){
        broken[i] = 0;
    }
    rep(i, m){
        int a;
        cin >> a;
        broken[a] = 1;
    }
    vector<ll> dp(n + 1);
    rep(i, n + 1){
        dp[i] = 0;
    }
    dp[0] = 1;
    if(broken[1] == 0) dp[1] = 1;
    else dp[1] = 0;

    for(int i = 2; i <= n; i++){
        if(broken[i] == 1) dp[i] = 0;
        else{
            dp[i] += dp[i - 1] + dp[i - 2];
            dp[i] %= MOD;
        }
    }

    cout << dp[n] % MOD << endl;
    return 0;
}


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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int sum;
    if(A==B) sum+=1;
    if(A==C) sum+=1;
    if(B==C) sum+=1;
    if(sum==1) cout << "Yes" << endl;
    else cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    int N = 0, D = 0;
    int X[10][10];
    int cnt = 0;
    int i = 0, j = 0, k = 0, l = 0;
    double decimal = 0.0;
    double length = 0.0, length_d = 0.0;


    scanf("%d %d", &N, &D);

    for(i = 0; i < N; i++){
        for(j = 0; j < D; j++){
            scanf("%d", &X[i][j]);
        }
    }

    for(i = 0; i < N; i++){
        for(j = i+1; j < N; j++){
             for(k = 0; k < D; k++){
                 length_d += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
             }
             length = sqrt(length_d);
             decimal = length - (int)length;
             if(decimal == 0){
                 cnt++;
             }
             length_d = 0;
        }
        
    }
    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
const int INF=1001001001;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int stack=0,e=0;
  for(int i=0;i<n;i++){
    if(s[i]=='S'){stack++;}
    else if(stack>0){stack--;e++;}
  }
  cout<<n-2*e<<endl;
  return 0;
}

Measured memory_bytes: 3740
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        String U = sc.next();

        if (U.equals(S))
            A -= 1;
        else
            B -= 1;

        System.out.println(A + " " + B);
    }
}

Measured memory_bytes: 38892
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> ps(n); cin >> ps;
    vector<int> ls1(n, -1), rs1(n, -1);
    vector<int> ls2(n, -1), rs2(n, -1);
    vector<int> is(n);
    iota(is.begin(), is.end(), 0);
    sort(is.rbegin(), is.rend(), [&](int i, int j){ return ps[i] < ps[j]; });
    set<int> stl, str;
    for(auto i : is){
        auto ite = stl.upper_bound(- i);
        if(ite != stl.end()){
            ls1[i] = - *ite;
            ite = stl.upper_bound(*ite);
            if(ite != stl.end()){
                ls2[i] = - *ite;
            }
        }
        stl.insert(- i);
        printde(stl);
        ite = str.upper_bound(i);
        if(ite != str.end()){
            rs1[i] = *ite;
            ite = str.upper_bound(*ite);
            if(ite != str.end()){
                rs2[i] = *ite;
            }
        }
        str.insert(i);
    }
    printde(ls1, ls2);
    printde(rs1, rs2);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(ls1[i] != -1){
            int l = ls2[i] != -1 ? ls2[i] + 1 : 0;
            int r = rs1[i] != -1 ? rs1[i] - 1 : n - 1;
            ans += ps[i] * (ls1[i] - l + 1) * (r - i + 1);
        }
        printde(i, ans);
        if(rs1[i] != -1){
            int r = rs2[i] != -1 ? rs2[i] - 1 : n - 1;
            int l = ls1[i] != -1 ? ls1[i] + 1 : 0;
            ans += ps[i] * (i - l + 1) * (r - rs1[i] + 1);
        }
        printde(i, ans);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 12416
import java.util.*;

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

		Scanner sc = new Scanner(System.in);
		String N = sc.next();

		if(Character.isUpperCase(N.charAt(0))){
			System.out.println("A");
		}else{
			System.out.println("a");
		}	

		return;
	}
}


Measured memory_bytes: 35748
#include<stdio.h>

int main(){
  int n,x;
  int i;
  int a = 0;
  int d = 0;

  scanf("%d %d",&n,&x);

  if(1>n || n>100)return 0;
  if(1>x || x>10000)return 0;

  int L[n];

  for(i=0;i<n;i++){
    scanf("%d",&L[i]);
  }

  for(i=0;i<=n;i++){
    if(i!=0)d = d + L[i-1];
    if(i==0)d=0;

    if(d>x)break;
    else a++;
  }

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

  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  1
//
//  Created by Charles Wayne on 2018/3/11.
//  Copyright © 2018年 Charles Wayne. All rights reserved.
//

#include <iostream>
using namespace std;
char s1[5],s2[5],s3[5];
int main(int argc, const char * argv[]) {
    while(~scanf("%s%s%s",s1,s2,s3)){
        printf("%c%c%c",s1[0],s2[1],s3[2]);
    }
    return 0;
}


Measured memory_bytes: 764