akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N, K;
int l[50];
int ans = 0;

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> l[i];
    
    sort(l, l + N, greater<int>());
    for (int i = 0; i < K; i++) ans += l[i];
    
    cout << ans << endl;
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int a[200020];

map<int, int> mp;

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>a[i];

	for (int i = 0; i < n; i++) mp[a[i]]++;

	for (int i = 0; i < n; i++) {
		mp[a[i]]--;

		auto ite = mp.end(); --ite;

		if (ite->second == 0) --ite;
		cout<< ite->first <<endl;

		mp[a[i]]++;
	}
	
	return 0;
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long X){
  if(A <= X && X<=A+B){
    cout << YES << "\n";
  }else{
    cout << NO << "\n";
  }
}

// Generated by 1.1.4 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 A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long X;
  scanf("%lld",&X);
  solve(A, B, X);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }

        int minCost = Integer.MAX_VALUE;
        for (int i = -100; i <= 100; i++) {
            int num = i;
            int cost = 0;
            for (int j = 0; j < n; j++) {
                if (as[j] != num) {
                    cost += (num - as[j]) * (num - as[j]);
                }
            }
            minCost = Math.min(minCost, cost);
        }
        System.out.println(minCost);
    }
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n; i++) a[i] = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i = 0 ; i < n ; i++) {
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		List<Entry<Integer, Integer>> entry = new ArrayList<>(map.entrySet());
		Collections.sort(entry, new Comparator<Entry<Integer, Integer>>() {
			public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2) {
				if(obj1.getValue() >= 2 && obj2.getValue() >= 2) return obj2.getKey() - obj1.getKey();
				else return obj2.getValue() - obj1.getValue();
			}
		});
		if(entry.get(0).getValue() >= 4) {
			System.out.println(1L * entry.get(0).getKey() * entry.get(0).getKey());
		} else if(entry.get(0).getValue() >= 2 && entry.get(1).getValue() >= 2) {
			System.out.println(1L * entry.get(0).getKey() * entry.get(1).getKey());
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 55148
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM 
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n, k;
int main() {
	read(n, k);
	if(k == 1) cout << 0 << endl;
	else cout << n - k << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[i*(i-1)//2 for i in range(2,450)]
if n in l:
  print('Yes')
  k=l.index(n)+1
  print(k+1)
  x=[[k] for _ in range(k+1)]
  p=1
  for i in range(k):
    for j in range(k-i):
      x[i].append(p+j)
      x[i+j+1].append(p+j)
    p=p+k-i
  for i in x:
    print(*i)
else:
  print('No')

Measured memory_bytes: 12688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    int A[n];
    for (int i = 0; i < n; i++) sc(A[i])
    bool inv;
    if (n % 2 == 0) inv = true;
    else inv = false;
    list<int> ls;
    ls.push_front(A[0]);
    for (int i = 1; i < n; i++){
        if (inv){
            ls.push_front(A[i]);
            inv = false;
        }else {
            ls .push_back(A[i]);
            inv = true;
        }
    }
    for (auto it = ls.begin(); it != ls.end(); it++){
        if (it == ls.begin()) cout << *it;
        else cout << " " << *it;
    }
    cout << endl;
    return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int a,b;
    cin>>a>>b;
    if(a%b==0) cout<<-1<<endl;
    else cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin >> n >>m;
    int ncr = ((n+m)*(n+m-1))/2;
    int ncr_n = ((n)*(n-1))/2;
    int ncr_m = ((m)*(m-1))/2;
    int ans = ncr_n + ncr_m;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl G(n);
    vpll vp;

    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].eb(b);
        G[b].eb(a);
        vp.eb(a, b);
    } 
    
    map<pll, ll> mp;
    vl cs(n);  // cs[i] : 頂点iとiの親を結ぶ辺の色
    vl used(n);  // used[i] : 頂点iを訪れたかどうか
    queue<ll> Q;

    Q.emplace(0);
    used[0] = 1;
    ll K = 0;

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

        if(K < G[v].size()) {
            K = G[v].size();
        }
        
        ll color = 1;
        for(auto u : G[v]) {
            if(used[u]) {
                continue;
            }
            if(color == cs[v]) {
                color++;
            }
            cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = color++;
            used[u] = 1;
            Q.emplace(u);
        }
    }

    out(K);

    for(auto p : vp) {
        out(mp[p]);
    }

    re0;
}

