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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, d[55], ans = 0;
	
	cin >> N;
	
	rep(i, N)
		cin >> d[i];
		
	rep(i, N)
		for(int j=i+1; j<N; j++)
			ans += d[i] * d[j];
	
	cout << ans;
	
	return 0;
}

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

int main()
{
   int i,j,n,m;
   cin>>n>>m;
   char arr[n][m];
   for(i=0;i<n;i++)
     for(j=0;j<m;j++)
       cin>>arr[i][j];
   for(i=0;i<m+2;i++)
     cout<<"#";
     cout<<endl;
   for(i=0;i<n;i++)
   {
    cout<<"#";
    for(j=0;j<m;j++)
   {
       cout<<arr[i][j];
   }
     cout<<"#";
     cout<<endl;
   }
   for(i=0;i<m+2;i++)
     cout<<"#";
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N,T,E,x[10000],first=0,i,num=-1,flg=0;

  scanf("%d%d%d" ,&N ,&T ,&E);

  for( i = 0 ; i < N ; i++ ){
   
    scanf("%d" ,&x[i]);
    
    first = x[i];
    
    if( flg == 0 ){
      while( x[i] <= (T+E) ){
	if( (T-E) <= x[i] && x[i] <= (T+E) ){
	  num = i+1; flg = 1;
	}
	x[i] += first;
      }
    }
  }
  printf("%d\n" ,num);

  return 0;
}

Measured memory_bytes: 604
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .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 ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($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, parser) => {
        $next
    };

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

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

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

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

    if h <= a.iter().sum::<usize>() {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
n = int(input())
a_li = list(map(int,input().split()))
if n < 3:
    print(1)
    exit()
ans = 1
flag = "flat"
for i in range(1,n):
    if a_li[i-1] > a_li[i]:
        if flag == "up":
            ans += 1
            flag = "flat"
            continue
        flag = "down"
    elif a_li[i-1] < a_li[i]:
        if flag == "down":
            ans += 1
            flag = "flat"
            continue
        flag = "up"
    else:
        if flag == "flat":
            flag = "flat"
print(ans)

Measured memory_bytes: 14252
n = gets.to_i

if n<=9 then puts "Yes"
elsif n%2==0 and n/2<10 then puts "Yes"
elsif n%3==0 and n/3<10 then puts "Yes"
elsif n%4==0 and n/4<10 then puts "Yes"
elsif n%5==0 and n/5<10 then puts "Yes"
elsif n%6==0 and n/6<10 then puts "Yes"
elsif n%7==0 and n/7<10 then puts "Yes"
elsif n%8==0 and n/8<10 then puts "Yes"
elsif n%9==0 and n/9<10 then puts "Yes"
else puts "No" end

Measured memory_bytes: 1788
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define INF 100000000
#define MAXS 1024
#define MAXN 10
#define MAXNUM 100
typedef long long ll;

ll dp[MAXN][MAXS];
int n, s;

int main(void) {
    dp[0][0] = 1;
    for(int i = 0; i <= 100; ++i){
        for(int j = 1000; j >= i; --j){
            for(int k = 9; k > 0; --k){
                dp[k][j] += dp[k-1][j-i];
            }
        }
    }
    while (1) {
        cin >> n >> s;
        if (n == 0 && s == 0) break;
        cout << dp[n][s] << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 25;
int h,w;
string s[maxn];
bool vis[maxn][maxn];
int dis[maxn][maxn],re;
queue<pair<int,int> >q;
void bfs(int u,int v)
{
	if(s[u][v]=='#')return;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			dis[i][j]=0;
			vis[i][j]=0;
		}
	}
	int cx=u,cy=v;
	dis[cx][cy]=0;
	vis[cx][cy]=1;
	q.push({cx,cy});
	while(q.size())
	{
		cx=q.front().first,cy = q.front().second;
		q.pop();
		re=max(re,dis[cx][cy]);
		for(int i=-1;i<=1;i++)
		{
			for(int j=-1;j<=1;j++)if(!i||!j)
			{
				int x=cx+i,y=cy+j;
				if(x==h||x<0||y==w||y<0)continue;
				if(vis[x][y])continue;
				if(s[x][y]=='#')continue;
				dis[x][y]=dis[cx][cy]+1;
				vis[x][y]=1;
				q.push({x,y});
			}
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			bfs(i,j);
		}
	}
	cout<<re;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
)

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_A&lang=jp>
 */

func init() {
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	str := scanner.Text()
	for _, s := range str {
		if 'a' <= s && s <= 'z' {
			fmt.Print(strings.ToUpper(string(s)))
		} else if 'A' <= s && s <= 'Z' {
			fmt.Print(strings.ToLower(string(s)))
		} else {
			fmt.Print(string(s))
		}
	}
	fmt.Println("")
}

Measured memory_bytes: 1112
S = input()
N = len(S)

MOD = 10**9 + 7
dp = [[0 for _ in range(13)] for _ in range(N)]  # dp[i][j]: S[i]までみて13で割ってjあまるものの個数

# 初期値
if S[0] == "?":
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1


# dpテーブル更新式
for i in range(1, N):
    si = S[i]
    if si == "?":
        for si_cand in range(10):
            for j in range(13):
                dp[i][(j*10+si_cand)%13] += dp[i-1][j] % MOD
    else:
        for j in range(13):
            dp[i][(j*10+int(si))%13] += dp[i-1][j] % MOD

print(dp[N-1][5] % MOD)


Measured memory_bytes: 68080
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    p,q,r=L()
    print(min(p+q,q+r,r+p))

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	int i,sum=0;
	char a[100000];
	scanf("%s", &a);
	for (i = 0; i < 100000; i++) {
		if (a[i] == 0) {
			break;
		}
		sum += a[i] - 48;
	}
	if (sum == 1) {
		sum = 10;
	}
	printf("%d", sum);
}

