akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                ans += d[i] * d[j];
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 22868
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

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

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = std::usize::MAX;
    for i in 0..26 {
        let ch = std::char::from_digit(i + 10u32, 36).unwrap();
        let mut temp_ans = 0;
        let mut s = s.clone();
        while !s.iter().all(|&x| x == ch) {
            temp_ans += 1;
            for j in 0..s.len() - 1 {
                if s[j + 1] == ch {
                    s[j] = ch;
                }
            }
            s.pop();
            // println!("{:?}", &s);
        }
        ans = min(ans, temp_ans);
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
# N =  map(int, input())
# l = map(int, input().split())
l = list(map(int, input().split()))

l.sort()
lm = max(l)
ll = [lm - i for i in l]

ans = int(ll[0] / 2) + int(ll[1] / 2)

if(ll[0] % 2 + ll[1] % 2 ) ==2:
    ans +=1
elif(ll[0] % 2 + ll[1] % 2 ) ==1:
    ans +=2

print(ans)

Measured memory_bytes: 3064
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int d;
    cin >> d;
    cout << "Christmas";
    while (d++ < 25) cout << " Eve";
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int x, y, z;
  std::cin >> x >> y >> z;

  if (x > y) {
    int tmp = x;
    x = y;
    y = tmp;
  }
  if (y > z) {
   int tmp = y;
   y = z;
   z = tmp;
  }
  if (x > y) {
    int tmp = x;
    x = y;
    y = tmp;
  }
  std::cout << x << " " << y << " " << z << std::endl;
}



Measured memory_bytes: 3112
program main
  implicit none
  
  integer :: n,a,b,m,i,j,s,h,sn,cou=0,o
  
  read(*,*)n,a,b
  
  do i = 1, n
    s = 0
    if (i <= 9) then
      s = i
    else if (i <= 99) then
      j = int(i/10)
      o = i - j*10
      s = j + o
    else if (i <= 999) then
      h = int(i/100)
      j = int((i - h*100)/10)
      o = i - h*100 - j*10
      s = h+j+o
    else if (i <= 9999) then
      sn = int(i/1000)
      h = int((i - sn*1000)/100)
      j = int((i - sn*1000 - h*100)/10)
      o = i - sn*1000 - h*100 - j*10
      s = sn+h+j+o
    else
      s = 1
    end if
    
    if ((a <= s) .and. (s <= b)) then
      cou = cou + i
    end if
  end do
  
  write(*,*)cou
end program main

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
//static const int INFTY = (1<<20);


int64_t gcd(int64_t a, int64_t b) {
	if (a%b==0) return b;
	else return gcd(b, a%b);
}

int64_t lcm(int64_t a, int64_t b) {
	return a / gcd(a, b) * b;
}

//ABC148_c
int main() {
	int64_t a, b;
	cin >> a >> b;

	cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define INF 10000000;
using namespace std;

int main() {
	int towns[10][10]; 
	int n;
	while (1) {
		cin >> n;
		if (!n)break;

		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				towns[i][j] = INF;
			}
		}
		for (int i = 0; i < 10; i++) {
			towns[i][i] = 0;
		}
		int biggest_town = 0;
		int a, b, c;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (biggest_town < a)biggest_town = a;
			if (biggest_town < b)biggest_town = b;
			towns[a][b] = c;
			towns[b][a] = c;
		}

		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					if (towns[i][j] > towns[i][k] + towns[k][j]) {
						towns[i][j] = towns[i][k] + towns[k][j];
					}
				}
			}
		}
		int start, total_time = 100000;
		for (int i = 0; i <= biggest_town; i++) {
			int tmp = 0;
			for (int j = 0; j <= biggest_town; j++) {
				if (towns[i][j] != 10000000)tmp += towns[i][j];
			}
			if (total_time > tmp) {
				total_time = tmp;
				start = i;
			}
		}
		cout << start << ' ' << total_time << endl;
	}
}


Measured memory_bytes: 3080
N, *I = map(int, open(0).read().split())
AB = list(zip(*[iter(I[:2 * N])] * 2))
CD = sorted(zip(*[iter(I[2 * N:])] * 2))