Measured memory_bytes: 22128
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, m) = scan!(i64, usize);
    let mut likes = vec![true; m];
    for _ in 0..n {
        let v = scan!(i64;;);
        for i in 1..(m + 1) {
            match v[1..].iter().find(|&x| *x == (i as i64)) {
                None => likes[i - 1] = false,
                Some(_) => (),
            }
        }
    }
    let mut ans = 0;
    for &v in likes.iter() {
        if v {
            ans += 1
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  a,b = 0,0
  # 4, 2で分ける
  for x in map(int,input().split()):
    if x % 4 == 0:
      a += 1
    elif x % 2 == 0:
      b += 1
  print('Yes' if a+b//2 >= n//2 else 'No') 
  # b // 2 によって、2の倍数が偶数個なら、それは4の倍数として使うことが出来る
  # n // 2　もし n = 6ならば...n = 3となり、数字の間に4の倍数を入れれるって分かる
  
if __name__ == '__main__':
  main()

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int h, w;
    cin >> h >> w;
    vector<string> vec(h);
    rep(i, h) { cin >> vec[i]; }

    // 処理
    vector<bool> row(h, false);
    vector<bool> colum(h, false);
    rep(i, h) {
        rep(j, w) {
            if (vec[i][j] == '#') {
                row[i]   = true;
                colum[j] = true;
            }
        }
    }
    // 出力
    rep(i, h) {
        if (row[i]) {
            rep(j, w) {
                if (colum[j]) {
                    cout << vec[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}


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

#define sc static_cast

int main()
{
    int N;
    long M;
    cin >> N >> M;
    int *A = new int[N];
    int *X = new int[N];
    long long *S = new long long[N+1];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A, A + N);
    for(int i=0;i<N;i++){
        S[i+1] = S[i] + sc<long long>(A[N-1-i]);
    }
    int l = A[0] * 2, r = A[N - 1] * 2;
    long shake;
    int mid = (l + r) / 2, oldmid=0;
    while (oldmid!=mid)
    {
        oldmid = mid;
        shake = 0L;
        int y = N - 1;
        for (int x = 0; x < N; x++)
        {
            if(y < 0){
                shake += sc<long>(N);
                X[x] = N;
                continue;
            }
            while (A[y] >= mid - A[x])
            {
                y--;
                if (y < 0)
                {
                    X[x] = 0;
                    break;
                }
            }
            shake += sc<long>(N - y - 1);
            X[x] = N - y - 1;
        }
        if (shake < M)
        {
            r = mid;
        }
        else
        {
            if (shake > M)
            {
                l = mid;
            }
            else
            {
                break;
            }
        }
        mid = (l + r) / 2;
    }

    long long remind = sc<long long>(mid) * sc<long long>(shake - M);
    long long sum = 0;
    for(int i=0;i<N;i++){
        sum += sc<long long>(A[i]) * sc<long long>(X[i]) + S[X[i]];
    }

    cout << sum - remind << "\n";

    return 0;
}


Measured memory_bytes: 1792
n,k = map(int,input().split())
x = [i for i in range(n+2) if i % 2 == 1]
for i in range(len(x)):
    if x[i] >=100:
        x.pop(i)

if int(len(x)) >= k:
    print("YES")
else:
    print("NO")

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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  int k=min(d,e);

 int cnt=0;
  
int g=min(a+b,2*c);
  cnt +=k*g;
  int l=abs(d-e);
  if(d>=e){
  if(a >=2*c){
  cnt +=l*2*c;
  
  }
   else{
   cnt +=l*a;}
  }
  else{
    if(b >=2*c)cnt +=l*2*c;
  else{cnt += l*b;}
}
  cout <<cnt <<endl;
}

Measured memory_bytes: 3560
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	//n := r.nextInt()
	r.Scan(true)
	a := r.nextStringArray().toInts()

	s := 0
	mp := make(map[int]int, 1E5)
	for _, ai := range a {
		mp[ai]++
		s += ai
	}

	r.Scan(false)
	q := r.nextInt()
	for i := 1; i <= q; i++ {
		r.Scan(true)
		b, c := r.nextInt(), r.nextInt()
		s += (c - b) * mp[b]
		fmt.Fprintln(stdout, s)
		mp[c] += mp[b]
		mp[b] = 0
	}

}


Measured memory_bytes: 13320
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> v(h);
  for (int i = 0; i < h; i++)
    cin >> v[i];

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (v[i][j] == '.') {
        int c = '0';
        for (int k = 0; k < 8; k++) {
          if (0 <= i + dy[k] && i + dy[k] < h && 0 <= j + dx[k]
              && j + dx[k] < w) {
            if (v[i + dy[k]][j + dx[k]] == '#')
              c++;
          }
        }
        v[i][j] = c;
      }
    }
  }

  for (auto x : v) {
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 2e5+2;
unsigned long long nums[MAXN];
 
const long long MAXL = 1e18;
 
//判断a*b是否超过1e18
bool overflow(unsigned long long a, unsigned long long b) {
    //判断是否越界
    if (ULLONG_MAX / a < b) {
        return true;
    }
    //判断是否超过1e18
    unsigned long long ans = a*b;
    if (ans>MAXL) {
        return true;
    }
    return false;
}
 
int main() {
    int n;
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%llu", &nums[i]);
        if (0==nums[i]) {
            printf("0\n");
            return 0;
        }
    }
 
    long long ans=1;
    for (int i=0; i<n; i++) {
        if (true == overflow(ans, nums[i])) {
            printf("-1\n");
            return 0;
        }
        ans *= nums[i];
    }
 
    printf("%llu", ans);
 
    return 0;
}


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

int main() {
  long n, a, b;
  cin >> n >> a >> b;
  if ((max(a, b) - min(a, b)) % 2 == 0) {
    cout << (max(a, b) - min(a, b)) / 2;
  }
  else {
    long x = min(min(a, b) - 1, n - max(a, b));
    cout << x + 1 + (max(a, b) - min(a, b) - 1) / 2;
  }
}

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

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    string N;
    cin >> N;
    ll ans=0;
    for(char a : N){
        int b = (int)(a-'0');
        ans = (ans + b)%9;
    }
    if(ans) out("No");
    else out("Yes");
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3768
program name
    implicit none
    integer(4):: a,b
    integer(4):: i,ans

    read*, a,b

    ans=0

    do i=1,2
        if (a >= b) then
            ans=ans+a
            a=a-1
        else
            ans=ans+b
            b=b-1
        end if
    end do

    print*, ans
end program name

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(int i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    if(N<0||300<N){N=1;}
    vector<vector<ll>>DP(301,vector<ll>(90001,0));//pos,RED,set
    vector<vector<ll>>DP2(301,vector<ll>(90001,0));//pos,RED,set
    DP[0][0]=1;
    DP2[0][0]=1;
    static ll mod=998244353;
    int a;
    int sum=0;
    for(int i=1;i<=N;i++){
        cin>>a;
        sum+=a;
        for(int j=0;j<90001;j++){
            DP[i][j]+=DP[i-1][j]*2;
            if(j+a<=90000){
                DP[i][j+a]+=DP[i-1][j];
                DP2[i][j+a]+=DP2[i-1][j];
                DP[i][j+a]%=mod;
                DP2[i][j+a]%=mod;

            }
            DP2[i][j]+=DP2[i-1][j];
            DP[i][j]%=mod;
            DP2[i][j]%=mod;
        }
    }
    ll sub=1;
    for(int i=0;i<N;i++){
        sub*=3;
        sub%=mod;
    }
    for(int i=(sum+1)/2;i<90001;i++){
        sub-=3*DP[N][i];
        sub%=mod;
    }
    if(sum%2==0){
        sub+=3*DP2[N][sum/2];
        sub%=mod;
    }
    sub+=mod;
    sub%=mod;
    cout<<sub<<endl;
}

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

int main() {
int X,ans=0;
cin>>X;
if(X<0||1000000000<X){return 0;}
ans+=(X/500)*1000;
X-=(X/500)*500;
ans+=(X/5)*5;
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter as co
n,m=map(int,input().split())
a=[]
x=0
y=10**6
for i in range(m):
    l,r=map(int,input().split())
    if(l>x):
        x=l
    if(r<y):
        y=r
if(y>=x):
    print(y-x+1)
else:
    print(0)


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

long long int GCD(long long int x, long long int y) {
    if(x<y) swap(x, y);
    
    if(y==0) {
        return x;
    }
    
    return GCD(y, x%y);
}
    
int main() {
    int N;
    cin >> N;
    long long int tmp;
    cin >> tmp;
    for(int n=1; n<N; n++) {
        long long int A;
        cin >> A;
        tmp = GCD(A, tmp);
    }
    
    cout << tmp << endl;



    return 0;
    
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    a > b ? ans+= b : ans+= a;
    c > d ? ans+= d : ans+= c;

    cout << ans << endl;
}

Measured memory_bytes: 3640
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}

fn main() {
    let_all!(n: usize, m: i32);
    let mut memo = vec![0_f64; m as usize + 1];
    for _ in 0 .. n {
        let args = read_line!(' '; i32);
        let mut floor = 0_f64;
        let mut used = 0;
        let mut this_pot = vec![0_f64; m as usize + 1];
        for i in 0 .. args.len() / 2 {
            let bottom = args[i * 2 + 1];
            let height = args[i * 2 + 2];
            let space = min(m, bottom * height + used);
            for current in used .. space + 1 {
                this_pot[current as usize] = floor + (current - used) as f64 / bottom as f64;
            }
            floor += (space - used) as f64 / bottom as f64;
            used += bottom * height;
        }
        for i in 0 .. memo.len() {
            let current = memo.len() - i - 1;
            for j in 0 .. i + 1{
                if memo[current] + this_pot[j] > memo[current + j] {
                    memo[current + j] = memo[current] + this_pot[j];
                }
            }
        }
    }
    let mut max = 0_f64;
    for m in memo {
        if m > max {
            max = m;
        }
    }
    println!("{:.*}", 10, max);
}


Measured memory_bytes: 5048
$s = <>;chomp $s;

chop $s;
chop $s;
$len = length $s;
while (substr ($s, 0, $len/2 - 1) ne substr( $s, $len/2, -1)) {
    chop $s; chop $s;
    $len = length $s;
}

print length $s;


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

class bit {
private:
	vll* v;
	lli n;
public:
  bit(){}
	bit (lli n) {
		this->v = new vll(n+1);
		this->n = n;
	}
	void add(lli i,lli val){
		for(;i <= n;i += i&-i) this->v->at(i) += val;
	}
	lli sum(lli i){
		lli ret = 0;
		for(;i > 0;i -= i&-i) ret += this->v->at(i);
		return ret;
	}
};


lli n;
vll a;
bit b;
mat dp;
unordered_map<lli,lli> inv;

int main(){
  cin >> n;
  a = vll(n*2+1);
  dp = mat(n+1,vll(n+1,INT_MAX));
  b = bit(n*2+1);
  for(lli i = 1;i <= n*2;i++){
    lli x;
    char c;
    cin >> c >> x;
    if(c == 'W') a[i] = 2*x,inv[2*x]=i;
    else if(c == 'B') a[i] = 2*x-1,inv[2*x-1]=i;
  }
  dp[0][0] = 0;
  for(lli i = 0;i <= n;i++){
    if(i > 0) b.add(inv[2*i-1],1);
    for(lli j = 0;j <= n;j++){
      // if(i == 0 && j == 2){
      //   cout << inv[2*j] << endl;
      //   cout << b.sum(2*n+1) << endl;
      //   cout << b.sum(inv[2*j]) << endl;
      // }
      if(j > 0) b.add(inv[2*j],1);
      if(i > 0) dp[i][j] = min(dp[i][j],dp[i-1][j]+(b.sum(n*2+1)-b.sum(inv[2*i-1])));
      if(j > 0) dp[i][j] = min(dp[i][j],dp[i][j-1]+(b.sum(n*2+1)-b.sum(inv[2*j])));
    }
    for(lli j = 1;j <= n;j++){
      b.add(inv[2*j],-1);
    }
  }
  // for(lli i = 0;i <= n;i++){
  //   for(lli j = 0;j <= n;j++){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[n][n] << endl;


}


Measured memory_bytes: 32000
map_dict = dict()
for i in range(3):
    a1, a2, a3 = input().split()
    map_dict[a1] = 1 + i * 3
    map_dict[a2] = 2 + i * 3
    map_dict[a3] = 3 + i * 3

win_pattern = [
    (1, 2, 3),
    (4, 5, 6),
    (7, 8, 9),
    (1, 4, 7),
    (2, 5, 8),
    (3, 6, 9),
    (1, 5, 9),
    (3, 5, 7),
]
n = int(input())
scored = []
for i in range(n):
    b = input()
    try:
        scored.append(map_dict[b])
    except:
        pass
scored = set(scored)

flag = False
for pattern in win_pattern:
    if set(pattern).issubset(scored):
        print('Yes')
        flag = True
        break
if not flag:
    print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=1000000000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  ll n,m;cin>>n>>m;
  vi v(n*3,inf);
  vvi g(n*3);
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    rep(j,3)g[a*3+j].push_back((b*3)+((j+1)%3));
  }
  ll s,t;cin>>s>>t;s--;t--;
  v[s*3]=0;
  queue<ll> q;
  q.push(s*3);
  while(!q.empty()){
    ll a=q.front();
    q.pop();
    for(ll i:g[a]){
      if(v[i]==inf){
        v[i]=v[a]+1;
        q.push(i);
      }
    }
  }
  if(v[t*3]==inf)cout<<-1<<endl;
  else cout<<v[t*3]/3<<endl;
}


