akhauriyash/Code-Regression huggingface dataset:
INF = 100000000000000

def ev1(s):
    ans = 0
    try:
        ans = eval(s)
        if ans == (): raise Exception
        if len(s)==0: raise Exception
    except:
        ans = -INF
    return ans

def ev2(s):
    ans = 0
    try:
        ans = eval(s)
        if ans == (): raise Exception
        if len(s)==0: raise Exception
    except:
        ans = INF
    return ans

def ggg(s):
    if ev1(s)==-INF:
        return -INF
    n = len(s)
    ans = INF
    D10 = [str(x) for x in range(10)]
    D9 = [str(x) for x in range(1,10)]
    OP = ['*', '+', '-', '&', '^', '|']
    for i in range(n):
        for d in D10:
            if s[i] in D10:
                t = s[0:i] + d + s[i:]
                nxt = ev2(t)
                if nxt < ans: ans = nxt
        for d in D10:
            if s[i] in D10:
                t = s[0:i+1] + d + s[i+1:]
                nxt = ev2(t)
                if nxt < ans: ans = nxt
        for c in OP:
            if i<n-1 and (s[i] in D10) and (s[i+1] in D9):
                t = s[0:i+1] + c + s[i+1:]
                nxt = ev2(t)
                if nxt < ans: ans = nxt
        if (s[i] in D10 and ((i>0 and s[i-1] in D10) or (i<n-1 and s[i+1] in D9))) or (s[i] in OP and i>0 and i<n-1 and s[i-1] in D10 and s[i+1] in D10):
            t = s[0:i] + s[i+1:]
            nxt = ev2(t)
            if nxt < ans: ans = nxt
    return ans

while True:
    s = input().split()
    N = int(s[0])
    s = s[1]
    if N==0:
        break
    n = len(s)
    ans = -INF
    D10 = [str(x) for x in range(10)]
    D9 = [str(x) for x in range(1,10)]
    OP = ['*', '+', '-', '&', '^', '|']
    fff = ev1
    if N%2==0: fff = ggg
    for i in range(n):
        for d in D10:
            if s[i] in D10:
                t = s[0:i] + d + s[i:]
                nxt = fff(t)
                if nxt > ans: ans = nxt
        for d in D10:
            if s[i] in D10:
                t = s[0:i+1] + d + s[i+1:]
                nxt = fff(t)
                if nxt > ans: ans = nxt
        for c in OP:
            if i<n-1 and (s[i] in D10) and (s[i+1] in D9):
                t = s[0:i+1] + c + s[i+1:]
                nxt = fff(t)
                if nxt > ans: ans = nxt
        if (s[i] in D10 and ((i>0 and s[i-1] in D10) or (i<n-1 and s[i+1] in D9))) or (s[i] in OP and i>0 and i<n-1 and s[i-1] in D10 and s[i+1] in D10):
            t = s[0:i] + s[i+1:]
            nxt = fff(t)
            if nxt > ans: ans = nxt
    print(ans)


Measured memory_bytes: 5740
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
using namespace std;

struct data{ int x, y, count; };

const int INF = 10000000;

int w, h, n;
int sx, sy;
int gx, gy;
int vx[] = { 1, 0, -1, 0, };
int vy[] = { 0, 1, 0, -1, };
char field[1001][1001];
int d[1001][1001][11];

int bfs(){

    queue<data> que;

    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            for (int k = 0; k <= n + 1; k++) d[j][i][k] = INF;

    que.push({ sx, sy, 1 });
    d[sx][sy][1] = 0;
    field[sx][sy] = '.';

    while (que.size()){

        data p = que.front(); que.pop();

        if (p.count == n + 1) break;

        for (int i = 0; i < 4; i++){

            int nx = p.x + vx[i], ny = p.y + vy[i], c = p.count;

            if (0 < nx && nx < w + 1 && 0 < ny && ny < h + 1 && field[nx][ny] != 'X'
                && d[nx][ny][c] == INF){

                if (field[nx][ny] != '.' && c == field[nx][ny] - '0'){
                    que.push({ nx, ny, c + 1 });
                    d[nx][ny][c] = d[nx][ny][c + 1] = d[p.x][p.y][c] + 1;
                    continue;
                }

                que.push({ nx, ny, c });
                d[nx][ny][c] = d[p.x][p.y][c] + 1;

            }
        }

    }

    return d[gx][gy][n];
}