Measured memory_bytes: 128
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1e9+7;
int main(void) {
    int n, a, ans = 23; cin >> n; vector<int> d(13, 0);
    rep(i, n) {
        cin >> a; d[a]++;
        ans = min(ans, a);
    }if (d[0] > 0 || d[12] > 1) {
        cout << 0 << endl;
        return 0;
    }
    req(i, 11) {
        if (d[i] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }vector<int> b(24, 0);
    b[0] = 1; int f = 0;
    req(i, 12) {
        if (d[i] == 0)continue;
        if (d[i] == 1) {
            if (f) b[24 - i] = 1;
            else b[i] = 1;
            f++; f %= 2;
        }
        else {
            b[24 - i] = 1; b[i] = 1;
        }
    }int cnt = 1;
    req(i, 23) {
        if (!b[i]) cnt++;
        else {
            ans = min(ans, cnt);
            cnt = 1;
        }
    }cout << ans << endl;
}

Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val s = readLine()!!
    var ans = 0L
    for (i in 0 until n.toInt()) {
        if (s[i] == 'L' && i > 0) {
            if (s[i - 1] == 'L') ans++
        } else if (s[i] == 'R' && i < n - 1) {
            if (s[i + 1] == 'R') ans++
        }
    }
    println(Math.min(ans + 2 * k, n - 1))
}

Measured memory_bytes: 38844
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
using llong = long long;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s;
    cin >> s;

    int a_idx, z_idx;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'A'){
            a_idx = i;
            break;
        }
    }
    for (int i = s.size()-1; i >= 0; i--){
        if (s[i] == 'Z'){
            z_idx = i;
            break;
        }
    }
    cout << z_idx - a_idx + 1 << endl;

    return 0;
}