Measured memory_bytes: 18944
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> a(n);
    for(auto &x:a)
        cin >> x;
    
    sort(a.begin(),a.end());

    ll ans=0;
    int count=0;
    for(int i=1;i<n;i++){
        if(i%2==1){
            ans+=a.at(n-1-count);
            count++;
        }else{
            ans+=a.at(n-1-count);
        }
    }

    cout << ans << endl;

    return 0;
}


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

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


	int n;

	cin >> n;

	for(int x=n; ;x++)
	{
		bool ok = true;
		for(int j=2;j<=sqrt(x);j++)
		{
			if(x%j==0)
			{
				ok = false;
				break;
			}
		}
		if(ok)
		{
			cout << x << '\n';
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	char s,ss,sss;
	int cnt = 0;
	cin >>s>>ss>>sss;
	if(s == 'R'){
		if(ss == 'R'){
			if(sss == 'R'){
				cnt += 3;
			}else{
				cnt += 2;
			}
		}else{
			cnt += 1;
		}
	}else{
		if(ss == 'R'){
			if(sss == 'R'){
				cnt += 2;
			}else{
				cnt += 1;
			}
		}else{
			if(sss == 'R'){
				cnt += 1;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3624
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {
        class Dinam
        {
            public int Number { get; set; }
            public int[] Series { get; set; }

            public Dinam(int Number, int[] series)
            {
                this.Number = Number;
                this.Series = series;
            }
        }

        static void Main(string[] args)
        {
            List<Dinam> resultList = new List<Dinam>();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }

                int[] series = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

                int count = 0;
                while (true)
                {
                    int[] beforeSeries = (int[])series.Clone();
                    Dictionary<int, int> dict = new Dictionary<int, int>();

                    foreach (int a in series)
                    {
                        if (dict.ContainsKey(a))
                        {
                            dict[a]++;
                        }
                        else
                        {
                            dict[a] = 1;
                        }
                    }

                    series = series.Select(s => dict[s]).ToArray();

                    if (series.SequenceEqual(beforeSeries))
                    {
                        break;
                    }
                    
                    
                    count++;
                }

                resultList.Add(new Dinam(count, series));
            }

            foreach (Dinam d in resultList)
            {
                Console.WriteLine(d.Number);
                Console.WriteLine(string.Join(" ", d.Series.Select(s=> s.ToString()).ToArray()));
            }

        }
    }
}

Measured memory_bytes: 21020
import java.io.*;
import java.math.BigInteger;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    }

    static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            BigInteger[] a = new BigInteger[n];
            for (int i = 0; i < n; i++) {
                a[i] = new BigInteger(in.next());
            }
            BigInteger res = new BigInteger("1");
            for (int i = 0; i < n; i++) {
                res = res.multiply(a[i]).divide(findGcd(res, a[i]));
            }
            out.println(res);
        }

        private BigInteger findGcd(BigInteger a, BigInteger b) {
            while (b.compareTo(new BigInteger("0")) > 0) {
                BigInteger t = a.mod(b);
                a = b;
                b = t;
            }
            return a;
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23508
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
SC = [tuple(map(int,input().split())) for i in range(m)]
for i in range(1000):
  N = str(i)
  if len(N) != n: continue
  ok = True
  for s,c in SC:
    s-=1
    if int(N[s]) != c:
      ok = False
  if ok:
    print(i)
    exit()
print(-1)
    

Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) if (scanf("%d", &v)<1);
#define OUT(v) printf("%d\n", v)

