akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        xl: [(i64, i64); n],
    }
    let mut a = vec![];
    for (x, l) in xl {
        a.push((x + l, x - l));
    }
    a.sort();
    let mut cur: i64 = -1 << 50;
    let mut cnt = 0;
    for (r, l) in a {
        if cur <= l {
            cnt += 1;
            cur = r;
        }
    }
    puts!("{}\n", cnt);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 12540
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define fi first
#define se second
#define int long long
#define mod 1000000007
#define rem 998244353
#define maxn 300005
const int INF = 1e18;
typedef pair<int, int> pii;


signed main() {
    boostIO;
    int d, t, s;
    cin >> d >> t >> s;
    if(s * t >= d){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}
// XD ;;

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

long long int x, y;
int res = 0;

int main(){
  cin >> x >> y;
  while(x <= y){
    x *= 2LL;
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
//AtCoder ABC094 A - Cats and Dogs
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll A,B,X;
    cin>>A>>B>>X;
    bool ans=(A<=X&&A+B>=X);
    cout<<(ans?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
master = [list(map(int,input().split())) for _ in range(m)]

def dfs(s):
    global flag
    global a
    if not flag[s]:
        flag[s] = True
    for g in a[s]:
        if not flag[g]:
            dfs(g)

res = 0
for i in range(m):
    a = [[] for _ in range(n)]
    for j in range(m):
        if j == i:
            continue
        else:
            a[master[j][0]-1].append(master[j][1]-1)
            a[master[j][1]-1].append(master[j][0]-1)
    
    flag = [False for _ in range(n)]

    dfs(master[i][0] -1)

    if not all(flag):
        res += 1

print(res)

Measured memory_bytes: 3064
#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;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll inputLValue(){
    ll a;
    cin >> a;
    return a;
};

int main()
{
    int ans = 6;
    int A = inputValue();
    int B = inputValue();

    ans = ans - (A + B);
    cout << ans << endl;
}


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

#define IOBOOST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define _(x) {cout << #x << " = " << x << " ";}
#define sz(a) int((a).size())
#define pb push_back
#define F first
#define S second
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

const double E = 1e-8;
const double PI = acos(-1);
    
using namespace std;

int N, h[100005], dp[100005]; 

int solve() {
    dp[0] = 0;
    for(int i = 1; i < N; ++i) {
        dp[i] = dp[i-1] + abs(h[i-1] - h[i]);
        if(i > 1)
            dp[i] = min(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
    }
    return dp[N-1];
}
    
int main(int argc, char** argv) {
    
    IOBOOST
    
    cin>>N;
    for(int i = 0; i < N; ++i)
        cin>>h[i];
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
 
hints = []
for i in range(n):
    x, y, h = map(int, input().split())
    hints.append([x, y, h])

def reheight(center, point):
    if point[2] == 0:
        return 0
    else:
        return (point[2] + abs(center[0] - point[0]) + abs(center[1] - point[1]))

def height(center, high, point):
    return max(high - abs(center[0] - point[0]) - abs(center[1] - point[1]), 0)

for i in range(101):
    for j in range(101):
        k_ = 0
        center = [i, j]
        while (reheight(center, hints[k_]) == 0):
            k_ += 1
        hmax = reheight(center, hints[k_])
        k = 0
        while (k < n and (hints[k])[2] == height(center, hmax, (hints[k])[:2])):
            k += 1
        if k == n:
            break
    if k == n:
        break
        
print("{} {} {}".format(center[0], center[1], hmax))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll a[3][3];
    rep(0,i,3){
        rep(0,j,3)cin>>a[i][j];
    }
    bool ans=false;
    ll n;
    cin>>n;
    ll b[n];
    rep(0,i,n)cin>>b[i];
    rep(0,i,n){
        rep(0,j,3){
            rep(0,k,3)if(a[j][k]==b[i])a[j][k]=-1;
        }
    }
    rep(0,i,3){
        bool t=true;
        rep(0,j,3)if(a[i][j]!=-1)t=false;
        if(t)ans=true;
    }
    rep(0,j,3){
        bool t=true;
        rep(0,i,3)if(a[i][j]!=-1)t=false;
        if(t)ans=true;
    }
    bool t=true;
    rep(0,i,3)if(a[i][i]!=-1)t=false;
    if(t)ans=true;
    t=true;
    rep(0,i,3)if(a[i][2-i]!=-1)t=false;
    if(t)ans=true;
    if(ans)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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 (b < a) { a = b; return true; } return false; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;
  if (s.back() == 's') cout << s + "es" << endl;
  else cout << s + "s" << endl;
  
  return (0);
}

Measured memory_bytes: 3668
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	ll n; int x, m; cin>>n>>x>>m;
	int mn = min(n, (ll)m);
	vector<int> P; // value of pre & cycle
	ll sum_p = 0; // sum of pre + cycle
	vector<int> X(m, -1); // for cycle check & pre_len
	rp(i, 0, mn){
		if(X[x] > -1){
			int pre_len = X[x];
			int cyc_len = P.size() - pre_len;
			int nxt_len = (n - pre_len) % cyc_len;
			ll pre = 0; rp(i, 0, pre_len) pre += P[i];
			ll nxt = 0; rp(i, pre_len, pre_len + nxt_len) nxt += P[i];
			ll cyc = (sum_p - pre) * ((n - pre_len) / cyc_len);
			cout<< pre + cyc + nxt <<endl;
			return 0;
		}
		X[x] = i;
		P.push_back(x);
		sum_p += x;
		x = (ll)x*x % m;
	}
	cout<< sum_p <<endl;
}


Measured memory_bytes: 3996
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int j = 0;
		int[] coin = {10, 50, 100, 500};

		while(true){
			int bill = sc.nextInt();
			if(bill==0) break;
			if(j!=0) System.out.println();
			int[] num = new int[4];
			int charge = 0;
			int[] back = new int[4];

			for(int i=0; i<4; i++){
				num[i] = sc.nextInt();
				charge += coin[i]*num[i];
			}

			charge -= bill;

			for(int i=3; i>=0; i--){
				back[i] = charge / coin[i];
				charge -= back[i]*coin[i];
			}

			for(int i=0; i<4; i++){
				if(num[i]-back[i]>0){
					System.out.println(coin[i]+" "+(num[i]-back[i]));
				}
			}
			j = 1;
		}
	}

}

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

using namespace std;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

int main(int argc, char **argv)
{
  uint64_t A, B, C;
  cin >> A >> B >> C;
  
  cout << (((A < C && C < B) || (B < C && C < A)) ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    N, A, B, C = LI()
    L = [I()for _ in range(N)]
    loop = (1<<(2*N))
    ans = inf
    for l in range(loop):
        cost = 0
        bamboo_A = 0
        bamboo_B = 0
        bamboo_C = 0
        for j in range(N):
            if l&(1<<(2*j))>0:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_A += L[j]
                else:
                    cost += 10
                    bamboo_B += L[j]
            else:
                if l&(1<<(2*j+1))>0:
                    cost += 10
                    bamboo_C += L[j]
        if bamboo_A==0 or bamboo_B==0 or bamboo_C==0:
            continue
        cost += abs(A-bamboo_A) + abs(B-bamboo_B) + abs(C-bamboo_C) - 30
        ans = min(ans,cost)

    print(ans)
    return

def examD():
    N = I()
    P = LI()
    O_ = [-1]*N
    start = P[0]-1
    for i in range(N):
        O_[P[i]-1] = i
    #print(O_,start)
    A = [1]*N
    B = [1]*N
    for i in range(start+1,N):
        cur = O_[i]-O_[i-1]
        if cur>0:
            A[i] = A[i-1] + (cur+1)
            B[i] = B[i-1] - 1
        else:
            A[i] = A[i-1] + 1
            B[i] = B[i-1] - (-cur+1)
    for i in range(start)[::-1]:
        cur = O_[i]-O_[i+1]
        if cur>0:
            B[i] = B[i+1] + (cur+1)
            A[i] = A[i+1] - 1
        else:
            B[i] = B[i+1] + 1
            A[i] = A[i+1] - (-cur+1)
    if A[0]<1:
        add = (1-A[0])
        for i in range(N):
            A[i] += add
    if B[-1]<1:
        add = (1-B[-1])
        for i in range(N):
            B[i] += add

    print(" ".join(map(str,A)))
    print(" ".join(map(str,B)))
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return


from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
9
7 3 9 1 8 4 5 6 2
"""

Measured memory_bytes: 10588
import sys
import math

N, D = map(int, sys.stdin.readline().split())
X = []

for i in range(N):
    temp = list(map(int, sys.stdin.readline().split()))
    X.append(temp)


count = 0
for i in range(N):
    for j in range(i, N):
        if i == j:
            continue
        else:
            sum = 0
            for k in range(D):
                sum += (X[i][k] - X[j][k])*(X[i][k] - X[j][k])

            if math.sqrt(sum).is_integer():
                count += 1
print(count)

Measured memory_bytes: 3064
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO()
main = do
  n <- getInt
  ns <- getIntList
  print $ (head ns) + (last ns) + sum (zipWith min ns (tail ns))

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine


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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n],ans=1;
	for(ll i=0;i<n;i++)cin>>arr[i];
	multiset<ll> ms;
	ms.insert(arr[0]);
	for(ll i=1;i<n;i++)
	{
		if(*ms.begin()>=arr[i])ans++;
		ms.insert(arr[i]);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,m;
int a[100010];
int h1[100010],h2[100010];
vector<pii>v1,v2;
int output(int x,int y){
	int ans=0;
	for(int i=1;i<=n;i+=2)if(a[i]!=x)ans++;
	for(int i=2;i<=n;i+=2)if(a[i]!=y)ans++;
	return ans;
}
bool cmp(const pii&a,const pii&b){
	return a>b;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],m=max(m,a[i]+1);
	for(int i=1;i<=n;i+=2)h1[a[i]]++;
	for(int i=2;i<=n;i+=2)h2[a[i]]++;
	for(int i=1;i<=m;i++)v1.eb(h1[i],i);
	for(int i=1;i<=m;i++)v2.eb(h2[i],i);
	sort(v1.begin(),v1.end(),cmp);
	sort(v2.begin(),v2.end(),cmp);
	// for(pii v:v1)cout<<v.second<<' ';
	// puts("");
	// for(pii v:v2)cout<<v.second<<' ';
	// puts("");
	int x=v1[0].second,y=v2[0].second;
	if(x==y){
		int p=v1[1].second,q=v2[1].second;
		cout<<min(output(p,y),output(x,q))<<endl;
		// if(v1[1].second>v2[1].second)output(p,y);
		// else output(x,q);
	}else{
		// cout<<x<<' '<<y<<endl;
		cout<<output(x,y)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3700
use std::io;


fn main() {
    let s = read_one::<String>()
        .chars()
        .collect::<Vec<char>>();
    let mut is_yymm = false;
    let mut is_mmyy = false;
    if s[0] <= '1' && s[1] <= '2' || s[0] < '1' { is_mmyy = true; }
    if s[2] <= '1' && s[3] <= '2' || s[2] < '1' { is_yymm = true; }
    if s[0] == '0' && s[1] == '0' { is_mmyy = false; }
    if s[2] == '0' && s[3] == '0' { is_yymm = false; }
    match (is_yymm, is_mmyy) {
        (true, true) => println!("AMBIGUOUS"),
        (true, false) => println!("YYMM"),
        (false, true) => println!("MMYY"),
        _ => println!("NA"),
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    bool ldp[n][k]={},rdp[n][k]={};
    ldp[0][0]=rdp[0][0]=true;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<k;j++){
            ldp[i+1][j]|=ldp[i][j];
            rdp[i+1][j]|=rdp[i][j];
            if(ldp[i][j]&&j+a[i]<k)ldp[i+1][j+a[i]]=true;
            if(rdp[i][j]&&j+a[n-i-1]<k)rdp[i+1][j+a[n-i-1]]=true;
        }
    }
    int ans=n;
    for(int i=0;i<n;i++){
        int r=k-1;
        bool flag=false;
        for(int l=0;l<k;l++){
            if(ldp[i][l]){
                while(k<=l+r)r--;
                while(max(k-a[i],0)<=l+r){
                    if(rdp[n-i-1][r]){
                        flag=true;
                        break;
                    }
                    else r--;
                }
            }
        }
        if(flag)ans--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 49152
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int minCost = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int cost = sc.nextInt();
			int time = sc.nextInt();
			if (time <= t) {
				if (cost < minCost) {
					minCost = cost;
				}
			}
		}
		if (minCost == Integer.MAX_VALUE) {
			System.out.println("TLE");
		} else {
			System.out.println(minCost);
		}
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  cin >> s;
  string ans="";
  vi v;
  rep(i,(int)s.size()){
    if(s[i] != 'B'){
      ans += s[i];
    }else{
      if(!ans.empty()){
        ans.pop_back();
      }
    }
  }
  cout<< ans << endl;
	return 0;
}



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

int main()
{
  int n,counter = 0;
  cin>>n;
  string s;
  cin>>s;

  for(int i=0;i<n-2;i++)
  {
      if(s[i]==char('A') && s[i+1]==char('B') && s[i+2]==char('C'))
      {
          counter++;
      }
  }
  cout<<counter;

    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int l,n,sum=0,mini=INT_MAX;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		int flavor=l+i;
		if(abs(mini)>abs(flavor))mini=flavor;
		sum+=flavor;
	}
	cout<<sum-mini;
    return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
int main(){
	char a[10][5]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	char b[5];
	scanf("%s",b);
	for(int i=0;i<7;i++){
		if(strcmp(a[i],b)==0){
			printf("%d",7-i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
// {{{ Templates
#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

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

    int N;
    cin >> N;
    vector<int> p(N);
    vector<int> index;
    vector<bool> isindex(N, false);
    for (int i = 0; i < N; i++) {
        cin >> p[i];
        if (p[i] == i + 1) {
            index.push_back(i);
            isindex[i] = true;
        }
    }
    int cnt = 0;
    int ind = 0;
    while (ind < index.size()) {
        cnt++;
        if (isindex[index[ind] + 1]) {
            ind++;
        }
        ind++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, K;
  cin >> N >> K;
  
  int x;
  int distance = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x > K / 2) distance += K - x;
    else distance += x; 
  }
  distance *= 2;
  cout << distance << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int dp[105][4][2];

int main() {
  string S;
  cin >> S;
  int KK;
  cin >> KK;
  int N = S.size();

  dp[0][0][0] = 1;
  
  for (int i = 0; i < N; ++i) {
    int nd = S[i] - '0';
    for (int j = 0; j <= KK; ++j) {
      for (int k = 0; k < 2; ++k) {
	for (int d = 0; d <= 9; ++d) {
	  int ni = i + 1;
	  int nj, nk;
	  
	  if (d == 0) {
	    nj = j;
	  } else {
	    nj = j + 1;
	    if (nj > KK) continue;
	  }

	  if (k == 0) {
	    if (d > nd) continue;
	    else if (d == nd) nk = 0;
	    else nk = 1;
	  } else {
	    nk = 1;
	  }
	  
	  dp[ni][nj][nk] += dp[i][j][k];
	}
      }
    }
  }

  cout << dp[N][KK][1] + dp[N][KK][0] << endl;
  
  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    x, y = map(int, input().split())
    E[x-1].append(y-1); E[y-1].append(x-1)

preorder = [-1] * N # a dfs preordering of each vertex
dp = [[1] * 2 for _ in range(N)]
stack = [(0, -1, 0)] # (vertex, parent, status)
pre_num = 0 # current preordering
while stack:
    v, p, st = stack.pop()
    if st == 0 and preorder[v] < 0: # visited v for the first time
        preorder[v] = pre_num
        pre_num += 1
        n_children = 0
        for u in E[v]:
            if preorder[u] >= 0:
                continue
            if n_children == 0:
                stack += [(v, p, 2), (u, v, 0)]
                n_children += 1
            else:
                stack += [(v, p, 1), (u, v, 0)]
                n_children += 1
        if n_children == 0 and p != -1: # v is a leaf
            dp[p][0] *= dp[v][0] + dp[v][1]
            dp[p][0] %= MOD
            dp[p][1] *= dp[v][0]
            dp[p][1] %= MOD
    elif st == 0 and preorder[v] >= 0: # the edge (v, p) is a back edge
        continue
    elif st == 1: # now searching
        continue
    else: # search finished
        if p != -1:
            dp[p][0] *= dp[v][0] + dp[v][1]
            dp[p][0] %= MOD
            dp[p][1] *= dp[v][0]
            dp[p][1] %= MOD
print((dp[0][0] + dp[0][1]) % MOD)

Measured memory_bytes: 91296
_ = gets
ary = gets.chomp.split.map(&:to_i)

sum = 0
count = 0
min = Float::INFINITY
ary.each do |i|
    sum += i.abs
    min = i.abs if i.abs < min
    count += 1 if i < 0
end
if count % 2 != 0
    sum -= min * 2
end
puts sum

Measured memory_bytes: 11652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	if(a[0]==0){
		cout<<0<<endl;
		return 0;
	}
	int pro=1;
	rep(i,n){
		if(INF/pro+1<a[i]){
			cout<<-1<<endl;
			return 0;
		}
		pro*=a[i];
		
	}
	if(pro>INF) cout<<-1<<endl;
	else cout<<pro<<endl;
	return 0;
}



Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if (0 < a) { std::cout << "Positive" << std::endl; }
    else if (a <= 0 & 0 <= b)
    {
        std::cout << "Zero" << std::endl;
    }
    else if (b < 0)
    {
        int tmp = b - a + 1;
        if (tmp % 2 == 0) { std::cout << "Positive" << std::endl; }
        else
        {
            std::cout << "Negative" << std::endl;
        }
    }

    return 0;
}

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

int main() {
  int n, d, x;
  cin>>n>>d>>x;
  int ans = x;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    ans += (d - 1) / a + 1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <ctime>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=3010, Mod=998244353;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
signed main()
{
	int a,b;
	a=read(), b=read();
	printf("%lld\n",a*b);
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  int ans=0;
  int card[1001];
  for(int i=0;i<1001;i++){
    card[i]=0;
  }
  for(int i=0;i<m;i++){
    cin >> a >> b;
    if(a>=n){
      card[0]++;
    }else{
      card[n-a]++;
    }
  }
  int flag=0;
  for(int i=1001;i>=0;i--){
    if(flag==0&&card[i]>0){
      flag=1;
      ans-=i;
    }
    ans+=card[i]*i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

int main()
{
    int n, k;
    // N, K
    scanf("%d %d",&n, &k);
    // a1..aN (=a[0]..a[n-1])
    std::vector<unsigned int> arr(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&arr[i]);
    }
    
    // 一番総和の大きな組み合わせを探し当てる
    int max_i = 0;
    int max_total = 0;
    int latest_total = 0;

    // i = 0 だけ特別に計算する
    for (int j = 0; j < k; ++j) {
        max_total += arr[j];
    }
    latest_total = max_total - arr[max_i];
    
    int total = 0;
    for (int i = 1; i <= n - k; ++i) {
        total = latest_total + arr[i + k - 1];
        if (max_total < total) {
            max_i = i;
            max_total = total;
        }
        latest_total = total - arr[i];
    }
    
    double expect = 0.0;
    for (int i = max_i; i < max_i + k; ++i) {
        expect += double((arr[i]*(arr[i]+1)) / 2.0) / arr[i];
    }
    
    // 出力
    printf("%.12f\n", expect);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>S(3);
  cin >> S[0]>>S[1]>>S[2];
  sort(S.begin(),S.end());
  if(S[2]==S[1]+S[0])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		BigInteger a = new BigInteger(sc.next());
		BigInteger b = new BigInteger(sc.next());
		
		a = a.subtract(b);
		
		System.out.println(a);
	}

}



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

int main(){
  int n,m;
  cin >> n >> m;
  char a[n][n],b[m][m];
  for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> a[i][j];
  for(int i=0;i<m;i++) for(int j=0;j<m;j++) cin >> b[i][j];
  bool ans=false;
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      bool check=true;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l]){
            check=false;
          }
        }
      }
      if(check) ans=true;
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#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[3000];
ll DP[3001][3001], res;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> a[i];
	for (int i = 1; i != N + 1; ++i) {
		for (int j = 0; i + j != N + 1; ++j) {
			if ((N - i) & 1)
				DP[j][i + j] = min(DP[j][i + j - 1] - a[i + j - 1], DP[j + 1][i + j] - a[j]);
			else
				DP[j][i + j] = max(DP[j][i + j - 1] + a[i + j - 1], DP[j + 1][i + j] + a[j]);
//			cout << j << sp << i + j << sp << DP[j][i + j] << endl;
		}
	}
	cout << DP[0][N] << endl;
}

Measured memory_bytes: 70016
#include<iostream>
#include<cmath>
using namespace std;
long long n;
int main()
{
	cin>>n;
	for(int i=sqrt(n);i>=1;i--)
	{
		if(n%i==0)
		{
			long long l=n/i,s=1;
			while(l>=10)
			{
				s++;
				l/=10;
			}
			cout<<s<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 5000;
int N,K;
ll A[Nmax];

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];

	int ans = 0;
	vector<int> vec(N,K);
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(i==j) continue;
			if(vec[i]-A[j]>=0){
				vec[i]-=A[j];
			}
		}
	}

	for(int i=0; i<N; i++){
		//cout << vec[i] << endl;
		if(vec[i] > A[i]){
			ans ++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }
    static class Task{
        public void solve(Scanner sc, PrintWriter out){
            int N = nint(sc);
            int[] ai = intLine(sc, N);
            int left;
            int right;
            int rightright ;
            int changeCount = 0;
            if (N == 2){
                if (ai[0] == ai[1]){
                    out.println(1);
                }else {
                    out.println(0);
                }

                return;
            }

            for (int i=1; i<N-1; i++){

                right = ai[i+1];
                if (i ==1) {
                    left = ai[i-1];
                    if (left == ai[i] &&  ai[i] != right ) {
                        changeCount++;
                    }else if(left != ai[i] &&  ai[i] == right){
                        rightright = ai[i+2];
                        if (right == rightright){
                            i ++;
                        }
                        changeCount++;
                    }else if (left == ai[i] && right==ai[i]){
                        changeCount++;
                    }
                } else if (i == N-2){
                    if(ai[i] == right ){
                        changeCount++;
                    }
                } else if(ai[i] == right){
                    rightright = ai[i+2];
                    if (right == rightright){
                        i ++;
                    }
                    changeCount++;
                }
            }
            out.println(changeCount);

        }
    }

    static int nint(Scanner sc){
        return Integer.parseInt(sc.next());
    }
    static long nlong(Scanner sc){
        return Long.parseLong(sc.next());
    }
    static double ndouble(Scanner sc){
        return Double.parseDouble(sc.next());
    }
    static float nfloat(Scanner sc){
        return Float.parseFloat(sc.next());
    }
    static String nstr(Scanner sc){
        return  String.valueOf(sc.next());
    }
    static long[] longLine(Scanner sc, int size){
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }
    static int[] intLine(Scanner sc, int size){
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }
    static String[] strLine(Scanner sc, int size){
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>

int main() {
int n;
long long min = 1000000;
long long max = -1000000;
long long sum = 0;
long long* a = new long long[n];

std::cin >> n;
for(int i = 0; i < n; i++) {
std::cin >> a[i];
if(min > a[i]) {
min = a[i];
}
if(max < a[i]) {
max = a[i];
}
sum += a[i];
}
std::cout << min << ' ' << max << ' ' << sum << std::endl;
}

Measured memory_bytes: 3152
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	string s;
	getline(cin, s);
	vector<string> toks;
	stringstream check1(s); 
    string intermediate; 
    while(getline(check1, intermediate, ' ')){ 
        toks.push_back(intermediate); 
    } 
    stack<int> res;
    for(auto i:toks){
		if(i == "+"){
			int b = res.top();
			res.pop();
			int a = res.top();
			res.pop();
			res.push(a + b);
		}else if(i == "-"){
			int b = res.top();
			res.pop();
			int a = res.top();
			res.pop();
			res.push(a - b);
		}else if(i == "*"){
			int b = res.top();
			res.pop();
			int a = res.top();
			res.pop();
			res.push(a * b);
		}else if(i == "/"){
			int b = res.top();
			res.pop();
			int a = res.top();
			res.pop();
			res.push(a / b);
		}else res.push(stoi(i));
	}
	cout << res.top() << '\n';
	return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
	int n,q;string s;cin>>n>>q>>s;
	int p[n+1]={0};
	for(int i=1;i<n;i++){
		if(s[i-1]=='A'&&s[i]=='C') p[i+1]=p[i]+1;
		else p[i+1]=p[i];
	}
	while(q){
		int l,r;cin>>l>>r;
		//cout<<p[l]<<" "<<p[r]<<" ";
		int ans=p[r]-p[l];
		cout<<ans<<endl;
		q--;
	}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for(int i = 0; i < R; i++) {
        cin >> r.at(i);
        r.at(i)--;
    }
    sort(r.begin(), r.end());
    
    vector<vector<int>> C(N, vector<int>(N, 1000000000));
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        C.at(a).at(b) = c;
        C.at(b).at(a) = c;
    }
    for(int i = 0; i < N; i++) C.at(i).at(i) = 0;
    
    
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                C.at(j).at(k) = min(C.at(j).at(k), C.at(j).at(i) + C.at(i).at(k));
            }
        }
    }
    
    int ans = 1000000000;
    do{
        int tmp = 0;
        for(int i = 0; i < R-1; i++) {
            tmp += C.at(r.at(i)).at(r.at(i+1));
        }
        ans = min(ans, tmp);
    } while(next_permutation(r.begin(), r.end()));
    
    cout << ans << endl;
 }


Measured memory_bytes: 384
import java.io.*;
import java.util.*;

class Main 
{
  public static void main(String[] args) 
  {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt(), t = sc.nextInt();
    int sandRemain = X - t;
    if (sandRemain < 0)
    {
      sandRemain = 0;
    }
    System.out.println(sandRemain);
  }
}


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

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  
  int64_t numSet = N / (A+B);
  int64_t numRes = N - numSet *(A+B);
  
  int64_t numAdd = A;
  
  if (numRes < A){
    numAdd = numRes;
  }
  
  int64_t ans = numSet * A + numAdd;
  
  cout << ans << endl;
}


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

int main() {
  int P,Q,R;
  cin >> P >> Q >> R;
  int A = P + Q, B = Q + R, C = P + R;
  if (A > B) {
 	if (B < C) {
      cout << B << endl;
      
    }
    else {
      cout << C << endl;
    }
  }  
  else {
    if (A < C) {
      cout << A << endl;
    }
    else {
      cout << C << endl;
      
    }
  }
}    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,M;
    cin>>A>>B>>M;
    int a[A],b[B];
    int m[M][3];
    for(int i=0;i<A;i++)
        cin>>a[i];
    for(int i=0;i<B;i++)
        cin>>b[i];
    for(int i=0;i<M;i++)
       {

        for(int j=0;j<3;j++)
           {

            cin>>m[i][j];
            }
        }

    int arr[M];
    for(int p=0;p<M;p++)
    {
        arr[p]=a[m[p][0]-1]+b[m[p][1]-1]-m[p][2];

    }

    int mini = arr[0];
    for (int i = 0; i < M; i++)
    {
        if (mini > arr[i])
            mini = arr[i];
    }
    int min1=a[0],min2=b[0];
    for (int i = 0; i < A; i++)
    {
        if (min1 > a[i])
            min1 = a[i];

        if (min2 > b[i])
            min2 = b[i];
    }

    int minif=0;
    int mini2=min1+min2;
    if(mini<mini2)
        minif=mini;
    else
        minif=mini2;
    cout<<minif;
    return 0;
}


Measured memory_bytes: 2560
N = int(input())
s = []

result = 0
ABAB = 0
A = 0
B = 0
onon = 0

amari = 0
for i in range(N):
    s.append(input())

for S in s:
    AB = S.count("AB")
    result += AB
    if S[0] == "B" and S[-1] == "A":
        ABAB += 1
    elif S[0] == "B":
        B += 1
    elif S[-1] == "A":
        A += 1

if ABAB >= 1:
    onon = onon + ABAB - 1

if A >= 1 and ABAB >= 1 :
    onon += 1
    A -= 1
if B >= 1 and ABAB >= 1 :
    onon += 1
    B -= 1

if A >= 1 and B >= 1:
    if A >= B:
        onon += B
    else:
        onon += A


print(result + onon)



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N; cin >> N; 
	long long ans = 0; 
	for(long long i = 1; i <= N; i++){
		long long t = N / i; 
		ans += t * (t + 1) / 2 * i; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 3608
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int aSum = 0, bSum = 0;
			int n = stdIn.nextInt();
			if(n == 0)
			{
				break;
			}
			for(int i = 0; i < n; ++i)
			{
				int a = stdIn.nextInt();
				int b = stdIn.nextInt();
				if(a > b)
				{
					aSum += a + b;
				}
				else if(a < b)
				{
					bSum += a + b;
				}
				else
				{
					aSum += a;
					bSum += a;
				}
			}
			System.out.println(aSum + " " + bSum);
		}
	}
}

Measured memory_bytes: 12000
#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 ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll mod = 1e9 + 7;
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i;
    cin >> n;
    if(n == 1) {
    	cout << "0\n";
    	return 0;
    }
    ll ans = 1;
    for(i = 1; i <= n; i++) {
    	ans = (ans * 10)%mod;
    }
    ll sub1 = 1;
    ll sub2 = 1;
    for(i = 1; i <= n; i++) {
    	sub1 = (sub1 * 9)%mod;
    	sub2 = (sub2 * 8)%mod;
    }
    sub1 = (2*sub1)%mod;
    ans = ((ans - sub1 + sub2)%mod + mod)%mod;
    cout << ans << "\n";
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n, m, l, c1, c2;
		n = scan.nextInt();
		m = scan.nextInt();
		l = scan.nextInt();
		long rs = 0;// ?¨???????????????????????????????
		c1 = 0;// ????¬???????????????????
		c2 = 0;// ????¬???????????????????

		// ????¬???????????????¨???
		long num1[][] = new long[n + 5][m + 5];
		long num2[][] = new long[m + 5][l + 5];
		long result[][] = new long[n + 5][l + 5];

		// ????¬???????????????\??? num1
		for (int count = 0; count < n; count++) {
			for (int count2 = 0; count2 < m; count2++) {
				num1[count][count2] = scan.nextInt();
			}
		}
		// ????¬???????????????\??? num2
		for (int count3 = 0; count3 < m; count3++) {
			for (int count4 = 0; count4 < l; count4++) {
				num2[count3][count4] = scan.nextInt();
			}
		}

		// ?¨???? (n*m)?????°????????????
		// l??????????????????????????????
		for (int count7 = 0; count7 < l; count7++) {
			for (int count5 = 0; count5 < n; count5++) {
				for (int count6 = 0; count6 < m; count6++) {
					rs = rs + num1[count5][count6] * num2[count6][c2];
				}
				result[c1][c2] = rs;
				c1++;
				rs = 0;
			}

			c1 = 0;
			c2++;
		}

		// output (n*m)?????????
		for (int i = 0; i < n; i++) {
			for (int i2 = 0; i2 < l; i2++) {
				sb.append(result[i][i2]);
				if (i2 != (l - 1)) {
					sb.append(" ");
				}
			}
			sb.append("\n");
		}

		System.out.print(new String(sb));

	}
}

Measured memory_bytes: 52712
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000000
#define mod 1000000007
const int N = 200010 ;
int fact[N];
int n , a, b, c , dp[123][213];

int fres = 1;

inline int fastpower(int num,int po){
    int fres = 1;
    while(po > 0){
        if(po & 1)
            fres = (long long)fres * num % mod;
        po >>= 1;
        num = (long long)num * num % mod;
    }
    return fres;
}

inline int nck(int n,int k){
    if(k > n) return 0;
    return (long long)fact[n] * fastpower((long long)fact[k] * fact[n - k] % mod , mod - 2) % mod;
}

int solve(int i,int j){
    if(i == n || j == n) return 0;
    int &ret = dp[i][j];
    if(ret != -1)
        return ret;
    ret = 1;
    ret += (long long)solve(i + 1, j) * a % mod;
    if(ret >= mod) ret -= mod;
    ret += (long long)solve(i , j + 1) * b % mod;
    if(ret >= mod) ret -= mod;
    ret = (long long)ret * c % mod;
    return ret;
}

int main(){
    memset(dp , -1, sizeof(dp));
    fact[0] = 1;
    for(int i = 1;i < N;i++) fact[i] = (long long)i * fact[i - 1] % mod;
    cin >> n >> a >> b >> c;
    c = 100 - c;
    a = (long long)a * fastpower(100 , mod - 2) % mod;
    b = (long long)b * fastpower(100 , mod - 2) % mod;
    c = (long long)c * fastpower(100 , mod - 2) % mod;
    c = fastpower(c , mod - 2);
    int ans = 0;
    int cur;
    for(int i = 0 ;i < n;i++){
        cur = nck(n + i - 1 , i);
        cur = (long long)cur * fastpower(a , n) % mod;
        cur = (long long)cur * fastpower(b , i) % mod;
        cur = (long long)cur * (n + i) % mod;
        cur = (long long)cur * fastpower(c,  n + i + 1) % mod;
        ans += cur;
        if(ans >= mod) ans -= mod;
        cur = nck(n + i - 1 , i);
        cur = (long long)cur * fastpower(b , n) % mod;
        cur = (long long)cur * fastpower(a , i) % mod;
        cur = (long long)cur * (n + i) % mod;
        cur = (long long)cur * fastpower(c,  n + i + 1) % mod;
        ans += cur;
        if(ans >= mod) ans -= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int a;
	string s; 

	cin >> a >> s;
	if (a < 3200)
		cout << "red\n";
	else
		cout << s << "\n";
	return 0;
}

Measured memory_bytes: 256
X = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1700 <= X <= 1999:
    print(1)

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

#include <algorithm>	
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

vector<int> r;

int main()
{
	int n, S;
	while ( scanf ("%d %d", &n, &S ) && n && S ){

	r.clear();
	r.resize(n );
	rep (i, n ){
		int in;
		scanf (" %d", &in );
		r[i] = in;
	} // end rep
	sort (ALL (r ) );
	int res = 0;
	for (int i = 0; i < n - 1; i++ ){
		int rem = max (S - r[i], 0 );
		if (rem >= r[n-1] ) continue;
		if (rem == 0 ){
			res += n - i - 1;
			continue;
		} // end if

		int le = i+1;
		int ri = n-1;
		int mid = n;

		while (le <= ri ){
			mid = (le+ri+1)/2;
			if (r[mid] < rem ){
				le = mid+1;
			}else
			if (r[mid] > rem ){
				ri = mid-1;
			}else{ // if (r[mid] == rem )
				le = mid+1;
			}// end if
			
		} // end while
		while (r[mid] <= rem )
			mid++;
		res += n - mid;
	} // end rep
	printf ("%d\n", res );
} // end while
	
	return 0;
}

Measured memory_bytes: 960