akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
   int n;
   cin >> n;
   
   vector<double> a(n);
   rep(i,n) {
    cin >> a.at(i);
    }
    
    double x;
    
    rep(i, n) {
    x += 1 / a.at(i);
    }
    
    cout << 1 / x;
}

Measured memory_bytes: 256
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ca = A[:]
cb = B[:]

for i in range(N-1):
  ca[i+1] += ca[i]
for i in range(M-1):
  cb[i+1] += cb[i]

ans = 0
for i in range(N):
  if ca[i] <= K:
    idx = bisect.bisect_right(cb, K-ca[i])
  else:
    continue
  
  ans = max(ans, i+idx+1)

for i in range(M):
  if cb[i] <= K:
    idx = bisect.bisect_right(ca, K-cb[i])
  else:
    continue
  
  ans = max(ans, i+idx+1)
print(ans)


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

int A[3][3], N, B[20], C[3][3];

int main() {
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      cin >> A[i][j];
    }
  }
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> B[i];
  }
  for (int i=0; i<3; i++) {
    for (int j=0; j<3; j++) {
      for (int k=0; k<N; k++) {
        if (A[i][j] == B[k]) {
          C[i][j] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int i=0; i<3; i++) {
    if (ans == 0 && ((C[i][0] == 1 && C[i][1] == 1 && C[i][2] == 1) || (C[0][i] == 1 && C[1][i] == 1 && C[2][i] == 1))) {
      ans = 1;
      break;
    }
  }
  if (ans == 0 && ((C[0][0] == 1 && C[1][1] == 1 && C[2][2] == 1) || (C[0][2] == 1 && C[1][1] == 1 && C[2][0] == 1))) {
    ans = 1;
  }
  if (ans) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


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

#define ll long long
#define ld long double
#define ii pair<int ,int >
#define S second
#define F first
#define PI 3.1415926535897932384626
#define SPEED std::ios_base::sync_with_stdio(false);

unordered_map<int ,bool>mp;

bool check(int n){
    while(n){
        if(mp[n%10]){
            return 1;
        }
        n/=10;
    }
    return 0;
}

int main(){
    SPEED
    int n,l;
    cin>>n>>l;
    for(int i=0;i<l;i++){
        int x;cin>>x;
        mp[x]=1;
    }
    while(true){
        if(!check(n)){
            cout<<n;
            return 0;
        }
        n++;
    }
}


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

int main(){
  int ans1=-1,ans2=-1;
  string s;
  cin >> s;

  for(int i = 0; i < s.size()-2; i++){
    if(s[i]==s[i+1]){
      ans1=i+1;ans2=i+3;
      break;
    }
    else if(s[i]==s[i+2]){
      ans1=i+1;ans2=i+3;
      break;
    }
  }
  if(s.size()==2){
    if(s[0]==s[1]){
      ans1=1;ans2=2;
    }
  }

  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt(),b=scan.nextInt(),c=scan.nextInt();
		c-=a-b;
		if(c<0){
			c=0;
		}
		System.out.println(c);
	}
}

Measured memory_bytes: 22612
#include <stdio.h>
#define INF 100001

int main (void){
    int N;
    int a,b;
    int count[INF]={};//???????????°???????§????????????????????????£?????????????????°
    int i,max=0;
    
    scanf("%d", &N);
    while(N){
        scanf("%d %d",&a ,&b);
        for(a--;a!=b;a++){
           // printf("%d %d\n", a, b);
            count[a]++;
        }
    
        N--;
    }
    for(i=0;i<INF;i++){
        if(count[i] > i)
            count[i] = i;
        if(count[i] < i)
            count[i] = 0;
    }
    
    
    max = count[0];
    for(i=1;i<INF;i++){
        //if(i<10) printf("%d",count[i]);
        if(count[i] > max){
            max = count[i];
        }
    }
    
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 996
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

type Point = (Int,Int)
type Dist = (Int,Int)

main :: IO ()
main = do
    n <- readLn
    ws <- replicateM n rp
    --print ws
    let difs = sort $ map (ptNorm . uncurry ptDif) (pair ws)
    --print difs
    let difs' = sortBy (flip (comparing snd)) $ map lenP (group difs)
    --print difs'
    let winDif = fst (head difs')
    --print winDif
    let res = groupCount 0 winDif ws
    print res


groupCount :: Int -> Dist -> [Point] -> Int
groupCount ac _ []  = ac
groupCount ac d ls  = groupCount (ac+1) d (grouperLR d ls)

grouperLR :: Point -> [Point] -> [Point]
grouperLR d ls = intersect (grouper (ptNeg d) ls) (grouper d ls)

grouper :: Dist -> [Point] -> [Point]
grouper d [] = []
grouper d (p:ps) = {-traceShow (d,p:ps) $-} let newp = ptAdd d p in
                    case find ((newp ==)) ps of
                        Nothing -> ps
                        Just r  -> grouper d (newp:(delete r ps))


lenP ls = (head ls, length ls)

ptDif (a,b) (x,y) = (a-x,b-y)
ptAdd (a,b) (x,y) = (a+x,b+y)

ptNorm p@(x,y) = if x<0 then ptNeg p
                else if x==0 && y<0 then ptNeg p
                else p

ptNeg (x,y) = (-x,-y)


pair :: [a] -> [(a,a)]
pair []     = []
pair (a:as) = map (\x->(a,x)) as ++ pair as

Measured memory_bytes: 1276
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::io::{stdout, Write, BufWriter};
// use std::cmp::min;

fn main() {
    input!{
        n: usize,
        rec: [i32; n],
    }
    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    let mut ans: Vec<usize> = vec![0; n];
    for (i, &n) in rec.iter().enumerate() {
        ans[(n - 1) as usize] = i + 1;
    }
    for i in ans {
        writeln!(out, "{} ", i).unwrap();
    }
}


Measured memory_bytes: 7036
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    h, w = map(int, input().split())
    # 整数 N 個 (改行区切り)
    S = [list(input()) for i in range(h)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    for i in range(h):
        for j in range(w):
            if S[i][j] == "#":
                continue
            else:
                cnt = 0
                for s in range(i-1, i+2):
                    if s >= 0 and s <= h-1:
                        for t in range(j - 1, j + 2):
                            if t >= 0 and t <= w-1:
                                if S[s][t] == "#" and (s != i or t != j):
                                    cnt += 1
                S[i][j] = str(cnt)

    for a in range (h):
        print("".join(S[a]))


resolve()

Measured memory_bytes: 41456
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 50;
int main()
{
  int n,k,tv,tm,t,i,j,ii,res=0;
  int v[N_MAX],m[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++)
    cin >> v[i];
  for(i=0;i<=n;i++)
    for(j=0;j<=n-i;j++){
      if(i+j>k)
        break;
      tv=0;
      tm=0;
      for(ii=0;ii<n;ii++){
        if(ii>=i&&ii<n-j)
          continue;
        tv+=v[ii];
        if(v[ii]<0){
          m[tm]=v[ii];
          tm++;
        }
      }
      sort(m,m+tm);
      for(ii=0;ii<min(k-(i+j),tm);ii++)
        tv-=m[ii];
      res=max(res,tv);
    }
  cout << res << endl;
  return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;


int main(void){
	int a,b,c,d;
    cin >> a >> b >> c >> d;

    if (abs(a-b) <= d and abs(b-c) <= d){
        puts("Yes");
        return 0;
    }

    if(abs(a-c) <= d){
        puts("Yes");
        return 0;
    }

    puts("No");
    return 0;

}


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

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;

const int maxn = (int) 2e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 

#define inf mod

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        
    
int n, a[maxn], b[maxn], dp[maxn], t[maxn];
void upd(int pos, int val){
  for(; pos < maxn; pos = (pos | (pos + 1)))
    t[pos] = max(t[pos], val);
}
int get(int r){
  int res = 0;
  for(; r >= 0; r = (r & (r + 1)) - 1)
    res = max(res, t[r]);
  return res;
}
main () {
  cin >> n;
  forn(i, 1, n) cin >> a[i];
  forn(i, 1, n) cin >> b[i];
  forn(i, 1, n){
    dp[i] = get(a[i]) + b[i];  
    upd(a[i], dp[i]);
  }
  cout << *max_element(dp + 1, dp + n + 1);

}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,c;
  cin>>N;
  a=N/100;
  b=(N-a*100)/10;
  c=(N-a*100-b*10);
  if(a==7||b==7||c==7)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a + b == 15) {
		printf("+\n");
	}
	else if(a*b ==15){
		printf("*\n");
	}
	else {
		printf("x\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
main(){
  int n,a,b,c,d,i,j,k,x[100];
  char ev[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    a=0;
    b=0;
    c=0;
    d=0;
    while(1){
      if(a == 3)break;
      scanf("%s",ev);
      if(strcmp(ev,"OUT")==0){
	a++;
      }
      else if(strcmp(ev,"HIT")==0){
	b++;
	if(b > 3){
	  c++;
	  b--;
	}
      }
      else if(strcmp(ev,"HOMERUN")==0){
	c = b+1;
	b = 0;
      }
      d = d+c;
      c = 0;
    }
    x[i] = d;
  }
  for(j=0;j<n;j++){
    printf("%d\n",x[j]);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/

bool check(string a)
{
	int ize = a.size() / 2;
	int q = a.size() % 2;
	if (q == 1) {
		return 0;
	}
	string s = a.substr(0, ize);
	string t = a.substr(ize, ize);
	if (s == t) {
		return 1;
	} else {
		return 0;
	}
}

int main()
{
	cin >> s;
	while (1) {
		s.pop_back();
		if (check(s)) {
			cout << s.size() << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//C++ as C#
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int main()
{
	int h = read(), w = read();
	int columnAccum[2000] = {};
	int rowMax[2000] = {};
	int max = 0;
	for (int i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (int j = 0; j < w; j++)
		{
			if (getchar_unlocked() & 1)
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (int k = j - 1; k >= j - currentChain; k--)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else 
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		for (int j = w - 1; j >= w - currentChain; j--)
			rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
	int p[3];
	int k;
	for(int i=0;i<3;i++){
		cin >> p[i];
	}
	cin >> k;
	sort(p,p+3); 
	cout << pow(2,k)*p[2] + p[1] + p[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int r_, int l_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int calc(int x) {
  int res = 1;
  while (x >= 10) {
    x /= 10;
    res *= 10;
  }
  return res;
}

int main() {
  const int N = scan<int>();
  long long count[10][10] = {};
  for (int i: frep(1, N + 1)) {
    count[i / calc(i)][i % 10]++;
  }
  long long ans = 0;
  for (int i: frep(1, 10)) {
    for (int j: frep(1, 10)) {
      ans += count[i][j] * count[j][i];
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

i, j = 0, 1
count = 0
if N == 1:
  print(1)
else:
  while j < N:
    if j < N-1:
      if S[i] == S[j]:
        j += 1
      elif S[i] != S[j]:
        count += 1
        i = j
        j += 1
    elif j == N-1:
      if S[i] == S[j]:
        count += 1
      elif S[i] != S[j]:
        count += 2
      break
  print(count)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const int N=20005;
int a[N],b[N],p[N];
int main (){
	int n;scanf ("%d",&n);
	for (int i=1;i<=n;i++) scanf ("%d",&p[i]);
	for (int i=1;i<=n;i++) a[i]=a[i-1]+20005;
	for (int i=n;i>=1;i--) b[i]=b[i+1]+20005;
	for (int i=1;i<=n;i++)
		a[p[i]]-=(n-i+1);
	for (int i=1;i<=n;i++) printf ("%d ",a[i]);
	puts("");
	for (int i=1;i<=n;i++) printf ("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 896
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t H, W;
int32_t neighbours[][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

bool IsValid(const Pair &p) {
  return p.first >= 0 && p.first < H && p.second >= 0 && p.second < W;
}

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

  cin >> H >> W;
  vector<string> S(H);
  for (int32_t i = 0; i < H; ++i) {
    cin >> S[i];
  }
  for (int32_t i = 0; i < H; ++i) {
    for (int32_t j = 0; j < W; ++j) {
      if (S[i].c_str()[j] == '.') {
        int32_t sum = 0;
        for (const auto &neighbour : neighbours) {
          const Pair n = Pair(i + neighbour[0], j + neighbour[1]);
          if (IsValid(n)) {
            if (S[n.first].c_str()[n.second] == '#') {
              ++sum;
            }
          }
        }
        cout << sum;
      } else {
        cout << "#";
      }
    }
    cout << endl;
  }
  return 0;
}


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

int main() {
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++) cin >> b.at(i);
    int a;
    int sum;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        sum = 0;
        for (int j = 0; j < m; j++) {
            cin >> a;
            sum += a * b.at(j);
        }
        sum += c;
        if (sum > 0) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for (char i = '0' ; i <= '9'; i++) {
        for (char j = '0'; j <= '9'; j++) {
            for (char k = '0'; k <= '9'; ++k) {
                vector<char> temp = {i, j , k};
                int a = 0;
                for (char c : S) {
                    if (temp[a] == c) ++a;
                    if (a == 3) {
                        ++ans;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

bool valid(int N){
    int digit = N % 10;
    N /= 10;
    while(N > 0){
        int temp = N % 10;
        if(temp != digit-1) return false;
        N /= 10;
        digit--;
    }
    return true;
}

int main(void){
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    int ans = -1;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            int temp = A[i]*A[j];
            if(valid(temp)) ans = max(ans, temp);
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int maxn = 1000000 + 10;
const ll mod = 1000000000 + 7;

map<string, int> mp;
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

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

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

int n,x,ans,f[10005];

int main() {
	n=rd(),f[0]=1;
	For (i,1,n) {
		x=rd();
		Dep (i,10000,x) f[i]|=f[i-x];
	}
	Dep (i,10000,0) if (i%10!=0 && f[i]) { ans=i; break; }
	printf("%d\n",ans);
}






Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]

b=[list(map(int,input().split())) for _ in range(m)]

for i in range(n):
    c = 0
    for j in range(m):
        c+=a[i][j]*b[j][0]
    print(c)


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

int main() {
	int x;
	cin >> x;
	int out = 1;
	for(int i = 2; i < x; i++){
		if(x < i * i) break;
		int num = i;
		while(x > num){
			num *= i;
		}
		out = max(out, x < num ? num / i : num);
	}
	cout << out << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdlib>
#include<math.h>
using namespace std;

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

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int arr[n];
	int ret = 0;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		ret^=arr[i];
	}
	for(int i=0; i<n; i++){
		cout<<(ret^arr[i])<<" ";
	}
}

Measured memory_bytes: 3936
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
#define endl "\n"
typedef long long Int;
int main() {
    Int a,b,c;
    cin>>a>>b>>c;
    Int ans;
    ans = b+min(c,a+b+1);
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

const ll INF = 1e17;

int n, m;
ll x[1005], y[1005], z[1005];

int judge(ll cv, ll nv, int bit) {
    if (cv != nv) return cv > nv;
    else return bit;
}

ll calc(ll p, ll q, ll r) {
    return abs(p) + abs(q) + abs(r);
}

ll solve(int mask) {
    vector<ll> sum(n, 0);
    for (int i = 0; i < n; i++) {
        ll hoge = 0;
        if (mask & 1) hoge -= x[i];
        else hoge += x[i];

        if (mask & 2) hoge -= y[i];
        else hoge += y[i];

        if (mask & 4) hoge -= z[i];
        else hoge += z[i];

        sum[i] = hoge;
    }
    sort(sum.rbegin(), sum.rend());
    ll ans = 0;
    for (int i = 0; i < m; i++) ans += sum[i];
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for (int mask = 0; mask < 8; mask++) {
        ans = max(ans, solve(mask));
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    string s;
    cin >> s;
    ll L = s.size();
    char center_char = s[L/2];
    ll count = 0;
        
    if(L%2==0){
        // 真ん中から両端へ
        FOR(i, 0, L/2){
            ll r = L/2 + i;
            ll l = L/2 - 1 - i;
            char right = s[r];
            char left = s[l];
            if(right==left && right==center_char){
                count++;
            }else{
                break;
            }
        }
        p(L/2 + count);
    }
    else{
        ll N = (L-1)/2;
        ll K = L/2 + 1; // 絶対に達成できるK
        FOR(i, 1, N+1){
            ll r = L/2 + i;
            ll l = L/2 - i;
            char right = s[r];
            char left = s[l];
            if(right == left && right==center_char){
                count++;
            }else{
                break;
            }
        }    
        p(K+count);
    }

    
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VEC;

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

  string st1;cin>>st1;
  set<string> said{st1};
  char prech = st1.back();
  REP(i,N-1) {
    string st;cin>>st;
    // 同じ単語を言ってるか、最後と違う文字
    if (said.find(st)!=said.end() || prech != st.front()) {
      OUT("No");
      return 0;
    }
    said.insert(st);
    prech = st.back();
  }
  OUT("Yes");

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>

using namespace std;

int main(void) {

	int q, x;
	char com[20];

	list<int> v;

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L')
			v.pop_back();
		else if (com[6] == 'F')
			v.pop_front();
		else if (com[0] == 'd') {
			scanf("%d", &x);
			for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
				if (*it == x) {
					v.erase(it);
					break;
				}
			}
		}
	}

	int i = 0;
	for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
		if (i++) printf(" ");
		printf("%d", *it);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 34360
import math
import itertools
def gcd(x,y,z):
    xy = math.gcd(x,y)
    xyz = math.gcd(xy,z)
    return xyz
k1 = int(input())
k = list(range(1,k1+1))
l = []
for i in itertools.combinations_with_replacement(k,3):
    l.append(i)
num = 0
for h in l:
    t = gcd(h[0],h[1],h[2])
    if h[0] == h[1] == h[2]:
        num += t
    elif h[0] == h[1] or h[1] == h[2] or h[2] == h[0]:
        num += 3*t
    else:
        num += 6*t
print(num)    

Measured memory_bytes: 105272
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;

const int maxn = 1000 + 10;
struct Node {
	ll x, y, z;
} node[maxn];
int i, j, k;
bool cmp(const Node& a, const Node& b) {
	return (a.x * i + a.y * j + a.z * k) > (b.x * i + b.y * j + b.z * k);
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	ll ans = 0;
	for (int f = 1; f <= n; f++) scanf("%lld%lld%lld", &node[f].x, &node[f].y, &node[f].z);
	for (i = -1; i <= 1; i += 2) {
		for (j = -1; j <= 1; j += 2) {
			for (k = -1; k <= 1; k += 2) {
				sort(node + 1, node + n + 1, cmp);
				ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
				for (int f = 1; f <= m; f++) {
					cnt1 += node[f].x;
					cnt2 += node[f].y;
					cnt3 += node[f].z;
				}
				ans = max(ans, cnt1 * i + cnt2 * j + cnt3 * k);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,a[60],b[60],c[60],i,r=0,d[20],l;
  scanf("%d",&n);
  for(i=n;i;i/=2)r++;
  l=r;//printf("%d\n",r);
  for(i=n;i;i/=2)d[--r]=i%2;
  //for(i=0;i<l;i++)printf("%d",d[i]);printf("\n");
  r=0;
  for(i=1;i<l;i++){
    a[r  ]=a[r+1]=i+0;
    b[r  ]=b[r+1]=i+1;
    c[r++]=1<<(l-i-1);
    c[r++]=0;
  }
  n=1<<(l-1);
  for(i=1;i<l;i++){
    if(d[i]){
      a[r  ]=1;
      b[r  ]=i+1;
      c[r++]=n;
      n+=1<<(l-i-1);
    }
  }
  printf("%d %d\n",l,r);
  for(i=0;i<r;i++)printf("%d %d %d\n",a[i],b[i],c[i]);
  return 0;
}


Measured memory_bytes: 128
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	ll k,a,b;
	cin>>k>>a>>b;
	if(a+1>=b)cout<<k+1<<endl;
	else{
		if(1+k<a)cout<<k+1<<endl;
		else{
			ll tmp=k-(a-1);
			cout<<a+tmp/2*(b-a)+(tmp&1)<<endl;
		}
	}
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

using namespace std;
using ll = long long;

int main() {
  ll a[5],k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  bool res =false;
  for (int i = 0; i < 5; ++i) {
    for (int j = i; j < 5; ++j) {
      if(abs(a[i]-a[j])>k) {
        res = true;
        break;
      }
    }
    if(res)
      break;
  }
  if(res)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  600005

// segment tree for minimum
vi a(N),seg(4*N);

void update(ll n,ll l,ll r,ll idx,ll val)
{
    if(l==r)
    {
        a[idx]=max(val,a[idx]);
        seg[n]=max(val,a[idx]);
        return;
    }
    ll mid=(l+r)>>1;
    if(l<=idx&&idx<=mid)
        update(2*n,l,mid,idx,val);
    else
        update(2*n+1,mid+1,r,idx,val);
    seg[n]=max(seg[2*n],seg[2*n+1]);
}
ll query(ll n,ll l,ll r,ll low,ll high)
{
    if(l>high||low>r)
        return 0;
    if(low<=l&&r<=high)
        return seg[n];
    ll mid=(l+r)>>1;
    return max(query(2*n,l,mid,low,high),query(2*n+1,mid+1,r,low,high));
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll m=N-1;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        x++;
        ll l=max(1ll,x-k),r=x+k;
        ll q=query(1,1,m,l,r);
        update(1,1,m,x,q+1);
    }
    cout<<query(1,1,m,1,m)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 26652
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	int INF = 1 << 28;
	double EPS = 1e-9;

	int m,n;
	int[][] a;
	int x0,y0;
	
	void run() {
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			a=new int[n][m];
			for(int j=0;j<n;j++){
				String s=sc.next();
				for(int i=0;i<m;i++){
					if(s.charAt(i)=='@'){
						x0=i;
						y0=j;
					}else if(s.charAt(i)=='#'){
						a[j][i]=1;
					}
				}
			}
			solve();
		}
	}

	void solve() {
		LinkedList<P> que=new LinkedList<P>();
		boolean[][] visited=new boolean[n][m];
		int ans=0;
		
		que.offer(new P(x0,y0));
		visited[y0][x0]=true;
		
		int[] dx={0,0,-1,1};
		int[] dy={-1,1,0,0};
		
		for(;!que.isEmpty();){
			P p=que.poll();
			ans++;
			for(int i=0;i<4;i++){
				P q=new P(p.x+dx[i],p.y+dy[i]);
				if(q.x>=0&&q.x<m&&q.y>=0&&q.y<n&&a[q.y][q.x]==0&&!visited[q.y][q.x]){
					que.offer(q);
					visited[q.y][q.x]=true;
				}
			}
		}
		println(ans+"");
	}
	
	class P{
		int x,y;
		P(int x,int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s) {
		System.out.print(s);
	}

	void println(String s) {
		System.out.println(s);
	}

	public static void main(String[] args) {
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

int main(int argc, char** argv) {
	cin>>n;
	ll i, j, fz, fm;
	for(i=1;i<=3500;i++) {
		for(j=1;j<=3500;j++) {
			fz = 4 * i * j - n * j - n * i;
			if(fz <= 0)continue;
			fm = n * i * j;
			if(fm % fz == 0)goto ed;
		}
	}
	ed:
	cout<<i<<" "<<j<<" "<<fm / fz<<endl;
	return 0;
}

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

using namespace std;
const int MAXN=3030;
int dp[MAXN][MAXN],l1,l2;

char s1[MAXN] , s2[MAXN];

void output(int x,int y)
{
	if( !x || !y ) return ;
	
	if(s1[x]==s2[y])
	{
		output( x-1 , y-1 );
		cout<<s1[x];
	}
	else 
	{
		if(dp[x-1][y]>dp[x][y-1])
			output(x-1,y);
		else 
			output(x,y-1);
	}
}

int main()
{
	scanf("%s",s1+1);
	scanf("%s",s2+1);
	l1=strlen(s1+1);l2=strlen(s2+1);

	for(int i=1;i<=l1;++i)
		for(int j=1;j<=l2;++j)
		{
			if(s1[i]==s2[j])
				dp[i][j]=dp[i-1][j-1]+1;
			else 
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);	
		}
	
	output(l1,l2); 
	
	return 0;
}


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

int main() {
    string n;
    cin >> n;
    if(n.at(0) == n.at(1) && n.at(1) == n.at(2))
        cout << "Yes" << endl;
    else if(n.at(1) == n.at(2) && n.at(2) == n.at(3)) 
        cout << "Yes" << endl;   
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    n -= k;
    if(n < 0) cout << 1 << endl;
    else if(n == 0) cout << 0 << endl;
    else if(k == 1) cout << 0 << endl;
    else
    {
        int a = 1, b = 1;
        a += n;
        cout << abs(a - b) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def dfs(v, p, c):
    color[v] = c
    for e in graph[v]:
        if e[0] == p: continue
        if e[1] % 2: dfs(e[0], v, 1-c)
        else: dfs(e[0], v, c)


n = int(input())
color = [-1 for _ in range(n)]
graph = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = [int(x) for x in input().split()]
    u, v = u - 1, v - 1
    graph[u].append((v, w))
    graph[v].append((u, w))

dfs(0, -1, 1)
for i in range(n):
    print(color[i])

Measured memory_bytes: 79320
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int Mx(int a,int b){return a>b?a:b;}
int Mn(int a,int b){return a<b?a:b;}
const int N=10,INF=4000;
int n,l[N],nl[3],p[3][N],t[3],r[3],ans;
void dfs2(int cr,int fx,int len,int c)
{
  if(cr>t[fx])
    {
      if(!len)return;
      c+=(len>nl[fx]?len-nl[fx]:nl[fx]-len);
      r[fx]=Mn(r[fx],c-10); return; // -10
    }
  dfs2(cr+1,fx,len+l[p[fx][cr]],c+10);
  dfs2(cr+1,fx,len,c);
}
void dfs1(int cr)
{
  if(cr>n)
    {
      int ret=0;
      for(int i=0;i<=2;i++)
	{
	  r[i]=INF;dfs2(1,i,0,0);
	  ret+=r[i];
	}
      ans=Mn(ans,ret); return;
    }
  for(int i=0;i<=2;i++)
    {
      p[i][++t[i]]=cr;dfs1(cr+1);
      t[i]--;
    }
}
int main()
{
  scanf("%d%d%d%d",&n,&nl[0],&nl[1],&nl[2]);
  for(int i=1;i<=n;i++)scanf("%d",&l[i]);
  ans=INF; dfs1(1);
  printf("%d\n",ans);
  return 0;
}


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

bool is_prime(const unsigned n){
    switch(n) {
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された

    if(n % 2 == 0) return false;

    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i = 3; i * i <= n; i += 2) {
        if(n % i == 0) return false;
    }

    return true;
}

int main() {
  int x;
  cin >> x;
  for(int i = x; i < 1000000; ++i){
    if(is_prime(i)){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
       int main()
 {   int n,h;
     cin>>h;
     cin>>n;
     vector<int>human;
     int temp;
     for(int i=0;i<n;i++)
     {   
         cin>>temp;
         human.push_back(temp);
     }
   int sum=0;
    for(auto x:human)
    {
        sum=sum+x;
    }
 
   if(sum>=h)
     cout<<"Yes"<<endl;
     else
     {
         cout<<"No"<<endl;
     }
  return 0;   
 }

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

int main()
{
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
m = max(l)
# 一番長い辺が他の N−1 辺の長さの合計よりも真に短い場合に限り
# 条件を満たす N 角形が描ける。
if m < sum(l)-m:
    print('Yes')
else:
    print('No')

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	int ans = 1001001001;
	rep(i, n - k + 1) {
		int tmp = h[i + k - 1] - h[i];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 2 <= n <= 10^5, 1 <= k <= 100
  h <- V.fromListN n . map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= hi <= 10^4
  let dp = V.create $ do
        dp <- VM.new n
        VM.write dp 0 0
        forM_ [1..n-1] $ \i -> do
          c <- forM [max 0 (i-k)..i-1] $ \j -> do
            c <- VM.read dp j
            return (c + abs (h V.! i - h V.! j))
          VM.write dp i (minimum c)
        return dp
  print (V.last dp :: Int)


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll dp[100010];

int main()
{
    int n; cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    rep(i, 100010) dp[i] = INF;
    dp[0] = 0;
    rep(i, n)
    {
        if (i + 1 < n) chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        if (i + 2 < n) chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
        // if (i == 2)
        // {
        //     COUT(dp[i + 1]);
        //     COUT(h[i]);
        //     COUT(h[i + 1]);
        //     COUT(dp[i + 2]);
        //     COUT(h[i + 2]);
        // }
        // if (i == 3)
        // {
        //     COUT(dp[i + 1]);
        //     COUT(h[i]);
        //     COUT(h[i + 1]);
        //     COUT(dp[i + 2]);
        //     COUT(h[i + 2]);
        // }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    N, P = map(int, input().split())
    res = prime_factorize(P)
    ans = 1
    for x, ex in res:
        ans *= max(1, x ** (ex // N))
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38512
import Control.Applicative

-- Top, Front, Right. Back, Left, Bottom
-- X: Right-Left, Y: Front-Back, Z: Top-Bottom
type Dice a = (a,a,a,a,a,a)

rollPX :: Dice a -> Dice a
rollPX (tp,fr,rg,bk,lf,bt) = (fr,bt,rg,tp,lf,bk)

rollNX :: Dice a -> Dice a
rollNX (tp,fr,rg,bk,lf,bt) = (bk,tp,rg,bt,lf,fr)

rollPY :: Dice a -> Dice a
rollPY (tp,fr,rg,bk,lf,bt) = (lf,fr,tp,bk,bt,rg)

rollNY :: Dice a -> Dice a
rollNY (tp,fr,rg,bk,lf,bt) = (rg,fr,bt,bk,tp,lf)

rollPZ :: Dice a -> Dice a
rollPZ (tp,fr,rg,bk,lf,bt) = (tp,rg,bk,lf,fr,bt)

rollNZ :: Dice a -> Dice a
rollNZ (tp,fr,rg,bk,lf,bt) = (tp,lf,fr,rg,bk,bt)

rollX :: Int -> Dice a -> Dice a
rollX n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPX)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNX))

rollY :: Int -> Dice a -> Dice a
rollY n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPY)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNY))

rollZ :: Int -> Dice a -> Dice a
rollZ n = if n >= 0 then (foldl (.) id (replicate (n `mod` 4) rollPZ)) else (foldl (.) id (replicate ((-n) `mod` 4) rollNZ))

main = do
  [d1,d2,d3,d4,d5,d6] <- map read . words <$> getLine :: IO [Int]
  s <- getLine

  let
    dice = (d1,d5,d3,d2,d4,d6)
    rotate = foldl (.) id $ (flip map) (reverse s) $ \c -> case c of
                                    'S' -> rollPX
                                    'N' -> rollNX
                                    'E' -> rollPY
                                    'W' -> rollNY

    (top,_,_,_,_,_) = rotate dice

  print top



Measured memory_bytes: 3648
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   int a[60],b[60],c[60];
   cin >> n;
   rep(i,n) cin >> a[i];
   rep(i,n) cin >> b[i];
   rep(i,n-1) cin >> c[i];

   int ans = 0;
   rep(i,n){
      ans += b[a[i]-1];
      if((a[i]+1) == a[i+1]) ans += c[a[i]-1];
   }

   cout << ans << endl;


   return 0;
}

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


void solve(long long N){
    long long n = N % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
        return;
    } else if (n == 3) {
        cout << "bon" << endl;
        return;
    } else {
        cout << "pon" << endl;
        return;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
import fractions
n = int(input())
a = list(map(int, input().split()))
f = [0] * n
r = [0] * n
for i in range(n):
    if i == 0:
        f[i] = a[i]
        r[-i-1] = a[-i-1]
    else:
        f[i] = fractions.gcd(f[i-1], a[i])
        r[-i-1] = fractions.gcd(r[-i], a[-i-1])
f.insert(0, 0)
r.append(0)
ans = 0
for i in range(len(f) - 1):
    ans = max(ans, fractions.gcd(f[i], r[i+1]))
print(ans)


Measured memory_bytes: 16124
#include <iostream>
#include <string>
#include <queue>
#include <set>
using namespace std;

class Node{
public:
  int ax;
  int ay;
  int bx;
  int by;
  int p;

  int cost;
  Node(int ax, int ay, int bx, int by, int p, int cost)
    : ax(ax), ay(ay), bx(bx), by(by), p(p), cost(cost) { }
  bool operator <(const Node &N) const{
    if(ax != N.ax) return ax < N.ax;
    if(ay != N.ay) return ay < N.ay;
    if(bx != N.bx) return bx < N.bx;
    if(by != N.by) return by < N.by;
    if(p != N.p) return p < N.p;
    return false;
  }
};

int main() {
  while(1) {
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    char data[H][W];
    Node N(0,0,0,0,0,0);
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
	cin >> data[i][j];
	if(data[i][j] == 'A') {
	  N.ax = j;
	  N.ay = i;
	  data[i][j] = '.';
	}
	if(data[i][j] == 'B') {
	  N.bx = j;
	  N.by = i;
	  data[i][j] = '.';
	}
      }
    }

    string pat;
    cin >> pat;

    queue<Node> Q;
    Q.push(N);
    set<Node> visited;
    visited.insert(N);
    int d[5][2] = {{0,0},{0,-1},{1,0},{-1,0},{0,1}};

    int ansX, ansY, ansCost;
    ansX = ansY = ansCost = -1;

    while(!Q.empty()) {
      N = Q.front();
      Q.pop();

      if(N.ax == N.bx && N.ay == N.by) {
	ansX = N.ax;
	ansY = N.ay;
	ansCost = N.cost;
	break;
      }

      Node newN(0,0,0,0, (N.p+1)%pat.length(), N.cost + 1);

      int bd = -1;

      switch(pat[N.p]) {
      case '5':bd = 0; break;
      case '8':bd = 1; break;
      case '6':bd = 2; break;
      case '4':bd = 3; break;
      case '2':bd = 4; break;
      }

      newN.bx = N.bx + d[bd][0];
      newN.by = N.by + d[bd][1];
      if(newN.bx < 0 || newN.bx >= W) newN.bx = N.bx;
      if(newN.by < 0 || newN.by >= H) newN.by = N.by;

      for(int i = 0; i < 5; i++) {
	newN.ax = N.ax + d[i][0];
	newN.ay = N.ay + d[i][1];
	if(newN.ax < 0 || newN.ax >= W) newN.ax = N.ax;
	if(newN.ay < 0 || newN.ay >= H) newN.ay = N.ay;
	if(data[newN.ay][newN.ax] == '#') {
	  newN.ax = N.ax;
	  newN.ay = N.ay;
	}
	if(visited.find(newN) != visited.end()) continue;
	visited.insert(newN);
	Q.push(newN);
      }
    }
    if(ansX != -1 && ansY != -1 && ansCost != -1) {
      cout << ansCost << " " << ansY << " " << ansX << endl;
    } else {
      cout << "impossible" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2564