Measured memory_bytes: 640
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
const ll maxN=1e5;
ll a[maxN] , n , k ;
void solve(){
	cin>> n >> k ;
	for(ll i=0;i<n ;i++)cin>>a[i];
	sort(a , a+n);
	ll ans=0;
	for(ll i=0;i<k ;i++)ans+=a[i];
	cout<<ans<<endl;
}
int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>>t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数値の入力
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        boolean flg = false;
        // 固まり
        long l = b + c;

        // ブロック数とtarget
        long answer = b * (a / l);
        // 閾値
        long n = a % l;

        System.out.println(answer + Math.min(n, b));
    }
}


Measured memory_bytes: 22868
#include <iostream>
using namespace std;
long long dp[45];

long long fib(int n) {
    for (int i = 0; i <= n; i++) {
        if (i <= 1) dp[i] = 1;
        else dp[i] = dp[i-2] + dp[i-1];
    }
    return dp[n];
}

int main() {
    int n; cin >> n;
    cout << fib(n) << endl;
}


Measured memory_bytes: 3092
#include <iostream>

#define M_PI 3.1415926535897932384626

int main(){
    double r;
    std::cin >> r;
    //std::cout << M_PI*r*r << " " << 2*M_PI*r << std::endl;
    printf("%10.8f %10.8f", M_PI*r*r, M_PI*2*r);
    return 0;
}



