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

long long calc(int x, set<int> &s)
{
  auto l = s.lower_bound(x), r = l;
  l--;
  long long res = 0;
  if (l != s.begin())
    res += 1LL * (*r - x) * (*l - *prev(l));

  auto rr = next(r);
  if (rr != s.end())
    res += 1LL * (x - *l) * (*rr - *r);

  return res;
}

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

  int n, id[100100], x;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> x;
    id[x] = i;
  }

  long long ans = 0;
  set<int> s;
  s.insert(-1);
  s.insert(n);
  for (int i = n; i; i--)
  {
    ans += calc(id[i], s) * i;
    s.insert(id[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 5376
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

int main() {
    int N;
    cin >> N;

    N %= 10;

    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        cout << "hon" << endl;
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),i;
		long a[]=new long[3];
		a[0]=2;
		a[1]=1;
		for(i=0;i<n;i++) {
			a[2]=a[0]+a[1];
			a[0]=a[1];
			a[1]=a[2];
		}
		System.out.print(a[0]);
	}
}

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

//#include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;
//#pragma GCC optimize("", on)
//#pragma GCC optimization_level 3

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)
#define input(a) scanf("%lld", &(a))
#define print(a) printf("%lld\n", (a))

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << endl;                      \
        rep(i, h) {                                                            \
            rep(j, w) cerr << a[i][j] << space;                                \
            cerr << endl;                                                      \
        }                                                                      \
        cerr << "]" << endl;                                                   \
    }

#define lldump(a, n) dump(vector<vector<ll>>{a}, 1, n)

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)
#define loop() for (;;)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }
func sign(ll a) { return a ? abs(a) / a : 0; }

def in() {
    ll A;
    cin >> A;
    return A;
}

signed main() {
    ll N, ans = INF;
    cin >> N;
    inc(i, 0, N / 6) {
        ll res = 0, A = i * 6, B = (N - A) / 9 * 9, C = N - A - B;
        while (A) res += A % 6, A /= 6;
        while (B) res += B % 9, B /= 9;
        res += C;
        ans = min(ans, res);
    }
    cout << ans << endl;
}

// for compilation: g++ -Ofast -march=native -o _ _.cpp -std=c++17


Measured memory_bytes: 256
#include <stdio.h>
 
double outerproduct(double xa, double ya, double xb, double yb){
    return xa*yb-xb*ya;
}
 