for c, d in CD:
    ma = max(((a, b) for a, b in AB if a < c and b < d), key=lambda x: x[1], default=None)
    if ma:
        AB.remove(ma)

print(N - len(AB))

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
	int n, m;
	while(cin >> n >> m, n && m){
		vector<int> vec;
		map<int, int> mapX, mapY;
		//nの入力
		for(int i = 0; i < n; i++){
			int hi;
			cin >> hi;
			vec.push_back(hi);
		}
		for(int i = 0; i < n; i++){
			int h = 0;
			for(int j = i; j < n; j++){
				h += vec[j];
				mapY[h]++;
			}
		}
		vec.clear();
		//mの入力
		for(int i = 0; i < m; i++){
			int hi;
			cin >> hi;
			vec.push_back(hi);
		}
		for(int i = 0; i < m; i++){
			int h = 0;
			for(int j = i; j < m; j++){
				h += vec[j];
				mapX[h]++;
			}
		}

		//正方形を数える
		int count = 0;
		map<int, int>::iterator iteX, iteY;
		for(iteY = mapY.begin(); iteY != mapY.end(); iteY++){
			iteX = mapX.end();
			if(mapX.find(iteY->first) != iteX){
				count += mapX[iteY->first] * iteY->second;
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 27736
using System;

class ABC079D
{
	static public void Main(string[] args)
	{
		int H, W;
		string[] vals = Console.ReadLine().Split(' ');
		H = int.Parse(vals[0]);
		W = int.Parse(vals[1]);

		int[,] d = new int[10,10];
		for(int i=0; i<=9; i++)
		{
			vals = Console.ReadLine().Split(' ');
			for(int j=0; j<=9; j++)
				d[i,j] = int.Parse(vals[j]);
		}

		for(int k=0; k<=9; k++)
		{
			for(int i=0; i<=9; i++)
			{
				for(int j=0; j<=9; j++)
				{
					d[i,j] = Math.Min(d[i,j], d[i,k] + d[k, j]);
				}
			}
		}

		long sum = 0;
		for(int h=0; h<H; h++)
		{
			vals = Console.ReadLine().Split(' ');
			for(int w=0; w<W; w++)
			{
				int A = int.Parse(vals[w]);
				if(A != -1)
					sum += d[A, 1];
			}
		}
		Console.WriteLine(sum);
	}
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct UnionFind {
	vector<int> parent;
	int size;
	UnionFind(int n) :parent(n, -1), size(n) {}
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y)return false;
		if (sizeOf(x) < sizeOf(y))swap(x, y);
		parent[x] += parent[y]; parent[y] = x; size--;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
	int sizeOf(int x) { return -parent[root(x)]; }
};



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	int M; cin >> M;
	vector<int> a(M), b(M); rep(i, 0, M) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	int ans = 0;
	rep(i, 0, M) {
		UnionFind uf(N);
		rep(j, 0, M) {
			if (i == j)continue;
			uf.unite(a[j], b[j]);
		}
		if (uf.size != 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<pair<int,int>> v;
    rep(i,n){
        int a; cin >> a; 
        v.push_back(make_pair(a,i));
    }
    sort(ALL(v));
    rep(i,n) cout << v[i].second + 1 << endl;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a[20],ans=0,b[20];
  rep(i,5)cin >> a[i];
  rep(i,5)b[i]=a[i]%10;
  rep(i,5)if(b[i]==0)b[i]=10;
  sort(b,b+5);
  rep(i,5)ans+=((a[i]-1)/10+1)*10;
  printf("%lld",ans-10+b[0]);
}

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

int main(){
  int N, M;
  cin >> N;
  vector<string> blue(N);
  for (int i=0; i<N ; i++){
    string B;
    cin >> B;
    blue.at(i) = B;
  }
  vector<string> red(M);
  cin >> M;
  for (int i=0; i<M ; i++){
    string R;
    cin >> R;
    red.at(i) = R;
  }
  int Result = 0;
  for (int i=0; i<N; i++){
    int Sum = 0;
    for(int j=0; j<N ; j++){
      if (blue.at(i) == blue.at(j)){
        Sum ++;
      }
    }
    for(int j=0; j<M ; j++){
      if (blue.at(i) == red.at(j)){
        Sum --;
      }
    }
    if (Sum > Result){
      Result = Sum;
    }
  }
  cout << Result << endl;
}
   

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <deque>

using namespace std;

typedef long long ll;

int Q, H, S, D, N;
int main() {
	scanf("%d %d %d %d", &Q, &H, &S, &D);
	scanf("%d", &N);
	H = min(H, 2 * Q);
	S = min(S, 2 * H);
	D = min(D, 2 * S);
	printf("%lld\n", (ll)(N / 2) * D + (N % 2) * S);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    dsu uf(N);
    REP(_, M) {
        int A, B; cin >> A >> B;
        --A; --B;
        uf.merge(A, B);
    }

    int ans = 0;
    REP(i, N) if (uf.leader(i) == i) ans++;
    ans--;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int Ans = 0;
  Ans += a - 1;
  if(a<=b) ++Ans;
  printf("%d\n",Ans);
  return 0;
}


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

int main(void){
    int n, k, dis = 0;
    cin >> n >> k;
    vector<int> x(n);
    for (int i=0; i<n; i++) cin >> x[i];
    for (int i=0; i<n; i++){
        if (x[i] <= k - x[i]){
            dis += x[i] * 2;
        } else {
            dis += (k - x[i]) * 2;
        }
    }
    cout << dis << endl;
    return 0;
}

Measured memory_bytes: 3624
S = list(map(int, input()))
n = len(S)
S = S[::-1]
#print(S)
Smod = [S[i] * pow(10, i, 2019) %2019 for i in range(n)]
Scum = [0]*n
Scum[0] = Smod[0]
#print(Smod)

for i in range(1, n):
  Scum[i] = (Scum[i-1] + Smod[i])%2019
#print(Scum)
from collections import Counter
c = Counter(Scum)
#print(c)
ans = 0
for k in c:
  if k!=0 or k==0:
    ans += c[k]*(c[k] - 1)//2
    #print(k, c[k], ans)
    
for i in range(n):
  if Scum[i]==0:
    ans += 1
    #print(ans)
    
print(ans)

Measured memory_bytes: 91200
X = list(input())
ans = 0
s = 0
t = 0
flag = 0
for i in range(len(X)) :
    if X[i] == "S" :
        s += 1
        flag = 1
    else :
        if flag == 1 :
            ans += 2
            s -= 1
            if s == 0 :
                flag = 0
print(len(X)-ans)


Measured memory_bytes: 4840
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        // Your code here!
      var a = Console.ReadLine().Split().Select(y => int.Parse(y)).ToArray();
      int n = a[0];
      int x = a[1];
      var l = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
      int counter = 1;
      int zahyo = 0;
    
    for(int i=0; n!=i; i++){
        
        zahyo = zahyo + l[i];
        if(zahyo<=x){
            counter++;
        }
    }
    
    Console.WriteLine(counter);
    
    }
}


Measured memory_bytes: 13268
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Set<Integer> colors = new HashSet<>();
		int allCount = 0;
		for (int i = 0; i < n; i++) {
			int color = calcColor(in.nextInt());
			if (color == 100) {
				allCount += 1;
			} else if (color < 100) {
				colors.add(color);
			}
		}
		System.out.println(Math.max(colors.size(), 1) + " " + (colors.size()+allCount));

	}
	static int calcColor(int rate) {
		int color = Integer.MAX_VALUE;
		if (1 <= rate && rate <= 399) {
			color = 1;
		} else if (400 <= rate && rate <= 799) {
			color = 2;
		} else if (800 <= rate && rate <= 1199) {
			color = 3;
		} else if (1200 <= rate && rate <= 1599) {
			color = 4;
		} else if (1600 <= rate && rate <= 1999) {
			color = 5;
		} else if (2000 <= rate && rate <= 2399) {
			color = 6;
		} else if (2400 <= rate && rate <= 2799) {
			color = 7;
		} else if (2800 <= rate && rate <= 3199) {
			color = 8;
		} else {
			color = 100;
		}
		return color;
	}

}