Measured memory_bytes: 3284
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No") {
		if (judge_exp) {
			cout << ok << endl;
		} else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right) {
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void) {
	int a, b;
	cin >> a >> b;
	judge_outer(a < 9 && b < 9, "Yay!", ":(");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if((s[0]==s[1] and s[1]==s[2])or (s[1]==s[2] and s[2]==s[3])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
use std::cell::RefCell;
use std::cmp::{max, min};
use std::io::{self, stdout, BufWriter, Read, Write};
use std::iter::FromIterator;

#[allow(dead_code)]
struct Source {
    chars: Box<Iterator<Item = char>>,
}

#[allow(dead_code)]
impl Source {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }

    fn from_stdin() -> Self {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        Self::from_str(&data)
    }

    fn from_str(s: &str) -> Self {
        let data = String::from(s);
        let chars = data.chars().collect::<Vec<char>>().into_iter();
        Source {
            chars: Box::new(chars),
        }
    }
}

thread_local!(static SRC: RefCell<Source> = RefCell::new(Source::from_stdin()));

#[allow(unused_macros)]
macro_rules! input {
    ($($elem:tt)*) => {
        input_inner!(SRC, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    input! { a: i32, b: i32 }

    if a <= 8 && b <= 8 {
        writeln!(out, "Yay!").unwrap()
    } else {
        writeln!(out, ":(").unwrap()
    }
}


Measured memory_bytes: 4352
from heapq import heappush, heappop

n,m=map(int,input().split())
a=map(int,input().split())
hp=[]
for i in a:
    heappush(hp,-i)
for i in range(m):
    max=heappop(hp)
    heappush(hp, -(-max//2))
print(-sum(hp))

Measured memory_bytes: 14180
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;

  int ec = 0;
  int wc = 0;

  REP(i, n) {
    if(s[i] == 'E') ec++;
  }

  int ans = INF;
  REP(i, n) {
    if(s[i] == 'E') ec--;
    ans = min(ans, (ec + wc));
    if(s[i] == 'W') wc++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
#include<iostream>
using namespace std;
int main()
{
  
  int a,b,c;
  int box;
  cin >> a >> b >> c;

  if ( a >= b && b >= c ){
    cout << (a*10+b)+c << endl;
    
  }else if( a >= b && a >= c){
    cout << (a*10+c)+b << endl;
    
  }else if( b >= a && a >= c ){
    cout << (b*10+a)+c << endl;
    
  }else if( b >= a &&  b >= c){
    cout <<  (b*10+c)+a << endl;
    
  }else if( c >= a && a >= b ){
    cout <<  (c*10+a)+b << endl;
    
  }else if( c >= a && c >= b){
    cout <<  (c*10+b)+a << endl;
  }
  return(0);
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct edge{
    int to, dist, attack;
};

struct P {
    int from, money, enemy;

    bool operator >(const P& p) const {
        return enemy > p.enemy;
    }
};

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

int N, M, L;

int main() {
    while (cin >> N >> M >> L, N|M|L) {
        vector<vector<edge>> E(N+1);
        REP(i, M) {
            int from, to, dist, enemy;
            cin >> from >> to >> dist >> enemy;
            E[from].push_back((edge){to, dist, enemy});
            E[to].push_back((edge){from, dist, enemy});
        }

        bool G[N+1][L+1];
        fill_n((bool *)G, (N+1)*(L+1), false);

        priority_queue<P, vector<P>, greater<P>> q;
        // start
        q.push((P){1, L, 0});
        int enemy = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();
            // goal
            if (p.from == N) {
                enemy = p.enemy;
                break;
            }
            if (G[p.from][p.money]) continue;
            G[p.from][p.money] = true;
            for (edge e : E[p.from]) {
                if (p.money >= e.dist) {
                    q.push((P){e.to, p.money - e.dist, p.enemy});
                }
                q.push((P){e.to, p.money, p.enemy + e.attack});
            }
        }

        cout << enemy << endl;
    }
}

Measured memory_bytes: 1888
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;cin>>s;
	ll k;cin>>k;
	ll ans = 0;
	ll tmp = 1;
	bool flag = true;
	for(int i = 0; i < s.size() - 1; i++) {
		if (s[i] == s[i + 1]){
			tmp ++;
		}
		else{
			flag = false;
			ans += (tmp / 2);
			tmp = 1;
		}
	}

	ans += (tmp / 2);

	if (flag){
		cout << k * s.size() / 2 << endl;
		return 0;
	}

	if (s[0] != s[s.size() - 1]){
		cout << k * ans << endl;
		return 0;
	}

	ll a = 1;
	ll b = 1;
	for(int i = 1; i < s.size(); i++) {
		if(s[i] == s[0]){
			a ++;
		}
		else{
			break;
		}
	}
	for(int i = 1; i < s.size(); i++) {
		if(s[s.size() - i - 1] == s[s.size() - 1]){
			b++;
		}
		else{
			break;
		}
	}

	cout << ans * k + (k - 1) * ((a + b) / 2 - (a / 2) - (b / 2)) << endl;

	return 0;
}

Measured memory_bytes: 256
import bisect

S=[]

q=int(input())

def find(x):
    index=bisect.bisect_left(S,x)
    if index==len(S):
        return -1
    if S[index]==x:
        return index
    else:
        return -1


for _ in range(q):
    query=[int(i) for i in input().split(" ")]
    if query[0]==0:
        bisect.insort_left(S, query[1])
        print(len(S))
    elif query[0]==1:
        L,R=query[1],query[1]
        indL=bisect.bisect_left(S,L)
        indR=bisect.bisect_right(S,R)
        print(len(S[indL:indR]))
    elif query[0]==2:
        while find(query[1])>=0:
            S.pop(find(query[1]))
    else:
        L,R=query[1],query[2]
        indL=bisect.bisect_left(S,L)
        indR=bisect.bisect_right(S,R)
        for s in S[indL:indR]:
            print(s)



Measured memory_bytes: 14612
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int add=0, sub=0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='+') add++;
    else sub++;
  }
  cout<<add-sub<<endl;
}



Measured memory_bytes: 3592
//16:53:00

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace  std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	sort(all(v));
	int mn=v.back()-v[0];
	For(i,k-1,n-1) mn=min(mn,v[i]-v[i-k+1]);
	cout<<mn<<"\n";
	return 0;
}

















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

void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> a(h, vector<int>(w));
    int id = 1;
    rep(i, h) rep(j, w) if (s[i][j] == '#') a[i][j] = id++;
    rep(i, h) rep(j, w)
    {
        if (a[i][j] == 0)
        {
            if (j > 0)
                a[i][j] = a[i][j - 1];
        }
    }
    rep(i, h)
    {
        for (int j = w - 1; j >= 0; j--)
        {
            if (a[i][j] == 0)
            {
                if (j < w - 1)
                    a[i][j] = a[i][j + 1];
            }
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            if (a[i][j] == 0)
            {
                if (i > 0)
                    a[i][j] = a[i - 1][j];
            }
        }
    }
    for (int i = h - 1; i >= 0; i--)
    {
        rep(j, w)
        {
            if (a[i][j] == 0)
            {
                if (i < h - 1)
                    a[i][j] = a[i + 1][j];
            }
        }
    }
    rep(i, h)
    {
        rep(j, w) cout << a[i][j] << " ";
        cout << endl;
    }
}

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