int main() {
  int N;
  IN(N);

  int A[N];
  REP(i, N) {
    IN(A[i]);
  }
  sort(A, A+N);
  int min_index = 0;
  REP(i, N) {
    if (abs(A[N-1] - 2 * A[i]) < abs(A[N-1] - 2 * A[min_index]))
      min_index = i;
  }
  printf("%d %d\n", A[N-1], A[min_index]);
  return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest._900problems
{
    class MUJIN_PC_2017_A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long[] xs = ReadLongs();
            long res = 1;
            long tmp = 1;
            long mask = 1000000000 + 7;
            for(int i = 1; i < n; i++)
            {
                tmp++;
                if (xs[i] <= 2 * (tmp-1))
                {
                    res *= tmp;
                    res %= mask;
                    tmp--;
                }
            }
            res *= Permutation(tmp, tmp, mask);
            res %= mask;
            WriteLine(res);
        }

        static long Permutation(long n, long m, long mask)
        {
            long val = 1;
            for (long i = 0; i < m; i++)
            {
                val *= ((n - i) % mask);
                val %= mask;
            }
            return val;
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 20832
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // codeforces
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") // yandex

#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

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

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
	int x;
    sc(x);
    cout << ((x >= 30) ? "Yes" : "No");
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int viz[2][nmax],a[nmax],i,n,k,v;
int rec(int p,int nr)
{
	if(nr>k)return 1;
	if(viz[p][nr]!=-1)return viz[p][nr];
	//cout<<nr<<endl;
	int x=0;
	for(int i=1;i<=n;i++)x|=!rec(p^1,nr+a[i]);
	//cout<<p<<" "<<nr<<" "<<x<<endl;
	return viz[p][nr]=x;
}
int main()
{
	//freopen("cowpatibility.in","r",stdin);
	//freopen("cowpatibility.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>k;
	for(i=0;i<=k;i++)viz[0][i]=viz[1][i]=-1;
	for(i=1;i<=n;i++)cin>>a[i];
	v=rec(0,0);
	if(v)cout<<"First"<<endl;
	else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int kaibun(char *s){
    int len=strlen(s);
    char t[len+1];
    strcpy(t,s);
    int i,j;
    char tmp;
    for(i=0,j=len-1;i<len/2;i++,j--){
        tmp=t[i];
        t[i]=t[j];
        t[j]=tmp;
    }
    return strcmp(s,t);
}

int main(void)
{
    char s[100]={};
    char t[100]={};
    char u[100]={};
    scanf("%s",&s);
    int len=strlen(s);
    strncpy(t,s,(len-1)/2);
    strncpy(u,&s[(len+1)/2],(len-1)/2);
    if(kaibun(s)){
        printf("No");
    }else if(kaibun(t)){
        printf("No");
    }else if(kaibun(u)){
        printf("No");
    }else{
        printf("Yes");
    }

    return 0;
}

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

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

  LL ans;
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  FOR(i, 0, N){
    cin >> h[i];
  }

  vector<LL> cost(N, INF);
  cost[0] = 0;
  // cost[1] = abs(h[1] - h[0]);

  int start = 0;
  FOR(i, 1, N){
    if(i - K < 0){
      start = 0;
    } else {
      start = i - K;
    }

    FOR(j, start, i){
      cost[i] = min(cost[i], cost[j] + abs(h[i] - h[j]));
    }
  }

  ans = cost[N - 1];

  // FOR(i, 0, N){
  //   cout << cost[i] << " ";
  // }
  // cout << endl;

  cout << ans << '\n';

  return 0;
}

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

#define int long long
#define MAX 200005

using namespace std;
using ll = long long;

int a[MAX], b[MAX];
int sum_a[MAX], sum_b[MAX];

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

  int n, m, k;
  cin >> n >> m >> k;

  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> b[i];

  for (int i = 0; i < n; ++i) sum_a[i+1] += sum_a[i] + a[i];
  for (int i = 0; i < m; ++i) sum_b[i+1] += sum_b[i] + b[i];

  int ans = 0;

  for (int i = 0; i <= n; ++i) {
    int key = k - sum_a[i];
    if (key < 0) continue;

    int j = upper_bound(sum_b, sum_b+m+1, key) - sum_b - 1;
    
    ans = max(ans, i + j);
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 9864
#!/usr/bin/env python3
import sys 
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

d = {}
for i in range(n):
    d[i] = a[i]

d = sorted(d.items(), key=lambda x:x[1])
ans = ''
for i in range(n):
    ans += str((d[i][0]+1)) + ' ' 

print(ans)


Measured memory_bytes: 29728
#include<stdio.h>
#include<string.h>
int main(void)
{
  int stl,sum;
  char x[1000];
  for(;;){
    scanf("%s",&x);
    stl=strlen(x);
    sum=0;
    if(x[0]=='0'&&stl==1){
      break;
    }
    for(int i=0;i<stl;i++){
      sum+=x[i]-'0';
    }
    printf("%d\n",sum);
  }
  return 0;
}
       
    
    


Measured memory_bytes: 1928
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
    string s;
    cin >> s;
    int stl = s.length(), i; bool flag = 0;
    for (i = 0; i < stl; ++i) {
        if (s[i] == 'C') {flag = 1; break;}
    }
    if (!flag) { cout << "No"; return 0;}
    for (i = i + 1; i < stl; ++i) {
        if (s[i] == 'F') { cout << "Yes"; return 0;}
    }
    cout << "No";
    return 0;
    return 0;
}

Measured memory_bytes: 256