akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		String s = sc.next();

		out.println(s.replaceFirst("7", "8"));
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

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

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,m,n) for(int i=m;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

int main(){
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3632
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    A, B = MI()
    print(int(math.ceil(A / B)))


if __name__ == '__main__':
    main()


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

vector<P> decomp;
vector<int> divs;


void f(int i, int cv=1) {
	if (i == decomp.size()) {
		divs.push_back(cv);
		return;
	}
	int d, num;
	tie(d, num) = decomp[i];
	rep(j, num + 1) {
		f(i + 1, cv);
		cv *= d;
	}
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int tot = 0;
	rep(i, n) {
		cin >> a[i];
		tot += a[i];
	}
	for(int i = 2; i < 25000; i++) {
		int cnt = 0;
		while(tot % i == 0) {
			tot /= i;
			cnt++;
		}
		if (cnt) decomp.emplace_back(i, cnt);
	}
	if (tot != 1) decomp.emplace_back(tot, 1);
	f(0);
	sort(divs.begin(), divs.end());
	for(int i = divs.size() - 1; i >= 0; i--) {
		int d = divs[i];
		sort(a.begin(), a.end(),
			[&](int ai, int aj) {return ai % d < aj % d;});
		int t = k;
		int p = 0;
		while(p < a.size() && t >= a[p] % d) {
			t -= a[p] % d;
			p++;
		}
		t = k - t;
		while(p < a.size() && t >= d - a[p] % d) {
			t -= d - a[p] % d;
			p++;
		}
		if (p == a.size()) {
			cout << divs[i] << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
fn main() {
    let mut buf= String::new();
    std::io::stdin().read_line(&mut buf).ok();
    
    let mut line_itr = buf.split_whitespace();
    let a: u8 = line_itr.next().unwrap().parse().unwrap();
    let b: u16 = line_itr.next().unwrap().parse().unwrap();
    
    println!("{}",
        if a > 12 {
            b
        } else if a > 5 {
            b / 2
        } else {
            0
        }
    )
    
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> PII;
int main() {
  int N, M; cin >> N >> M;
  vector<PII> vec(M);
  for(int i=0; i<M; i++) {
    int a, b; cin >> a >> b;
    vec[i] = make_pair(a, b);
  }
  
  int lim_a = 1;
  int ans = 0;
  int const size = vec.size();
  int ok = 0;
  for(int i=0; i<size; i++) {
    int mx = 0;
    for(int j=0; j<size; j++) {
      if(vec[j].first <= lim_a) {
	if(mx <= vec[j].second && lim_a <= vec[j].second) {
	  mx = vec[j].second;
	}
      }
    }
    ans ++;
    if(mx>=N) {
      ok = 1;
      break;
    }
    lim_a = mx+1;
  }
  
  if(ok) { cout << ans << endl; }
  else   { cout << "Impossible" << endl; }
  
  return 0;
}

Measured memory_bytes: 1200
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func calc(n int) string {
	if n == 0 {
		return "0"
	}

	r := ""
	k := 1
	for n != 0 {
		if (n & 1) == 1 {
			n -= k
			r = "1" + r
		} else {
			r = "0" + r
		}
		n >>= 1
		k = -k
	}

	return r
}

func main() {
	n := loadint()
	fmt.Println(calc(n))
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int nA, nB, nC, K;
ll as[1010];
ll bs[1010];
ll cs[1010];
int main(void) {
  scanf("%d%d%d%d", &nA, &nB, &nC, &K);
  REP(i, nA) {
    scanf("%lld", &as[i]);
  }
  REP(i, nB) {
    scanf("%lld", &bs[i]);
  }
  REP(i, nC) {
    scanf("%lld", &cs[i]);
  }
  priority_queue<ll, vector<ll>, greater<ll> > q;
  REP(i, nA) REP(j, nB) {
    q.push(as[i] + bs[j]);
    if((int)q.size() > K) {
      q.pop();
    }
  }

  vector<ll> ds;
  while(!q.empty()) {
    ds.push_back(q.top()); q.pop();
  }

  REP(i, ds.size()) REP(j, nC) {
    q.push(ds[i] + cs[j]);
    if((int)q.size() > K) {
      q.pop();
    }
  }

  vector<ll> es;
  while(!q.empty()) {
    es.push_back(q.top()); q.pop();
  }
  reverse(es.begin(), es.end());
  REP(i, K) {
    printf("%lld\n", es[i]);
  }
  
  return 0;
}


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

int main(){
    
    int S;
    int h,m,s;
    
    cin >> S;  
    h = S / 3600;
    s = S % 3600;
    m = s / 60;
    s = s % 60;
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}

Measured memory_bytes: 1164
import sys
input = sys.stdin.readline

n, t = [int(x) for x in input().split()]
ab = []
for _ in range(n):
    ab.append([int(x) for x in input().split()])
ab_rev = ab[::-1]

dp1 = [[0] * t for _ in range(n + 1)] # 前から見た
dp2 = [[0] * t for _ in range(n + 1)] # 後ろから見た

for i in range(1, n + 1):
    a, b = ab[i - 1]
    for j in range(t):
        if j - a >= 0:
            dp1[i][j] = max(dp1[i - 1][j - a] + b, dp1[i - 1][j])
        else:
            dp1[i][j] = dp1[i - 1][j]

for i in range(1, n + 1):
    a, b = ab_rev[i - 1]
    for j in range(t):
        if j - a >= 0:
            dp2[i][j] = max(dp2[i - 1][j - a] + b, dp2[i - 1][j])
        else:
            dp2[i][j] = dp2[i - 1][j]

ans = -1

for i in range(1, n + 1):
    for j in range(t):
        ans = max(ans, dp1[i - 1][j] + dp2[n - i][t - 1 - j] + ab[i - 1][1])

print(ans)

Measured memory_bytes: 177928
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
cur = 0
for a in A:
    if a == cur + 1:
        cur += 1

print(N-cur if cur > 0 else -1)
# 54

Measured memory_bytes: 26140
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  int ret = 0;
  while (n--) {
    int x, y;
    scanf("%d%d", &x, &y);
    ret += y - x + 1;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[20]={},x[20][20]={},y[20][20]={},ans=0,f;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    for(int j=0; j<a[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  for(int i=0; i<(1<<n); i++) {
    f=1;
    for(int j=0; j<n; j++) {
      if(i&(1<<j)) {
        for(int k=0; k<a[j]; k++) {
          if(!y[j][k]&&i&(1<<x[j][k]-1)) {
            f=0;
          }
          if(y[j][k]&&!(i&(1<<x[j][k]-1))) {
            f=0;
          }
        }
      }
    }
    if(f) {
      ans=max(ans,__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    int x;
    cin>>x;
    int d, s;
    d = x / 500;
    s = (x - d * 500) / 5;
    cout << d * 1000 + s * 5;
    return 0;
}

Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let m, s = Array.fold_left max 0 ls, Array.fold_left (+) 0 ls
let _ = print_endline @@ if 2 * m < s then "Yes" else "No"

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b>=c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

vector<int> solve(int N, vector<ll>& xs)
{
    vector<int> ans;

    for (int i = N; i > 0; --i)
    {
        if (2 * i > N)
        {
            if (xs[i])
                ans.push_back(i);

            continue;
        }

        int v = 0;

        for (int j = 2*i; j <= N; j += i)
            v = (v + xs[j]) % 2;

        if (v != xs[i])
        {
            ans.push_back(i);
            xs[i] = 1;
        } else
            xs[i] = 0;
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> xs(N + 1);

    for (int i = 1; i <= N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans.size() << endl;

    for (auto x : ans)
        cout << x << '\n';

    return 0;
}


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

int gc,n,x[100005];

int main(){
	gc = 0;
	scanf("%d%d",&n,&x[0]);
	for(int i =1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	sort(x,x+n+1);
	for(int i =1;i<=n;i++){
		gc = __gcd(gc,x[i]-x[i-1]);
	}
	printf("%d\n",gc);
	return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;

int ans[N];
vector <int> adl[N];
int n, q;

int lazy[N];

void dfs(int node, int p){
    ans[node] = lazy[node];
    for (auto child : adl[node]){
        if (child == p) continue;
        lazy[child] += lazy[node];
        dfs(child, node);
    }
}

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

    cin >> n >> q;
    for (int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        adl[a].pb(b);
        adl[b].pb(a);
    }

    while (q--){
        int node, val;
        cin >> node >> val;
        lazy[node] += val;
    }

    dfs(1, 1);
    for (int i=1;i<=n;i++){
        cout << ans[i] << " ";
    }
    cout << el;

    return 0;
}

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

int main() {
  int n,ct=1000;
  cin >> n;
  for(;n>0;n--){
    int a,ctt=0;
    cin >>a;
    while(a == (a/2)*2){
      ctt++;
      a /=2;
    }
    if(ctt < ct){
      ct= ctt;
    }
  }
  cout << ct;
}


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

int n;
vector<vector <int> > c(9,vector<int>(9));

int main(){
  cin >> n;
  for(int i=1;i<=n;i++){
    int x = i % 10;
    int tmp = i;
    while(tmp/10!=0){
      tmp/=10;
    }
    int y = tmp%10;
    if(y!=0 && x!=0) c[y-1][x-1]++;
  }
  int res=0;
  for(int i=0;i<9;i++){
    for(int j=0;j<9;j++){
      res+=c[i][j]*c[j][i];
    }
  }
  cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e, e--;

    int res = 0;
    rep(i, n){
        if(a[i] == i) res++, i++;
    }
    cout << res << endl;

    return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n; cin>>n;
  
  cout<<pow(n,3)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

void solve() {
	int n, k;
	cin >> n >> k;

	vector<int> x(n), y(n);
	vector<int> xary, yary;

	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
		xary.push_back(x[i]);
		yary.push_back(y[i]);
	}

	sort(xary.begin(), xary.end());
	sort(yary.begin(), yary.end());

	ll ans = 1LL * (xary[n - 1] - xary[0]) * (yary[n - 1] - yary[0]);	//n個含まれている最小の長方形

	for (int xi = 0; xi < n; ++xi) {
		for (int xj = xi + 1; xj < n; ++xj) {
			for (int yi = 0; yi < n; ++yi) {
				for (int yj = yi + 1; yj < n; ++yj) {

					int num = 0;
					ll lx = xary[xi], rx = xary[xj];
					ll by = yary[yi], uy = yary[yj];

					for (int i = 0; i < n; i++) {
						if (lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy) {
							num++;
						}
					}

					if (num >= k) ans = min(ans, 1LL * (rx - lx)*(uy - by));
				}
			}
		}
	}

	cout << ans << endl;

}

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

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    //int ntest; cin >> ntest; while(ntest--)
    {
        int n,m; cin >> n >> m;
        vector<int> h(n);
        fori(i,n) {
            cin >> h[i];
        }
        vector<vector<int>> edges(n);
        fori(i,m) {
            int a,b; cin >> a >> b;
            a--; b--;
            edges[a].pb(b);
            edges[b].pb(a);
        }

        int ans = 0;
        fori(u,n) {
            int b = 1;
            for(int v: edges[u]) {
                b &= h[v] < h[u];
            }
            ans += b;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 8676
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main() {   
    int n, m,x,y; cin >> n >> m;
    vector<int> p(n);
    UnionFind tree(n);
    rep(i,n)cin >>p[i];
    rep(i,m){
      cin >> x>>y;x--;y--;
      tree.unite(x,y);
    }int ans = 0;
  rep(i,n){
    if(tree.same(i,p[i]-1))ans++; 
  }cout << ans << endl;
}

Measured memory_bytes: 4024
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N, A, B, C, D;
char S[212345];

int main() {

	scanf("%d%d%d%d%d%s", &N, &A, &B, &C, &D, S);

	if ((A < C && C < B && B < D) ||
		(A < B && B < C && C < D)) {

		for (int i = B - 1; i < D; ++i) {
			if (S[i] == '#' && S[i + 1] == '#') {
				printf("No\n");
				return 0;
			}
		}
		for (int i = A - 1; i < C; ++i) {
			if (S[i] == '#' && S[i + 1] == '#') {
				printf("No\n");
				return 0;
			}
		}

		printf("Yes\n");
	}
	else {
		bool f = false;
		for (int i = B - 1; i < D; ++i) {
			if (S[i] == '#' && S[i + 1] == '#') {
				printf("No\n");
				return 0;
			}
			if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
				f = true;
			}
		}
		if (f) {
			for (int i = A - 1; i < C; ++i) {
				if (S[i] == '#' && S[i + 1] == '#') {
					printf("No\n");
					return 0;
				}
			}

			printf("Yes\n");
		}
		else {
			printf("No\n");
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int n;
  cin >> n;

  ll res = 1;
  for (int i = 1; i <= n; ++i) {
    res *= i;
    res %= 1000000007;
  }
  cout << res << "\n";
}


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

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int c = scanner.nextInt();
			if ((n | c) == 0)
				break;
			int[] a = new int[n];
			int[] b = new int[c];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < 16; j++)
					a[i] |= (scanner.nextInt() << j);
			for (int i = 0; i < c; i++)
				for (int j = 0; j < 16; j++)
					b[i] |= (scanner.nextInt() << j);
			int[][] dp = new int[2][1 << 16];
			Arrays.fill(dp[0], -1);
			dp[0][0] = 0;
			int X = 1;
			for (int i = 0; i < n; i++, X = 1 - X) {
				Arrays.fill(dp[X], -1);
				for (int S = 0; S < 1 << 16; S++) {
					if (dp[1 - X][S] == -1)
						continue;
					int light = S | a[i];
					for (int j = 0; j < c; j++) {
						int pushed = light & b[j];
						int point = Integer.bitCount(pushed);
						int nx = light & ~b[j];
						if (dp[X][nx] < point + dp[1 - X][S])
							dp[X][nx] = point + dp[1 - X][S];
					}
				}
			}
			int max = 0;
			for (int i = 0; i < 1 << 16; i++)
				max = Math.max(max, dp[1 - X][i]);
			System.out.println(max);

		}
	}
}

Measured memory_bytes: 43784
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [[0]*10 for i in range(10)]

for i in range(1, n+1):
    if i % 10 != 0:
        a[int(str(i)[0])][int(str(i)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += a[i][j]*a[j][i]

print(ans)

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


int main(){
    int N;cin >> N;
    vector<int> a(3,0);
    for (int i = 0; i < N; i++) {
        int x;cin >> x;
        a[x-1]++;
    }
    double dp[N+2][N+2][N+2];
    for (int i = 0; i < N+2; i++) {
        for (int j = 0; j < N+2; j++) {
            for (int k = 0; k < N+2; k++) {
                dp[i][j][k]=0.0;
            }
        }
    }
    for (int k = 0; k <= N; k++) {
        for (int j = 0; j <= N; j++) {
            for (int i = 0; i <= N; i++) {
                if(i==0&&j==0&&k==0) continue;
                double sum=i+j+k;
                double t=0.0;
                if(j>0) t+=dp[i+1][j-1][k]*j;
                if(k>0) t+=dp[i][j+1][k-1]*k;
                if(i>0) t+=dp[i-1][j][k]*i;
                dp[i][j][k]=(t+N)/sum;
            }
        }
    }
    cout << setprecision(10) << fixed << dp[a[0]][a[1]][a[2]] << endl;
    return 0;
}



Measured memory_bytes: 215424
#include <iostream>
#include <vector>
using namespace std;
long long mod = 1000000007ll;
int main() {
  int n; 
  cin >> n;
  vector<long long> a(n), cumsum(n);
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    a.at(i) = ai;
    if (i == 0) {
      cumsum.at(i) = ai;
    } else {
      cumsum.at(i) = cumsum.at(i-1) + ai;
    }
    cumsum.at(i) %= mod;
    
  }

  long long ans = 0;

  for (int i = 0; i < n-1; ++i) {
    ans += cumsum.at(i) * a.at(i+1);
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r',
                's','t','u','v','w','x','y','z'};
  map<char, int> cnt;
  for(int i = 0; i < s.length(); i++) cnt[s[i]]++;
  for(int i = 0; i < 26; i++){
    if(cnt[a[i]] == 0){
      cout << a[i] << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}
    

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(r);
    int ans = pow(r, 2);
    co(ans);
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b, c, d = [int(_) for _ in input().split()]

    if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    string S;
    cin >> S;
    string ans;
    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else ans = "Sunny";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d);

	return 0;
}



Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int n = Input.nextInt();
        int h = Input.nextInt();
        int[] a = new int[n], b = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = Input.nextInt();
            b[i] = Input.nextInt();
        }
        Array.Sort(a);
        Array.Sort(b);
        int ans = 0;
        for (int i = 0; i < n && b[n - 1 - i] > a[n - 1]; i++)
        {
            h -= b[n - 1 - i];
            ans++;
            if (h <= 0)
            {
                Console.WriteLine(ans);
                return;
            }
        }
        Console.WriteLine(ans + (h - 1) / a[n - 1] + 1);



    }

}


class Input
{
    static string[] line = { };
    static int index = 0;
    static void readLine()
    {
        line = Console.ReadLine().Split(' ');
        index = 0;
    }
    public static int nextInt()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return int.Parse(line[index - 1]);
    }
    public static long nextLong()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return long.Parse(line[index - 1]);
    }
    public static string next()
    {
        if (index == line.Length)
        {

            readLine();
        }
        index++;
        return line[index - 1];
    }
}




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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , w;
	cin >> n >> w;
	
	vector<pii> v(n);
	for(auto& el : v)
		cin >> el.fi >> el.se;
		
	vector<vector<ll>> dp(n , vector<ll>(w + 1));
	rep(i , n)
	{
		rep(j , w + 1)
		{
			if(j >= v[i].fi) 
				dp[i][j] = v[i].se;
			if(j > 0) 
				dp[i][j] = max(dp[i][j] , dp[i][j - 1]);
			if(i > 0) 
				dp[i][j] = max(dp[i][j] , dp[i - 1][j]);
			if(i > 0 && j - v[i].fi >= 0) 
				dp[i][j] = max(dp[i][j] , dp[i - 1][j - v[i].fi] + v[i].se);
		}
	}
	
	cout << dp[n - 1][w];

	return 0;
}

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

struct Job {
	int work;
	int deadline;
	friend istream& operator>>(istream& in, Job& x) { return in >> x.work >> x.deadline; }
};

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto jobs = loadMany<Job>(n);
	sort(jobs.begin(), jobs.end(), [&](const Job& j1, const Job& j2){ return j1.deadline < j2.deadline; });
	auto t = 0;
	auto good = true;
	for (auto job : jobs) {
		if (t + job.work > job.deadline)
			good = false;
		t += job.work;
	}
	cout << (good ? "Yes\n" : "No\n");
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint A, B, C, K;
    cin >> A >> B >> C >> K;
    lint ans = min(A, K);
    K -= A;
    if(K > 0) K -= B;
    if(K > 0) {
        ans -= min(C, K);
        K -= C;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
from collections import deque
from itertools import product


def bfs(x, y):
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([(x,y)])

    while len(que) > 0:
        x, y = que.popleft()
        near_a = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        num = product([-2, -1, 0, 1, 2], repeat=2)
        near_b = [(x + dx, y + dy) for dx, dy in num]

        for cnt, l in enumerate((near_a, near_b)):
            for i, j in l:
                if (0 <= i < w and 0 <= j < h and
                        dist[j][i] > dist[y][x] + cnt and s[j][i] == '.'):
                    dist[j][i] = dist[y][x] + cnt
                    if cnt == 0:
                        que.appendleft((i, j))
                    elif cnt == 1:
                        que.append((i, j))
    return dist


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

ans = bfs(Cw - 1, Ch - 1)[Dh - 1][Dw - 1]
print(-1 if ans == 10 ** 9 else ans)


Measured memory_bytes: 99728
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
S = str(input())

ans = 0
for i in range(1, N) :
  X = S[:i]
  Y = S[i:]
  #print ("X: " + X)
  #print ("Y: " + Y)
  Xlist = []
  Ylist = []
  cnt = 0
  for x in range(len(X)) :
    if X[x] not in Xlist :
      Xlist.append(X[x])
  for y in range(len(Y)) :
    if Y[y] not in Ylist :
      Ylist.append(Y[y])
  
  for xl in range(len(Xlist)) :
    if Xlist[xl] in Ylist :
      cnt += 1
  ans = max(ans, cnt)
  
print (ans)
  
  
  

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

using namespace std;

int main(){
  int n,z,w; cin >> n >> z >> w;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  if(n==1) cout << abs(w-a[0]) << endl;
  else cout << max(abs(w-a[n-1]),abs(a[n-1]-a[n-2])) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    a += b + c;
    if (a >= 22) cout << "bust";
    else cout << "win";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main() {
  ll r;
  cin>>r;
  string ans;
  if(r<1200)ans="ABC";
  else if(r<2800)ans="ARC";
  else ans="AGC";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int A;
  
  int B;
  
  int C;
  
  cin >> A >> B >> C;
 
  if(A == B || B == C || A == C){
    if(!(A == B) || !(B == C) || !(A == C)){
       cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int ans=t.size(),n=t.size(),count=0,n1=s.size();
  for(int i=0;i<=n1-n;i++)
  {
      int ind=i;
      count=0;
      for(int j=0;j<n;j++)
      {
        if(s[i]==t[j])
        {
           count++;
        }
        i++;
      }
      ans=min(n-count,ans);
      i=ind;
  }
  cout<<ans<<endl;
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string S; cin >> S;
    REP(i,S.size()){
        if(i%2){
            if(S[i]=='L'||S[i]=='U'||S[i]=='D') continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(S[i]=='R'||S[i]=='U'||S[i]=='D') continue;
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int all(int a[],int key,int now,int end,int sum)
{
	int x;
	if(sum==key) return 1;
	if(now == end) return 0;
	else
	{
		x=all(a,key,now+1,end,sum+a[now])||all(a,key,now+1,end,sum);
	}
	return x==1;
}


int main()
{
	int n,q,i;
	int a[21],b[201];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&b[i]);
		if( all(a,b[i],0,n,0) ) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <cstdio>

int main(void){
	int n;
	long a, max=-1000000, min=1000000, sum=0;

	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		scanf(" %ld", &a);
		if(a>max) max = a;
		if(a<min) min = a;
		sum+=a;
	}

	printf("%ld %ld %ld\n", min, max, sum);

	return 0;
}

Measured memory_bytes: 1028
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] stones = new int[N];
        for (int i = 0; i < N; i++) {
            stones[i] = sc.nextInt();
        }
        int[] cost = new int[N];
        cost[0] = 0;
        cost[1] = Math.abs(stones[1] - stones[0]);
        for (int i = 2; i < N; i++) {
            int cost1 = Math.abs(stones[i] - stones[i-1]) + cost[i-1];
            int cost2 = Math.abs(stones[i] - stones[i-2]) + cost[i-2];
            cost[i] = Math.min(cost1, cost2);
        }
        System.out.println(cost[N-1]);
    }
}

Measured memory_bytes: 51044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int count = 1;
  int cl = 0, cr = 1;
  int child[100000] = {};
  int l = 0, r = 0;

  FOR(i, 1, s.length())
  {
    if (s[i] != s[i - 1])
    {
      if (s[i] == 'L')
      {
        cr = count;
        r = i;
        l = i - 1;
      }
      else
      {
        cl = count;
        if ((cr + cl) % 2 == 0)
        {
          child[r] = (cr + cl) / 2;
          child[l] = (cr + cl) / 2;
        }
        else
        {
          int po = (cr + cl) / 2;
          child[r] = po;
          child[l] = po;
          if (max(cr, cl) % 2 == 0)
          {
            if (cr < cl)
            {
              child[l]++;
            }
            else
            {
              child[r]++;
            }
          }
          else
          {
            if (cr < cl)
            {
              child[r]++;
            }
            else
            {
              child[l]++;
            }
          }
        }
      }
      count = 1;
    }
    else
    {
      count++;
    }
  }

  cl = count;
  if ((cr + cl) % 2 == 0)
  {
    child[r] = (cr + cl) / 2;
    child[l] = (cr + cl) / 2;
  }
  else
  {
    int po = (cr + cl) / 2;
    child[r] = po;
    child[l] = po;
    if (max(cr, cl) % 2 == 0)
    {
      if (cr < cl)
      {
        child[l]++;
      }
      else
      {
        child[r]++;
      }
    }
    else
    {
      if (cr < cl)
      {
        child[r]++;
      }
      else
      {
        child[l]++;
      }
    }
  }

  REP(i, s.length())
  {
    cout << child[i];
    if (i != s.length() - 1)
    {
      cout << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArrayDec(n);

			long ans = 0;
			for (long l : a) {
				ans += l;
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

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

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21716