akhauriyash/Code-Regression huggingface dataset:
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0351

#include<bits/stdc++.h>
const int N = 1505;
const int inf = 1e9;
using namespace std;

typedef pair <int, int> ii;
vector <ii> adj[N];
int n, m, d[N][N], ans, visit[N], f[N], ck[N];

void dijkstra(int S){
    for (int i = 1; i <= n; i++) d[S][i] = inf; d[S][S] = 0;
    priority_queue <ii, vector <ii>, greater<ii> > mq; mq.push(ii(d[S][S], S));
    while (mq.size()){
        ii z = mq.top(); mq.pop();
        int u = z.second, val = z.first;
        if (val != d[S][u]) continue;
        ans = max(ans, val);
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first, cost = adj[u][i].second;
            if (d[S][v] > d[S][u] + cost){
                d[S][v] = d[S][u] + cost;
                mq.push(ii(d[S][v], v));
            }
        }
    }
}

void dfs(int u, int root){
    if (visit[u]) return;
    visit[u] = true;
    f[u] = d[root][u];
    for (int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i].first, cost = adj[u][i].second;
        if (d[root][v] == d[root][u] + cost){
            dfs(v, root); f[u] = max(f[u], f[v]);
        }
    }
    if (f[u] == ans) ck[u] = 1;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v, d; cin >> u >> v >> d;
        adj[u].push_back(ii(v, d));
        adj[v].push_back(ii(u, d));
    }
    for (int i = 1; i <= n; i++) dijkstra(i);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) visit[j] = 0;
        dfs(i, i);
    }
    int cnt = 0; for (int i = 1; i <= n; i++) if (!ck[i]) cnt++;
    cout << cnt << "\n";
    for (int i = 1; i <= n; i++) if (!ck[i]) cout << i << "\n";
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  vector< int64 > cur;
  auto gen = MFP([&](auto gen, int64 v) -> void {
    if(v > 3234566667) return;
    int64 last = v % 10;
    for(int k = v == 0 ? 1 : 0; k < 10; k++) {
      if(v && abs(last - k) > 1) continue;
      gen(v * 10 + k);
    }
    if(v > 0) cur.emplace_back(v);
  });
  gen(0);
  sort(begin(cur), end(cur));
  cur.erase(unique(begin(cur), end(cur)), end(cur));
  int K;
  cin >> K;
  cout << cur[K - 1] << endl;
}



Measured memory_bytes: 1400
n=int(input())
p=[int(i) for i in input().split(" ")]

retval=0
for i in range(1,n-1):
    if p[i-1]>p[i] and p[i]>p[i+1]:
        retval+=1
    elif p[i-1]<p[i] and p[i]<p[i+1]:
        retval+=1

print(retval)


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
}

Measured memory_bytes: 3532
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Long> List = new ArrayList<>();
        long N = sc.nextLong();
        long K = sc.nextLong();
        for(int i=0;i<N;i++) List.add(sc.nextLong());
        Collections.sort(List,Collections.reverseOrder());
        long sum = 0;
        for(long i=K;i<List.size();i++) sum+=List.get((int)i);
        System.out.println(sum);
    }
}

Measured memory_bytes: 80380
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

mod = 10**9+7
def comb(n, k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= mod
    d = 1
    for i in range(1, k + 1):
        d *= i
        d %= mod
    return (c * pow(d, mod - 2, mod)) % mod


x,y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (x + y) // 3
x -= n
y -= n
if x < 0 or y < 0:
    print(0)
    exit()

print(comb(x + y, x))


Measured memory_bytes: 63608
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll N, A, B;
  std::cin >> N >> A >> B;

  ll cnt = N / (A + B);
  ll sum = cnt * A + std::min((N % (A+B)), A);

  print(sum);

  return 0;
}


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

using namespace std;

int max_b(int x){
  while(x / 10) x /= 10;
  return x;
}

int min_b(int x){
  return x % 10;
}