Measured memory_bytes: 22612
import sys

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


# main
N, M = map(int, sys.stdin.readline().strip().split())
edges = []

for _ in range(M):
	a, b = map(int, sys.stdin.readline().strip().split())
	edges.append((a-1, b-1))

ans = [0] * M
all_comb = (N*(N-1)//2)
ans[M-1] = all_comb
uf = UnionFind(N)
for i in range(M-1, 0, -1):
    a, b = edges[i]
    if uf.same(a, b):
        ans[i-1] = ans[i]
        continue

    ans[i-1] = ans[i] - (uf.size(a) * uf.size(b))
    uf.union(a, b)

# print(ans)
for i in range(M):
    print(ans[i])

Measured memory_bytes: 95452
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
#define NMAX 200000

signed main(){   

    int X,N,p[111]={0};

    cin>>X>>N;

    for(int i=0;i<N;i++){
        int in;
        cin>>in;
        p[in]=1;
    }

    int ans=0;
    for(int i=1;i<=110;i++){
        if(p[i]!=1){
            if(abs(ans-X)>abs(i-X)){
                ans=i;
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3180
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {                                                               
            var map = new int[10, 10];
            var xs = new int[] { 0, 1, 0, -1 };
            var ys = new int[] { -1, 0, 1, 0 };
            var xm = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
            var ym = new int[] { -1, -1, 0, 1, 1, 1, 0, -1 };
            var xl = new int[] { 0, 1, 1, 1, 0, -1, -1, -1, 0, 2, 0, -2 };
            var yl = new int[] { -1, -1, 0, 1, 1, 1, 0, -1, -2, 0, 2, 0 };
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                var str = line.Split(',');
                var x = int.Parse(str[0]);
                var y = int.Parse(str[1]);
                var s = int.Parse(str[2]);
                if (s == 1)
                {
                    PutInk(map, x, y, xs, ys);
                }
                else if (s == 2)
                {
                    PutInk(map, x, y, xm, ym);
                }
                else
                {
                    PutInk(map, x, y, xl, yl);
                }
            }
            var count = 0; var max = -1;
            foreach (var v in map)
            {
                if (v == 0) count++;
                max = Math.Max(max, v);
            }
            Console.WriteLine("{0}\n{1}",count,max);
        }
        public static void PutInk(int[,] map, int x, int y, int[] formX, int[] formY)
        {
            map[x, y] += 1;
            for (int i = 0; i < formX.Length; i++)
            {
                var rangeX = x + formX[i];
                var rangeY = y + formY[i];
                if (rangeX > -1 && rangeX < 10 && rangeY > -1 && rangeY < 10)
                    map[rangeX, rangeY] += 1;
            }
        }
    }
}


Measured memory_bytes: 15928
// C-Coins.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <numeric>


using lolo=long long;

struct Score {
	lolo A;
	lolo B;
	lolo C;
	lolo id;
	lolo D[3];
	Score(lolo A, lolo B, lolo C, lolo id) :
		A(A), B(B), C(C), id(id) {
		D[0] = A;
		D[1] = B;
		D[2] = C;
	}
};

using namespace std;
using vec=vector<lolo>;
using vecScore=vector<Score>;
using vecb=vector<bool>;

#define ALL(x) x.begin(), x.end()
#define FOR(i,N) for(lolo i=0; i<N; ++i)
#define FORN(i,A,B) for(lolo i=A; i<B; ++i)
#define REV(i,A,B) for(lolo i=A; i>B; --i)

template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}


int main()
{
	lolo X, Y, Z;
	cin >> X >> Y >> Z;
	lolo total = X + Y + Z;

	vec A(total), B(total), C(total);
	vecScore PEOPLE;
	for (lolo i = 0; i < total; ++i) {
		cin >> A[i] >> B[i] >> C[i];
		PEOPLE.emplace_back(A[i], B[i], C[i], i);
	}

	auto f = [](Score & a, Score & b) {
		return (a.A - a.B) < (b.A - b.B);
	};

	sort(ALL(PEOPLE), f);

	priority_queue<lolo> hidari_q;
	priority_queue<lolo> migiQ;
	vec hidari(total+1, -1);
	hidari[total] = 0;
	lolo popout;
	lolo sum = 0;

	FOR(i, Y) {
		hidari_q.push( - PEOPLE[i].B + PEOPLE[i].C);
		sum += PEOPLE[i].B;
		//hidari[i] = sum;
	}
	hidari[Y - 1] = sum;

	FORN(i, Y, total) {
		sum += PEOPLE[i].B;
		hidari_q.push(  - PEOPLE[i].B  + PEOPLE[i].C) ;
		popout = hidari_q.top();
		hidari_q.pop();

		sum += popout;
		hidari[i] = sum;		
	}
	sum = 0;
	// ----------------------------------------------------------------------------------
	vec migi(total+1, -1);
	migi[total] = 0;

	REV(i, total - 1, total - 1 - X ) { // 個数はN個
		migiQ.push( -  PEOPLE[i].A + PEOPLE[i].C)  ;
		sum += PEOPLE[i].A;
		//migi.push_back(sum);
		//migi[i] = sum;
	}
	migi[total - 1 - X + 1] = sum;
	REV(i, total - 1 - X, -1) {
		sum += PEOPLE[i].A;
		migiQ.push(- PEOPLE[i].A + PEOPLE[i].C);
		popout = migiQ.top(); migiQ.pop();
		sum += popout;
		migi[i] = sum;
		//migi.push_back(sum);
	}

	lolo ans = 0;
	//reverse(ALL(migi));



	FOR(i, total) {
		if (i < Y - 1) continue;
		//if (i > (total - 1 - X)) break;
		//if ((total - i + 1) < X) break;
		//if (hidari[i] == -1 or migi[i+1] == -1) continue;
		if (hidari[i] == -1 ) continue;
		if (migi[i + 1] == -1) break;
		

		lolo tmp = hidari[i] + migi[ i+1  ];
		chmax(ans, tmp);
	}

	cout << ans << endl;
	
	
	


}



Measured memory_bytes: 12908
package main

import (
	"fmt"
)

func main() {
	var s, t, u string
	var a, b int
	fmt.Scanf("%s %s", &s, &t)
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%s", &u)
	if u == s {
		fmt.Printf("%d %d\n", a-1, b)
	} else {
		fmt.Printf("%d %d\n", a, b-1)
	}
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        sc.close();

        int M = 0;
        for(int i = N-1; i >= 0; i--){
            int sum = 0;
            for(int j = 2*(i+1)-1; j < N; j = j+(i+1)){
                if(b[j] == 1)
                    sum++;
            }
            if(sum%2 == 1 && a[i] == 0){
                b[i] = 1;
                M++;
            }
            if(sum%2 == 0 && a[i] == 1){
                b[i] = 1;
                M++;
            }
        }
        System.out.println(M);
        for(int i = 0; i < N; i++){
            if(b[i] == 1){
                System.out.println(i+1);
            }
        }
    }
}

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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int q;
    cin >> q;
    lint med = LINF, bsum = 0, ans = 0;
    priority_queue<lint> lef;
    priority_queue<lint, vector<lint>, greater<lint>> rig;
    for (int i = 0; i < q; i++) {
        int f;
        cin >> f;
        if (f == 1) {
            lint a, b;
            cin >> a >> b;
            bsum += b;

            if (med == LINF) {
                med = a;
            } else if (a < med) {
                if (lef.size() == rig.size()) {
                    lef.push(a);
                    ans += med - a;
                    rig.push(med);
                    med = lef.top();
                    lef.pop();
                }
                else if (lef.size() < rig.size()) {
                    lef.push(a);
                    ans += med - a;
                }
            } else if (a >= med) {
                if (lef.size() == rig.size()) {
                    rig.push(a);
                    ans += a - med;
                } else if (lef.size() < rig.size()) {
                    rig.push(a);
                    ans += a - med;
                    lef.push(med);
                    lint nmed = rig.top();
                    rig.pop();
                    ans -= nmed - med;
                    med = nmed;
                }
            }
        } else if (f == 2) {
            cout << med << ' ' << ans + bsum << endl;
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

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

    bool ok = false;

    rep2(i,1,10){
        int B;
        if (N % i == 0)
        {
            B = N / i;
        }
        if(1<=B &&B<=9){
            ok = true;
        }
    }

    puts(ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    ll n,m;
    cin >> n >> m;
    ll teisyutu = 1LL << m;
    ll x = 1900 * m + 100 * ( n - m);
    cout << x * teisyutu << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product


def main():
    n, m = list(map(int, input().split()))
    matrix = [[0 for _ in range(n)] for _ in range(m)]
    for i in range(m):
        ks = list(map(int, input().split()))
        _ = ks[0]
        s = ks[1:]
        for si in s:
            matrix[i][si - 1] = 1

    ps = list(map(int, input().split()))

    # print(f'n: {n}, m: {m}')
    # print(f'matrix: {matrix}')
    # print(f'p: {ps}')

    count = 0
    for case in product([0, 1], repeat=n):
        # print('------')
        # print(f'case: {case}')
        ok = 0
        for s, p in zip(matrix, ps):
            target = [
                1 for idx, si in enumerate(s) if si == 1 and case[idx] == 1
            ]
            # print(f'* s: {s}, case: {case}, target: {target}')
            if sum(target) % 2 == p:
                ok += 1
        # print(f'ok: {ok}')
        if ok == m:
            count += 1

    print(count)


main()

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;

int main(){
   ll n;cin >>n;
   vector<ll>a(n);
   vector<ll>b(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i]>>b[i];
    }
    sort(all(a));
    sort(all(b));
    ll ans;
    if(n%2==1) {
        ll mint =a[n/2];
        ll mx=b[n/2];
        ans=mx-mint+1;
    }
    else {
        ll mint=a[n/2]+a[n/2-1];
        ll mx=b[n/2]+b[n/2-1];
        ans=mx-mint+1;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    public static void main(String[] arg){
        Main m = new Main();
        m.run();
    }

    void run(){
        int a = sc.nextInt();
        int b = sc.nextInt();

        int amin = ((a) * 100 + 7)/ 8;
        int amax = ((a+1) * 100 )/ 8;

        int bmin = ((b) * 100 + 9)/ 10;
        int bmax = ((b+1) * 100 )/ 10;

        if (bmin <= amin && amin < bmax){
            System.out.println(amin);
        }else if (amin <= bmin && bmin < amax){
            System.out.println(bmin);
        }else{
            System.out.println(-1);
        }
    }
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> p(N);
    rep(i, N) cin >> p[i];

    sort(p.begin(), p.end());
    
    int ans = 0;
    rep(i, N - 1) ans += p[i];

    cout << ans + (p[N - 1] / 2) << endl; 
    return 0;
}

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

ll dp[100005][4];
ll mod = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    string abc = "ABC";
    for (int i = s.size(); i >= 0; i--) {
        for (int j = 3; j >= 0; j--) {
            if (i == s.size()) {
                dp[i][j] = j == 3;
            } else {
                int m = s[i] == '?' ? 3 : 1;
                if (j == 3) {
                    dp[i][j] = m * dp[i + 1][j];
                } else {
                    int m1 = s[i] == '?' || s[i] == abc[j] ? 1 : 0;
                    dp[i][j] = m * dp[i + 1][j] + m1 * dp[i + 1][j + 1];
                }
            }
            dp[i][j] %= mod;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main(){
    while(true){
        int a,b;
        char op;
        cin >> a >> op >> b;
        if(op == '?'){
            break;
        }else if(op == '+'){
            cout << a+b << endl;
        }else if(op == '-'){
            cout << a-b << endl;
        }else if(op == '*'){
            cout << a*b << endl;
        }else{
            cout << a/b << endl;
        }
    }
}


Measured memory_bytes: 3084
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	double ans = 0;
	rep(i, 0, N) {
		double x; cin >> x;
		string s; cin >> s;
		if (s == "BTC") {
			ans += 380000.0*x;
		}
		else {
			ans += x;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#coding:utf-8

N = int(input())
S = input()

result = 999999
left = 0
right = len([x for x in S if x == '.'])
result_i = left + right
result = result_i

for i in range(0, N):
    if S[i] == '.':
        right -= 1
    if S[i] == '#':
        left += 1
    result_i = left + right
    result = min(result, result_i)
print(result)
        
        
    


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

vector<bool> prime_enum(int n){
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(ll i = 2; i < n; i++){
        if(!is_prime[i]) continue;
        for(ll j = 2; i * j < n; j++){
            is_prime[i * j] = false;
        }
    }
    return is_prime;
}

void Main(){
	auto v = prime_enum(100001);
	vector<int> cnt(100001, 0);
	int k = 0;
	for(int i = 3; i <= 100000; i+=2){
		if(v[i] && v[(i+1)/2]){
			k++;
		}
		cnt[i] = k;
	}
	int q; cin >> q;
	Rep(q){
		int l,r; cin >> l >> r;
		cout << cnt[r] - cnt[max(0,l-2)] << endl;
	}
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char s[100],t[100];
int a,b;
char u[100];
scanf("%s %s",s,t);
scanf("%d %d",&a,&b);
scanf("%s",u);
if(strcmp(s,u)==0){a--;}
else{b--;}
printf("%d %d",a,b);
}

Measured memory_bytes: 128
using System;
public class Hello{
    public static void Main(){
        // Your code here!
        var line = Console.ReadLine().Split(' ');
        int L = int.Parse(line[0]);
        int R = int.Parse(line[1]);
        int d = int.Parse(line[2]);
        int count = 0;
        for (int i = L; i <= R; i++)
        {
            if (i % d == 0)
            {
                count++;
            }
        }
        System.Console.WriteLine(count);
    }
}


Measured memory_bytes: 27320
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,p;
    cin >> n >> p;

    string str;
    cin >> str;

    if(10%p == 0){
        vector<vector<ll>> dp(n+1,vector<ll>(p,0));
        ll ans = 0;
        for(int i = 0; i < n; i++){
            ll c = (ll)(str[i] - '0');
            for(int j = 0; j < p; j++){
                dp[i+1][(j*10 + c)%p] += dp[i][j];
            }
            dp[i+1][c%p]++;
            ans += dp[i+1][0];
        }
        cout << ans << endl;
        return 0;
    }

    vector<ll> sum(n+1,0);
    ll t = 1;
    for(int i = 0; i < n; i++){
        sum[i+1] = (sum[i] + (ll)(str[n - i - 1] - '0')*t)%p;
        t = (t*10)%p;
    }

    ll ans = 0;
    map<ll,ll> mp;
    for(const auto x: sum){
        //cout << x << endl;
        if(mp.find(x) == mp.end()){
            mp.insert({x,1});
        }else{
            mp[x]++;
        }
    }

    for(const auto x: mp){
        ans += (x.second*(x.second-1))/2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 14484
import math

a, b = map(int, input().split())

count = 0

# 消費税が1%でも　A<=B<=100　より 10000を計算すればOK
# 全探索
for n in range(1, 10001, 1):
    # 小数点以下切り捨て計算
    c1 = math.floor(n * 0.08)
    c2 = math.floor(n * 0.10)

    if c1 == a and c2 == b:
        print(n)
        exit()
    else:
        count += 1

# 見つからなかったとき-1出力
if count == 10000:
    print(-1)

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);

  int a,b,c; cin >> a >> b >> c;
  string ans;
  if(a+b+c>=22){
    ans = "bust";
  } else {
    ans = "win";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    if(l==2)
        cout<<s<<endl;
    else
    {
        reverse(s.begin(),s.end());
        cout<<s<<endl;




    }


    return 0;


}


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

using namespace std;

int main(){
	int n,cnt=1;
	long sum=0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum=sum + arr[i];
	}
	sort(arr,arr+n);
	sum = sum - arr[n-1];
	for(int i=n-2;i>=0;i--){
		if(sum*2>=(long)arr[i+1]){
			cnt++;
			sum=sum - arr[i];
		}
		else
			break;
	}
	cout<<cnt;
}

Measured memory_bytes: 640
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,k = map(int, input().split())
ab = [None]*n
for i in range(n):
    ab[i] = list(map(int, input().split()))
ab.sort()
for a,b in ab:
    k -= b
    if k<=0:
        print(a)
        break

Measured memory_bytes: 52060
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
auto scan = []{ static LL a; scanf("%lld", &a); return a;};


string s, noxs;
bool ispal(string &s) {
  for (LL i = 0; i < s.size(); ++i) if(s[i] != s[s.size() - 1 - i]) return false;
  return true;
}
int main() {
  cin >> s;
  LL ans = 0;
  for(auto c : s) if(c!='x') noxs.push_back(c);

  LL beg = 0, ed = s.size() - 1;
  while (beg < ed ) {
    if (s[beg] != 'x' && s[ed] != 'x') {
      if (s[beg] != s[ed]) return 0 * puts("-1");
      else ++beg, --ed;
    }
    else {
      if (s[beg] == 'x' && s[ed] == 'x') ++beg, --ed;
      else if(s[beg] == 'x' && s[ed] != 'x') ++beg, ++ans;
      else ++ans, --ed;
    }
  }
  printf("%lld\n",ans);


}


Measured memory_bytes: 512
import sys
input=lambda: sys.stdin.readline().rstrip()
h,w,k=map(int,input().split())
C=[list(input()) for _ in range(h)]

ans=0
for i in range(2**h):
  for j in range(2**w):
    ct=0
    for ih in range(h):
      for iw in range(w):
        if i&(1<<ih)==0 and j&(1<<iw)==0 and C[ih][iw]=="#":
          ct+=1
    if ct==k:
      ans+=1
print(ans)

Measured memory_bytes: 9204
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String S = sc.nextLine();
		sc.close();
		int count = 0;
		String s[] = S.split("");
		
        for(int i = 1; i < N; i++) {
	    	if(s[i].equals("E")) {
	    		count ++;
	    	}
        }
		
        int min = count;
        for(int j = 1; j < N; j++) {
    		if( s[j-1].equals("W")) {
        		count++;
        	}
    		if( s[j].equals("E")) {
        		count--;
        	}
    		min = Math.min(min, count);	
        }
		System.out.println(min);
	}
}

Measured memory_bytes: 52472
N = int(input())

F = []
for i in range(N):
  F.append([int(i) for i in input().split()])

P = []
for i in range(N):
  P.append([int(i) for i in input().split()])

ans = (10**7) * N * (-1)
for i in range(1,2**10):
  bin_i_list = [int(x) for x in '{:0=10b}'.format(i)]
  count_list = []
  for n in range(N):
    count = 0
    for l in range(10):
      if F[n][l] == 1 and bin_i_list[l] == 1:
        count += 1
    count_list.append(count)

  tmp_ans = 0
  for n in range(N):
    tmp_ans += P[n][count_list[n]]

  ans = max(tmp_ans,ans)

print(ans)



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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        double[][] dp = new double[n][n + 1]; //[coin][#heads]
        dp[0][1] = in.nextDouble();
        dp[0][0] = 1 - dp[0][1];
        for (int i = 1; i < n; i++) {
            double p = in.nextDouble();
            dp[i][0] = dp[i - 1][0] * (1 - p);
            for (int j = 1; j <= i + 1; j++) {
                dp[i][j] = dp[i - 1][j] * (1 - p) + dp[i - 1][j - 1] * p;
            }
        }

        double ans = 0;
        for (int i = n / 2 + 1; i <= n; i++) {
            ans += dp[n - 1][i];
        }
        out.println(ans);
        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 109480
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
  cin>>n;
    vector<double> v(n);
    double s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double x=1;
    for(int i=0;i<n;i++){
        x=1;
        for(int j=0;j<n-i;j++){
            x/=2;
        }
        s+=v[i]*x;
    }
    x=1;
    for(int i=0;i<n;i++){
        x/=2;
    }
    s+=v[0]*x;
    cout<<s<<endl;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = (2 * 1e6 + 3);
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here

int main()
{
	IOS;
	ll a;
	cin >> a;
	cout << (a + a * a + a * a * a) << endl;
	return 0;
}

Measured memory_bytes: 3640