int main(void){

    cin >> h >> w >> n;

    for (int i = 1; i <= h; i++){
        for (int j = 1; j <= w; j++){
            cin >> field[j][i];
            if (field[j][i] == 'S'){
                sx = j; sy = i;
            }
            else if (n == field[j][i] - '0'){
                gx = j; gy = i;
            }
        }
    }

    int ans = bfs();

    cout << ans << endl;

}

Measured memory_bytes: 47012
N = int(input())
K = int(input())

# 桁DP
# 1の位がどの数値かで分岐させていく
#
# 例、F(314, 2)
# 1桁目が0だったらF(31, 2)を合計値に追加
# 1桁目が1~4だったらF(31, 1)を合計値に追加
# 1桁目が5~9だったらF(30, 1)を合計値に追加
# これを再帰させて繰り返していく
# 10以下だったらK==0なら1(10だけ)、K==1ならN個

from functools import lru_cache
@lru_cache(maxsize=None)
def F(N, K):
    assert N >= 0
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    # 1の位が0でないときはKを1つ減らして再帰させて追加。Kが1以上でないとできない
    if K >= 1:
        # 10の位以上がそのまま残せるパターン、余りの個数分ある
        ret += F(q, K-1) * r
        # 10の位以上の数を1つ減らすパターン、9 - 余りの個数分ある
        ret += F(q-1, K-1) * (9-r)
    # 1の位が0のときはKそのままで再帰させて追加
    ret += F(q, K)
    return ret

print(F(N, K))


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, Q;
vector<int> G[100000];

bool M[100000];
int par[100000];
int U[100000], R[100000];

int find(int x) {
  if (U[x] == x) return x;
  return U[x] = find(U[x]);
}

void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  //if (R[x] < R[y]) swap(x, y);
  U[y] = x;
  R[x] += R[y];
  R[y] = 0;
}