Measured memory_bytes: 4152
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int daytable[1440];
void init() {
	rep(i, 1440) {
		daytable[i] = 0;
	}
}
struct day { int time; char io; int num; };
int trans(string x) {
	string s1 = x.substr(0, 2);
	string s2 = x.substr(3, 2);
	int res; res = stoi(s1) * 60 + stoi(s2);
	return res;
}
bool comp(day x, day y) {
	if (x.num != y.num) {
		return x.num < y.num;
	}
	return x.time < y.time;
}
int main() {
	int n;
	while (cin >> n, n) {
		string s, t, u; char v;
		vector<day> a[365]; int cnt = 0; string memo;
		cin >> s >> t >> v >> u;
		memo = s;
		a[0].push_back({ trans(t),v,stoi(u) });
		rep(i, n-1) {
			cin >> s >> t >> v >> u;
			if (s != memo) {
				cnt++; memo = s;
			}
			a[cnt].push_back({ trans(t),v,stoi(u) });
		}
		int out[1000] = {};
		rep(i, cnt + 1) {
			init();
			sort(a[i].begin(), a[i].end(), comp);
			int len = a[i].size();
			for (int j = 0; j < len; j += 2) {
				if (a[i][j].num == 0) {
					Rep(k, a[i][j].time, a[i][j + 1].time) {
						daytable[k] = 1;
					}
				}
				else {
					Rep(k, a[i][j].time, a[i][j + 1].time) {
						if (daytable[k]) {
							out[a[i][j].num]++;
						}
					}
				}
			}
		}
		int ma = 0;
		rep(i, 1000) {
			ma = max(ma, out[i]);
		}
		cout << ma << endl;
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];

    ll x = 1;
    ll y = 1;
    rep(i, N) {
        ll m = max((x + T[i] - 1) / T[i], (y + A[i] - 1) / A[i]);
        x = m * T[i];
        y = m * A[i];
    }
    cout << x + y << endl;
}

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2
#define int long long

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,ans=0;
    cin>>n;
    Vi a(n),s(n+1);
    s[0]=0;
    REP(i,0,n){
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    map<int,int> mp;
    REP(i,0,n+1) mp[s[i]]++;
    for(auto x : mp){
        if(x.second>=2) ans+=x.second*(x.second-1)/2;
//        cout<<x.first<<" "<<x.second<<ENT;
    }
    cout<<ans<<ENT;
    return 0;
}


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