int main(){
  int N;
  cin >> N;
  
  int c[10][10];
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++) c[i][j] = 0;
  }
  
  for(int i = 1; i <= N; i++){
    c[max_b(i)][min_b(i)]++;
  }
  
  long long cnt = 0;
  for(int i = 1; i <= N; i++){
    int mx = max_b(i);
    int mn = min_b(i);
    if(mx == 0 || mn == 0) continue;
    
    cnt += c[mn][mx];
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, f = 0;
  char c;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%c", &c);
    if(c == 'Y')
      f = 1;
  }
  printf("%s\n", f ? "Four" : "Three");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[100];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,a){
		cin>>x[i];
		c+=(b-1)/x[i]+1;
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
typedef long long ll;

using namespace std;
int test(){
    //[0,2,2,6,8,8,10]
    int a[7];
    for(int i = 0; i < 5; i++){
        a[i] = i * 2;
    }
    a[2] = 2;
    a[5] = 8;
    a[6] = 10;
    cout << upper_bound(a, a+7, 12) - lower_bound(a, a+7, 11) << endl;
    return 0;
}

int main(){
    //test();
    int N,i,j,k;
    cin >> N;
    ll a[N], b[N];
    for(i = 0; i < N; i++){
        cin >> a[i];
    }
    for(i = 0; i < N; i++){
        cin >> b[i];
    }

    ll ans = 0;
    for(k = 0; k < 30; k++){
        ll a1[N], b1[N];
        ll T = pow(2,k);
        for( j = 0; j < N; j++){
            a1[j] = a[j] % (2 * T);
            b1[j] = b[j] % (2 * T);
        }
        sort(b1, b1+N);
        ll count = 0;
        for(j = 0; j < N; j++){
            //int pos_1 = lower_bound(b1, b1+N, T - a1[j]);
            //int pos_2 = lower_bound(b1, b1+N, 2 * T - a1[j]);
            //int pos_3 = lower_bound(b1, b1+N, 3 * T - a1[j]);
            //int pos_4 = lower_bound(b1, b1+N, 4 * T - a1[j]);
            //cout << pos_1 << pos_2 << pos_3 << pos_4 << endl;
            //count += pos_2 - pos_1 + pos_4 - pos_3;
            
            count += lower_bound(b1, b1+N, 4 * T - a1[j]) - lower_bound(b1, b1+N, 3 * T - a1[j]) + lower_bound(b1, b1+N, 2 * T - a1[j]) - lower_bound(b1, b1+N, T - a1[j]);
        }
        if(count % 2 == 1){
            ans += pow(2, k);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		int rank;
		if (x < 600) rank = 8;
		else if (x < 800) rank = 7;
		else if (x < 1000) rank = 6;
		else if (x < 1200) rank = 5;
		else if (x < 1400) rank = 4;
		else if (x < 1600) rank = 3;
		else if (x < 1800) rank = 2;
		else rank = 1;
		
		System.out.println(rank);
		
		sc.close();
	}
	
}



Measured memory_bytes: 27036
s = input()
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
if s[:2] in months and s[2:] in months:
	print("AMBIGUOUS")
elif s[:2] in months and s[2:] not in months:
	print("MMYY")
elif s[:2] not in months and s[2:] in months:
	print("YYMM")
else:
	print("NA")

Measured memory_bytes: 8972
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id,id1,id2,id3,id4,lim,from,to;
L A[Mx],B[Mx];
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(L i=0;i<n;i++)scanf("%lld",&A[i]);
    for(L i=0;i<m;i++)scanf("%lld",&B[i]);
    for(L i=1;i<n;i++){
        A[i]=A[i]+A[i-1];
    }
    for(L i=1;i<m;i++){
        B[i]=B[i]+B[i-1];
    }
    mx=0;
    for(L i=0;i<n;i++){
        c1=A[i];
        if(c1>k)break;
        c2=(k-c1);

        id=upper_bound(B,B+m,c2)-B;
        mx=max(mx,(i+id+1));
    }
    for(L i=0;i<m;i++){
        c1=B[i];
        if(c1>k)break;
        c2=(k-c1);

        id=upper_bound(A,A+n,c2)-A;
        mx=max(mx,(i+id+1));
    }
    // cout<<c<<endl;
    printf("%lld\n",mx);
    return 0;
}

/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

int main(){
	int H=1,W=1;	
	while (H>0&&W>0){	
		cin>>H>>W;  
		if (H==0&&W==0) break;
		for ( int k=0; k<H; k++){
			for ( int r=0; r<W; r++){
				cout<<"#";
			}
		cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, d;

int main(){
	cin >> n >> m >> d;
	
	if(d == 0) printf("%.10f\n", (double)(m-1)/n);
	else printf("%.10f\n", (double)(n-d)*2.0*(m-1)/n/n);
	
	return 0;
}

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


int main()
{

long long n,d;
cin>>n>>d;
 int ans = 0;

 while(n--)
 {

     long long  x,y;
     cin>>x>>y;


     if(x*x+y*y<=d*d)
        ans++;
 }
 cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
 
int a[4];
 
int main()
{
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == 'N') {
            a[0]++;
        }
        else if(s[i] == 'S') {
            a[1]++;
        }
        else if(s[i] == 'E') {
            a[2]++;
        }
        else a[3]++;
    }
    string ans = "Yes";
    if(a[0]!= 0) {
        if(a[1] == 0) ans = "No";
    }
    if(a[1]!= 0) {
        if(a[0] == 0) ans = "No";
    }
    if(a[2]!= 0) {
        if(a[3] == 0) ans = "No";
    }
    if(a[3]!= 0) {
        if(a[2] == 0) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

#define endl '\n'

using namespace std;

const int MAXN=3e3+3;
double dp[MAXN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    dp[0]=1;
    for(int i=0;i<n;++i){
        double coin;
        cin>>coin;
        for(int i2=i+1;i2>=0;--i2){
            dp[i2]=(i2==0 ? 0 : dp[i2-1])*coin+dp[i2]*(1-coin);
        }
    }
    double res=0;
    for(int i=n/2+1;i<=n;++i){
        res+=dp[i];
    }
    cout<<fixed<<setprecision(10)<<res<<endl;
return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));
  const t = s[0];
  const a = s[1];
  const b = s[2];

  const ans = Math.min(t * a, b);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7496
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: i64 = sc.get();
    let B: i64 = sc.get();
    let K: i64 = sc.get();
    if K > A {
        println!("{} {}", 0, max(0, B - (K - A)));
    } else {
        println!("{} {}", A - K, B);
    }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n, k;
    cin >> n >> k;

    int ans = 0;
    while(n > 0){
        n /= k;
        ans++;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi v (6,0);
  rep(i,n){
    double h;
    cin>>h;
    if(h<165)v[0]++;
    else if(h<170)v[1]++;
    else if(h<175)v[2]++;
    else if(h<180)v[3]++;
    else if(h<185)v[4]++;
    else v[5]++;
  }
  rep(i,6){
    cout<<i+1<<":";
    rep(j,v[i])
      cout<<"*";
    cout<<endl;
  }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

int32 dx[4] = {-1, 1, 0, 0};
int32 dy[4] = {0, 0, -1, 1};

int main(void){
	int32 H, W;
	string s[51];
	cin >> H >> W;
	REP(i, H) cin >> s[i];
	auto in = [&](int32 y, int32 x){return 0<=y&&y<H&&0<=x&&x<W;};
	REP(i, H){
		REP(j, W){
			int32 cnt = 0;
			if(s[i][j] == '.') continue;
			REP(k, 4){
				int32 yy = i+dy[k], xx = j+dx[k];
				if(!in(yy, xx)) continue;
				if(s[yy][xx] == '#') cnt++;
			}
			if(cnt == 0){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <cstdio>

int main(void) {
  int N, Y;
  scanf("%d %d", &N, &Y);

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int k = N - (i + j);
      if (10000 * i + 5000 * j + 1000 * k == Y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");

  return 0;
}

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

using namespace std;

long long RepeatSquaring(long long N, long long P, long long M) {
    if (P == 0) return 1;
    if (P % 2 == 0) {
        long long t = RepeatSquaring(N, P / 2, M);
        return t * t % M;
    }
    return N * RepeatSquaring(N, P - 1, M);
}

int main() {
    long long N, P;
    cin >> N >> P;

    map<long long, long long> counter;

    long long num = P;
    for (long long i = 2; i * i <= P; ++i) {
        if (num % i == 0) {
            counter[i]++;
            num /= i;
            i--;
        }
    }
    if (num != 1) counter[num]++;

    long long ans = 1;
    for (auto &elem: counter) {
        ans *= RepeatSquaring(elem.first, elem.second / N, LONG_LONG_MAX);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, d, left, right;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	left = a + b;
	right = c + d;
	
	if (left > right)
		printf("Left");
	else if (left < right)
		printf("Right");
	else if (left == right)
		printf("Balanced");
		
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;
vector<ll> fac(202000), finv(202000), inv(202000);
ll A, B, C, D;
void initcom(){
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  for(int i=2; i<202000; i++){
    fac[i] = (fac[i-1]*i) % mod;
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll nCr(int n, int k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}
ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}

ll dp[3010][3010];

void dfs(ll c, ll d){
  if(dp[c][d]==-1) dp[c][d]=0;
  if(c>A) {
    if(dp[c-1][d]==-1) dfs(c-1,d);
    dp[c][d] += dp[c-1][d]*d%mod;
    dp[c][d] %= mod;
  }
  if(d>B){
    if(dp[c][d-1]==-1) dfs(c,d-1);
    dp[c][d] += dp[c][d-1]*c%mod;
    dp[c][d] %= mod;
  }
  if(c>A && d>B) {
    if(dp[c-1][d-1]==-1) dfs(c-1,d-1);
    ll mn = (c-1)*(d-1) % mod;
    dp[c][d] -= dp[c-1][d-1]*mn%mod;
    if(dp[c][d]<0) dp[c][d] += mod;
    dp[c][d] %= mod;
  }
}

int main(){
  initcom();
   cin >> A >> B >> C >> D;
  rep(i,3010) rep(j,3010) dp[i][j]=-1;
  dp[A][B]=1;
  dfs(C, D);
  cout << dp[C][D] << endl;
  return 0;
}


Measured memory_bytes: 79144
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
using namespace std;

int main(){

	int S;
  	cin >>S;
  	long long L0,L1;
  	L0 = 2;
  	L1 = 1;
  	long long Ln,ans;
  	if(S==0){
    	ans = L0;
    }else if(S==1){
    	ans = L1;
    }else if(S>=2){
	  	for(int i = 0; i <S-1;i++ ){
        	Ln = L0 + L1;
          	L0 = L1;
			L1 = Ln;
        }
      	ans =Ln;

    
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;
const ll M=500006;
ll f[M],inv[M];
ll expo(ll base,ll exponent){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

vector<bool>  prime(1000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=1000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=1000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
    // freopen("alchemy_input.txt", "r", stdin);
 //    // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
 //    #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    ll tests=1,t=1;
   // cin>>tests;
    while(tests--)
    {
    	ll i,j,n,k;
    	cin>>n;
    	vector<ll>a(n),b(n),c(n);
    	rep(i,0,n-1) cin>>a[i]>>b[i]>>c[i];
    	ll dp[n][3];
    	dp[0][0]=a[0];
    	dp[0][1]=b[0];
    	dp[0][2]=c[0];
    	rep(i,1,n-1)
    	{
    		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    	}
    	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    }

	return 0;
}

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

int main(){
  int N,A,B;
  string S;
  cin >> N >> A >> B  >> S;
  int cnt=0,bcnt=0;
  rep(i,N){
    if(S.at(i)=='a'&&cnt<A+B){
      cout << "Yes" << endl;
      ++cnt;
    }else if(S.at(i)=='b'&&cnt<A+B&&bcnt<B){
      cout << "Yes" << endl;
      ++bcnt; ++cnt;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 896
Scanf.scanf"%f %f %f"(fun a b c->let c=4.*.atan 1.*.c/.180.in Printf.printf"%f
%f
%f
"(a*.b*.sin c/.2.)(a+.b+.sqrt(a*.a+.b*.b-.2.*.a*.b*.cos c))(b*.sin c))

Measured memory_bytes: 2828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する

int main(){
    string str;
    cin >> str;
    str.replace(5,1," ");
    str.replace(13,1," ");
    cout << str;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110


signed main()
{
    string A, B;
    cin >> A >> B;
    if(A.length() > B.length()) {
        printf("GREATER\n");
        return 0;
    }
    else if(A.length() < B.length()) {
        printf("LESS\n");
        return 0;
    }
    else {
        REP(i, A.length()) {
            int a = A[i] - '0';
            int b = B[i] - '0';
            if(a > b) {
                printf("GREATER\n");
                return 0;
            }
            else if(a < b) {
                printf("LESS\n");
                return 0;
            }
        }
    }
    printf("EQUAL\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long k;
char c[109];
int main()
{
	scanf("%s%lld",c,&k);
	for(int j=0;j<strlen(c);j++)
	{
		if(k-1==j)
		{
			printf("%c",c[j]);
			return 0;
		}
		if(c[j]!='1')
		{
			printf("%c",c[j]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import itertools

def main():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input())
    a = list(map(int, input().split()))
    b = list(itertools.accumulate(a))

    ans = 0
    for i in range(n):
        ans += (a[i] * (b[-1] - b[i]) % mod)
        ans %= mod
        
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 107256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] sticks = new int[n];
    for (int i = 0; i < n; i++)
      sticks[i] = sc.nextInt();
    Arrays.sort(sticks);
    int count = 0;
    int k;
    for (int i = 0; i < n - 2; i++) {
      k = i + 2;
      for (int j = i + 1; j < n - 1; j++) {
        while (k < n && sticks[i] + sticks[j] > sticks[k])
          k++;
        count += k - 1 - j;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 26572
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    var(string, s);

    string ans = "";

    for (char c : s) {
        if (c == 'B') {
            if (ans.size()) ans.pop_back();
        } else {
            ans += c;
        }
    }

    print(ans);

    return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    transform (s.begin()+k-1, s.end(), s.begin()+k-1 , ::tolower);
    transform (s.begin()+k, s.end(), s.begin()+k, ::toupper);
    cout << s << endl;
    return 0;
}

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


int main(){
	int N;
	cin >> N;
	int M = 0;
	rep(i,N){
		int tmp; cin >> tmp;
		if(M<tmp) M = tmp - 1;
	    else if(M>tmp) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;	
}














Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll N;
    cin >> N;
    vector<ll> h(N);
    ll i;
    for (i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    ll max = *max_element(h.begin(), h.end());
    ll cnt = 0;

    for (ll i = max; i >= 1; i--)
    {
        for (ll k = 0; k < N; k++)
        {
            if((h[k] == i && h[k+1] != i) || (k == N - 1 && h[k] == i)){
                cnt++;
            }
            if(h[k] == i) h[k]--;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
from functools import lru_cache
@lru_cache(maxsize=1000)
def digit_search(k, tight, own, X, started):
    if k == len(X):
        return int(own==7)

    digit = int(X[k])
    lim = digit if tight else 9
    res = 0
    for i in range(lim+1):
        if started:
            if i!=3 and i!=5 and i!=7: continue
        else:
            if i!=0 and i!=3 and i!=5 and i!=7: continue

        res += digit_search(k+1, tight and digit==i,\
                            own | (i==7)*4 | (i==5)*2 | (i==3),\
                            X, started or i!=0)

    return res

print(digit_search(0, True, 0, input(), False))


Measured memory_bytes: 4212
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
//namespace
using namespace std;
//#define , typedef, const
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)

#define all_range(C) begin(C), end(C)

typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

//main.cpp----------------------------

void solve();

ll a, b, x;

int main() {
  cin >> a >> b >> x;

  solve();

  return 0;
}

void solve() {
  ll sum = 0;
  bool flag = false;

  if(a==0) {
    cout << b/x+1 << endl;
    return;
  }

  sum = b/x - (a-1)/x;

  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define A 1000
 
main(){
  int length[A];
  int change=0;
  int N;
  int count=0;
  int i,j;
   
  scanf("%d",&N);
   
  for(i=1; i<=N; i++){
    scanf("%d",&length[i]);
  }
   
   
  for(i=1; i<=N; i++){
    for(j=N; j>i; j--){
      if(length[j] < length[j-1]){
      change=length[j-1];
      length[j-1]=length[j];
      length[j]=change;
      count++;
      }
    }
  }
   
  for(i=1; i<=N; i++){
    printf("%d",length[i]);
    if(i < N)
      printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 608
n,k=map(int,input().split())
a=list(map(int,input().split()))

i=0
s=1
way=[1]
co={1:[0]}
while  1==1:
    i+=1
    way.append(a[s-1])
    if a[s-1] not in co:
        co[a[s-1]]=[i]
    else:
        if k<co[a[s-1]][0]:
            print(way[k])
            break
        else:
            print(way[co[a[s-1]][0]+(k-co[a[s-1]][0])%(i-co[a[s-1]][0])])
            break
    s=a[s-1]

Measured memory_bytes: 52960
#include <cstdio>

char s[100005];
int len;

int main(){
	scanf("%s", s);
	while(s[len])
		++len;
	if(s[0] == s[len-1] && (len & 1))
		printf("Second\n");
	else if(s[0] != s[len-1] && !(len & 1))
		printf("Second\n");
	else
		printf("First\n");
}


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

int main(){
    int a,b,a1,b1,r;
    int tmp=0;
    int i=0;
    
    while(cin>>a>>b){
        if(a<b){
            tmp=a;
            a=b;
            b=tmp;
        }
        
        a1=a;
        b1=b;
        r=a1%b1;
        while(r!=0){
            a1=b1;
            b1=r;
            r=a1%b1;
            
        }
        printf("%d %ld\n",b1,(long)a*b/b1);
    }
    
    
    return 0;
    
}

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

const ll INF = 1000000000000000000;

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

  ll y = 0;
  ll ans = INF;
  for (int l = N - 1; l > 0; l--) {
    y += a[l];
    x -= a[l];
    ans = min(ans, abs(x-y));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
//int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
//while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

int32_t main(void){
	IOS;
	char c;
	cin>>c;
	if(isupper(c)) cout<<"A";
	else cout<<"a";
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    char c = ' ';
    int cnt = 0;
    rep(i,n)
    {
        if(s[i]!=c)
        {
            c = s[i];
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
k = list(map(int, input().split())) #input based on n
app = True
for i in k:
    if (i%2 != 0):
        continue
    if not (i%3 == 0 or i%5 == 0):
        app = False
        break
if app:
    print('APPROVED')
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
	
	int a, b, c, d, e, f;
	double x, y;
	
	while( scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f) != EOF){
		y = (double)(c*d - f*a) / (double)(b*d - e*a);
		x = ((double)c - (double)b*y) / (double)a;
		if( -0.0005 < x && x < 0.0005) x = 0.0;
		if( -0.0005 < y && y < 0.0005) y = 0.0;
		printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var nArray = cin.ReadIntArray(N);
            var i = 0;
            var nDic = nArray.ToDictionary(n => ++i, n => n);
            WriteLine(string.Join(" ", nDic.OrderBy(n => n.Value).Select(n => n.Key)));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(){
  int S1S2S3, a1, a2, a3;
  cin >> S1S2S3;
  a1 = S1S2S3/100;
  a2 = (S1S2S3-a1*100)/10;
  a3 = S1S2S3-(a1*100)-(a2*10);
  cout << a1 + a2 + a3 << endl;
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
  
n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  uf.union(a,b)
  
ans = 0
for i in range(n):
  ans = max(uf.size(i), ans)

print(ans)


Measured memory_bytes: 75980
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vi d;
    REP(i, 1, 110) {
        if(a%i == 0 && b%i == 0) d.pb(i);
    }
    reverse(all(d));
    cout << d[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256