bool same(int x, int y) {
  return find(x) == find(y);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> N >> Q) {
    if (N == 0 && Q == 0) break;
    rep(i, N) {
      G[i].clear();
      M[i] = false;
    }
    for (int i=0; i<N; i++) U[i] = i, R[i] = 1;
    rep(i, N-1) {
      int p;
      cin >> p;
      p--;
      G[p].pb(i+1);
      par[i+1] = p;
    }
    M[0] = true;
    vector<P> qs;
    rep(i, Q) {
      char c; int v;
      cin >> c >> v;
      v--;
      if (c == 'M') {
        if (M[v]) continue;
        M[v] = true;
        qs.pb(P(0, v));
      }
      else {
        qs.pb(P(1, v));
      }
    }
    rep(x, N) {
      for (int t : G[x]) {
        if (M[t]) continue;
        unite(x, t);
      }
    }
    long long ans = 0;
    reverse(all(qs));
    for (P &p : qs) {
      if (p._1 == 0) {
        // unmark
        unite(par[p._2], p._2);
      }
      else {
        ans += find(p._2)+1;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 11520
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

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

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from math import atan2, degrees

def solve():
    a, b, x = MI()

    s = x / a

    if a * b == 2 * s:
        theta = 45
    elif a * b < 2 * s: # 半分より多い
        h = 2 * (a * b - s) / a
        theta = degrees(atan2(h, a))
    else:               # 半分より少ない
        w = 2 * s / b
        theta = degrees(atan2(b, w))
    print(theta)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

ll mypow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

void solve() {
  ll n; cin >> n;
  map<ll, ll> map;
  rep(i, n) {
    ll a; cin >> a;
    if (map.find(a) == map.end()) map.insert(make_pair(a, 1));
    else map[a]++;
  }
  priority_queue<P> pq;
  for (auto it = map.begin(); it != map.end(); it++)
    if (it->second >= 2) pq.push(make_pair(it->first, it->second));
  
  ll ans = -1;
  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    ll f = p.first;
    ll s = p.second;
    if (s >= 4) {
      if (ans == -1) outl(mypow(f, 2));
      else outl(ans * f);
      return;
    } else if (s >= 2) {
      if (ans == -1) ans = f;
      else {
        outl(ans * f);
        return;
      }
    }
  }
  outl(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;  
  for(int i = 0; i < (int)s.size(); i+=2){
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 3688
n, m = gets.split.map(&:to_i)
edges = m.times.map { gets.split.map(&:to_i) }
ans = 0
edges.each do |bridge|
  tmp_edges = edges - [bridge]
  visited = [1]

  loop do
    connected_edges = tmp_edges.reject { |s| (visited & s).empty? }
    tmp_edges -= connected_edges
    connected_edges.each { |s| visited |= s }

    break if connected_edges.empty?
    break if tmp_edges.empty?
  end

  ans += 1 if visited.sort != [*1..n]
end
puts ans

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>

#define ll long long
#define endl endl
using namespace std;

const int INF = 0x3f3f3f3f;
int arr[200001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int ans=0;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    int m = arr[0];
    for(int i=0; i<n; i++)
    {
        m = max(m, arr[i]);
        if(arr[i] >= m) ans++;
    }
    cout << ans;
}



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

long long n;
vector<string> s;

long long solve();

int main() {
  cin >> n;
  s.resize(n);
  for(int i = 0; i < n; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, cnta = 0, cntb = 0, cntall = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = 1; j < s[i].size(); ++j)
      if(s[i][j - 1] == 'A' && s[i][j] == 'B') ++ans;
    if(s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')
      ++cntall;
    else if(s[i][0] == 'B')
      ++cntb;
    else if(s[i][s[i].size() - 1] == 'A')
      ++cnta;
  }
  ans += max(0LL, cntall - 1);
  if(cnta > 0 && cntall > 0) {
    ++ans;
    --cnta;
  }
  if(cntb > 0 && cntall > 0) {
    ++ans;
    --cntb;
  }
  long long now = min(cnta, cntb);
  ans += now;
  return ans;
}


Measured memory_bytes: 768
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto D = RDA;

	auto cnt = new long[](N);
	foreach (i; 0..N)
	{
		++cnt[D[i]];
	}

	long ans = cnt[0];
	foreach (i; 1..N)
	{
		foreach (j; 0..cnt[i])
			ans.modm(cnt[i-1]);
	}

	writeln(cnt[0] >= 2 || D[0] != 0 ? 0 : ans);
	stdout.flush();
	debug readln();
}

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

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int x;
    cin>>x;
    int c=0,pos=0;

    for(int i=1;pos<x;i++){
        pos+=i;
        c++;
    }
    cout<<c;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 200005
 
// it's swapnil07 ;)

int dp[105][100005];


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n, W; cin>>n>>W;
    int wt[n], val[n];
    For(i, 0, n)
        cin>>wt[i]>>val[i];
    For(i, 0, n){
        For(w, 0, W+1){
            if(i==0 && w<wt[i])
                dp[i][w] = 0;
            else if(i==0)
                dp[i][w] = val[i];
            else if(w<wt[i])
                dp[i][w] = dp[i-1][w];
            else
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-wt[i]]+val[i]);
        }
    }
    cout<<dp[n-1][W];
    return 0;
}

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

int main(){
	int a, b, c, n=0, i=0, ans[1000];
	while(cin>>a>>b){
		c=a+b;
		while(c!=0){
			c/=10;
			n++;
		}
		ans[i]=n;
		n=0;
		i++;
	}
	int j=0;
	while(j<i){
		cout<<ans[j]<<endl;
		j++;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

void solve()
{
    lli n;
    cin>>n;

    if(n%1000)
    {
        cout<<1000 - n%1000;
    }
    else cout<<0;
}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n, a;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end(), greater<int>());
  int e1, e2 = 0;
  for (int i = 0; i < v.size();) {
    e1 = v[i];
    int count = 0;
    for (; i < v.size() && v[i] == e1; i++, count++);
    if (count >= 2 && e2 > 0) {
      cout << 1LL * e1 * e2 << endl;
      return 0;
    }
    if (count >= 4) {
      cout << 1LL * e1 * e1 << endl;
      return 0;
    }
    if (count >= 2) {
      e2 = e1;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
LL x[SIZE],y[SIZE];
int main(){
    DRII(N,K);
    REP(i,N){
        cin>>x[i]>>y[i];
    }
    LL an=4e18;
    REP(i,N)REP(j,i)
        REP(i2,N)REP(j2,i2){
            int v=0;
            REP(k,N){
                if((x[i2]-x[k])*(x[j2]-x[k])<=0
                 &&(y[i]-y[k])*(y[j]-y[k])<=0)v++;
            }
            if(v>=K){
                an=min(an,abs(x[i2]-x[j2])*abs(y[i]-y[j]));
            }
        }
    cout<<an;
    return 0;
}


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

using namespace std;

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

  int64_t l = -1e18;
  int64_t r = 1e18;
  for (int i = 0; i < 100; i++) {
    int64_t b = (l + r) / 2;
    int64_t smaller = 0;
    int64_t larger = 0;
    for (int64_t i = 0; i < N; i++) {
      if (A[i] < i + b + 1) {
        smaller++;
      } else if (A[i] > i + b + 1) {
        larger++;
      }
    }

    if (smaller > larger) {
      r = b;
    } else if (smaller < larger) {
      l = b;
    } else if (smaller == larger) {
      l = b;
      r = b;
      break;
    }
  }

  int64_t answer = numeric_limits<int64_t>::max();
  for (int64_t b = l; b <= r; b++) {
    int64_t sum = 0;
    for (int i = 0; i < N; i++) {
      sum += abs(A[i] - (b + i + 1));
    }
    answer = min(answer, sum);
  }

  printf("%ld\n", answer);

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int getResult(const vector<int> &points, const int questions,
              const int borderA, const int borderB){
  int i = 0;

  int lowerBorderA = 0;
  for(; (i < questions) && (points[i] <= borderA); i++){
    lowerBorderA++;
  }

  int betweenBorderAB = 0;
  for(; (i < questions) && (borderA + 1 <= points[i]) && (points[i] <= borderB); i++){
    betweenBorderAB++;
  }
  
  int upperBorderB = 0;
  for(; i < questions; i++){
    upperBorderB++;
  }
  
  return min({lowerBorderA, betweenBorderAB, upperBorderB});
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  
  vector<int> P(N);
  for(int i = 0; i < N; i++){
    cin >> P[i];
  }
  sort(P.begin(), P.end());
  
  int result = getResult(P, N, A, B);
  cout << result;
  return 0;
}

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

using namespace std;

char s[9];

int main(){
    int a,b; cin >> a >> b;
    
    cin >> s;
    
    bool flag = true;
    
    for(int i = 0 ; i < a ; i++){
        if(s[i] == '-')
            flag = false;
    }
    
    for(int i = a + 1 ; i <= a + b ; i++){
        if(s[i] == '-')
            flag = false;
    }

    if(s[a] != '-')
        flag = false;
    
    
    if(flag == false)
        cout << "No" << endl;
    
    else
        cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
#include<stdio.h>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

const ll INF = ll(1e18) + 1;
const int intINF = 1e9 * 2 + 3;
//--------------------------------------------------

ulli gcd(ulli a, ulli b) {return (b <= 0) ? a : gcd(b, a % b);}
ulli lcm(ulli a, ulli b) {return a * b / gcd(a, b);}

bool isPrime(int n)
{
	if (n <= 3)return n > 1;
	if (n % 2 == 0)return false;
	if (n % 3 == 0)return false;
	for (int i = 5; i * i < n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0) { return false; }
	}
	return true;
}
//---------------------------------------------------



void Main()
{
	int h, w;
	cin >> h >> w;
	int map[100][100],
		dp[100][100];
	rep(i, 100) {
		rep(j, 100) {
			map[i][j] = 0;
			dp[i][j] = 0;
		}
		
	}
	rep(i, h)rep(j, w) {
		char input;
		cin >> input;
		if (input == '.') {
			map[i][j] = 1;
		}
		else {
			map[i][j] = 0;
		}
	}
	for (int i = 1; i < w; i++) {
		if (map[0][i]) {
			dp[0][i] = dp[0][i - 1];
		}
		else {
			if (map[0][i] == map[0][i - 1]) {
				dp[0][i] = dp[0][i - 1];
			}
			else {
				dp[0][i] = dp[0][i - 1] + 1;
			}
		}
	}

	for (int i = 1; i < w; i++) {
		if (map[i][0]) {
			dp[i][0] = dp[i - 1][0];
		}
		else {
			if (map[i][0] == map[i - 1][0]) {
				dp[i][0] = dp[i - 1][0];
			}
			else {
				dp[i][0] = dp[i - 1][0] + 1;
			}
		}
		
	}



	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (map[i][j]) {
				dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}
			else {
				int up = (map[i - 1][j] == map[i][j] ? dp[i - 1][j] : dp[i - 1][j] + 1),
					left = (map[i][j - 1] == map[i][j] ? dp[i][j - 1] : dp[i][j - 1] + 1);
				dp[i][j] = min(up, left);
			}
		}
	}

	int ans = dp[h - 1][w - 1];

	if (!map[0][0]) {
		ans++;
	}
	cout << ans << endl;
}


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

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

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

  int ans = 0;
  for (int i = 0; i < N; i++){
    if (mp[A[i]] == A[i] || mp[A[i]] == 0) continue;

    if (mp[A[i]] > A[i]){
      ans += mp[A[i]] - A[i];
      mp[A[i]] = A[i];
    }else if (mp[A[i]] > 0){
      ans += mp[A[i]];
      mp[A[i]] = 0;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1,0)


int main()
{
    char c;
    cin>>c;
    if(c == 'a'||c == 'e'||c == 'i'||c == 'o'||c == 'u'){
        cout<<"vowel"<<endl;
    }else{
        cout<<"consonant"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
X, N = map(int, input().split())
p_list = sorted(list(map(int, input().split())))

diff = [200, 0]


for i in range(-1, 102): # 1~100
    if i not in p_list:
        new_diff = abs(i - X)
        if new_diff < diff[0]:
            diff[0] = new_diff
            diff[1] = i

print(diff[1])

Measured memory_bytes: 9192
import java.util.*

fun main(args: Array<String>) {
    val (H, W, K) = readIntList()
    val S = Array(H) { readString() }

    val cutH = BooleanArray(H - 1) { false }

    fun cut(cutH: BooleanArray): Int {
        val cutHcount = cutH.count { it }
        var pre = IntArray(cutHcount + 1) { 0 }
        var res = cutHcount
        repeat(W) { w ->
            var p = 0
            val tmp = IntArray(cutHcount + 1) { 0 }
            repeat(H) { h ->
                if (S[h][w] == '1') tmp[p]++
                if (h < H - 1 && cutH[h]) p++
            }
            if (tmp.any { it > K }) return 10000000

            if (pre.withIndex().any { tmp[it.index] + it.value > K }) {
                res++
                pre.fill(0)
            }
            pre = pre
                .withIndex()
                .map { it.value + tmp[it.index] }
                .toIntArray()
        }

        return res
    }

    fun f(b: Boolean, i: Int): Int {
        cutH[i] = b
        if (i == cutH.size - 1) return cut(cutH)
        return Math.min(
            f(true, i + 1),
            f(false, i + 1)
        )
    }

    println(Math.min(f(true, 0), f(false, 0)))
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 110940
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

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

const ll mod = 1000000007;

unordered_map<ll, int> primeFactorize(ll a) {
  ll i = 2;
  unordered_map<ll, int> factor;
  while (i * i <= a) {
    if (a % i == 0) {
      factor[i]++;
      a /= i;
    }
    else i++;
  }
  factor[a]++;
  return factor;
}

ll modinv(ll x, ll m = mod) {
  ll b = m;
  ll u = 1;
  ll v = 0;
  ll tmp;
  while (b) {
    ll t = x / b;
    x -= t * b;
    tmp = x;
    x = b;
    b = tmp;
    u -= t * v;
    tmp = u;
    u = v;
    v = tmp;
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  vector<unordered_map<ll, int> > primeFactor(n);
  for (int i = 0; i < n; i++) primeFactor[i] = primeFactorize(a[i]);

  unordered_map<ll, int> primeMax;
  for (auto &x: primeFactor) {
    for (auto &y: x) primeMax[y.first] = max(primeMax[y.first], y.second);
  }

  ll target = 1;
  for (auto &x: primeMax) {
    for (int j = 0; j < x.second; j++) target = (target * x.first) % mod;
  }

  vector<ll> b(n, 1);
  for (int i = 0; i < n; i++) b[i] = (target * modinv(a[i])) % mod;

  ll ans = 0;
  for (auto &x: b) ans = (ans + x) % mod;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int dp[100], c[15][15], a[205][205];
signed main(void)
{
  int h, w;
  cin >> h >> w;
  REP(i, 10) REP(j, 10) cin >> c[i][j];
  REP(i, h) REP(j, w) cin >> a[i][j];

  REP(k, 10) REP(i, 10) REP(j, 10) chmin(c[i][j], c[i][k]+c[k][j]);
  // 
  // REP(i, 10) {
  //   REP(j, 10) {
  //     cout << c[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int res = 0;
  REP(i, h) REP(j, w) {
    if(a[i][j] == -1) continue;
    res += c[a[i][j]][1];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

n,m = map(int, input().split())
G = [[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    G[a].append(b)
    G[b].append(a)

color = [None]*n
flag = True
def dfs(cur, c):
    global flag
    if color[cur] is not None:
        if color[cur] != c:
            flag = False
        return
    color[cur] = c
    for to in G[cur]:
        dfs(to, c^1)

dfs(0, 0)

if flag:
    a = sum(color)
    b = n-a
    ans = a*b-m
else:
    ans = n*(n-1)//2 - m
print(ans)

Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
main(){
 int n,a[300001]={},count=0;
 cin>>n;
 for(int i=0;i<3*n;i++)cin>>a[i];
 sort(a,a+3*n); 
 int i=3*n-2;
 long long ans=a[i];
 while(1){
  count++;
  if(count==n)break;
  i-=2;
  ans+=a[i];
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N;
    cin>>N;
    vector<double> v(N);
    rep(i,N) cin>>v.at(i);
    sort(ALLOF(v));
    double ans=(v.at(0)+v.at(1))/2;
    for(int i=2;i<N;i++) ans=(ans+v.at(i))/2;
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	h := scanInt()
	w := scanInt()

	a := make([]string, h)

	for i := 0; i < h; i++ {
		a[i] = scanText()
	}

	cnt := make(map[string]int, 0)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			cnt[string(a[i][j])]++
		}
	}

	f := true

	chk2 := 0
	chk1 := 0

	if h%2==1 {
		chk2+=w
	}

	if w%2==1 {
		chk2+=h
	}

	if h%2==1&&w%2==1 {
		chk2-=2
		chk1++
	}

	for _, e := range cnt {
		if e%4 != 0 {
			if e%2==0 {
				chk2-=2
			} else {
				chk1--
			}
		}
	}

	if chk2<0||chk1<0 {
		f =false
	}

	// fmt.Println(chk2,chk1)

	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, c;
	cin >> n >> c;
	vector<vector<int>> d(c, vector<int>(c));
	rep(i, c)rep(j, c){
		cin >> d.at(i).at(j);
	}
	vector<map<int, int>> mv(3);
	rep(i, n)rep(j, n){
		int ii = i+1, jj = j+1;
		int in;
		cin >> in;
		in--;
		mv.at((ii+jj)%3)[in]++;
	}
	ll ans = 1e18;
	rep(i, c){
		ll add0 = 0;
		for(auto p : mv.at(0)){
			add0 += d.at(p.first).at(i) * p.second;
		}
		rep(j, c){
			ll add1 = 0;
			if(j == i) continue;
			for(auto p1 : mv.at(1)){
				add1 += d.at(p1.first).at(j) * p1.second;
			}
			rep(k, c){
				ll add2 = 0;
				if(i == k || j == k) continue;
				for(auto p2 : mv.at(2)){
					add2 += d.at(p2.first).at(k) * p2.second;
				}
				ans = min(ans, add0+add1+add2);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char a,b;
    cin>>a>>b;

    if(a=='D'){
        if(b=='H'){
            b='D';
        }
        else{
            b='H';
        }
    }
    
    cout<<b<<endl;
   
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    map<long long, long long> cnt;
    for(int i=0; i<N; ++i) {
        cin >> a[i];
        cnt[a[i]] += 1;
    }
    long long res = 0;
    for(auto p : cnt) res += p.second * (p.second - 1) / 2;

    for(int i=0; i<N; ++i) {
        long long d = cnt[a[i]];
        cout << res -  d * (d - 1) / 2 + (d - 1) * (d - 2) / 2 << '\n';
    }
}

Measured memory_bytes: 11008
#include <iostream>

#define puti cout << i << endl

using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i < min(a + k, b + 1); i++)      puti;
    for (int i = max(b - k + 1, a + k); i <= b; i++) puti;
    return 0;
}


Measured memory_bytes: 256
import sys
import pdb
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,Q = map(int, input().split())
    S = input().rstrip()
    dp = [0]*(N+1)
    for i in range(1,N):
        if S[i-1:i+1] == 'AC':
            dp[i+1] = dp[i]+1
        else:
            dp[i+1] = dp[i]
    for _ in range(Q):
        l,r = map(int, input().split())
        print(dp[r]-dp[l])

if __name__ == '__main__':
    main()

Measured memory_bytes: 8928
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int F[50];
    F[0]=F[1]=1;
    for(int i=2; i<=n; i++){
        F[i]=F[i-1]+F[i-2];
    }

    printf("%d\n", F[n]);

    return 0;
}


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

int main() {
  string first, second, third;
  char first_c, second_c, third_c;
  cin >> first >> second >> third ;

  first_c = first.at(0);
  second_c = second.at(0);
  third_c = third.at(0);
  cout << first_c << second_c << third_c << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
  int V[4][3][10]={};
  int b,f,r,v,n;
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    V[b-1][f-1][r-1]+=v;
  }
  for(int k=0;k<4;k++){
    for(int i=0;i<3;i++){
      for(int j=0;j<10;j++){
    cout<<" "<<V[k][i][j];
      }
      cout<<endl;
    }
    if(k!=3)cout<<"####################"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3104
maxA = 10**5 + 3

X = int(input())

def isPrime(x):
    for d in range(2, int(x**0.5)+1):
        if x%d == 0:
            return False
    return x != 1

for i in range(X, maxA+1):
    if isPrime(i):
        print(i)
        break


Measured memory_bytes: 9360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		long sum = 0;
		long digit = 0;
		for (int i = 1; i <= m; i++) {
			int d = sc.nextInt();
			long c = sc.nextLong();
			sum = sum + d * c;
			digit = digit + c;
		}
		long ans = (sum - 1) / 9 + digit - 1;
		System.out.println(ans);
	}
}

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

int main(){
int n,k;
cin>>n>>k;
vector<int>l(n);
for(int i=0;i<n;i++){
  cin>>l.at(i);
}
sort(l.begin(),l.end());
reverse(l.begin(),l.end());
int a=0;
for(int i=0;i<k;i++){
  a+=l.at(i);
  }
  cout<<a<<endl;  
return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    long H,W,minimum,i,k,count,n;
    long S[101];
    cin>>n;
    
    for (i=0;i<n;i++)
    {
        cin>>S[i];
    }

    for (i=n-1;i>0;i--)
    {
        cout<<S[i]<<" ";
    }
    cout<<S[i]<<endl;
    
    
    

    

    
    
    
    
    return 0;
    
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int modpow(ll a, ll n, ll p){
  if(n==0) return 1;
  if(n==1) return a%p;
  if(n%2 == 1) return (a*modpow(a,n-1,p))%p;
  ll t = modpow(a,n/2, p);
  return (t*t)%p;
 }

ll modnCa(ll n, ll a, ll p){
  ll upper = 1;
  ll lower = 1;
  for(ll i = 1; i <= a; i++){
    upper *= n-i+1;
    upper %= p;
    lower *= i;
    lower %= p;
  }
  ll inv_lower = modpow(lower, p-2, p);
  return (upper * inv_lower)%p;
}


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

  ll m = s/3;

  ll ans = 0;
  for(int i = 1; i<= m; i++){
    ans += modnCa(s-3*i+i-1, i-1, 1000000007);
    ans %= 1000000007;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3608
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    I[] a=new I[n];
    for(int i=0;i<n;i++){
      a[i]=new I(sc.nextInt(),sc.nextInt());
    }
    Arrays.sort(a,(s1,s2)->s1.p-s2.p);
//    System.out.println(Arrays.toString(a));
    long k=0;
    long c=0;
    for(int i=0;i<n;i++){
//      System.out.println(a[i]);
      if(a[i].k+k>=m){
        c+=(m-k)*a[i].p;
        break;
      }else{
        k+=a[i].k;
        c+=(long)(a[i].k)*(long)(a[i].p);
      }
//      System.out.println("k"+k+" c"+c);
    }
    System.out.println(c);
  }
  static class I{
    int p;
    int k;
    I(int p,int k){
      this.p=p;
      this.k=k;
    }
    public String toString(){
      return String.valueOf(p)+":"+String.valueOf(k);
    }
  }
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DFlippingSigns solver = new DFlippingSigns();
        solver.solve(1, in, out);
        out.close();
    }

    static class DFlippingSigns {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long a[] = new long[n];
            long dp[][] = new long[n][2];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            dp[0][0] = a[0] + a[1];
            dp[0][1] = -dp[0][0];
            for (int i = 1; i < n - 1; i++) {
                dp[i][0] = Math.max(dp[i - 1][0] + a[i + 1], dp[i - 1][1] + a[i + 1]);
                dp[i][1] = Math.max(dp[i - 1][0] - 2 * a[i] - a[i + 1], dp[i - 1][1] + 2 * a[i] - a[i + 1]);
            }
            out.println(Math.max(dp[n - 2][0], dp[n - 2][1]));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

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

}


Measured memory_bytes: 3120
import numpy as np
n, k = input().split(" ")

A = np.zeros((int(k), int(n)))
for i in range(int(k)):
    _ = input()
    for j in input().split(" "):
        A[i-1,int(j)-1] = 1
print(np.sum((np.sum(A, axis=0) == 0)))




Measured memory_bytes: 27280
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println(IntStream.range(0, sc.nextInt()).map(i -> sc.nextInt()).distinct().count());

        sc.close();
    }
}

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

using Int = long long;

int main() {
	Int Q;
	cin >> Q;
	while ( Q-- ) {
		Int A, B;
		cin >> A >> B;
		if ( A > B ) swap(A, B);
		
		if ( B - A <= 1 ) cout << 2*A-2 << endl;
		else {
			Int C = (Int)sqrt(A*B);
			if ( C*C == A*B ) C--;
			if ( C*(C+1) >= A*B ) cout << 2*C-2 << endl;
			else cout << 2*C-1 << endl;
		}
	}

	return 0;
}


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

int main(){
    ll x;
    cin>>x;
    ll ama=x%11;
    ll ans=0;
    if(x<11 && ama<=6){
        ans=1;
    }else if(x<11){
        ans=2;
    }else{
        ans=2*(x/11);
        if(ama==0){
        }else if(ama<=6){
            ans++;
        }else{
            ans+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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){
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> a(81);
  FOR(i, 1, 10){
    FOR(j, 1, 10){
      int ind;
      ind = (i-1) * 9 + j - 1;
      a[ind] = i * j;
    }
  }

  bool flag=false;
  REP(i, 81){
    if (N == a[i]){
      flag = true;
      break;
    }
  }

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

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n; string s,t;
	cin>>n>>s>>t;
	for(int i=0;i<=n;i++){
		string d = s;
		bool ok = 1;
		for(int j=i;j<n;j++){
			if(s[j] != t[j-i]){
				ok = 0;
			}
		}
		if(ok==0) continue;
		for(int x=n-i;x<n;x++){
			d.pb(t[x]);
		}
		cout<<d.size()<<endl; return 0;
	}
}

Measured memory_bytes: 256