Measured memory_bytes: 15872
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> cnt;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        cnt[a]++;
    }

    int sz = cnt.size();
    string ans;

    if(sz == 1){
        auto it = cnt.begin();
        int num = it -> first;

        if(num * 2 <= N || num + 1 == N) ans = "Yes";
        else ans = "No";
    }

    else if(sz == 2){
        auto it = cnt.begin();
        int n1 = it -> first;
        it++;
        int n2 = it -> first;

        int mn = min(n1, n2);
        int mx = max(n1, n2);

        int rest = mx - cnt[mn];
        int restcnt = N - cnt[mn];
        if(mn + 1 == mx && rest > 0){
            if(restcnt >= rest * 2){
                ans = "Yes";
            }
            else {
                ans = "No";
            }
        }
        else {
            ans = "No";
        }
    }

    else {
        ans = "No";
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#ABC122_C
N,Q=map(int,input().split())
S=input()

ls=[0]

Spre=S[0]
for i in range(1,N):
    Si=S[i]
    if Spre=='A' and Si=='C':
        ls.append(ls[-1]+1)
    else:
        ls.append(ls[-1])
    Spre=Si
 
for i in range(Q):
    l,r=map(int,input().split())
    print(ls[r-1]-ls[l-1])



Measured memory_bytes: 6124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
 int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> H(n, 0);
    vector<ll> path(n, 0);
    for (auto & h : H) cin >> h;
    for (ll i = 0; i < m; ++i) {
        ll a, b;
        cin >> a >> b;
        --a;--b;

        if (H[a] >= H[b]) {
            ++path[b];
        }
        if (H[b] >= H[a]) {
            ++path[a];
        }
    }
    ll res = 0;
    for (auto p : path) {
        if (p == 0) ++res;
    }
    cout << res << endl;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
//void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int N;
string s;
Vi ss,ans;
bool flag=false;

bool check(int n,int m){
    Vi a(N);
    a[0]=n;
    a[1]=m;
    REP(i,2,N){
        a[i]=a[i-1]^a[i-2]^ss[i-1];
    }
    flag=true;
    if(a[0]!=a[N-1]^a[N-2]^ss[N-1]) flag=false;
    if(a[1]!=a[0]^a[N-1]^ss[0]) flag=false;
    if(flag) ans=a;
    return flag;
}

void vout(Vi a){
    REP(i,0,a.size()){
        if(a[i]==0) cout<<'S';
        else cout<<'W';
    }
    cout<<endl;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    cin>>N>>s;
    REP(i,0,N){
        if(s[i]=='o') ss.pb(0);
        else ss.pb(1);
    }
    if(check(0,0)){vout(ans);return 0;}
    if(check(0,1)){vout(ans);return 0;}
    if(check(1,0)){vout(ans);return 0;}
    if(check(1,1)){vout(ans);return 0;}
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
int main(){
  int n,i;
  cin>>n;
  vint a(n);
  lint sum=0;
  for(i=0;i<n;i++){
   cin>>a[i]; sum+=a[i];sum--;
  }
cout<<sum<<endl;
  
  

}

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

int main(){
  long W, a, b;
  cin >> W >> a >> b;
  if(a+W<=b){
    cout << b-a-W << endl;
    return 0;
  }
  else if(b+W<=a){
    cout << a-b-W << endl;
    return 0;
  }
  cout << "0" << endl;
  return 0;
}

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

using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<40;

int D;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> D;
    
    string res = "Christmas";    
    string eve = " Eve";
    
    for (int i = 0; i < (25 - D); ++i) {
        res += eve;
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  double win=0;
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    long long point=i;
    double tmp=1;
    tmp/=n;
    while(point<k){
      point*=2;
      tmp/=2;
    }
    win+=tmp;
  }
  printf("%.10lf\n",win);
  return 0;
}


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

ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main() {
    int n;cin >> n;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];
    rep(i,n-1){
        t[i+1] = lcm(t[i],t[i+1]);
    }
    cout << t[n-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;
const string alp = "abcdefghijklmnopqrstuvwxyz";

int main() {
    // int N = 1000000000000001;
    ll K;
    cin >> K;
    K = K -1;

    bool isLoop = true;
    string output = "";
    while (isLoop) {
        ll amari = K % 26;
        K = K / 26;

        output = alp.at(amari) + output ;
        if ( K == 0) {
            isLoop = false;
        }else{
            K = (K * 26 - 26)/26;
        }
    }

    cout << output << endl;
    return 0;
}

Measured memory_bytes: 3628
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    ans = []

    tmp = (n - 1) * (n - 2) // 2
    if k > tmp:
        print(-1)
        exit(0)

    for i in range(n - 1):
        ans.append([i, n - 1])

    breakflg = False
    for i in range(n - 1):
        for j in range(i + 1, n - 1):
            if tmp == k:
                breakflg = True
                break

            tmp -= 1
            ans.append([i, j])

        if breakflg:
            break

    print(len(ans))
    for a, b in ans:
        print(a + 1, b + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 80368
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(a>=c||b>=c||a+b>=c){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

void solve() {
	int N; cin >> N;
	map<string, int>mp;
	REP(i, N) {
		string S; cin >> S;
		mp[S]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


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

int main(){
    int n;
    cin >> n;
    int s[110];
    int fullScore = 0;
    bool isZero = true;
    for(int i=0; i<n; i++){
        cin >> s[i];
        fullScore += s[i];
        if(s[i] % 10 != 0){
            isZero = false;
        }
    }
    if(fullScore % 10 != 0){
        cout << fullScore << endl;
    }else{
        if(isZero){
            cout << 0 << endl;
        }else{
            sort(s, s+n);
            for(int i=0; ; i++){
                if(s[i] % 10 != 0){
                    cout << fullScore - s[i] << endl;
                    break;
                }
            }
        }
    }
    return 0;
}

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

int main(){
	int triangle[10][10];
	long long int input;

	while(cin >> input){
		for(int i=0; i < 10; i++){
			triangle[0][9-i] = input % 10;
			input /= 10;
		}

		for(int i=1; i < 10; i++){
			for(int j=0; j < 10-i; j++){
				triangle[i][j] = (triangle[i-1][j] + triangle[i-1][j+1]) % 10;
			}
		}
		cout << triangle[9][0] << endl;
	}
}

Measured memory_bytes: 1156
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
XU=[list(SR().split()) for _ in range(N)]
ans = 0

for xu in XU:
    if xu[1] == 'JPY':
        ans += int(xu[0])
    else:
        ans += float(xu[0])*380000
print(ans)

Measured memory_bytes: 5296
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t X;
    intmax_t ans = 0;

    scanf("%jd", &X);

    X -= ((X % 100) / 5) * 105;

    if (X < 0) {
        puts("0");
        return 0;
    }

    if ((X % 100) > 0) 
        X -= 100 + (X % 100);

    if (X < 0) {
        puts("0");
        return 0;
    }

    puts("1");

    return 0;
}


Measured memory_bytes: 128
n=int(input())

# 最上公倍数を考える
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

num_list=[]
for _ in range(n):
    num_list.append(int(input()))
print(lcm(*num_list))

Measured memory_bytes: 5332
s = input()
s = s[:-1]
ans = 0
while len(s) >= 2:
  if len(s) % 2 == 0:
    if s[:len(s) // 2] == s[len(s) // 2:]:
      ans = len(s)
      break
    else:
      s = s[:-1]
  else:
    s = s[:-1]
print(ans)

Measured memory_bytes: 3060
N, M = map(int, input().split())
start_pos = []
check_point = []
for _ in range(N):
    a, b = map(int, input().split())
    start_pos.append((a, b))

for _ in range(M):
    c, d = map(int, input().split())
    check_point.append((c, d))

for a, b in start_pos:
    min_dist = 1_000_000_000
    min_dist_pos = 0
    for i, pos in enumerate(check_point):
        c, d = pos
        tmp = abs(a - c) + abs(b - d)
        if tmp < min_dist:
            min_dist = tmp
            min_dist_pos = i + 1

    print(min_dist_pos)


Measured memory_bytes: 67344
W, H, x, y = map(float, input().split())

if x == W or y == H or x == 0.0 or y == 0.0:
    ans = H*W/2
    ans_2 = 0
elif x*H == y*W or (W-x)*H == y*W:
    ans = H*W/2
    if float(x) == W/2 and float(y) == H/2:
        ans_2 = 1
    else:
        ans_2 = 0
elif abs(W/2-x) * (H/2) / abs(H/2-y) < W/2:
    ans = H*W/2
    ans_2 = 0
else:
    yoko_a = W * y
    yoko_b = W * (H-y)
    yoko = min(yoko_a, yoko_b)

    tate_a = H * x
    tate_b = H * (W-x)
    tate = min(tate_a, tate_b)
    
    ans = max(tate, yoko)
    ans = float(ans)

    if tate == yoko:
        ans_2 = 1
    else:
        ans_2 = 0

print(ans, ans_2)

Measured memory_bytes: 38396
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		ll n;
		cin>>n;

		string str = "";
		string letter = "abcdefghijklmnopqrstuvwxyz";
		while(n) {
			ll rem = n%26;

			if(rem == 0) {
				str = 'z' + str;
				n = n/26 - 1;
			}
			else {
				str = char(int('a') + rem - 1) + str;
				n = n/26; 
			}
		}
		cout<<str<<endl;
		return 0;
	}


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

int N;
i64 C;

vector<i64> x,v;

i64 ans = 0;

int main(){
  cin >> N >> C;
  x.resize(N);
  v.resize(N);
  for(int i = 0;i < N;i++) cin >> x[i] >> v[i];

  {
    i64 sum = 0;
    for(int i = 0;i < N;i++){
      sum += v[i];
      // sum - x[i]
      ans = max(ans , sum - x[i]);
    }
  }
  {
    i64 sum = 0;
    for(int i = N - 1;i >= 0;i--){
      sum += v[i];
      //sum - (C - x[i])
      ans = max(ans , sum - (C - x[i]));
    }
  }
  {
    vector<i64> left(N);
    vector<i64> right(N);
    i64 sum = 0;
    for(int i = 0;i < N;i++){
      sum += v[i];
      // 戻る分のエネルギー..x[i]
      left[i] = sum - x[i] * 2;
    }

    sum = 0;
    for(int i = N - 1;i >= 0;i--){
      sum += v[i];
      //sum - (C - x[i])
      right[i] = sum - (C - x[i]);
    }

    for(int i = 1;i < N;i++){
      left[i] = max(left[i - 1],left[i]);
    }

    for(int i = N - 2;i >= 0;i--){
      right[i] = max(right[i + 1],right[i]);
    }

    for(int i = 0;i < N - 1;i++){
      ans = max(ans , left[i] + right[i + 1]);
    }

  }
  {
    vector<i64> left(N);
    vector<i64> right(N);
    i64 sum = 0;
    for(int i = 0;i < N;i++){
      sum += v[i];
      // 戻る分のエネルギー..x[i]
      left[i] = sum - x[i];
    }

    sum = 0;
    for(int i = N - 1;i >= 0;i--){
      sum += v[i];
      //sum - (C - x[i])
      right[i] = sum - (C - x[i]) * 2;
    }

    for(int i = 1;i < N;i++){
      left[i] = max(left[i - 1],left[i]);
    }

    for(int i = N - 2;i >= 0;i--){
      right[i] = max(right[i + 1],right[i]);
    }

    for(int i = 0;i < N - 1;i++){
      ans = max(ans , left[i] + right[i + 1]);
    }

  }
  cout << ans << endl;
}



Measured memory_bytes: 3424
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int A, B;
  cin >> A >> B;
  //入力終了
  
  int ans = 0;
  for(int i = A; i<=B; i++){
    //intをstringに変換
    string str = to_string(i), rev = str;
    //文字列の順列を逆にする
    reverse(rev.begin(), rev.end() );
    if(str == rev)
      ans++;
  }

  //解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long N;
long a[200005];
long b[200005];

set<long> up;
set<long> down;

int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		a[i]--;
		b[a[i]] = i;
	}

	up.insert(-1);
	up.insert(N);
	down.insert(1);
	down.insert(-N);

	long ans = 0;

	for(int i = 0; i < N; i++){
		long upidx, downidx, right, left;
		upidx = *up.lower_bound(b[i]);
		downidx = -(*down.lower_bound(-b[i]));

		right = (upidx - b[i]);
		left = (b[i] - downidx);
		ans += (i+1) * right * left;
		up.insert(b[i]);
		down.insert(-b[i]);
	}
	cout << ans << endl;
}



Measured memory_bytes: 22144