int main() {
    double x[3], y[3], xp, yp, op1, op2, op3;
    while( EOF!=scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
            &x[0], &y[0], &x[1], &y[1], &x[2], &y[2], &xp, &yp) ) {
            op1 = outerproduct(x[1]-x[0], y[1]-y[0], xp-x[0], yp-y[0]);
            op2 = outerproduct(x[2]-x[1], y[2]-y[1], xp-x[1], yp-y[1]);
            op3 = outerproduct(x[0]-x[2], y[0]-y[2], xp-x[2], yp-y[2]);
        if ( ( (op1>0.0)&&(op2>0.0)&&(op3>0.0) )||
        ( (op1<0.0)&&(op2<0.0)&&(op3<0.0) ) ) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    long long int arr[n];
    long long int pr = 1;
    long long int m = 1e18;

    rep(i, n) {
        cin >> arr[i];
        if(arr[i] == 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    rep(i, n) {
        if(arr[i] <= m / pr) {
            pr = pr * arr[i];
        } else {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << pr << endl;

    return 0;
}

Measured memory_bytes: 4376
#include <iostream>
using namespace std;
int ch[23][23],cnt;
void dfs(int,int);
int main(){
  int w,h,i,j,k,l;
  string in[21];
  while(1){
    cnt=0;
    cin >> w >> h;
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      cin >> in[i];
    }
    for(i=0;i<h+2;i++){
      for(j=0;j<w+2;j++){
	ch[i][j]=1;
      }
    }
    for(i=0,k=1;k<h+1;i++,k++){
      for(j=0,l=1;l<w+1;l++,j++){
	if(in[i][j]=='.') ch[k][l]=0;
	else if(in[i][j]=='#') ch[k][l]=1;
	else ch[k][l]=2;
      }
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(ch[i][j]==2) dfs(i,j);
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
void dfs(int i,int j){
  if(ch[i][j]==1) return ;
  ch[i][j]=1;
  cnt++;
  dfs(i+1,j);
  dfs(i-1,j);
  dfs(i,j-1);
  dfs(i,j+1);
}

Measured memory_bytes: 1216
import Data.Int (Int64)
import Data.List (sortBy, transpose)

divCeil :: Integral a => a -> a -> a
divCeil a b = (a + b - 1) `div` b

solve :: Integral a => a -> [a] -> [a] -> a
solve h as bs = f 1 h fs
    where
        a = maximum as
        fs = takeWhile (>= a) $ sortBy (flip compare) $ as ++ bs
        f i s [] = i - 1 + divCeil s a
        f i s (x : xs) = if s - x <= 0 then i else f (i + 1) (s - x) xs

main :: IO ()
main = do
    [_, h] <- fmap read . words <$> getLine :: IO [Int64]
    [xs, ys] <- transpose . fmap (fmap read . words) . lines <$> getContents
    print $ solve h xs ys


Measured memory_bytes: 146812
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  a.erase(unique(all(a)), a.end());
  for (size_t i = 0; i < a.size(); ++i) {
    cout << a[i];
    if (i != a.size() - 1) cout << " ";
  }
  cout << '\n';

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<int> cnt(4);
    rep (i, 3) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++, cnt[b]++;
    }
    int n1 = 0, n2 = 0;
    rep (i, 4) {
        if (cnt[i] == 1) n1++;
        else if (cnt[i] == 2) n2++;
    }
    if (n1 == 2 && n2 == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  VI B(N-1);
  for (int i = 0; i < N-1; i++) cin >> B[i];
  int sum = B[0];
  for (int i = 1; i < N-1; i++) {
    if (B[i] >= B[i-1]) {
      sum += B[i-1];
    } else {
      sum += B[i];
    }
  }
  sum += B[N-2];
  cout << sum << endl;
  return 0;
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    ll n;
    cin>>n;

    vector<ll> a(n+1,0);
    a.at(1)=0;
    ll sum=1;
    for(int i=2;i<=n;i++){
        for(int j=1;i*j<=n;j++){
            a.at(i*j)++;
        }
        sum += i*(a.at(i)+1);
    }
    cout<<sum<<endl;
}



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

int gcd(int a, int b) {
	if (a > b) return gcd(b, a);
	while (a != 0) {
		int tmp = b % a;
		b = a;
		a = tmp;
	}
	return b;
}

int main() {
	int k;
	cin >> k;
	int sum = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				int x = gcd(a, b);
				x = gcd(x, c);
				sum += x;
			}
		}
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3624
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<usize>();
    let ans = (1..n+1).fold(0,|y,x|{
        y + x
    });
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int solve(int x, int y, int z) {
	int ans;
	if (x % y) {
		ans = (x / y) * z + z;
	} else {
		ans = (x / y) * z;
	}
	return ans;
}
int main() {

	/*	int t;
		cin >> t;
		while (t--) { */

	int x1, y1, z1;
	cin >> x1 >> y1 >> z1;
	cout << solve(x1, y1, z1) << "\n";

	return 0;
}






Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;

  int a[n],b[m];
  for(int i=0;i<n;i++){
        cin>>a[i];  
    }
  for(int j=0;j<m;j++){
        cin>>b[j];  
    }
      
    bool flagw=true;
    int x1=x,y1=y;
    int z=x;
    while(x1<y1){
        z++;
        x1++;
    }

    int amax=*max_element(a,a+n);
    int bmin=*min_element(b,b+m);
    //Zの判定条件とまでは行ってなさそう
     //&&max_element(a,a+n)<min_element(b,b+m)
    for(int i=x+1;i<z;i++){
        if(amax<i&&i<=bmin){
            flagw=false;
            break;
        }
    }
         

    // for(int i=x;i<=y;i++){
        
    // }

    cout<<((flagw)?"War":"No War")<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("sse4.2")
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize ("unroll-loops")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define MP make_pair
#define sp(x) fixed<<setprecision(x)
#define pb push_back
#define die(x) return cout << x << endl, 0
#define fastio ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define file ifstream cin("input.txt"); ofstream cout("output.txt")
#define F first
#define S second
#define int long long
#define lc ind << 1
#define rc ind << 1 | 1
//thissss
const int MAXN = 100 * 1000 + 7, MOD = 1000 * 1000 * 1000 + 7;
int n, l, t, x[MAXN], a[MAXN];
bool w[MAXN];
int32_t main(){
    fastio;
	cin >> n >> l >> t;
	for(int i = 0; i < n; i ++){
		int W;
		cin >> x[i] >> W;
		w[i] = W - 1;
	}
	for(int i = 0; i < n; i ++){
		int z = 1;
		if(w[i]) z = -1;
		a[i] = (x[i] + z * t)%l + l;
		a[i] %= l;
		//cout << a[i] << ' ';
	}
	sort(a, a + n);
	int d = 0;
	for(int i = 0; i < n; i ++){
		if(!w[i]) d += (t - (l - x[i]) + l - 1)/l;
		else d -= (t - x[i] + l - 1)/l;
	}
	d = (d%n + n)%n;
	//cout << endl << d << endl;
	for(int i = 0; i < n; i ++){
		cout << a[(i + d)%n] << '\n';
	}
    return 0;

}


Measured memory_bytes: 5200
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let q = input::<usize>();
    let s = input::<String>().chars().collect::<Vec<char>>();
    let lr = (0..q)
        .map(|_| {
            let l = input();
            let r = input();
            (l, r)
        })
        .collect::<Vec<(usize, usize)>>();

    let sum = {
        let mut v = Vec::with_capacity(n);
        let mut cnt = 0;
        v.push(cnt);
        for i in 0..n - 1 {
            if s[i] == 'A' && s[i + 1] == 'C' {
                cnt += 1;
            }
            v.push(cnt);
        }
        v
    };

    for (l, r) in lr {
        let ans = sum[r - 1] - sum[l - 1];
        println!("{}", ans);
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cou = 0;
    for (int i=a; i<=b;i++){
        if (c%i==0){
            cou +=1;
        }
    }
    cout <<cou<<endl;
    return 0;
}


Measured memory_bytes: 3108
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n:usize,
        k:usize,
    }

    let mut sunukes = vec![0; n];

    for _ in 0..k {
        input! {
            d: usize,
            a: [usize; d],
        }
        for a_i in a {
            sunukes[a_i - 1] += 1;
        }
    }

    let ans = sunukes.iter().filter(|x| **x == 0).count();

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


Measured memory_bytes: 2212
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
temp = 10 ** 9
ans = 0
for i in range(N):
  if temp > abs(T - 0.006 * H[i] - A): 
    ans = i
    temp = abs(T - 0.006 * H[i] - A)
print(ans + 1)    

Measured memory_bytes: 38256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define VMAX 10000
int main(){
  int n,i,j;
  short *A,*B;
  int C[VMAX+1];
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for (i = 0;i<=VMAX;i++)
    C[i] = 0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  /* C[i] now contains the number of elements equal to i */
  for (i = 1;i<= VMAX;i++){
    C[i] = C[i]+C[i-1];
  }
  /* C[i] now contains the number of elements less than or equal to i */
  for (j = 1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 8460
N = int(input())
t, a = list(map(int, input().split())) # first time
# print("%d : %d"%(t, a))
for i in range(N-1):
    t_i, a_i = list(map(int, input().split()))
    mul = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
    t = mul * t_i
    a = mul * a_i
    # print("%d : %d"%(t, a))
print(int(t+a))

Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   vector<int>d(N);
   for(int k=0;k<N;k++){
       cin>>d[k];
   }
   sort(d.begin(),d.end());
   if(d[N/2-1]==d[N/2]){
       cout<<0;
   }else{
       cout<<d[N/2]-d[N/2-1];
   }
}

Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;

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

bool mp[1000][1000];
bool flag[1000][1000];

struct pr{
	int nx,ny,cnt;
};
int main(){
	int t,n;
	while(cin>>t>>n){
		if(t==0&&n==0)break;
		CLR(mp);CLR(flag);
		REP(i,n){
			int tx,ty;
			cin>>tx>>ty;
			tx+=300;ty+=300;
			mp[tx][ty]=true;
		}
		int sx,sy;
		cin>>sx>>sy;
		sx+=300;sy+=300;
		int sum=1;
		flag[sx][sy]=true;
		queue<pr>q;
		pr p;
		p.nx=sx;p.ny=sy;p.cnt=0;
		q.push(p);
		while(!q.empty()){
			pr pi=q.front();q.pop();
			int x=pi.nx;
			int y=pi.ny;
			int tt=pi.cnt;
			if(tt>=t)continue;
			REP(j,6)if(!flag[x+dx[j]][y+dy[j]]&&!mp[x+dx[j]][y+dy[j]]){
				flag[x+dx[j]][y+dy[j]]=true;
				sum++;
				pr p2;p2.nx=x+dx[j];p2.ny=y+dy[j];p2.cnt=tt+1;
				q.push(p2);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3176
using System;
using System.Collections.Generic;

namespace sumitb2019_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();

      var x = (int)Math.Ceiling(n / 1.08);
      
      if ((int)(x * 1.08) == n)
      {
        Console.WriteLine(x);
      }
      else
      {
        Console.WriteLine(":(");
      }
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }
  }
}

Measured memory_bytes: 13268
a = int(input())
n = list(range(1,a+1))
n = n[0::2]
#print(n)
ans = 0
arr = []
x = 1
count = 0
for i in n:
  count = 0
  for x in range(1,a+1):
    if  i % x ==0:
      count +=1
      #continue
  arr.append(count)    
    
    
print(arr.count(8))

Measured memory_bytes: 3064
import Data.Array.ST (STUArray, runSTUArray, newArray, writeArray, getBounds)
import Data.Array.Unboxed
import Data.Ix (range)
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type PosXY = (Int,Int) 
type Box = UArray PosXY Char
type STBox s = ST s (STUArray s PosXY Char)

readDigits = map read <$> words <$> getLine :: IO [Int]

mkBox :: Int -> Int -> Box
mkBox w h =
    let dirs = [(1,0), (0,1), (-1,0), (0,-1)] in
    runSTUArray $ do
        box <- newArray ((1,1),(w,h)) '.' :: STBox s 
        go box (1,1) dirs
    where
    go :: (STUArray s PosXY Char) -> PosXY -> [PosXY] -> STBox s 
    go box _ [] = return box
    go box xy dxdys@(dxy:nextdxys) = do
        rng <- getBounds box
        writeArray box xy '#' 
        let nxy = (\(x1,y1) (x2,y2) -> (x1+x2, y1+y2)) xy dxy
        if (inRange rng nxy) then
            go box nxy dxdys
        else
            go box xy nextdxys

main :: IO ()
main = 
    loop
    where
    loop = do
        [h,w] <- readDigits
        unless (h == 0 && w == 0) $ do
            let box = mkBox w h
            let ((sx,sy), (ex,ey)) = bounds box
            putStrLn $ unlines [[box!(x,y) | x<-[sx..ex]] | y<-[sy..ey]]
            loop

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	ull a, b, n;
	cin >> a >> b >> n;
	ull x = min(b-1, n);
	cout << (a*x)/b << "\n";
	return 0;
}



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

int main() {
    //
    string str;
    string ans;
    string kekka = "";
    bool chk = false;
    cin >> str >> ans;

    if (str.size() < ans.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    reverse(str.begin(), str.end());
    reverse(ans.begin(), ans.end());

    for (int i = 0; i <= str.size() - ans.size(); i++) {
        chk = false;
        for (int j = 0; j < ans.size(); j++) {
            // cout << i << "," << j << "==" << str.at(i + j) << ":" << ans.at(j) << endl;
            if (str.at(i + j) == ans.at(j) || str.at(i + j) == '?') {
                chk = true;
            } else {
                chk = false;
                break;
            }
        }

        if (chk == true) {
            if (i == 0) {
                // cout << ans;
                kekka += ans;
                for (int j = ans.size(); j < str.size(); j++) {
                    if (str.at(j) == '?') {
                        kekka += 'a';
                        // cout << 'a';
                    } else {
                        kekka += str.at(j);
                        // cout << str.at(j);
                    }
                }
            } else {
                for (int j = 0; j <= i - 1; j++) {
                    if (str.at(j) == '?') {
                        kekka += 'a';
                        // cout << 'a';
                    } else {
                        kekka += str.at(j);
                        // cout << str.at(j);
                    }
                }
                // cout << ans;
                kekka += ans;
                for (int j = i + ans.size(); j < str.size(); j++) {
                    if (str.at(j) == '?') {
                        kekka += 'a';
                        // cout << 'a';
                    } else {
                        kekka += str.at(j);
                        // cout << str.at(j);
                    }
                }
            }
            reverse(kekka.begin(), kekka.end());
            cout << kekka;
            cout << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
    //
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void){

long long int N;
long long int i, a, m, sum = 0;
scanf("%lld", &N);


for(i = 1; (i+1)*i+i<=N; i++){

    m = (N - i) / i;
    a = (N - i) % i;
    if(m>i && a == 0){
      sum += m;
    }

}


printf("%lld\n", sum);


return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
int pos = 0;

    rep(i,n){
        pos = a[pos];
        if(pos == 1){
            cout << i+1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

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

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] arr = sc.readArray(n);
        int cnt = 0;
        for(int i = 0; i <n; i = i + 2){
            if(arr[i] % 2 !=0){
               cnt++;
            }
        }
        System.out.println(cnt);
    }
}


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

int main(void){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;
        
        for(int j=0;j<W;j++){
            cout << '#';
        }
        cout << endl;
        
        for(int i=1;i<H-1;i++){
            cout << '#';
            for(int j=1;j<W-1;j++){
                cout << '.';
            }
            cout << '#' << endl;
        }
        for(int j=0;j<W;j++){
            cout << '#';
        }
        cout << endl << endl;
        }
    }


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define MAX_CITY 20
#define MAX_PRICE 1000
#define INF 100000
using namespace std;
int n, m;
int d[MAX_CITY+1][MAX_CITY+1];

void init() {
    for(int r = 1; r <= n; r++) {
        for(int c = 1; c <= n; c++) {
            d[r][c] = INF;
        }
    }
}

void warshall_floyd() {
    for(int via = 1; via <= n; via++) {
        for(int from = 1; from <= n; from++) {
            for(int to = 1; to <= n; to++) {
                d[from][to] = min(d[from][to], d[from][via] + d[via][to]);
            }
        }
    }
}

void print() {
    for(int r = 1; r <= n; r++) {
        for(int c = 1; c <= n; c++) {
            cout << d[r][c];
            if(c == n) putchar('\n');
            else putchar(' ');
        }
    }
}

int main(void) {
    memset(d, 0, sizeof(d));
    cin >> n >> m;
    init();
    for(int r = 0; r < m; r++) {
        int from, to, cost1, cost2;
        scanf("%d,%d,%d,%d", &from, &to, &cost1, &cost2);
        d[from][to] = cost1;
        d[to][from] = cost2;
    }
    warshall_floyd();
    int start, goal, salary, pole_cost;
    scanf("%d,%d,%d,%d", &start , &goal , &salary , &pole_cost);
    cout << (salary - (pole_cost + d[start][goal] + d[goal][start])) << endl;
    
    //print();
    
    return(0);
}

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

int main() {
  
  string S;
  cin >> S;
  
  string T;
  cin >> T;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      cout << "No" << endl;
      break;
    }
  }
  
  T.pop_back();
  if (S == T){
    cout << "Yes" <<endl;
  }
    
  
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(){
	int a, b, c, d, e, f, i;
	while(scanf("%d %d", &a, &b) != EOF){
		if(a <= b){
			c = a;
			d = b;
		}
		else{
			c = b;
			d = a;
		}
		e=d%c;
		while(e!=0){
			d=c;
			c=e;
			e=d%c;
		}
		e=c;
		f=1;
		if(a <= b){
			c = a;
			d = b;
		}
		else{
			c = b;
			d = a;
		}
		for(i=1;f!=0;i++){
			f=(d*i)%c;		
		}
	printf("%d %d\n", e, d*(i-1));
	}
	return 0;
}

Measured memory_bytes: 596
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

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

    let mut ans = 0;
    h.iter().fold(0, |highest, &h| {
        if h >= highest {
            ans += 1;
        }
        std::cmp::max(h, highest)
    });
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


map<pair<int,int>, int> mp;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        string s;
        cin >> s;
        int a = 0, b = 0, c = 0;
        for(int i = 0;  i < (int)s.length(); i++){
            if(s[i] == 'a') a++;
            else if(s[i] == 'b') b++;
            else c++;
        }

        int mn = min(a, min(b,c));
        a -= mn;
        b -= mn;
        c -= mn;
        if(a+b+c == 0 || a+b+c == 1){
            cout << "YES\n";
        }
        else if(a + b + c ==2 && a < 2 && b < 2 && c < 2){
            cout << "YES\n";
        }
        else cout << "NO\n";

    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N;
  cin>>N;
  map<ll,ll> m;
  for (int i(0);i<N;i++){
    ll a;
    cin>>a;
    m[a]++;
  }
  vector<pair<ll,ll>> p;
  for (auto mi:m){
    if (mi.second >= 2){
      p.push_back({mi.first,mi.second});
    }
  }
  sort(p.rbegin(),p.rend());
  ll maxi(0);
  for (int i(0);i<int(p.size());i++){
    if (p[i].second >= 4){
      maxi = p[i].first*p[i].first;
      break;
    }
  }
  if (int(p.size()) >= 2){
    cout << max(maxi,p[0].first * p[1].first) << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 6528
#include <iostream>
using namespace std; //stdのcout
class Dice
{
    int top;
    int front;
    int right;
    int left;
    int back;
    int bottom;

public:
    Dice(int top, int front, int right, int left, int back, int bottom);
    void turn_front(int f);
    void find_top(int t);
    void roll_char(char command);
    int get_right();
};
Dice ::Dice(int top, int front, int right, int left, int back, int bottom)
{
    this->top = top;
    this->front = front;
    this->right = right;
    this->left = left;
    this->back = back;
    this->bottom = bottom;
}
void Dice ::roll_char(char command)
{
    int tmp;
    switch (command)
    {
    case 'S':
        tmp = top;
        top = back;
        back = bottom;
        bottom = front;
        front = tmp;
        break;
    case 'N':
        tmp = top;
        top = front;
        front = bottom;
        bottom = back;
        back = tmp;
        break;
    case 'W':
        tmp = top;
        top = right;
        right = bottom;
        bottom = left;
        left = tmp;
        break;
    case 'E':
        tmp = top;
        top = left;
        left = bottom;
        bottom = right;
        right = tmp;
        break;
    }
}
void Dice ::turn_front(int f) //指定の面が正面に来るようにサイコロを設置する
{
    char command[] = "NENEN";
    int i = 0;
    while (top != f)
    {
        roll_char(*(command + i));
        i++;
    }
    roll_char('S');
}

void Dice ::find_top(int t) //d.topがtになるまで転がす
{
    while (top != t)
    {
        roll_char('E');
    }
}
int Dice ::get_right()
{
    return right;
}
int main(void)
{
    int top, front, right, left, back, bottom;
    cin >> top >> front >> right >> left >> back >> bottom;
    Dice d(top, front, right, left, back, bottom);
    int n;
    cin >> n;

    while (n)
    {
        int t, f;
        cin >> t >> f;
        d.turn_front(f); //d.frontがfになるようにサイコロを設置する
        d.find_top(t);   //d.topがtになるまで転がす
        cout << d.get_right() << endl;
        n--;
    }
}



Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAX(x,y) x=max(x,y)
#define MIN(x,y) x=min(x,y)
#define inf 0x3f3f3f3f
using namespace std;

const int N=400005;

int n,v,g[N*2],f[N*2],bin[25],tot,len[25],lef[25][N],rig[25][N],a[N],bel[N],p1[N],p2[N];
bool ans[N];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void dp()
{
	bin[0]=1;
	for (int i=1;i<=tot;i++) bin[i]=bin[i-1]*2;
	for (int i=0;i<bin[tot];i++) g[i]=n+1;
	for (int i=0;i<bin[tot];i++)
		for (int j=0;j<=tot;j++)
			if (!(i&bin[j])) MAX(f[i+bin[j]],rig[j][f[i]+1]),MIN(g[i+bin[j]],lef[j][g[i]-1]);
	for (int i=0;i<bin[tot];i++)
	{
		int l=f[i],r=g[i^(bin[tot]-1)];
		if (l+1>=r)
		{
			for (int j=1;j<=n;j++) ans[j]=1;
			return;
		}
		if (p1[bel[l+1]]<=l+1&&p2[bel[l+1]]>=r-1) ans[bel[l+1]]=1;
	}
}

int main()
{
	n=read();v=read();
	for (int i=1;i<=n;i++) a[i]=read();
	tot=0;len[0]=0;
	while (v) len[++tot]=v,v>>=1;
	sort(len,len+tot+1);
	memset(lef,inf,sizeof(lef));
	for (int i=0;i<tot;i++)
		for (int j=1;j<=n;j++)
		{
			int l=j;
			while (l<n&&a[l+1]-a[l]<=len[i]) l++;
			rig[i][j]=l;lef[i][l]=j;j=l;
		}
	int id=0;
	for (int j=1;j<=n;j++)
	{
		int l=j;bel[j]=++id;
		while (l<n&&a[l+1]-a[l]<=len[tot]) l++,bel[l]=id;
		p1[id]=j;p2[id]=l;j=l;
	}
	dp();
	for (int i=1;i<=n;i++) puts(ans[bel[i]]?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 80256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define is insert
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<char> vc;
typedef vector<vector<char>> vv;
//set<int, Comparator> S;
int main() {
    int K,X;
    cin >> K >> X;
    cout << ((500*K >= X )? "Yes" : "No") <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int adj[250][250];
int ans, rr[200];
void makeall(vector<int> v, int n, int d = 0)
{
	if (v.size() == n)
	{
		
	int a = 0;
   for (int i = 0; i < n-1; i++)
		{
		a += adj[v[i]][v[i+1]];
		
		
	}
	ans = min(ans, a);
	return;
}
	for (int i = 1; i <= n; i++)
	{
	if (!(d & (1 << i)))
		{
		v.push_back(rr[i]);
			//printf("%d\n", i);
		makeall(v, n, d | (1<< i));
			v.pop_back();
	}
}
}


int main()
{
	ans = 999999999;
	for (int i = 0; i < 250; i++)
	fill_n(adj[i], 250,  999999999);
	int x, n, r;
	scanf("%d%d%d", &n, &x, &r);
	for (int i = 0; i < r; i++)
	{
	scanf("%d", &rr[i+1]);
		//printf("%d", rr[i+1]);
}
	for (int i = 0; i < x; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		adj[a][b] = c;
		adj[b][a] = c;
	}
	for (int k = 0; k <= n; k++)
	{
	for (int i = 0; i <= n; i++)
		{
		for (int j = 0; j <= n; j++)
			{
			if (adj[i][j] > adj[i][k] + adj[k][j]) adj[i][j] = adj[i][k] + adj[k][j];
			//printf("%d %d %d\n", i, j, adj[i][j]);
		}
	}
    }
	vector<int> v;
	makeall(v, r);
	printf("%d", ans);
} 

Measured memory_bytes: 512
N = int(input())
A = list(map(int,input().split()))
S = [A[0]]+[0]*(N-1)
for i in range(1,N):
    S[i] = S[i-1] + A[i]
Ans = 10**10
for i in range(0,N-1):
    Ans = min(Ans,abs(S[N-1]-S[i]*2))
print(Ans)

Measured memory_bytes: 24824
/** AtCoder Beginner Contest 136, by Abreto<m@abreto.net> */
#include <bits/stdc++.h>

using namespace std;

namespace abreto {

void main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << max((C - (A - B)), 0) << '\n';
}

}

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>

using namespace std;

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

    bool ok = true;

    for(int i =n - 1; i > 0 ; i--){
        if(h[i] >= h[i - 1]){
            continue;
        } else if (h[i] == h[i - 1] - 1 ){
            h[i - 1] = h[i - 1] -1;
        }else{
            ok = false;
            break;
        }
    }

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

    return 0;
}


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

int main() {
  string s; cin >> s;
  
  int ans = 0;
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'R') count++;
    else {
      ans = max(ans, count);
      count = 0;
    }
  }
  
  ans = max(ans, count);
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ps push_back
#define LL long long
using namespace std;
const int maxn=2e5+5;
int a[maxn],b[maxn];
LL pre[maxn];

int main()
{
    int n, m, k, pos, len=0, ans=0;
    cin>>n>>m>>k;
    for(int i=0; i<n; i++){scanf("%d", &a[i]);if(i)pre[i]=pre[i-1]+a[i];else pre[i]=a[i];}
    LL sum=0;
    len=0;
    pos=lower_bound(pre, pre+n, k)-pre;
    if(pre[pos]==k)len+=pos+1;
    else len+=pos;
//    cout<<pos<<endl;
    ans=max(ans, len);
    for(int i=0; i<m; i++){
        scanf("%d", &b[i]);
        sum+=b[i];
        len=0;
        if(k-sum>=0)
        {
            len=i+1;
            pos=lower_bound(pre, pre+n, (long long)k-sum)-pre;
            if(pre[pos]==k-sum)len+=pos+1;
            else len+=pos;
        }
        ans=max(len, ans);
//        cout<<len<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6832
fn input_line() -> Vec<String> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).unwrap();
  return buf
    .split_whitespace()
    .map(|word| String::from(word))
    .collect();
}

fn main() {
  let inputs = input_line();
  let a: i64 = inputs[0].parse().unwrap();
  let mut b: i64 = inputs[1].parse().unwrap();
  let mut c: i64 = inputs[2].parse().unwrap();
  let inputs = input_line();
  let k: i64 = inputs[0].parse().unwrap();

  for _ in 0..k {
    if b <= a {
      b *= 2;
    } else {
      c *= 2;
    }
  }

  let ans = if a < b && b < c {
    "Yes"
  } else {
    "No"
  };

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

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

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

    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> e(n);
    for (ll i = 0; i < n; i++){
        cin >> e[i].first >> e[i].second;
    }

    sort(e.begin(), e.end());

    ll c = 0;
    ll ans = 0;

    for (ll i = 0; i < n; i++){
        if (c + e[i].second <= m){
            c += e[i].second;
            ans += e[i].first * e[i].second;
        }
        else{
            ans += e[i].first * (m-c);
            break;
        }
    }

    cout << ans << endl;
    
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 3000 + 7;

int n;
string s;

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	static char buf[N];
	scanf("%s", buf);
	s = buf;
	return true;
}

int dp[N][N];
int sum[N][N];

int add(int a, int b){
	a += b;
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

void solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	forn(i, n)
		sum[0][i + 1] = 1;
	forn(i, n - 1) forn(j, i + 2){
		if (s[i] == '<')
			dp[i + 1][j] = sum[i][j];
		else
			dp[i + 1][j] = add(sum[i][i + 1], -sum[i][j]);
		sum[i + 1][j + 1] = add(sum[i + 1][j], dp[i + 1][j]);
	}
	
	printf("%d\n", sum[n - 1][n]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 69632